]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: ath12k: add ath12k_ab_to_ah() and ath12k_ab_set_ah()
authorKarthikeyan Periyasamy <quic_periyasa@quicinc.com>
Fri, 29 Nov 2024 11:20:33 +0000 (13:20 +0200)
committerKalle Valo <quic_kvalo@quicinc.com>
Sat, 30 Nov 2024 12:10:36 +0000 (14:10 +0200)
Currently, one or more ath12k_hw is part of a device (struct ath12k_base) but
in future, it would be part of device group abstraction (struct
ath12k_hw_group), i.e., when multiple radios (ar) across different devices can
be combined together in a device group (struct ath12k_hw_group).

In order to facilitate the above transition, introduce helpers
ath12k_ab_to_ah() and ath12k_ab_set_ah() to get and set values of ath12k_hw
respectively.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Karthikeyan Periyasamy <quic_periyasa@quicinc.com>
Signed-off-by: Harshitha Prem <quic_hprem@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://patch.msgid.link/20241128165026.2618331-3-kvalo@kernel.org
drivers/net/wireless/ath/ath12k/core.c
drivers/net/wireless/ath/ath12k/core.h
drivers/net/wireless/ath/ath12k/mac.c

index 5313b026730715f96481c5441f3a5aafa3626cd6..14d0aa26d850a95715aa51ebdac9cbef4107a5c3 100644 (file)
@@ -986,7 +986,7 @@ static void ath12k_rfkill_work(struct work_struct *work)
        spin_unlock_bh(&ab->base_lock);
 
        for (i = 0; i < ab->num_hw; i++) {
-               ah = ab->ah[i];
+               ah = ath12k_ab_to_ah(ab, i);
                if (!ah)
                        continue;
 
@@ -1038,7 +1038,7 @@ static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab)
                set_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags);
 
        for (i = 0; i < ab->num_hw; i++) {
-               ah = ab->ah[i];
+               ah = ath12k_ab_to_ah(ab, i);
                if (!ah || ah->state == ATH12K_HW_STATE_OFF)
                        continue;
 
@@ -1077,7 +1077,7 @@ static void ath12k_core_post_reconfigure_recovery(struct ath12k_base *ab)
        int i, j;
 
        for (i = 0; i < ab->num_hw; i++) {
-               ah = ab->ah[i];
+               ah = ath12k_ab_to_ah(ab, i);
                if (!ah || ah->state == ATH12K_HW_STATE_OFF)
                        continue;
 
@@ -1131,7 +1131,7 @@ static void ath12k_core_restart(struct work_struct *work)
 
        if (ab->is_reset) {
                for (i = 0; i < ab->num_hw; i++) {
-                       ah = ab->ah[i];
+                       ah = ath12k_ab_to_ah(ab, i);
                        ieee80211_restart_hw(ah->hw);
                }
        }
index f4a710d495846e3e48110ebe215495bb2f8d63ef..ba52be1cfd0f85eaf508752e14810fac9a3088e6 100644 (file)
@@ -1160,4 +1160,15 @@ static inline struct ieee80211_hw *ath12k_ar_to_hw(struct ath12k *ar)
 #define for_each_ar(ah, ar, index) \
        for ((index) = 0; ((index) < (ah)->num_radio && \
             ((ar) = &(ah)->radio[(index)])); (index)++)
+
+static inline struct ath12k_hw *ath12k_ab_to_ah(struct ath12k_base *ab, int idx)
+{
+       return ab->ah[idx];
+}
+
+static inline void ath12k_ab_set_ah(struct ath12k_base *ab, int idx,
+                                   struct ath12k_hw *ah)
+{
+       ab->ah[idx] = ah;
+}
 #endif /* _CORE_H_ */
index 8d42077078676e5198fd8491e17700b6ba386640..8cafb67523c9846b0ff923397b4fb1cd340e99f6 100644 (file)
@@ -10832,7 +10832,7 @@ int ath12k_mac_register(struct ath12k_base *ab)
        ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS)) - 1;
 
        for (i = 0; i < ab->num_hw; i++) {
-               ah = ab->ah[i];
+               ah = ath12k_ab_to_ah(ab, i);
 
                ret = ath12k_mac_hw_register(ah);
                if (ret)
@@ -10843,7 +10843,7 @@ int ath12k_mac_register(struct ath12k_base *ab)
 
 err:
        for (i = i - 1; i >= 0; i--) {
-               ah = ab->ah[i];
+               ah = ath12k_ab_to_ah(ab, i);
                if (!ah)
                        continue;
 
@@ -10859,7 +10859,7 @@ void ath12k_mac_unregister(struct ath12k_base *ab)
        int i;
 
        for (i = ab->num_hw - 1; i >= 0; i--) {
-               ah = ab->ah[i];
+               ah = ath12k_ab_to_ah(ab, i);
                if (!ah)
                        continue;
 
@@ -10917,6 +10917,7 @@ static struct ath12k_hw *ath12k_mac_hw_allocate(struct ath12k_base *ab,
 void ath12k_mac_destroy(struct ath12k_base *ab)
 {
        struct ath12k_pdev *pdev;
+       struct ath12k_hw *ah;
        int i;
 
        for (i = 0; i < ab->num_radios; i++) {
@@ -10928,11 +10929,12 @@ void ath12k_mac_destroy(struct ath12k_base *ab)
        }
 
        for (i = 0; i < ab->num_hw; i++) {
-               if (!ab->ah[i])
+               ah = ath12k_ab_to_ah(ab, i);
+               if (!ah)
                        continue;
 
-               ath12k_mac_hw_destroy(ab->ah[i]);
-               ab->ah[i] = NULL;
+               ath12k_mac_hw_destroy(ah);
+               ath12k_ab_set_ah(ab, i, NULL);
        }
 }
 
@@ -10965,7 +10967,7 @@ int ath12k_mac_allocate(struct ath12k_base *ab)
 
                ah->dev = ab->dev;
 
-               ab->ah[i] = ah;
+               ath12k_ab_set_ah(ab, i, ah);
        }
 
        ath12k_dp_pdev_pre_alloc(ab);
@@ -10974,11 +10976,12 @@ int ath12k_mac_allocate(struct ath12k_base *ab)
 
 err:
        for (i = i - 1; i >= 0; i--) {
-               if (!ab->ah[i])
+               ah = ath12k_ab_to_ah(ab, i);
+               if (!ah)
                        continue;
 
-               ath12k_mac_hw_destroy(ab->ah[i]);
-               ab->ah[i] = NULL;
+               ath12k_mac_hw_destroy(ah);
+               ath12k_ab_set_ah(ab, i, NULL);
        }
 
        return ret;