From patchwork Tue Sep 6 04:48:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 603798 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1B7CECAAA1 for ; Tue, 6 Sep 2022 04:48:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232318AbiIFEsz (ORCPT ); Tue, 6 Sep 2022 00:48:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231836AbiIFEsx (ORCPT ); Tue, 6 Sep 2022 00:48:53 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18A3B5FAD2 for ; Mon, 5 Sep 2022 21:48:47 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id b144so5428097pfb.7 for ; Mon, 05 Sep 2022 21:48:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=R4zEEzriyM2dk3bgEA5bMN8hoDe1qItJp2RwfiL+VrQ=; b=nMWPuI7nddWxuGQDuaKgrNNVgG2AKRT4nfspclQMmClH5Cg8AjQoDSEcaE0VHVcEEz kk+719msswQ0tCH7QQYTvZs28w69/KswoO45p+bsJm+a5d0IScoa6nRVtO9Yl1KNZkGI w0MOLTnAeaxE8+LpGypoZoZHi0G1NKc5Dsq4YYLlFkCnPtcyrhtno0saYEV+sYC3iIco aXz4J5S1pbvSS2JAoWgIIGQFPMS6iTB4hzQ48g1HyW2cnackSVDXFbez6W4aUGEWeT4/ uxmbvaQZMHBZS6q/IXEsjmbI89S4Ve5/ZsUAJGtNCD6Ue2u23cFYrLXpLSGoTGpnGvZR fN/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=R4zEEzriyM2dk3bgEA5bMN8hoDe1qItJp2RwfiL+VrQ=; b=YnSsQAOmG10XaMfBawNnRxJnYOgWMvdkOq7FNZ+WoZoXjttkztUhVRtpIKiyV4afGl 2/s9J3Ggxbfq+pOIN9zRj7oSQpje0aE/JyrYbyuLShe5vrgP5bCzWv5YCR2wlefhm4LK 7QFoyVWLfke7X/nHBHnATDtOeFUGJIBFwU4Z9eFB4+T2pyAoSQ4ddmwjdIxJB6/n8QEk vEMdeW3HrIWDdWR4hO3mUVlGM8jqV/ETcQWiEhCjEd5M46+lreRsFB6EjYviWMo8yz+N py9KAxGD6NJAxrUIxWmAVC9qj1jJ0FvuVszhIO3vw0Dru0zRIEXIrJlHiRF4ovg5xpZD HXbA== X-Gm-Message-State: ACgBeo35/SKFNPw5vaGMgiszEIHvfMY4EVcwc42XKdo77/IDzYoNvKMg Wfa2TVTMRbWR1xfz7Q8AC7yWng== X-Google-Smtp-Source: AA6agR46cHUf56KkFJc2aSYbDU+9x7C9H01VMNXOkIpE+s9kAjEd8L+wcDFjntpngtCBWFhXoSPNZg== X-Received: by 2002:a63:1257:0:b0:42f:fbe8:3ac0 with SMTP id 23-20020a631257000000b0042ffbe83ac0mr27721532pgs.412.1662439726525; Mon, 05 Sep 2022 21:48:46 -0700 (PDT) Received: from virs-pc-021.intranet.virscient.com (124-248-138-161.static.lightwire.co.nz. [124.248.138.161]) by smtp.gmail.com with ESMTPSA id ij28-20020a170902ab5c00b00176b66954a6sm2726822plb.121.2022.09.05.21.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 21:48:46 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen , kernel test robot Subject: [PATCH v3 01/12] cfg80211: regulatory: extend regulatory support for S1G Date: Tue, 6 Sep 2022 16:48:01 +1200 Message-Id: <20220906044812.7609-2-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906044812.7609-1-kieran.frewen@morsemicro.com> References: <20220906044812.7609-1-kieran.frewen@morsemicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Extend the S1G regulatory information to support all regulatory domains. An reg_s1g.h file is included containing structs with key regulatory class information. These structs were required to ensure the right combination of information was available to a series of functions which support the mapping between frequencies, bandwidths, and channels. Reported-by: kernel test robot Signed-off-by: Kieran Frewen --- include/net/cfg80211.h | 8 ++ net/wireless/Makefile | 2 +- net/wireless/reg.c | 60 +++++++++-- net/wireless/reg_s1g.c | 231 +++++++++++++++++++++++++++++++++++++++++ net/wireless/reg_s1g.h | 53 ++++++++++ net/wireless/util.c | 35 ++++++- 6 files changed, 376 insertions(+), 13 deletions(-) create mode 100644 net/wireless/reg_s1g.c create mode 100644 net/wireless/reg_s1g.h diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 908d58393484..945e7700de66 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5909,6 +5909,14 @@ ieee80211_channel_to_khz(const struct ieee80211_channel *chan) return MHZ_TO_KHZ(chan->center_freq) + chan->freq_offset; } +/** + * ieee80211_s1g_channel_to_freq_khz - convert S1G channel index to + * frequency in khz + * @chan: int channel index to convert + * Return: The corresponding frequency (in KHz) + */ +u32 ieee80211_s1g_channel_to_freq_khz(int chan); + /** * ieee80211_s1g_channel_width - get allowed channel width from @chan * diff --git a/net/wireless/Makefile b/net/wireless/Makefile index 527ae669f6f7..10cc0db5a935 100644 --- a/net/wireless/Makefile +++ b/net/wireless/Makefile @@ -10,7 +10,7 @@ obj-$(CONFIG_WEXT_PROC) += wext-proc.o obj-$(CONFIG_WEXT_SPY) += wext-spy.o obj-$(CONFIG_WEXT_PRIV) += wext-priv.o -cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o +cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o reg_s1g.o scan.o nl80211.o cfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o mesh.o ap.o trace.o ocb.o cfg80211-y += pmsr.o cfg80211-$(CONFIG_OF) += of.o diff --git a/net/wireless/reg.c b/net/wireless/reg.c index c7383ede794f..3377cea16c2b 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -62,6 +62,7 @@ #include "reg.h" #include "rdev-ops.h" #include "nl80211.h" +#include "reg_s1g.h" /* * Grace period we give before making sure all current interfaces reside on @@ -1737,26 +1738,54 @@ static uint32_t reg_rule_to_chan_bw_flags(const struct ieee80211_regdomain *regd * the largest bandwidth which cleanly divides the freq_range. */ int edge_offset; - int ch_bw = max_bandwidth_khz; + int ch_bw, freq_end, freq_start, class_idx = -1; + unsigned int i; + const struct s1g_oper_class *oper = reg_s1g_get_oper_class(regd->alpha2); + + if (!oper) { + bw_flags |= IEEE80211_CHAN_DISABLED; + return bw_flags; + } + + for (i = 0; i < oper->class_count; i++) { + if (center_freq_khz >= oper->class[i].start_freq && + center_freq_khz <= oper->class[i].end_freq) { + class_idx = i; + break; + } + } + + if (class_idx == -1) { + bw_flags |= IEEE80211_CHAN_DISABLED; + return bw_flags; + } + + ch_bw = oper->class[class_idx].max_bw_khz; + freq_start = oper->class[class_idx].start_freq; + freq_end = oper->class[class_idx].end_freq; while (ch_bw) { - edge_offset = (center_freq_khz - ch_bw / 2) - - freq_range->start_freq_khz; - if (edge_offset % ch_bw == 0) { - switch (KHZ_TO_MHZ(ch_bw)) { - case 1: + if (oper->class[class_idx].align_to_end) + edge_offset = freq_end - + (center_freq_khz - (ch_bw) / 2); + else + edge_offset = (center_freq_khz - (ch_bw) / 2) - + freq_start; + if (edge_offset % (ch_bw) == 0) { + switch (ch_bw) { + case MHZ_TO_KHZ(1): bw_flags |= IEEE80211_CHAN_1MHZ; break; - case 2: + case MHZ_TO_KHZ(2): bw_flags |= IEEE80211_CHAN_2MHZ; break; - case 4: + case MHZ_TO_KHZ(4): bw_flags |= IEEE80211_CHAN_4MHZ; break; - case 8: + case MHZ_TO_KHZ(8): bw_flags |= IEEE80211_CHAN_8MHZ; break; - case 16: + case MHZ_TO_KHZ(16): bw_flags |= IEEE80211_CHAN_16MHZ; break; default: @@ -2555,9 +2584,18 @@ static void handle_channel_custom(struct wiphy *wiphy, const struct ieee80211_reg_rule *reg_rule = NULL; const struct ieee80211_power_rule *power_rule = NULL; u32 bw, center_freq_khz; + bool is_s1g = chan->band == NL80211_BAND_S1GHZ; center_freq_khz = ieee80211_channel_to_khz(chan); - for (bw = MHZ_TO_KHZ(20); bw >= min_bw; bw = bw / 2) { + + if (is_s1g) { + bw = MHZ_TO_KHZ(16); + min_bw = MHZ_TO_KHZ(1); + } else { + bw = MHZ_TO_KHZ(20); + } + + for (; bw >= min_bw; bw = bw / 2) { reg_rule = freq_reg_info_regd(center_freq_khz, regd, bw); if (!IS_ERR(reg_rule)) break; diff --git a/net/wireless/reg_s1g.c b/net/wireless/reg_s1g.c new file mode 100644 index 000000000000..6727d9986419 --- /dev/null +++ b/net/wireless/reg_s1g.c @@ -0,0 +1,231 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "reg_s1g.h" + +/* The following channel lists have been retrieved from + * IEEE Std 802.11-2020 Table E-5 + */ +static const u8 us_supported_channels[] = { + 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51 +}; + +static const u8 eu_supported_channels_863[] = { + 1, 3, 5, 7, 9 +}; + +static const u8 eu_supported_channels_901_4[] = { + 33, 35 +}; + +static const u8 jp_supported_channels[] = { + 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21 +}; + +static const u8 kr_supported_channels[] = { + 1, 2, 3, 5, 6, 7, 8, 9, 10, 11 +}; + +static const u8 sg_supported_channels_863[] = { + 7, 9, 10, 11 +}; + +static const u8 sg_supported_channels_902[] = { + 37, 38, 39, 40, 41, 42, 43, 45 +}; + +static const u8 au_nz_supported_channels[] = { + 27, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51 +}; + +/* The following s1g_oper_class structs are taken from + * IEEE Std 802.11-2020 Table E-5 + */ +static const struct s1g_oper_class country_class_au = { + .cc = "AU", + .class_count = 2, + .class = { + { + .band_start = 902000, + .start_freq = 915000, + .end_freq = 920000, + .max_bw_khz = MHZ_TO_KHZ(4), + .align_to_end = false, + .supported_chan = au_nz_supported_channels, + .n_supported_chan = sizeof(au_nz_supported_channels), + }, + { + .band_start = 902000, + .start_freq = 920000, + .end_freq = 928000, + .max_bw_khz = MHZ_TO_KHZ(8), + .align_to_end = true, + .supported_chan = NULL, + .n_supported_chan = 0, + } + }, +}; + +static const struct s1g_oper_class country_class_nz = { + .cc = "NZ", + .class_count = 2, + .class = { + { + .band_start = 902000, + .start_freq = 915000, + .end_freq = 924000, + .max_bw_khz = MHZ_TO_KHZ(8), + .align_to_end = false, + .supported_chan = au_nz_supported_channels, + .n_supported_chan = sizeof(au_nz_supported_channels), + }, + { + .band_start = 902000, + .start_freq = 924000, + .end_freq = 928000, + .max_bw_khz = MHZ_TO_KHZ(8), + .align_to_end = false, + .supported_chan = NULL, + .n_supported_chan = 0, + } + }, +}; + +static const struct s1g_oper_class country_class_us = { + .cc = "US", + .class_count = 3, + .class = { + { + .band_start = 902000, + .start_freq = 902000, + .end_freq = 904000, + .max_bw_khz = MHZ_TO_KHZ(16), + .align_to_end = false, + .supported_chan = us_supported_channels, + .n_supported_chan = sizeof(us_supported_channels), + }, + { + .band_start = 902000, + .start_freq = 920000, + .end_freq = 928000, + .max_bw_khz = MHZ_TO_KHZ(16), + .align_to_end = false, + .supported_chan = NULL, + .n_supported_chan = 0, + }, + { + .band_start = 902000, + .start_freq = 904000, + .end_freq = 920000, + .max_bw_khz = MHZ_TO_KHZ(16), + .align_to_end = false, + .supported_chan = NULL, + .n_supported_chan = 0, + } + }, +}; + +static const struct s1g_oper_class country_class_sg = { + .cc = "SG", + .class_count = 2, + .class = { + { + .band_start = 863000, + .start_freq = 866000, + .end_freq = 869000, + .max_bw_khz = MHZ_TO_KHZ(2), + .align_to_end = true, + .supported_chan = sg_supported_channels_863, + .n_supported_chan = sizeof(sg_supported_channels_863), + }, + { + .band_start = 902000, + .start_freq = 920000, + .end_freq = 925000, + .max_bw_khz = MHZ_TO_KHZ(4), + .align_to_end = false, + .supported_chan = sg_supported_channels_902, + .n_supported_chan = sizeof(sg_supported_channels_902), + }, + }, +}; + +static const struct s1g_oper_class country_class_kr = { + .cc = "KR", + .class_count = 1, + .class = { + { + .band_start = 917500, + .start_freq = 917500, + .end_freq = 923500, + .max_bw_khz = MHZ_TO_KHZ(4), + .align_to_end = true, + .supported_chan = kr_supported_channels, + .n_supported_chan = sizeof(kr_supported_channels), + } + }, +}; + +static const struct s1g_oper_class country_class_eu = { + .cc = "EU", + .class_count = 1, + .class = { + { + .band_start = 863000, + .start_freq = 863000, + .end_freq = 868000, + .max_bw_khz = MHZ_TO_KHZ(1), + .align_to_end = false, + .supported_chan = eu_supported_channels_863, + .n_supported_chan = sizeof(eu_supported_channels_863), + }, + { + .band_start = 901400, + .start_freq = 917400, + .end_freq = 919400, + .max_bw_khz = MHZ_TO_KHZ(1), + .align_to_end = false, + .supported_chan = eu_supported_channels_901_4, + .n_supported_chan = sizeof(eu_supported_channels_901_4), + } + }, +}; + +static const struct s1g_oper_class country_class_jp = { + .cc = "JP", + .class_count = 1, + .class = { + { + .band_start = 916500, + .start_freq = 916500, + .end_freq = 927500, + .max_bw_khz = MHZ_TO_KHZ(1), + .align_to_end = false, + .supported_chan = jp_supported_channels, + .n_supported_chan = sizeof(jp_supported_channels), + } + }, +}; + +const struct s1g_oper_class *reg_s1g_get_oper_class(const char *cc) +{ + if (!strcmp(cc, "EU")) + return &country_class_eu; + if (!strcmp(cc, "SG")) + return &country_class_sg; + if (!strcmp(cc, "US")) + return &country_class_us; + if (!strcmp(cc, "AU")) + return &country_class_au; + if (!strcmp(cc, "KR")) + return &country_class_kr; + if (!strcmp(cc, "JP")) + return &country_class_jp; + if (!strcmp(cc, "NZ")) + return &country_class_nz; + return NULL; +} diff --git a/net/wireless/reg_s1g.h b/net/wireless/reg_s1g.h new file mode 100644 index 000000000000..3165166054d2 --- /dev/null +++ b/net/wireless/reg_s1g.h @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __NET_WIRELESS_REG_S1G_H +#define __NET_WIRELESS_REG_S1G_H + +#include "reg.h" + +/** + * Struct cca_class + * + * The specifics of a cca level classification used to validate bw/frequency + * combinations in a regulatory domain + * @band_start: The channel starting frequency (kHz) for that CCA classification + * @start_freq: The start of the valid frequency (kHz) range for the CCA + * classification + * @end_freq: The end of the valid frequency (kHz) range for the CCA + * classification + * @max_bw_khz: The maximum valid bandwidth for the CCA classification + * @align_to_end: True if the maximum valid bandwidth for the range is aligned + * to the end_freq + * @supported_chan: A list of supported channel indexes + * @n_supported_chan: A count of the supported channels for this CCA + * classification + */ +struct s1g_cca_classification { + u32 band_start; + u32 start_freq; + u32 end_freq; + u32 max_bw_khz; + bool align_to_end; + const u8 *supported_chan; + u8 n_supported_chan; +}; + +/** + * Struct s1g_oper_class + * + * An aggregated view of the operating classes for a single regulatory + * domain + * @cc: country code (2-character code) + * @class_count: The number of CCA level classifications that exist + * within that country + * @class: The specifics of a CCA level classification within a regulatory + * domain. + */ +struct s1g_oper_class { + char cc[3]; + int class_count; + struct s1g_cca_classification class[]; +}; + +const struct s1g_oper_class *reg_s1g_get_oper_class(const char *cc); + +#endif /*__NET_WIRELESS_REG_S1G_H */ diff --git a/net/wireless/util.c b/net/wireless/util.c index 2c127951764a..aeccb6ce595c 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -22,6 +22,7 @@ #include #include "core.h" #include "rdev-ops.h" +#include "reg_s1g.h" const struct ieee80211_rate * @@ -72,6 +73,27 @@ u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband, } EXPORT_SYMBOL(ieee80211_mandatory_rates); +static u32 ieee80211_s1g_base_freq(int chan) +{ + const struct ieee80211_regdomain *regd = rtnl_dereference(cfg80211_regdomain); + const struct s1g_oper_class *oper = reg_s1g_get_oper_class(regd->alpha2); + u8 i, j, index = 0; + + if (!oper) + return 0; + + if (oper->class_count > 1) + for (i = 0; i < oper->class_count; i++) + for (j = 0; j < oper->class[i].n_supported_chan; j++) + if (oper->class[i].supported_chan[j] == chan) { + index = i; + goto out; + } + return 0; /* not supported */ +out: + return oper->class[index].band_start; +} + u32 ieee80211_channel_to_freq_khz(int chan, enum nl80211_band band) { /* see 802.11 17.3.8.3.2 and Annex J @@ -104,7 +126,7 @@ u32 ieee80211_channel_to_freq_khz(int chan, enum nl80211_band band) return MHZ_TO_KHZ(56160 + chan * 2160); break; case NL80211_BAND_S1GHZ: - return 902000 + chan * 500; + return ieee80211_s1g_base_freq(chan) + chan * 500; default: ; } @@ -112,6 +134,17 @@ u32 ieee80211_channel_to_freq_khz(int chan, enum nl80211_band band) } EXPORT_SYMBOL(ieee80211_channel_to_freq_khz); +u32 ieee80211_s1g_channel_to_freq_khz(int chan) +{ + u32 base = ieee80211_s1g_base_freq(chan); + + if (!base) + return 0; + + return (base + chan * 500); +} +EXPORT_SYMBOL(ieee80211_s1g_channel_to_freq_khz); + enum nl80211_chan_width ieee80211_s1g_channel_width(const struct ieee80211_channel *chan) { From patchwork Tue Sep 6 04:48:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 603347 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92898C38145 for ; Tue, 6 Sep 2022 04:48:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232334AbiIFEs4 (ORCPT ); Tue, 6 Sep 2022 00:48:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232295AbiIFEsz (ORCPT ); Tue, 6 Sep 2022 00:48:55 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C086B5F233 for ; Mon, 5 Sep 2022 21:48:49 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id q15so10197648pfn.11 for ; Mon, 05 Sep 2022 21:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=BiyzywgHHj+IVb5QDXTCFlBPfP6+IwHSEhwSM4r8OT0=; b=V7DCEhsYjTgi2OkQTP2r11v1NCdy9TiI+7gLB7gxxRAjuaOd1uetcsziLD0uDf2KI9 PvrTlzibVCi0Eon3jdZpRg4bPv4kzSe676mZEVs1zlVXCVpc7YG7QcIMggvhPxfchoj2 UYRAmC5STYNkUeTzB0lHWMnKHBSg8lldYjJsnlwr248eWfpc3BJb5nCwNsKOMmO5xdl2 h5RJkXiRo4Bb/f8MESTA9HPngjxzNWorcUdJMLurqe07Q8hOsTYUt0Ebf4WgyTE6yh0A vSiJgDbiMD974czwXNCyDqyrEhPaGERHRZBBOl0HvVoQfGLw6WFkenJJCB00cjHSVeBm NlxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=BiyzywgHHj+IVb5QDXTCFlBPfP6+IwHSEhwSM4r8OT0=; b=Q195rvjz/AEd2o4/5PpbaNQMF8h7NEOgAPIjhr0frxxlPqShn8o2bE/X9QR4EX/BvW A/aDQvQiPVJJ6Evskh707Gl/q+22RnMi3tS5u2DGmLTiWjvpUerPDvRoAr93zWNW1cYO rfNbi1kkX7RRPVie3SHIX3EAbbWXdg2rMG4Eib1pzOoUEOofZi1SrgRlCLGrryp99xUv kje5M1thktrcYjTFJHsr+POP9VoeC+urHgpb0pzpiOL6xZ0wYsdnk01YEshSNBSz46Da gMxOzbJAZLH7N/5Q622dgBU6woeJyr0NTFrXr6CFd5bULVgfiuCROtaF43veeFBqoZ2E FeUQ== X-Gm-Message-State: ACgBeo1iGlLjmQIqQjulcyjPCaVR/PXN9JUDGdrzq2AvOnRG+A9iNazl 7XU357nRiHPTXBGB3TNl1TKwZw== X-Google-Smtp-Source: AA6agR5HHoAF9pOmXIkxjI0QqA++GZUo1e+WTnmSF2SYJdknFX6alnb+buf0LDQ39opBSQKbwXupwg== X-Received: by 2002:a63:fd47:0:b0:432:be56:9ab1 with SMTP id m7-20020a63fd47000000b00432be569ab1mr15069551pgj.252.1662439729304; Mon, 05 Sep 2022 21:48:49 -0700 (PDT) Received: from virs-pc-021.intranet.virscient.com (124-248-138-161.static.lightwire.co.nz. [124.248.138.161]) by smtp.gmail.com with ESMTPSA id ij28-20020a170902ab5c00b00176b66954a6sm2726822plb.121.2022.09.05.21.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 21:48:48 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v3 02/12] mac80211: update TIM for S1G specification changes Date: Tue, 6 Sep 2022 16:48:02 +1200 Message-Id: <20220906044812.7609-3-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906044812.7609-1-kieran.frewen@morsemicro.com> References: <20220906044812.7609-1-kieran.frewen@morsemicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Updates to the TIM information element to match changes made in the IEEE Std 802.11ah-2020. Signed-off-by: Kieran Frewen --- net/mac80211/tx.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 45df9932d0ba..bf85a01fcf9d 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -4749,9 +4749,9 @@ static void __ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, ps->dtim_count--; } - tim = pos = skb_put(skb, 6); + tim = pos = skb_put(skb, 5); *pos++ = WLAN_EID_TIM; - *pos++ = 4; + *pos++ = 3; *pos++ = ps->dtim_count; *pos++ = link_conf->dtim_period; @@ -4782,13 +4782,18 @@ static void __ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, /* Bitmap control */ *pos++ = n1 | aid0; /* Part Virt Bitmap */ - skb_put(skb, n2 - n1); + skb_put(skb, n2 - n1 + 1); memcpy(pos, ps->tim + n1, n2 - n1 + 1); tim[1] = n2 - n1 + 4; } else { *pos++ = aid0; /* Bitmap control */ - *pos++ = 0; /* Part Virt Bitmap */ + + if (ieee80211_get_sband(sdata)->band != NL80211_BAND_S1GHZ) { + skb_put(skb, 1); + tim[1] = 4; + *pos++ = 0; /* Part Virt Bitmap */ + } } } From patchwork Tue Sep 6 04:48:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 603797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69B4AECAAA1 for ; Tue, 6 Sep 2022 04:49:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232342AbiIFEs7 (ORCPT ); Tue, 6 Sep 2022 00:48:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229766AbiIFEs6 (ORCPT ); Tue, 6 Sep 2022 00:48:58 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F37B5F981 for ; Mon, 5 Sep 2022 21:48:52 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id x1so5807300plv.5 for ; Mon, 05 Sep 2022 21:48:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=A3efkcxMqCbaa7PDe+x91aoe1xznbgpM9T9i+RQwS/c=; b=FPUc1a/ZLi8lk0q0FsUZTnn0ZPJVmPVFJpIAWD78/o61WUvuz05MgdKxREWRiMCNpK XJlCmn5feJTXmemsNmwIVlBol1P5BCHayVqtnbalQsx7kZyocMwlub/pYMKAY0t2ek2e NnQ//ieuJ/9DikjOL2KYo0HF8ltgrLo3iT9OeQXxNIetBsNlMCnZr1Q1K+l53D9cKFFn A+IxDoJPLytRqdRlIULhi2y40nX7G83dEzqN8ouYWmcagQj/6Gzg3B4dKoX41AAxDwTi 0n2WxxoNSTJ2sS322BvmJMsUZlUKeYWBtkpqFHriDFPJ5W9CvT/ZD2muh3OPx+MBz9/G vtHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=A3efkcxMqCbaa7PDe+x91aoe1xznbgpM9T9i+RQwS/c=; b=oCv8aYhZd5Cqir1z3qE9Ri3n3arSPbi8DGdPvMx54aqTX3dHwl13mg3dr8flE0Y4de s31DBsMj2EfyWs1OUqVovGOcbcLaKBHGgyKMS7wA2tmW+NmrK39Q5PhQb9i6itnvOu1B Hua7B+CQ392oJGtNWz8ed8VHPzVQ604FdR3e+KNVwf9cLIzr+ilb9LbdhGV0H9YR6RPy fGkwPCJAILT6Q6ltD5pv8rx/Rq1kFzPPjUe0i3oVUbFe8HArfN6v5fjPs5oDJQ2V7C1b +GMbCVP+pAHjowGpKYm69t+p8632xpbJyZGsFO2fvLYqGQuqF73zeTQkx5RWnPT5ZU4v fUrw== X-Gm-Message-State: ACgBeo3fiq7dGO+Uu/SMah2qevtJXO5nN9oAa5mwNDIYII3yYJuR2fLK 67SIROOZqRLm7O5WpOU5VMBXJE+PCgrxJ2Wg X-Google-Smtp-Source: AA6agR5xYZbe+CQ2cxrzh+LmwdcaHoE/qcmVXpR2vtmEiqNrpKoFELUYPeueXECwsn8ZiU6xQGcziQ== X-Received: by 2002:a17:90b:2712:b0:1fa:fe17:16db with SMTP id px18-20020a17090b271200b001fafe1716dbmr23228649pjb.165.1662439732033; Mon, 05 Sep 2022 21:48:52 -0700 (PDT) Received: from virs-pc-021.intranet.virscient.com (124-248-138-161.static.lightwire.co.nz. [124.248.138.161]) by smtp.gmail.com with ESMTPSA id ij28-20020a170902ab5c00b00176b66954a6sm2726822plb.121.2022.09.05.21.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 21:48:51 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v3 03/12] mac80211: S1G beacon/short beacon support Date: Tue, 6 Sep 2022 16:48:03 +1200 Message-Id: <20220906044812.7609-4-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906044812.7609-1-kieran.frewen@morsemicro.com> References: <20220906044812.7609-1-kieran.frewen@morsemicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org If configured, use the S1G short beacon format. The S1G short beacon format includes a limited set of information elements. Signed-off-by: Kieran Frewen --- include/net/cfg80211.h | 2 +- include/net/mac80211.h | 1 + net/mac80211/cfg.c | 1 + net/mac80211/ieee80211_i.h | 1 + net/mac80211/tx.c | 14 +++++++++++++- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 945e7700de66..b750b2ad246b 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1328,7 +1328,7 @@ struct cfg80211_ap_settings { struct cfg80211_beacon_data beacon; - int beacon_interval, dtim_period; + int beacon_interval, dtim_period, short_beacon_period; const u8 *ssid; size_t ssid_len; enum nl80211_hidden_ssid hidden_ssid; diff --git a/include/net/mac80211.h b/include/net/mac80211.h index f198af600b5e..359edfa9ec1c 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -672,6 +672,7 @@ struct ieee80211_bss_conf { bool enable_beacon; u8 dtim_period; u16 beacon_int; + u8 short_beacon_period; u16 assoc_capability; u64 sync_tsf; u32 sync_device_ts; diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index a4f6971b7a19..03ed90ce9a84 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1236,6 +1236,7 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev, } link_conf->dtim_period = params->dtim_period; + link_conf->short_beacon_period = params->short_beacon_period; link_conf->enable_beacon = true; link_conf->allow_p2p_go_ps = sdata->vif.p2p; link_conf->twt_responder = params->twt_responder; diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index e192e1ec0261..cd8879998739 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -267,6 +267,7 @@ struct beacon_data { struct ieee80211_meshconf_ie *meshconf; u16 cntdwn_counter_offsets[IEEE80211_MAX_CNTDWN_COUNTERS_NUM]; u8 cntdwn_current_counter; + u8 long_beacon_count; struct cfg80211_mbssid_elems *mbssid_ies; struct rcu_head rcu_head; }; diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index bf85a01fcf9d..48c737aeb3f7 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -5099,6 +5099,18 @@ ieee80211_beacon_get_ap(struct ieee80211_hw *hw, struct sk_buff *skb = NULL; u16 csa_off_base = 0; int mbssid_len; + bool is_short = false; + + if (vif->cfg.s1g) { + if (beacon->long_beacon_count == 0) { + is_short = false; + beacon->long_beacon_count = + vif->bss_conf.short_beacon_period - 1; + } else { + is_short = true; + beacon->long_beacon_count--; + } + } if (beacon->cntdwn_counter_offsets[0]) { if (!is_template) @@ -5136,7 +5148,7 @@ ieee80211_beacon_get_ap(struct ieee80211_hw *hw, csa_off_base = skb->len; } - if (beacon->tail) + if (beacon->tail && !is_short) skb_put_data(skb, beacon->tail, beacon->tail_len); if (ieee80211_beacon_protect(skb, local, sdata, link) < 0) From patchwork Tue Sep 6 04:48:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 603346 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F40E9C38145 for ; Tue, 6 Sep 2022 04:49:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232367AbiIFEtC (ORCPT ); Tue, 6 Sep 2022 00:49:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229766AbiIFEtA (ORCPT ); Tue, 6 Sep 2022 00:49:00 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 370C465544 for ; Mon, 5 Sep 2022 21:48:55 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id m10-20020a17090a730a00b001fa986fd8eeso13785652pjk.0 for ; Mon, 05 Sep 2022 21:48:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=xs9rQoFSztjp512nGA2Dk3P/aPtDkMwSvLthvC06sgk=; b=NYDTw5TSgMRjtIO8n3oMEG4JnMnrHTcyI+Hj/cq94XVGeg/lytvSyLCcC8O1puQ5x1 PB8MiWtFrbPwNEqg06icJ5dwa3EGyrCHdtPno+j6sP2n9rzgQzNtUw7FizkMQ879pqKH zqSHSKHT/21sFGSfktqKk04bJKy4N14l1C9+oqZ/C+uxRVIgJ5/2Z4S0UPSHxSx2vA2j KZA8iejNG37hd74f8Vs/wFkMuLevA+4MtPCVzPs8hipl7Mz6fLTdhV2f/weTBOvmL7rK nS+fo1N89CMO01JZ3Cu7IG8WEmGeO4UnGLUzcQYzE/QhLL9Cn3Zq+fS2BmIAhUKDPnf0 DLzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=xs9rQoFSztjp512nGA2Dk3P/aPtDkMwSvLthvC06sgk=; b=njnAFgYrO5wZzrqlALbaZa1xRGtgn2B/0aB4Eg2lJ3MAJtlCOwDdREUKonsGGPO8Iy 78rNLKA8qfZkR+l+EYzcksaaCWtwmS27Itq3n1dLqbgYvc3Z8sifRfo2oB2P9r5Y9Bca yO9fNM7ASDiV0j1D/6q8vyl60b8DkpuzjdQsSZzmDl2j/NhFFWC6AKLeCCtVhDOb1Tph FAKy3wcVwA6usteH8uDJpSTfgRI3xaJVzzFMvCsSsytb15QnYHP1JHHsRYb6m9zlJ5Hd eKj8flf0X833bxVj1+rqzZKXHkJmc1QcOEFwdVqovRAjpNHvYIn/ezyVm3jJR1asyJov zn9A== X-Gm-Message-State: ACgBeo2UhmmTmJRMLfNE3SNXCwGpgBA7iOIUq1Ai2cQR7y6CDDVFgMtX vpT3skOsLKzWixfnJintLG8Xlg== X-Google-Smtp-Source: AA6agR59JVA0u46HHh2vZEu7CGV2jCE/wo1idw9kywRXZqoVJbnGRhrwT6Mlk4FVwt2iSlGkHVycXg== X-Received: by 2002:a17:902:e947:b0:170:d739:8cbe with SMTP id b7-20020a170902e94700b00170d7398cbemr53421730pll.141.1662439734927; Mon, 05 Sep 2022 21:48:54 -0700 (PDT) Received: from virs-pc-021.intranet.virscient.com (124-248-138-161.static.lightwire.co.nz. [124.248.138.161]) by smtp.gmail.com with ESMTPSA id ij28-20020a170902ab5c00b00176b66954a6sm2726822plb.121.2022.09.05.21.48.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 21:48:54 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v3 04/12] nl80211: support setting S1G short beacon period Date: Tue, 6 Sep 2022 16:48:04 +1200 Message-Id: <20220906044812.7609-5-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906044812.7609-1-kieran.frewen@morsemicro.com> References: <20220906044812.7609-1-kieran.frewen@morsemicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org With the kernel able to send both short and long S1G beacons, include the ability for setting the short beacon period. Signed-off-by: Kieran Frewen --- include/uapi/linux/nl80211.h | 7 +++++++ net/wireless/nl80211.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index ffb7c573e299..7daa2ce1cb57 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -2741,6 +2741,9 @@ enum nl80211_commands { * When used with %NL80211_CMD_FRAME_TX_STATUS, indicates the ack RX * timestamp. When used with %NL80211_CMD_FRAME RX notification, indicates * the incoming frame RX timestamp. + * + * @NL80211_ATTR_SHORT_BEACON_PERIOD: S1G short beacon period in TUs. + * * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use @@ -3269,6 +3272,8 @@ enum nl80211_attrs { NL80211_ATTR_TX_HW_TIMESTAMP, NL80211_ATTR_RX_HW_TIMESTAMP, + NL80211_ATTR_SHORT_BEACON_PERIOD, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, @@ -4951,6 +4956,7 @@ enum nl80211_bss_scan_width { * using the nesting index as the antenna number. * @NL80211_BSS_FREQUENCY_OFFSET: frequency offset in KHz * @NL80211_BSS_MLO_LINK_ID: MLO link ID of the BSS (u8). + * @NL80211_BSS_SHORT_BEACON_PERIOD: S1G short beacon period in TUs * @__NL80211_BSS_AFTER_LAST: internal * @NL80211_BSS_MAX: highest BSS attribute */ @@ -4977,6 +4983,7 @@ enum nl80211_bss { NL80211_BSS_CHAIN_SIGNAL, NL80211_BSS_FREQUENCY_OFFSET, NL80211_BSS_MLO_LINK_ID, + NL80211_BSS_SHORT_BEACON_PERIOD, /* keep last */ __NL80211_BSS_AFTER_LAST, diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 2705e3ee8fc4..5e9aaa8c0d7d 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -805,6 +805,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { [NL80211_ATTR_MLD_ADDR] = NLA_POLICY_EXACT_LEN(ETH_ALEN), [NL80211_ATTR_MLO_SUPPORT] = { .type = NLA_FLAG }, [NL80211_ATTR_MAX_NUM_AKM_SUITES] = { .type = NLA_REJECT }, + [NL80211_ATTR_SHORT_BEACON_PERIOD] = { .type = NLA_U16 }, }; /* policy for the key attributes */ @@ -5711,6 +5712,9 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]); params->dtim_period = nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]); + if (info->attrs[NL80211_ATTR_SHORT_BEACON_PERIOD]) + params->short_beacon_period = + nla_get_u32(info->attrs[NL80211_ATTR_SHORT_BEACON_PERIOD]); err = cfg80211_validate_beacon_int(rdev, dev->ieee80211_ptr->iftype, params->beacon_interval); From patchwork Tue Sep 6 04:48:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 603796 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E2DAECAAA1 for ; Tue, 6 Sep 2022 04:49:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232508AbiIFEtF (ORCPT ); Tue, 6 Sep 2022 00:49:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229766AbiIFEtD (ORCPT ); Tue, 6 Sep 2022 00:49:03 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14E015F233 for ; Mon, 5 Sep 2022 21:48:58 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id q15-20020a17090a304f00b002002ac83485so6337139pjl.0 for ; Mon, 05 Sep 2022 21:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=qGFhC4Pt6EcprkTSPzvVWVdSH6KTqSlQ80Wc40VOPaU=; b=2seAIBgqWcGKZBYj5qJppmfLVNv0YbjnpSFpnQZZ8R+dFr4ydawr6UQADjynGH826Y 7pwAsEQdID2BZKT6XsxScthPlLJG3kcSAL01koiXsqr9e+vRrUI6PHQTz4gjag4Xb4Ci uMJp07qiVd8+oSXQCxQt73e6fN42vWGZ7mLgBv9BXtT9/omo15jW2nusAFdYv7URtUKH 8mqtOEvbkDJXZfliszl1mIXTmiowI3axwrFRh0yJF5toB93LvFLEXDgR9EN80tifDv6/ hKQJXeQFazSIK1o4+qTEQLz9yl1/9i1hiOOEY079HPoq9qvbq4HTamBGma5rE66glL7E 7wCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=qGFhC4Pt6EcprkTSPzvVWVdSH6KTqSlQ80Wc40VOPaU=; b=RJVZudMfACj/bLGMXIsKsd4p1KTMfqNGFVTaqwEa5Dq9yfTzffdGVo5KaHV3UPRTz2 sM8Lah0JV67Noub0N1WY+veEB8PV97DbwuQCMVZDzAiuYJe1CnNqUjr+4HvWxeV2sjdj 2ihzsBeL2zSy4bznrOX0p4ZTu3SpQtTRFJdxXWJzWyF29xjiMBFx5PB00pAuObvalU/J PF0Elb+UrtgrJ9BUS2ZjbTwDygFJtCD1ECoJ0TTVV/HAu3bTkwAVZYJuojp1OJZkP7GD FJAx8GnqVXT7A36A/p1NuUszBNu+depv78uN81H7hxRpluh6tn3eo0VCs9yiwdrfyzsz N5EA== X-Gm-Message-State: ACgBeo3IPgFgF+MkkUJYBPD6/1N/4RabVrx+xba3dUNJYGJOqtQFr40E 1W22zqUBxeJENox1N2uVcw0ZbQ== X-Google-Smtp-Source: AA6agR4j7wy4xgUPhF8lwecPZVG/oAhTIjrQH8ppcyAqZRCb3UgWk6aeNk+E42w4o7xt9acqUUbifw== X-Received: by 2002:a17:90b:4c8c:b0:200:5fa3:9766 with SMTP id my12-20020a17090b4c8c00b002005fa39766mr9211872pjb.129.1662439737612; Mon, 05 Sep 2022 21:48:57 -0700 (PDT) Received: from virs-pc-021.intranet.virscient.com (124-248-138-161.static.lightwire.co.nz. [124.248.138.161]) by smtp.gmail.com with ESMTPSA id ij28-20020a170902ab5c00b00176b66954a6sm2726822plb.121.2022.09.05.21.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 21:48:57 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v3 05/12] nl80211: support advertising S1G capabilities Date: Tue, 6 Sep 2022 16:48:05 +1200 Message-Id: <20220906044812.7609-6-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906044812.7609-1-kieran.frewen@morsemicro.com> References: <20220906044812.7609-1-kieran.frewen@morsemicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Include S1G capabilities in netlink band info messages. Signed-off-by: Kieran Frewen --- include/uapi/linux/nl80211.h | 7 +++++++ net/wireless/nl80211.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 7daa2ce1cb57..f20b9aefd420 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -3994,6 +3994,10 @@ enum nl80211_band_iftype_attr { * @NL80211_BAND_ATTR_EDMG_BW_CONFIG: Channel BW Configuration subfield encodes * the allowed channel bandwidth configurations. * Defined by IEEE P802.11ay/D4.0 section 9.4.2.251, Table 13. + * @NL80211_BAND_ATTR_S1G_MCS_NSS_SET: S1G capabilities, supported S1G-MCS and NSS + * set subfield, as in the S1G information IE, 5 bytes + * @NL80211_BAND_ATTR_S1G_CAPA: S1G capabilities information subfield as in the + * S1G information IE, 10 bytes * @NL80211_BAND_ATTR_MAX: highest band attribute currently defined * @__NL80211_BAND_ATTR_AFTER_LAST: internal use */ @@ -4014,6 +4018,9 @@ enum nl80211_band_attr { NL80211_BAND_ATTR_EDMG_CHANNELS, NL80211_BAND_ATTR_EDMG_BW_CONFIG, + NL80211_BAND_ATTR_S1G_MCS_NSS_SET, + NL80211_BAND_ATTR_S1G_CAPA, + /* keep last */ __NL80211_BAND_ATTR_AFTER_LAST, NL80211_BAND_ATTR_MAX = __NL80211_BAND_ATTR_AFTER_LAST - 1 diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 5e9aaa8c0d7d..931e35619cf4 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -1949,6 +1949,16 @@ static int nl80211_send_band_rateinfo(struct sk_buff *msg, nla_nest_end(msg, nl_rates); + /* S1G capabilities */ + if (sband->band == NL80211_BAND_S1GHZ && sband->s1g_cap.s1g && + (nla_put(msg, NL80211_BAND_ATTR_S1G_CAPA, + sizeof(sband->s1g_cap.cap), + sband->s1g_cap.cap) || + nla_put(msg, NL80211_BAND_ATTR_S1G_MCS_NSS_SET, + sizeof(sband->s1g_cap.nss_mcs), + sband->s1g_cap.nss_mcs))) + return -ENOBUFS; + return 0; } From patchwork Tue Sep 6 04:48:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 603345 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 525F7ECAAA1 for ; Tue, 6 Sep 2022 04:49:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231785AbiIFEtJ (ORCPT ); Tue, 6 Sep 2022 00:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231487AbiIFEtI (ORCPT ); Tue, 6 Sep 2022 00:49:08 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE0C3696E5 for ; Mon, 5 Sep 2022 21:49:00 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id 73so9622485pga.1 for ; Mon, 05 Sep 2022 21:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=N7kGX5xaT//6eWvGI4ewEIkNsO+zil6xVfa/eI991C8=; b=yI/DYOapE4n0Ne5gXB9766V91JiF6EdnbvYV5OCwbsntqxnUVZuR6FzjW/zss0XQiU eRVZj9CMVwwsgBTnrqYL1775nytskFC63DyamIley9DKDamgaU/66JyA4hY55WqSVf5H 8QD67ltg2gGnlkwsKSKnwyaBUSw3Vtr1F4T5nwMmSjZOKPJJfOpSzFcsDFCpplYgDbwQ 7GJhRGvCNniU6n95Rd0wxuLeI5p3CdJA24eaHcia90LfGDFiK3YUUSjBLcMQieHioL+3 IPEIXCCZSI9HNlXnYfQuDCINO+TnxoPyrzR1I7te+TQfE1Hd4TnZ+ARUMIe6qmWRJAEn rc6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=N7kGX5xaT//6eWvGI4ewEIkNsO+zil6xVfa/eI991C8=; b=NdDGRiBCiXLsYdHHvC+1okS86HEoEXrfsnTfbd0gRsYgFDplxGKCarQkxIpGNCBqFG 057vaUGR+m8XPphS571G5V/0jvdpJCYpPHdKD5gqJGVKoeL+SiFx4QGr5oxRTb1eH2NF GXV6C0m9P1dy4+OOM3DQforaORKUAWZO5VovTQ1v6iLW2WIUtAsnO7uFbBxQlNQyhQ82 59qPXTL1O+Uf7UJJkN1a+vnQeNMcN1B2G6tEU/61WPTD1FLF5VnuvoEsInwSP8IAymy7 WB2DUPgedi41fVOquFWOiRtb27468gxfkECECbXZ4l7qUQuonPCL1GNiyugQxKLfSgT2 9p7A== X-Gm-Message-State: ACgBeo2Xt4oRYXIkOOmaKipP5s6qBkAER2y+6J3Cy+Xideqmh4u980Bl 2wg1Y8LTqZHUQ4s7SPFifp/p+g== X-Google-Smtp-Source: AA6agR66y+neQ+eILIKn194uHyUHE082BdizlwENEQQTcXmMbuPJr93zjQO2irDw6pkghP4uCTaP0g== X-Received: by 2002:a63:4802:0:b0:41c:ac9e:1950 with SMTP id v2-20020a634802000000b0041cac9e1950mr45249987pga.376.1662439740449; Mon, 05 Sep 2022 21:49:00 -0700 (PDT) Received: from virs-pc-021.intranet.virscient.com (124-248-138-161.static.lightwire.co.nz. [124.248.138.161]) by smtp.gmail.com with ESMTPSA id ij28-20020a170902ab5c00b00176b66954a6sm2726822plb.121.2022.09.05.21.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 21:48:59 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v3 06/12] mac80211: support ieee80211_ext format Date: Tue, 6 Sep 2022 16:48:06 +1200 Message-Id: <20220906044812.7609-7-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906044812.7609-1-kieran.frewen@morsemicro.com> References: <20220906044812.7609-1-kieran.frewen@morsemicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Ensure S1G beacons use the new ieee80211_ext format when required. Signed-off-by: Kieran Frewen --- net/mac80211/rx.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 57df21e2170a..d46eeebedb4b 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -4895,6 +4895,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, struct ieee80211_local *local = hw_to_local(hw); struct ieee80211_sub_if_data *sdata; struct ieee80211_hdr *hdr; + struct ieee80211_ext *ext_hdr; __le16 fc; struct ieee80211_rx_data rx; struct ieee80211_sub_if_data *prev; @@ -4911,7 +4912,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, if (ieee80211_is_data(fc) || ieee80211_is_mgmt(fc)) I802_DEBUG_INC(local->dot11ReceivedFragmentCount); - if (ieee80211_is_mgmt(fc)) { + if (ieee80211_is_mgmt(fc) || ieee80211_is_s1g_beacon(fc)) { /* drop frame if too short for header */ if (skb->len < ieee80211_hdrlen(fc)) err = -ENOBUFS; @@ -4926,13 +4927,17 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, return; } - hdr = (struct ieee80211_hdr *)skb->data; + if (ieee80211_is_s1g_beacon(fc)) + ext_hdr = (struct ieee80211_ext *)skb->data; + else + hdr = (struct ieee80211_hdr *)skb->data; + ieee80211_parse_qos(&rx); ieee80211_verify_alignment(&rx); - if (unlikely(ieee80211_is_probe_resp(hdr->frame_control) || - ieee80211_is_beacon(hdr->frame_control) || - ieee80211_is_s1g_beacon(hdr->frame_control))) + if (unlikely(ieee80211_is_probe_resp(fc) || + ieee80211_is_beacon(fc) || + ieee80211_is_s1g_beacon(fc))) ieee80211_scan_rx(local, skb); if (ieee80211_is_data(fc)) { @@ -4991,7 +4996,10 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, prev = sdata; continue; } - + if (ieee80211_is_s1g_beacon(fc)) + rx.sta = sta_info_get_bss(prev, ext_hdr->u.s1g_beacon.sa); + else + rx.sta = sta_info_get_bss(prev, hdr->addr2); rx.sdata = prev; ieee80211_rx_for_interface(&rx, skb, false); @@ -4999,6 +5007,10 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, } if (prev) { + if (ieee80211_is_s1g_beacon(fc)) + rx.sta = sta_info_get_bss(prev, ext_hdr->u.s1g_beacon.sa); + else + rx.sta = sta_info_get_bss(prev, hdr->addr2); rx.sdata = prev; if (ieee80211_rx_for_interface(&rx, skb, true)) From patchwork Tue Sep 6 04:48:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 603795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17ECCC38145 for ; Tue, 6 Sep 2022 04:49:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231487AbiIFEtL (ORCPT ); Tue, 6 Sep 2022 00:49:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231664AbiIFEtJ (ORCPT ); Tue, 6 Sep 2022 00:49:09 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 807975FAD2 for ; Mon, 5 Sep 2022 21:49:03 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id fa2so10082459pjb.2 for ; Mon, 05 Sep 2022 21:49:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=K8GudPxsF46B4+Ei1CxsynahHoMg60f2b5O5c9BJbtM=; b=Ibsx89k23ABRA1v3f/HUdPaEwPWfD3htmwZKVfDwePnZpYbcQcM76qMXQzWDLYBss2 qd3DQ1bB8FZjpi9tauV5HS6S6YuLFeqy7d8FqAR1aMjqrvbrduAWOfklqmuC7gOAeMOj Qd7fQIOZf+yycDBnJOQJs3DbvunsSqvj9SanRhGJHoeBGVySWs1upRN9id6WNxB7lZPM gDvxP/yGetPi0ZfNjnQ8H2hyhv/WaeKD5bBuLTEeUcLlDQ31pUbDFvfSte5nrw+IjPrE c4RoLFbSCcx3BOso8QTxrpxbrpgGuLtVoQLz6Wg7DK8aruPO9gCMT08Xy6nzUgZff1BW 9aSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=K8GudPxsF46B4+Ei1CxsynahHoMg60f2b5O5c9BJbtM=; b=mgBBs9YXwe18NN+WjRkW2lj60dLte/8rUg3YigbRtPKqeuOsAr/Z9AhSWkM4fXwj5a xIDJCXqUfsIGLh8e3TRidXk+oXtFziPrt7J8DUXIGFjks9yhcFr1o5fCfnIe4j5on+zx nx8AtOmzeShT5VxIIA5GBQNR7sviG/506/eMrrzJX+Sah1ItQsSWiAnlzD2LRxqj24jf Hg8IEyD1XtTBUwNDQEBDEE/dXUg7Q2Z5mMgv4rSqgZc2PASEe+vXOaeprfui6gWRkhTI OonvpMREuvtnnAJfPpd2gzBVHxqDT1oJfdJx1eIEF+SX4jLSuSBlP/6+mJh2FGwCCls+ /eRQ== X-Gm-Message-State: ACgBeo10FDwE+Ccx0rUR2J0AJ8M72k26z/ykfP4tl/d/Vkp8KBtfjE9g 4ajLOZLxD1vI3Ar/FM1H713WzQ== X-Google-Smtp-Source: AA6agR5CzYraGaNfpf0Fz53weHpPQ1UR0z/VHKsv4j5oFVviYr0oeicsDQiEW8Zh6NYy7Ngck/KwHg== X-Received: by 2002:a17:90b:1bc8:b0:200:43c7:5940 with SMTP id oa8-20020a17090b1bc800b0020043c75940mr11801455pjb.46.1662439743104; Mon, 05 Sep 2022 21:49:03 -0700 (PDT) Received: from virs-pc-021.intranet.virscient.com (124-248-138-161.static.lightwire.co.nz. [124.248.138.161]) by smtp.gmail.com with ESMTPSA id ij28-20020a170902ab5c00b00176b66954a6sm2726822plb.121.2022.09.05.21.49.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 21:49:02 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v3 07/12] mac80211: S1G capabilities information element in probe request Date: Tue, 6 Sep 2022 16:48:07 +1200 Message-Id: <20220906044812.7609-8-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906044812.7609-1-kieran.frewen@morsemicro.com> References: <20220906044812.7609-1-kieran.frewen@morsemicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add the missing S1G capabilities information element to probe requests. Signed-off-by: Kieran Frewen --- net/mac80211/ieee80211_i.h | 1 + net/mac80211/util.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index cd8879998739..e8ff4af9fc03 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -2400,6 +2400,7 @@ void ieee80211_add_s1g_capab_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb); void ieee80211_add_aid_request_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb); +u8 *ieee80211_ie_build_s1g_cap(u8 *pos, struct ieee80211_sta_s1g_cap *s1g_cap); /* channel management */ bool ieee80211_chandef_ht_oper(const struct ieee80211_ht_operation *ht_oper, diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 53826c663723..78e8c286011e 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1857,6 +1857,12 @@ static int ieee80211_build_preq_ies_band(struct ieee80211_sub_if_data *sdata, rate_flags = ieee80211_chandef_rate_flags(chandef); shift = ieee80211_chandef_get_shift(chandef); + /* For direct mac80211 scan (probe request), add S1G IE and consider its override bits */ + if (band == NL80211_BAND_S1GHZ) { + pos = ieee80211_ie_build_s1g_cap(pos, &sband->s1g_cap); + goto done; + } + num_rates = 0; for (i = 0; i < sband->n_bitrates; i++) { if ((BIT(i) & rate_mask) == 0) @@ -2919,6 +2925,21 @@ size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset) return pos; } +u8 *ieee80211_ie_build_s1g_cap(u8 *pos, struct ieee80211_sta_s1g_cap *s1g_cap) +{ + *pos++ = WLAN_EID_S1G_CAPABILITIES; + *pos++ = sizeof(struct ieee80211_s1g_cap); + memset(pos, 0, sizeof(struct ieee80211_s1g_cap)); + + memcpy(pos, &s1g_cap->cap, sizeof(s1g_cap->cap)); + pos += sizeof(s1g_cap->cap); + + memcpy(pos, &s1g_cap->nss_mcs, sizeof(s1g_cap->nss_mcs)); + pos += sizeof(s1g_cap->nss_mcs); + + return pos; +} + u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap, u16 cap) { From patchwork Tue Sep 6 04:48:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 603344 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A672CECAAA1 for ; Tue, 6 Sep 2022 04:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232416AbiIFEtN (ORCPT ); Tue, 6 Sep 2022 00:49:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231664AbiIFEtM (ORCPT ); Tue, 6 Sep 2022 00:49:12 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4836369F58 for ; Mon, 5 Sep 2022 21:49:06 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id o4so10059928pjp.4 for ; Mon, 05 Sep 2022 21:49:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=gEzSj0cQ8tFtuGpVrdD28/ELiDwSc22eP11NGOwvdoM=; b=Aog6gX14ezGtmnLOC584TyaW1aHnPNepiCAHP3dqIjWQ6dbXitAZF0DBYUEnnCXMFU di0/z8OW3cSyU0o/fbTTzlg7BsieIcH4r0kEznPwUXNlc74FctlDH3KicJFoOJNL0gE3 /67E8kIhojYLuKhYxO+YDyk8RfA7eEI4pXLszEfSPnVQnw/xKC8fYcD0pchpQTQDvGUJ f785VPfqqF95P28IH4DuwmIe61TqNdStSxq/31wIt6294JLBZIhUyp0CRFgwmt+S9Mtv Heekjc8iCh6BbOH9s3QCKxqWYibdbPIw+mc+FVmX3YRI17D/UsHCKd2U5QPMdH+/nm7S Cfjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=gEzSj0cQ8tFtuGpVrdD28/ELiDwSc22eP11NGOwvdoM=; b=BJcDSvuGWxUQZSvsJR4sjcB0uMoDCY1CLKLbyuUh+WBt/J6JKsLV3uuEM5/HjWIZXp qLN78jFMhFKaD+yul0WRQLyep7lTak4ywqERqH+qJMGX/3roH5Okf6lPflt2D3gxB11i 0XgutiwcyJ9uu7SNkCr1PWPycRujqja1+v0B5LjcOrlHU2mWU+Vywws6SAseG3qFMsu2 /e6lCYXDyCjicHw3bVg03k0FLNWVGjvAJFLdu1hHtX8sEGTu1O5EfnYhKpgVHMlOtKAZ gxBUycsubDGR3IWh4a0MdfbWM7p+kIil/+PBDMrlXxZCXh44FBhbNaF06Ci5J2+Jbp0O Y5Yw== X-Gm-Message-State: ACgBeo363gOSBtrolpHsGcolwtrP4uAXVkZgJGznkADv1GW4ebYG8NId AgcpjBbHoa2SwiFAoc0Ns7Ldjw== X-Google-Smtp-Source: AA6agR4B+DsDTzKvx86Qd+C8RiVEGbDgmaxo/vuYLt6MQuA6DhXpfH3LqICEbh7lnRv0MNDI5SN69A== X-Received: by 2002:a17:90b:3a89:b0:1fe:4d6d:bd75 with SMTP id om9-20020a17090b3a8900b001fe4d6dbd75mr23420137pjb.199.1662439745745; Mon, 05 Sep 2022 21:49:05 -0700 (PDT) Received: from virs-pc-021.intranet.virscient.com (124-248-138-161.static.lightwire.co.nz. [124.248.138.161]) by smtp.gmail.com with ESMTPSA id ij28-20020a170902ab5c00b00176b66954a6sm2726822plb.121.2022.09.05.21.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 21:49:05 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v3 08/12] cfg80211: S1G rate flags Date: Tue, 6 Sep 2022 16:48:08 +1200 Message-Id: <20220906044812.7609-9-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906044812.7609-1-kieran.frewen@morsemicro.com> References: <20220906044812.7609-1-kieran.frewen@morsemicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Increase the size of S1G rate_info flags to support S1G. Add flags for new S1G bandwidths and S1G MCS. Signed-off-by: Kieran Frewen --- include/net/cfg80211.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index b750b2ad246b..281775f6b3e0 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1660,6 +1660,7 @@ int cfg80211_check_station_change(struct wiphy *wiphy, * @RATE_INFO_FLAGS_EDMG: 60GHz MCS in EDMG mode * @RATE_INFO_FLAGS_EXTENDED_SC_DMG: 60GHz extended SC MCS * @RATE_INFO_FLAGS_EHT_MCS: EHT MCS information + * @RATE_INFO_FLAGS_S1G_MCS: MCS field filled with S1G MCS */ enum rate_info_flags { RATE_INFO_FLAGS_MCS = BIT(0), @@ -1670,6 +1671,7 @@ enum rate_info_flags { RATE_INFO_FLAGS_EDMG = BIT(5), RATE_INFO_FLAGS_EXTENDED_SC_DMG = BIT(6), RATE_INFO_FLAGS_EHT_MCS = BIT(7), + RATE_INFO_FLAGS_S1G_MCS = BIT(8), }; /** @@ -1686,6 +1688,11 @@ enum rate_info_flags { * @RATE_INFO_BW_HE_RU: bandwidth determined by HE RU allocation * @RATE_INFO_BW_320: 320 MHz bandwidth * @RATE_INFO_BW_EHT_RU: bandwidth determined by EHT RU allocation + * @RATE_INFO_BW_1: 1 MHz bandwidth + * @RATE_INFO_BW_2: 2 MHz bandwidth + * @RATE_INFO_BW_4: 4 MHz bandwidth + * @RATE_INFO_BW_8: 8 MHz bandwidth + * @RATE_INFO_BW_16: 16 MHz bandwidth */ enum rate_info_bw { RATE_INFO_BW_20 = 0, @@ -1697,6 +1704,11 @@ enum rate_info_bw { RATE_INFO_BW_HE_RU, RATE_INFO_BW_320, RATE_INFO_BW_EHT_RU, + RATE_INFO_BW_1, + RATE_INFO_BW_2, + RATE_INFO_BW_4, + RATE_INFO_BW_8, + RATE_INFO_BW_16, }; /** @@ -1719,9 +1731,9 @@ enum rate_info_bw { * only valid if bw is %RATE_INFO_BW_EHT_RU) */ struct rate_info { - u8 flags; - u8 mcs; + u16 flags; u16 legacy; + u8 mcs; u8 nss; u8 bw; u8 he_gi; From patchwork Tue Sep 6 04:48:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 603794 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE1AFC38145 for ; Tue, 6 Sep 2022 04:49:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232563AbiIFEtR (ORCPT ); Tue, 6 Sep 2022 00:49:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231664AbiIFEtP (ORCPT ); Tue, 6 Sep 2022 00:49:15 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E62265F981 for ; Mon, 5 Sep 2022 21:49:08 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id c24so9573261pgg.11 for ; Mon, 05 Sep 2022 21:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=cGKebCJTTmHoJDxgEyDfxV59WE1YuVso0IOHSeDM1lI=; b=wO/ETsTV2qOsXmTsnTQz34UjxOkDNgoXJIyJJVfLoOGuDBXrFsPaEx2i76RnDzn84J 0/Csne0fUoriRurBuoC1ZSEpqLPQgksIExe1eWEAmUia7GPL1hnVthHIjlFOAHD867Vu sgRLikXi7onrtiQ0dGa3Pu1xQtFxsnTVsowImAzAbWms9voa16J0+QcaEnSwyBSnxnD4 nnwLpD7o0JSdpON15nWPXQq3VRgFmbGaj9/hJepBaeumvk07BLjF6Ma1YxK/br2KQnHJ suKyc+Ip4MxDUeWjtt9DqzPEMoOCgXU15mbKDBEeVehh81ztWr2keoEe6AFoRUPIgN7R KwCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=cGKebCJTTmHoJDxgEyDfxV59WE1YuVso0IOHSeDM1lI=; b=qTFabjMkWK5flZLb58s88ZI/jgQAjI2F/LyDV15CsdrptlsjTLXYYs/srq1rZybItn +wA3gCHggn/vHnUuUk128bIQu7WmnBdhtXT4Wrv8lAF1hfu6ncGYnV9xWd2JhMG7X41a P71RLXte0TsCqv3UWTxsWjzujboj8knn4Ecv/E6ggvl1tAw8xXIWeorNmLa59Xc5PJMM l8ja0hJ2BD50LUtAl6PjtwOhQw8+1eddyjY4wZ6u6wmUby6s1crS6Z0AVSxYI9xBjHfI aSwqnyx5PR5EPmQcLxvg4cBQEHw5ZKiao87P6B0hUnl9RXXnCJJn6HhTeBmMluC80NLU sAeA== X-Gm-Message-State: ACgBeo1lOqyEyQrfiLUoORGZZ7xyiCyWTDqml7CTh+SsIQyMBZTxDdD8 RrPCUxg+gapfBN9nOWzQenEP0A== X-Google-Smtp-Source: AA6agR4JpCal74uSGWvpzxVWwRXPXeMsceoxQURFEnAfjsYDOlPv9zylrWyxozZSZPOa2FTdQEyD/Q== X-Received: by 2002:a62:1c8f:0:b0:537:2284:bd00 with SMTP id c137-20020a621c8f000000b005372284bd00mr53457672pfc.78.1662439748434; Mon, 05 Sep 2022 21:49:08 -0700 (PDT) Received: from virs-pc-021.intranet.virscient.com (124-248-138-161.static.lightwire.co.nz. [124.248.138.161]) by smtp.gmail.com with ESMTPSA id ij28-20020a170902ab5c00b00176b66954a6sm2726822plb.121.2022.09.05.21.49.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 21:49:08 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v3 09/12] nl80211: support advertising S1G rate information Date: Tue, 6 Sep 2022 16:48:09 +1200 Message-Id: <20220906044812.7609-10-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906044812.7609-1-kieran.frewen@morsemicro.com> References: <20220906044812.7609-1-kieran.frewen@morsemicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add S1G rate information to netlink STA rate message. Signed-off-by: Kieran Frewen --- include/uapi/linux/nl80211.h | 14 ++++++++++++++ net/wireless/nl80211.c | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index f20b9aefd420..5ae301905671 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -3600,6 +3600,13 @@ enum nl80211_eht_ru_alloc { * (u8, see &enum nl80211_eht_gi) * @NL80211_RATE_INFO_EHT_RU_ALLOC: EHT RU allocation, if not present then * non-OFDMA was used (u8, see &enum nl80211_eht_ru_alloc) + * @NL80211_RATE_INFO_S1G_MCS: S1G MCS index (u8, 0-10) + * @NL80211_RATE_INFO_S1G_NSS: S1G NSS value (u8, 1-4) + * @NL80211_RATE_INFO_1_MHZ_WIDTH: 1 MHz S1G rate + * @NL80211_RATE_INFO_2_MHZ_WIDTH: 2 MHz S1G rate + * @NL80211_RATE_INFO_4_MHZ_WIDTH: 4 MHz S1G rate + * @NL80211_RATE_INFO_8_MHZ_WIDTH: 8 MHz S1G rate + * @NL80211_RATE_INFO_16_MHZ_WIDTH: 16 MHz S1G rate * @__NL80211_RATE_INFO_AFTER_LAST: internal use */ enum nl80211_rate_info { @@ -3626,6 +3633,13 @@ enum nl80211_rate_info { NL80211_RATE_INFO_EHT_NSS, NL80211_RATE_INFO_EHT_GI, NL80211_RATE_INFO_EHT_RU_ALLOC, + NL80211_RATE_INFO_S1G_MCS, + NL80211_RATE_INFO_S1G_NSS, + NL80211_RATE_INFO_1_MHZ_WIDTH, + NL80211_RATE_INFO_2_MHZ_WIDTH, + NL80211_RATE_INFO_4_MHZ_WIDTH, + NL80211_RATE_INFO_8_MHZ_WIDTH, + NL80211_RATE_INFO_16_MHZ_WIDTH, /* keep last */ __NL80211_RATE_INFO_AFTER_LAST, diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 931e35619cf4..73eef7e9f4c3 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -6133,12 +6133,27 @@ bool nl80211_put_sta_rate(struct sk_buff *msg, struct rate_info *info, int attr) return false; switch (info->bw) { + case RATE_INFO_BW_1: + rate_flg = NL80211_RATE_INFO_1_MHZ_WIDTH; + break; + case RATE_INFO_BW_2: + rate_flg = NL80211_RATE_INFO_2_MHZ_WIDTH; + break; + case RATE_INFO_BW_4: + rate_flg = NL80211_RATE_INFO_4_MHZ_WIDTH; + break; case RATE_INFO_BW_5: rate_flg = NL80211_RATE_INFO_5_MHZ_WIDTH; break; + case RATE_INFO_BW_8: + rate_flg = NL80211_RATE_INFO_8_MHZ_WIDTH; + break; case RATE_INFO_BW_10: rate_flg = NL80211_RATE_INFO_10_MHZ_WIDTH; break; + case RATE_INFO_BW_16: + rate_flg = NL80211_RATE_INFO_16_MHZ_WIDTH; + break; default: WARN_ON(1); fallthrough; @@ -6197,6 +6212,14 @@ bool nl80211_put_sta_rate(struct sk_buff *msg, struct rate_info *info, int attr) nla_put_u8(msg, NL80211_RATE_INFO_HE_RU_ALLOC, info->he_ru_alloc)) return false; + } else if (info->flags & RATE_INFO_FLAGS_S1G_MCS) { + if (nla_put_u8(msg, NL80211_RATE_INFO_S1G_MCS, info->mcs)) + return false; + if (nla_put_u8(msg, NL80211_RATE_INFO_S1G_NSS, info->nss)) + return false; + if (info->flags & RATE_INFO_FLAGS_SHORT_GI && + nla_put_flag(msg, NL80211_RATE_INFO_SHORT_GI)) + return false; } else if (info->flags & RATE_INFO_FLAGS_EHT_MCS) { if (nla_put_u8(msg, NL80211_RATE_INFO_EHT_MCS, info->mcs)) return false; From patchwork Tue Sep 6 04:48:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 603343 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D81BECAAA1 for ; Tue, 6 Sep 2022 04:49:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232568AbiIFEtX (ORCPT ); Tue, 6 Sep 2022 00:49:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232364AbiIFEtS (ORCPT ); Tue, 6 Sep 2022 00:49:18 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C123365544 for ; Mon, 5 Sep 2022 21:49:11 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id w63so1127980pgb.7 for ; Mon, 05 Sep 2022 21:49:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=+yMmPcPzo0P0xN20tJgU4+omK6D2iL+r9spD1mNUQ7Q=; b=PJMs44VNdW7QfUFem0LZY8I0KNYDz8U3WQXH0zHJ1SqYq/ENEID8HlyT8TwovUKdRE jeMZgvC+XO35RboMah/cXhi/GhGDu+gjCOkjrJocw5jWUv9dxuNd+iemzV5toWLlA5jY ChM76NnhV9kEj3zn7wR0WkxjG4iYzu5TEW5ScFnP/ubgApKBOtsnhSmHnyIGW1u2NlFl 3j7cYo+C+7QdI9Ly+hGkcwRFLXtIAxVd9ILCkgwXb5WrFxsvdz7wUQkGlqOGqgcIv3Vf b9ZwiMfo5tSrvIwTjYZNLZfhEkEZWcn1FpSgNw5pabl2cXFkbESXE5ikBOf+mktFWmHJ 9nmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=+yMmPcPzo0P0xN20tJgU4+omK6D2iL+r9spD1mNUQ7Q=; b=qU2msAvQlep3eEQS5LKMkirdeD4f3fZNqrM7ajo21/MA/jGUbpBnDPuuWvsY9Wq2lQ 7edQIB4VwzBKx72x7w/erMmrNBsZlwS/kT4QFggNyYHTY8qARD+UguM3LEl+8rBG8f4X jgABvVr9WRbh98UYS7NofNx+xNE51JaT/CZsp809sNRpHFvL5k2tsZCC8Y6ckhehbYz4 AlHvxF6LBi6to4TzlF4OauNUF1jQvrrj7PK5ClEP0lLIgE/9O6Kn2QrmFyIq5UCg/RiP +XOG4+H7qcZZQ8T/RoMZ5NPRjDdloq2wwHD6I2cUDTOGKmVL6ykdNJfuRUPJAKVoAFCB QBFw== X-Gm-Message-State: ACgBeo1SfufHHajqYeioQdHafhWUdH2YkMl9EbtTT6Cbkpc6l8QICvpu eL+gjbD/ZBEHRPCQ5i3hblHpig== X-Google-Smtp-Source: AA6agR65megw1DFKiEJFcuL00xTzzuZj3/avKxjibl22fLIv/vaHDYe7eF9Wo3a1Kvc0LT79AS8Mdg== X-Received: by 2002:a05:6a00:bd8:b0:537:ea87:45f3 with SMTP id x24-20020a056a000bd800b00537ea8745f3mr49081680pfu.55.1662439751276; Mon, 05 Sep 2022 21:49:11 -0700 (PDT) Received: from virs-pc-021.intranet.virscient.com (124-248-138-161.static.lightwire.co.nz. [124.248.138.161]) by smtp.gmail.com with ESMTPSA id ij28-20020a170902ab5c00b00176b66954a6sm2726822plb.121.2022.09.05.21.49.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 21:49:10 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v3 10/12] mac80211: support S1G rate encoding. Date: Tue, 6 Sep 2022 16:48:10 +1200 Message-Id: <20220906044812.7609-11-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906044812.7609-1-kieran.frewen@morsemicro.com> References: <20220906044812.7609-1-kieran.frewen@morsemicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add support for receiving and transmitting S1G frames. Signed-off-by: Kieran Frewen --- drivers/net/wireless/mac80211_hwsim.c | 2 +- include/net/mac80211.h | 32 ++++++++++++++++---- net/mac80211/cfg.c | 42 ++++++++++++++++++++------- net/mac80211/rx.c | 8 +++++ net/mac80211/sta_info.c | 7 +++++ net/mac80211/sta_info.h | 7 +++++ net/mac80211/util.c | 29 +++++++++++++++++- 7 files changed, 109 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 6e55f153ff26..5ecbc80be338 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -1575,7 +1575,7 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw, memset(&rx_status, 0, sizeof(rx_status)); rx_status.flag |= RX_FLAG_MACTIME_START; rx_status.freq = chan->center_freq; - rx_status.freq_offset = chan->freq_offset ? 1 : 0; + rx_status.freq_offset = chan->freq_offset; rx_status.band = chan->band; if (info->control.rates[0].flags & IEEE80211_TX_RC_VHT_MCS) { rx_status.rate_idx = diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 359edfa9ec1c..2e4a78301e3d 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -863,6 +863,10 @@ enum mac80211_tx_info_flags { #define IEEE80211_TX_CTL_STBC_SHIFT 23 #define IEEE80211_TX_RC_S1G_MCS IEEE80211_TX_RC_VHT_MCS +#define IEEE80211_TX_RC_2_MHZ_WIDTH IEEE80211_TX_RC_MCS +#define IEEE80211_TX_RC_4_MHZ_WIDTH IEEE80211_TX_RC_40_MHZ_WIDTH +#define IEEE80211_TX_RC_8_MHZ_WIDTH IEEE80211_TX_RC_80_MHZ_WIDTH +#define IEEE80211_TX_RC_16_MHZ_WIDTH IEEE80211_TX_RC_160_MHZ_WIDTH /** * enum mac80211_tx_control_flags - flags to describe transmit control @@ -1051,6 +1055,20 @@ ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate) return (rate->idx >> 4) + 1; } +static inline u8 +ieee80211_rate_get_s1g_mcs(const struct ieee80211_tx_rate *rate) +{ + /* S1G uses the same MCS encoding as VHT */ + return ieee80211_rate_get_vht_mcs(rate); +} + +static inline u8 +ieee80211_rate_get_s1g_nss(const struct ieee80211_tx_rate *rate) +{ + /* S1G uses the same NSS encoding as VHT */ + return ieee80211_rate_get_vht_nss(rate); +} + /** * struct ieee80211_tx_info - skb transmit information * @@ -1435,6 +1453,7 @@ enum mac80211_rx_encoding { RX_ENC_HT, RX_ENC_VHT, RX_ENC_HE, + RX_ENC_S1G, }; /** @@ -1491,10 +1510,11 @@ struct ieee80211_rx_status { u32 device_timestamp; u32 ampdu_reference; u32 flag; - u16 freq: 13, freq_offset: 1; + u16 freq; + u16 freq_offset; u8 enc_flags; - u8 encoding:2, bw:3, he_ru:3; - u8 he_gi:2, he_dcm:1; + u8 encoding:3, bw:5; + u8 he_ru:3, he_gi:2, he_dcm:1; u8 rate_idx; u8 nss; u8 rx_flags; @@ -1510,8 +1530,7 @@ struct ieee80211_rx_status { static inline u32 ieee80211_rx_status_to_khz(struct ieee80211_rx_status *rx_status) { - return MHZ_TO_KHZ(rx_status->freq) + - (rx_status->freq_offset ? 500 : 0); + return MHZ_TO_KHZ(rx_status->freq) + rx_status->freq_offset; } /** @@ -6568,6 +6587,9 @@ bool rate_usable_index_exists(struct ieee80211_supported_band *sband, { unsigned int i; + if (sband->band == NL80211_BAND_S1GHZ) + return true; + for (i = 0; i < sband->n_bitrates; i++) if (rate_supported(sta, sband->band, i)) return true; diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 03ed90ce9a84..7cbf85338c9e 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -747,8 +747,16 @@ void sta_set_rate_info_tx(struct sta_info *sta, const struct ieee80211_tx_rate *rate, struct rate_info *rinfo) { + struct ieee80211_supported_band *sband; + + sband = ieee80211_get_sband(sta->sdata); rinfo->flags = 0; - if (rate->flags & IEEE80211_TX_RC_MCS) { + if (rate->flags & IEEE80211_TX_RC_S1G_MCS && + sband->band == NL80211_BAND_S1GHZ) { + rinfo->flags |= RATE_INFO_FLAGS_S1G_MCS; + rinfo->mcs = ieee80211_rate_get_s1g_mcs(rate); + rinfo->nss = ieee80211_rate_get_s1g_nss(rate); + } else if (rate->flags & IEEE80211_TX_RC_MCS) { rinfo->flags |= RATE_INFO_FLAGS_MCS; rinfo->mcs = rate->idx; } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { @@ -756,25 +764,37 @@ void sta_set_rate_info_tx(struct sta_info *sta, rinfo->mcs = ieee80211_rate_get_vht_mcs(rate); rinfo->nss = ieee80211_rate_get_vht_nss(rate); } else { - struct ieee80211_supported_band *sband; int shift = ieee80211_vif_get_shift(&sta->sdata->vif); u16 brate; - sband = ieee80211_get_sband(sta->sdata); WARN_ON_ONCE(sband && !sband->bitrates); if (sband && sband->bitrates) { brate = sband->bitrates[rate->idx].bitrate; rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); } } - if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) - rinfo->bw = RATE_INFO_BW_40; - else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) - rinfo->bw = RATE_INFO_BW_80; - else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) - rinfo->bw = RATE_INFO_BW_160; - else - rinfo->bw = RATE_INFO_BW_20; + if (sband->band == NL80211_BAND_S1GHZ) { + if (rate->flags & IEEE80211_TX_RC_2_MHZ_WIDTH) + rinfo->bw = RATE_INFO_BW_2; + else if (rate->flags & IEEE80211_TX_RC_4_MHZ_WIDTH) + rinfo->bw = RATE_INFO_BW_4; + else if (rate->flags & IEEE80211_TX_RC_8_MHZ_WIDTH) + rinfo->bw = RATE_INFO_BW_8; + else if (rate->flags & IEEE80211_TX_RC_16_MHZ_WIDTH) + rinfo->bw = RATE_INFO_BW_16; + else + rinfo->bw = RATE_INFO_BW_1; + } else { + if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) + rinfo->bw = RATE_INFO_BW_40; + else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) + rinfo->bw = RATE_INFO_BW_80; + else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) + rinfo->bw = RATE_INFO_BW_160; + else + rinfo->bw = RATE_INFO_BW_20; + } + if (rate->flags & IEEE80211_TX_RC_SHORT_GI) rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; } diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index d46eeebedb4b..9eab2af626d6 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -5106,6 +5106,14 @@ void ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *pubsta, status->rate_idx, status->nss)) goto drop; break; + case RX_ENC_S1G: + if (WARN_ONCE(status->rate_idx > 10 || + !status->nss || + status->nss > 8, + "Rate marked as a S1G rate but data is invalid: MCS: %d, NSS: %d\n", + status->rate_idx, status->nss)) + goto drop; + break; default: WARN_ON_ONCE(1); fallthrough; diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index cb23da9aff1e..331f5551477e 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -2295,6 +2295,13 @@ static void sta_stats_decode_rate(struct ieee80211_local *local, u32 rate, rinfo->he_ru_alloc = STA_STATS_GET(HE_RU, rate); rinfo->he_dcm = STA_STATS_GET(HE_DCM, rate); break; + case STA_STATS_RATE_TYPE_S1G: + rinfo->flags = RATE_INFO_FLAGS_S1G_MCS; + rinfo->mcs = STA_STATS_GET(S1G_MCS, rate); + rinfo->nss = STA_STATS_GET(S1G_NSS, rate); + if (STA_STATS_GET(SGI, rate)) + rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; + break; } } diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 2eb3a9452e07..1c0547769803 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -935,6 +935,8 @@ enum sta_stats_type { #define STA_STATS_FIELD_VHT_NSS GENMASK( 7, 4) #define STA_STATS_FIELD_HE_MCS GENMASK( 3, 0) #define STA_STATS_FIELD_HE_NSS GENMASK( 7, 4) +#define STA_STATS_FIELD_S1G_MCS GENMASK( 3, 0) +#define STA_STATS_FIELD_S1G_NSS GENMASK( 7, 4) #define STA_STATS_FIELD_BW GENMASK(11, 8) #define STA_STATS_FIELD_SGI GENMASK(12, 12) #define STA_STATS_FIELD_TYPE GENMASK(15, 13) @@ -979,6 +981,11 @@ static inline u32 sta_stats_encode_rate(struct ieee80211_rx_status *s) r |= STA_STATS_FIELD(HE_RU, s->he_ru); r |= STA_STATS_FIELD(HE_DCM, s->he_dcm); break; + case RX_ENC_S1G: + r |= STA_STATS_FIELD(TYPE, STA_STATS_RATE_TYPE_S1G); + r |= STA_STATS_FIELD(S1G_NSS, s->nss); + r |= STA_STATS_FIELD(S1G_MCS, s->rate_idx); + break; default: WARN_ON(1); return STA_STATS_RATE_INVALID; diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 78e8c286011e..68aa99acfdc4 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -3929,7 +3929,7 @@ u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local, u64 ts = status->mactime; struct rate_info ri; u16 rate; - u8 n_ltf; + u8 n_ltf, guard_factor; if (WARN_ON(!ieee80211_have_rx_timestamp(status))) return 0; @@ -4016,6 +4016,33 @@ u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local, ts += 4 * n_ltf; } + break; + case RX_ENC_S1G: + /* Set to duration of S1G OFDM symbol with normal GI */ + guard_factor = 40; + ri.flags |= RATE_INFO_FLAGS_S1G_MCS; + ri.mcs = status->rate_idx; + ri.nss = status->nss; + if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) { + ri.flags |= RATE_INFO_FLAGS_SHORT_GI; + guard_factor = 36; + } + + /* See 80211-2020, section 23.3.2 for S1G PPDU + * format and 23.3.6 for timing-related parameters. + * Here using the general structure for S1G_1M as + * in figure 23-3. + */ + if (status->flag & RX_FLAG_MACTIME_PLCP_START) { + mpdu_offset += 2; + ts += (14 * guard_factor); + + /* Add S1G-LTFs per streams */ + n_ltf = (ri.nss != 1) && (ri.nss % 2) ? + ri.nss + 1 : ri.nss; + ts += (guard_factor * n_ltf); + } + break; default: WARN_ON(1); From patchwork Tue Sep 6 04:48:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 603793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1D05C6FA83 for ; Tue, 6 Sep 2022 04:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232364AbiIFEtY (ORCPT ); Tue, 6 Sep 2022 00:49:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229818AbiIFEtV (ORCPT ); Tue, 6 Sep 2022 00:49:21 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8365C66A43 for ; Mon, 5 Sep 2022 21:49:14 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id a5-20020a17090aa50500b002008eeb040eso1442993pjq.1 for ; Mon, 05 Sep 2022 21:49:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=U4+WSp5Hf5M3UD/mtG12IEyiqRiUL1EUylH+ou79N/4=; b=FiN+ViXQE4l3iprSeA0fOa3Ns1mqzczlYcI0LPffda/PEuPyw4eGR87p7EawCl+LpE +XKSogS4p7+Tn6vxr/tL6edsrjPMyz/0KYiWzynh2F/NYWqoXEoE4Fg+HL2dcubpXNyl 7qxQSv5zRIrLxdMi6V3shkv4n5dfN9HMuqIu/FH14ZFuiQujoxRdVI0LfTNZlvxOlxat UeJ1ATNDWloSAfjLXJ2vTmOrYSO/htOe6gPVKeT98RMGpO+5uSTGYKYNtx+PeU9/sPfJ KGWxOlyTuv5mT3y95CM6UP8fR4QUtISvIxDDs2Y1wb4dF80qrurF156k7ipaN1PzBb+8 WACw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=U4+WSp5Hf5M3UD/mtG12IEyiqRiUL1EUylH+ou79N/4=; b=Ll1H75qPUNEBdYce81MhxFhF44CnyNh8aAdUZM/rjkSe1hqwvTuB5Y9CfLhNZW75t7 ls0VzXWVXqko9jl4KUymmQn2krABqgBAGdT6e5mpXI0aTUFDC5ja6F8FdfosSvJiaPdY KSOyEybhPsQM1um8CD+UxPEZQDXaA7yk1DoydKIMqtP4WA4iDqjknsOzM2qaTknCV4Es rgJreDbRlszimwMoIzirGFQWCp4VeklcTF5cs4l9Em9vKTJGfqusfwi4vH9tfPj+JqTP QAAOhhq4U4sBxbR33D4MaTNHCdJuml9HT/HJUuGiGD59NRDNi41FcvLBlsYwZhElWioz KNFg== X-Gm-Message-State: ACgBeo1gheADiW4PkLojsyUS3WmbHk5emb22mplEN9hU0LUrsP5Ku//I EM0GkPzntazRTxAeEDe0Q8seJA== X-Google-Smtp-Source: AA6agR6QiGWkscjTVjjMw6X5+Lk0w7e9/M+ggh2n1xNthVqb+0RiOa+82c5Ch0w/5RABr5lWuZup4w== X-Received: by 2002:a17:903:120a:b0:172:5a63:7442 with SMTP id l10-20020a170903120a00b001725a637442mr52735593plh.55.1662439754052; Mon, 05 Sep 2022 21:49:14 -0700 (PDT) Received: from virs-pc-021.intranet.virscient.com (124-248-138-161.static.lightwire.co.nz. [124.248.138.161]) by smtp.gmail.com with ESMTPSA id ij28-20020a170902ab5c00b00176b66954a6sm2726822plb.121.2022.09.05.21.49.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 21:49:13 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v3 11/12] cfg80211: support for calculating S1G bitrates Date: Tue, 6 Sep 2022 16:48:11 +1200 Message-Id: <20220906044812.7609-12-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906044812.7609-1-kieran.frewen@morsemicro.com> References: <20220906044812.7609-1-kieran.frewen@morsemicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Support for reporting and calculating S1G MCS bitrates. Signed-off-by: Kieran Frewen --- net/wireless/util.c | 113 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/net/wireless/util.c b/net/wireless/util.c index aeccb6ce595c..d9d7dde3d4f2 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -1384,6 +1384,117 @@ static u32 cfg80211_calculate_bitrate_vht(struct rate_info *rate) return 0; } +static u32 cfg80211_calculate_bitrate_s1g(struct rate_info *rate) +{ + /* For 1, 2, 4, 8 and 16 MHz channels */ + static const u32 base[5][12] = { + { 300000, + 600000, + 900000, + 1200000, + 1800000, + 2400000, + 2700000, + 3000000, + 3600000, + 4000000, + /* MCS 10 supported in 1 MHz only */ + 150000, + }, + { 650000, + 1300000, + 1950000, + 2600000, + 3900000, + 5200000, + 5850000, + 6500000, + 7800000, + /* MCS 9 not valid */ + }, + { 1350000, + 2700000, + 4050000, + 5400000, + 8100000, + 10800000, + 12150000, + 13500000, + 16200000, + 18000000, + }, + { 2925000, + 5850000, + 8775000, + 11700000, + 17550000, + 23400000, + 26325000, + 29250000, + 35100000, + 39000000, + }, + { 8580000, + 11700000, + 17550000, + 23400000, + 35100000, + 46800000, + 52650000, + 58500000, + 70200000, + 78000000, + }, + }; + u32 bitrate; + /* default is 1 MHz index */ + int idx = 0; + + if (rate->mcs > 11) + goto warn; + + switch (rate->bw) { + case RATE_INFO_BW_16: + idx = 4; + break; + case RATE_INFO_BW_8: + idx = 3; + break; + case RATE_INFO_BW_4: + idx = 2; + break; + case RATE_INFO_BW_2: + idx = 1; + break; + case RATE_INFO_BW_1: + idx = 0; + break; + case RATE_INFO_BW_5: + case RATE_INFO_BW_10: + case RATE_INFO_BW_20: + case RATE_INFO_BW_40: + case RATE_INFO_BW_80: + case RATE_INFO_BW_160: + default: + goto warn; + } + + bitrate = base[idx][rate->mcs]; + bitrate *= rate->nss; + + if (rate->flags & RATE_INFO_FLAGS_SHORT_GI) + bitrate = (bitrate / 9) * 10; + /* do NOT round down here */ + return (bitrate + 50000) / 100000; +warn: + if (!rate->bw && !rate->mcs && !rate->nss) + pr_debug("%s: rx status was not received yet!", __func__); + else + WARN_ONCE(1, "invalid rate bw=%d, mcs=%d, nss=%d\n", + rate->bw, rate->mcs, rate->nss); + return 0; +} + static u32 cfg80211_calculate_bitrate_he(struct rate_info *rate) { #define SCALE 6144 @@ -1612,6 +1723,8 @@ u32 cfg80211_calculate_bitrate(struct rate_info *rate) return cfg80211_calculate_bitrate_he(rate); if (rate->flags & RATE_INFO_FLAGS_EHT_MCS) return cfg80211_calculate_bitrate_eht(rate); + if (rate->flags & RATE_INFO_FLAGS_S1G_MCS) + return cfg80211_calculate_bitrate_s1g(rate); return rate->legacy; } From patchwork Tue Sep 6 04:48:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 603342 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3657FECAAA1 for ; Tue, 6 Sep 2022 04:49:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231891AbiIFEt3 (ORCPT ); Tue, 6 Sep 2022 00:49:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232343AbiIFEt1 (ORCPT ); Tue, 6 Sep 2022 00:49:27 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A53D6AA12 for ; Mon, 5 Sep 2022 21:49:17 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id o4so10060204pjp.4 for ; Mon, 05 Sep 2022 21:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=GNqXMxZS8O9iLZAjkr5TFaBGJEQ6fxE12NJY7BMykUk=; b=J4wGPnfEw5Muofoys49J6lrerVpDrMuJco6/lVYszSkROAOWrd4FBacyM1wN8IDOdp RVw/kh/So5nTRMFv73SvNPg7XN1jMnREI9/U2AtlkbviHYmJitz3lyek0WWYu3u2bJtq A5ifYixqaXjB3DBtUCBuWpYLjWsdEepwXIvrOsDgWA6GeNs/MZPp3z/7+3+lAAKfwSk+ qzssBybSOB8aJqCWdzEGGnggO7Nb9DpDxlgQbVfJ6J2I4auzwS1b6QSAXLbr+WxIFh3j gTn4FEBzeOCrjaeHESuuDXXBXMybnHOMDK1QQOfHNhzpuvqFkGOm/NURxA8qqjfACx70 PNOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=GNqXMxZS8O9iLZAjkr5TFaBGJEQ6fxE12NJY7BMykUk=; b=kkv4lU1rP581PYvBIjOMVPlJ23t4pWI+WziZrdo5WcB4iVgVdy8aO4JF+gh+Czo840 QSynppRzBtPOtdu89oUoiv8AoDwzvSN+cPa6krsjrjofwqC9soQNiH/KxBqIcVg2MNXm /9tP+yW1NL5N2hudoiHATtMUjprj3oUIDQkJDpxRYeEpHqRlfRJXz36o3VBqAqQBsX6N xSyTnEAt3RMhTNyiuYKoz9NSF764ke8SgAuGykpaEcL8IaKy36WX91QPv6X51rRR4Pbr f7U4/4dZgMg5Q9+5Z/Ytbv/1FP4yLx04D94LTWprv8ItTT1aZxSOaeDpvyPUSJe120Ss zKBA== X-Gm-Message-State: ACgBeo3zFnkAbEcTT2hNDs5T+dUqUDDs+JgoIGxX1+b6gS8T1YnDGggk IutEcKhLjMyaiDPqBO9xi9oE+A== X-Google-Smtp-Source: AA6agR4QguUUyE1XV+qqRgxexgmqqMtkR21hzOuw8C5GNWLSFAbggLvDRhM3zcS41JGzbafYotgrVg== X-Received: by 2002:a17:902:da8d:b0:175:4a53:9d0f with SMTP id j13-20020a170902da8d00b001754a539d0fmr28573163plx.13.1662439756744; Mon, 05 Sep 2022 21:49:16 -0700 (PDT) Received: from virs-pc-021.intranet.virscient.com (124-248-138-161.static.lightwire.co.nz. [124.248.138.161]) by smtp.gmail.com with ESMTPSA id ij28-20020a170902ab5c00b00176b66954a6sm2726822plb.121.2022.09.05.21.49.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 21:49:16 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v3 12/12] mac80211_hwsim: support for S1G rate information Date: Tue, 6 Sep 2022 16:48:12 +1200 Message-Id: <20220906044812.7609-13-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906044812.7609-1-kieran.frewen@morsemicro.com> References: <20220906044812.7609-1-kieran.frewen@morsemicro.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Include S1G rate information in S1G frames. Signed-off-by: Kieran Frewen --- drivers/net/wireless/mac80211_hwsim.c | 38 ++++++++++++++++++++------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 5ecbc80be338..6742f308ef7a 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -1577,7 +1577,14 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw, rx_status.freq = chan->center_freq; rx_status.freq_offset = chan->freq_offset; rx_status.band = chan->band; - if (info->control.rates[0].flags & IEEE80211_TX_RC_VHT_MCS) { + if (info->control.rates[0].flags & IEEE80211_TX_RC_S1G_MCS && + rx_status.band == NL80211_BAND_S1GHZ) { + rx_status.rate_idx = + ieee80211_rate_get_s1g_mcs(&info->control.rates[0]); + rx_status.nss = + ieee80211_rate_get_s1g_nss(&info->control.rates[0]); + rx_status.encoding = RX_ENC_S1G; + } else if (info->control.rates[0].flags & IEEE80211_TX_RC_VHT_MCS) { rx_status.rate_idx = ieee80211_rate_get_vht_mcs(&info->control.rates[0]); rx_status.nss = @@ -1588,14 +1595,27 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw, if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS) rx_status.encoding = RX_ENC_HT; } - if (info->control.rates[0].flags & IEEE80211_TX_RC_40_MHZ_WIDTH) - rx_status.bw = RATE_INFO_BW_40; - else if (info->control.rates[0].flags & IEEE80211_TX_RC_80_MHZ_WIDTH) - rx_status.bw = RATE_INFO_BW_80; - else if (info->control.rates[0].flags & IEEE80211_TX_RC_160_MHZ_WIDTH) - rx_status.bw = RATE_INFO_BW_160; - else - rx_status.bw = RATE_INFO_BW_20; + if (rx_status.band == NL80211_BAND_S1GHZ) { + if (info->control.rates[0].flags & IEEE80211_TX_RC_2_MHZ_WIDTH) + rx_status.bw = RATE_INFO_BW_2; + else if (info->control.rates[0].flags & IEEE80211_TX_RC_4_MHZ_WIDTH) + rx_status.bw = RATE_INFO_BW_4; + else if (info->control.rates[0].flags & IEEE80211_TX_RC_8_MHZ_WIDTH) + rx_status.bw = RATE_INFO_BW_8; + else if (info->control.rates[0].flags & IEEE80211_TX_RC_16_MHZ_WIDTH) + rx_status.bw = RATE_INFO_BW_16; + else + rx_status.bw = RATE_INFO_BW_1; + } else { + if (info->control.rates[0].flags & IEEE80211_TX_RC_40_MHZ_WIDTH) + rx_status.bw = RATE_INFO_BW_40; + else if (info->control.rates[0].flags & IEEE80211_TX_RC_80_MHZ_WIDTH) + rx_status.bw = RATE_INFO_BW_80; + else if (info->control.rates[0].flags & IEEE80211_TX_RC_160_MHZ_WIDTH) + rx_status.bw = RATE_INFO_BW_160; + else + rx_status.bw = RATE_INFO_BW_20; + } if (info->control.rates[0].flags & IEEE80211_TX_RC_SHORT_GI) rx_status.enc_flags |= RX_ENC_FLAG_SHORT_GI; /* TODO: simulate optional packet loss */