From patchwork Mon Jul 11 01:08: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: 12912732 X-Patchwork-Delegate: johannes@sipsolutions.net 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 A1259C433EF for ; Mon, 11 Jul 2022 01:09:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229621AbiGKBJA (ORCPT ); Sun, 10 Jul 2022 21:09:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbiGKBI6 (ORCPT ); Sun, 10 Jul 2022 21:08:58 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FEB2B1FC for ; Sun, 10 Jul 2022 18:08:56 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id cp18-20020a17090afb9200b001ef79e8484aso4665363pjb.1 for ; Sun, 10 Jul 2022 18:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uLwOARZB19JUF/kodrlpT2SqaqWPAUoPYWN2cKAx5dU=; b=HgmSAhfIBeD0V8EXaphiksXe0gYxbEDjpemNjjr+2AyFB3B+vY0pRPHSaa0HbzJY7a m5NjTUKPhh16mAdYXqgSdhHNX9Am0Q2wXHCXEIDKUIKr9T8O8p18lSAWjdCkxsM3d9Hg ASEidOyLs55ZTgIBSM3801nDeMrQv3bzKSl/V5e8t9eXS00XpSZDmGFTUucs9wvFhnU+ rJjlVSwoEz/Q/xpgBeahUDIe3wjFWUyUtTBJhbatyRnSicZMTpEX4dbNzxEPwRlKYEJt GUSSnDv0x0oDgTJ2A5mnIbgYM3WpXWRDroMiQ1hAWb1GdybeQFB6kJ0ixGG27hZpJE+G Kedg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uLwOARZB19JUF/kodrlpT2SqaqWPAUoPYWN2cKAx5dU=; b=IH26Q/zV+phUiu8vO7l1vkXpglaAZ8yDJx8movUeO+ippgytViZ3xD7U7BTm/5JxP3 jAaFhYlY67a4692CcUrb/8JyamtujBw7U5Wosq8AybK3H77pKODT92GZfna5wk+fgy3r Uhw+wjVixuwKzOsVHgcAWgAbmiyY+pmuE2JdUIW9V3dXa8LsQjN0p3lN41LX+OMvUffh YR46ZA5DKVYQ1OII5ipPXZH5djKfu+TmHoPFeLxrr54RGg0QbV7HBBZvaNmwXFEyKYV4 kmVHeLnKC27+SRFhVvVZ+Pnz++xBsrOE7Ssqxt833OgUhxa5WM4Ve+Gzdd8vKoXk8UKW 5m3g== X-Gm-Message-State: AJIora81JgYB6HtObySyjUI4ZxxflBa+nDZgnAY7WVzK1mnoV7zh8e76 Jj0xY8oaCnpnF/tTd4W1vgCyCOaKI1dVFKPm X-Google-Smtp-Source: AGRyM1s4krA41x4IsRUZVSH9J9Fg6tM4qMv/vzXsqiRH57eCZrOu/7w4rR3dupleWRGb+YrvSCJOkw== X-Received: by 2002:a17:903:22ca:b0:16c:4145:75a1 with SMTP id y10-20020a17090322ca00b0016c414575a1mr4612868plg.134.1657501735946; Sun, 10 Jul 2022 18:08:55 -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 ij5-20020a170902ab4500b0015e8d4eb1dbsm3341330plb.37.2022.07.10.18.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 18:08:55 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Kieran Frewen , Bassem Dawood Subject: [PATCH 01/12] cfg80211: regulatory: extend regulatory support for S1G Date: Mon, 11 Jul 2022 01:08:05 +0000 Message-Id: <20220711010816.45927-2-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711010816.45927-1-kieran.frewen@morsemicro.com> References: <20220711010816.45927-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. Signed-off-by: Kieran Frewen Signed-off-by: Bassem Dawood --- net/wireless/reg.c | 50 ++++++-- net/wireless/reg_s1g.h | 281 +++++++++++++++++++++++++++++++++++++++++ net/wireless/util.c | 31 ++++- 3 files changed, 349 insertions(+), 13 deletions(-) create mode 100644 net/wireless/reg_s1g.h diff --git a/net/wireless/reg.c b/net/wireless/reg.c index c7383ede794f..d9ed6b619164 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,44 @@ 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; + unsigned int i; + const struct s1g_oper_class *oper = reg_s1g_get_oper_class(regd->alpha2); + + 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; + } + } + + 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 +2574,16 @@ 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.h b/net/wireless/reg_s1g.h new file mode 100644 index 000000000000..69dd4e2cd4d3 --- /dev/null +++ b/net/wireless/reg_s1g.h @@ -0,0 +1,281 @@ +/* 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 for that CCA classification + * @start_freq: The start of the valid frequency range for the CCA + * classification + * @end_freq: The end of the valid frequency range for the CCA classification + * @max_bw_khz: The maximum valid bw for the CCA classification + * @align_to_end: True if the maximum valid BW 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; + u8 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 + * @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; + int class_count; + struct s1g_cca_classification class[]; +}; + +/* 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 = 0, + .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 = 1, + .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 = 0, + .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 = 0, + .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 = 0, + .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 = 0, + .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 = 0, + .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 = 1, + .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 = 0, + .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 = 1, + .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 = 0, + .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 = 0, + .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), + .supported_chan = jp_supported_channels, + .n_supported_chan = sizeof(jp_supported_channels), + } + }, +}; + +static 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 &country_class_us; +} + +#endif /*__NET_WIRELESS_REG_S1G_H */ diff --git a/net/wireless/util.c b/net/wireless/util.c index b7257862e0fe..412403d29c22 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,23 @@ 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->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; + } +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 +122,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 +130,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 Mon Jul 11 01:08: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: 12912733 X-Patchwork-Delegate: johannes@sipsolutions.net 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 BBBEBC43334 for ; Mon, 11 Jul 2022 01:09:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbiGKBJB (ORCPT ); Sun, 10 Jul 2022 21:09:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbiGKBI7 (ORCPT ); Sun, 10 Jul 2022 21:08:59 -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 29EF29FCC for ; Sun, 10 Jul 2022 18:08:59 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d10so3541459pfd.9 for ; Sun, 10 Jul 2022 18:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C4/CKqP+X1iR04x3vc0jrPvHXSENxHXVZdbRPwIl99c=; b=sBLzmEjBp3AB8IS0gG8sctsRNNVI/8/3t0Doj7ZWbzAd783deBuZINRdQi1Lz36n9+ KudOHqc/DawJQKSO+O3KOXx30gBXlARmvDd3GG3RownC/o01E9cNTvsxpJpktwbqVsG4 4W1FKR9KRwm2pGZHhm2BEIwjHV7PqzeNOOSa4k3h/8DM6KMxrJ8d5YN8Dx6d8sw7pue5 emSFLq/usamxbkRGzXJkp5QQTwX6Q1PaC/WLRZVlMrAnIWYKGoPKLDJrQLR6RNEctNif 5e3ZOHgtF+UowVbug3YbUjdKS2H1+29+WAjlDy35VWDW+w1unRYtKpOYK3RNM+rS/NG1 P4/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C4/CKqP+X1iR04x3vc0jrPvHXSENxHXVZdbRPwIl99c=; b=dEXnH7WlN2SY48dFx/SfC1jNZixzR95OXjQaGgQeoNL8zUL0jNPi7PMBH+I8iLdiBj pzAJONDA2D1qK8md8sSMt6aw1m7WtRDiYBKLJePDKGF7nLHV+im9dqT6qx2bAQyaPsAN SRlDtwoAcz9VrkeqB+5LDjxSS89XV+iGDIAaFWv+a2Ey+iTjK0PZKdI/pMmPCKwtTjGf KjgAbyhGMZJG+xjyDstPQu5VcY4+yGX9IysEysXWlYnC9d+Abnpg2jK9uxrKn9HXnqFu PpKrqLizofyc+b7jD3kfHiVcgLKvME7NcJbaKNVWtkC9MldDeozsyU5pefzUQ3SsRFRX P/Xg== X-Gm-Message-State: AJIora8BFZPnLQDFbb+ZNuXdDSWEd8BTWp9RrvPuOQ+b+SB/PqxEbcJr YyudpFTcz6Oe4XMjhx5DZhQ9jQ== X-Google-Smtp-Source: AGRyM1t0U4N2I2k1VhTnbat1Za2S+udrEgdp3UKV0RcE0ntSqMo4tUr/xsX/Sf4N/mA2Uj89Bl0fGg== X-Received: by 2002:a65:4685:0:b0:416:ce1:8d9b with SMTP id h5-20020a654685000000b004160ce18d9bmr1171162pgr.529.1657501738701; Sun, 10 Jul 2022 18:08:58 -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 ij5-20020a170902ab4500b0015e8d4eb1dbsm3341330plb.37.2022.07.10.18.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 18:08:58 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Kieran Frewen , Bassem Dawood Subject: [PATCH 02/12] mac80211: update TIM for S1G specification changes Date: Mon, 11 Jul 2022 01:08:06 +0000 Message-Id: <20220711010816.45927-3-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711010816.45927-1-kieran.frewen@morsemicro.com> References: <20220711010816.45927-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.11-2020. Signed-off-by: Kieran Frewen Signed-off-by: Bassem Dawood --- 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 c3e14ef20c05..3d83f838d728 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -4710,9 +4710,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; @@ -4743,13 +4743,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 Mon Jul 11 01:08: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: 12912734 X-Patchwork-Delegate: johannes@sipsolutions.net 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 42F6BC43334 for ; Mon, 11 Jul 2022 01:09:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbiGKBJE (ORCPT ); Sun, 10 Jul 2022 21:09:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbiGKBJD (ORCPT ); Sun, 10 Jul 2022 21:09:03 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 240EEB1F2 for ; Sun, 10 Jul 2022 18:09:02 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id o15so3576721pjh.1 for ; Sun, 10 Jul 2022 18:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cXVbTmInU8G8tlN7P+BDM9qyU7c1qqtqt8NCUQ0GTLY=; b=ZEpTJtLfKz1lDgD+Qf4RQk3NUNywZwcaqNnbmRLKt/PTBb0fWIt73s9wpXoDVEzLy3 vrvDLMj9TTHW6lCT9fzJuf2uxywVFO71UNyfx1fXGNJopppF4SsPvcuha0+SBAn/fQgf 31qWv/pfx11YvejP5lq+VQbGXLO0ibCFLj2jgtS0qCQpQtE12RqEm/cbISx2Dl+nNG5F xzf8D3gm7cvhlk2Err3OesKWm9psFB3w7mPqr7dml4wteCXFuDy/8J2kjoGT2NtNkc57 O5h7KqDt+PRbwzalWjz7QhxrPbyOWJUlKrRpVxdabecezoAwlVv3vDAZ6N2sA2ZIkC4F kqYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cXVbTmInU8G8tlN7P+BDM9qyU7c1qqtqt8NCUQ0GTLY=; b=H6S8tXYh2e12Siw+xt/B9vxzP1sMzclPu+4fblD799BkWUXrGr/LEho41QaHyYpOru UmvRedMipXyWrvND8IWliGF0tW/MNG4s6hzLYakomOqyislzIM2vZbzUEx8ZIV9Re2MP 98EVN0yR9MH1wBWxzT984F7ADIWM8y8xzYRK1dS5+p4rVqvMme2a/g/nKVciJid0FtuH zLeGDyqcPrzQie9kEcaH4QTzmCSltBBbx7gTTlzDoOQ+R7dWPHHkKSNFik5GsmOKqjGZ R8t6PCjmeLXv8TqSyxOa6xkqG9YAqCbOe+gZ+VKdSVhFOnUP8Wj6n0nCXmTd+/qqY1H6 0tYQ== X-Gm-Message-State: AJIora+Fq0PK3wPA6hHyydxNMeqIfQGqmNIV8IV/XHR11SE9KBY1MZZy EltWdfDC01XvaQ/HIwU6gtWScllf9iG77Xk9 X-Google-Smtp-Source: AGRyM1utQZi7qV3/xAtkfBdUPm27YD6Vxn1KHu5w7wWC7nO5iSp8Y/Pm8US1/sM3oPuvqm6pHyKQmg== X-Received: by 2002:a17:902:7c06:b0:16a:755f:86dd with SMTP id x6-20020a1709027c0600b0016a755f86ddmr15831708pll.82.1657501741441; Sun, 10 Jul 2022 18:09:01 -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 ij5-20020a170902ab4500b0015e8d4eb1dbsm3341330plb.37.2022.07.10.18.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 18:09:01 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Kieran Frewen , Bassem Dawood Subject: [PATCH 03/12] mac80211: S1G beacon/short beacon support Date: Mon, 11 Jul 2022 01:08:07 +0000 Message-Id: <20220711010816.45927-4-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711010816.45927-1-kieran.frewen@morsemicro.com> References: <20220711010816.45927-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 Signed-off-by: Bassem Dawood --- 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 996782c44838..7859b8b11968 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1310,7 +1310,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 27f24ac0426d..1fd461ed746d 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -656,6 +656,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 b387f5f4fef0..b4c2f4e9083e 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1227,6 +1227,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 2190d08f4e34..19fa3f830abc 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -257,6 +257,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 3d83f838d728..632df040f07f 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -5065,6 +5065,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) @@ -5102,7 +5114,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_id) < 0) From patchwork Mon Jul 11 01:08: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: 12912735 X-Patchwork-Delegate: johannes@sipsolutions.net 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 7A2E8C43334 for ; Mon, 11 Jul 2022 01:09:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229661AbiGKBJI (ORCPT ); Sun, 10 Jul 2022 21:09:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229654AbiGKBJH (ORCPT ); Sun, 10 Jul 2022 21:09:07 -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 A9C97A47D for ; Sun, 10 Jul 2022 18:09:04 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id f11so2617781pgj.7 for ; Sun, 10 Jul 2022 18:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fWihvkUSKIGivzcP1YXtA/DPAqQK57hLC5nzlOA+jRM=; b=e08PkTGOJJ2e3R2jH2lGYGhDbeMmWyALvabgwED2WK3XUDvg1nkpodJg/m2uMYC6KR OjCTPUCyi1vereghSC3ONavx8cfONssU45z14vqARFttPcu8+Ud9dG3+5Qe5rltnITEi ImR5NKmo1JyTM4ftDDcJf0JuwHyaN7rvO3mkhtLwW2Jurm8ztz2Jw/edZmb4sFMiB0Lh JaWo1ow8I2QoAwZqY76jPp6z2yaPUEYwUzjsUx7S0kkt8wJIIWe51ctHK9ld6t8ag/G1 pNNG7Puxd8PokBtSIaKPLhs++6sFXfYXFOr9ULGYM0zZiQC1GaDEHXquEtE9aN1gIvdq rIPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fWihvkUSKIGivzcP1YXtA/DPAqQK57hLC5nzlOA+jRM=; b=pUo5NI8Qy4E6yfK8cGKN9wjajRW2FguxeNi+AVruSa3KPmQVtCvGaFGDL+dAFe3vVI 3rNqv0pXz2LoDjKpTtUd3xsCf5MezPIgs9klvfAEhw6y4B5wUi2biPqY+m3J63iGplXu ha+Dk6v3KPyJvbucbquJQqksyIqd4nIdFpNxUFwnxtMTPKK7YeVVqUyo/sdv0xB/Spfr viu4SjWxrpQBrg9ZxYaauamnPCdtVmf8iU1rRGHNt3OF2TQnlAYmeD9NQQne6rNUAiWL 5hncQCC3d0wWCv/4oC/puZw+ABjPrGJ5Rzl5tZUnq/GMX+9A3bwPCM0D8AkzR2G1IJap +bVA== X-Gm-Message-State: AJIora/iRClYCaUtnibuViN4HOIzS+nh2QDyI1VabAY6iDes5Rn24l9q p2Eu5h2X6kTkYJDm+ht2S4UWFQ== X-Google-Smtp-Source: AGRyM1sWefQTvt/L95aFPWGO5MI4V+SqpjypcEoUm67ng2hltIPK/nxkocTA/gFmbnTm3DbBXbA3hA== X-Received: by 2002:a63:86c2:0:b0:415:eb:d166 with SMTP id x185-20020a6386c2000000b0041500ebd166mr13268946pgd.124.1657501744199; Sun, 10 Jul 2022 18:09:04 -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 ij5-20020a170902ab4500b0015e8d4eb1dbsm3341330plb.37.2022.07.10.18.09.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 18:09:03 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Kieran Frewen , Bassem Dawood Subject: [PATCH 04/12] nl80211: support setting S1G short beacon period Date: Mon, 11 Jul 2022 01:08:08 +0000 Message-Id: <20220711010816.45927-5-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711010816.45927-1-kieran.frewen@morsemicro.com> References: <20220711010816.45927-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 Signed-off-by: Bassem Dawood --- include/uapi/linux/nl80211.h | 6 ++++++ net/wireless/nl80211.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 89f64f46b98d..bd6e2cae1dd3 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -2694,6 +2694,8 @@ enum nl80211_commands { * connection. Used with %NL80211_CMD_CONNECT. If this attribute is not * included in NL80211_CMD_CONNECT drivers must not perform MLO connection. * + * @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 @@ -3214,6 +3216,8 @@ enum nl80211_attrs { NL80211_ATTR_MLO_SUPPORT, + NL80211_ATTR_SHORT_BEACON_PERIOD, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, @@ -4890,6 +4894,7 @@ enum nl80211_bss_scan_width { * Contains a nested array of signal strength attributes (u8, dBm), * using the nesting index as the antenna number. * @NL80211_BSS_FREQUENCY_OFFSET: frequency offset in KHz + * @NL80211_BSS_SHORT_BEACON_PERIOD: S1G short beacon period in TUs * @__NL80211_BSS_AFTER_LAST: internal * @NL80211_BSS_MAX: highest BSS attribute */ @@ -4915,6 +4920,7 @@ enum nl80211_bss { NL80211_BSS_PARENT_BSSID, NL80211_BSS_CHAIN_SIGNAL, NL80211_BSS_FREQUENCY_OFFSET, + NL80211_BSS_SHORT_BEACON_PERIOD, /* keep last */ __NL80211_BSS_AFTER_LAST, diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 6a45801c783c..ab47e4130141 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -798,6 +798,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { NLA_POLICY_RANGE(NLA_U8, 0, IEEE80211_MLD_MAX_NUM_LINKS), [NL80211_ATTR_MLD_ADDR] = NLA_POLICY_EXACT_LEN(ETH_ALEN), [NL80211_ATTR_MLO_SUPPORT] = { .type = NLA_FLAG }, + [NL80211_ATTR_SHORT_BEACON_PERIOD] = { .type = NLA_U32 }, }; /* policy for the key attributes */ @@ -5654,6 +5655,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 Mon Jul 11 01:08: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: 12912736 X-Patchwork-Delegate: johannes@sipsolutions.net 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 B5D1DC433EF for ; Mon, 11 Jul 2022 01:09:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229694AbiGKBJL (ORCPT ); Sun, 10 Jul 2022 21:09:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbiGKBJK (ORCPT ); Sun, 10 Jul 2022 21:09:10 -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 6C1DA9FD0 for ; Sun, 10 Jul 2022 18:09:07 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id t5-20020a17090a6a0500b001ef965b262eso3542429pjj.5 for ; Sun, 10 Jul 2022 18:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Qw8ezip5HpbHXc3qzfiV/NhGAs+vlPEN8xfZY1FMMjQ=; b=aeqeTu6KLTvMPqXCWUVpYSuvoXzz1m17/mxcG7edVyrlOkAzI5Eempxm9Zu3RGrrhL JE/Elxe8IuSPv3uOmYsLjrLjFafDKXfE74dXFlICfAkpuxoR9YuDWH+nlEaNyBoTGUEW zpGQNgYD5oW1Mt5eDDunYFUEKMDszvTETr1e0MbwJYi01WXHCbTc+mk4bET0YV33/IHA ZJj1Hg6UXOeF/P2WRXtXYr4oyMRJNlh+IaviQhlkEG85vowaFesha+9V8lWtovWTviAo 7SaNdWNuouQd23ks8ohSnsZtB1Zrdf0xu/FpWZDw24I4i/0Oatz5Mh2JB/jKNXT9k7qL 2Jeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Qw8ezip5HpbHXc3qzfiV/NhGAs+vlPEN8xfZY1FMMjQ=; b=18zB46xK9KWw9jMDomZlQb5PAjwf/9tYmeeqyRNwfaIwwLv+q6BTgo1WXqKtY87aIv rqv0zNd6qSgnfKTOcDIRrMQvoYy3+4FObfbWkVXU79a5kz6DdZdDsi/AJAAqimyFWsgb OthOz1rqmA/IdNqZ4xzcudmWZOYFyPtRfvMP0N5Q0iPKH3z6/TFWIU03KZ1QTUbqvOBR IaVZcWSr/IYH+WcQP7jIrHPptU+Cs34WG2aByZMSUr2kpkL21EDAFR1SROYlHpfbBsHu l5Iu70KbRMeCZRpW0/cYVIKqrxWZ5ukozGJ5i0HmP4XJm8Dn9yGa+yU1ELR71jJD85xY NvTw== X-Gm-Message-State: AJIora8VtUe/9iffDUPi/Mueqq+1zJ8tkrt6Ownk8xRwQciMS717SpVG jj7G1wV1RTXPPYSTJ2gBLmOrag== X-Google-Smtp-Source: AGRyM1tXZ6uscQhjUJ1+EPU9DLSwgYyXBbjL4nyCkLQa60qmiIabE8IuVAwmHGFQoJ0TUUi0F4J6lw== X-Received: by 2002:a17:90a:2e03:b0:1ed:2cd5:6c4e with SMTP id q3-20020a17090a2e0300b001ed2cd56c4emr14613299pjd.225.1657501746929; Sun, 10 Jul 2022 18:09:06 -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 ij5-20020a170902ab4500b0015e8d4eb1dbsm3341330plb.37.2022.07.10.18.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 18:09:06 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Kieran Frewen , Bassem Dawood Subject: [PATCH 05/12] nl80211: support advertising S1G capabilities Date: Mon, 11 Jul 2022 01:08:09 +0000 Message-Id: <20220711010816.45927-6-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711010816.45927-1-kieran.frewen@morsemicro.com> References: <20220711010816.45927-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 Signed-off-by: Bassem Dawood --- 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 bd6e2cae1dd3..71074332ccc5 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -3933,6 +3933,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 */ @@ -3953,6 +3957,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 ab47e4130141..077dc2938551 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -1942,6 +1942,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 Mon Jul 11 01:08: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: 12912737 X-Patchwork-Delegate: johannes@sipsolutions.net 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 00A2FC433EF for ; Mon, 11 Jul 2022 01:09:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbiGKBJO (ORCPT ); Sun, 10 Jul 2022 21:09:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229715AbiGKBJN (ORCPT ); Sun, 10 Jul 2022 21:09:13 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ACFD15A23 for ; Sun, 10 Jul 2022 18:09:10 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id fz10so3572088pjb.2 for ; Sun, 10 Jul 2022 18:09:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nh259kpnKYV3BBVAWC0uC/nH7ZHNh5TP6sTi10lPBHs=; b=LuIkDiAw3AFZGIZme5IkAZBtvozjgZQ0W389V2TYtKjBE5fwBL87/nvVRfM9p8BUq6 GKnFkN583fTW33WifoOTJVUzZuNPMvwb8MoweHN1FyonVgC2bXB7RvnqvPS2DQDhfU8j 7gSmDev4rGs7yBzKULiNcKqjqdKukNH6dkuH3doMygPkD9QVZE/Tpr7L0nRNxuXesxry XD+o6zarrL7bnJozqb+SBHnEdYOzUBOfjmDMfh2xjb31cUOReyJ3epnFzbUT8LLjkKeE k41/ZbpvVr4tUcYXcElQ9Yemp8AarXWxn6k0ud6No4/YAuDaRtv2z6YbqdrNNnB0fmzE aWNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nh259kpnKYV3BBVAWC0uC/nH7ZHNh5TP6sTi10lPBHs=; b=7rxdnn946Gy/5mLS1ShURVR8oo+PhfvPqTFCdR4u1Q/3++qiJGPO1mrakRo+y/E0C9 fqm9ridV+M6EpBLoZ18/ceyVAnZewGBy6VgNRnZ/PaMmlcrh6sdI9hHYbSwyakrxCPqv LLmYWGkcDLMdtJpyFqXrdW5LenJXF+2TwtAYRY0tbardd1zHLW5MyotausjJ7oR0U8xA JAviy4bZkQfAVmiYGeGh+UAKDSiccSuIAU99PkOlUdytl57AtdamqcshI0c2RP62HqLu iMhjdpyICRtBgga0RDjPLvME8KnGpFZS0qEaFGPLUU9GOFkUY6qYhciQbiSpvmdJm8V7 /GRQ== X-Gm-Message-State: AJIora8OCvH9Kdf/XaGNfVSE5KW+E+Wm64VujLehB2+AH75VPCg9Mbq7 E6xEGRRIw3aX7wOoAIOjrI5r5g== X-Google-Smtp-Source: AGRyM1uwttwqrDnmrMTdiHwtH5v9Ad6ZQjcj2iiEERfL2vFwodAvvaCtumSNNpH+VGVjY8PxR6+x3g== X-Received: by 2002:a17:902:8487:b0:16b:de14:43a7 with SMTP id c7-20020a170902848700b0016bde1443a7mr16197829plo.44.1657501749688; Sun, 10 Jul 2022 18:09:09 -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 ij5-20020a170902ab4500b0015e8d4eb1dbsm3341330plb.37.2022.07.10.18.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 18:09:09 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Kieran Frewen , Bassem Dawood Subject: [PATCH 06/12] mac80211: support ieee80211_ext format Date: Mon, 11 Jul 2022 01:08:10 +0000 Message-Id: <20220711010816.45927-7-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711010816.45927-1-kieran.frewen@morsemicro.com> References: <20220711010816.45927-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 Signed-off-by: Bassem Dawood --- net/mac80211/rx.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index d017ad14d7db..feab1d58e932 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -4772,6 +4772,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; @@ -4787,7 +4788,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; @@ -4802,13 +4803,16 @@ 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)) { @@ -4868,7 +4872,10 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, continue; } - rx.sta = sta_info_get_bss(prev, hdr->addr2); + 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_prepare_and_rx_handle(&rx, skb, false); @@ -4876,7 +4883,10 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, } if (prev) { - rx.sta = sta_info_get_bss(prev, hdr->addr2); + 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_prepare_and_rx_handle(&rx, skb, true)) From patchwork Mon Jul 11 01:08: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: 12912738 X-Patchwork-Delegate: johannes@sipsolutions.net 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 DFAE3C433EF for ; Mon, 11 Jul 2022 01:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229717AbiGKBJR (ORCPT ); Sun, 10 Jul 2022 21:09:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbiGKBJP (ORCPT ); Sun, 10 Jul 2022 21:09:15 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED55615A24 for ; Sun, 10 Jul 2022 18:09:12 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id y18so3203979plb.2 for ; Sun, 10 Jul 2022 18:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HP2Xh2jTVuEvoNP5QULFaNS+5OUv0Z2UMJAizsDyPds=; b=PFor8hDk3U8LxtvWU0mbNtVd8XtId6oJbGrj7y7YVmvhAMByUa8pXj+xbDb3MHGnjq uyzKzHm5ZCSyfa8ckMvSn1w4WYpbBGzPpjXx2rHtsDLg7o6jKWXojyqtrpO0Z5n4EEIS tVI9XTpDP/NFrqeo+c72Mq1qGwvUocTHEyMj5zFJNXUf4wKcGTu5lCapNEEqkx2cI2I7 6M7qH3V2kFWM9knIZOIDTUT48sB5UJYFqiJEfqf0SP1yzQP4DcJ0hYCUKe31RH3KqAEF RWwtnjoJs5OIf1jROlGCWre8L/41a8iHkJtcoP2tnRdrKkKC0tvy0obqJm3PugSzcsvL PIPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HP2Xh2jTVuEvoNP5QULFaNS+5OUv0Z2UMJAizsDyPds=; b=oaCSFNmIjGFqI+Skk8PM9QiVgVQxj6Bbs7ZgMS2HdkaLddqWQD6IoM36W7Q9JYWKYS 8iFWfxwspkR5fMrMhH18pFKzqJxNCNsfJwfFc2u5swVyMIwyWPsuMvY3S1Xm6iVW9QkG 6yVZKXFxNooCIYqrkBfZCAMJhariajmD4UqJlxeVhHayMjCdf4iKrfOUs5T0XWiQxneM 2djvXf8Kk/jHUgYsSz1m+jW9LcjWPHsnim/iCbRHXNCaqWdrWf5e+ePrCgPRDx+qPZYR XnEz71BlJiDT0HA2GoK8+yS2vBUIsOsNSjigJrzS1dnywipsQD7lgLSUPJ0/DgB5/HSo oMtg== X-Gm-Message-State: AJIora+UB4RHT7RVXK7oL6AS+ty5h7WKvG1V5lNcLRb/+iZHOPNcY2Bv wXLoNyaWjtwUKlHc7uH/fVz42g== X-Google-Smtp-Source: AGRyM1twaeuK3LLDlf0Fxs5IajXc+Sn8mvqOzZc9oQcC05Pz5yS+TStp5jusUYaC/on+D+3eh14C/w== X-Received: by 2002:a17:902:6a81:b0:16b:d807:9acd with SMTP id n1-20020a1709026a8100b0016bd8079acdmr15473644plk.40.1657501752390; Sun, 10 Jul 2022 18:09:12 -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 ij5-20020a170902ab4500b0015e8d4eb1dbsm3341330plb.37.2022.07.10.18.09.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 18:09:12 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Kieran Frewen , Bassem Dawood Subject: [PATCH 07/12] mac80211: S1G capabilities information element in probe request Date: Mon, 11 Jul 2022 01:08:11 +0000 Message-Id: <20220711010816.45927-8-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711010816.45927-1-kieran.frewen@morsemicro.com> References: <20220711010816.45927-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 Signed-off-by: Bassem Dawood --- net/mac80211/util.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/net/mac80211/util.c b/net/mac80211/util.c index bccc3a309ed0..51a2c1dee360 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1832,6 +1832,43 @@ 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) { + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + struct ieee80211_s1g_cap s1g_capab; + + *pos++ = WLAN_EID_S1G_CAPABILITIES; + *pos++ = sizeof(s1g_capab); + + memcpy(s1g_capab.capab_info, + sband->s1g_cap.cap, + sizeof(sband->s1g_cap.cap)); + memcpy(s1g_capab.supp_mcs_nss, + sband->s1g_cap.nss_mcs, + sizeof(sband->s1g_cap.nss_mcs)); + + /* override the capability info */ + for (i = 0; i < sizeof(ifmgd->s1g_capa.capab_info); i++) { + u8 mask = ifmgd->s1g_capa_mask.capab_info[i]; + + s1g_capab.capab_info[i] &= ~mask; + s1g_capab.capab_info[i] |= ifmgd->s1g_capa.capab_info[i] & mask; + } + + /* then MCS and NSS set */ + for (i = 0; i < sizeof(ifmgd->s1g_capa.supp_mcs_nss); i++) { + u8 mask = ifmgd->s1g_capa_mask.supp_mcs_nss[i]; + + s1g_capab.supp_mcs_nss[i] &= ~mask; + s1g_capab.supp_mcs_nss[i] |= ifmgd->s1g_capa.supp_mcs_nss[i] & mask; + } + + memcpy(pos, &s1g_capab, sizeof(s1g_capab)); + pos += sizeof(s1g_capab); + /* No more IEs relevant for S1G */ + goto done; + } + num_rates = 0; for (i = 0; i < sband->n_bitrates; i++) { if ((BIT(i) & rate_mask) == 0) From patchwork Mon Jul 11 01:08: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: 12912739 X-Patchwork-Delegate: johannes@sipsolutions.net 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 39E87C43334 for ; Mon, 11 Jul 2022 01:09:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229730AbiGKBJ0 (ORCPT ); Sun, 10 Jul 2022 21:09:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbiGKBJR (ORCPT ); Sun, 10 Jul 2022 21:09:17 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75240B485 for ; Sun, 10 Jul 2022 18:09:15 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id o15so3577033pjh.1 for ; Sun, 10 Jul 2022 18:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oL39zzxpS0oN7YLsNwfPuUDWDQJZalCgqn70twVNd4s=; b=rxxdUGCDzbkmT+x7kGNtSqYrX+gQ9KBO/68RspFK3IZEyyEiTNxrAQbxAk8uDvVtTh E+ldQEdXzIvuK6UvkLpKPVdZW5DUhbPJ747mJsLYxOFFLRANJcJAeT8wwWCFmvswKhDX 5fUa9XvkLCG3r2zLmYcP7hWJ1xuk0YzG6RpA205UYuvKbuHrRI/cFyNdlPQzUcEB8A7t 7260XpL0gGZHx0AqJs9+MKp9rr5zCyyIFkzmDG/k30xU0eo/fP57NF8RT6K6LV+kpNk+ T2ovr3cB3gYIe3rcPJeqQQc+8tG+yUfwNjxAe2eJ48dGKs067xj1FOqxyHbU4GrmEwyr p8+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oL39zzxpS0oN7YLsNwfPuUDWDQJZalCgqn70twVNd4s=; b=3s9uivsqALKuGtkHN2GVU4XW1fFiQHocYW+LWY/NEtWsSykNvVhFpRHm8hC2i1EK4u 3lbD+dY6f9/KvgOxMDVk6H0vdELiXbDhBRVVZTsl5q3lQ1+bKz3w9ZLKZEXtm902MxAu Lfm+9sZBNfXgW3oCyTWMO6uMbBF57f+ViEdhUlNHWUllyv/jT6E2eAJuvrW+lspAbCXR GTHNO4t4tqxpzCjSVY9V8S5iX1gGf1Tmsun04C5e0t6GnIjo6YGq2gpk2y58nGi50wFX huS06IPI0cj0cwsC46SoqHruxqr14H1R6IU60kwd90HKuJJ1VjDilSlIlSjUixjZMP4d x6qQ== X-Gm-Message-State: AJIora+jCEsi4JFNbHWdInnH2RvstnaOnSlNFucuUwH5fxohPcAI/dwH MtY9QBWlAAYKHV0M0Pew1LmEIbWKSA+smWtS X-Google-Smtp-Source: AGRyM1u0A/ptDvOrOcQ7GOSnb2y/d2GyhHFBmAqDy5JrBK2zwPZVarNQJVcQxNVuL35IBg+mDWZSZA== X-Received: by 2002:a17:90a:fa05:b0:1ef:89d1:1255 with SMTP id cm5-20020a17090afa0500b001ef89d11255mr14694363pjb.73.1657501755105; Sun, 10 Jul 2022 18:09:15 -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 ij5-20020a170902ab4500b0015e8d4eb1dbsm3341330plb.37.2022.07.10.18.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 18:09:14 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Kieran Frewen , Bassem Dawood Subject: [PATCH 08/12] cfg80211: S1G rate flags Date: Mon, 11 Jul 2022 01:08:12 +0000 Message-Id: <20220711010816.45927-9-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711010816.45927-1-kieran.frewen@morsemicro.com> References: <20220711010816.45927-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 Signed-off-by: Bassem Dawood --- include/net/cfg80211.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 7859b8b11968..47f71fb5d07a 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1608,6 +1608,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), @@ -1618,6 +1619,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), }; /** @@ -1634,6 +1636,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, @@ -1645,6 +1652,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, }; /** @@ -1667,7 +1679,7 @@ enum rate_info_bw { * only valid if bw is %RATE_INFO_BW_EHT_RU) */ struct rate_info { - u8 flags; + u16 flags; u8 mcs; u16 legacy; u8 nss; From patchwork Mon Jul 11 01:08:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 12912740 X-Patchwork-Delegate: johannes@sipsolutions.net 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 F0BA2C433EF for ; Mon, 11 Jul 2022 01:09:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229744AbiGKBJa (ORCPT ); Sun, 10 Jul 2022 21:09:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbiGKBJ0 (ORCPT ); Sun, 10 Jul 2022 21:09:26 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0531315FE2 for ; Sun, 10 Jul 2022 18:09:18 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id r1so3181108plo.10 for ; Sun, 10 Jul 2022 18:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7+ne/UYswmphwy9OweGF6u67TAf6M/bMHMTMkD1A5YU=; b=w+/sYLpOw4FnugUFIuzt8mqPeyFevJc1FYDEnWEvBx57/f6VMm2pEtWU+ErcP1Yxh9 7EbnjCfxTZi0Obs4oDDolEWOgDDLCpjk5W0VPEXf+rOhQLoWpFk3fqhkdk9aHBFyZgMT kj+W1oFdnRTW5EXYTLnhVtZuFt4mHVGNhOVnAgybYjswlAUtzUq1xX/++BPEef1glspp bdU79lc8FZSASCmN41Pk0ODHaJCQzW3PPH8Ga3alItkd7dOO0WxnTWb52Co6VbMZexVA cEf56qsCXKGMURx3/k8bQ0RN2uPoLNbvNoJSnU15bXaJhubqT6BfY25uwNb/3gSNp9yM d0QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7+ne/UYswmphwy9OweGF6u67TAf6M/bMHMTMkD1A5YU=; b=s9IU/cE6HSa939wAVT4pDrxDUaKByr7SB9Gkn0i0h7o9S+nwXv1CbVLQlMJiMgZtpL 1ch2BU4liZqi5HjY1coifXzez5aNurLMCBJL4KQizohYSH4MVWxtKk10SdrjjygrJ2nl HxhoSvIcISnUjofZs8kO/o6m243G/97sWw3GO++gcMxJZxlatF59hzjQbR8ZnFZ8JX08 INtu/va38Sq2t7ReKbsgBEaMIwF9WMhWzftRf+x++HvlcVz5/qk7iNrDKoEB+DmQ5P0O 1JVx+KTFhFF9DMELjgrNNGcz85z3u244OEQQTKWtxXLL+n9j/Px9n7P5tsvXrOI35OVQ 5/rg== X-Gm-Message-State: AJIora+voBp7aEN3zBZOe+ox+XWddxR/smOcNWbuTl+UkD25aQSns6oH e2oHDhH4Rd4MBKVGOXQ7srGKog== X-Google-Smtp-Source: AGRyM1uVcMqGd/Zyza6/cJP5TUlGDeE5PDOWt9poK+k60xaxxo6Z79YXcXTuMnYKsCL+JyqSfcIa3g== X-Received: by 2002:a17:902:7209:b0:16b:fa09:5d6 with SMTP id ba9-20020a170902720900b0016bfa0905d6mr16308442plb.120.1657501758016; Sun, 10 Jul 2022 18:09:18 -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 ij5-20020a170902ab4500b0015e8d4eb1dbsm3341330plb.37.2022.07.10.18.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 18:09:17 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Kieran Frewen , Bassem Dawood Subject: [PATCH 09/12] nl80211: support advertising S1G rate information Date: Mon, 11 Jul 2022 01:08:13 +0000 Message-Id: <20220711010816.45927-10-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711010816.45927-1-kieran.frewen@morsemicro.com> References: <20220711010816.45927-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 Signed-off-by: Bassem Dawood --- 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 71074332ccc5..19cf030004e9 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -3539,6 +3539,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 { @@ -3565,6 +3572,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 077dc2938551..70efed2b5899 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -6073,6 +6073,21 @@ 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_8: + rate_flg = NL80211_RATE_INFO_8_MHZ_WIDTH; + break; + case RATE_INFO_BW_16: + rate_flg = NL80211_RATE_INFO_16_MHZ_WIDTH; + break; case RATE_INFO_BW_5: rate_flg = NL80211_RATE_INFO_5_MHZ_WIDTH; break; @@ -6137,6 +6152,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 Mon Jul 11 01:08:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 12912741 X-Patchwork-Delegate: johannes@sipsolutions.net 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 08672C43334 for ; Mon, 11 Jul 2022 01:09:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229747AbiGKBJb (ORCPT ); Sun, 10 Jul 2022 21:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229751AbiGKBJ1 (ORCPT ); Sun, 10 Jul 2022 21:09:27 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4467C16584 for ; Sun, 10 Jul 2022 18:09:21 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id b8so2165713pjo.5 for ; Sun, 10 Jul 2022 18:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eACZUBR6D3EsRDShUX90rju2qike1PMAdJxvFDl2bkM=; b=LtRbp/byFZow/OrvLRqgZHxJin/wPOtLgSiTvBWFF58VFsGTLHNXQIsODzCy7Adpix V93uJGN3YyJkv/aaNYCBWrqCsl0oJmmZxDirSnerc1v5hcmvR6hejkIX8mg1VhzQqGtr cjMOG0HiyrvQArs+IDkUgZLMxcDVhuCGVqMbjDLkPoqN6nmn1u23nBuPD1uajTVopq75 eAwnu6iBXyGhUR2ziIHRbQKHFLZadPyhtlLWvsuel3u2idAb1fPgDrJoyDp18FXvSUva y4iAUO0YMZSMRxe1/8QOBxpDVwLvkaMfinO6TEx3qKRaO+QTIUl6Nr1l80zTQEuszQ2w Zd7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eACZUBR6D3EsRDShUX90rju2qike1PMAdJxvFDl2bkM=; b=h2COcp+EFtwKIlfJX6bDXpMcn/gaf/0Rqj7NKok2Z2ytWP7BmAmjLNFcSDWvHDJkKW vOtq7ilDQMPC0pppLQgXHf6745OoalC97snoAZJFahQCS8ajynuS6TnHeeIEHxebjRjI dxAaPVMF2/ZhCW02bYiUa0bN2RT02dASbBTrs49F0iEc+Di97qFwhgQUybkl8F9S/Sea PjuXMHNQ9mhvt0eOLtv7dMRIdKXgf9v/LaEL9H5gMAlIorMDKTTFVxS7PhHnagHdUz8/ 6ExrydHurrQx1VX9cPKnTV6VFvNHyg07Q7s9o1fkE1/QHXuGZIQF7ULDJYJ9mlZjye5S F4Fg== X-Gm-Message-State: AJIora+jUM2b/w12zdtUs85XYskAmAMpX3HaujQE/X6HMO8Ign0x6yfm ZgKVNilITmYOWYOdozngmlK+Kg== X-Google-Smtp-Source: AGRyM1uRrD4IaAIfGPcsQawoV0DnxGSEcmeBWUv6aunnK0+NCwcvT9yCqJDfqUYE3JJU6QV+eXVoog== X-Received: by 2002:a17:902:a502:b0:151:8289:b19 with SMTP id s2-20020a170902a50200b0015182890b19mr15997453plq.149.1657501760715; Sun, 10 Jul 2022 18:09:20 -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 ij5-20020a170902ab4500b0015e8d4eb1dbsm3341330plb.37.2022.07.10.18.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 18:09:20 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Kieran Frewen , Bassem Dawood Subject: [PATCH 10/12] mac80211: support S1G rate encoding. Date: Mon, 11 Jul 2022 01:08:14 +0000 Message-Id: <20220711010816.45927-11-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711010816.45927-1-kieran.frewen@morsemicro.com> References: <20220711010816.45927-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 Signed-off-by: Bassem Dawood --- 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 | 30 ++++++++++++++++++- 7 files changed, 110 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index c5bb97b381cf..304249038ac6 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -1547,7 +1547,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 1fd461ed746d..93fe4b98017c 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -848,6 +848,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 @@ -1028,6 +1032,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 * @@ -1408,6 +1426,7 @@ enum mac80211_rx_encoding { RX_ENC_HT, RX_ENC_VHT, RX_ENC_HE, + RX_ENC_S1G, }; /** @@ -1458,10 +1477,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; @@ -1477,8 +1497,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; } /** @@ -6506,6 +6525,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 b4c2f4e9083e..a5511eb56dd9 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -743,8 +743,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) { @@ -752,25 +760,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 feab1d58e932..e0a2975d0959 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -4982,6 +4982,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 014032369994..da03d4eef321 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -2297,6 +2297,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 218430790660..d2173a191da4 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -931,6 +931,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) @@ -975,6 +977,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 51a2c1dee360..8b896aec5f8c 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -3861,7 +3861,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; @@ -3948,6 +3948,34 @@ 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 Mon Jul 11 01:08:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 12912742 X-Patchwork-Delegate: johannes@sipsolutions.net 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 C391BC433EF for ; Mon, 11 Jul 2022 01:09:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbiGKBJd (ORCPT ); Sun, 10 Jul 2022 21:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229678AbiGKBJ1 (ORCPT ); Sun, 10 Jul 2022 21:09:27 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E10A165A4 for ; Sun, 10 Jul 2022 18:09:24 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id g4so3520656pgc.1 for ; Sun, 10 Jul 2022 18:09:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zu1KPhIskeJjpHwFJ5sq4T1Dv+v0bG6sgY/TYDuPtPs=; b=clHWvjexYNQIHmw6UUilkLNRXAxRxYU5vFs7uX3CPjo2xaJh6KyPgcDP+820SB4ZaO CY20XoSH9qnGusPUdsxTe7OMM8oDWQsH+4dUnAYT0XzDMJ1ZjTgUu+UU9S1f0UTlmC44 deT28rv2vKtK8FTC7vqDan7WP+Symgm4Y9SRT4bVfdNcNLhxx3nU1/jKqcbwmFcVvjjA LaXyPYzfJAXJVhBcIzGx7LRY9WEzSnD9UjmxpCHRPMiVdLcH9iW5Ok1kYkYtF4A/1OL4 dm4Yp5Y4w7fUNqFRm2MbCBmGSWqdmRLAYCHMWnD77ggN+QPPQwNwDvXLI+2BbPgukcCA Dcug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zu1KPhIskeJjpHwFJ5sq4T1Dv+v0bG6sgY/TYDuPtPs=; b=zbtw+vyjSIi9PE2oNe0ETeEwSQZMWJ/ZRTp80hiYacvEuN2wfHP9D/nScdtBhHU1Md bzmxIRHQDKjCWxwFheYqovL747ARAw0Ldqifk31itmL3QVjvSPsfBvc9JXfix/qN0sx0 SlGVWwtRyFX46SGLVQdKmBA3FsMiNhz8ckI3Sfz7uBOjt9ioNa8czU0Js6ZDY4t0n+Ll Q4v6AuDDhUQ8oe4vwvQYbTYrIskag3DYwef/xy4M5cekB5ZCuoHc61wPw6ylxkHhXCOJ hj/z7oE57hQDAAUO4LKC3dJKXl9DWgOeDc6oLqdaJvhwviSswSshR5lLLuYS7ZcNCOoq kKzw== X-Gm-Message-State: AJIora/u9xrViYQEItd8zuJ4NfqXpJ/vbuNVTC+Lia8NKWKFgO21OuD+ U00Qb5S57CyAODMdg0vbSip+xg== X-Google-Smtp-Source: AGRyM1uXnBM/5Xsub0QK2kCFkykhpuGTeZ8bibNn+Mr/GXTqbaFt6zOiKcsvS1eOGGMVZ+wctr9rCA== X-Received: by 2002:a63:5663:0:b0:412:7e4f:e208 with SMTP id g35-20020a635663000000b004127e4fe208mr13982934pgm.619.1657501763544; Sun, 10 Jul 2022 18:09:23 -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 ij5-20020a170902ab4500b0015e8d4eb1dbsm3341330plb.37.2022.07.10.18.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 18:09:23 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Kieran Frewen , Bassem Dawood Subject: [PATCH 11/12] cfg80211: support for calculating S1G bitrates Date: Mon, 11 Jul 2022 01:08:15 +0000 Message-Id: <20220711010816.45927-12-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711010816.45927-1-kieran.frewen@morsemicro.com> References: <20220711010816.45927-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 Signed-off-by: Bassem Dawood --- net/wireless/util.c | 113 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/net/wireless/util.c b/net/wireless/util.c index 412403d29c22..1bc604ec66dc 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -1380,6 +1380,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 @@ -1608,6 +1719,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 Mon Jul 11 01:08:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 12912743 X-Patchwork-Delegate: johannes@sipsolutions.net 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 4E895C43334 for ; Mon, 11 Jul 2022 01:09:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229729AbiGKBJf (ORCPT ); Sun, 10 Jul 2022 21:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbiGKBJ3 (ORCPT ); Sun, 10 Jul 2022 21:09:29 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE4B215FDB for ; Sun, 10 Jul 2022 18:09:26 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id j12so3187347plj.8 for ; Sun, 10 Jul 2022 18:09:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=morsemicro-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aUn3EPCckrE531sAIYD4jpJJiQgREvuGMuNMzPatpEA=; b=GX4Fs/hE2viFSZq8F8iB0SQurYtOEPrPb2wCBUeHtULW5zDQB3QIsYr5CcCd3QFsmG tFz5HRveoObxle36esdkSjKMwEJZmGAceozZ0pzVbQqjxoElFKdR1DjlHPABOB8sBCSH POyQDLA73zyWtXws6V1hMLXX3HgUREyHVHGWzrnMIukA6V1NTMNBldftgVz4wf8gWpPw cKhAj1TCfFzFceMmisDSBsIcG3p8k/+vmQaeUGucMhLQZwGDIVxWUlvCZcYRpl0LMgH8 SUYyYNZparjOFijoyGhmcsKywHlvZhp/LkFovIY7AYhr6ae65ZRHBfzG6okWpVbVn36L fUIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aUn3EPCckrE531sAIYD4jpJJiQgREvuGMuNMzPatpEA=; b=SfFdkz/CSVWYWRZAFE+ILSq08/LgUPKY/Vsax9EOvc9mUMORblMX621bNuEjyYmh7Z 5AhI8f8T+VKNe/2Stm+Z+o0S06do/GzlPuN8qyI/vQI4OhBRDtVV0h3cbb6gHmzF2qtl qSmtUM77YjThCUcJVBTaJJ7gXC8X0WNifC0UR1UFS6YU0QttxVLWX0pEN7VRi3xqBjgW 3RT4sMCLIB7j0Up7W3IhvUHjakU32S9mW+qw7MbfpaE/P8UjkqrVOPYOkrbJu5H52jAN 3/tuCwDbkf+OYF+wAUt/wn4l4+BYt5Zptv0M1CpT0GuhL+ZRqCZx0pIuPOBNjMb2cLuI qDvA== X-Gm-Message-State: AJIora972awswT+OoLYJyLGmIvJ6IglR3jB+O5Hc7v4ziMSQZHIPRgRl yC7Ty+u2tb9IUCGPkQUs68m7KA== X-Google-Smtp-Source: AGRyM1skKLs/owtGg3sZfe7FNtbJaGt4s/GRRxOHDe76frkKvIyweolniowiEKyenrlDoBskGo5LxQ== X-Received: by 2002:a17:902:ee42:b0:16b:e518:d894 with SMTP id 2-20020a170902ee4200b0016be518d894mr15983296plo.5.1657501766236; Sun, 10 Jul 2022 18:09:26 -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 ij5-20020a170902ab4500b0015e8d4eb1dbsm3341330plb.37.2022.07.10.18.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 18:09:25 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Kieran Frewen , Bassem Dawood Subject: [PATCH 12/12] mac80211_hwsim: support for S1G rate information Date: Mon, 11 Jul 2022 01:08:16 +0000 Message-Id: <20220711010816.45927-13-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711010816.45927-1-kieran.frewen@morsemicro.com> References: <20220711010816.45927-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 Signed-off-by: Bassem Dawood --- 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 304249038ac6..c4c0796a610d 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -1549,7 +1549,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 = @@ -1560,14 +1567,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 */