From patchwork Mon Feb 14 22:30:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aloka Dixit X-Patchwork-Id: 12746187 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 18363C433EF for ; Mon, 14 Feb 2022 22:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231865AbiBNWbO (ORCPT ); Mon, 14 Feb 2022 17:31:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231376AbiBNWbN (ORCPT ); Mon, 14 Feb 2022 17:31:13 -0500 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C7F411B32C for ; Mon, 14 Feb 2022 14:31:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1644877864; x=1676413864; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LdQlytw+qO0lg4bdIohWOSgj1PROmxBDj09GEvuAm1c=; b=jccF+eJnDLh5LnbfUzL06e2duJU4TZoqAQckf9zE8Wn/UumfRVZtfAyl 9DY76py7zW4+qfr54bFr1XMiuqWJelGoDn/uB/ciqzyzKtVdnFZF8h3jt DM38e1w9EMVytTtswg6VmA1pYFaMWC1klMoA4NzqBuuU9Sb7IF5fZiVqo 8=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-02.qualcomm.com with ESMTP; 14 Feb 2022 14:31:04 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2022 14:31:03 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Mon, 14 Feb 2022 14:31:03 -0800 Received: from alokad-linux.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Mon, 14 Feb 2022 14:31:03 -0800 From: Aloka Dixit To: , CC: Aloka Dixit Subject: [PATCH 1/3] nl80211: advertise RU puncturing support to userspace Date: Mon, 14 Feb 2022 14:30:49 -0800 Message-ID: <20220214223051.3610-2-quic_alokad@quicinc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220214223051.3610-1-quic_alokad@quicinc.com> References: <20220214223051.3610-1-quic_alokad@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org RU preamble puncturing is allowed for bandwidths more that 80 MHz except 80+80. Drivers may not support puncturing at all or have restrictions for a minimum bandwidth. Add new attribute NL80211_ATTR_RU_PUNCT_SUPP_BW to advertise the driver support to the userspace. Default value (0) will indicate that RU puncturing is not supported. Signed-off-by: Aloka Dixit --- include/net/cfg80211.h | 6 ++++++ include/uapi/linux/nl80211.h | 22 ++++++++++++++++++++++ net/wireless/nl80211.c | 22 ++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 136c0c537334..5605cf6d247b 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5129,6 +5129,10 @@ struct wiphy_iftype_akm_suites { * @ema_max_profile_periodicity: maximum profile periodicity supported by * the driver. Setting this field to a non-zero value indicates that the * driver supports enhanced multi-BSSID advertisements (EMA AP). + * + * @ru_punct_supp_bw: Whether the driver supports RU puncturing, and if so, + * for which bandwidths. See &enum nl80211_ru_punct_supp_bw for the + * possible values for this field. */ struct wiphy { struct mutex mtx; @@ -5276,6 +5280,8 @@ struct wiphy { u8 mbssid_max_interfaces; u8 ema_max_profile_periodicity; + enum nl80211_ru_punct_supp_bw ru_punct_supp_bw; + char priv[] __aligned(NETDEV_ALIGN); }; diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 98ed52663d6b..b4849afede98 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -2663,6 +2663,10 @@ enum nl80211_commands { * association request when used with NL80211_CMD_NEW_STATION). Can be set * only if %NL80211_STA_FLAG_WME is set. * + * @NL80211_ATTR_RU_PUNCT_SUPP_BW: (u8) Minimum bandwidth for which + * the driver supports preamble puncturing, value should be of type + * &enum nl80211_ru_punct_supp_bw + * * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use @@ -3175,6 +3179,8 @@ enum nl80211_attrs { NL80211_ATTR_EHT_CAPABILITY, + NL80211_ATTR_RU_PUNCT_SUPP_BW, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, @@ -7600,4 +7606,20 @@ enum nl80211_ap_settings_flags { NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT = 1 << 1, }; +/** + * enum nl80211_ru_punct_supp_bw - Bandwidths supporting preamble puncturing + * + * @NL80211_RU_PUNCT_NOT_SUPP: preamble puncturing is not supported + * @NL80211_RU_PUNCT_SUPP_BW_80: puncturing supported within channels of at + * least 80 MHz bandwidth + * @NL80211_RU_PUNCT_SUPP_BW_160: puncturing supported within channels of at + * least 160 MHz bandwidth + * @NL80211_RU_PUNCT_SUPP_BW_320: puncturing supported within 320 MHz. + */ +enum nl80211_ru_punct_supp_bw { + NL80211_RU_PUNCT_NOT_SUPP, + NL80211_RU_PUNCT_SUPP_BW_80, + NL80211_RU_PUNCT_SUPP_BW_160, + NL80211_RU_PUNCT_SUPP_BW_320, +}; #endif /* __LINUX_NL80211_H */ diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 1595e14fd678..3b244b96d15f 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -782,6 +782,8 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { NLA_POLICY_RANGE(NLA_BINARY, NL80211_EHT_MIN_CAPABILITY_LEN, NL80211_EHT_MAX_CAPABILITY_LEN), + [NL80211_ATTR_RU_PUNCT_SUPP_BW] = + NLA_POLICY_MAX(NLA_U8, NL80211_RU_PUNCT_SUPP_BW_320), }; /* policy for the key attributes */ @@ -2293,6 +2295,23 @@ static int nl80211_put_mbssid_support(struct wiphy *wiphy, struct sk_buff *msg) return -ENOBUFS; } +static int +nl80211_put_ru_punct_supp_bw(struct cfg80211_registered_device *rdev, + struct sk_buff *msg) +{ + if (!rdev->wiphy.ru_punct_supp_bw) + return 0; + + if (rdev->wiphy.ru_punct_supp_bw > NL80211_RU_PUNCT_SUPP_BW_320) + return -EINVAL; + + if (nla_put_u8(msg, NL80211_ATTR_RU_PUNCT_SUPP_BW, + rdev->wiphy.ru_punct_supp_bw)) + return -ENOBUFS; + + return 0; +} + struct nl80211_dump_wiphy_state { s64 filter_wiphy; long start; @@ -2881,6 +2900,9 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, if (nl80211_put_mbssid_support(&rdev->wiphy, msg)) goto nla_put_failure; + if (nl80211_put_ru_punct_supp_bw(rdev, msg)) + goto nla_put_failure; + /* done */ state->split_start = 0; break; From patchwork Mon Feb 14 22:30:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aloka Dixit X-Patchwork-Id: 12746189 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 38291C433F5 for ; Mon, 14 Feb 2022 22:31:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231868AbiBNWbQ (ORCPT ); Mon, 14 Feb 2022 17:31:16 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230102AbiBNWbP (ORCPT ); Mon, 14 Feb 2022 17:31:15 -0500 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45D24F70DB for ; Mon, 14 Feb 2022 14:31:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1644877867; x=1676413867; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oZ4e+rxFSKbTGOS677+bymtqwSgK8yFYiuoUsTbZQVQ=; b=SaC3AyaqcuIYpkvgqpFmeqbASLk3yZf6aaQYyGCcsRKPWps3qRtDWgyO rvn58h7vGXD/ER1D0aXlKuK5EOO3zbilEZ8hVEoWr7vW9a7PDFAmw9Q86 ZnnSCbjsh+/YSS/P5dSk7cPkJFviQen+0fClLyym6V96ZeGPH7cph62Tp 0=; Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-01.qualcomm.com with ESMTP; 14 Feb 2022 14:31:07 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg01-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2022 14:31:06 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Mon, 14 Feb 2022 14:31:04 -0800 Received: from alokad-linux.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Mon, 14 Feb 2022 14:31:04 -0800 From: Aloka Dixit To: , CC: Aloka Dixit Subject: [PATCH 2/3] cfg80211: validate RU puncturing bitmap Date: Mon, 14 Feb 2022 14:30:50 -0800 Message-ID: <20220214223051.3610-3-quic_alokad@quicinc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220214223051.3610-1-quic_alokad@quicinc.com> References: <20220214223051.3610-1-quic_alokad@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org RU puncturing bitmap consists of 16 bits, each bit corresponding to a 20 MHz channel in the operating bandwidth. Lowest bit corresponds to the lowest frequency. Bit set to 1 indicates that the channel is punctured otherwise it is active. Validate the bitmap against following rules: - Primary 20 MHz channel cannot be punctured - As per IEEE P802.11be/D1.3, December 2021, 36.3.12.11.3 Preamble puncturing for PPDUs in a non-OFDMA transmission - As per IEEE P802.11be/D1.3, December 2021, 36.3.12.11.2 Preamble puncturing for PPDUs in an OFDMA transmission. Signed-off-by: Aloka Dixit --- include/net/cfg80211.h | 12 ++++- net/wireless/chan.c | 99 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 5605cf6d247b..c3246e989828 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -742,6 +742,11 @@ struct key_params { * chan will define the primary channel and all other * parameters are ignored. * @freq1_offset: offset from @center_freq1, in KHz + * @ru_punct_bitmap: RU puncturing bitmap. Each bit represents a 20 MHz channel + * with lowest bit corresponding to the smallest frequency. Bit set to 1 + * indicates that the channel is punctured, otherwise the channel is active + * @ru_punct_bitmap_supp_he: Indicates whether RU puncturing bitmap validation + * should include OFDMA bitmaps. */ struct cfg80211_chan_def { struct ieee80211_channel *chan; @@ -750,6 +755,8 @@ struct cfg80211_chan_def { u32 center_freq2; struct ieee80211_edmg edmg; u16 freq1_offset; + u16 ru_punct_bitmap; + bool ru_punct_bitmap_supp_he; }; /* @@ -878,7 +885,10 @@ cfg80211_chandef_identical(const struct cfg80211_chan_def *chandef1, chandef1->width == chandef2->width && chandef1->center_freq1 == chandef2->center_freq1 && chandef1->freq1_offset == chandef2->freq1_offset && - chandef1->center_freq2 == chandef2->center_freq2); + chandef1->center_freq2 == chandef2->center_freq2 && + chandef1->ru_punct_bitmap == chandef2->ru_punct_bitmap && + chandef1->ru_punct_bitmap_supp_he == + chandef2->ru_punct_bitmap_supp_he); } /** diff --git a/net/wireless/chan.c b/net/wireless/chan.c index 8b7fb4a9e07b..4390e9297222 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c @@ -32,6 +32,7 @@ void cfg80211_chandef_create(struct cfg80211_chan_def *chandef, chandef->center_freq2 = 0; chandef->edmg.bw_config = 0; chandef->edmg.channels = 0; + chandef->ru_punct_bitmap = 0; switch (chan_type) { case NL80211_CHAN_NO_HT: @@ -196,6 +197,101 @@ static int cfg80211_chandef_get_width(const struct cfg80211_chan_def *c) return nl80211_chan_width_to_mhz(c->width); } +/* IEEE P802.11be/D1.31, December 2021, Table 36-30 5-bit punctured channel + * indication for the non-OFDMA case in an EHT MU PPDU + */ +static const u16 ru_punct_bitmap_80[] = {0xF, 0xE, 0xD, 0xB, 0x7}; +static const u16 ru_punct_bitmap_160[] = {0xFF, 0xFE, 0xFD, 0xFB, 0xF7, 0xEF, + 0xDF, 0xBF, 0x7F, 0xFC, 0xF3, 0xCF, + 0x3F}; +static const u16 ru_punct_bitmap_320[] = {0xFFFF, 0xFFFC, 0xFFF3, 0xFFCF, + 0xFF3F, 0xFCFF, 0xF3FF, 0xCFFF, + 0x3FFF, 0xFFF0, 0xFF0F, 0xF0FF, + 0x0FFF, 0xFFC0, 0xFF30, 0xFCF0, + 0xF3F0, 0xCFF0, 0x3FF0, 0x0FFC, + 0x0FF3, 0x0FCF, 0x0F3F, 0x0CFF, + 0x03FF}; + +bool cfg80211_ru_punct_bitmap_valid(const struct cfg80211_chan_def *chandef) +{ + u8 i, non_ofdma_bitmap_count, ofdma_block_count = 1; + u16 bitmap, pri_ch_bit_pos; + const u16 *non_ofdma_bitmap; + u32 start_freq; + + if (!chandef->ru_punct_bitmap) /* All channels active */ + return true; + + bitmap = ~chandef->ru_punct_bitmap; + WARN_ON_ONCE(sizeof(bitmap) != sizeof(chandef->ru_punct_bitmap)); + + switch (chandef->width) { + case NL80211_CHAN_WIDTH_80: + bitmap &= 0xF; + non_ofdma_bitmap = &ru_punct_bitmap_80[0]; + non_ofdma_bitmap_count = ARRAY_SIZE(ru_punct_bitmap_80); + start_freq = chandef->center_freq1 - 40; + break; + + case NL80211_CHAN_WIDTH_160: + bitmap &= 0xFF; + non_ofdma_bitmap = &ru_punct_bitmap_160[0]; + non_ofdma_bitmap_count = ARRAY_SIZE(ru_punct_bitmap_160); + ofdma_block_count = 2; + start_freq = chandef->center_freq1 - 80; + break; + + case NL80211_CHAN_WIDTH_320: + bitmap &= 0xFFFF; + non_ofdma_bitmap = &ru_punct_bitmap_320[0]; + non_ofdma_bitmap_count = ARRAY_SIZE(ru_punct_bitmap_320); + ofdma_block_count = 4; + start_freq = chandef->center_freq1 - 160; + break; + + default: + return false; + } + + if (!bitmap) /* No channel active */ + return false; + + pri_ch_bit_pos = ((chandef->chan->center_freq - start_freq) / 20); + if (!(bitmap & BIT(pri_ch_bit_pos))) + return false; + + /* Check for non-OFDMA puncturing patterns */ + for (i = 0; i < non_ofdma_bitmap_count; i++) + if (non_ofdma_bitmap[i] == bitmap) + return true; + + if (!chandef->ru_punct_bitmap_supp_he) + return false; + + /* Check for OFDMA puncturing patterns */ + for (i = 0; i < ofdma_block_count; i++) { + switch ((bitmap >> (i * 4)) & 0xF) { + /* IEEE P802.11be/D1.31, December 2021, 36.3.12.11.2 Preamble + * puncturing for PPDUs in an OFDMA transmission + */ + case 0xF: + case 0x7: + case 0xB: + case 0xD: + case 0xE: + case 0x3: + case 0xC: + case 0x9: + case 0x0: + break; + default: + return false; + } + } + + return true; +} + bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef) { u32 control_freq, oper_freq; @@ -316,6 +412,9 @@ bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef) !cfg80211_edmg_chandef_valid(chandef)) return false; + if (!cfg80211_ru_punct_bitmap_valid(chandef)) + return false; + return true; } EXPORT_SYMBOL(cfg80211_chandef_valid); From patchwork Mon Feb 14 22:30:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aloka Dixit X-Patchwork-Id: 12746190 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 89038C433EF for ; Mon, 14 Feb 2022 22:31:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231880AbiBNWbU (ORCPT ); Mon, 14 Feb 2022 17:31:20 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231874AbiBNWbR (ORCPT ); Mon, 14 Feb 2022 17:31:17 -0500 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AFB8F70DB for ; Mon, 14 Feb 2022 14:31:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1644877869; x=1676413869; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HiapnwOFBt/dZtzTSGiVoojDoOVJahSpERDOiy5mTBo=; b=CQHFDpRZRb0EbQwQ1wAAaSyvguR2qHkFGdHlo3sQxmtWvRfN/nl7Tj1W LkGgX/wGEImkdHpXwqRygrBJzwIZJuuDdlse5AJ2GfL69/B0Tr4Xx3q1L HhhPJvz1i4ATcDClAf8gRqydGzVSFMoGqONNp+ghLbpmVH9GtSVxZhX8v w=; Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-01.qualcomm.com with ESMTP; 14 Feb 2022 14:31:07 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg01-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2022 14:31:06 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Mon, 14 Feb 2022 14:31:05 -0800 Received: from alokad-linux.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Mon, 14 Feb 2022 14:31:04 -0800 From: Aloka Dixit To: , CC: Aloka Dixit Subject: [PATCH 3/3] nl80211: validate RU puncturing bitmap Date: Mon, 14 Feb 2022 14:30:51 -0800 Message-ID: <20220214223051.3610-4-quic_alokad@quicinc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220214223051.3610-1-quic_alokad@quicinc.com> References: <20220214223051.3610-1-quic_alokad@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add new attributes NL80211_ATTR_RU_PUNCT_BITMAP and NL80211_ATTR_RU_PUNCT_SUPP_HE to receive RU puncturing information from the userspace. - Bitmap consists of 16 bits, each bit corresponding to a 20 MHz channel in the operating bandwidth. Lowest bit corresponds to the lowest frequency. Validate the bitmap against the minimum bandwidth support advertised by the driver. - HE support flag indicates whether OFDMA puncturing patterns should be considered during validation. Signed-off-by: Aloka Dixit --- include/uapi/linux/nl80211.h | 10 ++++++++ net/wireless/nl80211.c | 49 ++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index b4849afede98..1cccc1e8dc29 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -2667,6 +2667,14 @@ enum nl80211_commands { * the driver supports preamble puncturing, value should be of type * &enum nl80211_ru_punct_supp_bw * + * @NL80211_ATTR_RU_PUNCT_SUPP_HE: flag attribute, used to indicate that RU + * puncturing bitmap validation should include OFDMA bitmaps. + * + * @NL80211_ATTR_RU_PUNCT_BITMAP: (u16) RU puncturing bitmap where the lowest + * bit corresponds to the lowest 20 MHz channel. Each bit set to 1 + * indicates that the sub-channel is punctured, set 0 indicates that the + * channel is active. + * * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use @@ -3180,6 +3188,8 @@ enum nl80211_attrs { NL80211_ATTR_EHT_CAPABILITY, NL80211_ATTR_RU_PUNCT_SUPP_BW, + NL80211_ATTR_RU_PUNCT_SUPP_HE, + NL80211_ATTR_RU_PUNCT_BITMAP, /* add attributes here, update the policy in nl80211.c */ diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 3b244b96d15f..720e53917013 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -784,6 +784,8 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { NL80211_EHT_MAX_CAPABILITY_LEN), [NL80211_ATTR_RU_PUNCT_SUPP_BW] = NLA_POLICY_MAX(NLA_U8, NL80211_RU_PUNCT_SUPP_BW_320), + [NL80211_ATTR_RU_PUNCT_SUPP_HE] = { .type = NLA_FLAG }, + [NL80211_ATTR_RU_PUNCT_BITMAP] = { .type = NLA_U16 }, }; /* policy for the key attributes */ @@ -3117,6 +3119,46 @@ static bool nl80211_can_set_dev_channel(struct wireless_dev *wdev) wdev->iftype == NL80211_IFTYPE_P2P_GO; } +static int nl80211_parse_ru_punct_bitmap(struct cfg80211_registered_device *rdev, + struct genl_info *info, + struct cfg80211_chan_def *chandef) +{ + chandef->ru_punct_bitmap_supp_he = + nla_get_flag(info->attrs[NL80211_ATTR_RU_PUNCT_SUPP_HE]); + + chandef->ru_punct_bitmap = + nla_get_u16(info->attrs[NL80211_ATTR_RU_PUNCT_BITMAP]); + + if (!chandef->ru_punct_bitmap) + return 0; + + if (!rdev->wiphy.ru_punct_supp_bw && + (chandef->ru_punct_bitmap || chandef->ru_punct_bitmap_supp_he)) + return -EOPNOTSUPP; + + switch (chandef->width) { + case NL80211_CHAN_WIDTH_80: + if (rdev->wiphy.ru_punct_supp_bw >= + NL80211_RU_PUNCT_SUPP_BW_160) + return -EOPNOTSUPP; + break; + + case NL80211_CHAN_WIDTH_160: + if (rdev->wiphy.ru_punct_supp_bw >= + NL80211_RU_PUNCT_SUPP_BW_320) + return -EOPNOTSUPP; + break; + + case NL80211_CHAN_WIDTH_320: + break; + + default: + return -EOPNOTSUPP; + } + + return 0; +} + int nl80211_parse_chandef(struct cfg80211_registered_device *rdev, struct genl_info *info, struct cfg80211_chan_def *chandef) @@ -3124,6 +3166,7 @@ int nl80211_parse_chandef(struct cfg80211_registered_device *rdev, struct netlink_ext_ack *extack = info->extack; struct nlattr **attrs = info->attrs; u32 control_freq; + int err; if (!attrs[NL80211_ATTR_WIPHY_FREQ]) return -EINVAL; @@ -3230,6 +3273,12 @@ int nl80211_parse_chandef(struct cfg80211_registered_device *rdev, return -EINVAL; } + if (info->attrs[NL80211_ATTR_RU_PUNCT_BITMAP]) { + err = nl80211_parse_ru_punct_bitmap(rdev, info, chandef); + if (err) + return err; + } + return 0; }