From patchwork Wed Mar 15 13:28:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Kumar Singh X-Patchwork-Id: 664004 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 02D8EC7618A for ; Wed, 15 Mar 2023 13:29:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231928AbjCON3a (ORCPT ); Wed, 15 Mar 2023 09:29:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231401AbjCON32 (ORCPT ); Wed, 15 Mar 2023 09:29:28 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9BC4132EF for ; Wed, 15 Mar 2023 06:29:26 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FALMJo010097; Wed, 15 Mar 2023 13:29:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=IuS8CiINANoWXW3ZqLYC9o9ewOdKaPcsvL9bh4EgnHg=; b=NmCiNyj8ryfp7mW5SJDrywZ+LvFgrlgX2e8khp/UCRg+jlqFG/0+4qVP9xg4raqh6TAu ea+I9vGUD7qrJIjoA4ZmucXoh/l+QU9mUznBmzGkmAZ1nFoO73oXLBXr4f2NMIi8DPUS 0PIXuzj4fpO2VjjFzv99G5ZKrIzSqSH8VV7g/W6tu5xDfK8kGv8lF+Bkqp0hi2ZU8T0C CJ/0CJneV7EsZafk2eTKukCvmu5Tmrxhkr26j+PaIk7bQWjJwatnuMh3ObpRHiTp3weB kDOUJT80m6tluKo9u7moIaZlhtRcNeEAjXmO2UrzJ1D6T1o5qqfaRNLWlL/I+ICmvixl Eg== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pb2cshp08-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:24 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32FDTN6M023329 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:23 GMT 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.41; Wed, 15 Mar 2023 06:29:21 -0700 From: Aditya Kumar Singh To: CC: , Aditya Kumar Singh Subject: [PATCH v3 1/9] wifi: mac80211: rework on 6 GHz power type definition Date: Wed, 15 Mar 2023 18:58:56 +0530 Message-ID: <20230315132904.31779-2-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230315132904.31779-1-quic_adisi@quicinc.com> References: <20230315132904.31779-1-quic_adisi@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) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: ic_bRCxprSQ0DS5u9nm0-r8YEgNoEwrY X-Proofpoint-ORIG-GUID: ic_bRCxprSQ0DS5u9nm0-r8YEgNoEwrY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_06,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=891 impostorscore=0 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 priorityscore=1501 adultscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150114 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 6 GHz regulatory domain introduces different modes for 6 GHz AP operation - Low Power Indoor(LPI), Standard Power(SP) and Very Low Power(VLP). 6 GHz non-AP STAs could be operated as either Regular or Subordinate clients. We have separate definitions of AP and client. However, IEEE80211_REG_UNSET_* is not a defined power type. Also due to IEEE80211_REG_UNSET_*, it is difficult to use _MAX to size arrays. Move IEEE80211_REG_UNSET_* to last after *_MAX for both AP and client power mode enums. Signed-off-by: Aditya Kumar Singh --- include/linux/ieee80211.h | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index 2463bdd2a382..24d4b5ef3de2 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -2173,41 +2173,48 @@ int ieee80211_get_vht_max_nss(struct ieee80211_vht_cap *cap, unsigned int max_vht_nss); /** - * enum ieee80211_ap_reg_power - regulatory power for a Access Point + * enum ieee80211_ap_reg_power - regulatory power for an Access Point * - * @IEEE80211_REG_UNSET_AP: Access Point has no regulatory power mode * @IEEE80211_REG_LPI: Indoor Access Point - * @IEEE80211_REG_SP: Standard power Access Point - * @IEEE80211_REG_VLP: Very low power Access Point - * @IEEE80211_REG_AP_POWER_AFTER_LAST: internal + * @IEEE80211_REG_SP: Standard Power Access Point + * @IEEE80211_REG_VLP: Very Low Power Access Point + * @__IEEE80211_REG_AP_POWER_AFTER_LAST: internal use * @IEEE80211_REG_AP_POWER_MAX: maximum value + * @IEEE80211_REG_UNSET_AP: Access Point has no regulatory power + * mode. */ enum ieee80211_ap_reg_power { - IEEE80211_REG_UNSET_AP, IEEE80211_REG_LPI_AP, IEEE80211_REG_SP_AP, IEEE80211_REG_VLP_AP, - IEEE80211_REG_AP_POWER_AFTER_LAST, + + /* keep last */ + __IEEE80211_REG_AP_POWER_AFTER_LAST, IEEE80211_REG_AP_POWER_MAX = - IEEE80211_REG_AP_POWER_AFTER_LAST - 1, + __IEEE80211_REG_AP_POWER_AFTER_LAST - 1, + /* always last in order to use _MAX to size arrays */ + IEEE80211_REG_UNSET_AP = 0xFF, }; /** * enum ieee80211_client_reg_power - regulatory power for a client * - * @IEEE80211_REG_UNSET_CLIENT: Client has no regulatory power mode * @IEEE80211_REG_DEFAULT_CLIENT: Default Client * @IEEE80211_REG_SUBORDINATE_CLIENT: Subordinate Client - * @IEEE80211_REG_CLIENT_POWER_AFTER_LAST: internal + * @__IEEE80211_REG_CLIENT_POWER_AFTER_LAST: internal use * @IEEE80211_REG_CLIENT_POWER_MAX: maximum value + * @IEEE80211_REG_UNSET_CLIENT: Client has no regulatory power mode */ enum ieee80211_client_reg_power { - IEEE80211_REG_UNSET_CLIENT, IEEE80211_REG_DEFAULT_CLIENT, IEEE80211_REG_SUBORDINATE_CLIENT, - IEEE80211_REG_CLIENT_POWER_AFTER_LAST, + + /* keep last */ + __IEEE80211_REG_CLIENT_POWER_AFTER_LAST, IEEE80211_REG_CLIENT_POWER_MAX = - IEEE80211_REG_CLIENT_POWER_AFTER_LAST - 1, + __IEEE80211_REG_CLIENT_POWER_AFTER_LAST - 1, + /* always last in order to use _MAX to size arrays */ + IEEE80211_REG_UNSET_CLIENT = 0XFF, }; /* 802.11ax HE MAC capabilities */ From patchwork Wed Mar 15 13:28:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Kumar Singh X-Patchwork-Id: 664516 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 AE852C6FD1D for ; Wed, 15 Mar 2023 13:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231987AbjCON3d (ORCPT ); Wed, 15 Mar 2023 09:29:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231971AbjCON3c (ORCPT ); Wed, 15 Mar 2023 09:29:32 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAA523800A for ; Wed, 15 Mar 2023 06:29:28 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FALtAS028808; Wed, 15 Mar 2023 13:29:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=6JxMriThy8rHyVmNmNdnGa3RIbvkTohNhIII6hIdg0Q=; b=YRshfPw/GTqbIb2IL9hZRR2RKc+91bXh5avbbZBDwbUvnY0T+5BYLyjEpyFvLUiX8l3e q1q7493o0V9kC7mdfXf+GT5IsnfqOqWrrzLO3yQt8+jmUoqPYRg50d28JdwJpkNStr3f a6Z6O4xqH02xzlFd+6azTGdATUMHB+bbEZGnyDgV9XiKLSz/8ufm2p5GZ22IFxVT+CDj vN0ZcsMS21j1wHfbGOafGKapUrWH5tWuBZX8oL+IQqeOH/hIOrg8ZC/S9CB0N9Bcd1uT BY23BWtE9BGVJdxqIv0swDuhfsqY/qu2BacVd35ZdVDhDjd60yiLyas0nNM/n4dMz88c Gg== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pb2c21nks-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:25 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32FDTPJ0000806 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:25 GMT 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.41; Wed, 15 Mar 2023 06:29:23 -0700 From: Aditya Kumar Singh To: CC: , Wen Gong , Aditya Kumar Singh Subject: [PATCH v3 2/9] wifi: cfg80211: save Power Spectral Density (PSD) of the regulatory rule Date: Wed, 15 Mar 2023 18:58:57 +0530 Message-ID: <20230315132904.31779-3-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230315132904.31779-1-quic_adisi@quicinc.com> References: <20230315132904.31779-1-quic_adisi@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) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: vf_bdy-7E0IFp9SdzNe_SdmVl3QFi6Xq X-Proofpoint-ORIG-GUID: vf_bdy-7E0IFp9SdzNe_SdmVl3QFi6Xq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_06,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 clxscore=1015 bulkscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 mlxscore=0 phishscore=0 impostorscore=0 adultscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150114 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Wen Gong 6 GHz regulatory domains 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 7cebba1c4135..d64481d8d871 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 896191f420d5..c2bf0b39fd1e 100644 --- a/include/net/regulatory.h +++ b/include/net/regulatory.h @@ -224,6 +224,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 9a0ac0363f1f..844d2000b4e1 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -4167,6 +4167,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 @@ -4205,6 +4207,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, @@ -4305,6 +4308,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 @@ -4322,6 +4327,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 @@ -4404,6 +4411,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: channels has power spectral density value */ enum nl80211_reg_rule_flags { NL80211_RRF_NO_OFDM = 1<<0, @@ -4423,6 +4431,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 0a31b1d2845d..1e8fe560078f 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -1106,6 +1106,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; @@ -8456,6 +8460,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); } @@ -8629,6 +8638,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[], @@ -8650,6 +8660,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 0d40d6af7e10..452e0085ed2c 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -1587,6 +1587,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; } @@ -1793,6 +1795,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; } @@ -1813,6 +1818,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 @@ -1882,6 +1890,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; } @@ -2572,6 +2586,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 Wed Mar 15 13:28:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Kumar Singh X-Patchwork-Id: 664003 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 AC89DC61DA4 for ; Wed, 15 Mar 2023 13:29:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231976AbjCON3e (ORCPT ); Wed, 15 Mar 2023 09:29:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231401AbjCON3d (ORCPT ); Wed, 15 Mar 2023 09:29:33 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06E2F2E0E1 for ; Wed, 15 Mar 2023 06:29:31 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FC4r1h003779; Wed, 15 Mar 2023 13:29:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=kqO/erB5nXqTQ0RjoPSaCQr0/FRemTLyjK0d8hnSdic=; b=gt66MyCuBpt/wusZ/ZGMPZ8S/BIDmgxJhhonMiJd8l9Dm/0s/S1T9LVLbOQzQcKfreJ0 /9ukw2KMPoHCnjtfHn0IIvL+Q5aSbQE6QT10fbWq2z36NYXLV2hEHPJ2IyTJKHT2F5cX quaqMXr9ONAlMAAEM2Qo5pMELtZ2TZXZ9bpLWbKa5+6pHwTsXhQ+MJzbH3PsLofqPRyK /j9xuLXql1shijv+mvmWje8WvhO0CQl7pTf93gSr78QRZI1mKpVtey76HGu9Cdq5XeVH fqnBHpcqaR8MWcnzP9E0rA3+impdbyCUqGGx1fCCMZjB1diMXBSKuKebJpXplpCWsFhp LA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pb2c2sm0k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:27 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32FDTQpR028926 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:26 GMT 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.41; Wed, 15 Mar 2023 06:29:25 -0700 From: Aditya Kumar Singh To: CC: , Aditya Kumar Singh Subject: [PATCH v3 3/9] wifi: mac80211: add combined power type definition for 6 GHz Date: Wed, 15 Mar 2023 18:58:58 +0530 Message-ID: <20230315132904.31779-4-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230315132904.31779-1-quic_adisi@quicinc.com> References: <20230315132904.31779-1-quic_adisi@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) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: t4TXh6W0_JPeICtTJ2LHxYwpQ6R-i_mb X-Proofpoint-ORIG-GUID: t4TXh6W0_JPeICtTJ2LHxYwpQ6R-i_mb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_06,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 priorityscore=1501 lowpriorityscore=0 malwarescore=0 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 clxscore=1015 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150114 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 d64481d8d871..7bc9ff9c3f36 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -6065,6 +6065,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 844d2000b4e1..eddccd491fc9 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -4075,6 +4075,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_PWR_MODE_AP_SP: Low Power Indoor (Access Point) + * @NL80211_REG_PWR_MODE_AP_SP: Standard Power (Access Point) + * @NL80211_REG_PWR_MODE_AP_VLP: Very Low Power (Access Point) + * @NL80211_REG_PWR_MODE_REGULAR_CLIENT_LPI: Low Power Indoor (Regular + * or Default Client) + * @NL80211_REG_PWR_MODE_REGULAR_CLIENT_SP: Standard Power (Regular + * or Default Client) + * @NL80211_REG_PWR_MODE_REGULAR_CLIENT_VLP: Very Low Power (Regular + * or Default Client) + * @NL80211_REG_PWR_MODE_SUBORDINATE_CLIENT_LPI: Low Power Indoor + * (Subordinate Client) + * @NL80211_REG_PWR_MODE_SUBORDINATE_CLIENT_SP: Standard Power + * (Subordinate Client) + * @NL80211_REG_PWR_MODE_SUBORDINATE_CLIENT_VLP: Very Low Power + * (Subordinate Client) + * @__NL80211_REG_PWR_MODE_LAST: Internal use + * @NL80211_REG_PWR_MODE_MAX: Max supported number of power + * modes + */ +enum nl80211_regulatory_power_modes { + NL80211_REG_PWR_MODE_AP_LPI, + NL80211_REG_PWR_MODE_AP_SP, + NL80211_REG_PWR_MODE_AP_VLP, + NL80211_REG_PWR_MODE_REGULAR_CLIENT_LPI, + NL80211_REG_PWR_MODE_REGULAR_CLIENT_SP, + NL80211_REG_PWR_MODE_REGULAR_CLIENT_VLP, + NL80211_REG_PWR_MODE_SUBORDINATE_CLIENT_LPI, + NL80211_REG_PWR_MODE_SUBORDINATE_CLIENT_SP, + NL80211_REG_PWR_MODE_SUBORDINATE_CLIENT_VLP, + + /* keep last */ + __NL80211_REG_PWR_MODE_LAST, + NL80211_REG_PWR_MODE_MAX = __NL80211_REG_PWR_MODE_LAST, +}; + /** * enum nl80211_wmm_rule - regulatory wmm rule * diff --git a/net/wireless/util.c b/net/wireless/util.c index d1a89e82ead0..56a23e5797f4 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_PWR_MODE_AP_LPI; + case IEEE80211_REG_SP_AP: + return NL80211_REG_PWR_MODE_AP_SP; + case IEEE80211_REG_VLP_AP: + return NL80211_REG_PWR_MODE_AP_VLP; + default: + return NL80211_REG_PWR_MODE_MAX; + } +} +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_PWR_MODE_REGULAR_CLIENT_LPI; + case IEEE80211_REG_SP_AP: + return NL80211_REG_PWR_MODE_REGULAR_CLIENT_SP; + case IEEE80211_REG_VLP_AP: + return NL80211_REG_PWR_MODE_REGULAR_CLIENT_VLP; + default: + return NL80211_REG_PWR_MODE_MAX; + } + case IEEE80211_REG_SUBORDINATE_CLIENT: + switch (ap_type) { + case IEEE80211_REG_LPI_AP: + return NL80211_REG_PWR_MODE_SUBORDINATE_CLIENT_LPI; + case IEEE80211_REG_SP_AP: + return NL80211_REG_PWR_MODE_SUBORDINATE_CLIENT_SP; + case IEEE80211_REG_VLP_AP: + return NL80211_REG_PWR_MODE_SUBORDINATE_CLIENT_VLP; + default: + return NL80211_REG_PWR_MODE_MAX; + } + default: + return NL80211_REG_PWR_MODE_MAX; + } +} +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 Wed Mar 15 13:28:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Kumar Singh X-Patchwork-Id: 664515 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 4AC56C7618A for ; Wed, 15 Mar 2023 13:29:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232081AbjCON3h (ORCPT ); Wed, 15 Mar 2023 09:29:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231993AbjCON3e (ORCPT ); Wed, 15 Mar 2023 09:29:34 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDD8B8A393 for ; Wed, 15 Mar 2023 06:29:32 -0700 (PDT) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FAMMQ0011262; Wed, 15 Mar 2023 13:29:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=I8rwVTOOSK+Lnr6Kakn0cBE0/dyTUJG/gx/+vxsbcgQ=; b=XZImzfhrya1tzC3I2Bz/k8rR5BjDn2bgeG5Vbn45NjcJevsvqpSinTStE05zce7f7t0K 4Mj5zdJOkaUUcsEHo5/J03DdmQRrrFAxy3oyP9fGTF4RV88QXQZ4lAW8Ze/GVQ6jEQNY FsDiMGT/ooel6hAkFo6H3hpblYKsu3yDW86+g4Wyyqx9VYHd7P7HpePUT+Y2TIGWTdeA K6Feu6R834nEsc9KjOoh+jPNMi89t7Bf2E5RjIykJE6LLxrK8n/Whfbre278aHCY4S9u orwZIEqC6bbEQ99Mvx1cPvCOPhlgRcb015/OJzjQ9IUV59CWE1hKldRaUx7wCKNl85wW jA== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pb2cr1nvr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:29 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32FDTSq3018233 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:28 GMT 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.41; Wed, 15 Mar 2023 06:29:27 -0700 From: Aditya Kumar Singh To: CC: , Aditya Kumar Singh Subject: [PATCH v3 4/9] wifi: cfg80211: add NL command to set 6 GHz power mode Date: Wed, 15 Mar 2023 18:58:59 +0530 Message-ID: <20230315132904.31779-5-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230315132904.31779-1-quic_adisi@quicinc.com> References: <20230315132904.31779-1-quic_adisi@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) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: KMsELZ4p07IlJOpowfBX7aYC3SbkCSGE X-Proofpoint-GUID: KMsELZ4p07IlJOpowfBX7aYC3SbkCSGE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_06,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 malwarescore=0 phishscore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150114 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 6 GHz introduces various power modes for access points and for clients. When user configures these power modes, currently cfg80211 does not have support to store the configured power mode. Add support to store the 6 GHz configured power mode in the structure wireless_dev via a new NL command - NL80211_CMD_SET_6GHZ_POWER_MODE. The above command uses a new NL attributes to set power mode for AP and client interfaces - NL80211_ATTR_6GHZ_REG_POWER_MODE. Signed-off-by: Aditya Kumar Singh --- include/net/cfg80211.h | 6 +++- include/uapi/linux/nl80211.h | 10 ++++++ net/wireless/ap.c | 2 ++ net/wireless/nl80211.c | 66 +++++++++++++++++++++++++++++++++++- net/wireless/sme.c | 2 ++ 5 files changed, 84 insertions(+), 2 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 7bc9ff9c3f36..d8d78141bab6 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5805,7 +5805,8 @@ static inline void wiphy_unlock(struct wiphy *wiphy) * @unprot_beacon_reported: (private) timestamp of last * unprotected beacon report * @links: array of %IEEE80211_MLD_MAX_NUM_LINKS elements containing @addr - * @ap and @client for each link + * @ap and @client for each link. If link is 6 GHz link then uses + * @reg_6ghz_pwr_configured as well. * @valid_links: bitmap describing what elements of @links are valid */ struct wireless_dev { @@ -5914,11 +5915,14 @@ struct wireless_dev { struct { unsigned int beacon_interval; struct cfg80211_chan_def chandef; + enum ieee80211_ap_reg_power power_mode_6ghz; } ap; struct { struct cfg80211_internal_bss *current_bss; + enum ieee80211_client_reg_power power_mode_6ghz; } client; }; + bool reg_6ghz_pwr_configured; } links[IEEE80211_MLD_MAX_NUM_LINKS]; u16 valid_links; }; diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index eddccd491fc9..bff81489fa8a 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -1309,6 +1309,8 @@ * The number of peers that HW timestamping can be enabled for concurrently * is indicated by %NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS. * + * @NL80211_CMD_SET_6GHZ_POWER_MODE: Set 6 GHz power mode for the interface + * * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */ @@ -1562,6 +1564,8 @@ enum nl80211_commands { NL80211_CMD_SET_HW_TIMESTAMP, + NL80211_CMD_SET_6GHZ_POWER_MODE, + /* add new commands above here */ /* used to define NL80211_CMD_MAX below */ @@ -2786,6 +2790,10 @@ enum nl80211_commands { * bit corresponds to the lowest 20 MHz channel. Each bit set to 1 * indicates that the sub-channel is punctured. Higher 16 bits are * reserved. + * @NL80211_ATTR_6GHZ_REG_POWER_MODE: Regulatory power mode for 6 GHz operation. + * This can be used for both AP and clients. Values are defined in + * &enum ieee80211_ap_reg_power and &enum ieee80211_client_reg_power. + * Therefore, iftype should be taken into consideration. u8 value. * * @NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS: Maximum number of peers that HW * timestamping can be enabled for concurrently (u16), a wiphy attribute. @@ -3328,6 +3336,8 @@ enum nl80211_attrs { NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS, NL80211_ATTR_HW_TIMESTAMP_ENABLED, + NL80211_ATTR_6GHZ_REG_POWER_MODE, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, diff --git a/net/wireless/ap.c b/net/wireless/ap.c index 0962770303b2..b8e2d9466434 100644 --- a/net/wireless/ap.c +++ b/net/wireless/ap.c @@ -30,6 +30,8 @@ static int ___cfg80211_stop_ap(struct cfg80211_registered_device *rdev, if (!wdev->links[link_id].ap.beacon_interval) return -ENOENT; + wdev->links[link_id].reg_6ghz_pwr_configured = false; + err = rdev_stop_ap(rdev, dev, link_id); if (!err) { wdev->conn_owner_nlportid = 0; diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 1e8fe560078f..36cb4574145c 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -809,6 +809,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { [NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS] = { .type = NLA_U16 }, [NL80211_ATTR_HW_TIMESTAMP_ENABLED] = { .type = NLA_FLAG }, + [NL80211_ATTR_6GHZ_REG_POWER_MODE] = { .type = NLA_U8 }, }; /* policy for the key attributes */ @@ -16213,6 +16214,61 @@ static int nl80211_set_hw_timestamp(struct sk_buff *skb, return rdev_set_hw_timestamp(rdev, dev, &hwts); } +static bool nl80211_6ghz_power_mode_is_valid(enum nl80211_iftype iftype, + u8 power_mode) +{ + /* For APs, referenced from enum ieee80211_ap_reg_power, and + * For clients, referenced from enum ieee80211_client_reg_power + */ + switch (iftype) { + case NL80211_IFTYPE_AP: + return ((power_mode >= IEEE80211_REG_LPI_AP) && + (power_mode <= IEEE80211_REG_AP_POWER_MAX)); + case NL80211_IFTYPE_STATION: + return ((power_mode >= IEEE80211_REG_DEFAULT_CLIENT) && + (power_mode <= IEEE80211_REG_CLIENT_POWER_MAX)); + default: + return false; + } +} + +static int nl80211_set_6ghz_power_mode(struct sk_buff *skb, + struct genl_info *info) +{ + struct net_device *netdev = info->user_ptr[1]; + struct wireless_dev *wdev = netdev->ieee80211_ptr; + enum nl80211_iftype iftype = wdev->iftype; + unsigned int link_id = nl80211_link_id(info->attrs); + u8 power_mode; + + if (iftype != NL80211_IFTYPE_AP && + iftype != NL80211_IFTYPE_STATION) + return -EOPNOTSUPP; + + if (!info->attrs[NL80211_ATTR_6GHZ_REG_POWER_MODE]) + return -EINVAL; + + power_mode = nla_get_u8(info->attrs[NL80211_ATTR_6GHZ_REG_POWER_MODE]); + if (!nl80211_6ghz_power_mode_is_valid(iftype, power_mode)) + return -EINVAL; + + wdev_lock(wdev); + if (wdev->links[link_id].reg_6ghz_pwr_configured) { + wdev_unlock(wdev); + return -EALREADY; + } + + if (iftype == NL80211_IFTYPE_AP) + wdev->links[link_id].ap.power_mode_6ghz = power_mode; + else + wdev->links[link_id].client.power_mode_6ghz = power_mode; + + wdev->links[link_id].reg_6ghz_pwr_configured = true; + + wdev_unlock(wdev); + return 0; +} + #define NL80211_FLAG_NEED_WIPHY 0x01 #define NL80211_FLAG_NEED_NETDEV 0x02 #define NL80211_FLAG_NEED_RTNL 0x04 @@ -17393,6 +17449,14 @@ static const struct genl_small_ops nl80211_small_ops[] = { .flags = GENL_UNS_ADMIN_PERM, .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP), }, + { + .cmd = NL80211_CMD_SET_6GHZ_POWER_MODE, + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .doit = nl80211_set_6ghz_power_mode, + .flags = GENL_UNS_ADMIN_PERM, + .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV | + NL80211_FLAG_MLO_VALID_LINK_ID), + }, }; static struct genl_family nl80211_fam __ro_after_init = { @@ -17409,7 +17473,7 @@ static struct genl_family nl80211_fam __ro_after_init = { .n_ops = ARRAY_SIZE(nl80211_ops), .small_ops = nl80211_small_ops, .n_small_ops = ARRAY_SIZE(nl80211_small_ops), - .resv_start_op = NL80211_CMD_REMOVE_LINK_STA + 1, + .resv_start_op = NL80211_CMD_SET_6GHZ_POWER_MODE + 1, .mcgrps = nl80211_mcgrps, .n_mcgrps = ARRAY_SIZE(nl80211_mcgrps), .parallel_ops = true, diff --git a/net/wireless/sme.c b/net/wireless/sme.c index 28ce13840a88..5ccc371fdfaf 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c @@ -1558,6 +1558,8 @@ int cfg80211_disconnect(struct cfg80211_registered_device *rdev, if (!wdev->connected) wdev->u.client.ssid_len = 0; + wdev->links[0].reg_6ghz_pwr_configured = false; + return err; } From patchwork Wed Mar 15 13:29:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Kumar Singh X-Patchwork-Id: 664002 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 D98B3C61DA4 for ; Wed, 15 Mar 2023 13:29:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232109AbjCON3l (ORCPT ); Wed, 15 Mar 2023 09:29:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232005AbjCON3h (ORCPT ); Wed, 15 Mar 2023 09:29:37 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 934AB7280 for ; Wed, 15 Mar 2023 06:29:34 -0700 (PDT) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FCoUIe002631; Wed, 15 Mar 2023 13:29:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=SdclsZLWQSbZgChifUPbYLVn0iNzw/yF9D3DEQ9DctE=; b=gV6Upw9gvIzpj1RtWVz+uRxNYq0xouU2rVstJkB3eEilaMgGblPVkteT6cE73bo+vGkT WeJdXjK+nAnOCLLDq9C6V1rVBO8bJbipz5N5gi4HC0QI4UrfqbDCPFBzVkZFucE6ocpt qN3TB5HilYRiSheRw96d2FG1hl6kNYg2Z1yHd/VYp/IxmhFx+nXULLbUiYkaoGSD4jmR JNp8eVL01B0MeHhrO7u4gQ6Svh1809KFCOI5KeyHBhgy8A1Q2AXHqO+ROP79MNdyEkUq tp5oDP76ZoEMrZ6WZqDUH027WcFs6ablyxF8Z+ysOgmulCbWEs03Zbc4MqKSjJxYXbuZ Rw== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pbeceg3t9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:31 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32FDTUOD029367 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:30 GMT 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.41; Wed, 15 Mar 2023 06:29:28 -0700 From: Aditya Kumar Singh To: CC: , Aditya Kumar Singh Subject: [PATCH v3 5/9] wifi: mac80211: add support for 6 GHz channels and regulatory Date: Wed, 15 Mar 2023 18:59:00 +0530 Message-ID: <20230315132904.31779-6-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230315132904.31779-1-quic_adisi@quicinc.com> References: <20230315132904.31779-1-quic_adisi@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) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: lwhgDnOx1pNStPFF_SGgpIsou5W3sYCj X-Proofpoint-GUID: lwhgDnOx1pNStPFF_SGgpIsou5W3sYCj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_06,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 malwarescore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150114 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, 134 insertions(+), 9 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index d8d78141bab6..fa2c0551e3da 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_PWR_MODE_MAX]; struct ieee80211_rate *bitrates; enum nl80211_band band; int n_channels; @@ -6101,6 +6119,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 c2bf0b39fd1e..93402ccf366c 100644 --- a/include/net/regulatory.h +++ b/include/net/regulatory.h @@ -221,6 +221,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 1a28fe5cb614..9ddbc02571c1 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -3676,6 +3676,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; @@ -3718,6 +3721,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) { + reg_6ghz_ap_power = + sdata->wdev.links[bss_conf->link_id].ap.power_mode_6ghz; + reg_6ghz_power_final = + ieee80211_ap_reg_power_to_reg_power_mode(reg_6ghz_ap_power); + } else { + reg_6ghz_client_power = + sdata->wdev.links[bss_conf->link_id].client.power_mode_6ghz; + 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 @@ -3725,7 +3761,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 452e0085ed2c..c5bf3c9abdb1 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -1594,7 +1594,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; @@ -1608,7 +1609,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 @@ -1640,7 +1646,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_PWR_MODE_AP_LPI); if (!IS_ERR(reg_rule)) return reg_rule; } @@ -2292,7 +2299,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_PWR_MODE_AP_LPI); if (!IS_ERR(reg_rule)) flags = reg_rule->flags; @@ -2535,7 +2543,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; @@ -2544,7 +2553,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; } @@ -2596,11 +2605,29 @@ static void handle_band_custom(struct wiphy *wiphy, struct ieee80211_supported_band *sband, const struct ieee80211_regdomain *regd) { - unsigned int i; + unsigned int i, j; + bool channels_6ghz_present = false; if (!sband) return; + if (sband->band == NL80211_BAND_6GHZ) { + for (i = 0; i < NL80211_REG_PWR_MODE_MAX; i++) { + if (!sband->channels_6ghz[i]) + continue; + + channels_6ghz_present = 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 (channels_6ghz_present) + return; + } + /* * We currently assume that you always want at least 20 MHz, * otherwise channel 12 might get enabled if this rule is @@ -2608,7 +2635,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_PWR_MODE_AP_LPI); } /* Used by drivers prior to wiphy registration */ diff --git a/net/wireless/util.c b/net/wireless/util.c index 56a23e5797f4..266ce51b2f7b 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_PWR_MODE_MAX) + 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 Wed Mar 15 13:29:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Kumar Singh X-Patchwork-Id: 664514 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 C65EAC6FD1D for ; Wed, 15 Mar 2023 13:30:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232042AbjCON3p (ORCPT ); Wed, 15 Mar 2023 09:29:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231993AbjCON3j (ORCPT ); Wed, 15 Mar 2023 09:29:39 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDE3188ECB for ; Wed, 15 Mar 2023 06:29:36 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FALwjS010975; Wed, 15 Mar 2023 13:29:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=pqAWvxlqR0vpcGaNhENl63U35Eyf/xUYOLVNkQ6ttkU=; b=aQWPWa5FXDwscjZyNvEf/pbY70XEGxNpqvIbmkni0WmQvq0WlEVqwiYX11jIlORKb54B CyujWVnaZJI418rD9wrx20x/mQM4dN1JA6nTX61coa6MYXlLw33iDAjMVO+3G34q7n7B rW7ccoBPj8KM8BZ8kGZDUwmD5zFZOSGwunW8kBl5SdtuiaEG/ujdKUz6Z4LLVVwQstxJ b94/WbuLbbPQlCCMAw+l99Diphys/jGhWZITPn7dIzwrdMtrlmBTkGYzoJxbBL2IKPly gZOHnxUaonTOFk544AQr94MVV9xWj7WgLbO3gB3zxM2y4KsVnzmp75HGxQKyrl6rXBGK VQ== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pb2c2sm0v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:32 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32FDTWXr023757 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:32 GMT 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.41; Wed, 15 Mar 2023 06:29:30 -0700 From: Aditya Kumar Singh To: CC: , Aditya Kumar Singh Subject: [PATCH v3 6/9] wifi: cfg80211: rework nl80211_parse_chandef for 6 GHz Date: Wed, 15 Mar 2023 18:59:01 +0530 Message-ID: <20230315132904.31779-7-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230315132904.31779-1-quic_adisi@quicinc.com> References: <20230315132904.31779-1-quic_adisi@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) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: QaAj9NncjBFNCh9YIRqBy4_1R7XQESB1 X-Proofpoint-ORIG-GUID: QaAj9NncjBFNCh9YIRqBy4_1R7XQESB1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_06,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 priorityscore=1501 lowpriorityscore=0 malwarescore=0 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 clxscore=1015 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150114 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Currently, nl80211_parse_chandef function just selects a channel based on the control frequency provided. However, for 6 GHz, power mode also needs to be considered since 6 GHz has got multiple channel pools based on the power mode. Modify logic to consider power mode as well for 6 GHz interface and accordingly select the channel for the given control frequency. Signed-off-by: Aditya Kumar Singh --- include/net/cfg80211.h | 9 ++++++ net/mac80211/cfg.c | 41 +++++++++++++++++++++++++++ net/mac80211/ieee80211_i.h | 3 ++ net/wireless/nl80211.c | 57 ++++++++++++++++++++++++++------------ net/wireless/nl80211.h | 3 +- net/wireless/pmsr.c | 8 ++++-- net/wireless/rdev-ops.h | 21 ++++++++++++++ net/wireless/trace.h | 34 +++++++++++++++++++++++ 8 files changed, 155 insertions(+), 21 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index fa2c0551e3da..0120a520c58e 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -512,6 +512,10 @@ struct ieee80211_sta_s1g_cap { u8 nss_mcs[5]; }; +#define is_6ghz_freq_khz(freq) \ + (freq >= MHZ_TO_KHZ(5945) && freq <= MHZ_TO_KHZ(7125)) +#define is_6ghz_freq(freq) is_6ghz_freq_khz(MHZ_TO_KHZ(freq)) + /** * struct ieee80211_channel_6ghz - 6 GHz channel definitions * @@ -4367,6 +4371,8 @@ struct mgmt_frame_regs { * @del_link_station: Remove a link of a station. * * @set_hw_timestamp: Enable/disable HW timestamping of TM/FTM frames. + * + * @get_6ghz_power_mode: Get the 6 GHz power mode for the given interface. */ struct cfg80211_ops { int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); @@ -4722,6 +4728,9 @@ struct cfg80211_ops { struct link_station_del_parameters *params); int (*set_hw_timestamp)(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_set_hw_timestamp *hwts); + int (*get_6ghz_power_mode)(struct wireless_dev *wdev, + unsigned int link_id, + enum nl80211_regulatory_power_modes *power_mode); }; /* diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 760ad934f9e1..9af1e31bdc91 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -4947,6 +4947,46 @@ static int ieee80211_set_hw_timestamp(struct wiphy *wiphy, return local->ops->set_hw_timestamp(&local->hw, &sdata->vif, hwts); } +int +ieee80211_get_6ghz_power_mode(struct wireless_dev *wdev, + unsigned int link_id, + enum nl80211_regulatory_power_modes *power_mode_6ghz) +{ + enum nl80211_iftype iftype; + struct ieee80211_sub_if_data *sdata; + struct ieee80211_vif vif; + enum ieee80211_ap_reg_power power_mode_6ghz_ap; + enum ieee80211_client_reg_power power_mode_6ghz_client; + + if (!wdev) + return -EINVAL; + + iftype = wdev->iftype; + + /* For APs, 6 GHz power mode is taken from the user configured + * value. However, for clients, power mode is also dependent + * upon the APs power mode to which this client has associated. + * Hence for client, need to take power mode of associated AP, + * which is present in beacon data. + */ + if (iftype == NL80211_IFTYPE_AP) { + power_mode_6ghz_ap = wdev->links[link_id].ap.power_mode_6ghz; + *power_mode_6ghz = + ieee80211_ap_reg_power_to_reg_power_mode(power_mode_6ghz_ap); + } else if (iftype == NL80211_IFTYPE_STATION) { + sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); + vif = sdata->vif; + power_mode_6ghz_client = wdev->links[link_id].client.power_mode_6ghz; + *power_mode_6ghz = + ieee80211_client_reg_power_to_reg_power_mode(power_mode_6ghz_client, + vif.bss_conf.power_type); + } else { + *power_mode_6ghz = NL80211_REG_PWR_MODE_AP_LPI; + } + + return 0; +} + const struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface, @@ -5058,4 +5098,5 @@ const struct cfg80211_ops mac80211_config_ops = { .mod_link_station = ieee80211_mod_link_station, .del_link_station = ieee80211_del_link_station, .set_hw_timestamp = ieee80211_set_hw_timestamp, + .get_6ghz_power_mode = ieee80211_get_6ghz_power_mode, }; diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 3d4edc25a69e..1a82fc9c0f1f 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -2572,4 +2572,7 @@ ieee80211_eht_cap_ie_to_sta_eht_cap(struct ieee80211_sub_if_data *sdata, const struct ieee80211_eht_cap_elem *eht_cap_ie_elem, u8 eht_cap_len, struct link_sta_info *link_sta); +int ieee80211_get_6ghz_power_mode(struct wireless_dev *wdev, + unsigned int link_id, + enum nl80211_regulatory_power_modes *power_mode_6ghz); #endif /* IEEE80211_I_H */ diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 36cb4574145c..042035f26e9f 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -3208,10 +3208,13 @@ static int nl80211_parse_punct_bitmap(struct cfg80211_registered_device *rdev, int nl80211_parse_chandef(struct cfg80211_registered_device *rdev, struct genl_info *info, - struct cfg80211_chan_def *chandef) + struct cfg80211_chan_def *chandef, + struct wireless_dev *wdev) { struct netlink_ext_ack *extack = info->extack; struct nlattr **attrs = info->attrs; + enum nl80211_regulatory_power_modes power_mode_6ghz; + unsigned int link_id = nl80211_link_id(info->attrs); u32 control_freq; if (!attrs[NL80211_ATTR_WIPHY_FREQ]) { @@ -3227,7 +3230,23 @@ int nl80211_parse_chandef(struct cfg80211_registered_device *rdev, nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ_OFFSET]); memset(chandef, 0, sizeof(*chandef)); - chandef->chan = ieee80211_get_channel_khz(&rdev->wiphy, control_freq); + + if (is_6ghz_freq_khz(control_freq)) { + if (!wdev) + return -EINVAL; + + power_mode_6ghz = rdev_get_6ghz_power_mode(rdev, wdev, link_id); + + if (power_mode_6ghz >= NL80211_REG_PWR_MODE_MAX) + return -EINVAL; + + chandef->chan = ieee80211_get_6ghz_channel_khz(&rdev->wiphy, + control_freq, + power_mode_6ghz); + } else { + chandef->chan = ieee80211_get_channel_khz(&rdev->wiphy, control_freq); + } + chandef->width = NL80211_CHAN_WIDTH_20_NOHT; chandef->center_freq1 = KHZ_TO_MHZ(control_freq); chandef->freq1_offset = control_freq % 1000; @@ -3358,7 +3377,7 @@ static int __nl80211_set_channel(struct cfg80211_registered_device *rdev, link_id = 0; } - result = nl80211_parse_chandef(rdev, info, &chandef); + result = nl80211_parse_chandef(rdev, info, &chandef, wdev); if (result) return result; @@ -5976,7 +5995,8 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) } if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { - err = nl80211_parse_chandef(rdev, info, ¶ms->chandef); + err = nl80211_parse_chandef(rdev, info, ¶ms->chandef, + wdev); if (err) goto out; } else if (wdev->valid_links) { @@ -9865,7 +9885,7 @@ static int nl80211_start_radar_detection(struct sk_buff *skb, if (dfs_region == NL80211_DFS_UNSET) goto unlock; - err = nl80211_parse_chandef(rdev, info, &chandef); + err = nl80211_parse_chandef(rdev, info, &chandef, wdev); if (err) goto unlock; @@ -9945,7 +9965,7 @@ static int nl80211_notify_radar_detection(struct sk_buff *skb, return -EINVAL; } - err = nl80211_parse_chandef(rdev, info, &chandef); + err = nl80211_parse_chandef(rdev, info, &chandef, wdev); if (err) { GENL_SET_ERR_MSG(info, "Unable to extract chandef info"); return err; @@ -10143,7 +10163,7 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info) } skip_beacons: - err = nl80211_parse_chandef(rdev, info, ¶ms.chandef); + err = nl80211_parse_chandef(rdev, info, ¶ms.chandef, wdev); if (err) goto free; @@ -11236,6 +11256,7 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) struct cfg80211_ibss_params ibss; struct wiphy *wiphy; struct cfg80211_cached_keys *connkeys = NULL; + struct wireless_dev *wdev = dev->ieee80211_ptr; int err; memset(&ibss, 0, sizeof(ibss)); @@ -11258,7 +11279,7 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) if (!rdev->ops->join_ibss) return -EOPNOTSUPP; - if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC) + if (wdev->iftype != NL80211_IFTYPE_ADHOC) return -EOPNOTSUPP; wiphy = &rdev->wiphy; @@ -11277,7 +11298,7 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) ibss.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); } - err = nl80211_parse_chandef(rdev, info, &ibss.chandef); + err = nl80211_parse_chandef(rdev, info, &ibss.chandef, wdev); if (err) return err; @@ -11376,13 +11397,13 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) ibss.userspace_handles_dfs = nla_get_flag(info->attrs[NL80211_ATTR_HANDLE_DFS]); - wdev_lock(dev->ieee80211_ptr); + wdev_lock(wdev); err = __cfg80211_join_ibss(rdev, dev, &ibss, connkeys); if (err) kfree_sensitive(connkeys); else if (info->attrs[NL80211_ATTR_SOCKET_OWNER]) - dev->ieee80211_ptr->conn_owner_nlportid = info->snd_portid; - wdev_unlock(dev->ieee80211_ptr); + wdev->conn_owner_nlportid = info->snd_portid; + wdev_unlock(wdev); return err; } @@ -12248,7 +12269,7 @@ static int nl80211_remain_on_channel(struct sk_buff *skb, duration > rdev->wiphy.max_remain_on_channel_duration) return -EINVAL; - err = nl80211_parse_chandef(rdev, info, &chandef); + err = nl80211_parse_chandef(rdev, info, &chandef, wdev); if (err) return err; @@ -12470,7 +12491,7 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) */ chandef.chan = NULL; if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { - err = nl80211_parse_chandef(rdev, info, &chandef); + err = nl80211_parse_chandef(rdev, info, &chandef, wdev); if (err) return err; } @@ -12879,7 +12900,8 @@ static int nl80211_join_ocb(struct sk_buff *skb, struct genl_info *info) struct ocb_setup setup = {}; int err; - err = nl80211_parse_chandef(rdev, info, &setup.chandef); + err = nl80211_parse_chandef(rdev, info, &setup.chandef, + dev->ieee80211_ptr); if (err) return err; @@ -12954,7 +12976,8 @@ static int nl80211_join_mesh(struct sk_buff *skb, struct genl_info *info) cfg.auto_open_plinks = false; if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { - err = nl80211_parse_chandef(rdev, info, &setup.chandef); + err = nl80211_parse_chandef(rdev, info, &setup.chandef, + dev->ieee80211_ptr); if (err) return err; } else { @@ -15291,7 +15314,7 @@ static int nl80211_tdls_channel_switch(struct sk_buff *skb, !info->attrs[NL80211_ATTR_OPER_CLASS]) return -EINVAL; - err = nl80211_parse_chandef(rdev, info, &chandef); + err = nl80211_parse_chandef(rdev, info, &chandef, wdev); if (err) return err; diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h index 0278d817bb02..24966630ba27 100644 --- a/net/wireless/nl80211.h +++ b/net/wireless/nl80211.h @@ -24,7 +24,8 @@ static inline u64 wdev_id(struct wireless_dev *wdev) int nl80211_parse_chandef(struct cfg80211_registered_device *rdev, struct genl_info *info, - struct cfg80211_chan_def *chandef); + struct cfg80211_chan_def *chandef, + struct wireless_dev *wdev); int nl80211_parse_random_mac(struct nlattr **attrs, u8 *mac_addr, u8 *mac_addr_mask); diff --git a/net/wireless/pmsr.c b/net/wireless/pmsr.c index 2bc647720cda..501b8af547e1 100644 --- a/net/wireless/pmsr.c +++ b/net/wireless/pmsr.c @@ -184,7 +184,8 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev, static int pmsr_parse_peer(struct cfg80211_registered_device *rdev, struct nlattr *peer, struct cfg80211_pmsr_request_peer *out, - struct genl_info *info) + struct genl_info *info, + struct wireless_dev *wdev) { struct nlattr *tb[NL80211_PMSR_PEER_ATTR_MAX + 1]; struct nlattr *req[NL80211_PMSR_REQ_ATTR_MAX + 1]; @@ -213,7 +214,7 @@ static int pmsr_parse_peer(struct cfg80211_registered_device *rdev, if (err) return err; - err = nl80211_parse_chandef(rdev, info, &out->chandef); + err = nl80211_parse_chandef(rdev, info, &out->chandef, wdev); if (err) return err; @@ -316,7 +317,8 @@ int nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info) idx = 0; nla_for_each_nested(peer, peers, rem) { /* NB: this reuses info->attrs, but we no longer need it */ - err = pmsr_parse_peer(rdev, peer, &req->peers[idx], info); + err = pmsr_parse_peer(rdev, peer, &req->peers[idx], info, + wdev); if (err) goto out_err; idx++; diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h index 2e497cf26ef2..b2c8b92789cd 100644 --- a/net/wireless/rdev-ops.h +++ b/net/wireless/rdev-ops.h @@ -1511,4 +1511,25 @@ rdev_set_hw_timestamp(struct cfg80211_registered_device *rdev, return ret; } + +static inline enum nl80211_regulatory_power_modes +rdev_get_6ghz_power_mode(struct cfg80211_registered_device *rdev, + struct wireless_dev *wdev, + unsigned int link_id) +{ + enum nl80211_regulatory_power_modes power_mode_6ghz; + int ret; + + if (!rdev->ops->get_6ghz_power_mode) + return NL80211_REG_PWR_MODE_MAX; + + trace_rdev_get_6ghz_power_mode(&rdev->wiphy, wdev, link_id); + ret = rdev->ops->get_6ghz_power_mode(wdev, link_id, &power_mode_6ghz); + trace_rdev_return_6ghz_power_mode(wdev, ret, power_mode_6ghz); + + if (ret) + return NL80211_REG_PWR_MODE_MAX; + + return power_mode_6ghz; +} #endif /* __CFG80211_RDEV_OPS */ diff --git a/net/wireless/trace.h b/net/wireless/trace.h index 716a1fa70069..f9595f86fc08 100644 --- a/net/wireless/trace.h +++ b/net/wireless/trace.h @@ -3946,6 +3946,40 @@ TRACE_EVENT(rdev_set_hw_timestamp, __entry->enable) ); +TRACE_EVENT(rdev_get_6ghz_power_mode, + TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, + unsigned int link_id), + TP_ARGS(wiphy, wdev, link_id), + TP_STRUCT__entry( + WIPHY_ENTRY + WDEV_ENTRY + __field(u32, link_id) + ), + TP_fast_assign( + WIPHY_ASSIGN; + WDEV_ASSIGN; + __entry->link_id = params->link_id; + ), + TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT ", link_id: %u", + WIPHY_PR_ARG, WDEV_PR_ARG, __entry->link_id) +); + +TRACE_EVENT(rdev_return_6ghz_power_mode, + TP_PROTO(struct wireless_dev *wdev, int ret, u8 power_mode), + TP_ARGS(wdev, ret, power_mode), + TP_STRUCT__entry( + WDEV_ENTRY + __field(u8, ret) + __field(u8, power_mode) + ), + TP_fast_assign( + WDEV_ASSIGN; + __entry->ret = ret; + __entry->power_mode = power_mode; + ), + TP_printk(WDEV_PR_FMT ", ret: %d, power_mode: %d", + WDEV_PR_ARG, __entry->ret, __entry->power_mode) +); #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ #undef TRACE_INCLUDE_PATH From patchwork Wed Mar 15 13:29:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Kumar Singh X-Patchwork-Id: 664000 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 38C37C61DA4 for ; Wed, 15 Mar 2023 13:30:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232111AbjCON3r (ORCPT ); Wed, 15 Mar 2023 09:29:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231401AbjCON3j (ORCPT ); Wed, 15 Mar 2023 09:29:39 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B73249E2 for ; Wed, 15 Mar 2023 06:29:38 -0700 (PDT) Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FBJflb002718; Wed, 15 Mar 2023 13:29:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=ULgVJs53tRi1qRu/AgX/Rh48jRvgAJYldVOmCCkZAoI=; b=MJ55dJ8issZ1zjZ26y5/DSioA+w5KfQ1rtTNNtIdjW+S6SG6KuF7hmXAH7XUi/MGwin5 n7Vr6nuIRt14A6yvUarjj+BsQ4ov0KtCEwH/uVpAB7kbt/8YgZEV14vmwPj4mRSXH6ln gHmmOarCGmYC96w/dqzJFhHfavEN/8Rh23f0ntS30B8IEtkJRxlElpYHwL2CZdgj3LUW 1WYMAvIBMTrXqcpigF/907keo7+KV5zjFzEIZM4kwRMiS8R8MBjDy+s+CujQPpSMngec CPVC+jKNLdQV7IkOt4L9ke0QNlXo6Zgt+yepyhNJJCkqj9GyNuUEMKSKlMGbhZxS6xUq Og== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pb2c89n5w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:35 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32FDTYjF023762 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:34 GMT 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.41; Wed, 15 Mar 2023 06:29:32 -0700 From: Aditya Kumar Singh To: CC: , Aditya Kumar Singh Subject: [PATCH v3 7/9] wifi: cfg80211: save 6 GHz power mode of the regulatory rules Date: Wed, 15 Mar 2023 18:59:02 +0530 Message-ID: <20230315132904.31779-8-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230315132904.31779-1-quic_adisi@quicinc.com> References: <20230315132904.31779-1-quic_adisi@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) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: miCXgJti9kzR1Tv3GMRUN9b0jam5hsYh X-Proofpoint-ORIG-GUID: miCXgJti9kzR1Tv3GMRUN9b0jam5hsYh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_06,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 lowpriorityscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150114 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 bff81489fa8a..aa0fcf98aab1 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -4358,6 +4358,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 @@ -4377,6 +4379,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 042035f26e9f..cdb26aac24d1 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -8481,6 +8481,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)) @@ -8660,6 +8667,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_PWR_MODE_AP_LPI, + NL80211_REG_PWR_MODE_MAX - 1), }; static int parse_reg_rule(struct nlattr *tb[], @@ -8707,6 +8718,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; } From patchwork Wed Mar 15 13:29:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Kumar Singh X-Patchwork-Id: 664001 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 215DEC7618A for ; Wed, 15 Mar 2023 13:30:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232157AbjCON3s (ORCPT ); Wed, 15 Mar 2023 09:29:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232008AbjCON3m (ORCPT ); Wed, 15 Mar 2023 09:29:42 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B2B98C81A for ; Wed, 15 Mar 2023 06:29:39 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FAMS3A012014; Wed, 15 Mar 2023 13:29:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=p6r2L/y+sHWOHtnO5ltvrBx6yVEp1zIcqMpxiPavqCg=; b=pSIoZg9WdJUQmvVYEUtAz64HXr75i/f7vmjZcqD15TV5gvaNIGLhaVtSukzXrbDm8sxi ndpz8GySR/uPufqvdw1XRiQSFRhwbpid40J0j99QdmVovO/Fx1u3IvrcGudV3tFlFjuV w/+FsSkmEVJHP2wCX3jytrFVqbv7mKPYwzIez8kytF8pDgC5CGyKb6wwR5viTgydO1s1 9WkYiOTD6fSrv0Xd72iqz4NQhbL4uvwV5hR+Tkie8uMi7JliKxc+v72d3jgC7om8F0VX RgHAgPChaQL0ZsgXrm3K5gvexVMlihIcRFIQ/XUQ7+xRcB60lA7qhz4zUJ5MLY6b9y2/ yw== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pb2cshp0k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:36 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32FDTZ3p000858 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:35 GMT 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.41; Wed, 15 Mar 2023 06:29:34 -0700 From: Aditya Kumar Singh To: CC: , Aditya Kumar Singh Subject: [PATCH v3 8/9] wifi: cfg80211: fix chandef identical logic for 6 GHz chandefs Date: Wed, 15 Mar 2023 18:59:03 +0530 Message-ID: <20230315132904.31779-9-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230315132904.31779-1-quic_adisi@quicinc.com> References: <20230315132904.31779-1-quic_adisi@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) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: D0M49tHd1OFa7vjKQ-j-TpSOkE2enAb8 X-Proofpoint-ORIG-GUID: D0M49tHd1OFa7vjKQ-j-TpSOkE2enAb8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_06,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=971 impostorscore=0 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 priorityscore=1501 adultscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150114 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Currently, two chandefs are identical if they point to the same ieee80211_channel as well as other members of the chandef are same. However, with 6 GHz regulatory power modes changes, now 6 GHz channel can be picked from different channel pool and hence there can be a scenario where chandefs are actually idenatical but the channels are from a different pool (for example - AP-STA concurrency case). In this situation, the above logic will fail. Hence, for 6 GHz, instead of comparing the pointers, members inside ieee80211_channel can be compared and if they are same along with above condition then chandef can be assumed to be identical. Fix the same for 6 GHz channel comparison. Signed-off-by: Aditya Kumar Singh --- include/net/cfg80211.h | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 0120a520c58e..2f11b2451efe 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -903,6 +903,31 @@ void cfg80211_chandef_create(struct cfg80211_chan_def *chandef, struct ieee80211_channel *channel, enum nl80211_channel_type chantype); +/** + * cfg80211_6ghz_channel_identical - check if two 6 GHz channel definitions are + * identical + * @channel1: first channel definition + * @channel2: second channel definition + * + * Return: %true if the channels are identical except for the flags and power + * related settings, %false otherwise. + */ +static inline bool +cfg80211_6ghz_channel_identical(struct ieee80211_channel *channel1, + struct ieee80211_channel *channel2) +{ + if (!channel1 || !channel2) + return false; + + if (channel1->band == channel2->band && + channel1->band != NL80211_BAND_6GHZ) + return false; + + return (channel1->band == channel2->band && + channel1->center_freq == channel2->center_freq && + channel1->freq_offset == channel2->freq_offset); +} + /** * cfg80211_chandef_identical - check if two channel definitions are identical * @chandef1: first channel definition @@ -915,11 +940,17 @@ static inline bool cfg80211_chandef_identical(const struct cfg80211_chan_def *chandef1, const struct cfg80211_chan_def *chandef2) { - return (chandef1->chan == chandef2->chan && - chandef1->width == chandef2->width && - chandef1->center_freq1 == chandef2->center_freq1 && - chandef1->freq1_offset == chandef2->freq1_offset && - chandef1->center_freq2 == chandef2->center_freq2); + bool same_chan = chandef1->chan == chandef2->chan; + bool same_chand_def_prop = chandef1->width == chandef2->width && + chandef1->center_freq1 == chandef2->center_freq1 && + chandef1->freq1_offset == chandef2->freq1_offset && + chandef1->center_freq2 == chandef2->center_freq2; + + if (!same_chan) + same_chan = cfg80211_6ghz_channel_identical(chandef1->chan, + chandef2->chan); + + return (same_chan && same_chand_def_prop); } /** From patchwork Wed Mar 15 13:29:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Kumar Singh X-Patchwork-Id: 664513 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 D5D30C7619A for ; Wed, 15 Mar 2023 13:30:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231405AbjCONaJ (ORCPT ); Wed, 15 Mar 2023 09:30:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232005AbjCON3o (ORCPT ); Wed, 15 Mar 2023 09:29:44 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B96A90081 for ; Wed, 15 Mar 2023 06:29:41 -0700 (PDT) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FB2VXB001524; Wed, 15 Mar 2023 13:29:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=A5cwBDEQQaiZOiOcBwZZI5nDqXSOCEAJP3vBiw7Qijg=; b=TJ3GSG4dXfuDDdwvrLA2KhHVEMIPVDmr1qnT5wQwDS9M1/CbWLn7IwwfjM+wr2d4jhnI J03VNZWRVOEG6O83y7ukM3ygaesi8F1sCIwn3u2QsP+gHt1ceirpZxvpp3dQ4VmXqNc1 HvHURGx/V+v5phIHhyxmbrWwiRuxGwA0ZDIecF/la7q+Jb3Leavlrj5iMTpfLI84leA1 qXH8pnls/i21x4D3sg1am5/NUprRqY3FqXXOKSOupq/1jhbGtps1ClOBrgjLvvkEYhKY NS/3Mhx5onf9BTlaGdEUcvCYZxvaYwEKF8IDA8nCnnbhBqwJ4Gr58KQ+MAEe6KGc4zGS 2g== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pb2by9n2x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:38 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32FDTbOE023775 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 13:29:38 GMT 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.41; Wed, 15 Mar 2023 06:29:36 -0700 From: Aditya Kumar Singh To: CC: , Aditya Kumar Singh Subject: [PATCH v3 9/9] wifi: mac80211: use proper API to fetch 6 GHz channel Date: Wed, 15 Mar 2023 18:59:04 +0530 Message-ID: <20230315132904.31779-10-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230315132904.31779-1-quic_adisi@quicinc.com> References: <20230315132904.31779-1-quic_adisi@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) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: nxW6RTdx8xFKh_q8xOeMbz6taHjJ8Voj X-Proofpoint-GUID: nxW6RTdx8xFKh_q8xOeMbz6taHjJ8Voj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_06,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 suspectscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150114 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Commit "wifi: mac80211: add support for 6 GHz channels and regulatory" adds different channel pools for different power modes for 6 GHz channels. Currently, during MLME and association BSS handling, channel is fetched from older API ieee80211_get_channel_khz which will not consider the power mode for 6 GHz. Hence use proper API ieee80211_get_6ghz_channel_khz to fetch the 6 GHz channel. Signed-off-by: Aditya Kumar Singh --- net/mac80211/mlme.c | 14 ++++++++++++-- net/mac80211/scan.c | 15 +++++++++++++-- net/wireless/nl80211.c | 35 ++++++++++++++++++++++++++--------- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index e13a0354c397..7fc3f4af8202 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -5361,11 +5361,21 @@ static void ieee80211_rx_bss_info(struct ieee80211_link_data *link, struct ieee80211_local *local = sdata->local; struct ieee80211_bss *bss; struct ieee80211_channel *channel; + u32 rx_freq_khz = ieee80211_rx_status_to_khz(rx_status); + enum nl80211_regulatory_power_modes power_mode_6ghz; sdata_assert_lock(sdata); - channel = ieee80211_get_channel_khz(local->hw.wiphy, - ieee80211_rx_status_to_khz(rx_status)); + if (is_6ghz_freq_khz(rx_freq_khz)) { + ieee80211_get_6ghz_power_mode(&sdata->wdev, 0, + &power_mode_6ghz); + channel = ieee80211_get_6ghz_channel_khz(local->hw.wiphy, + rx_freq_khz, + power_mode_6ghz); + } else { + channel = ieee80211_get_channel_khz(local->hw.wiphy, + rx_freq_khz); + } if (!channel) return; diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 32fa8aca7005..bd5f73b06856 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -261,6 +261,8 @@ void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb) struct ieee80211_channel *channel; size_t min_hdr_len = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); + u32 rx_freq_khz = ieee80211_rx_status_to_khz(rx_status); + enum nl80211_regulatory_power_modes power_mode_6ghz; if (!ieee80211_is_probe_resp(mgmt->frame_control) && !ieee80211_is_beacon(mgmt->frame_control) && @@ -319,8 +321,17 @@ void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb) return; } - channel = ieee80211_get_channel_khz(local->hw.wiphy, - ieee80211_rx_status_to_khz(rx_status)); + if (is_6ghz_freq_khz(rx_freq_khz)) { + ieee80211_get_6ghz_power_mode(sdata1 ? &sdata1->wdev : &sdata2->wdev, + 0, &power_mode_6ghz); + + channel = ieee80211_get_6ghz_channel_khz(local->hw.wiphy, + rx_freq_khz, + power_mode_6ghz); + } else { + channel = ieee80211_get_channel_khz(local->hw.wiphy, + rx_freq_khz); + } if (!channel || channel->flags & IEEE80211_CHAN_DISABLED) return; diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index cdb26aac24d1..8d97a3e58015 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -1574,12 +1574,26 @@ static int nl80211_key_allowed(struct wireless_dev *wdev) return 0; } -static struct ieee80211_channel *nl80211_get_valid_chan(struct wiphy *wiphy, +static struct ieee80211_channel *nl80211_get_valid_chan(struct wireless_dev *wdev, + unsigned int link_id, u32 freq) { + struct wiphy *wiphy = wdev->wiphy; + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); struct ieee80211_channel *chan; + enum nl80211_regulatory_power_modes power_mode_6ghz; + + if (is_6ghz_freq_khz(freq)) { + power_mode_6ghz = rdev_get_6ghz_power_mode(rdev, wdev, link_id); + + if (power_mode_6ghz >= NL80211_REG_PWR_MODE_MAX) + return NULL; + + chan = ieee80211_get_6ghz_channel_khz(wiphy, freq, power_mode_6ghz); + } else { + chan = ieee80211_get_channel_khz(wiphy, freq); + } - chan = ieee80211_get_channel_khz(wiphy, freq); if (!chan || chan->flags & IEEE80211_CHAN_DISABLED) return NULL; return chan; @@ -10652,7 +10666,7 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) freq += nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ_OFFSET]); - chan = nl80211_get_valid_chan(&rdev->wiphy, freq); + chan = nl80211_get_valid_chan(dev->ieee80211_ptr, 0, freq); if (!chan) return -EINVAL; @@ -10861,6 +10875,8 @@ static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, } static struct cfg80211_bss *nl80211_assoc_bss(struct cfg80211_registered_device *rdev, + struct net_device *dev, + unsigned int link_id, const u8 *ssid, int ssid_len, struct nlattr **attrs, const u8 **bssid_out) @@ -10879,7 +10895,7 @@ static struct cfg80211_bss *nl80211_assoc_bss(struct cfg80211_registered_device if (attrs[NL80211_ATTR_WIPHY_FREQ_OFFSET]) freq += nla_get_u32(attrs[NL80211_ATTR_WIPHY_FREQ_OFFSET]); - chan = nl80211_get_valid_chan(&rdev->wiphy, freq); + chan = nl80211_get_valid_chan(dev->ieee80211_ptr, link_id, freq); if (!chan) return ERR_PTR(-EINVAL); @@ -11062,8 +11078,8 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) goto free; } req.links[link_id].bss = - nl80211_assoc_bss(rdev, ssid, ssid_len, attrs, - &bssid); + nl80211_assoc_bss(rdev, dev, link_id, ssid, ssid_len, + attrs, &bssid); if (IS_ERR(req.links[link_id].bss)) { err = PTR_ERR(req.links[link_id].bss); req.links[link_id].bss = NULL; @@ -11114,7 +11130,7 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) if (req.link_id >= 0) return -EINVAL; - req.bss = nl80211_assoc_bss(rdev, ssid, ssid_len, info->attrs, + req.bss = nl80211_assoc_bss(rdev, dev, 0, ssid, ssid_len, info->attrs, &bssid); if (IS_ERR(req.bss)) return PTR_ERR(req.bss); @@ -11813,13 +11829,14 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info) nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ_OFFSET]); if (freq) { - connect.channel = nl80211_get_valid_chan(wiphy, freq); + connect.channel = nl80211_get_valid_chan(dev->ieee80211_ptr, 0, freq); if (!connect.channel) return -EINVAL; } else if (info->attrs[NL80211_ATTR_WIPHY_FREQ_HINT]) { freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ_HINT]); freq = MHZ_TO_KHZ(freq); - connect.channel_hint = nl80211_get_valid_chan(wiphy, freq); + connect.channel_hint = nl80211_get_valid_chan(dev->ieee80211_ptr, 0, + freq); if (!connect.channel_hint) return -EINVAL; }