wifi: ath12k: refactor transmitted arvif retrieval
authorAloka Dixit <aloka.dixit@oss.qualcomm.com>
Mon, 10 Feb 2025 18:27:16 +0000 (10:27 -0800)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Fri, 28 Feb 2025 19:53:13 +0000 (11:53 -0800)
Create a new function ath12k_mac_get_tx_arvif() to retrieve 'arvif'
for the transmitted interface of the MBSSID set. This clean up will
help modifying the same code path for MLO changes.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1

Signed-off-by: Aloka Dixit <aloka.dixit@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Link: https://patch.msgid.link/20250210182718.408891-4-aloka.dixit@oss.qualcomm.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/mac.c

index 3e3afdc56fc968f9901fcd6302be2a90f3d1f874..2de9a9b003a62afb4f608587507e5abace200f3b 100644 (file)
@@ -580,6 +580,19 @@ static int ath12k_mac_vif_link_chan(struct ieee80211_vif *vif, u8 link_id,
        return 0;
 }
 
+static struct ath12k_link_vif *ath12k_mac_get_tx_arvif(struct ath12k_link_vif *arvif)
+{
+       struct ath12k_vif *tx_ahvif;
+
+       if (arvif->ahvif->vif->mbssid_tx_vif) {
+               tx_ahvif = ath12k_vif_to_ahvif(arvif->ahvif->vif->mbssid_tx_vif);
+               if (tx_ahvif)
+                       return &tx_ahvif->deflink;
+       }
+
+       return NULL;
+}
+
 struct ieee80211_bss_conf *
 ath12k_mac_get_link_bss_conf(struct ath12k_link_vif *arvif)
 {
@@ -1638,7 +1651,6 @@ static int ath12k_mac_setup_bcn_tmpl_ema(struct ath12k_link_vif *arvif)
        struct ieee80211_ema_beacons *beacons;
        struct ath12k_link_vif *tx_arvif;
        bool nontx_profile_found = false;
-       struct ath12k_vif *tx_ahvif;
        int ret = 0;
        u8 i;
 
@@ -1650,10 +1662,9 @@ static int ath12k_mac_setup_bcn_tmpl_ema(struct ath12k_link_vif *arvif)
                return -ENOLINK;
        }
 
-       tx_ahvif = ath12k_vif_to_ahvif(ahvif->vif->mbssid_tx_vif);
-       tx_arvif = &tx_ahvif->deflink;
+       tx_arvif = ath12k_mac_get_tx_arvif(arvif);
        beacons = ieee80211_beacon_get_template_ema_list(ath12k_ar_to_hw(tx_arvif->ar),
-                                                        tx_ahvif->vif,
+                                                        tx_arvif->ahvif->vif,
                                                         tx_arvif->link_id);
        if (!beacons || !beacons->cnt) {
                ath12k_warn(arvif->ar->ab,
@@ -1696,11 +1707,10 @@ static int ath12k_mac_setup_bcn_tmpl(struct ath12k_link_vif *arvif)
        struct ath12k_vif *ahvif = arvif->ahvif;
        struct ieee80211_vif *vif = ath12k_ahvif_to_vif(ahvif);
        struct ieee80211_bss_conf *link_conf;
-       struct ath12k_link_vif *tx_arvif = arvif;
+       struct ath12k_link_vif *tx_arvif;
        struct ath12k *ar = arvif->ar;
        struct ath12k_base *ab = ar->ab;
        struct ieee80211_mutable_offsets offs = {};
-       struct ath12k_vif *tx_ahvif = ahvif;
        bool nontx_profile_found = false;
        struct sk_buff *bcn;
        int ret;
@@ -1715,17 +1725,19 @@ static int ath12k_mac_setup_bcn_tmpl(struct ath12k_link_vif *arvif)
                return -ENOLINK;
        }
 
-       if (vif->mbssid_tx_vif) {
-               tx_ahvif = ath12k_vif_to_ahvif(vif->mbssid_tx_vif);
-               tx_arvif = &tx_ahvif->deflink;
+       tx_arvif = ath12k_mac_get_tx_arvif(arvif);
+       if (tx_arvif) {
                if (tx_arvif != arvif && arvif->is_up)
                        return 0;
 
                if (link_conf->ema_ap)
                        return ath12k_mac_setup_bcn_tmpl_ema(arvif);
+       } else {
+               tx_arvif = arvif;
        }
 
-       bcn = ieee80211_beacon_get_template(ath12k_ar_to_hw(tx_arvif->ar), tx_ahvif->vif,
+       bcn = ieee80211_beacon_get_template(ath12k_ar_to_hw(tx_arvif->ar),
+                                           tx_arvif->ahvif->vif,
                                            &offs, tx_arvif->link_id);
        if (!bcn) {
                ath12k_warn(ab, "failed to get beacon template from mac80211\n");
@@ -1782,6 +1794,7 @@ static void ath12k_control_beaconing(struct ath12k_link_vif *arvif,
 {
        struct ath12k_wmi_vdev_up_params params = {};
        struct ath12k_vif *ahvif = arvif->ahvif;
+       struct ath12k_link_vif *tx_arvif;
        struct ath12k *ar = arvif->ar;
        int ret;
 
@@ -1812,11 +1825,9 @@ static void ath12k_control_beaconing(struct ath12k_link_vif *arvif,
        params.vdev_id = arvif->vdev_id;
        params.aid = ahvif->aid;
        params.bssid = arvif->bssid;
-       if (ahvif->vif->mbssid_tx_vif) {
-               struct ath12k_vif *tx_ahvif =
-                       ath12k_vif_to_ahvif(ahvif->vif->mbssid_tx_vif);
-               struct ath12k_link_vif *tx_arvif = &tx_ahvif->deflink;
 
+       tx_arvif = ath12k_mac_get_tx_arvif(arvif);
+       if (tx_arvif) {
                params.tx_bssid = tx_arvif->bssid;
                params.nontx_profile_idx = info->bssid_index;
                params.nontx_profile_cnt = 1 << info->bssid_indicator;
@@ -7841,14 +7852,9 @@ static int ath12k_mac_setup_vdev_params_mbssid(struct ath12k_link_vif *arvif,
                                               u32 *flags, u32 *tx_vdev_id)
 {
        struct ath12k_vif *ahvif = arvif->ahvif;
-       struct ieee80211_vif *tx_vif = ahvif->vif->mbssid_tx_vif;
        struct ieee80211_bss_conf *link_conf;
        struct ath12k *ar = arvif->ar;
        struct ath12k_link_vif *tx_arvif;
-       struct ath12k_vif *tx_ahvif;
-
-       if (!tx_vif)
-               return 0;
 
        link_conf = ath12k_mac_get_link_bss_conf(arvif);
        if (!link_conf) {
@@ -7857,11 +7863,13 @@ static int ath12k_mac_setup_vdev_params_mbssid(struct ath12k_link_vif *arvif,
                return -ENOLINK;
        }
 
-       tx_ahvif = ath12k_vif_to_ahvif(tx_vif);
-       tx_arvif = &tx_ahvif->deflink;
+       tx_arvif = ath12k_mac_get_tx_arvif(arvif);
+       if (!tx_arvif)
+               return 0;
 
        if (link_conf->nontransmitted) {
-               if (ar->ah->hw->wiphy != ieee80211_vif_to_wdev(tx_vif)->wiphy)
+               if (ath12k_ar_to_hw(ar)->wiphy !=
+                   ath12k_ar_to_hw(tx_arvif->ar)->wiphy)
                        return -EINVAL;
 
                *flags = WMI_VDEV_MBSSID_FLAGS_NON_TRANSMIT_AP;
@@ -9238,9 +9246,9 @@ ath12k_mac_update_vif_chan(struct ath12k *ar,
                           int n_vifs)
 {
        struct ath12k_wmi_vdev_up_params params = {};
+       struct ath12k_link_vif *arvif, *tx_arvif;
        struct ieee80211_bss_conf *link_conf;
        struct ath12k_base *ab = ar->ab;
-       struct ath12k_link_vif *arvif;
        struct ieee80211_vif *vif;
        struct ath12k_vif *ahvif;
        u8 link_id;
@@ -9308,11 +9316,9 @@ ath12k_mac_update_vif_chan(struct ath12k *ar,
                params.vdev_id = arvif->vdev_id;
                params.aid = ahvif->aid;
                params.bssid = arvif->bssid;
-               if (vif->mbssid_tx_vif) {
-                       struct ath12k_vif *tx_ahvif =
-                               ath12k_vif_to_ahvif(vif->mbssid_tx_vif);
-                       struct ath12k_link_vif *tx_arvif = &tx_ahvif->deflink;
 
+               tx_arvif = ath12k_mac_get_tx_arvif(arvif);
+               if (tx_arvif) {
                        params.tx_bssid = tx_arvif->bssid;
                        params.nontx_profile_idx = link_conf->bssid_index;
                        params.nontx_profile_cnt = 1 << link_conf->bssid_indicator;