wifi: ath12k: handle scan link during vdev create
authorAditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Thu, 17 Apr 2025 05:49:13 +0000 (11:19 +0530)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Fri, 16 May 2025 17:34:15 +0000 (10:34 -0700)
For scanning purposes, the driver can use link ID 15 (scan link). A future
change will make non-ML interfaces to select the scan link. In this
scenario, arvif->link_id will be used to retrieve the link configuration in
ath12k_mac_vdev_create(). However, link ID 15 is not recognized as a valid
link ID in the upper kernel, which will result in a failure to fetch
link_conf and subsequently cause the scan to fail.

To avoid this issue, ensure link_conf is fetched only when the link ID is
within the valid range. Since link_conf cannot be retrieved using the scan
link, use vif->addr as the Ethernet address for creating the scan vdev.
This address will serve as the source address (address 2) in the probe
request frames during scanning. Additionally, use the automatic Tx power
value for the vdev. As this is a scan vdev, these values do not affect the
scan functionality.

Note that vif->addr will only be taken when a valid link_conf can not be
fetched. Otherwise, link_conf's address will be taken as address 2.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1

Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Link: https://patch.msgid.link/20250417-fix_scan_vdev_handling-v3-1-9ec42513d26b@oss.qualcomm.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/mac.c

index 59aa69ca1ae2937832004316a73c1b59945c9a24..de5fb7d9ed52827f924eec7bece91805c017bf86 100644 (file)
@@ -8328,7 +8328,7 @@ int ath12k_mac_vdev_create(struct ath12k *ar, struct ath12k_link_vif *arvif)
        struct ieee80211_vif *vif = ath12k_ahvif_to_vif(ahvif);
        struct ath12k_wmi_vdev_create_arg vdev_arg = {0};
        struct ath12k_wmi_peer_create_arg peer_param = {0};
-       struct ieee80211_bss_conf *link_conf;
+       struct ieee80211_bss_conf *link_conf = NULL;
        u32 param_id, param_value;
        u16 nss;
        int i;
@@ -8343,22 +8343,21 @@ int ath12k_mac_vdev_create(struct ath12k *ar, struct ath12k_link_vif *arvif)
        if (vif->type == NL80211_IFTYPE_MONITOR && ar->monitor_vdev_created)
                return -EINVAL;
 
-       /* If no link is active and scan vdev is requested
-        * use a default link conf for scan address purpose.
-        */
-       if (arvif->link_id == ATH12K_DEFAULT_SCAN_LINK && vif->valid_links)
-               link_id = ffs(vif->valid_links) - 1;
-       else
-               link_id = arvif->link_id;
+       link_id = arvif->link_id;
 
-       link_conf = wiphy_dereference(hw->wiphy, vif->link_conf[link_id]);
-       if (!link_conf) {
-               ath12k_warn(ar->ab, "unable to access bss link conf in vdev create for vif %pM link %u\n",
-                           vif->addr, arvif->link_id);
-               return -ENOLINK;
+       if (link_id < IEEE80211_MLD_MAX_NUM_LINKS) {
+               link_conf = wiphy_dereference(hw->wiphy, vif->link_conf[link_id]);
+               if (!link_conf) {
+                       ath12k_warn(ar->ab, "unable to access bss link conf in vdev create for vif %pM link %u\n",
+                                   vif->addr, arvif->link_id);
+                       return -ENOLINK;
+               }
        }
 
-       memcpy(arvif->bssid, link_conf->addr, ETH_ALEN);
+       if (link_conf)
+               memcpy(arvif->bssid, link_conf->addr, ETH_ALEN);
+       else
+               memcpy(arvif->bssid, vif->addr, ETH_ALEN);
 
        arvif->ar = ar;
        vdev_id = __ffs64(ab->free_vdev_map);
@@ -8513,7 +8512,11 @@ int ath12k_mac_vdev_create(struct ath12k *ar, struct ath12k_link_vif *arvif)
                break;
        }
 
-       arvif->txpower = link_conf->txpower;
+       if (link_conf)
+               arvif->txpower = link_conf->txpower;
+       else
+               arvif->txpower = NL80211_TX_POWER_AUTOMATIC;
+
        ret = ath12k_mac_txpower_recalc(ar);
        if (ret)
                goto err_peer_del;