Skip to contentSkip to conversation

wifi: ath12k: parse nested DBS/SBS capability TLVs

PATCH Superseded Jonathan Wolf 2 participants 3 messages Nov 18 Qualcomm ATH12K wireless driver

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: ath12k: parse nested DBS/SBS capability TLVs

The DBS/SBS capabilities in WMI_SERVICE_READY_EXT2_EVENTID are carried in a WMI_TAG_ARRAY_STRUCT containing nested TLVs. The array pointer therefore points to an inner TLV header, not directly to struct ath12k_wmi_dbs_or_sbs_cap_params.

Casting the array pointer to that structure reads hw_mode_id as sbs_lower_band_end_freq. On WCN7850 firmware advertising hardware mode 5 and a 5900 MHz cutoff, the driver consequently records 5 MHz as the cutoff. This produces invalid SBS ranges such as 4900-5 MHz and makes a 5/6 GHz MLO pair appear to occupy the same hardware MAC, triggering partner-link deactivation.

Iterate the nested capability TLVs with ath12k_wmi_tlv_iter() and reject unexpected tags and payloads shorter than the capability structure. Use the first record, matching the vendor host extractor, and leave the cutoff at zero when the array is empty. Only store the cutoff after the complete array has been validated. This leaves the existing hardware-mode and link-selection policy unchanged.

Tested this parser on a Steam Frame with WCN7850 hw2.0, applying the patch to Valve's matching 7.2 kernel source. MLO advertisement and radio-mapping diagnostics were enabled separately. The cutoff changed from 5 to 5900 MHz, the 5200/6135 MHz links mapped to separate MACs, and AP-side data counters increased on both links during traffic. No driver recovery or association loss was observed during the test. An unmodified upstream kernel was not boot-tested.

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

Tested-on: WCN7850 hw2.0 PCI WLAN.IOE_HMT.1.1-00018-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1

---
 drivers/net/wireless/ath/ath12k/wmi.c | 24 +++++++++++++++++++++---
 drivers/net/wireless/ath/ath12k/wmi.h |  1 +
 2 files changed, 22 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath12k/wmi.c +21 -3
index 75b259990..f43c9a359 100644
@@ -5781,11 +5781,25 @@ 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 **first = data;
+
+	if (tag != WMI_TAG_DBS_OR_SBS_CAP_EXT || len < sizeof(**first))
+		return -EPROTO;
+
+	if (!*first)
+		*first = ptr;
+
+	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;
+	const struct ath12k_wmi_dbs_or_sbs_cap_params *caps = NULL;
 	struct ath12k_wmi_pdev *wmi_handle = &ab->wmi_ab.wmi[0];
 	struct ath12k_wmi_svc_rdy_ext2_parse *parse = data;
 	int ret;
@@ -5840,9 +5854,13 @@ 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;
+			ret = ath12k_wmi_tlv_iter(ab, ptr, len,
+						  ath12k_wmi_tlv_dbs_sbs_caps, &caps);
+			if (ret)
+				return ret;
+
 			ab->wmi_ab.sbs_lower_band_end_freq =
-				__le32_to_cpu(dbs_or_sbs_caps->sbs_lower_band_end_freq);
+				caps ? le32_to_cpu(caps->sbs_lower_band_end_freq) : 0;
 
 			ath12k_dbg(ab, ATH12K_DBG_WMI, "sbs_lower_band_end_freq %u\n",
 				   ab->wmi_ab.sbs_lower_band_end_freq);
drivers/net/wireless/ath/ath12k/wmi.h +1 -0
index b508aa759..94bb6854b 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,
Signature · 1 line
2.56.0
#1 lore raw
Quoted 27 lines · Jonathan Wolf

The DBS/SBS capabilities in WMI_SERVICE_READY_EXT2_EVENTID are carried in a WMI_TAG_ARRAY_STRUCT containing nested TLVs. The array pointer therefore points to an inner TLV header, not directly to struct ath12k_wmi_dbs_or_sbs_cap_params.

Casting the array pointer to that structure reads hw_mode_id as sbs_lower_band_end_freq. On WCN7850 firmware advertising hardware mode 5 and a 5900 MHz cutoff, the driver consequently records 5 MHz as the cutoff. This produces invalid SBS ranges such as 4900-5 MHz and makes a 5/6 GHz MLO pair appear to occupy the same hardware MAC, triggering partner-link deactivation.

Iterate the nested capability TLVs with ath12k_wmi_tlv_iter() and reject unexpected tags and payloads shorter than the capability structure. Use the first record, matching the vendor host extractor, and leave the cutoff at zero when the array is empty. Only store the cutoff after the complete array has been validated. This leaves the existing hardware-mode and link-selection policy unchanged.

Tested this parser on a Steam Frame with WCN7850 hw2.0, applying the patch to Valve's matching 7.2 kernel source. MLO advertisement and radio-mapping diagnostics were enabled separately. The cutoff changed from 5 to 5900 MHz, the 5200/6135 MHz links mapped to separate MACs, and AP-side data counters increased on both links during traffic. No driver recovery or association loss was observed during the test. An unmodified upstream kernel was not boot-tested.

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

Tested-on: WCN7850 hw2.0 PCI WLAN.IOE_HMT.1.1-00018-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1

Tested-on: is not an official tag so we usually have it at a separate line before official tags:

<leave a blank line>
Tested-on:
<leave a blank line>
Fixes:
Link:
Signed-off-by:

Quoted 38 lines
---
 drivers/net/wireless/ath/ath12k/wmi.c | 24 +++++++++++++++++++++---
 drivers/net/wireless/ath/ath12k/wmi.h |  1 +
 2 files changed, 22 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath12k/wmi.c +15 -1
index 75b259990..f43c9a359 100644
@@ -5781,11 +5781,25 @@ 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 **first = data;
+
+	if (tag != WMI_TAG_DBS_OR_SBS_CAP_EXT || len < sizeof(**first))
+		return -EPROTO;
+
+	if (!*first)
+		*first = ptr;
+
+	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;
+	const struct ath12k_wmi_dbs_or_sbs_cap_params *caps = NULL;
 	struct ath12k_wmi_pdev *wmi_handle = &ab->wmi_ab.wmi[0];
 	struct ath12k_wmi_svc_rdy_ext2_parse *parse = data;
 	int ret;

drivers/net/wireless/ath/ath12k/wmi.c static int ath12k_wmi_svc_rdy_ext2_parse(struct ath12k_base *ab, · line 5860

Quoted 8 lines
drivers/net/wireless/ath/ath12k/wmi.c +4 -1
@@ -5840,9 +5854,13 @@ 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;
+			ret = ath12k_wmi_tlv_iter(ab, ptr, len,
+						  ath12k_wmi_tlv_dbs_sbs_caps, &caps);
+			if (ret)
+				return ret;

better to leave a warning before return

drivers/net/wireless/ath/ath12k/wmi.c static int ath12k_wmi_svc_rdy_ext2_parse(struct ath12k_base *ab, · line 5866

Quoted 7 lines
drivers/net/wireless/ath/ath12k/wmi.c +2 -1
+
 			ab->wmi_ab.sbs_lower_band_end_freq =
-				__le32_to_cpu(dbs_or_sbs_caps->sbs_lower_band_end_freq);
+				caps ? le32_to_cpu(caps->sbs_lower_band_end_freq) : 0;
 
 			ath12k_dbg(ab, ATH12K_DBG_WMI, "sbs_lower_band_end_freq %u\n",
 				   ab->wmi_ab.sbs_lower_band_end_freq);

to follow the convention, would be better to move the sbs_lower_band_end_freq cache and debug print into the parser as well

Quoted 12 lines
drivers/net/wireless/ath/ath12k/wmi.h +1 -0
index b508aa759..94bb6854b 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,
#2 lore raw

Thanks for the review, Baochen.

I’ve moved Tested-on above the official trailers and added a warning when parsing the DBS/SBS capabilities fails. I’ve also moved the cutoff assignment and debug print into the DBS/SBS parser helper so the driver only updates the cutoff after the full array validates.

I’ll retest on the Steam Frame and send v2.

Jonathan

Quoted 120 lines · Baochen Qiang
Quoted 27 lines · Jonathan Wolf

The DBS/SBS capabilities in WMI_SERVICE_READY_EXT2_EVENTID are carried in a WMI_TAG_ARRAY_STRUCT containing nested TLVs. The array pointer therefore points to an inner TLV header, not directly to struct ath12k_wmi_dbs_or_sbs_cap_params.

Casting the array pointer to that structure reads hw_mode_id as sbs_lower_band_end_freq. On WCN7850 firmware advertising hardware mode 5 and a 5900 MHz cutoff, the driver consequently records 5 MHz as the cutoff. This produces invalid SBS ranges such as 4900-5 MHz and makes a 5/6 GHz MLO pair appear to occupy the same hardware MAC, triggering partner-link deactivation.

Iterate the nested capability TLVs with ath12k_wmi_tlv_iter() and reject unexpected tags and payloads shorter than the capability structure. Use the first record, matching the vendor host extractor, and leave the cutoff at zero when the array is empty. Only store the cutoff after the complete array has been validated. This leaves the existing hardware-mode and link-selection policy unchanged.

Tested this parser on a Steam Frame with WCN7850 hw2.0, applying the patch to Valve's matching 7.2 kernel source. MLO advertisement and radio-mapping diagnostics were enabled separately. The cutoff changed from 5 to 5900 MHz, the 5200/6135 MHz links mapped to separate MACs, and AP-side data counters increased on both links during traffic. No driver recovery or association loss was observed during the test. An unmodified upstream kernel was not boot-tested.

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

Tested-on: WCN7850 hw2.0 PCI WLAN.IOE_HMT.1.1-00018-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1

Tested-on: is not an official tag so we usually have it at a separate line before official tags:

<leave a blank line>
Tested-on:
<leave a blank line>
Fixes:
Link:
Signed-off-by:

Quoted 38 lines
---
 drivers/net/wireless/ath/ath12k/wmi.c | 24 +++++++++++++++++++++---
 drivers/net/wireless/ath/ath12k/wmi.h |  1 +
 2 files changed, 22 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath12k/wmi.c +15 -1
index 75b259990..f43c9a359 100644
@@ -5781,11 +5781,25 @@ 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 **first = data;
+
+     if (tag != WMI_TAG_DBS_OR_SBS_CAP_EXT || len < sizeof(**first))
+             return -EPROTO;
+
+     if (!*first)
+             *first = ptr;
+
+     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;
+     const struct ath12k_wmi_dbs_or_sbs_cap_params *caps = NULL;
      struct ath12k_wmi_pdev *wmi_handle = &ab->wmi_ab.wmi[0];
      struct ath12k_wmi_svc_rdy_ext2_parse *parse = data;
      int ret;

drivers/net/wireless/ath/ath12k/wmi.c static int ath12k_wmi_svc_rdy_ext2_parse(struct ath12k_base *ab, · line 5860

Quoted 8 lines
drivers/net/wireless/ath/ath12k/wmi.c +4 -1
@@ -5840,9 +5854,13 @@ 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;
+                     ret = ath12k_wmi_tlv_iter(ab, ptr, len,
+                                               ath12k_wmi_tlv_dbs_sbs_caps, &caps);
+                     if (ret)
+                             return ret;

better to leave a warning before return

drivers/net/wireless/ath/ath12k/wmi.c static int ath12k_wmi_svc_rdy_ext2_parse(struct ath12k_base *ab, · line 5866

Quoted 7 lines
drivers/net/wireless/ath/ath12k/wmi.c +2 -1
+
                      ab->wmi_ab.sbs_lower_band_end_freq =
-                             __le32_to_cpu(dbs_or_sbs_caps->sbs_lower_band_end_freq);
+                             caps ? le32_to_cpu(caps->sbs_lower_band_end_freq) : 0;
 
                      ath12k_dbg(ab, ATH12K_DBG_WMI, "sbs_lower_band_end_freq %u\n",
                                 ab->wmi_ab.sbs_lower_band_end_freq);

to follow the convention, would be better to move the sbs_lower_band_end_freq cache and debug print into the parser as well

Quoted 12 lines
drivers/net/wireless/ath/ath12k/wmi.h +1 -0
index b508aa759..94bb6854b 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,