Skip to contentSkip to conversation

wifi: ath12k: parse the nested DBS/SBS capability TLV

PATCH In review Jonathan Wolf 2 participants 2 messages Nov 19 – Nov 20 Qualcomm ATH12K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 wifi: ath12k: parse the nested DBS/SBS capability TLV

The DBS/SBS capability in WMI_SERVICE_READY_EXT2_EVENTID is inside a WMI_TAG_ARRAY_STRUCT. The array payload starts with the inner TLV header. Casting that pointer to struct ath12k_wmi_dbs_or_sbs_cap_params makes ath12k read hw_mode_id as sbs_lower_band_end_freq.

On WCN7850 with hardware mode 5 and a 5900 MHz cutoff, this gives an SBS frequency range of 4900-5 MHz. The driver can then map the 5 GHz and 6 GHz links to the same MAC and request deactivation of one link.

Use ath12k_wmi_tlv_iter() to reach the capability payload. Check the tag and minimum payload length before converting the cutoff to CPU byte order. Clear the cached cutoff before parsing so an empty array leaves it at zero.

Fixes 241d130f1419 ("wifi: ath12k: parse and save sbs_lower_band_end_freq from WMI_SERVICE_READY_EXT2_EVENTID event")

---
Changes in v3:
- Follow Baochen's suggestion to decode and log the single capability in the iterator callback. Drop the first-record pointer and wrapper. Clear the cutoff before walking the array to handle an empty array.

Changes in v2:
- Warn on a nested parse error. Move the cutoff assignment and debug message into a helper and separate Tested-on from the trailers.

v2: https://lore.kernel.org/ath12k/[email protected]/
v1: https://lore.kernel.org/ath12k/[email protected]/

Built ath12k for arm64. A host test of the event parser reproduces the 5 MHz result on ath-current and gets 5900 MHz with v3. This revision has not yet been run on hardware.

 drivers/net/wireless/ath/ath12k/wmi.c | 32 +++++++++++++++++++++------
 drivers/net/wireless/ath/ath12k/wmi.h |  1 +
 2 files changed, 26 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath12k/wmi.c +25 -7
index 75b259990c..9b1de1ec06 100644
@@ -5781,11 +5781,27 @@ static int ath12k_wmi_update_hw_mode_list(struct ath12k_base *ab)
 	return 0;
 }
 
+static int ath12k_wmi_tlv_dbs_sbs_caps(struct ath12k_base *ab, u16 tag,
+				       u16 len, const void *ptr, void *data)
+{
+	const struct ath12k_wmi_dbs_or_sbs_cap_params *caps = ptr;
+
+	if (tag != WMI_TAG_DBS_OR_SBS_CAP_EXT || len < sizeof(*caps))
+		return -EPROTO;
+
+	ab->wmi_ab.sbs_lower_band_end_freq =
+		le32_to_cpu(caps->sbs_lower_band_end_freq);
+
+	ath12k_dbg(ab, ATH12K_DBG_WMI, "sbs_lower_band_end_freq %u\n",
+		   ab->wmi_ab.sbs_lower_band_end_freq);
+
+	return 0;
+}
+
 static int ath12k_wmi_svc_rdy_ext2_parse(struct ath12k_base *ab,
 					 u16 tag, u16 len,
 					 const void *ptr, void *data)
 {
-	const struct ath12k_wmi_dbs_or_sbs_cap_params *dbs_or_sbs_caps;
 	struct ath12k_wmi_pdev *wmi_handle = &ab->wmi_ab.wmi[0];
 	struct ath12k_wmi_svc_rdy_ext2_parse *parse = data;
 	int ret;
@@ -5840,12 +5856,14 @@ static int ath12k_wmi_svc_rdy_ext2_parse(struct ath12k_base *ab,
 		} else if (!parse->htt_msdu_idx_to_qtype_map_done) {
 			parse->htt_msdu_idx_to_qtype_map_done = true;
 		} else if (!parse->dbs_or_sbs_cap_ext_done) {
-			dbs_or_sbs_caps = ptr;
-			ab->wmi_ab.sbs_lower_band_end_freq =
-				__le32_to_cpu(dbs_or_sbs_caps->sbs_lower_band_end_freq);
-
-			ath12k_dbg(ab, ATH12K_DBG_WMI, "sbs_lower_band_end_freq %u\n",
-				   ab->wmi_ab.sbs_lower_band_end_freq);
+			ab->wmi_ab.sbs_lower_band_end_freq = 0;
+			ret = ath12k_wmi_tlv_iter(ab, ptr, len,
+						  ath12k_wmi_tlv_dbs_sbs_caps, NULL);
+			if (ret) {
+				ath12k_warn(ab, "failed to parse DBS/SBS capabilities WMI TLV: %d\n",
+					    ret);
+				return ret;
+			}
 
 			ret = ath12k_wmi_update_hw_mode_list(ab);
 			if (ret) {
drivers/net/wireless/ath/ath12k/wmi.h +1 -0
index b508aa759b..94bb6854b0 100644
@@ -2032,6 +2032,7 @@ enum wmi_tlv_tag {
 	WMI_TAG_PDEV_SET_BIOS_SAR_TABLE_CMD = 0x3D8,
 	WMI_TAG_PDEV_SET_BIOS_GEO_TABLE_CMD = 0x3D9,
 	WMI_TAG_PDEV_SET_BIOS_INTERFACE_CMD = 0x3FB,
+	WMI_TAG_DBS_OR_SBS_CAP_EXT = 0x400,
 	WMI_TAG_RSSI_DBM_CONVERSION_PARAMS_INFO_FIXED_PARAM = 0x427,
 	WMI_TAG_RSSI_DBM_CONVERSION_PARAMS_INFO,
 	WMI_TAG_RSSI_DBM_CONVERSION_TEMP_OFFSET_INFO,

base-commit: b1ed5a45b994a6473ca1cf34f35a1bf87f1d8e2a

Signature · 1 line
2.56.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 9 lines · Jonathan Wolf

The DBS/SBS capability in WMI_SERVICE_READY_EXT2_EVENTID is inside a WMI_TAG_ARRAY_STRUCT. The array payload starts with the inner TLV header. Casting that pointer to struct ath12k_wmi_dbs_or_sbs_cap_params makes ath12k read hw_mode_id as sbs_lower_band_end_freq.

On WCN7850 with hardware mode 5 and a 5900 MHz cutoff, this gives an SBS frequency range of 4900-5 MHz. The driver can then map the 5 GHz and 6 GHz links to the same MAC and request deactivation of one link.

Quoted 7 lines

Use ath12k_wmi_tlv_iter() to reach the capability payload. Check the tag and minimum payload length before converting the cutoff to CPU byte order. Clear the cached cutoff before parsing so an empty array leaves it at zero.

Fixes 241d130f1419 ("wifi: ath12k: parse and save sbs_lower_band_end_freq from WMI_SERVICE_READY_EXT2_EVENTID event")