From patchwork Tue Oct 6 04:22:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ttttabcd X-Patchwork-Id: 11818049 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA29C6CA for ; Tue, 6 Oct 2020 04:22:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37D83208B6 for ; Tue, 6 Oct 2020 04:22:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="IF60/54e" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725955AbgJFEW0 (ORCPT ); Tue, 6 Oct 2020 00:22:26 -0400 Received: from mail-41104.protonmail.ch ([185.70.41.104]:55542 "EHLO mail-41104.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbgJFEW0 (ORCPT ); Tue, 6 Oct 2020 00:22:26 -0400 Received: from mail-02.mail-europe.com (mail-02.mail-europe.com [51.89.119.103]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail-41104.protonmail.ch (Postfix) with ESMTPS id AC93120021CE for ; Tue, 6 Oct 2020 04:22:23 +0000 (UTC) Authentication-Results: mail-41104.protonmail.ch; dkim=pass (1024-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="IF60/54e" Date: Tue, 06 Oct 2020 04:22:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1601958140; bh=0uL+oKdZ+kIeGKgDRmsSuusyePnfIt0hi8CQ7e378S0=; h=Date:To:From:Cc:Reply-To:Subject:From; b=IF60/54eovN4JhWjC/GAGNk93iXPz3RrokoXxvGTywJy5ILvTGTPeD/jbznsld95l 9o48p9UsgUQ3r/ugkuwhVXaSwkIc/W4sEvpaXncRjWELFUsJ9Fc2Km65RmF8+n8evB Y8KoFm8CMDRnGscI9i2u0Z2SdjfWxPnf0gIiAA3Q= To: "johannes@sipsolutions.net" From: Ttttabcd Cc: "linux-wireless@vger.kernel.org" Reply-To: Ttttabcd Subject: [PATCH] iw: Add support for specifying the 160MHz bandwidth when setting the channel/frequency Message-ID: MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HK_RANDOM_REPLYTO shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The current iw tool only supports the direct setting of [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] bandwidth when setting the channel/frequency. If we want to set the 160MHz bandwidth, we need to calculate the center frequency ourselves, which is inconvenient. E.g: iw phy phy0 set freq 5220 160 5250 From now on we can: iw phy phy0 set channel 44 160MHz iw phy phy0 set freq 5220 160MHz This is much more convenient. Signed-off-by: AK Deng --- phy.c | 8 ++++---- util.c | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) -- 2.28.0 diff --git a/phy.c b/phy.c index 716677e..2d489ef 100644 --- a/phy.c +++ b/phy.c @@ -199,13 +199,13 @@ static int handle_freq(struct nl80211_state *state, struct nl_msg *msg, } COMMAND(set, freq, - " [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n" + " [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz]\n" " [5|10|20|40|80|80+80|160] [ []]", NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_freq, "Set frequency/channel the hardware is using, including HT\n" "configuration."); COMMAND(set, freq, - " [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n" + " [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz]\n" " [5|10|20|40|80|80+80|160] [ []]", NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_freq, NULL); @@ -222,9 +222,9 @@ static int handle_chan(struct nl80211_state *state, struct nl_msg *msg, return put_chandef(msg, &chandef); } -COMMAND(set, channel, " [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]", +COMMAND(set, channel, " [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz]", NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_chan, NULL); -COMMAND(set, channel, " [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]", +COMMAND(set, channel, " [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz]", NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_chan, NULL); diff --git a/util.c b/util.c index 186e05b..647e85a 100644 --- a/util.c +++ b/util.c @@ -576,10 +576,10 @@ static int parse_freqs(struct chandef *chandef, int argc, char **argv, * user by giving "NOHT" instead. * * The working specifier if chan is set are: - * [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] + * [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz] * * And if frequency is set: - * [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] + * [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz] * [5|10|20|40|80|80+80|160] [ []] * * If the mode/channel width is not given the NOHT is assumed. @@ -619,6 +619,10 @@ int parse_freqchan(struct chandef *chandef, bool chan, int argc, char **argv, .width = NL80211_CHAN_WIDTH_80, .freq1_diff = 0, .chantype = -1 }, + { .name = "160MHz", + .width = NL80211_CHAN_WIDTH_160, + .freq1_diff = 0, + .chantype = -1 }, }; const struct chanmode *chanmode_selected = NULL; unsigned int freq; @@ -1233,6 +1237,7 @@ int get_cf1(const struct chanmode *chanmode, unsigned long freq) { unsigned int cf1 = freq, j; unsigned int vht80[] = { 5180, 5260, 5500, 5580, 5660, 5745 }; + unsigned int vht160[] = { 5180, 5500 }; switch (chanmode->width) { case NL80211_CHAN_WIDTH_80: @@ -1247,6 +1252,18 @@ int get_cf1(const struct chanmode *chanmode, unsigned long freq) cf1 = vht80[j] + 30; break; + case NL80211_CHAN_WIDTH_160: + /* setup center_freq1 */ + for (j = 0; j < ARRAY_SIZE(vht160); j++) { + if (freq >= vht160[j] && freq < vht160[j] + 160) + break; + } + + if (j == ARRAY_SIZE(vht160)) + break; + + cf1 = vht160[j] + 70; + break; default: cf1 = freq + chanmode->freq1_diff; break;