From b733f89803e6b3bb44d9fa56c3d2723a6975dce7 Mon Sep 17 00:00:00 2001 From: Chaithanya Garrepalli Date: Mon, 4 Oct 2021 23:46:39 +0530 Subject: [PATCH] qcacmn: change RxDMA rings to DMAC mode for QCN9224 For Waikiki use same SW2RxDMA ring for both radios Change-Id: I33ab1749afada08e97d0b16fe68773c2d5532a15 --- dp/wifi3.0/be/dp_be.c | 76 +++++++++++++++++++++++++++++++++++++++++-- dp/wifi3.0/dp_main.c | 59 ++++++++++++++++++++------------- dp/wifi3.0/dp_types.h | 3 ++ hal/wifi3.0/hal_api.h | 8 +++++ 4 files changed, 121 insertions(+), 25 deletions(-) diff --git a/dp/wifi3.0/be/dp_be.c b/dp/wifi3.0/be/dp_be.c index f73b1bd1d3..9ddf1ec523 100644 --- a/dp/wifi3.0/be/dp_be.c +++ b/dp/wifi3.0/be/dp_be.c @@ -53,6 +53,9 @@ static struct wlan_cfg_tcl_wbm_ring_num_map g_tcl_wbm_map_array[MAX_TCL_DATA_RIN static void dp_soc_cfg_attach_be(struct dp_soc *soc) { soc->wlan_cfg_ctx->tcl_wbm_map_array = g_tcl_wbm_map_array; + + /* this is used only when dmac mode is enabled */ + soc->num_rx_refill_buf_rings = 1; } qdf_size_t dp_get_context_size_be(enum dp_context_type context_type) @@ -607,6 +610,10 @@ dp_rxdma_ring_sel_cfg_be(struct dp_soc *soc) pdev->pdev_id); rx_mac_srng = dp_get_rxdma_ring(pdev, lmac_id); + + if (!rx_mac_srng->hal_srng) + continue; + htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev, rx_mac_srng->hal_srng, RXDMA_BUF, RX_DATA_BUFFER_SIZE, @@ -896,22 +903,87 @@ static QDF_STATUS dp_soc_ppe_srng_init(struct dp_soc *soc) static void dp_soc_srng_deinit_be(struct dp_soc *soc) { + uint32_t i; + dp_soc_ppe_srng_deinit(soc); + + if (hal_dmac_cmn_src_rxbuf_ring_get(soc->hal_soc)) { + for (i = 0; i < soc->num_rx_refill_buf_rings; i++) { + dp_srng_deinit(soc, &soc->rx_refill_buf_ring[i], + RXDMA_BUF, 0); + } + } } static void dp_soc_srng_free_be(struct dp_soc *soc) { + uint32_t i; + dp_soc_ppe_srng_free(soc); + + if (hal_dmac_cmn_src_rxbuf_ring_get(soc->hal_soc)) { + for (i = 0; i < soc->num_rx_refill_buf_rings; i++) + dp_srng_free(soc, &soc->rx_refill_buf_ring[i]); + } } static QDF_STATUS dp_soc_srng_alloc_be(struct dp_soc *soc) { - return dp_soc_ppe_srng_alloc(soc); + struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx; + uint32_t ring_size; + uint32_t i; + + soc_cfg_ctx = soc->wlan_cfg_ctx; + + ring_size = wlan_cfg_get_dp_soc_rxdma_refill_ring_size(soc_cfg_ctx); + if (hal_dmac_cmn_src_rxbuf_ring_get(soc->hal_soc)) { + for (i = 0; i < soc->num_rx_refill_buf_rings; i++) { + if (dp_srng_alloc(soc, &soc->rx_refill_buf_ring[i], + RXDMA_BUF, ring_size, 0)) { + dp_err("%pK: dp_srng_alloc failed refill ring", + soc); + goto fail; + } + } + } + + if (dp_soc_ppe_srng_alloc(soc)) { + dp_err("%pK: ppe rings alloc failed", + soc); + goto fail; + } + + return QDF_STATUS_SUCCESS; +fail: + dp_soc_srng_free_be(soc); + return QDF_STATUS_E_NOMEM; } static QDF_STATUS dp_soc_srng_init_be(struct dp_soc *soc) { - return dp_soc_ppe_srng_init(soc); + int i = 0; + + if (hal_dmac_cmn_src_rxbuf_ring_get(soc->hal_soc)) { + for (i = 0; i < soc->num_rx_refill_buf_rings; i++) { + if (dp_srng_init(soc, &soc->rx_refill_buf_ring[i], + RXDMA_BUF, 0, 0)) { + dp_err("%pK: dp_srng_init failed refill ring", + soc); + goto fail; + } + } + } + + if (dp_soc_ppe_srng_init(soc)) { + dp_err("%pK: ppe rings init failed", + soc); + goto fail; + } + + return QDF_STATUS_SUCCESS; +fail: + dp_soc_srng_deinit_be(soc); + return QDF_STATUS_E_NOMEM; } #ifdef DP_TX_IMPLICIT_RBM_MAPPING diff --git a/dp/wifi3.0/dp_main.c b/dp/wifi3.0/dp_main.c index b8543f4ea0..b32d7ff889 100644 --- a/dp/wifi3.0/dp_main.c +++ b/dp/wifi3.0/dp_main.c @@ -5513,9 +5513,11 @@ static QDF_STATUS dp_rxdma_ring_config(struct dp_soc *soc) mac_for_pdev = i; lmac_id = dp_get_lmac_id_for_pdev_id(soc, 0, i); - htt_srng_setup(soc->htt_handle, mac_for_pdev, - soc->rx_refill_buf_ring[lmac_id]. - hal_srng, RXDMA_BUF); + if (soc->rx_refill_buf_ring[lmac_id].hal_srng) + htt_srng_setup(soc->htt_handle, mac_for_pdev, + soc->rx_refill_buf_ring[lmac_id]. + hal_srng, RXDMA_BUF); + /* Configure monitor mode rings */ dp_monitor_htt_srng_setup(soc, pdev, lmac_id, @@ -12044,25 +12046,25 @@ dp_soc_attach(struct cdp_ctrl_objmgr_psoc *ctrl_psoc, goto fail3; } + if (!QDF_IS_STATUS_SUCCESS(soc->arch_ops.txrx_soc_attach(soc))) { + dp_err("unable to do target specific attach"); + goto fail4; + } + if (dp_soc_srng_alloc(soc)) { dp_err("failed to allocate soc srng rings"); - goto fail4; + goto fail5; } if (dp_soc_tx_desc_sw_pools_alloc(soc)) { dp_err("dp_soc_tx_desc_sw_pools_alloc failed"); - goto fail5; - } - - if (!QDF_IS_STATUS_SUCCESS(soc->arch_ops.txrx_soc_attach(soc))) { - dp_err("unable to do target specific attach"); goto fail6; } if (!dp_monitor_modularized_enable()) { if (dp_mon_soc_attach_wrapper(soc)) { dp_err("failed to attach monitor"); - goto fail6; + goto fail7; } } @@ -12081,10 +12083,12 @@ dp_soc_attach(struct cdp_ctrl_objmgr_psoc *ctrl_psoc, qdf_skb_total_mem_stats_read()); return soc; -fail6: +fail7: dp_soc_tx_desc_sw_pools_free(soc); -fail5: +fail6: dp_soc_srng_free(soc); +fail5: + soc->arch_ops.txrx_soc_detach(soc); fail4: dp_hw_link_desc_ring_free(soc); fail3: @@ -12733,8 +12737,10 @@ static void dp_pdev_srng_deinit(struct dp_pdev *pdev) struct dp_soc *soc = pdev->soc; uint8_t i; - dp_srng_deinit(soc, &soc->rx_refill_buf_ring[pdev->lmac_id], RXDMA_BUF, - pdev->lmac_id); + if (!hal_dmac_cmn_src_rxbuf_ring_get(soc->hal_soc)) + dp_srng_deinit(soc, &soc->rx_refill_buf_ring[pdev->lmac_id], + RXDMA_BUF, + pdev->lmac_id); if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) { dp_deinit_tx_pair_by_index(soc, IPA_TCL_DATA_RING_IDX); @@ -12777,10 +12783,13 @@ static QDF_STATUS dp_pdev_srng_init(struct dp_pdev *pdev) soc_cfg_ctx = soc->wlan_cfg_ctx; - if (dp_srng_init(soc, &soc->rx_refill_buf_ring[pdev->lmac_id], - RXDMA_BUF, 0, pdev->lmac_id)) { - dp_init_err("%pK: dp_srng_init failed rx refill ring", soc); - goto fail1; + if (!hal_dmac_cmn_src_rxbuf_ring_get(soc->hal_soc)) { + if (dp_srng_init(soc, &soc->rx_refill_buf_ring[pdev->lmac_id], + RXDMA_BUF, 0, pdev->lmac_id)) { + dp_init_err("%pK: dp_srng_init failed rx refill ring", + soc); + goto fail1; + } } if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) { @@ -12837,7 +12846,8 @@ static void dp_pdev_srng_free(struct dp_pdev *pdev) struct dp_soc *soc = pdev->soc; uint8_t i; - dp_srng_free(soc, &soc->rx_refill_buf_ring[pdev->lmac_id]); + if (!hal_dmac_cmn_src_rxbuf_ring_get(soc->hal_soc)) + dp_srng_free(soc, &soc->rx_refill_buf_ring[pdev->lmac_id]); if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) { dp_free_tx_ring_pair_by_index(soc, IPA_TCL_DATA_RING_IDX); @@ -12872,10 +12882,13 @@ static QDF_STATUS dp_pdev_srng_alloc(struct dp_pdev *pdev) soc_cfg_ctx = soc->wlan_cfg_ctx; ring_size = wlan_cfg_get_dp_soc_rxdma_refill_ring_size(soc_cfg_ctx); - if (dp_srng_alloc(soc, &soc->rx_refill_buf_ring[pdev->lmac_id], - RXDMA_BUF, ring_size, 0)) { - dp_init_err("%pK: dp_srng_alloc failed rx refill ring", soc); - goto fail1; + if (!hal_dmac_cmn_src_rxbuf_ring_get(soc->hal_soc)) { + if (dp_srng_alloc(soc, &soc->rx_refill_buf_ring[pdev->lmac_id], + RXDMA_BUF, ring_size, 0)) { + dp_init_err("%pK: dp_srng_alloc failed rx refill ring", + soc); + goto fail1; + } } if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) { diff --git a/dp/wifi3.0/dp_types.h b/dp/wifi3.0/dp_types.h index 7afe9e154a..eb540d4f7b 100644 --- a/dp/wifi3.0/dp_types.h +++ b/dp/wifi3.0/dp_types.h @@ -2175,6 +2175,9 @@ struct dp_soc { #endif uint8_t rxdma2sw_rings_not_supported:1, mec_fw_offload:1; + + /* Number of Rx refill rings */ + uint8_t num_rx_refill_buf_rings; }; #ifdef IPA_OFFLOAD diff --git a/hal/wifi3.0/hal_api.h b/hal/wifi3.0/hal_api.h index 24bdf86b75..0871e660b9 100644 --- a/hal/wifi3.0/hal_api.h +++ b/hal/wifi3.0/hal_api.h @@ -2961,4 +2961,12 @@ hal_cmem_write(hal_soc_handle_t hal_soc_hdl, uint32_t offset, return; } + +static inline bool +hal_dmac_cmn_src_rxbuf_ring_get(hal_soc_handle_t hal_soc_hdl) +{ + struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl; + + return hal_soc->dmac_cmn_src_rxbuf_ring; +} #endif /* _HAL_APIH_ */