ATH11K Archive mirror
 help / color / mirror / Atom feed
From: Wen Gong <quic_wgong@quicinc.com>
To: <ath11k@lists.infradead.org>
Cc: <linux-wireless@vger.kernel.org>, <kvalo@kernel.org>,
	<quic_jjohnson@quicinc.com>, <quic_wgong@quicinc.com>
Subject: [PATCH v6 01/13] wifi: ath11k: add support to select 6 GHz regulatory type
Date: Wed, 20 Sep 2023 04:23:37 -0400	[thread overview]
Message-ID: <20230920082349.29111-2-quic_wgong@quicinc.com> (raw)
In-Reply-To: <20230920082349.29111-1-quic_wgong@quicinc.com>

There are 3 types of regulatory rules for AP mode and 6 type for
station mode. Add wmi_vdev_type and ieee80211_ap_reg_power to
select the exact reg rules.

Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23

Signed-off-by: Wen Gong <quic_wgong@quicinc.com>
---
 drivers/net/wireless/ath/ath11k/reg.c | 66 +++++++++++++++++++++------
 drivers/net/wireless/ath/ath11k/reg.h |  6 ++-
 drivers/net/wireless/ath/ath11k/wmi.c |  3 +-
 3 files changed, 58 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/reg.c b/drivers/net/wireless/ath/ath11k/reg.c
index 7f9fb968dac6..2a3edb60c08f 100644
--- a/drivers/net/wireless/ath/ath11k/reg.c
+++ b/drivers/net/wireless/ath/ath11k/reg.c
@@ -607,25 +607,64 @@ ath11k_reg_update_weather_radar_band(struct ath11k_base *ab,
 	*rule_idx = i;
 }
 
+enum wmi_reg_6ghz_ap_type
+ath11k_reg_ap_pwr_convert(enum ieee80211_ap_reg_power power_type)
+{
+	switch (power_type) {
+	case IEEE80211_REG_LPI_AP:
+		return WMI_REG_INDOOR_AP;
+	case IEEE80211_REG_SP_AP:
+		return WMI_REG_STANDARD_POWER_AP;
+	case IEEE80211_REG_VLP_AP:
+		return WMI_REG_VERY_LOW_POWER_AP;
+	default:
+		return WMI_REG_MAX_AP_TYPE;
+	}
+}
+
 struct ieee80211_regdomain *
 ath11k_reg_build_regd(struct ath11k_base *ab,
-		      struct cur_regulatory_info *reg_info, bool intersect)
+		      struct cur_regulatory_info *reg_info, bool intersect,
+		      enum wmi_vdev_type vdev_type,
+		      enum ieee80211_ap_reg_power power_type)
 {
 	struct ieee80211_regdomain *tmp_regd, *default_regd, *new_regd = NULL;
-	struct cur_reg_rule *reg_rule;
+	struct cur_reg_rule *reg_rule, *reg_rule_6ghz;
 	u8 i = 0, j = 0, k = 0;
 	u8 num_rules;
 	u16 max_bw;
-	u32 flags;
+	u32 flags, reg_6ghz_number, max_bw_6ghz;
 	char alpha2[3];
 
 	num_rules = reg_info->num_5ghz_reg_rules + reg_info->num_2ghz_reg_rules;
 
-	/* FIXME: Currently taking reg rules for 6 GHz only from Indoor AP mode list.
-	 * This can be updated after complete 6 GHz regulatory support is added.
-	 */
-	if (reg_info->is_ext_reg_event)
-		num_rules += reg_info->num_6ghz_rules_ap[WMI_REG_INDOOR_AP];
+	if (reg_info->is_ext_reg_event) {
+		if (vdev_type == WMI_VDEV_TYPE_STA) {
+			enum wmi_reg_6ghz_ap_type ap_type;
+
+			ap_type = ath11k_reg_ap_pwr_convert(power_type);
+
+			if (ap_type == WMI_REG_MAX_AP_TYPE)
+				ap_type = WMI_REG_INDOOR_AP;
+			reg_6ghz_number = reg_info->num_6ghz_rules_client
+					[ap_type][WMI_REG_DEFAULT_CLIENT];
+			if (reg_6ghz_number == 0) {
+				ap_type = WMI_REG_INDOOR_AP;
+				reg_6ghz_number = reg_info->num_6ghz_rules_client
+						[ap_type][WMI_REG_DEFAULT_CLIENT];
+			}
+			reg_rule_6ghz = reg_info->reg_rules_6ghz_client_ptr
+					[ap_type][WMI_REG_DEFAULT_CLIENT];
+			max_bw_6ghz = reg_info->max_bw_6ghz_client
+					[ap_type][WMI_REG_DEFAULT_CLIENT];
+		} else {
+			reg_6ghz_number = reg_info->num_6ghz_rules_ap[WMI_REG_INDOOR_AP];
+			reg_rule_6ghz =
+				reg_info->reg_rules_6ghz_ap_ptr[WMI_REG_INDOOR_AP];
+			max_bw_6ghz = reg_info->max_bw_6ghz_ap[WMI_REG_INDOOR_AP];
+		}
+		num_rules += reg_6ghz_number;
+	}
 
 	if (!num_rules)
 		goto ret;
@@ -672,13 +711,10 @@ ath11k_reg_build_regd(struct ath11k_base *ab,
 			 * per other BW rule flags we pass from here
 			 */
 			flags = NL80211_RRF_AUTO_BW;
-		} else if (reg_info->is_ext_reg_event &&
-			   reg_info->num_6ghz_rules_ap[WMI_REG_INDOOR_AP] &&
-			   (k < reg_info->num_6ghz_rules_ap[WMI_REG_INDOOR_AP])) {
-			reg_rule = reg_info->reg_rules_6ghz_ap_ptr[WMI_REG_INDOOR_AP] +
-				   k++;
-			max_bw = min_t(u16, reg_rule->max_bw,
-				       reg_info->max_bw_6ghz_ap[WMI_REG_INDOOR_AP]);
+		} else if (reg_info->is_ext_reg_event && reg_6ghz_number &&
+			   (k < reg_6ghz_number)) {
+			reg_rule = reg_rule_6ghz + k++;
+			max_bw = min_t(u16, reg_rule->max_bw, max_bw_6ghz);
 			flags = NL80211_RRF_AUTO_BW;
 		} else {
 			break;
diff --git a/drivers/net/wireless/ath/ath11k/reg.h b/drivers/net/wireless/ath/ath11k/reg.h
index 2f284f26378d..acc69ec15b6e 100644
--- a/drivers/net/wireless/ath/ath11k/reg.h
+++ b/drivers/net/wireless/ath/ath11k/reg.h
@@ -30,7 +30,11 @@ void ath11k_reg_free(struct ath11k_base *ab);
 void ath11k_regd_update_work(struct work_struct *work);
 struct ieee80211_regdomain *
 ath11k_reg_build_regd(struct ath11k_base *ab,
-		      struct cur_regulatory_info *reg_info, bool intersect);
+		      struct cur_regulatory_info *reg_info, bool intersect,
+		      enum wmi_vdev_type vdev_type,
+		      enum ieee80211_ap_reg_power power_type);
 int ath11k_regd_update(struct ath11k *ar);
 int ath11k_reg_update_chan_list(struct ath11k *ar, bool wait);
+enum wmi_reg_6ghz_ap_type
+ath11k_reg_ap_pwr_convert(enum ieee80211_ap_reg_power power_type);
 #endif
diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c
index 23ad6825e5be..5a6578865b25 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.c
+++ b/drivers/net/wireless/ath/ath11k/wmi.c
@@ -7150,7 +7150,8 @@ static int ath11k_reg_chan_list_event(struct ath11k_base *ab,
 	    !ath11k_reg_is_world_alpha((char *)reg_info->alpha2))
 		intersect = true;
 
-	regd = ath11k_reg_build_regd(ab, reg_info, intersect);
+	regd = ath11k_reg_build_regd(ab, reg_info, intersect,
+				     WMI_VDEV_TYPE_AP, IEEE80211_REG_LPI_AP);
 	if (!regd) {
 		ath11k_warn(ab, "failed to build regd from reg_info\n");
 		goto fallback;
-- 
2.40.1


-- 
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

  reply	other threads:[~2023-09-20  8:24 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-20  8:23 [PATCH v6 00/13] wifi: ath11k: add support for 6 GHz station for various modes : LPI, SP and VLP Wen Gong
2023-09-20  8:23 ` Wen Gong [this message]
2023-09-20  8:23 ` [PATCH v6 02/13] wifi: ath11k: store cur_regulatory_info for each radio Wen Gong
2023-09-21 19:51   ` Jeff Johnson
2023-09-29 13:16   ` Kalle Valo
2023-09-20  8:23 ` [PATCH v6 03/13] wifi: ath11k: fix a possible dead lock caused by ab->base_lock Wen Gong
2023-09-21 19:54   ` Jeff Johnson
2023-09-25 10:35     ` Kalle Valo
2023-10-02 15:51   ` Kalle Valo
2023-09-20  8:23 ` [PATCH v6 04/13] wifi: ath11k: update regulatory rules when interface added Wen Gong
2023-09-21 19:58   ` Jeff Johnson
2023-09-22  9:32   ` Aditya Kumar Singh
2023-09-20  8:23 ` [PATCH v6 05/13] wifi: ath11k: update regulatory rules when connect to AP on 6 GHz band for station Wen Gong
2023-09-21 19:59   ` Jeff Johnson
2023-09-22  9:39   ` Aditya Kumar Singh
2023-09-22 10:02     ` Wen Gong
2023-09-22 13:18       ` Aditya Kumar Singh
2023-09-25 10:43         ` Wen Gong
2023-09-25 10:52           ` Aditya Kumar Singh
2023-09-25 10:57             ` Wen Gong
2023-09-20  8:23 ` [PATCH v6 06/13] wifi: ath11k: save power spectral density(psd) of regulatory rule Wen Gong
2023-09-21 20:00   ` Jeff Johnson
2023-09-22  9:49   ` Aditya Kumar Singh
2023-09-20  8:23 ` [PATCH v6 07/13] wifi: ath11k: add parse of transmit power envelope element Wen Gong
2023-09-21 20:04   ` Jeff Johnson
2023-09-20  8:23 ` [PATCH v6 08/13] wifi: ath11k: save max tx power in vdev start response event from firmware Wen Gong
2023-09-21 20:04   ` Jeff Johnson
2023-09-20  8:23 ` [PATCH v6 09/13] wifi: ath11k: fill parameters for vdev set tpc power WMI command Wen Gong
2023-09-21 20:09   ` Jeff Johnson
2023-09-21 20:11   ` Jeff Johnson
2023-09-25 10:46     ` Wen Gong
2023-09-29 13:18   ` Kalle Valo
2023-09-20  8:23 ` [PATCH v6 10/13] wifi: ath11k: add WMI_TLV_SERVICE_EXT_TPC_REG_SUPPORT service bit Wen Gong
2023-09-21 20:13   ` Jeff Johnson
2023-09-20  8:23 ` [PATCH v6 11/13] wifi: ath11k: discard BSS_CHANGED_TXPOWER when EXT_TPC_REG_SUPPORT for 6 GHz Wen Gong
2023-09-21 20:39   ` Jeff Johnson
2023-09-22  9:04   ` Aditya Kumar Singh
2023-09-22  9:17     ` Wen Gong
2023-09-20  8:23 ` [PATCH v6 12/13] wifi: ath11k: add handler for WMI_VDEV_SET_TPC_POWER_CMDID Wen Gong
2023-09-21 20:37   ` Jeff Johnson
2023-09-20  8:23 ` [PATCH v6 13/13] wifi: ath11k: send TPC power to firmware for 6 GHz station Wen Gong
2023-09-21 20:38   ` Jeff Johnson
2023-09-22  9:24   ` Aditya Kumar Singh
2023-09-22 10:12     ` Wen Gong
2023-09-22 13:25       ` Aditya Kumar Singh
2023-09-25  2:15         ` Wen Gong
2023-09-25  5:41           ` Aditya Kumar Singh
2023-09-25 10:50             ` Wen Gong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230920082349.29111-2-quic_wgong@quicinc.com \
    --to=quic_wgong@quicinc.com \
    --cc=ath11k@lists.infradead.org \
    --cc=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=quic_jjohnson@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).