]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: ath12k: Initialize hal_ops through hal_init
authorPavankumar Nandeshwar <quic_pnandesh@quicinc.com>
Thu, 9 Oct 2025 11:10:30 +0000 (16:40 +0530)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Fri, 10 Oct 2025 14:06:17 +0000 (07:06 -0700)
Modularize the HAL layer by moving hal_ops from ab->hw_params into the
ab->hal. This reduces indirection and allows data path to access HAL ops
directly through the HAL context.

Initialize hal_ops via hal_init using a const table ath12k_hw_version_map.
This approach will be extended to register other HAL parameters during
init.

Remove ab->hw_params->hal_ops as it is no longer needed.

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: Pavankumar Nandeshwar <quic_pnandesh@quicinc.com>
Signed-off-by: Ripan Deuri <quic_rdeuri@quicinc.com>
Reviewed-by: Baochen Qiang <baochen.qiang@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Link: https://patch.msgid.link/20251009111045.1763001-4-quic_rdeuri@quicinc.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
13 files changed:
drivers/net/wireless/ath/ath12k/ahb.c
drivers/net/wireless/ath/ath12k/dp.c
drivers/net/wireless/ath/ath12k/dp_mon.c
drivers/net/wireless/ath/ath12k/dp_rx.h
drivers/net/wireless/ath/ath12k/hal.c
drivers/net/wireless/ath/ath12k/hal.h
drivers/net/wireless/ath/ath12k/hw.h
drivers/net/wireless/ath/ath12k/wifi7/dp_rx.h
drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c
drivers/net/wireless/ath/ath12k/wifi7/hal.c
drivers/net/wireless/ath/ath12k/wifi7/hal_qcn9274.h
drivers/net/wireless/ath/ath12k/wifi7/hal_wcn7850.h
drivers/net/wireless/ath/ath12k/wifi7/hw.c

index 7eb8dedaa9474657b19ad66193ec4d37a276f741..2c991580571c0557640b420c8af8a99ad2331349 100644 (file)
@@ -563,7 +563,7 @@ static int ath12k_ahb_config_ext_irq(struct ath12k_base *ab)
        u32 num_irq;
 
        ring_mask = ab->hw_params->ring_mask;
-       hal_ops = ab->hw_params->hal_ops;
+       hal_ops = ab->hal.hal_ops;
        for (i = 0; i < ATH12K_EXT_IRQ_GRP_NUM_MAX; i++) {
                irq_grp = &ab->ext_irq_grp[i];
                num_irq = 0;
index 5b255e7c0deb3d965022635b997754cb12dde1d2..167878e9964cbabcc6e59875841cdab5d30ebca2 100644 (file)
@@ -142,7 +142,7 @@ static int ath12k_dp_srng_calculate_msi_group(struct ath12k_base *ab,
                        grp_mask = &ab->hw_params->ring_mask->rx_wbm_rel[0];
                        ring_num = 0;
                } else {
-                       map = ab->hw_params->hal_ops->tcl_to_wbm_rbm_map;
+                       map = ab->hal.hal_ops->tcl_to_wbm_rbm_map;
                        for (i = 0; i < ab->hw_params->max_tx_ring; i++) {
                                if (ring_num == map[i].wbm_ring_num) {
                                        ring_num = i;
@@ -508,7 +508,7 @@ static int ath12k_dp_srng_common_setup(struct ath12k_base *ab)
        }
 
        for (i = 0; i < ab->hw_params->max_tx_ring; i++) {
-               map = ab->hw_params->hal_ops->tcl_to_wbm_rbm_map;
+               map = ab->hal.hal_ops->tcl_to_wbm_rbm_map;
                tx_comp_ring_num = map[i].wbm_ring_num;
 
                ret = ath12k_dp_srng_setup(ab, &dp->tx_ring[i].tcl_data_ring,
index d2924fe46b4ffd1001a3f94cb067b32992d53e3c..89ba9ad4141745521a78e934fb0c4885309dd797 100644 (file)
@@ -2052,7 +2052,7 @@ ath12k_dp_mon_rx_merg_msdus(struct ath12k_pdev_dp *dp_pdev,
 
                rx_desc = (struct hal_rx_desc *)head_msdu->data;
                hdr_desc =
-                       ab->hw_params->hal_ops->rx_desc_get_msdu_payload(rx_desc);
+                       ab->hal.hal_ops->rx_desc_get_msdu_payload(rx_desc);
 
                /* Base size */
                wh = (struct ieee80211_hdr_3addr *)hdr_desc;
index 716623f83adcb5a09e156747cb851a28c6b74839..0ecb96bc9054451d5d1328a947e46112f1446aea 100644 (file)
@@ -109,27 +109,27 @@ static inline u16 ath12k_dp_rx_h_frag_no(struct ath12k_base *ab,
 static inline u8 ath12k_dp_rx_h_l3pad(struct ath12k_base *ab,
                                      struct hal_rx_desc *desc)
 {
-       return ab->hw_params->hal_ops->rx_desc_get_l3_pad_bytes(desc);
+       return ab->hal.hal_ops->rx_desc_get_l3_pad_bytes(desc);
 }
 
 static inline void ath12k_dp_rx_desc_end_tlv_copy(struct ath12k_base *ab,
                                                  struct hal_rx_desc *fdesc,
                                                  struct hal_rx_desc *ldesc)
 {
-       ab->hw_params->hal_ops->rx_desc_copy_end_tlv(fdesc, ldesc);
+       ab->hal.hal_ops->rx_desc_copy_end_tlv(fdesc, ldesc);
 }
 
 static inline void ath12k_dp_rxdesc_set_msdu_len(struct ath12k_base *ab,
                                                 struct hal_rx_desc *desc,
                                                 u16 len)
 {
-       ab->hw_params->hal_ops->rx_desc_set_msdu_len(desc, len);
+       ab->hal.hal_ops->rx_desc_set_msdu_len(desc, len);
 }
 
 static inline u32 ath12k_dp_rxdesc_get_ppduid(struct ath12k_base *ab,
                                              struct hal_rx_desc *rx_desc)
 {
-       return ab->hw_params->hal_ops->rx_desc_get_mpdu_ppdu_id(rx_desc);
+       return ab->hal.hal_ops->rx_desc_get_mpdu_ppdu_id(rx_desc);
 }
 
 static inline bool ath12k_dp_rxdesc_mpdu_valid(struct ath12k_base *ab,
@@ -137,7 +137,7 @@ static inline bool ath12k_dp_rxdesc_mpdu_valid(struct ath12k_base *ab,
 {
        u32 tlv_tag;
 
-       tlv_tag = ab->hw_params->hal_ops->rx_desc_get_mpdu_start_tag(rx_desc);
+       tlv_tag = ab->hal.hal_ops->rx_desc_get_mpdu_start_tag(rx_desc);
 
        return tlv_tag == HAL_RX_MPDU_START;
 }
@@ -146,7 +146,7 @@ static inline void ath12k_dp_rx_desc_get_dot11_hdr(struct ath12k_base *ab,
                                                   struct hal_rx_desc *desc,
                                                   struct ieee80211_hdr *hdr)
 {
-       ab->hw_params->hal_ops->rx_desc_get_dot11_hdr(desc, hdr);
+       ab->hal.hal_ops->rx_desc_get_dot11_hdr(desc, hdr);
 }
 
 static inline void ath12k_dp_rx_desc_get_crypto_header(struct ath12k_base *ab,
@@ -154,13 +154,13 @@ static inline void ath12k_dp_rx_desc_get_crypto_header(struct ath12k_base *ab,
                                                       u8 *crypto_hdr,
                                                       enum hal_encrypt_type enctype)
 {
-       ab->hw_params->hal_ops->rx_desc_get_crypto_header(desc, crypto_hdr, enctype);
+       ab->hal.hal_ops->rx_desc_get_crypto_header(desc, crypto_hdr, enctype);
 }
 
 static inline u8 ath12k_dp_rx_get_msdu_src_link(struct ath12k_base *ab,
                                                struct hal_rx_desc *desc)
 {
-       return ab->hw_params->hal_ops->rx_desc_get_msdu_src_link_id(desc);
+       return ab->hal.hal_ops->rx_desc_get_msdu_src_link_id(desc);
 }
 
 static inline void ath12k_dp_clean_up_skb_list(struct sk_buff_head *skb_list)
index 87abacc8ae8e1dd023b377ded32783e06b868baa..338a4e5244ddfbc4e140bd647f5e13e10d71c8d9 100644 (file)
@@ -1105,7 +1105,7 @@ int ath12k_hal_srng_init(struct ath12k_base *ab)
 {
        int ret;
 
-       ret = ab->hw_params->hal_ops->create_srng_config(ab);
+       ret = ab->hal.hal_ops->create_srng_config(ab);
        if (ret)
                goto err_hal;
 
index 4c3a5ec6ae83f8dd08abb8c6d3d09e6035009d2c..4874bebc11f7faea382212d1f56f0d40b6428a73 100644 (file)
@@ -1462,6 +1462,7 @@ struct ath12k_hal {
                dma_addr_t paddr;
        } wrp;
 
+       const struct hal_ops *hal_ops;
        /* Available REO blocking resources bitmap */
        u8 avail_blk_resource;
 
@@ -1579,6 +1580,7 @@ enum nl80211_he_ru_alloc ath12k_he_ru_tones_to_nl80211_he_ru_alloc(u16 ru_tones)
 }
 
 struct ath12k_hw_version_map {
+       const struct hal_ops *hal_ops;
        u32 hal_desc_sz;
 };
 
@@ -1603,9 +1605,6 @@ struct hal_ops {
        u8 *(*rx_desc_get_msdu_payload)(struct hal_rx_desc *desc);
 };
 
-extern const struct hal_ops hal_qcn9274_ops;
-extern const struct hal_ops hal_wcn7850_ops;
-
 u32 ath12k_wifi7_hal_reo_qdesc_size(u32 ba_window_size, u8 tid);
 void ath12k_wifi7_hal_reo_qdesc_setup(struct hal_rx_reo_queue *qdesc,
                                      int tid, u32 ba_window_size,
index 35d6900720feeef6d736df38dcc17402db6d5f8b..7e8f1f7ef5847161bdedd4db6cd47b7ebe974d5a 100644 (file)
@@ -193,8 +193,6 @@ struct ath12k_hw_params {
        void (*wmi_init)(struct ath12k_base *ab,
                         struct ath12k_wmi_resource_config_arg *config);
 
-       const struct hal_ops *hal_ops;
-
        u64 qmi_cnss_feature_bitmap;
 
        u32 rfkill_pin;
index 35709dfccbcf31bfe79837194abd7f13ab8a9804..ece6a1311ef0c7c514d3e57d98f1fd184a8d5c40 100644 (file)
@@ -50,6 +50,6 @@ void ath12k_wifi7_dp_extract_rx_desc_data(struct ath12k_base *ab,
                                          struct hal_rx_desc *rx_desc,
                                          struct hal_rx_desc *ldesc)
 {
-       ab->hw_params->hal_ops->extract_rx_desc_data(rx_info, rx_desc, ldesc);
+       ab->hal.hal_ops->extract_rx_desc_data(rx_info, rx_desc, ldesc);
 }
 #endif
index ab5824abfe758ad1b0bd20b7aa04c371827efff8..036bacd704e92a3e9970b77afd0e5e4409fee699 100644 (file)
@@ -107,7 +107,7 @@ tcl_ring_sel:
        ti.ring_id = ring_selector % ab->hw_params->max_tx_ring;
 
        ring_map |= BIT(ti.ring_id);
-       ti.rbm_id = ab->hw_params->hal_ops->tcl_to_wbm_rbm_map[ti.ring_id].rbm_id;
+       ti.rbm_id = ab->hal.hal_ops->tcl_to_wbm_rbm_map[ti.ring_id].rbm_id;
 
        tx_ring = &dp->tx_ring[ti.ring_id];
 
index 4ad3ef3ba5e0f49a6acc24c9a7f47344c9cafa2d..0e3930c8575a2a740bea98cb50de19bcb4ae7a56 100644 (file)
@@ -7,18 +7,24 @@
 #include "hal_desc.h"
 #include "../hal.h"
 #include "hal.h"
+#include "hal_qcn9274.h"
+#include "hal_wcn7850.h"
 
 static const struct ath12k_hw_version_map ath12k_wifi7_hw_ver_map[] = {
        [ATH12K_HW_QCN9274_HW10] = {
+               .hal_ops = &hal_qcn9274_ops,
                .hal_desc_sz = sizeof(struct hal_rx_desc_qcn9274_compact),
        },
        [ATH12K_HW_QCN9274_HW20] = {
+               .hal_ops = &hal_qcn9274_ops,
                .hal_desc_sz = sizeof(struct hal_rx_desc_qcn9274_compact),
        },
        [ATH12K_HW_WCN7850_HW20] = {
+               .hal_ops = &hal_wcn7850_ops,
                .hal_desc_sz = sizeof(struct hal_rx_desc_wcn7850),
        },
        [ATH12K_HW_IPQ5332_HW10] = {
+               .hal_ops = &hal_qcn9274_ops,
                .hal_desc_sz = sizeof(struct hal_rx_desc_qcn9274_compact),
        },
 };
@@ -29,6 +35,7 @@ int ath12k_wifi7_hal_init(struct ath12k_base *ab)
 
        memset(hal, 0, sizeof(*hal));
 
+       hal->hal_ops = ath12k_wifi7_hw_ver_map[ab->hw_rev].hal_ops;
        hal->hal_desc_sz = ath12k_wifi7_hw_ver_map[ab->hw_rev].hal_desc_sz;
 
        return 0;
index 1563854b5b6a5dd543d4af3d03e8cab6c716467f..4d08292d8a7f975d671b98e8edebbc416566a74f 100644 (file)
@@ -12,6 +12,7 @@
 #include "../hal.h"
 #include "hal_rx.h"
 
+extern const struct hal_ops hal_qcn9274_ops;
 extern const struct ath12k_hal_tcl_to_wbm_rbm_map
 ath12k_hal_qcn9274_tcl_to_wbm_rbm_map[DP_TCL_NUM_RING_MAX];
 
index 80de7ea522b54fb4fef48a379860ba5b8fda9219..8207e73602b3c4ae1b1a78326a52f923435b9164 100644 (file)
@@ -10,6 +10,7 @@
 #include "../hal.h"
 #include "hal_rx.h"
 
+extern const struct hal_ops hal_wcn7850_ops;
 extern const struct ath12k_hal_tcl_to_wbm_rbm_map
 ath12k_hal_wcn7850_tcl_to_wbm_rbm_map[DP_TCL_NUM_RING_MAX];
 
index 621022064962e1b8206dc4e9253b6bb37481c402..f469a829ae9a7d9c3c4561f6b60e73e55d78b036 100644 (file)
@@ -758,8 +758,6 @@ static const struct ath12k_hw_params ath12k_wifi7_hw_params[] = {
 
                .wmi_init = ath12k_wifi7_wmi_init_qcn9274,
 
-               .hal_ops = &hal_qcn9274_ops,
-
                .qmi_cnss_feature_bitmap = BIT(CNSS_QDSS_CFG_MISS_V01),
 
                .rfkill_pin = 0,
@@ -847,8 +845,6 @@ static const struct ath12k_hw_params ath12k_wifi7_hw_params[] = {
 
                .wmi_init = ath12k_wifi7_wmi_init_wcn7850,
 
-               .hal_ops = &hal_wcn7850_ops,
-
                .qmi_cnss_feature_bitmap = BIT(CNSS_QDSS_CFG_MISS_V01) |
                                           BIT(CNSS_PCIE_PERST_NO_PULL_V01),
 
@@ -934,8 +930,6 @@ static const struct ath12k_hw_params ath12k_wifi7_hw_params[] = {
 
                .wmi_init = ath12k_wifi7_wmi_init_qcn9274,
 
-               .hal_ops = &hal_qcn9274_ops,
-
                .qmi_cnss_feature_bitmap = BIT(CNSS_QDSS_CFG_MISS_V01),
 
                .rfkill_pin = 0,
@@ -1017,8 +1011,6 @@ static const struct ath12k_hw_params ath12k_wifi7_hw_params[] = {
 
                .wmi_init = &ath12k_wifi7_wmi_init_qcn9274,
 
-               .hal_ops = &hal_qcn9274_ops,
-
                .qmi_cnss_feature_bitmap = BIT(CNSS_QDSS_CFG_MISS_V01),
 
                .rfkill_pin = 0,