[PATCH ath-next 03/15] wifi: ath12k: add extended QMI WLAN cfg for CE and service pipes

From: Madhavan Ganesan

Date: Thu Nov 12 2026 - 03:43:13 EST


QMI_WLANFW_WLAN_CFG_REQ_V01 carries up to 12 CE entries and 24
service-to-CE mappings in its base arrays. QCN9575 requires 13 CE
pipes, one more than the base tgt_cfg array holds. The old code set
req->tgt_cfg_len to 13 and looped up to that count while filling
req->tgt_cfg[], writing one entry past the 12-element array into the
following svc_cfg_valid/svc_cfg_len fields before the request was ever
sent. qmi_send_request() then fails outright, since the QMI encoder
rejects a VAR_LEN_ARRAY whose length exceeds its declared elem_len
(12), so the WLAN config request never reaches firmware at all.

Firmware accepts overflow entries through ext_tgt_cfg (TLV 0x1A) and
ext_svc_cfg (TLV 0x1B) in the same WLAN config request. Add the
corresponding fields to qmi_wlanfw_wlan_cfg_req_msg_v01 and extend the
QMI element-info table to encode both TLVs, so service-to-CE mappings
can also overflow into the extended array if a future target requires
more than 24. When CE or service entries exceed the base array
limits, keep the first entries in the base arrays and place the
remainder in the extended arrays, clamped to their maximum sizes to
avoid out-of-bounds writes.

If the combined base and extended arrays still cannot hold all
configured entries, fail ath12k_qmi_wlanfw_wlan_cfg_send() with
-EINVAL up front, before any request is built or sent, rather than
silently dropping the extra entries. Update
QMI_WLANFW_WLAN_CFG_REQ_MSG_V01_MAX_LEN from 803 to 1835 to reflect
the larger message.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6-01243-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3

Signed-off-by: Madhavan Ganesan <madhavan.ganesan@xxxxxxxxxxxxxxxx>
---
drivers/net/wireless/ath/ath12k/qmi.c | 124 ++++++++++++++++++++++++++++++++--
drivers/net/wireless/ath/ath12k/qmi.h | 12 +++-
2 files changed, 131 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/qmi.c b/drivers/net/wireless/ath/ath12k/qmi.c
index 52a925fc44ee..69512b82aa3b 100644
--- a/drivers/net/wireless/ath/ath12k/qmi.c
+++ b/drivers/net/wireless/ath/ath12k/qmi.c
@@ -2018,6 +2018,62 @@ static const struct qmi_elem_info qmi_wlanfw_wlan_cfg_req_msg_v01_ei[] = {
shadow_reg_v3),
.ei_array = qmi_wlanfw_shadow_reg_v3_cfg_s_v01_ei,
},
+ {
+ .data_type = QMI_OPT_FLAG,
+ .elem_len = 1,
+ .elem_size = sizeof(u8),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x1A,
+ .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
+ ext_tgt_cfg_valid),
+ },
+ {
+ .data_type = QMI_DATA_LEN,
+ .elem_len = 1,
+ .elem_size = sizeof(u8),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x1A,
+ .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
+ ext_tgt_cfg_len),
+ },
+ {
+ .data_type = QMI_STRUCT,
+ .elem_len = QMI_WLANFW_MAX_EXT_NUM_CE_V01,
+ .elem_size = sizeof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01),
+ .array_type = VAR_LEN_ARRAY,
+ .tlv_type = 0x1A,
+ .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
+ ext_tgt_cfg),
+ .ei_array = qmi_wlanfw_ce_tgt_pipe_cfg_s_v01_ei,
+ },
+ {
+ .data_type = QMI_OPT_FLAG,
+ .elem_len = 1,
+ .elem_size = sizeof(u8),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x1B,
+ .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
+ ext_svc_cfg_valid),
+ },
+ {
+ .data_type = QMI_DATA_LEN,
+ .elem_len = 1,
+ .elem_size = sizeof(u8),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x1B,
+ .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
+ ext_svc_cfg_len),
+ },
+ {
+ .data_type = QMI_STRUCT,
+ .elem_len = QMI_WLANFW_MAX_EXT_NUM_SVC_V01,
+ .elem_size = sizeof(struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01),
+ .array_type = VAR_LEN_ARRAY,
+ .tlv_type = 0x1B,
+ .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
+ ext_svc_cfg),
+ .ei_array = qmi_wlanfw_ce_svc_pipe_cfg_s_v01_ei,
+ },
{
.data_type = QMI_EOTI,
.array_type = NO_ARRAY,
@@ -3537,10 +3593,28 @@ static int ath12k_qmi_wlanfw_wlan_cfg_send(struct ath12k_base *ab)
{
struct qmi_wlanfw_wlan_cfg_req_msg_v01 *req;
struct qmi_wlanfw_wlan_cfg_resp_msg_v01 resp = {};
+ int ret = 0, pipe_num, ext_pipe_num;
struct ce_pipe_config *ce_cfg;
struct service_to_pipe *svc_cfg;
struct qmi_txn txn;
- int ret = 0, pipe_num;
+
+ if (ab->qmi.ce_cfg.tgt_ce_len >
+ QMI_WLANFW_MAX_NUM_CE_V01 + QMI_WLANFW_MAX_EXT_NUM_CE_V01) {
+ ath12k_err(ab, "CE pipe config has %u entries, exceeds QMI capacity of %u\n",
+ ab->qmi.ce_cfg.tgt_ce_len,
+ QMI_WLANFW_MAX_NUM_CE_V01 +
+ QMI_WLANFW_MAX_EXT_NUM_CE_V01);
+ return -EINVAL;
+ }
+
+ if (ab->qmi.ce_cfg.svc_to_ce_map_len >
+ QMI_WLANFW_MAX_NUM_SVC_V01 + QMI_WLANFW_MAX_EXT_NUM_SVC_V01) {
+ ath12k_err(ab, "service map config has %u entries, exceeds QMI capacity of %u\n",
+ ab->qmi.ce_cfg.svc_to_ce_map_len,
+ QMI_WLANFW_MAX_NUM_SVC_V01 +
+ QMI_WLANFW_MAX_EXT_NUM_SVC_V01);
+ return -EINVAL;
+ }

ce_cfg = (struct ce_pipe_config *)ab->qmi.ce_cfg.tgt_ce;
svc_cfg = (struct service_to_pipe *)ab->qmi.ce_cfg.svc_to_ce_map;
@@ -3555,8 +3629,17 @@ static int ath12k_qmi_wlanfw_wlan_cfg_send(struct ath12k_base *ab)

req->tgt_cfg_valid = 1;
/* This is number of CE configs */
- req->tgt_cfg_len = ab->qmi.ce_cfg.tgt_ce_len;
- for (pipe_num = 0; pipe_num < req->tgt_cfg_len ; pipe_num++) {
+ req->tgt_cfg_len = min_t(u32, ab->qmi.ce_cfg.tgt_ce_len,
+ QMI_WLANFW_MAX_NUM_CE_V01);
+ if (ab->qmi.ce_cfg.tgt_ce_len > QMI_WLANFW_MAX_NUM_CE_V01) {
+ req->ext_tgt_cfg_valid = 1;
+ req->ext_tgt_cfg_len =
+ min_t(u32, ab->qmi.ce_cfg.tgt_ce_len -
+ QMI_WLANFW_MAX_NUM_CE_V01,
+ QMI_WLANFW_MAX_EXT_NUM_CE_V01);
+ }
+
+ for (pipe_num = 0; pipe_num < req->tgt_cfg_len; pipe_num++) {
req->tgt_cfg[pipe_num].pipe_num =
__le32_to_cpu(ce_cfg[pipe_num].pipenum);
req->tgt_cfg[pipe_num].pipe_dir =
@@ -3569,9 +3652,32 @@ static int ath12k_qmi_wlanfw_wlan_cfg_send(struct ath12k_base *ab)
__le32_to_cpu(ce_cfg[pipe_num].flags);
}

+ for (ext_pipe_num = 0; ext_pipe_num < req->ext_tgt_cfg_len; ext_pipe_num++) {
+ pipe_num = QMI_WLANFW_MAX_NUM_CE_V01 + ext_pipe_num;
+ req->ext_tgt_cfg[ext_pipe_num].pipe_num =
+ __le32_to_cpu(ce_cfg[pipe_num].pipenum);
+ req->ext_tgt_cfg[ext_pipe_num].pipe_dir =
+ __le32_to_cpu(ce_cfg[pipe_num].pipedir);
+ req->ext_tgt_cfg[ext_pipe_num].nentries =
+ __le32_to_cpu(ce_cfg[pipe_num].nentries);
+ req->ext_tgt_cfg[ext_pipe_num].nbytes_max =
+ __le32_to_cpu(ce_cfg[pipe_num].nbytes_max);
+ req->ext_tgt_cfg[ext_pipe_num].flags =
+ __le32_to_cpu(ce_cfg[pipe_num].flags);
+ }
+
req->svc_cfg_valid = 1;
/* This is number of Service/CE configs */
- req->svc_cfg_len = ab->qmi.ce_cfg.svc_to_ce_map_len;
+ req->svc_cfg_len = min_t(u32, ab->qmi.ce_cfg.svc_to_ce_map_len,
+ QMI_WLANFW_MAX_NUM_SVC_V01);
+ if (ab->qmi.ce_cfg.svc_to_ce_map_len > QMI_WLANFW_MAX_NUM_SVC_V01) {
+ req->ext_svc_cfg_valid = 1;
+ req->ext_svc_cfg_len =
+ min_t(u32, ab->qmi.ce_cfg.svc_to_ce_map_len -
+ QMI_WLANFW_MAX_NUM_SVC_V01,
+ QMI_WLANFW_MAX_EXT_NUM_SVC_V01);
+ }
+
for (pipe_num = 0; pipe_num < req->svc_cfg_len; pipe_num++) {
req->svc_cfg[pipe_num].service_id =
__le32_to_cpu(svc_cfg[pipe_num].service_id);
@@ -3581,6 +3687,16 @@ static int ath12k_qmi_wlanfw_wlan_cfg_send(struct ath12k_base *ab)
__le32_to_cpu(svc_cfg[pipe_num].pipenum);
}

+ for (ext_pipe_num = 0; ext_pipe_num < req->ext_svc_cfg_len; ext_pipe_num++) {
+ pipe_num = QMI_WLANFW_MAX_NUM_SVC_V01 + ext_pipe_num;
+ req->ext_svc_cfg[ext_pipe_num].service_id =
+ __le32_to_cpu(svc_cfg[pipe_num].service_id);
+ req->ext_svc_cfg[ext_pipe_num].pipe_dir =
+ __le32_to_cpu(svc_cfg[pipe_num].pipedir);
+ req->ext_svc_cfg[ext_pipe_num].pipe_num =
+ __le32_to_cpu(svc_cfg[pipe_num].pipenum);
+ }
+
/* set shadow v3 configuration */
if (ab->hw_params->supports_shadow_regs) {
req->shadow_reg_v3_valid = 1;
diff --git a/drivers/net/wireless/ath/ath12k/qmi.h b/drivers/net/wireless/ath/ath12k/qmi.h
index ed024084cac2..7879f439a5ff 100644
--- a/drivers/net/wireless/ath/ath12k/qmi.h
+++ b/drivers/net/wireless/ath/ath12k/qmi.h
@@ -544,7 +544,7 @@ struct qmi_wlanfw_aux_uc_info_resp_msg_v01 {
};

#define QMI_WLANFW_WLAN_MODE_REQ_MSG_V01_MAX_LEN 11
-#define QMI_WLANFW_WLAN_CFG_REQ_MSG_V01_MAX_LEN 803
+#define QMI_WLANFW_WLAN_CFG_REQ_MSG_V01_MAX_LEN 1835
#define QMI_WLANFW_WLAN_MODE_REQ_V01 0x0022
#define QMI_WLANFW_WLAN_CFG_REQ_V01 0x0023
#define QMI_WLANFW_MAX_STR_LEN_V01 16
@@ -552,6 +552,8 @@ struct qmi_wlanfw_aux_uc_info_resp_msg_v01 {
#define QMI_WLANFW_MAX_NUM_SVC_V01 24
#define QMI_WLANFW_MAX_NUM_SHADOW_REG_V01 24
#define QMI_WLANFW_MAX_NUM_SHADOW_REG_V3_V01 60
+#define QMI_WLANFW_MAX_EXT_NUM_CE_V01 32
+#define QMI_WLANFW_MAX_EXT_NUM_SVC_V01 32

struct qmi_wlanfw_wlan_mode_req_msg_v01 {
u32 mode;
@@ -582,6 +584,14 @@ struct qmi_wlanfw_wlan_cfg_req_msg_v01 {
u32 shadow_reg_v3_len;
struct qmi_wlanfw_shadow_reg_v3_cfg_s_v01
shadow_reg_v3[QMI_WLANFW_MAX_NUM_SHADOW_REG_V3_V01];
+ u8 ext_tgt_cfg_valid;
+ u32 ext_tgt_cfg_len;
+ struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01
+ ext_tgt_cfg[QMI_WLANFW_MAX_EXT_NUM_CE_V01];
+ u8 ext_svc_cfg_valid;
+ u32 ext_svc_cfg_len;
+ struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01
+ ext_svc_cfg[QMI_WLANFW_MAX_EXT_NUM_SVC_V01];
};

struct qmi_wlanfw_wlan_cfg_resp_msg_v01 {

--
2.34.1