From patchwork Tue Aug 30 02:20: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: 601448 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 6F14AECAAD5 for ; Tue, 30 Aug 2022 02:20:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229828AbiH3CUq (ORCPT ); Mon, 29 Aug 2022 22:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbiH3CUo (ORCPT ); Mon, 29 Aug 2022 22:20:44 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF3587C333 for ; Mon, 29 Aug 2022 19:20:43 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id f12so9567401plb.11 for ; Mon, 29 Aug 2022 19:20:43 -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; bh=u9vzsvJZ1zw3iEr8rRQq4rL8aF67x/gQVDonBdLqrj8=; b=rwmV+1k0r0oczG2b7U6PmTPq9sbN46chMwNh6qsvObFFA90d4ba8jHv7Llq7vvgdqi dawRPxA7zFTo48GaB/GgXnVVc/fYet2srRGvMwQIUc3UQT3z2Z4HuAS4Mz5DX2nLV6yc +qkXUtp3uwgOE2xcFONYwZt2FoWb2TueZKk9Kpm3ncGDCz82KW0Lnf/w6S8DRj+kg4FZ R+DUiwxEiQBEroP/BbJIgUDSqQtzpiPBFkpWScksg+hMKIucb0TgJ0RzOCeBuuBKyTxQ QlwrDuk0zJiWu7j23jcuUAqvok9rlmF0k8b6fl3jYxN4Zu+T8nn3iXBb8azpMCiNgGUd 07cw== 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; bh=u9vzsvJZ1zw3iEr8rRQq4rL8aF67x/gQVDonBdLqrj8=; b=3IsZcgzDUcVTLvxyO6T2j8/8H5xaEXtNZIKbcU2cqcf9bdo6fnv/DzraDjbtESncDh tcfjVjA6v0iabwmid7xHg+iSS0exXC5iuGyXEbzNlwZTmzZf7f7XIYsNCeOHlg0oNTCD A1t7ZLJP4cm/RjMeE3Me8mhKPUag9SbtSIKgw6N3S1EBH4QRgF+hpIaLI7uZZh3Q5qRL iyDr/+p+UZrUiVrfDUr527hR+csRKvS5t8e3oagvLg5e4tLEGCx+3t3dZiZPLAtXigHF MOHkpwY8irILQWu4bUVo2NI775nV1ZLHj/UCSbvWLGv4TZ8KmQSaQshOKT1qp/qqaZ0t Sz9w== X-Gm-Message-State: ACgBeo1dlQcdwHX/FzFt4G4KQl8UZfYAUodB2hz2SfDjqJKVxspxRJHe /QP6FtaFF04/gxfkpz9XlZ9W8g== X-Google-Smtp-Source: AA6agR7nd9QijXSsHWkTEHn2yQ9q1Rgi4zl0IdqT69eiX9+ag5xSLbYoUtd3K2ZpYbkHINzMshhipQ== X-Received: by 2002:a17:903:110e:b0:171:3114:7112 with SMTP id n14-20020a170903110e00b0017131147112mr19919316plh.114.1661826043643; Mon, 29 Aug 2022 19:20:43 -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 q12-20020a170902a3cc00b0016d8d277c02sm8220050plb.25.2022.08.29.19.20.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 19:20:43 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v2 02/12] mac80211: update TIM for S1G specification changes Date: Tue, 30 Aug 2022 02:20:07 +0000 Message-Id: <20220830022017.51017-3-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220830022017.51017-1-kieran.frewen@morsemicro.com> References: <20220830022017.51017-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 Aug 30 02:20: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: 601447 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 2BDFAECAAD2 for ; Tue, 30 Aug 2022 02:20:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229897AbiH3CUw (ORCPT ); Mon, 29 Aug 2022 22:20:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbiH3CUu (ORCPT ); Mon, 29 Aug 2022 22:20:50 -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 E9FA57E013 for ; Mon, 29 Aug 2022 19:20:49 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id f4so9362594pgc.12 for ; Mon, 29 Aug 2022 19:20: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; bh=94HBYAbisDAuvh8wguvjigNQ4uVcXLkynJD9kKl9mlw=; b=haGMmpEt2yZhM7gvv9GZ7Fukx1Bw4xm1msoG3P05iocWzITjq1d9sEYw9b9O7Ntbst fADkgDUGNuwQ5K5jSJrEFjx/9Bz7Ty4ba3++evOH8MTY4xDyiYQq4dm5NwoeX35ch5QJ 3zPCJ/6PxqWM7xu0Or36wpuG2rafxmpLQ7uMuV1W6sDki/PJF23vTUgJc6L8U+ZRN+ng pZnwSZdTwkU6B/sSe1/8QFx+S4X1vwpbv4udGbhXcSQeS03TOsOv8W39ev3bRUB6w5SA 0nvvTxz4LCBeTxBYhpwAwUFa3Z3fCQ+Oz+JVAy79EkKBEOxh+IvooVzzcMw9h0lgfyqP romg== 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; bh=94HBYAbisDAuvh8wguvjigNQ4uVcXLkynJD9kKl9mlw=; b=xJsK8fvTrjZv+xOIG5A2asprdA7U7dg5JsKxQP9X9nKI6nS5euaPKsK7EbKruhN5Dr ON/BXaExJmZkHJJD2qEqVbti/wMFKdL0Hb2cYFnYNPSr3lekqdzSQe8tZ4kEl43Hi3js 3tb2e/hc97hcMnleE6jewFI/YKFdrsaSIlBOuhYtLfDsY0i+UlJzYvkqzfvETXm2YKxv +Q4sJ5OopYo0oMBWa5Ikl7SxE6N6ct3LhxVV1t10EFf6tIRogzUqbhLAMKGWngDtHOLF 2DQq1vSzB1GM2JZbC394+fHd4JS97xkBz/x3VsfM3uOGrNsPWlQkfnX9NlRqPBduLAOi yr0Q== X-Gm-Message-State: ACgBeo3mCBPYzbkDITNGcopPOvug1TEOi0ybnMzjDaTxu92tEwu6dO8n DAHCnGoGoViDwAcDbSdba/JsuQ== X-Google-Smtp-Source: AA6agR4t6FdWu/c3d9cpdtEiMOAGhN9MvvipD096JHc/STq54DFJbWesQe1r9jiaZMDUSKhbrxUyjw== X-Received: by 2002:a65:6ccf:0:b0:42b:20e8:5b8a with SMTP id g15-20020a656ccf000000b0042b20e85b8amr15653911pgw.500.1661826049491; Mon, 29 Aug 2022 19:20: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 q12-20020a170902a3cc00b0016d8d277c02sm8220050plb.25.2022.08.29.19.20.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 19:20:49 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v2 04/12] nl80211: support setting S1G short beacon period Date: Tue, 30 Aug 2022 02:20:09 +0000 Message-Id: <20220830022017.51017-5-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220830022017.51017-1-kieran.frewen@morsemicro.com> References: <20220830022017.51017-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 Aug 30 02:20: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: 601446 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 DDE57ECAAD2 for ; Tue, 30 Aug 2022 02:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229915AbiH3CVA (ORCPT ); Mon, 29 Aug 2022 22:21:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbiH3CU6 (ORCPT ); Mon, 29 Aug 2022 22:20:58 -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 9CF0B7F133 for ; Mon, 29 Aug 2022 19:20:55 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id u9-20020a17090a1f0900b001fde6477464so3340428pja.4 for ; Mon, 29 Aug 2022 19:20: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; bh=ZjqpoFg5F92iNpozG4jkmKHf9FAGoWr+LPzk3rQ1MkQ=; b=syKd2CVcSM0SymvP/sMg+3YRmaID5LA8wINKRCTx8cPPyKD/WJ8bsM/yogdsr3bTyT aBWutqmrCAuCU6dc6Lm5du9FdVjZyoJAOK7ShXOKIZICMsHNLGH4A+P56eHPnwdEOlRM HONB7IpzPjPWRR7o+1ZeLQXwvj2k+mikY016mxSjVnFg1muIVna29NmsXQxyFImsPS0m AsfaUr7xkBRmHlV8qxStK/dqz2VUHWBD6cpPW/J4X8GYVL/wJPBcZSFvSs4MyY6p9OqU aT8AfmXXl0TamuoT/zewRcBz3jVMh0txlb/gyB4lWp06a4+IMMGD9uDMlXSdjzsAIE/R seZg== 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; bh=ZjqpoFg5F92iNpozG4jkmKHf9FAGoWr+LPzk3rQ1MkQ=; b=iAd7vvaDviGwEu5ou2RUamDb6Xminfe5eF4GttqNo98KdduTp07qqEGB5+SDRj1ENz isht5syB08bOS+VnCdyynYmcTBYAqsMT5V0sIvfFYFWqeNIgfAv4fbvFX8uTki18Z6yu WwEbb8ft8XfVbI7rXbWeJ11WpChz9fJY85zPvfDQRia0nFLNlpUAmENTBHic+GwLsJ8H PRhRc3wNcnISscvugssA4EAPUeEr/szJ3rVTFGhWK3RkK1Ljt0U0dHGgrobuxj3TWNAz oAvbDdMkc4fRbjuis3THc4YqiZ4XzJH4wP8xgua+r2dNoVhn2hvc08OvubJgzQYk1tWE Qw+g== X-Gm-Message-State: ACgBeo1wwwb1xtgX6UKutgDjZBQPwluPEilO9n22fipC3K+C5ha4H8+r 52/GdKmlDGNZsT7Ns7Dd9bTJodz9OzeN5hwF X-Google-Smtp-Source: AA6agR69Z1F54vIQ8ZehTUmOfb0lNjpxvq+uDYDyEtMWZK/REXIxI8bLFHNSFxssvhX0JroHVk9osQ== X-Received: by 2002:a17:902:9006:b0:172:927e:c19a with SMTP id a6-20020a170902900600b00172927ec19amr19217534plp.162.1661826055206; Mon, 29 Aug 2022 19:20: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 q12-20020a170902a3cc00b0016d8d277c02sm8220050plb.25.2022.08.29.19.20.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 19:20:54 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v2 06/12] mac80211: support ieee80211_ext format Date: Tue, 30 Aug 2022 02:20:11 +0000 Message-Id: <20220830022017.51017-7-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220830022017.51017-1-kieran.frewen@morsemicro.com> References: <20220830022017.51017-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 Aug 30 02:20: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: 601445 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 A6BDCECAAD3 for ; Tue, 30 Aug 2022 02:21:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229889AbiH3CVD (ORCPT ); Mon, 29 Aug 2022 22:21:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbiH3CVC (ORCPT ); Mon, 29 Aug 2022 22:21:02 -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 579037FFA4 for ; Mon, 29 Aug 2022 19:21:01 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id z3-20020a17090abd8300b001fd803e34f1so7859526pjr.1 for ; Mon, 29 Aug 2022 19:21:01 -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; bh=PS78Y6Cc1leof3wv7vMwmck9H+AaNqnxAUUmZvGqIsU=; b=elAKci7qbregr6JktXP+ihUWumpJssCmWqf2bgrfBCbTLJIXE3jR3cLEoVOicjCcLe uwotTugvJHxjfOW3qSzVehPnwAC3+Mv6by6p7EorKHTcyQU79ME8+RaY6bzU/6uAvlyb x3RODYKzEnYUDFbSkNTinxRCDZLZ+z0z7kU4O/BbB+ADm77eBYGqRm+NB8UlXm2B0pjk RJS44KbWWOsrqD5nhsLZRXBueUDNHOsSnGoye0574vQ1Hfjg8/fAYku7+iVct6o7MEIQ FanR9dX6t3V7+QOwfUMQNHuQuqO8jwnpHRkLWFBpJarqF6KDA2Z+ZU1v0jN5kYvhqevQ xVEQ== 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; bh=PS78Y6Cc1leof3wv7vMwmck9H+AaNqnxAUUmZvGqIsU=; b=e3AOp85ouXFSgmTomsykbh+6EqBHQZmbWpjbgHDxhwpqttbWD9sz9zob8EFpxcQTMy jlN6lYr195GVYYL8WXAzoLXxKZ7uWvROffudFAHUm8zBdllwne7VbD1wuRmlVsChl8Kx kr+4n5I9fyqFE4LVw+39fJFuIQiJe+IT0cWJTmWnTcBB3Zk5Cdie5TGJ6miGNssKKfVz oHSbp4CRAwI1K2lZtXpgamaHZZa5xsZmFcqI4rQK2+K99CBy93rmM5C4XSpvztXwOWL8 1Z8hydsDdw+/xzU25Qp21a3vzxVL1Ff7yQBFoG9iUapZrFY/4nNRppKTuWQmLhTbUlBs rARw== X-Gm-Message-State: ACgBeo0JELQTRnqisG7NxIL9nJTGLrh8+NCIKhuRwOiZxFIUJsEXntjT x9hKl9Kk6/5YlEvIphEP2xLYnEjYC9Ng3zbd X-Google-Smtp-Source: AA6agR7eyYrgRs5sSjXS45b5rcVrClKrr7Uze/qNoH1XRiYNWmt9vaCxWwMIiSx9z1kGiGap6ZjCHA== X-Received: by 2002:a17:902:f686:b0:175:44a:c707 with SMTP id l6-20020a170902f68600b00175044ac707mr3418477plg.62.1661826060903; Mon, 29 Aug 2022 19:21: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 q12-20020a170902a3cc00b0016d8d277c02sm8220050plb.25.2022.08.29.19.20.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 19:21:00 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v2 08/12] cfg80211: S1G rate flags Date: Tue, 30 Aug 2022 02:20:13 +0000 Message-Id: <20220830022017.51017-9-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220830022017.51017-1-kieran.frewen@morsemicro.com> References: <20220830022017.51017-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 f462dcdd023a..cdd43ba9c62e 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 Aug 30 02:20: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: 601444 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 021E1ECAAD3 for ; Tue, 30 Aug 2022 02:21:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229791AbiH3CVJ (ORCPT ); Mon, 29 Aug 2022 22:21:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229921AbiH3CVI (ORCPT ); Mon, 29 Aug 2022 22:21:08 -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 306637CA91 for ; Mon, 29 Aug 2022 19:21:07 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id v5so3526999plo.9 for ; Mon, 29 Aug 2022 19:21:07 -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; bh=RHopkjClYRCGGjKkbdyeKOpr+kFyb34b5lqs1q4lMTk=; b=tiFC6BwU/MFxDXvNUYeTIryd1R13wkZOSob5Q/25tNnfjoxTcqFISdKEmovN+sKC3W 5h28YJ4+gP6/RTZ3YkO5Vc7SSt7HFzwB6JlJY1HeALRQ5hAtK0BuB1Xi/pgaQWmSajAE MTXh9IumfuBG6PheJr3P1da+skf4rwa/OjNLN2zC2nrGML/QN5OJw/pGXYGeFWrkgXkq Fv80Ql53Zhlw7mJsxfn2oGEiVts8Jok4UnE7vmJhAdab/TR5xWsHdhRNcnw7PzL5J5Sh eFw0LT8FaY38sCTrd8qL0ju7xEcIVlDlDvKv6ek445+7sce58/DusNnqgmlTQxIvpcw4 sXGA== 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; bh=RHopkjClYRCGGjKkbdyeKOpr+kFyb34b5lqs1q4lMTk=; b=Q+Mlsp0qp/gEsOKHPLLzd/fQSWzzEXGG7+XQw8bkJ+Ngg359gYNeHJQ5FCMxvc4zt0 2RPJor9rbwHPrkLoTAEQ4nhPswjjIIas7lDQSreMmrPGgDmdzqnU9I1geyD0M8jecVkk cbmKQJfNrKCocOFsOvATee59P2aaWOdOknkMmxDQnifjF3QrVw0vQ59c0zZNIqfdkiRr 7TPqjYC6vKRMhXylVe1yoVug7uvSoJJzs0FWgjVYM9lW6KppU0lq9zHZlArPjyEVWkUq NbdkiigczVy6mzmL+xyLG8BD4eNCG1KejFj6Vr5phHJFy4E05vkHAorjaf3MEJMma8P/ fm7g== X-Gm-Message-State: ACgBeo1humr7wzHS+BhvnVXTTXZV7pMIMjMu1Oay3pJzBMP4n1ouAtv6 N13ruoS05VflN1QoArjfi89LNH5Wm5WcyjWd X-Google-Smtp-Source: AA6agR7DepY9HWs5sOZD+g648m+XxFhhOOHix3j8CsF6Mg2Bfem21LCxL9svLEtA3v6ll+IlxD0jyg== X-Received: by 2002:a17:902:aa49:b0:172:f8ed:1b27 with SMTP id c9-20020a170902aa4900b00172f8ed1b27mr19743879plr.52.1661826066642; Mon, 29 Aug 2022 19:21: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 q12-20020a170902a3cc00b0016d8d277c02sm8220050plb.25.2022.08.29.19.21.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 19:21:06 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v2 10/12] mac80211: support S1G rate encoding. Date: Tue, 30 Aug 2022 02:20:15 +0000 Message-Id: <20220830022017.51017-11-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220830022017.51017-1-kieran.frewen@morsemicro.com> References: <20220830022017.51017-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 | 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 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..5147f688751d 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,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 Tue Aug 30 02:20:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Frewen X-Patchwork-Id: 601443 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 2FD38ECAAD2 for ; Tue, 30 Aug 2022 02:21:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229922AbiH3CVQ (ORCPT ); Mon, 29 Aug 2022 22:21:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229911AbiH3CVP (ORCPT ); Mon, 29 Aug 2022 22:21:15 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E74B77E013 for ; Mon, 29 Aug 2022 19:21:13 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id w13so9382872pgq.7 for ; Mon, 29 Aug 2022 19:21:13 -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; bh=uyJmH5QODACX39loBetvnkaSvQzRkAD1ZxCe7Jwbavs=; b=jW0/pHHuEvWNUqTZFXj/6dp78kQJUVSdoW7b4MKyMttf1kLFVp3g7egiRdRPGYr8WX Gjyr9xZQg+z29KxDzwKRzw3/mnNik/o6jM71JWeGb7sjeuwOUf53KnEbhRqxIzPJPGM+ TNV9TLgNL2Qax2lSwrBsRV1APhSqB/qQGpU5yNRIMLYJ7i/wYZ6v53+Cw4ecHt95BHvs fjVVVGFXIp29M9lh8UH41dzwxd0CNxNpNdkTYwqATF2Z3o7UjmlFgHxL9NUZyGV2r9w7 AXXR0ccTnuxlo4aTS5Tz7gZQ2T2TVmA1VrJqujIrG70G7lkDs5fjLeYS2RZa1oC5D0vN zoJQ== 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; bh=uyJmH5QODACX39loBetvnkaSvQzRkAD1ZxCe7Jwbavs=; b=dnmYtB/rmvbTb5+li0gNLJmxe8i/3ATEijC+68OQIbYXjqYgkKKpe8BNVA/Rf76ECh ouKAnrju3apOoKX6Z2Geu69E16OvqP/uRawxkqg6MEA8seIjNmyZlcf3xV9DMewxh6NP b/f89WUiD5rcbzs9B/urOkLcqo7+lzuE0vhCTCXhdZAptB8Vcym+pkolQgVlwqUurmaL vgpBpiNe3uRVfxUoCchK1c/+SmkGfDRyEihclSfSE/zuW2wPj3FP8Xv8W38qN1Iugprg F/by4Gixs5l7AUyhFjpP/bo1O7GoVSBvwwH1nyy+rwufqiT6mUAPV8292lg1Kj2X/9Bh P9eQ== X-Gm-Message-State: ACgBeo0kE8KBa/ZHshIqcnWZnIYzzgzMHV0Vi/dj/VmfN/KKc1TvYRGE 72B+oARnoZV9+s4yYrcfNNJKWw== X-Google-Smtp-Source: AA6agR5boHVFZHfDxj0vD8doXQxq/+b4JwpL5uxK5PAkB6jBffvrQoElZBUh0F8loWcSawxGllnKeQ== X-Received: by 2002:a05:6a00:1ac7:b0:537:4186:c106 with SMTP id f7-20020a056a001ac700b005374186c106mr19185403pfv.76.1661826072710; Mon, 29 Aug 2022 19:21: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 q12-20020a170902a3cc00b0016d8d277c02sm8220050plb.25.2022.08.29.19.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 19:21:12 -0700 (PDT) From: Kieran Frewen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, quic_jjohnson@quicinc.com, Kieran Frewen Subject: [PATCH v2 12/12] mac80211_hwsim: support for S1G rate information Date: Tue, 30 Aug 2022 02:20:17 +0000 Message-Id: <20220830022017.51017-13-kieran.frewen@morsemicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220830022017.51017-1-kieran.frewen@morsemicro.com> References: <20220830022017.51017-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 */