]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: ath12k: remove hal_desc_sz from hw params
authorRaj Kumar Bhagat <quic_rajkbhag@quicinc.com>
Mon, 29 Jan 2024 06:57:19 +0000 (12:27 +0530)
committerKalle Valo <quic_kvalo@quicinc.com>
Fri, 2 Feb 2024 12:32:51 +0000 (14:32 +0200)
With word mask subscription support, the rx_desc structure will
change. The fields in this structure rx_desc will be reduced to only
the required fields. To make word mask subscription changes compatible
with the older firmware version (firmware that does not support word
mask subscription), two different structures of rx_desc will be
required for the same hardware.

The hardware param hal_desc_sz value cannot be constant for the same
hardware. It depends on the size of rx_desc structure which may
change based on firmware capability to support word mask subscription.
Hence, remove hal_desc_sz from hardware param and add hal_rx_ops
to get the size of rx_desc in run time.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00188-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-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: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://msgid.link/20240129065724.2310207-9-quic_rajkbhag@quicinc.com
drivers/net/wireless/ath/ath12k/core.c
drivers/net/wireless/ath/ath12k/dp.c
drivers/net/wireless/ath/ath12k/dp.h
drivers/net/wireless/ath/ath12k/dp_mon.c
drivers/net/wireless/ath/ath12k/dp_rx.c
drivers/net/wireless/ath/ath12k/hal.c
drivers/net/wireless/ath/ath12k/hal.h
drivers/net/wireless/ath/ath12k/hw.c
drivers/net/wireless/ath/ath12k/hw.h

index 7f0b395f12969659c097eeeb8f7c76ba979bc5e9..ca3777c684b37df9584abe8e310b9d36decba73d 100644 (file)
@@ -748,6 +748,8 @@ static int ath12k_core_start(struct ath12k_base *ab,
                goto err_mac_destroy;
        }
 
+       ath12k_dp_hal_rx_desc_init(ab);
+
        ret = ath12k_wmi_cmd_init(ab);
        if (ret) {
                ath12k_err(ab, "failed to send wmi init cmd: %d\n", ret);
index a6f81f2f97ef45a6e739fea29d27d3cef0263a18..af800d60f3a2efdded7779d293b77ba8bd43df56 100644 (file)
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: BSD-3-Clause-Clear
 /*
  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <crypto/hash.h>
@@ -997,6 +997,12 @@ void ath12k_dp_pdev_pre_alloc(struct ath12k_base *ab)
        }
 }
 
+void ath12k_dp_hal_rx_desc_init(struct ath12k_base *ab)
+{
+       ab->hal.hal_desc_sz =
+               ab->hal_rx_ops->rx_desc_get_desc_size();
+}
+
 static void ath12k_dp_service_mon_ring(struct timer_list *t)
 {
        struct ath12k_base *ab = from_timer(ab, t, mon_reap_timer);
index 0a10cd36235619bab6c81198ad22a5297de97efa..226b95bd5ab0ce33453d5689005c06e993ca94ed 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
 /*
  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #ifndef ATH12K_DP_H
@@ -1821,4 +1821,5 @@ struct ath12k_rx_desc_info *ath12k_dp_get_rx_desc(struct ath12k_base *ab,
                                                  u32 cookie);
 struct ath12k_tx_desc_info *ath12k_dp_get_tx_desc(struct ath12k_base *ab,
                                                  u32 desc_id);
+void ath12k_dp_hal_rx_desc_init(struct ath12k_base *ab);
 #endif
index 7aa55cf64e8b9e3f4d3b6f8fc39a86c57c7be936..2d56913a75d0f89a7e9fb57d4d99f2fdaad23f49 100644 (file)
@@ -864,7 +864,7 @@ static void ath12k_dp_mon_rx_msdus_set_payload(struct ath12k *ar, struct sk_buff
 {
        u32 rx_pkt_offset, l2_hdr_offset;
 
-       rx_pkt_offset = ar->ab->hw_params->hal_desc_sz;
+       rx_pkt_offset = ar->ab->hal.hal_desc_sz;
        l2_hdr_offset = ath12k_dp_rx_h_l3pad(ar->ab,
                                             (struct hal_rx_desc *)msdu->data);
        skb_pull(msdu, rx_pkt_offset + l2_hdr_offset);
index d8816b38ccaa467a2d0da7b7191cac6272612729..10ea33fafff43cfa5cae258f977381ac4226b3f1 100644 (file)
@@ -58,7 +58,7 @@ static bool ath12k_dp_rx_h_more_frags(struct ath12k_base *ab,
 {
        struct ieee80211_hdr *hdr;
 
-       hdr = (struct ieee80211_hdr *)(skb->data + ab->hw_params->hal_desc_sz);
+       hdr = (struct ieee80211_hdr *)(skb->data + ab->hal.hal_desc_sz);
        return ieee80211_has_morefrags(hdr->frame_control);
 }
 
@@ -67,7 +67,7 @@ static u16 ath12k_dp_rx_h_frag_no(struct ath12k_base *ab,
 {
        struct ieee80211_hdr *hdr;
 
-       hdr = (struct ieee80211_hdr *)(skb->data + ab->hw_params->hal_desc_sz);
+       hdr = (struct ieee80211_hdr *)(skb->data + ab->hal.hal_desc_sz);
        return le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG;
 }
 
@@ -1761,7 +1761,7 @@ static int ath12k_dp_rx_msdu_coalesce(struct ath12k *ar,
        int buf_first_hdr_len, buf_first_len;
        struct hal_rx_desc *ldesc;
        int space_extra, rem_len, buf_len;
-       u32 hal_rx_desc_sz = ar->ab->hw_params->hal_desc_sz;
+       u32 hal_rx_desc_sz = ar->ab->hal.hal_desc_sz;
 
        /* As the msdu is spread across multiple rx buffers,
         * find the offset to the start of msdu for computing
@@ -2473,7 +2473,7 @@ static int ath12k_dp_rx_process_msdu(struct ath12k *ar,
        u8 l3_pad_bytes;
        u16 msdu_len;
        int ret;
-       u32 hal_rx_desc_sz = ar->ab->hw_params->hal_desc_sz;
+       u32 hal_rx_desc_sz = ar->ab->hal.hal_desc_sz;
 
        last_buf = ath12k_dp_rx_get_msdu_last_buf(msdu_list, msdu);
        if (!last_buf) {
@@ -2804,7 +2804,7 @@ static int ath12k_dp_rx_h_verify_tkip_mic(struct ath12k *ar, struct ath12k_peer
        u8 mic[IEEE80211_CCMP_MIC_LEN];
        int head_len, tail_len, ret;
        size_t data_len;
-       u32 hdr_len, hal_rx_desc_sz = ar->ab->hw_params->hal_desc_sz;
+       u32 hdr_len, hal_rx_desc_sz = ar->ab->hal.hal_desc_sz;
        u8 *key, *data;
        u8 key_idx;
 
@@ -2854,7 +2854,7 @@ static void ath12k_dp_rx_h_undecap_frag(struct ath12k *ar, struct sk_buff *msdu,
        struct ieee80211_hdr *hdr;
        size_t hdr_len;
        size_t crypto_len;
-       u32 hal_rx_desc_sz = ar->ab->hw_params->hal_desc_sz;
+       u32 hal_rx_desc_sz = ar->ab->hal.hal_desc_sz;
 
        if (!flags)
                return;
@@ -2892,7 +2892,7 @@ static int ath12k_dp_rx_h_defrag(struct ath12k *ar,
        bool is_decrypted = false;
        int msdu_len = 0;
        int extra_space;
-       u32 flags, hal_rx_desc_sz = ar->ab->hw_params->hal_desc_sz;
+       u32 flags, hal_rx_desc_sz = ar->ab->hal.hal_desc_sz;
 
        first_frag = skb_peek(&rx_tid->rx_frags);
        last_frag = skb_peek_tail(&rx_tid->rx_frags);
@@ -2968,7 +2968,7 @@ static int ath12k_dp_rx_h_defrag_reo_reinject(struct ath12k *ar,
        struct ath12k_rx_desc_info *desc_info;
        u8 dst_ind;
 
-       hal_rx_desc_sz = ab->hw_params->hal_desc_sz;
+       hal_rx_desc_sz = ab->hal.hal_desc_sz;
        link_desc_banks = dp->link_desc_banks;
        reo_dest_ring = rx_tid->dst_ring_desc;
 
@@ -3122,7 +3122,7 @@ static u64 ath12k_dp_rx_h_get_pn(struct ath12k *ar, struct sk_buff *skb)
        struct ieee80211_hdr *hdr;
        u64 pn = 0;
        u8 *ehdr;
-       u32 hal_rx_desc_sz = ar->ab->hw_params->hal_desc_sz;
+       u32 hal_rx_desc_sz = ar->ab->hal.hal_desc_sz;
 
        hdr = (struct ieee80211_hdr *)(skb->data + hal_rx_desc_sz);
        ehdr = skb->data + hal_rx_desc_sz + ieee80211_hdrlen(hdr->frame_control);
@@ -3305,7 +3305,7 @@ ath12k_dp_process_rx_err_buf(struct ath12k *ar, struct hal_reo_dest_ring *desc,
        struct ath12k_skb_rxcb *rxcb;
        struct hal_rx_desc *rx_desc;
        u16 msdu_len;
-       u32 hal_rx_desc_sz = ab->hw_params->hal_desc_sz;
+       u32 hal_rx_desc_sz = ab->hal.hal_desc_sz;
        struct ath12k_rx_desc_info *desc_info;
        u64 desc_va;
 
@@ -3486,7 +3486,7 @@ static void ath12k_dp_rx_null_q_desc_sg_drop(struct ath12k *ar,
        int n_buffs;
 
        n_buffs = DIV_ROUND_UP(msdu_len,
-                              (DP_RX_BUFFER_SIZE - ar->ab->hw_params->hal_desc_sz));
+                              (DP_RX_BUFFER_SIZE - ar->ab->hal.hal_desc_sz));
 
        skb_queue_walk_safe(msdu_list, skb, tmp) {
                rxcb = ATH12K_SKB_RXCB(skb);
@@ -3510,7 +3510,7 @@ static int ath12k_dp_rx_h_null_q_desc(struct ath12k *ar, struct sk_buff *msdu,
        struct hal_rx_desc *desc = (struct hal_rx_desc *)msdu->data;
        u8 l3pad_bytes;
        struct ath12k_skb_rxcb *rxcb = ATH12K_SKB_RXCB(msdu);
-       u32 hal_rx_desc_sz = ar->ab->hw_params->hal_desc_sz;
+       u32 hal_rx_desc_sz = ar->ab->hal.hal_desc_sz;
 
        msdu_len = ath12k_dp_rx_h_msdu_len(ab, desc);
 
@@ -3607,7 +3607,7 @@ static void ath12k_dp_rx_h_tkip_mic_err(struct ath12k *ar, struct sk_buff *msdu,
        struct hal_rx_desc *desc = (struct hal_rx_desc *)msdu->data;
        u8 l3pad_bytes;
        struct ath12k_skb_rxcb *rxcb = ATH12K_SKB_RXCB(msdu);
-       u32 hal_rx_desc_sz = ar->ab->hw_params->hal_desc_sz;
+       u32 hal_rx_desc_sz = ar->ab->hal.hal_desc_sz;
 
        rxcb->is_first_msdu = ath12k_dp_rx_h_first_msdu(ab, desc);
        rxcb->is_last_msdu = ath12k_dp_rx_h_last_msdu(ab, desc);
@@ -3922,7 +3922,7 @@ int ath12k_dp_rxdma_ring_sel_config_qcn9274(struct ath12k_base *ab)
        struct htt_rx_ring_tlv_filter tlv_filter = {0};
        u32 ring_id;
        int ret;
-       u32 hal_rx_desc_sz = ab->hw_params->hal_desc_sz;
+       u32 hal_rx_desc_sz = ab->hal.hal_desc_sz;
 
        ring_id = dp->rx_refill_buf_ring.refill_buf_ring.ring_id;
 
@@ -3957,7 +3957,7 @@ int ath12k_dp_rxdma_ring_sel_config_wcn7850(struct ath12k_base *ab)
        struct htt_rx_ring_tlv_filter tlv_filter = {0};
        u32 ring_id;
        int ret;
-       u32 hal_rx_desc_sz = ab->hw_params->hal_desc_sz;
+       u32 hal_rx_desc_sz = ab->hal.hal_desc_sz;
        int i;
 
        ring_id = dp->rx_refill_buf_ring.refill_buf_ring.ring_id;
index b6b8298a2bdcdf78ec675d8c7cf3fa2cbf14a341..fa1bfb5256d05b7cffc9d4fa90a234f8785b45bb 100644 (file)
@@ -680,6 +680,11 @@ static u32 ath12k_hw_qcn9274_dp_rx_h_mpdu_err(struct hal_rx_desc *desc)
        return errmap;
 }
 
+static u32 ath12k_hw_qcn9274_get_rx_desc_size(void)
+{
+       return sizeof(struct hal_rx_desc_qcn9274);
+}
+
 const struct hal_rx_ops hal_rx_qcn9274_ops = {
        .rx_desc_get_first_msdu = ath12k_hw_qcn9274_rx_desc_get_first_msdu,
        .rx_desc_get_last_msdu = ath12k_hw_qcn9274_rx_desc_get_last_msdu,
@@ -717,6 +722,7 @@ const struct hal_rx_ops hal_rx_qcn9274_ops = {
        .dp_rx_h_ip_cksum_fail = ath12k_hw_qcn9274_dp_rx_h_ip_cksum_fail,
        .dp_rx_h_is_decrypted = ath12k_hw_qcn9274_dp_rx_h_is_decrypted,
        .dp_rx_h_mpdu_err = ath12k_hw_qcn9274_dp_rx_h_mpdu_err,
+       .rx_desc_get_desc_size = ath12k_hw_qcn9274_get_rx_desc_size,
 };
 
 const struct hal_ops hal_qcn9274_ops = {
@@ -1137,6 +1143,11 @@ static u32 ath12k_hw_wcn7850_dp_rx_h_mpdu_err(struct hal_rx_desc *desc)
        return errmap;
 }
 
+static u32 ath12k_hw_wcn7850_get_rx_desc_size(void)
+{
+       return sizeof(struct hal_rx_desc_wcn7850);
+}
+
 const struct hal_rx_ops hal_rx_wcn7850_ops = {
        .rx_desc_get_first_msdu = ath12k_hw_wcn7850_rx_desc_get_first_msdu,
        .rx_desc_get_last_msdu = ath12k_hw_wcn7850_rx_desc_get_last_msdu,
@@ -1175,6 +1186,7 @@ const struct hal_rx_ops hal_rx_wcn7850_ops = {
        .dp_rx_h_ip_cksum_fail = ath12k_hw_wcn7850_dp_rx_h_ip_cksum_fail,
        .dp_rx_h_is_decrypted = ath12k_hw_wcn7850_dp_rx_h_is_decrypted,
        .dp_rx_h_mpdu_err = ath12k_hw_wcn7850_dp_rx_h_mpdu_err,
+       .rx_desc_get_desc_size = ath12k_hw_wcn7850_get_rx_desc_size,
 };
 
 const struct hal_ops hal_wcn7850_ops = {
index 33dedfbb3964ce2e215833d0024198eb2303f2fe..82517991510b00a0cbb45ba3b319c7565c03c3e2 100644 (file)
@@ -1023,6 +1023,8 @@ struct ath12k_hal {
        /* shadow register configuration */
        u32 shadow_reg_addr[HAL_SHADOW_NUM_REGS];
        int num_shadow_reg_configured;
+
+       u32 hal_desc_sz;
 };
 
 /* Maps WBM ring number and Return Buffer Manager Id per TCL ring */
@@ -1075,6 +1077,7 @@ struct hal_rx_ops {
        bool (*dp_rx_h_ip_cksum_fail)(struct hal_rx_desc *desc);
        bool (*dp_rx_h_is_decrypted)(struct hal_rx_desc *desc);
        u32 (*dp_rx_h_mpdu_err)(struct hal_rx_desc *desc);
+       u32 (*rx_desc_get_desc_size)(void);
 };
 
 struct hal_ops {
index cbb6e2b6d8264e577d4bbd81d664d6694d505121..f399511746a87ad31cb3024a12559beb4fd3896c 100644 (file)
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: BSD-3-Clause-Clear
 /*
  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/types.h>
@@ -897,7 +897,6 @@ static const struct ath12k_hw_params ath12k_hw_params[] = {
                .reoq_lut_support = false,
                .supports_shadow_regs = false,
 
-               .hal_desc_sz = sizeof(struct hal_rx_desc_qcn9274),
                .num_tcl_banks = 48,
                .max_tx_ring = 4,
 
@@ -963,7 +962,6 @@ static const struct ath12k_hw_params ath12k_hw_params[] = {
                .reoq_lut_support = false,
                .supports_shadow_regs = true,
 
-               .hal_desc_sz = sizeof(struct hal_rx_desc_wcn7850),
                .num_tcl_banks = 7,
                .max_tx_ring = 3,
 
@@ -1029,7 +1027,6 @@ static const struct ath12k_hw_params ath12k_hw_params[] = {
                .reoq_lut_support = false,
                .supports_shadow_regs = false,
 
-               .hal_desc_sz = sizeof(struct hal_rx_desc_qcn9274),
                .num_tcl_banks = 48,
                .max_tx_ring = 4,
 
index efa3411dc63d73248ff6c475d7553b27f5e65787..987188f56b291d72f3cc891b569eac18ffd0850a 100644 (file)
@@ -187,7 +187,6 @@ struct ath12k_hw_params {
        bool reoq_lut_support:1;
        bool supports_shadow_regs:1;
 
-       u32 hal_desc_sz;
        u32 num_tcl_banks;
        u32 max_tx_ring;