]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: ath12k: refactor REO CMD ring handling
authorBaochen Qiang <baochen.qiang@oss.qualcomm.com>
Mon, 12 Jan 2026 07:36:22 +0000 (15:36 +0800)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Fri, 16 Jan 2026 01:19:38 +0000 (17:19 -0800)
The entry of REO CMD ring of existing chips has a 64 bit TLV header, hence
below functions take a 64 bit TLV assumption by default

        ath12k_wifi7_hal_reo_init_cmd_ring()
        ath12k_wifi7_hal_reo_cmd_queue_stats()
        ath12k_wifi7_hal_reo_cmd_flush_cache()
        ath12k_wifi7_hal_reo_cmd_update_rx_queue()

However this is not the case for QCC2072 of which the TLV is 32 bit,
meaning above functions don't work for it.

Rename/refactor above functions to prepare for QCC2072 support:

Rename the first one to ath12k_wifi7_hal_reo_init_cmd_ring_tlv64() to
better reflect what it is doing. There will be a 32 bit variant when
QCC2072 support is in place.

For the last ones, remove TLV length assumption and offload TLV encoding
work to a newly added callback _reo_cmd_enc_tlv_hdr. This way each chip
can register its own handler hence can do the work accordingly.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00302-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.115823.3

Signed-off-by: Baochen Qiang <baochen.qiang@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Link: https://patch.msgid.link/20260112-ath12k-support-qcc2072-v2-2-fc8ce1e43969@oss.qualcomm.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/hal.c
drivers/net/wireless/ath/ath12k/hal.h
drivers/net/wireless/ath/ath12k/wifi7/hal_desc.h
drivers/net/wireless/ath/ath12k/wifi7/hal_qcn9274.c
drivers/net/wireless/ath/ath12k/wifi7/hal_rx.c
drivers/net/wireless/ath/ath12k/wifi7/hal_rx.h
drivers/net/wireless/ath/ath12k/wifi7/hal_wcn7850.c

index c7a152490fa09fd1fdc9dd7d7b32c723c01a9d2c..b19bec8ea082d0831b57a719e29b265591fd9039 100644 (file)
@@ -823,3 +823,14 @@ void ath12k_hal_dump_srng_stats(struct ath12k_base *ab)
                                   jiffies_to_msecs(jiffies - srng->timestamp));
        }
 }
+
+void *ath12k_hal_encode_tlv64_hdr(void *tlv, u64 tag, u64 len)
+{
+       struct hal_tlv_64_hdr *tlv64 = tlv;
+
+       tlv64->tl = le64_encode_bits(tag, HAL_TLV_HDR_TAG) |
+                   le64_encode_bits(len, HAL_TLV_HDR_LEN);
+
+       return tlv64->value;
+}
+EXPORT_SYMBOL(ath12k_hal_encode_tlv64_hdr);
index f23ba1f9eaac2359e913a44530a6c8bb55da7f40..595e4904647150b56d945c4500c5af6540978328 100644 (file)
@@ -1426,8 +1426,30 @@ struct hal_ops {
                                         u32 *sw_cookie,
                                         struct ath12k_buffer_addr **pp_buf_addr,
                                         u8 *rbm, u32 *msdu_cnt);
+       void *(*reo_cmd_enc_tlv_hdr)(void *tlv, u64 tag, u64 len);
 };
 
+#define HAL_TLV_HDR_TAG                GENMASK(9, 1)
+#define HAL_TLV_HDR_LEN                GENMASK(25, 10)
+#define HAL_TLV_USR_ID         GENMASK(31, 26)
+
+#define HAL_TLV_ALIGN  4
+
+struct hal_tlv_hdr {
+       __le32 tl;
+       u8 value[];
+} __packed;
+
+#define HAL_TLV_64_HDR_TAG             GENMASK(9, 1)
+#define HAL_TLV_64_HDR_LEN             GENMASK(21, 10)
+#define HAL_TLV_64_USR_ID              GENMASK(31, 26)
+#define HAL_TLV_64_ALIGN               8
+
+struct hal_tlv_64_hdr {
+       __le64 tl;
+       u8 value[];
+} __packed;
+
 dma_addr_t ath12k_hal_srng_get_tp_addr(struct ath12k_base *ab,
                                       struct hal_srng *srng);
 dma_addr_t ath12k_hal_srng_get_hp_addr(struct ath12k_base *ab,
@@ -1515,4 +1537,5 @@ void ath12k_hal_rx_reo_ent_buf_paddr_get(struct ath12k_hal *hal, void *rx_desc,
                                         dma_addr_t *paddr, u32 *sw_cookie,
                                         struct ath12k_buffer_addr **pp_buf_addr,
                                         u8 *rbm, u32 *msdu_cnt);
+void *ath12k_hal_encode_tlv64_hdr(void *tlv, u64 tag, u64 len);
 #endif
index 9dad8f7ca9f2130e0b8833d4469e03a89a0f642a..cdcf24b1d6eba32fb0bfb6c9d7a11a97892598d8 100644 (file)
@@ -487,27 +487,6 @@ enum hal_tlv_tag {
        HAL_TLV_BASE                                            = 511 /* 0x1ff */,
 };
 
-#define HAL_TLV_HDR_TAG                GENMASK(9, 1)
-#define HAL_TLV_HDR_LEN                GENMASK(25, 10)
-#define HAL_TLV_USR_ID          GENMASK(31, 26)
-
-#define HAL_TLV_ALIGN  4
-
-struct hal_tlv_hdr {
-       __le32 tl;
-       u8 value[];
-} __packed;
-
-#define HAL_TLV_64_HDR_TAG             GENMASK(9, 1)
-#define HAL_TLV_64_HDR_LEN             GENMASK(21, 10)
-#define HAL_TLV_64_USR_ID              GENMASK(31, 26)
-#define HAL_TLV_64_ALIGN               8
-
-struct hal_tlv_64_hdr {
-       __le64 tl;
-       u8 value[];
-} __packed;
-
 #define RX_MPDU_DESC_INFO0_MSDU_COUNT          GENMASK(7, 0)
 #define RX_MPDU_DESC_INFO0_FRAG_FLAG           BIT(8)
 #define RX_MPDU_DESC_INFO0_MPDU_RETRY          BIT(9)
index c129e937132b446bc546b7ed2abcb8e3b01041e9..ff26e9684e9e3808a163f064fbc961c23ef85cc6 100644 (file)
@@ -1020,7 +1020,7 @@ const struct hal_ops hal_qcn9274_ops = {
        .write_reoq_lut_addr = ath12k_wifi7_hal_write_reoq_lut_addr,
        .write_ml_reoq_lut_addr = ath12k_wifi7_hal_write_ml_reoq_lut_addr,
        .setup_link_idle_list = ath12k_wifi7_hal_setup_link_idle_list,
-       .reo_init_cmd_ring = ath12k_wifi7_hal_reo_init_cmd_ring,
+       .reo_init_cmd_ring = ath12k_wifi7_hal_reo_init_cmd_ring_tlv64,
        .reo_hw_setup = ath12k_wifi7_hal_reo_hw_setup,
        .reo_shared_qaddr_cache_clear = ath12k_wifi7_hal_reo_shared_qaddr_cache_clear,
        .rx_buf_addr_info_set = ath12k_wifi7_hal_rx_buf_addr_info_set,
@@ -1029,4 +1029,5 @@ const struct hal_ops hal_qcn9274_ops = {
        .get_idle_link_rbm = ath12k_wifi7_hal_get_idle_link_rbm,
        .rx_msdu_list_get = ath12k_wifi7_hal_rx_msdu_list_get,
        .rx_reo_ent_buf_paddr_get = ath12k_wifi7_hal_rx_reo_ent_buf_paddr_get,
+       .reo_cmd_enc_tlv_hdr = ath12k_hal_encode_tlv64_hdr,
 };
index 903fb52a03bfd70448c0e33fb8f70c65aeda2eeb..3b8710a3b6ad2b03b94d88008b1e5709c015685b 100644 (file)
@@ -23,15 +23,13 @@ void ath12k_wifi7_hal_reo_set_desc_hdr(struct hal_desc_header *hdr,
        hdr->info0 |= le32_encode_bits(magic, HAL_DESC_HDR_INFO0_DBG_RESERVED);
 }
 
-static int ath12k_wifi7_hal_reo_cmd_queue_stats(struct hal_tlv_64_hdr *tlv,
+static int ath12k_wifi7_hal_reo_cmd_queue_stats(struct ath12k_hal *hal, void *tlv,
                                                struct ath12k_hal_reo_cmd *cmd)
 {
        struct hal_reo_get_queue_stats *desc;
 
-       tlv->tl = le64_encode_bits(HAL_REO_GET_QUEUE_STATS, HAL_TLV_HDR_TAG) |
-                 le64_encode_bits(sizeof(*desc), HAL_TLV_HDR_LEN);
-
-       desc = (struct hal_reo_get_queue_stats *)tlv->value;
+       desc = hal->ops->reo_cmd_enc_tlv_hdr(tlv, HAL_REO_GET_QUEUE_STATS,
+                                            sizeof(*desc));
        memset_startat(desc, 0, queue_addr_lo);
 
        desc->cmd.info0 &= ~cpu_to_le32(HAL_REO_CMD_HDR_INFO0_STATUS_REQUIRED);
@@ -47,8 +45,7 @@ static int ath12k_wifi7_hal_reo_cmd_queue_stats(struct hal_tlv_64_hdr *tlv,
        return le32_get_bits(desc->cmd.info0, HAL_REO_CMD_HDR_INFO0_CMD_NUMBER);
 }
 
-static int ath12k_wifi7_hal_reo_cmd_flush_cache(struct ath12k_hal *hal,
-                                               struct hal_tlv_64_hdr *tlv,
+static int ath12k_wifi7_hal_reo_cmd_flush_cache(struct ath12k_hal *hal, void *tlv,
                                                struct ath12k_hal_reo_cmd *cmd)
 {
        struct hal_reo_flush_cache *desc;
@@ -61,10 +58,8 @@ static int ath12k_wifi7_hal_reo_cmd_flush_cache(struct ath12k_hal *hal,
                hal->current_blk_index = avail_slot;
        }
 
-       tlv->tl = le64_encode_bits(HAL_REO_FLUSH_CACHE, HAL_TLV_HDR_TAG) |
-                 le64_encode_bits(sizeof(*desc), HAL_TLV_HDR_LEN);
-
-       desc = (struct hal_reo_flush_cache *)tlv->value;
+       desc = hal->ops->reo_cmd_enc_tlv_hdr(tlv, HAL_REO_FLUSH_CACHE,
+                                            sizeof(*desc));
        memset_startat(desc, 0, cache_addr_lo);
 
        desc->cmd.info0 &= ~cpu_to_le32(HAL_REO_CMD_HDR_INFO0_STATUS_REQUIRED);
@@ -98,15 +93,13 @@ static int ath12k_wifi7_hal_reo_cmd_flush_cache(struct ath12k_hal *hal,
 }
 
 static int
-ath12k_wifi7_hal_reo_cmd_update_rx_queue(struct hal_tlv_64_hdr *tlv,
+ath12k_wifi7_hal_reo_cmd_update_rx_queue(struct ath12k_hal *hal, void *tlv,
                                         struct ath12k_hal_reo_cmd *cmd)
 {
        struct hal_reo_update_rx_queue *desc;
 
-       tlv->tl = le64_encode_bits(HAL_REO_UPDATE_RX_REO_QUEUE, HAL_TLV_HDR_TAG) |
-                 le64_encode_bits(sizeof(*desc), HAL_TLV_HDR_LEN);
-
-       desc = (struct hal_reo_update_rx_queue *)tlv->value;
+       desc = hal->ops->reo_cmd_enc_tlv_hdr(tlv, HAL_REO_UPDATE_RX_REO_QUEUE,
+                                            sizeof(*desc));
        memset_startat(desc, 0, queue_addr_lo);
 
        desc->cmd.info0 &= ~cpu_to_le32(HAL_REO_CMD_HDR_INFO0_STATUS_REQUIRED);
@@ -227,7 +220,8 @@ int ath12k_wifi7_hal_reo_cmd_send(struct ath12k_base *ab, struct hal_srng *srng,
                                  enum hal_reo_cmd_type type,
                                  struct ath12k_hal_reo_cmd *cmd)
 {
-       struct hal_tlv_64_hdr *reo_desc;
+       struct ath12k_hal *hal = &ab->hal;
+       void *reo_desc;
        int ret;
 
        spin_lock_bh(&srng->lock);
@@ -241,14 +235,13 @@ int ath12k_wifi7_hal_reo_cmd_send(struct ath12k_base *ab, struct hal_srng *srng,
 
        switch (type) {
        case HAL_REO_CMD_GET_QUEUE_STATS:
-               ret = ath12k_wifi7_hal_reo_cmd_queue_stats(reo_desc, cmd);
+               ret = ath12k_wifi7_hal_reo_cmd_queue_stats(hal, reo_desc, cmd);
                break;
        case HAL_REO_CMD_FLUSH_CACHE:
-               ret = ath12k_wifi7_hal_reo_cmd_flush_cache(&ab->hal, reo_desc,
-                                                          cmd);
+               ret = ath12k_wifi7_hal_reo_cmd_flush_cache(hal, reo_desc, cmd);
                break;
        case HAL_REO_CMD_UPDATE_RX_QUEUE:
-               ret = ath12k_wifi7_hal_reo_cmd_update_rx_queue(reo_desc, cmd);
+               ret = ath12k_wifi7_hal_reo_cmd_update_rx_queue(hal, reo_desc, cmd);
                break;
        case HAL_REO_CMD_FLUSH_QUEUE:
        case HAL_REO_CMD_UNBLOCK_CACHE:
@@ -891,8 +884,8 @@ void ath12k_wifi7_hal_reo_qdesc_setup(struct hal_rx_reo_queue *qdesc,
                                          REO_QUEUE_DESC_MAGIC_DEBUG_PATTERN_3);
 }
 
-void ath12k_wifi7_hal_reo_init_cmd_ring(struct ath12k_base *ab,
-                                       struct hal_srng *srng)
+void ath12k_wifi7_hal_reo_init_cmd_ring_tlv64(struct ath12k_base *ab,
+                                             struct hal_srng *srng)
 {
        struct hal_srng_params params;
        struct hal_tlv_64_hdr *tlv;
index 8a0f4a781d8a253dcc2f47c6eee7483b4cc9d402..aa1bca81395571db0a7fd9adabb99a546ea0beca 100644 (file)
@@ -860,8 +860,8 @@ void ath12k_wifi7_hal_rx_msdu_list_get(struct ath12k *ar,
                                       void *link_desc,
                                       void *msdu_list_opaque,
                                       u16 *num_msdus);
-void ath12k_wifi7_hal_reo_init_cmd_ring(struct ath12k_base *ab,
-                                       struct hal_srng *srng);
+void ath12k_wifi7_hal_reo_init_cmd_ring_tlv64(struct ath12k_base *ab,
+                                             struct hal_srng *srng);
 void ath12k_wifi7_hal_reo_shared_qaddr_cache_clear(struct ath12k_base *ab);
 void ath12k_wifi7_hal_reo_hw_setup(struct ath12k_base *ab, u32 ring_hash_map);
 void ath12k_wifi7_hal_reo_qdesc_setup(struct hal_rx_reo_queue *qdesc,
index 7108cc41536d171181b2226e6ff8c929a270b643..49c45431c0c79dfb15ba75f0c48e9957ad63f809 100644 (file)
@@ -793,7 +793,7 @@ const struct hal_ops hal_wcn7850_ops = {
        .write_reoq_lut_addr = ath12k_wifi7_hal_write_reoq_lut_addr,
        .write_ml_reoq_lut_addr = ath12k_wifi7_hal_write_ml_reoq_lut_addr,
        .setup_link_idle_list = ath12k_wifi7_hal_setup_link_idle_list,
-       .reo_init_cmd_ring = ath12k_wifi7_hal_reo_init_cmd_ring,
+       .reo_init_cmd_ring = ath12k_wifi7_hal_reo_init_cmd_ring_tlv64,
        .reo_shared_qaddr_cache_clear = ath12k_wifi7_hal_reo_shared_qaddr_cache_clear,
        .reo_hw_setup = ath12k_wifi7_hal_reo_hw_setup,
        .rx_buf_addr_info_set = ath12k_wifi7_hal_rx_buf_addr_info_set,
@@ -802,4 +802,5 @@ const struct hal_ops hal_wcn7850_ops = {
        .get_idle_link_rbm = ath12k_wifi7_hal_get_idle_link_rbm,
        .rx_msdu_list_get = ath12k_wifi7_hal_rx_msdu_list_get,
        .rx_reo_ent_buf_paddr_get = ath12k_wifi7_hal_rx_reo_ent_buf_paddr_get,
+       .reo_cmd_enc_tlv_hdr = ath12k_hal_encode_tlv64_hdr,
 };