wifi: ath11k: update proper pdev/vdev id for testmode command
authorVenkateswara Naralasetty <quic_vnaralas@quicinc.com>
Thu, 1 Jun 2023 14:32:14 +0000 (20:02 +0530)
committerKalle Valo <quic_kvalo@quicinc.com>
Fri, 9 Jun 2023 12:30:19 +0000 (15:30 +0300)
User can extend test mode command support to set vdev and pdev params
for debug purpose at run time by sending vdev/pdev param set command
through the testmode command interface.

Fill the proper pdev/vdev id in driver since, pdev/vdev id details may
not be available at user space. It will make sure that the proper
vdev/pdev ids are sent to firmware.

Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1

Signed-off-by: Venkateswara Naralasetty <quic_vnaralas@quicinc.com>
Signed-off-by: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20230601143214.13006-1-quic_rajkbhag@quicinc.com
drivers/net/wireless/ath/ath11k/testmode.c

index 3611b6ec39c6630ab82507375ea45c2e4f3b8661..8fc5cddb28bded48f2cc0949243171a83f0323eb 100644 (file)
@@ -297,13 +297,16 @@ err:
        return ret;
 }
 
-static int ath11k_tm_cmd_wmi(struct ath11k *ar, struct nlattr *tb[])
+static int ath11k_tm_cmd_wmi(struct ath11k *ar, struct nlattr *tb[],
+                            struct ieee80211_vif *vif)
 {
        struct ath11k_pdev_wmi *wmi = ar->wmi;
        struct sk_buff *skb;
+       struct ath11k_vif *arvif;
        u32 cmd_id, buf_len;
-       int ret;
+       int ret, tag;
        void *buf;
+       u32 *ptr;
 
        mutex_lock(&ar->conf_mutex);
 
@@ -327,6 +330,34 @@ static int ath11k_tm_cmd_wmi(struct ath11k *ar, struct nlattr *tb[])
 
        cmd_id = nla_get_u32(tb[ATH11K_TM_ATTR_WMI_CMDID]);
 
+       /* Make sure that the buffer length is long enough to
+        * hold TLV and pdev/vdev id.
+        */
+       if (buf_len < sizeof(struct wmi_tlv) + sizeof(u32)) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       ptr = buf;
+       tag = FIELD_GET(WMI_TLV_TAG, *ptr);
+
+       /* pdev/vdev id start after TLV header */
+       ptr++;
+
+       if (tag == WMI_TAG_PDEV_SET_PARAM_CMD)
+               *ptr = ar->pdev->pdev_id;
+
+       if (ar->ab->fw_mode != ATH11K_FIRMWARE_MODE_FTM &&
+           (tag == WMI_TAG_VDEV_SET_PARAM_CMD || tag == WMI_TAG_UNIT_TEST_CMD)) {
+               if (vif) {
+                       arvif = (struct ath11k_vif *)vif->drv_priv;
+                       *ptr = arvif->vdev_id;
+               } else {
+                       ret = -EINVAL;
+                       goto out;
+               }
+       }
+
        ath11k_dbg(ar->ab, ATH11K_DBG_TESTMODE,
                   "cmd wmi cmd_id %d buf length %d\n",
                   cmd_id, buf_len);
@@ -460,7 +491,7 @@ int ath11k_tm_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
        case ATH11K_TM_CMD_GET_VERSION:
                return ath11k_tm_cmd_get_version(ar, tb);
        case ATH11K_TM_CMD_WMI:
-               return ath11k_tm_cmd_wmi(ar, tb);
+               return ath11k_tm_cmd_wmi(ar, tb, vif);
        case ATH11K_TM_CMD_TESTMODE_START:
                return ath11k_tm_cmd_testmode_start(ar, tb);
        case ATH11K_TM_CMD_WMI_FTM: