From patchwork Mon Jul 4 10:23:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Kumar Singh X-Patchwork-Id: 588097 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 7B4CAC433EF for ; Mon, 4 Jul 2022 10:25:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233792AbiGDKZn (ORCPT ); Mon, 4 Jul 2022 06:25:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233875AbiGDKZW (ORCPT ); Mon, 4 Jul 2022 06:25:22 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30E591B7 for ; Mon, 4 Jul 2022 03:24:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1656930243; x=1688466243; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=l26yKAdHAT0aHgydRvuzdgRPmcJU/SbFfguiNZFjGoY=; b=VWbRp2aPVxKA+dND9v8Uiwd/4/xuoxAtGpleMmfFe7sK7Efw1FXf2kIi 41uYwTQ/aanyFc491h8/ixneJomWHGshE7KTbN/0r6zvQO+s63QcWjiJY 3W2tqcy2Rnrc9U/VTFsqi9XIKbcSv5B2OgzCb4YzKkbH1/OflCXpY/PjQ E=; Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 04 Jul 2022 03:24:02 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2022 03:24:02 -0700 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.22; Mon, 4 Jul 2022 03:24:02 -0700 Received: from adisi-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.986.22; Mon, 4 Jul 2022 03:24:00 -0700 From: Aditya Kumar Singh To: CC: , Wen Gong , "Aditya Kumar Singh" Subject: [PATCH 1/7] cfg80211: save Power Spectral Density (PSD) of the regulatory rule Date: Mon, 4 Jul 2022 15:53:35 +0530 Message-ID: <20220704102341.5692-2-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220704102341.5692-1-quic_adisi@quicinc.com> References: <20220704102341.5692-1-quic_adisi@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Wen Gong 6 GHz regulatory domain introduces Power Spectral Density (PSD). The PSD value of the regulatory rule should be taken into effect for the ieee80211_channels falling into that particular regulatory rule. Save the values in the channel which has PSD value and add nl80211 attributes accordingly to handle it. Signed-off-by: Wen Gong Co-developed-by: Aditya Kumar Singh Signed-off-by: Aditya Kumar Singh --- include/net/cfg80211.h | 5 +++++ include/net/regulatory.h | 1 + include/uapi/linux/nl80211.h | 9 +++++++++ net/wireless/nl80211.c | 18 ++++++++++++++++++ net/wireless/reg.c | 17 +++++++++++++++++ 5 files changed, 50 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 140354f5f15b..600c080a280b 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -115,6 +115,8 @@ struct wiphy; * This may be due to the driver or due to regulatory bandwidth * restrictions. * @IEEE80211_CHAN_NO_EHT: EHT operation is not permitted on this channel. + * @IEEE80211_CHAN_PSD: power spectral density (in dBm) + * on this channel */ enum ieee80211_channel_flags { IEEE80211_CHAN_DISABLED = 1<<0, @@ -138,6 +140,7 @@ enum ieee80211_channel_flags { IEEE80211_CHAN_16MHZ = 1<<18, IEEE80211_CHAN_NO_320MHZ = 1<<19, IEEE80211_CHAN_NO_EHT = 1<<20, + IEEE80211_CHAN_PSD = 1<<21, }; #define IEEE80211_CHAN_NO_HT40 \ @@ -171,6 +174,7 @@ enum ieee80211_channel_flags { * on this channel. * @dfs_state_entered: timestamp (jiffies) when the dfs state was entered. * @dfs_cac_ms: DFS CAC time in milliseconds, this is valid for DFS channels. + * @psd: power spectral density (in dBm) */ struct ieee80211_channel { enum nl80211_band band; @@ -187,6 +191,7 @@ struct ieee80211_channel { enum nl80211_dfs_state dfs_state; unsigned long dfs_state_entered; unsigned int dfs_cac_ms; + s8 psd; }; /** diff --git a/include/net/regulatory.h b/include/net/regulatory.h index 47f06f6f5a67..ed20004fb6a9 100644 --- a/include/net/regulatory.h +++ b/include/net/regulatory.h @@ -221,6 +221,7 @@ struct ieee80211_reg_rule { u32 flags; u32 dfs_cac_ms; bool has_wmm; + s8 psd; }; struct ieee80211_regdomain { diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 279f9715919e..8c21136ac18c 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -4062,6 +4062,8 @@ enum nl80211_wmm_rule { * as the primary or any of the secondary channels isn't possible * @NL80211_FREQUENCY_ATTR_NO_EHT: EHT operation is not allowed on this channel * in current regulatory domain. + * @NL80211_FREQUENCY_ATTR_PSD: power spectral density (in dBm) + * is allowed on this channel in current regulatory domain. * @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number * currently defined * @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use @@ -4100,6 +4102,7 @@ enum nl80211_frequency_attr { NL80211_FREQUENCY_ATTR_16MHZ, NL80211_FREQUENCY_ATTR_NO_320MHZ, NL80211_FREQUENCY_ATTR_NO_EHT, + NL80211_FREQUENCY_ATTR_PSD, /* keep last */ __NL80211_FREQUENCY_ATTR_AFTER_LAST, @@ -4200,6 +4203,8 @@ enum nl80211_reg_type { * a given frequency range. The value is in mBm (100 * dBm). * @NL80211_ATTR_DFS_CAC_TIME: DFS CAC time in milliseconds. * If not present or 0 default CAC time will be used. + * @NL80211_ATTR_POWER_RULE_PSD: power spectral density (in dBm). + * This could be negative. * @NL80211_REG_RULE_ATTR_MAX: highest regulatory rule attribute number * currently defined * @__NL80211_REG_RULE_ATTR_AFTER_LAST: internal use @@ -4217,6 +4222,8 @@ enum nl80211_reg_rule_attr { NL80211_ATTR_DFS_CAC_TIME, + NL80211_ATTR_POWER_RULE_PSD, + /* keep last */ __NL80211_REG_RULE_ATTR_AFTER_LAST, NL80211_REG_RULE_ATTR_MAX = __NL80211_REG_RULE_ATTR_AFTER_LAST - 1 @@ -4299,6 +4306,7 @@ enum nl80211_sched_scan_match_attr { * @NL80211_RRF_NO_160MHZ: 160MHz operation not allowed * @NL80211_RRF_NO_HE: HE operation not allowed * @NL80211_RRF_NO_320MHZ: 320MHz operation not allowed + * @NL80211_RRF_PSD: channel has power spectral density value */ enum nl80211_reg_rule_flags { NL80211_RRF_NO_OFDM = 1<<0, @@ -4318,6 +4326,7 @@ enum nl80211_reg_rule_flags { NL80211_RRF_NO_160MHZ = 1<<16, NL80211_RRF_NO_HE = 1<<17, NL80211_RRF_NO_320MHZ = 1<<18, + NL80211_RRF_PSD = 1<<19, }; #define NL80211_RRF_PASSIVE_SCAN NL80211_RRF_NO_IR diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index eda2ad029c90..afa8cd686e0e 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -1096,6 +1096,10 @@ static int nl80211_msg_put_channel(struct sk_buff *msg, struct wiphy *wiphy, if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_OFFSET, chan->freq_offset)) goto nla_put_failure; + if ((chan->flags & IEEE80211_CHAN_PSD) && + nla_put_s8(msg, NL80211_FREQUENCY_ATTR_PSD, chan->psd)) + goto nla_put_failure; + if ((chan->flags & IEEE80211_CHAN_DISABLED) && nla_put_flag(msg, NL80211_FREQUENCY_ATTR_DISABLED)) goto nla_put_failure; @@ -8168,6 +8172,11 @@ static int nl80211_put_regdom(const struct ieee80211_regdomain *regdom, reg_rule->dfs_cac_ms)) goto nla_put_failure; + if ((reg_rule->flags & NL80211_RRF_PSD) && + nla_put_s8(msg, NL80211_ATTR_POWER_RULE_PSD, + reg_rule->psd)) + goto nla_put_failure; + nla_nest_end(msg, nl_reg_rule); } @@ -8341,6 +8350,7 @@ static const struct nla_policy reg_rule_policy[NL80211_REG_RULE_ATTR_MAX + 1] = [NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN] = { .type = NLA_U32 }, [NL80211_ATTR_POWER_RULE_MAX_EIRP] = { .type = NLA_U32 }, [NL80211_ATTR_DFS_CAC_TIME] = { .type = NLA_U32 }, + [NL80211_ATTR_POWER_RULE_PSD] = { .type = NLA_S8 }, }; static int parse_reg_rule(struct nlattr *tb[], @@ -8362,6 +8372,14 @@ static int parse_reg_rule(struct nlattr *tb[], reg_rule->flags = nla_get_u32(tb[NL80211_ATTR_REG_RULE_FLAGS]); + if (reg_rule->flags & NL80211_RRF_PSD) { + if (!tb[NL80211_ATTR_POWER_RULE_PSD]) + return -EINVAL; + + reg_rule->psd = + nla_get_s8(tb[NL80211_ATTR_POWER_RULE_PSD]); + } + freq_range->start_freq_khz = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_START]); freq_range->end_freq_khz = diff --git a/net/wireless/reg.c b/net/wireless/reg.c index c7383ede794f..9a06aadba0d7 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -1619,6 +1619,8 @@ static u32 map_regdom_flags(u32 rd_flags) channel_flags |= IEEE80211_CHAN_NO_HE; if (rd_flags & NL80211_RRF_NO_320MHZ) channel_flags |= IEEE80211_CHAN_NO_320MHZ; + if (rd_flags & NL80211_RRF_PSD) + channel_flags |= IEEE80211_CHAN_PSD; return channel_flags; } @@ -1825,6 +1827,9 @@ static void handle_channel_single_rule(struct wiphy *wiphy, chan->dfs_cac_ms = reg_rule->dfs_cac_ms; } + if (chan->flags & IEEE80211_CHAN_PSD) + chan->psd = reg_rule->psd; + return; } @@ -1845,6 +1850,9 @@ static void handle_channel_single_rule(struct wiphy *wiphy, chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; } + if (chan->flags & IEEE80211_CHAN_PSD) + chan->psd = reg_rule->psd; + if (chan->orig_mpwr) { /* * Devices that use REGULATORY_COUNTRY_IE_FOLLOW_POWER @@ -1914,6 +1922,12 @@ static void handle_channel_adjacent_rules(struct wiphy *wiphy, rrule2->dfs_cac_ms); } + if ((rrule1->flags & NL80211_RRF_PSD) && + (rrule2->flags & NL80211_RRF_PSD)) + chan->psd = min_t(s8, rrule1->psd, rrule2->psd); + else + chan->flags &= ~NL80211_RRF_PSD; + return; } @@ -2600,6 +2614,9 @@ static void handle_channel_custom(struct wiphy *wiphy, chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; } + if (chan->flags & IEEE80211_CHAN_PSD) + chan->psd = reg_rule->psd; + chan->max_power = chan->max_reg_power; } From patchwork Mon Jul 4 10:23:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Kumar Singh X-Patchwork-Id: 588096 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 90C6DC433EF for ; Mon, 4 Jul 2022 10:25:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234502AbiGDKZw (ORCPT ); Mon, 4 Jul 2022 06:25:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234507AbiGDKZ3 (ORCPT ); Mon, 4 Jul 2022 06:25:29 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ED8610FFD for ; Mon, 4 Jul 2022 03:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1656930248; x=1688466248; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=JLjUcfEAoZGdc0LpXM0fzRBNZSHUKbX665cALsYwCoo=; b=keOjFQ4TSAcijuoytFihVG2NPWiz9J1uNHGOiJwjxIYNa7ArzHVqTM+J DmW+sdbZHTFPwszc+hgUO0RyOa7P3m2CzqObsJT/GmbGWW95EtWq916Tx 1D6+5Z6i9Ch8ynYzVOk5ZX374phmEz9Amgj163zorUHw5IyL6MfgOK4b+ Y=; Received: from ironmsg-lv-alpha.qualcomm.com ([10.47.202.13]) by alexa-out.qualcomm.com with ESMTP; 04 Jul 2022 03:24:08 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg-lv-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2022 03:24:08 -0700 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.22; Mon, 4 Jul 2022 03:24:07 -0700 Received: from adisi-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.986.22; Mon, 4 Jul 2022 03:24:06 -0700 From: Aditya Kumar Singh To: CC: , Aditya Kumar Singh Subject: [PATCH 3/7] mac80211: add combined power type definition for 6 GHz Date: Mon, 4 Jul 2022 15:53:37 +0530 Message-ID: <20220704102341.5692-4-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220704102341.5692-1-quic_adisi@quicinc.com> References: <20220704102341.5692-1-quic_adisi@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 6 GHz regulatory domain introduces different power modes for 6 GHz AP operation - Low Power Indoor(LPI), Standard Power(SP) and Very Low Power(VLP). 6 GHz STAs could be operated as either Regular or Subordinate clients. We have separate definitions of AP and client. However, during concurrency (multi-interfaces), it would be difficult to keep different enum containers for different interface types in order to track its power mode. Add new combined power type definition for 6 GHz interfaces. Also add support to convert existing AP/Client Power type to this new combined power type enum. Signed-off-by: Aditya Kumar Singh --- include/net/cfg80211.h | 19 ++++++++++++ include/uapi/linux/nl80211.h | 38 +++++++++++++++++++++++ net/wireless/util.c | 60 ++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 600c080a280b..ed482b23fb9c 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5902,6 +5902,25 @@ ieee80211_frequency_to_channel(int freq) struct ieee80211_channel * ieee80211_get_channel_khz(struct wiphy *wiphy, u32 freq); +/** + * ieee80211_ap_reg_power_to_reg_power_mode - convert AP specific 6 GHz power + * type into combined 6 GHz power type + * @ap_type: AP's power mode + * Return: Power mode as referenced in &enum nl80211_regulatory_power_modes + */ +enum nl80211_regulatory_power_modes +ieee80211_ap_reg_power_to_reg_power_mode(enum ieee80211_ap_reg_power ap_type); + +/** + * ieee80211_client_reg_power_to_reg_power_mode - convert Client specific 6 GHz + * power type into combined 6 GHz power type + * @client_type: Client's power mode + * @ap_type: AP's power mode to which this client is associating + * Return: Power mode as referenced in &enum nl80211_regulatory_power_modes + */ +enum nl80211_regulatory_power_modes +ieee80211_client_reg_power_to_reg_power_mode(enum ieee80211_client_reg_power client_type, + enum ieee80211_ap_reg_power ap_type); /** * ieee80211_get_channel - get channel struct from wiphy for specified frequency * diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 8c21136ac18c..789f73878f50 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -3970,6 +3970,44 @@ enum nl80211_band_attr { #define NL80211_BAND_ATTR_HT_CAPA NL80211_BAND_ATTR_HT_CAPA +/** + * enum nl80211_regulatory_power_modes - 6 GHz regulatory power + * modes + * @NL80211_REG_AP_LPI: Low Power Indoor (Access Point) + * @NL80211_REG_AP_SP: Standard Power (Access Point) + * @NL80211_REG_AP_VLP: Very Low Power (Access Point) + * @NL80211_REG_REGULAR_CLIENT_LPI: Low Power Indoor (Regular + * or Default Client) + * @NL80211_REG_REGULAR_CLIENT_SP: Standard Power (Regular + * or Default Client) + * @NL80211_REG_REGULAR_CLIENT_VLP: Very Low Power (Regular + * or Default Client) + * @NL80211_REG_SUBORDINATE_CLIENT_LPI: Low Power Indoor + * (Subordinate Client) + * @NL80211_REG_SUBORDINATE_CLIENT_SP: Standard Power + * (Subordinate Client) + * @NL80211_REG_SUBORDINATE_CLIENT_VLP: Very Low Power + * (Subordinate Client) + * @NL80211_REG_MAX_POWER_MODES: Max supported number of power + * modes + * @__NL80211_REG_LAST: Internal use + */ +enum nl80211_regulatory_power_modes { + NL80211_REG_AP_LPI, + NL80211_REG_AP_SP, + NL80211_REG_AP_VLP, + NL80211_REG_REGULAR_CLIENT_LPI, + NL80211_REG_REGULAR_CLIENT_SP, + NL80211_REG_REGULAR_CLIENT_VLP, + NL80211_REG_SUBORDINATE_CLIENT_LPI, + NL80211_REG_SUBORDINATE_CLIENT_SP, + NL80211_REG_SUBORDINATE_CLIENT_VLP, + + /* keep last */ + __NL80211_REG_LAST, + NL80211_REG_MAX_POWER_MODES = __NL80211_REG_LAST - 1, +}; + /** * enum nl80211_wmm_rule - regulatory wmm rule * diff --git a/net/wireless/util.c b/net/wireless/util.c index b7257862e0fe..cca0ee321a03 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -190,6 +190,66 @@ struct ieee80211_channel *ieee80211_get_channel_khz(struct wiphy *wiphy, } EXPORT_SYMBOL(ieee80211_get_channel_khz); +enum nl80211_regulatory_power_modes +ieee80211_ap_reg_power_to_reg_power_mode(enum ieee80211_ap_reg_power ap_type) +{ + switch (ap_type) { + case IEEE80211_REG_LPI_AP: + return NL80211_REG_AP_LPI; + case IEEE80211_REG_SP_AP: + return NL80211_REG_AP_SP; + case IEEE80211_REG_VLP_AP: + return NL80211_REG_AP_VLP; + default: + return NL80211_REG_MAX_POWER_MODES + 1; + } +} +EXPORT_SYMBOL(ieee80211_ap_reg_power_to_reg_power_mode); + +/* ieee80211_client_reg_power_to_reg_power_mode: Accepts the individual power type of + * a 6 GHz client and power type of AP to which the client is associating and returns + * the final combined power mode as enumerated in &enum nl80211_regulatory_power_modes. + * + * Unlike AP, for client there is no direct mapping because final power mode of + * operation of client is dependent upon the power type of AP. + * For example - + * If client is a Regular client and AP is Low Power Indoor then combined power mode + * will be Regular Low Power Indoor where as if AP is Standard Power, then it will be + * Regular Standard Power Mode. + */ +enum nl80211_regulatory_power_modes +ieee80211_client_reg_power_to_reg_power_mode(enum ieee80211_client_reg_power client_type, + enum ieee80211_ap_reg_power ap_type) +{ + switch (client_type) { + case IEEE80211_REG_DEFAULT_CLIENT: + switch (ap_type) { + case IEEE80211_REG_LPI_AP: + return NL80211_REG_REGULAR_CLIENT_LPI; + case IEEE80211_REG_SP_AP: + return NL80211_REG_REGULAR_CLIENT_SP; + case IEEE80211_REG_VLP_AP: + return NL80211_REG_REGULAR_CLIENT_VLP; + default: + return NL80211_REG_MAX_POWER_MODES + 1; + } + case IEEE80211_REG_SUBORDINATE_CLIENT: + switch (ap_type) { + case IEEE80211_REG_LPI_AP: + return NL80211_REG_SUBORDINATE_CLIENT_LPI; + case IEEE80211_REG_SP_AP: + return NL80211_REG_SUBORDINATE_CLIENT_SP; + case IEEE80211_REG_VLP_AP: + return NL80211_REG_SUBORDINATE_CLIENT_SP; + default: + return NL80211_REG_MAX_POWER_MODES; + } + default: + return NL80211_REG_MAX_POWER_MODES + 1; + } +} +EXPORT_SYMBOL(ieee80211_client_reg_power_to_reg_power_mode); + static void set_mandatory_flags_band(struct ieee80211_supported_band *sband) { int i, want; From patchwork Mon Jul 4 10:23:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Kumar Singh X-Patchwork-Id: 588095 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 768D6CCA47F for ; Mon, 4 Jul 2022 10:25:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234524AbiGDKZ5 (ORCPT ); Mon, 4 Jul 2022 06:25:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234299AbiGDKZf (ORCPT ); Mon, 4 Jul 2022 06:25:35 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94AD51115C for ; Mon, 4 Jul 2022 03:24:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1656930253; x=1688466253; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=1rcXM5diwjF9xWa5nm07uvLm6hFCJu0vRsRlo5z046w=; b=QOHUNZZ7Ggc9M6rhKwrlAlzZkDrY6HRj3pK0aZ4fV2Bo2kcEv4i6WTG4 GTeI0Fz8Y5Tv9IBYtrzNFBReAAbxU9eqqiXzr/BysFuvBpIZxA7ffKu4q 2YqAN9tp8BsXWm4kFI3MulkFrjChaK3gYRIJuY+PcKsgQKo/fkZZJezLo 0=; Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 04 Jul 2022 03:24:13 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2022 03:24:13 -0700 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.22; Mon, 4 Jul 2022 03:24:12 -0700 Received: from adisi-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.986.22; Mon, 4 Jul 2022 03:24:11 -0700 From: Aditya Kumar Singh To: CC: , Aditya Kumar Singh Subject: [PATCH 5/7] mac80211: add support for 6 GHz channels and regulatory Date: Mon, 4 Jul 2022 15:53:39 +0530 Message-ID: <20220704102341.5692-6-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220704102341.5692-1-quic_adisi@quicinc.com> References: <20220704102341.5692-1-quic_adisi@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 6 GHz introduces various power modes of operation. Currently, based on the power mode, channel's Power Spectral Density (PSD) value as well as channel disabled flag can change. For single interface, current implementation works just fine. But for multi-interfaces, for example AP-STA concurrency, two different channel context needs to be maintained. This is because, STA power mode also depends on the AP's power mode it is going to associate with. Hence, PSD value and channel disabled flag might vary. In this case, same channel context cannot be used for both AP and STA. Therefore, to support multiple channel space for each power mode, the 6 GHz channels needs a separate storage space in struct ieee80211_supported_band. Because of this, the existing APIs to get the channel/freq from freq/channel will not work for 6 GHz band. Add support to store all possible 6 GHz channel pools according to the power mode as well as add API support for getting chan/freq info from the new struct ieee80211_channel_6ghz. Signed-off-by: Aditya Kumar Singh --- include/net/cfg80211.h | 31 ++++++++++++++++++++++++++++ include/net/regulatory.h | 1 + net/mac80211/util.c | 40 +++++++++++++++++++++++++++++++++++- net/wireless/reg.c | 44 +++++++++++++++++++++++++++++++++------- net/wireless/util.c | 27 ++++++++++++++++++++++++ 5 files changed, 135 insertions(+), 8 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 1e8852c6149f..21c058bec5fe 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -512,6 +512,21 @@ struct ieee80211_sta_s1g_cap { u8 nss_mcs[5]; }; +/** + * struct ieee80211_channel_6ghz - 6 GHz channel definitions + * + * This structure defines all the channels supported by the + * 6 GHz band. + * + * @channels: Array of channels the hardware can operate with + * in 6 GHz band. + * @n_channels: Number of channels in @channels + */ +struct ieee80211_channel_6ghz { + struct ieee80211_channel *channels; + int n_channels; +}; + /** * struct ieee80211_supported_band - frequency band definition * @@ -520,6 +535,7 @@ struct ieee80211_sta_s1g_cap { * * @channels: Array of channels the hardware can operate with * in this band. + * @channels_6ghz: Array of 6 GHz channels the hardware can operate with * @band: the band this structure represents * @n_channels: Number of channels in @channels * @bitrates: Array of bitrates the hardware can operate with @@ -539,6 +555,8 @@ struct ieee80211_sta_s1g_cap { */ struct ieee80211_supported_band { struct ieee80211_channel *channels; + struct ieee80211_channel_6ghz + *channels_6ghz[NL80211_REG_MAX_POWER_MODES + 1]; struct ieee80211_rate *bitrates; enum nl80211_band band; int n_channels; @@ -5943,6 +5961,19 @@ ieee80211_get_channel(struct wiphy *wiphy, int freq) return ieee80211_get_channel_khz(wiphy, MHZ_TO_KHZ(freq)); } +/** + * ieee80211_get_6ghz_channel_khz - get channel struct from wiphy for specified + * frequency in 6 GHz band + * + * @wiphy: the struct wiphy to get the channel for + * @freq: the center frequency (in KHz) of the channel + * @power_mode: the power mode in which freq is to be operated + * Return: The channel struct from @wiphy at @freq. + */ +struct ieee80211_channel * +ieee80211_get_6ghz_channel_khz(struct wiphy *wiphy, u32 freq, + enum nl80211_regulatory_power_modes power_mode); + /** * cfg80211_channel_is_psc - Check if the channel is a 6 GHz PSC * @chan: control channel to check diff --git a/include/net/regulatory.h b/include/net/regulatory.h index ed20004fb6a9..5589c3eb8316 100644 --- a/include/net/regulatory.h +++ b/include/net/regulatory.h @@ -218,6 +218,7 @@ struct ieee80211_reg_rule { struct ieee80211_freq_range freq_range; struct ieee80211_power_rule power_rule; struct ieee80211_wmm_rule wmm_rule; + enum nl80211_regulatory_power_modes power_mode; u32 flags; u32 dfs_cac_ms; bool has_wmm; diff --git a/net/mac80211/util.c b/net/mac80211/util.c index efdea5c2f2db..6a955ef5712c 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -3464,6 +3464,9 @@ bool ieee80211_chandef_he_6ghz_oper(struct ieee80211_sub_if_data *sdata, bool support_80_80, support_160, support_320; u8 he_phy_cap, eht_phy_cap; u32 freq; + enum ieee80211_ap_reg_power reg_6ghz_power_beacon, reg_6ghz_ap_power; + enum ieee80211_client_reg_power reg_6ghz_client_power; + enum nl80211_regulatory_power_modes reg_6ghz_power_final; if (chandef->chan->band != NL80211_BAND_6GHZ) return true; @@ -3506,6 +3509,39 @@ bool ieee80211_chandef_he_6ghz_oper(struct ieee80211_sub_if_data *sdata, return false; } + /* 6 GHz Power mode present in the beacon */ + reg_6ghz_power_beacon = u8_get_bits(he_6ghz_oper->control, + IEEE80211_HE_6GHZ_OPER_CTRL_REG_INFO); + switch (reg_6ghz_power_beacon) { + case IEEE80211_REG_LPI_AP: + case IEEE80211_REG_SP_AP: + case IEEE80211_REG_VLP_AP: + break; + default: + sdata_info(sdata, + "Invalid Regulatory Info subfield in HE 6 GHz operation, expect issues\n"); + return false; + } + + /* For AP/AP_VLAN/MESH_POINT interfaces, the 6 GHz power mode depends on the + * mode configured by user (LPI/SP/VLP). For other interfaces (for ex STA) + * mode depends on the power mode present in beacon as well as power mode + * configured by the user for that interface + */ + if (iftype == NL80211_IFTYPE_AP || iftype == NL80211_IFTYPE_AP_VLAN || + iftype == NL80211_IFTYPE_MESH_POINT) { + /* 6 GHz Power mode configured by the user in the config */ + reg_6ghz_ap_power = sdata->wdev.ap_6ghz_power; + reg_6ghz_power_final = + ieee80211_ap_reg_power_to_reg_power_mode(reg_6ghz_ap_power); + } else { + /* 6 GHz Power mode configured by the user in the config */ + reg_6ghz_client_power = sdata->wdev.client_6ghz_power; + reg_6ghz_power_final = + ieee80211_client_reg_power_to_reg_power_mode(reg_6ghz_client_power, + reg_6ghz_power_beacon); + } + /* * The EHT operation IE does not contain the primary channel so the * primary channel frequency should be taken from the 6 GHz operation @@ -3513,7 +3549,9 @@ bool ieee80211_chandef_he_6ghz_oper(struct ieee80211_sub_if_data *sdata, */ freq = ieee80211_channel_to_frequency(he_6ghz_oper->primary, NL80211_BAND_6GHZ); - he_chandef.chan = ieee80211_get_channel(sdata->local->hw.wiphy, freq); + he_chandef.chan = ieee80211_get_6ghz_channel_khz(sdata->local->hw.wiphy, + MHZ_TO_KHZ(freq), + reg_6ghz_power_final); switch (u8_get_bits(he_6ghz_oper->control, IEEE80211_HE_6GHZ_OPER_CTRL_REG_INFO)) { diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 9a06aadba0d7..fae360afbd65 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -1626,7 +1626,8 @@ static u32 map_regdom_flags(u32 rd_flags) static const struct ieee80211_reg_rule * freq_reg_info_regd(u32 center_freq, - const struct ieee80211_regdomain *regd, u32 bw) + const struct ieee80211_regdomain *regd, u32 bw, + enum nl80211_regulatory_power_modes power_mode) { int i; bool band_rule_found = false; @@ -1640,7 +1641,12 @@ freq_reg_info_regd(u32 center_freq, const struct ieee80211_freq_range *fr = NULL; rr = ®d->reg_rules[i]; - fr = &rr->freq_range; + + if (rr->power_mode == power_mode) + fr = &rr->freq_range; + + if (!fr) + continue; /* * We only need to know if one frequency rule was @@ -1672,7 +1678,8 @@ __freq_reg_info(struct wiphy *wiphy, u32 center_freq, u32 min_bw) u32 bw; for (bw = MHZ_TO_KHZ(bws[i]); bw >= min_bw; bw = MHZ_TO_KHZ(bws[i--])) { - reg_rule = freq_reg_info_regd(center_freq, regd, bw); + reg_rule = freq_reg_info_regd(center_freq, regd, bw, + NL80211_REG_AP_LPI); if (!IS_ERR(reg_rule)) return reg_rule; } @@ -2324,7 +2331,8 @@ static void reg_process_ht_flags_channel(struct wiphy *wiphy, if (regd) { const struct ieee80211_reg_rule *reg_rule = freq_reg_info_regd(MHZ_TO_KHZ(channel->center_freq), - regd, MHZ_TO_KHZ(20)); + regd, MHZ_TO_KHZ(20), + NL80211_REG_AP_LPI); if (!IS_ERR(reg_rule)) flags = reg_rule->flags; @@ -2563,7 +2571,8 @@ static void update_all_wiphy_regulatory(enum nl80211_reg_initiator initiator) static void handle_channel_custom(struct wiphy *wiphy, struct ieee80211_channel *chan, const struct ieee80211_regdomain *regd, - u32 min_bw) + u32 min_bw, + enum nl80211_regulatory_power_modes power_mode) { u32 bw_flags = 0; const struct ieee80211_reg_rule *reg_rule = NULL; @@ -2572,7 +2581,7 @@ static void handle_channel_custom(struct wiphy *wiphy, center_freq_khz = ieee80211_channel_to_khz(chan); for (bw = MHZ_TO_KHZ(20); bw >= min_bw; bw = bw / 2) { - reg_rule = freq_reg_info_regd(center_freq_khz, regd, bw); + reg_rule = freq_reg_info_regd(center_freq_khz, regd, bw, power_mode); if (!IS_ERR(reg_rule)) break; } @@ -2625,10 +2634,30 @@ static void handle_band_custom(struct wiphy *wiphy, const struct ieee80211_regdomain *regd) { unsigned int i; + unsigned int j; + bool _6ghz_new_support = false; if (!sband) return; + if (sband->band == NL80211_BAND_6GHZ) { + for (i = 0; i < NL80211_REG_MAX_POWER_MODES + 1; i++) { + if (!sband->channels_6ghz[i]) + continue; + + if (!_6ghz_new_support) + _6ghz_new_support = true; + + for (j = 0; j < sband->channels_6ghz[i]->n_channels; j++) + handle_channel_custom(wiphy, + &sband->channels_6ghz[i]->channels[j], + regd, MHZ_TO_KHZ(20), i); + } + + if (_6ghz_new_support) + return; + } + /* * We currently assume that you always want at least 20 MHz, * otherwise channel 12 might get enabled if this rule is @@ -2636,7 +2665,8 @@ static void handle_band_custom(struct wiphy *wiphy, */ for (i = 0; i < sband->n_channels; i++) handle_channel_custom(wiphy, &sband->channels[i], regd, - MHZ_TO_KHZ(20)); + MHZ_TO_KHZ(20), + NL80211_REG_AP_LPI); } /* Used by drivers prior to wiphy registration */ diff --git a/net/wireless/util.c b/net/wireless/util.c index cca0ee321a03..38e807e30874 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -165,6 +165,33 @@ int ieee80211_freq_khz_to_channel(u32 freq) } EXPORT_SYMBOL(ieee80211_freq_khz_to_channel); +struct ieee80211_channel +*ieee80211_get_6ghz_channel_khz(struct wiphy *wiphy, u32 freq, + enum nl80211_regulatory_power_modes power_mode) +{ + struct ieee80211_supported_band *sband; + int i; + struct ieee80211_channel *chan; + + sband = wiphy->bands[NL80211_BAND_6GHZ]; + + if (!sband || power_mode >= NL80211_REG_MAX_POWER_MODES + 1) + return NULL; + + if (!sband->channels_6ghz[power_mode]) + return ieee80211_get_channel_khz(wiphy, freq); + + for (i = 0; i < sband->channels_6ghz[power_mode]->n_channels; i++) { + chan = &sband->channels_6ghz[power_mode]->channels[i]; + + if (ieee80211_channel_to_khz(chan) == freq) + return chan; + } + + return NULL; +} +EXPORT_SYMBOL(ieee80211_get_6ghz_channel_khz); + struct ieee80211_channel *ieee80211_get_channel_khz(struct wiphy *wiphy, u32 freq) { From patchwork Mon Jul 4 10:23:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Kumar Singh X-Patchwork-Id: 588094 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 C607BC43334 for ; Mon, 4 Jul 2022 10:26:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233456AbiGDK0D (ORCPT ); Mon, 4 Jul 2022 06:26:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234450AbiGDKZm (ORCPT ); Mon, 4 Jul 2022 06:25:42 -0400 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 7926211440 for ; Mon, 4 Jul 2022 03:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1656930258; x=1688466258; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=MvdYv+YJGN2ILOx1k1ef7ciZKV3uX6IdJ7SV9yLTtkA=; b=v0YoVWrtPt36Vf/T61YlHK3YAxye67906+eBDIQDlVn2wJA3Xwvc7YXc f7XWKhgydVoygIzmKbpKYmggaOucqg+eXoaxvgYgCmSQqd0qHA4UbJ3yw Um44OdTwrtpojnF6ZzrkJgmE+lXqKIXZUoUHer7fHPcU22+jyCP/m8Gsn o=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-02.qualcomm.com with ESMTP; 04 Jul 2022 03:24:18 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2022 03:24:18 -0700 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.22; Mon, 4 Jul 2022 03:24:17 -0700 Received: from adisi-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.986.22; Mon, 4 Jul 2022 03:24:16 -0700 From: Aditya Kumar Singh To: CC: , Aditya Kumar Singh Subject: [PATCH 7/7] cfg80211: save 6 GHz power mode of the regulatory rules Date: Mon, 4 Jul 2022 15:53:41 +0530 Message-ID: <20220704102341.5692-8-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220704102341.5692-1-quic_adisi@quicinc.com> References: <20220704102341.5692-1-quic_adisi@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Currently when user space demands the reg rules via NL80211_CMD_GET_REG command, along with Power Spectral Denity (PSD) values, power mode needs to be advertised since in 6 GHz AP beacon, Tx power envelope should have PSD info as well which can be opted based on the power mode. Similarly, via NL80211_CMD_SET_REG command, user space can try to set regulatory rules and cfg80211 needs to store the incoming power mode for the rule. Add support for 6 GHz power mode advertisement in NL80211_CMD_GET_REG command and saving 6 GHz power mode for reg rules via NL80211_CMD_SET_REG command. Signed-off-by: Aditya Kumar Singh --- include/uapi/linux/nl80211.h | 4 ++++ net/wireless/nl80211.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index e62838887802..f2a32023a3f4 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -4258,6 +4258,8 @@ enum nl80211_reg_type { * If not present or 0 default CAC time will be used. * @NL80211_ATTR_POWER_RULE_PSD: power spectral density (in dBm). * This could be negative. + * @NL80211_ATTR_REG_POWER_MODE: the regulatory power mode for 6 GHz rules. + * Referenced from &enum nl80211_regulatory_power_modes * @NL80211_REG_RULE_ATTR_MAX: highest regulatory rule attribute number * currently defined * @__NL80211_REG_RULE_ATTR_AFTER_LAST: internal use @@ -4277,6 +4279,8 @@ enum nl80211_reg_rule_attr { NL80211_ATTR_POWER_RULE_PSD, + NL80211_ATTR_REG_POWER_MODE, + /* keep last */ __NL80211_REG_RULE_ATTR_AFTER_LAST, NL80211_REG_RULE_ATTR_MAX = __NL80211_REG_RULE_ATTR_AFTER_LAST - 1 diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 915516bd4d93..5c0ac12c26b7 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -8200,6 +8200,13 @@ static int nl80211_put_regdom(const struct ieee80211_regdomain *regdom, reg_rule->dfs_cac_ms)) goto nla_put_failure; + /* Put power mode as well if its a 6 GHz reg rule */ + if (freq_range->start_freq_khz >= MHZ_TO_KHZ(5925) && + freq_range->end_freq_khz <= MHZ_TO_KHZ(7125) && + nla_put_u8(msg, NL80211_ATTR_REG_POWER_MODE, + reg_rule->power_mode)) + goto nla_put_failure; + if ((reg_rule->flags & NL80211_RRF_PSD) && nla_put_s8(msg, NL80211_ATTR_POWER_RULE_PSD, reg_rule->psd)) @@ -8379,6 +8386,10 @@ static const struct nla_policy reg_rule_policy[NL80211_REG_RULE_ATTR_MAX + 1] = [NL80211_ATTR_POWER_RULE_MAX_EIRP] = { .type = NLA_U32 }, [NL80211_ATTR_DFS_CAC_TIME] = { .type = NLA_U32 }, [NL80211_ATTR_POWER_RULE_PSD] = { .type = NLA_S8 }, + [NL80211_ATTR_REG_POWER_MODE] = + NLA_POLICY_RANGE(NLA_U8, + NL80211_REG_AP_LPI, + NL80211_REG_MAX_POWER_MODES), }; static int parse_reg_rule(struct nlattr *tb[], @@ -8426,6 +8437,15 @@ static int parse_reg_rule(struct nlattr *tb[], reg_rule->dfs_cac_ms = nla_get_u32(tb[NL80211_ATTR_DFS_CAC_TIME]); + if (freq_range->start_freq_khz >= MHZ_TO_KHZ(5925) && + freq_range->end_freq_khz <= MHZ_TO_KHZ(7125)) { + if (!tb[NL80211_ATTR_REG_POWER_MODE]) + return -EINVAL; + + reg_rule->power_mode = + nla_get_u8(tb[NL80211_ATTR_REG_POWER_MODE]); + } + return 0; }