xref: /wlan-driver/qca-wifi-host-cmn/dp/wifi3.0/dp_rings_main.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name  * above copyright notice and this permission notice appear in all
8*5113495bSYour Name  * copies.
9*5113495bSYour Name  *
10*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name  */
19*5113495bSYour Name 
20*5113495bSYour Name #include <wlan_ipa_obj_mgmt_api.h>
21*5113495bSYour Name #include <qdf_types.h>
22*5113495bSYour Name #include <qdf_lock.h>
23*5113495bSYour Name #include <qdf_net_types.h>
24*5113495bSYour Name #include <qdf_lro.h>
25*5113495bSYour Name #include <qdf_module.h>
26*5113495bSYour Name #include <hal_hw_headers.h>
27*5113495bSYour Name #include <hal_api.h>
28*5113495bSYour Name #include <hif.h>
29*5113495bSYour Name #include <htt.h>
30*5113495bSYour Name #include <wdi_event.h>
31*5113495bSYour Name #include <queue.h>
32*5113495bSYour Name #include "dp_types.h"
33*5113495bSYour Name #include "dp_rings.h"
34*5113495bSYour Name #include "dp_internal.h"
35*5113495bSYour Name #include "dp_tx.h"
36*5113495bSYour Name #include "dp_tx_desc.h"
37*5113495bSYour Name #include "dp_rx.h"
38*5113495bSYour Name #ifdef DP_RATETABLE_SUPPORT
39*5113495bSYour Name #include "dp_ratetable.h"
40*5113495bSYour Name #endif
41*5113495bSYour Name #include <cdp_txrx_handle.h>
42*5113495bSYour Name #include <wlan_cfg.h>
43*5113495bSYour Name #include <wlan_utility.h>
44*5113495bSYour Name #include "cdp_txrx_cmn_struct.h"
45*5113495bSYour Name #include "cdp_txrx_stats_struct.h"
46*5113495bSYour Name #include "cdp_txrx_cmn_reg.h"
47*5113495bSYour Name #include <qdf_util.h>
48*5113495bSYour Name #include "dp_peer.h"
49*5113495bSYour Name #include "htt_stats.h"
50*5113495bSYour Name #include "dp_htt.h"
51*5113495bSYour Name #include "htt_ppdu_stats.h"
52*5113495bSYour Name #include "qdf_mem.h"   /* qdf_mem_malloc,free */
53*5113495bSYour Name #include "cfg_ucfg_api.h"
54*5113495bSYour Name #include <wlan_module_ids.h>
55*5113495bSYour Name 
56*5113495bSYour Name #ifdef WIFI_MONITOR_SUPPORT
57*5113495bSYour Name #include <dp_mon.h>
58*5113495bSYour Name #endif
59*5113495bSYour Name #include "qdf_ssr_driver_dump.h"
60*5113495bSYour Name 
61*5113495bSYour Name #ifdef WLAN_FEATURE_STATS_EXT
62*5113495bSYour Name #define INIT_RX_HW_STATS_LOCK(_soc) \
63*5113495bSYour Name 	qdf_spinlock_create(&(_soc)->rx_hw_stats_lock)
64*5113495bSYour Name #define DEINIT_RX_HW_STATS_LOCK(_soc) \
65*5113495bSYour Name 	qdf_spinlock_destroy(&(_soc)->rx_hw_stats_lock)
66*5113495bSYour Name #else
67*5113495bSYour Name #define INIT_RX_HW_STATS_LOCK(_soc)  /* no op */
68*5113495bSYour Name #define DEINIT_RX_HW_STATS_LOCK(_soc) /* no op */
69*5113495bSYour Name #endif
70*5113495bSYour Name 
71*5113495bSYour Name static QDF_STATUS dp_init_tx_ring_pair_by_index(struct dp_soc *soc,
72*5113495bSYour Name 						uint8_t index);
73*5113495bSYour Name static void dp_deinit_tx_pair_by_index(struct dp_soc *soc, int index);
74*5113495bSYour Name static void dp_free_tx_ring_pair_by_index(struct dp_soc *soc, uint8_t index);
75*5113495bSYour Name static QDF_STATUS dp_alloc_tx_ring_pair_by_index(struct dp_soc *soc,
76*5113495bSYour Name 						 uint8_t index);
77*5113495bSYour Name 
78*5113495bSYour Name /* default_dscp_tid_map - Default DSCP-TID mapping
79*5113495bSYour Name  *
80*5113495bSYour Name  * DSCP        TID
81*5113495bSYour Name  * 000000      0
82*5113495bSYour Name  * 001000      1
83*5113495bSYour Name  * 010000      2
84*5113495bSYour Name  * 011000      3
85*5113495bSYour Name  * 100000      4
86*5113495bSYour Name  * 101000      5
87*5113495bSYour Name  * 110000      6
88*5113495bSYour Name  * 111000      7
89*5113495bSYour Name  */
90*5113495bSYour Name static uint8_t default_dscp_tid_map[DSCP_TID_MAP_MAX] = {
91*5113495bSYour Name 	0, 0, 0, 0, 0, 0, 0, 0,
92*5113495bSYour Name 	1, 1, 1, 1, 1, 1, 1, 1,
93*5113495bSYour Name 	2, 2, 2, 2, 2, 2, 2, 2,
94*5113495bSYour Name 	3, 3, 3, 3, 3, 3, 3, 3,
95*5113495bSYour Name 	4, 4, 4, 4, 4, 4, 4, 4,
96*5113495bSYour Name 	5, 5, 5, 5, 5, 5, 5, 5,
97*5113495bSYour Name 	6, 6, 6, 6, 6, 6, 6, 6,
98*5113495bSYour Name 	7, 7, 7, 7, 7, 7, 7, 7,
99*5113495bSYour Name };
100*5113495bSYour Name 
101*5113495bSYour Name /* default_pcp_tid_map - Default PCP-TID mapping
102*5113495bSYour Name  *
103*5113495bSYour Name  * PCP     TID
104*5113495bSYour Name  * 000      0
105*5113495bSYour Name  * 001      1
106*5113495bSYour Name  * 010      2
107*5113495bSYour Name  * 011      3
108*5113495bSYour Name  * 100      4
109*5113495bSYour Name  * 101      5
110*5113495bSYour Name  * 110      6
111*5113495bSYour Name  * 111      7
112*5113495bSYour Name  */
113*5113495bSYour Name static uint8_t default_pcp_tid_map[PCP_TID_MAP_MAX] = {
114*5113495bSYour Name 	0, 1, 2, 3, 4, 5, 6, 7,
115*5113495bSYour Name };
116*5113495bSYour Name 
117*5113495bSYour Name uint8_t
118*5113495bSYour Name dp_cpu_ring_map[DP_NSS_CPU_RING_MAP_MAX][WLAN_CFG_INT_NUM_CONTEXTS_MAX] = {
119*5113495bSYour Name 	{0x0, 0x1, 0x2, 0x0, 0x0, 0x1, 0x2, 0x0, 0x0, 0x1, 0x2},
120*5113495bSYour Name 	{0x1, 0x2, 0x1, 0x2, 0x1, 0x2, 0x1, 0x2, 0x1, 0x2, 0x1},
121*5113495bSYour Name 	{0x0, 0x2, 0x0, 0x2, 0x0, 0x2, 0x0, 0x2, 0x0, 0x2, 0x0},
122*5113495bSYour Name 	{0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2},
123*5113495bSYour Name 	{0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3},
124*5113495bSYour Name #ifdef WLAN_TX_PKT_CAPTURE_ENH
125*5113495bSYour Name 	{0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1}
126*5113495bSYour Name #endif
127*5113495bSYour Name };
128*5113495bSYour Name 
129*5113495bSYour Name qdf_export_symbol(dp_cpu_ring_map);
130*5113495bSYour Name 
131*5113495bSYour Name /**
132*5113495bSYour Name  * dp_soc_ring_if_nss_offloaded() - find if ring is offloaded to NSS
133*5113495bSYour Name  * @soc: DP soc handle
134*5113495bSYour Name  * @ring_type: ring type
135*5113495bSYour Name  * @ring_num: ring_num
136*5113495bSYour Name  *
137*5113495bSYour Name  * Return: 0 if the ring is not offloaded, non-0 if it is offloaded
138*5113495bSYour Name  */
dp_soc_ring_if_nss_offloaded(struct dp_soc * soc,enum hal_ring_type ring_type,int ring_num)139*5113495bSYour Name static uint8_t dp_soc_ring_if_nss_offloaded(struct dp_soc *soc,
140*5113495bSYour Name 					    enum hal_ring_type ring_type,
141*5113495bSYour Name 					    int ring_num)
142*5113495bSYour Name {
143*5113495bSYour Name 	uint8_t nss_config = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
144*5113495bSYour Name 	uint8_t status = 0;
145*5113495bSYour Name 
146*5113495bSYour Name 	switch (ring_type) {
147*5113495bSYour Name 	case WBM2SW_RELEASE:
148*5113495bSYour Name 	case REO_DST:
149*5113495bSYour Name 	case RXDMA_BUF:
150*5113495bSYour Name 	case REO_EXCEPTION:
151*5113495bSYour Name 		status = ((nss_config) & (1 << ring_num));
152*5113495bSYour Name 		break;
153*5113495bSYour Name 	default:
154*5113495bSYour Name 		break;
155*5113495bSYour Name 	}
156*5113495bSYour Name 
157*5113495bSYour Name 	return status;
158*5113495bSYour Name }
159*5113495bSYour Name 
160*5113495bSYour Name #if !defined(DP_CON_MON)
dp_soc_reset_mon_intr_mask(struct dp_soc * soc)161*5113495bSYour Name void dp_soc_reset_mon_intr_mask(struct dp_soc *soc)
162*5113495bSYour Name {
163*5113495bSYour Name 	int i;
164*5113495bSYour Name 
165*5113495bSYour Name 	for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
166*5113495bSYour Name 		soc->intr_ctx[i].rx_mon_ring_mask = 0;
167*5113495bSYour Name 		soc->intr_ctx[i].host2rxdma_mon_ring_mask = 0;
168*5113495bSYour Name 	}
169*5113495bSYour Name }
170*5113495bSYour Name 
171*5113495bSYour Name qdf_export_symbol(dp_soc_reset_mon_intr_mask);
172*5113495bSYour Name 
dp_service_lmac_rings(void * arg)173*5113495bSYour Name void dp_service_lmac_rings(void *arg)
174*5113495bSYour Name {
175*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)arg;
176*5113495bSYour Name 	int ring = 0, i;
177*5113495bSYour Name 	struct dp_pdev *pdev = NULL;
178*5113495bSYour Name 	union dp_rx_desc_list_elem_t *desc_list = NULL;
179*5113495bSYour Name 	union dp_rx_desc_list_elem_t *tail = NULL;
180*5113495bSYour Name 
181*5113495bSYour Name 	/* Process LMAC interrupts */
182*5113495bSYour Name 	for  (ring = 0 ; ring < MAX_NUM_LMAC_HW; ring++) {
183*5113495bSYour Name 		int mac_for_pdev = ring;
184*5113495bSYour Name 		struct dp_srng *rx_refill_buf_ring;
185*5113495bSYour Name 
186*5113495bSYour Name 		pdev = dp_get_pdev_for_lmac_id(soc, mac_for_pdev);
187*5113495bSYour Name 		if (!pdev)
188*5113495bSYour Name 			continue;
189*5113495bSYour Name 
190*5113495bSYour Name 		rx_refill_buf_ring = &soc->rx_refill_buf_ring[mac_for_pdev];
191*5113495bSYour Name 
192*5113495bSYour Name 		dp_monitor_process(soc, NULL, mac_for_pdev,
193*5113495bSYour Name 				   QCA_NAPI_BUDGET);
194*5113495bSYour Name 
195*5113495bSYour Name 		for (i = 0;
196*5113495bSYour Name 		     i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++)
197*5113495bSYour Name 			dp_rxdma_err_process(&soc->intr_ctx[i], soc,
198*5113495bSYour Name 					     mac_for_pdev,
199*5113495bSYour Name 					     QCA_NAPI_BUDGET);
200*5113495bSYour Name 
201*5113495bSYour Name 		if (!dp_soc_ring_if_nss_offloaded(soc, RXDMA_BUF,
202*5113495bSYour Name 						  mac_for_pdev))
203*5113495bSYour Name 			dp_rx_buffers_replenish(soc, mac_for_pdev,
204*5113495bSYour Name 						rx_refill_buf_ring,
205*5113495bSYour Name 						&soc->rx_desc_buf[mac_for_pdev],
206*5113495bSYour Name 						0, &desc_list, &tail, false);
207*5113495bSYour Name 	}
208*5113495bSYour Name 
209*5113495bSYour Name 	qdf_timer_mod(&soc->lmac_reap_timer, DP_INTR_POLL_TIMER_MS);
210*5113495bSYour Name }
211*5113495bSYour Name 
212*5113495bSYour Name #endif
213*5113495bSYour Name 
214*5113495bSYour Name #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
215*5113495bSYour Name /**
216*5113495bSYour Name  * dp_is_reo_ring_num_in_nf_grp1() - Check if the current reo ring is part of
217*5113495bSYour Name  *				rx_near_full_grp1 mask
218*5113495bSYour Name  * @soc: Datapath SoC Handle
219*5113495bSYour Name  * @ring_num: REO ring number
220*5113495bSYour Name  *
221*5113495bSYour Name  * Return: 1 if the ring_num belongs to reo_nf_grp1,
222*5113495bSYour Name  *	   0, otherwise.
223*5113495bSYour Name  */
224*5113495bSYour Name static inline int
dp_is_reo_ring_num_in_nf_grp1(struct dp_soc * soc,int ring_num)225*5113495bSYour Name dp_is_reo_ring_num_in_nf_grp1(struct dp_soc *soc, int ring_num)
226*5113495bSYour Name {
227*5113495bSYour Name 	return (WLAN_CFG_RX_NEAR_FULL_IRQ_MASK_1 & (1 << ring_num));
228*5113495bSYour Name }
229*5113495bSYour Name 
230*5113495bSYour Name /**
231*5113495bSYour Name  * dp_is_reo_ring_num_in_nf_grp2() - Check if the current reo ring is part of
232*5113495bSYour Name  *				rx_near_full_grp2 mask
233*5113495bSYour Name  * @soc: Datapath SoC Handle
234*5113495bSYour Name  * @ring_num: REO ring number
235*5113495bSYour Name  *
236*5113495bSYour Name  * Return: 1 if the ring_num belongs to reo_nf_grp2,
237*5113495bSYour Name  *	   0, otherwise.
238*5113495bSYour Name  */
239*5113495bSYour Name static inline int
dp_is_reo_ring_num_in_nf_grp2(struct dp_soc * soc,int ring_num)240*5113495bSYour Name dp_is_reo_ring_num_in_nf_grp2(struct dp_soc *soc, int ring_num)
241*5113495bSYour Name {
242*5113495bSYour Name 	return (WLAN_CFG_RX_NEAR_FULL_IRQ_MASK_2 & (1 << ring_num));
243*5113495bSYour Name }
244*5113495bSYour Name 
245*5113495bSYour Name /**
246*5113495bSYour Name  * dp_srng_get_near_full_irq_mask() - Get near-full irq mask for a particular
247*5113495bSYour Name  *				ring type and number
248*5113495bSYour Name  * @soc: Datapath SoC handle
249*5113495bSYour Name  * @ring_type: SRNG type
250*5113495bSYour Name  * @ring_num: ring num
251*5113495bSYour Name  *
252*5113495bSYour Name  * Return: near-full irq mask pointer
253*5113495bSYour Name  */
dp_srng_get_near_full_irq_mask(struct dp_soc * soc,enum hal_ring_type ring_type,int ring_num)254*5113495bSYour Name uint8_t *dp_srng_get_near_full_irq_mask(struct dp_soc *soc,
255*5113495bSYour Name 					enum hal_ring_type ring_type,
256*5113495bSYour Name 					int ring_num)
257*5113495bSYour Name {
258*5113495bSYour Name 	struct wlan_cfg_dp_soc_ctxt *cfg_ctx = soc->wlan_cfg_ctx;
259*5113495bSYour Name 	uint8_t wbm2_sw_rx_rel_ring_id;
260*5113495bSYour Name 	uint8_t *nf_irq_mask = NULL;
261*5113495bSYour Name 
262*5113495bSYour Name 	switch (ring_type) {
263*5113495bSYour Name 	case WBM2SW_RELEASE:
264*5113495bSYour Name 		wbm2_sw_rx_rel_ring_id =
265*5113495bSYour Name 			wlan_cfg_get_rx_rel_ring_id(cfg_ctx);
266*5113495bSYour Name 		if (ring_num != wbm2_sw_rx_rel_ring_id) {
267*5113495bSYour Name 			nf_irq_mask = &soc->wlan_cfg_ctx->
268*5113495bSYour Name 					int_tx_ring_near_full_irq_mask[0];
269*5113495bSYour Name 		}
270*5113495bSYour Name 		break;
271*5113495bSYour Name 	case REO_DST:
272*5113495bSYour Name 		if (dp_is_reo_ring_num_in_nf_grp1(soc, ring_num))
273*5113495bSYour Name 			nf_irq_mask =
274*5113495bSYour Name 			&soc->wlan_cfg_ctx->int_rx_ring_near_full_irq_1_mask[0];
275*5113495bSYour Name 		else if (dp_is_reo_ring_num_in_nf_grp2(soc, ring_num))
276*5113495bSYour Name 			nf_irq_mask =
277*5113495bSYour Name 			&soc->wlan_cfg_ctx->int_rx_ring_near_full_irq_2_mask[0];
278*5113495bSYour Name 		else
279*5113495bSYour Name 			qdf_assert(0);
280*5113495bSYour Name 		break;
281*5113495bSYour Name 	default:
282*5113495bSYour Name 		break;
283*5113495bSYour Name 	}
284*5113495bSYour Name 
285*5113495bSYour Name 	return nf_irq_mask;
286*5113495bSYour Name }
287*5113495bSYour Name 
288*5113495bSYour Name /**
289*5113495bSYour Name  * dp_srng_set_msi2_ring_params() - Set the msi2 addr/data in the ring params
290*5113495bSYour Name  * @soc: Datapath SoC handle
291*5113495bSYour Name  * @ring_params: srng params handle
292*5113495bSYour Name  * @msi2_addr: MSI2 addr to be set for the SRNG
293*5113495bSYour Name  * @msi2_data: MSI2 data to be set for the SRNG
294*5113495bSYour Name  *
295*5113495bSYour Name  * Return: None
296*5113495bSYour Name  */
dp_srng_set_msi2_ring_params(struct dp_soc * soc,struct hal_srng_params * ring_params,qdf_dma_addr_t msi2_addr,uint32_t msi2_data)297*5113495bSYour Name void dp_srng_set_msi2_ring_params(struct dp_soc *soc,
298*5113495bSYour Name 				  struct hal_srng_params *ring_params,
299*5113495bSYour Name 				  qdf_dma_addr_t msi2_addr,
300*5113495bSYour Name 				  uint32_t msi2_data)
301*5113495bSYour Name {
302*5113495bSYour Name 	ring_params->msi2_addr = msi2_addr;
303*5113495bSYour Name 	ring_params->msi2_data = msi2_data;
304*5113495bSYour Name }
305*5113495bSYour Name 
306*5113495bSYour Name /**
307*5113495bSYour Name  * dp_srng_msi2_setup() - Setup MSI2 details for near full IRQ of an SRNG
308*5113495bSYour Name  * @soc: Datapath SoC handle
309*5113495bSYour Name  * @ring_params: ring_params for SRNG
310*5113495bSYour Name  * @ring_type: SENG type
311*5113495bSYour Name  * @ring_num: ring number for the SRNG
312*5113495bSYour Name  * @nf_msi_grp_num: near full msi group number
313*5113495bSYour Name  *
314*5113495bSYour Name  * Return: None
315*5113495bSYour Name  */
dp_srng_msi2_setup(struct dp_soc * soc,struct hal_srng_params * ring_params,int ring_type,int ring_num,int nf_msi_grp_num)316*5113495bSYour Name void dp_srng_msi2_setup(struct dp_soc *soc,
317*5113495bSYour Name 			struct hal_srng_params *ring_params,
318*5113495bSYour Name 			int ring_type, int ring_num, int nf_msi_grp_num)
319*5113495bSYour Name {
320*5113495bSYour Name 	uint32_t msi_data_start, msi_irq_start, addr_low, addr_high;
321*5113495bSYour Name 	int msi_data_count, ret;
322*5113495bSYour Name 
323*5113495bSYour Name 	ret = pld_get_user_msi_assignment(soc->osdev->dev, "DP",
324*5113495bSYour Name 					  &msi_data_count, &msi_data_start,
325*5113495bSYour Name 					  &msi_irq_start);
326*5113495bSYour Name 	if (ret)
327*5113495bSYour Name 		return;
328*5113495bSYour Name 
329*5113495bSYour Name 	if (nf_msi_grp_num < 0) {
330*5113495bSYour Name 		dp_init_info("%pK: ring near full IRQ not part of an ext_group; ring_type: %d,ring_num %d",
331*5113495bSYour Name 			     soc, ring_type, ring_num);
332*5113495bSYour Name 		ring_params->msi2_addr = 0;
333*5113495bSYour Name 		ring_params->msi2_data = 0;
334*5113495bSYour Name 		return;
335*5113495bSYour Name 	}
336*5113495bSYour Name 
337*5113495bSYour Name 	if (dp_is_msi_group_number_invalid(soc, nf_msi_grp_num,
338*5113495bSYour Name 					   msi_data_count)) {
339*5113495bSYour Name 		dp_init_warn("%pK: 2 msi_groups will share an msi for near full IRQ; msi_group_num %d",
340*5113495bSYour Name 			     soc, nf_msi_grp_num);
341*5113495bSYour Name 		QDF_ASSERT(0);
342*5113495bSYour Name 	}
343*5113495bSYour Name 
344*5113495bSYour Name 	pld_get_msi_address(soc->osdev->dev, &addr_low, &addr_high);
345*5113495bSYour Name 
346*5113495bSYour Name 	ring_params->nf_irq_support = 1;
347*5113495bSYour Name 	ring_params->msi2_addr = addr_low;
348*5113495bSYour Name 	ring_params->msi2_addr |= (qdf_dma_addr_t)(((uint64_t)addr_high) << 32);
349*5113495bSYour Name 	ring_params->msi2_data = (nf_msi_grp_num % msi_data_count)
350*5113495bSYour Name 		+ msi_data_start;
351*5113495bSYour Name 	ring_params->flags |= HAL_SRNG_MSI_INTR;
352*5113495bSYour Name }
353*5113495bSYour Name 
354*5113495bSYour Name /* Percentage of ring entries considered as nearly full */
355*5113495bSYour Name #define DP_NF_HIGH_THRESH_PERCENTAGE	75
356*5113495bSYour Name /* Percentage of ring entries considered as critically full */
357*5113495bSYour Name #define DP_NF_CRIT_THRESH_PERCENTAGE	90
358*5113495bSYour Name /* Percentage of ring entries considered as safe threshold */
359*5113495bSYour Name #define DP_NF_SAFE_THRESH_PERCENTAGE	50
360*5113495bSYour Name 
361*5113495bSYour Name /**
362*5113495bSYour Name  * dp_srng_configure_nf_interrupt_thresholds() - Configure the thresholds for
363*5113495bSYour Name  *			near full irq
364*5113495bSYour Name  * @soc: Datapath SoC handle
365*5113495bSYour Name  * @ring_params: ring params for SRNG
366*5113495bSYour Name  * @ring_type: ring type
367*5113495bSYour Name  */
368*5113495bSYour Name void
dp_srng_configure_nf_interrupt_thresholds(struct dp_soc * soc,struct hal_srng_params * ring_params,int ring_type)369*5113495bSYour Name dp_srng_configure_nf_interrupt_thresholds(struct dp_soc *soc,
370*5113495bSYour Name 					  struct hal_srng_params *ring_params,
371*5113495bSYour Name 					  int ring_type)
372*5113495bSYour Name {
373*5113495bSYour Name 	if (ring_params->nf_irq_support) {
374*5113495bSYour Name 		ring_params->high_thresh = (ring_params->num_entries *
375*5113495bSYour Name 					    DP_NF_HIGH_THRESH_PERCENTAGE) / 100;
376*5113495bSYour Name 		ring_params->crit_thresh = (ring_params->num_entries *
377*5113495bSYour Name 					    DP_NF_CRIT_THRESH_PERCENTAGE) / 100;
378*5113495bSYour Name 		ring_params->safe_thresh = (ring_params->num_entries *
379*5113495bSYour Name 					    DP_NF_SAFE_THRESH_PERCENTAGE) /100;
380*5113495bSYour Name 	}
381*5113495bSYour Name }
382*5113495bSYour Name 
383*5113495bSYour Name /**
384*5113495bSYour Name  * dp_srng_set_nf_thresholds() - Set the near full thresholds to srng data
385*5113495bSYour Name  *			structure from the ring params
386*5113495bSYour Name  * @soc: Datapath SoC handle
387*5113495bSYour Name  * @srng: SRNG handle
388*5113495bSYour Name  * @ring_params: ring params for a SRNG
389*5113495bSYour Name  *
390*5113495bSYour Name  * Return: None
391*5113495bSYour Name  */
392*5113495bSYour Name static inline void
dp_srng_set_nf_thresholds(struct dp_soc * soc,struct dp_srng * srng,struct hal_srng_params * ring_params)393*5113495bSYour Name dp_srng_set_nf_thresholds(struct dp_soc *soc, struct dp_srng *srng,
394*5113495bSYour Name 			  struct hal_srng_params *ring_params)
395*5113495bSYour Name {
396*5113495bSYour Name 	srng->crit_thresh = ring_params->crit_thresh;
397*5113495bSYour Name 	srng->safe_thresh = ring_params->safe_thresh;
398*5113495bSYour Name }
399*5113495bSYour Name 
400*5113495bSYour Name #else
401*5113495bSYour Name static inline void
dp_srng_set_nf_thresholds(struct dp_soc * soc,struct dp_srng * srng,struct hal_srng_params * ring_params)402*5113495bSYour Name dp_srng_set_nf_thresholds(struct dp_soc *soc, struct dp_srng *srng,
403*5113495bSYour Name 			  struct hal_srng_params *ring_params)
404*5113495bSYour Name {
405*5113495bSYour Name }
406*5113495bSYour Name #endif
407*5113495bSYour Name 
408*5113495bSYour Name /**
409*5113495bSYour Name  * dp_get_num_msi_available()- API to get number of MSIs available
410*5113495bSYour Name  * @soc: DP soc Handle
411*5113495bSYour Name  * @interrupt_mode: Mode of interrupts
412*5113495bSYour Name  *
413*5113495bSYour Name  * Return: Number of MSIs available or 0 in case of integrated
414*5113495bSYour Name  */
415*5113495bSYour Name #if defined(WLAN_MAX_PDEVS) && (WLAN_MAX_PDEVS == 1)
dp_get_num_msi_available(struct dp_soc * soc,int interrupt_mode)416*5113495bSYour Name static int dp_get_num_msi_available(struct dp_soc *soc, int interrupt_mode)
417*5113495bSYour Name {
418*5113495bSYour Name 	return 0;
419*5113495bSYour Name }
420*5113495bSYour Name #else
dp_get_num_msi_available(struct dp_soc * soc,int interrupt_mode)421*5113495bSYour Name static int dp_get_num_msi_available(struct dp_soc *soc, int interrupt_mode)
422*5113495bSYour Name {
423*5113495bSYour Name 	int msi_data_count;
424*5113495bSYour Name 	int msi_data_start;
425*5113495bSYour Name 	int msi_irq_start;
426*5113495bSYour Name 	int ret;
427*5113495bSYour Name 
428*5113495bSYour Name 	if (interrupt_mode == DP_INTR_INTEGRATED) {
429*5113495bSYour Name 		return 0;
430*5113495bSYour Name 	} else if (interrupt_mode == DP_INTR_MSI || interrupt_mode ==
431*5113495bSYour Name 		   DP_INTR_POLL) {
432*5113495bSYour Name 		ret = pld_get_user_msi_assignment(soc->osdev->dev, "DP",
433*5113495bSYour Name 						  &msi_data_count,
434*5113495bSYour Name 						  &msi_data_start,
435*5113495bSYour Name 						  &msi_irq_start);
436*5113495bSYour Name 		if (ret) {
437*5113495bSYour Name 			qdf_err("Unable to get DP MSI assignment %d",
438*5113495bSYour Name 				interrupt_mode);
439*5113495bSYour Name 			return -EINVAL;
440*5113495bSYour Name 		}
441*5113495bSYour Name 		return msi_data_count;
442*5113495bSYour Name 	}
443*5113495bSYour Name 	qdf_err("Interrupt mode invalid %d", interrupt_mode);
444*5113495bSYour Name 	return -EINVAL;
445*5113495bSYour Name }
446*5113495bSYour Name #endif
447*5113495bSYour Name 
448*5113495bSYour Name /**
449*5113495bSYour Name  * dp_srng_configure_pointer_update_thresholds() - Retrieve pointer
450*5113495bSYour Name  * update threshold value from wlan_cfg_ctx
451*5113495bSYour Name  * @soc: device handle
452*5113495bSYour Name  * @ring_params: per ring specific parameters
453*5113495bSYour Name  * @ring_type: Ring type
454*5113495bSYour Name  * @ring_num: Ring number for a given ring type
455*5113495bSYour Name  * @num_entries: number of entries to fill
456*5113495bSYour Name  *
457*5113495bSYour Name  * Fill the ring params with the pointer update threshold
458*5113495bSYour Name  * configuration parameters available in wlan_cfg_ctx
459*5113495bSYour Name  *
460*5113495bSYour Name  * Return: None
461*5113495bSYour Name  */
462*5113495bSYour Name static void
dp_srng_configure_pointer_update_thresholds(struct dp_soc * soc,struct hal_srng_params * ring_params,int ring_type,int ring_num,int num_entries)463*5113495bSYour Name dp_srng_configure_pointer_update_thresholds(
464*5113495bSYour Name 				struct dp_soc *soc,
465*5113495bSYour Name 				struct hal_srng_params *ring_params,
466*5113495bSYour Name 				int ring_type, int ring_num,
467*5113495bSYour Name 				int num_entries)
468*5113495bSYour Name {
469*5113495bSYour Name 	if (ring_type == REO_DST) {
470*5113495bSYour Name 		ring_params->pointer_timer_threshold =
471*5113495bSYour Name 			wlan_cfg_get_pointer_timer_threshold_rx(
472*5113495bSYour Name 						soc->wlan_cfg_ctx);
473*5113495bSYour Name 		ring_params->pointer_num_threshold =
474*5113495bSYour Name 			wlan_cfg_get_pointer_num_threshold_rx(
475*5113495bSYour Name 						soc->wlan_cfg_ctx);
476*5113495bSYour Name 	}
477*5113495bSYour Name }
478*5113495bSYour Name 
dp_srng_init_idx(struct dp_soc * soc,struct dp_srng * srng,int ring_type,int ring_num,int mac_id,uint32_t idx)479*5113495bSYour Name QDF_STATUS dp_srng_init_idx(struct dp_soc *soc, struct dp_srng *srng,
480*5113495bSYour Name 			    int ring_type, int ring_num, int mac_id,
481*5113495bSYour Name 			    uint32_t idx)
482*5113495bSYour Name {
483*5113495bSYour Name 	bool idle_check;
484*5113495bSYour Name 
485*5113495bSYour Name 	hal_soc_handle_t hal_soc = soc->hal_soc;
486*5113495bSYour Name 	struct hal_srng_params ring_params;
487*5113495bSYour Name 
488*5113495bSYour Name 	if (srng->hal_srng) {
489*5113495bSYour Name 		dp_init_err("%pK: Ring type: %d, num:%d is already initialized",
490*5113495bSYour Name 			    soc, ring_type, ring_num);
491*5113495bSYour Name 		return QDF_STATUS_SUCCESS;
492*5113495bSYour Name 	}
493*5113495bSYour Name 
494*5113495bSYour Name 	/* memset the srng ring to zero */
495*5113495bSYour Name 	qdf_mem_zero(srng->base_vaddr_unaligned, srng->alloc_size);
496*5113495bSYour Name 
497*5113495bSYour Name 	qdf_mem_zero(&ring_params, sizeof(struct hal_srng_params));
498*5113495bSYour Name 	ring_params.ring_base_paddr = srng->base_paddr_aligned;
499*5113495bSYour Name 	ring_params.ring_base_vaddr = srng->base_vaddr_aligned;
500*5113495bSYour Name 
501*5113495bSYour Name 	ring_params.num_entries = srng->num_entries;
502*5113495bSYour Name 
503*5113495bSYour Name 	dp_info("Ring type: %d, num:%d vaddr %pK paddr %pK entries %u",
504*5113495bSYour Name 		ring_type, ring_num,
505*5113495bSYour Name 		(void *)ring_params.ring_base_vaddr,
506*5113495bSYour Name 		(void *)ring_params.ring_base_paddr,
507*5113495bSYour Name 		ring_params.num_entries);
508*5113495bSYour Name 
509*5113495bSYour Name 	if (soc->intr_mode == DP_INTR_MSI && !dp_skip_msi_cfg(soc, ring_type)) {
510*5113495bSYour Name 		dp_srng_msi_setup(soc, srng, &ring_params, ring_type, ring_num);
511*5113495bSYour Name 		dp_verbose_debug("Using MSI for ring_type: %d, ring_num %d",
512*5113495bSYour Name 				 ring_type, ring_num);
513*5113495bSYour Name 	} else {
514*5113495bSYour Name 		ring_params.msi_data = 0;
515*5113495bSYour Name 		ring_params.msi_addr = 0;
516*5113495bSYour Name 		dp_srng_set_msi2_ring_params(soc, &ring_params, 0, 0);
517*5113495bSYour Name 		dp_verbose_debug("Skipping MSI for ring_type: %d, ring_num %d",
518*5113495bSYour Name 				 ring_type, ring_num);
519*5113495bSYour Name 	}
520*5113495bSYour Name 
521*5113495bSYour Name 	dp_srng_configure_interrupt_thresholds(soc, &ring_params,
522*5113495bSYour Name 					       ring_type, ring_num,
523*5113495bSYour Name 					       srng->num_entries);
524*5113495bSYour Name 
525*5113495bSYour Name 	dp_srng_set_nf_thresholds(soc, srng, &ring_params);
526*5113495bSYour Name 	dp_srng_configure_pointer_update_thresholds(soc, &ring_params,
527*5113495bSYour Name 						    ring_type, ring_num,
528*5113495bSYour Name 						    srng->num_entries);
529*5113495bSYour Name 
530*5113495bSYour Name 	if (srng->cached)
531*5113495bSYour Name 		ring_params.flags |= HAL_SRNG_CACHED_DESC;
532*5113495bSYour Name 
533*5113495bSYour Name 	idle_check = dp_check_umac_reset_in_progress(soc);
534*5113495bSYour Name 
535*5113495bSYour Name 	srng->hal_srng = hal_srng_setup_idx(hal_soc, ring_type, ring_num,
536*5113495bSYour Name 					    mac_id, &ring_params, idle_check,
537*5113495bSYour Name 					    idx);
538*5113495bSYour Name 
539*5113495bSYour Name 	if (!srng->hal_srng) {
540*5113495bSYour Name 		dp_srng_free(soc, srng);
541*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
542*5113495bSYour Name 	}
543*5113495bSYour Name 
544*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
545*5113495bSYour Name }
546*5113495bSYour Name 
547*5113495bSYour Name qdf_export_symbol(dp_srng_init_idx);
548*5113495bSYour Name 
549*5113495bSYour Name #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
550*5113495bSYour Name /**
551*5113495bSYour Name  * dp_service_near_full_srngs() - Bottom half handler to process the near
552*5113495bSYour Name  *				full IRQ on a SRNG
553*5113495bSYour Name  * @dp_ctx: Datapath SoC handle
554*5113495bSYour Name  * @dp_budget: Number of SRNGs which can be processed in a single attempt
555*5113495bSYour Name  *		without rescheduling
556*5113495bSYour Name  * @cpu: cpu id
557*5113495bSYour Name  *
558*5113495bSYour Name  * Return: remaining budget/quota for the soc device
559*5113495bSYour Name  */
560*5113495bSYour Name static
dp_service_near_full_srngs(void * dp_ctx,uint32_t dp_budget,int cpu)561*5113495bSYour Name uint32_t dp_service_near_full_srngs(void *dp_ctx, uint32_t dp_budget, int cpu)
562*5113495bSYour Name {
563*5113495bSYour Name 	struct dp_intr *int_ctx = (struct dp_intr *)dp_ctx;
564*5113495bSYour Name 	struct dp_soc *soc = int_ctx->soc;
565*5113495bSYour Name 
566*5113495bSYour Name 	/*
567*5113495bSYour Name 	 * dp_service_near_full_srngs arch ops should be initialized always
568*5113495bSYour Name 	 * if the NEAR FULL IRQ feature is enabled.
569*5113495bSYour Name 	 */
570*5113495bSYour Name 	return soc->arch_ops.dp_service_near_full_srngs(soc, int_ctx,
571*5113495bSYour Name 							dp_budget);
572*5113495bSYour Name }
573*5113495bSYour Name #endif
574*5113495bSYour Name 
575*5113495bSYour Name #ifndef QCA_HOST_MODE_WIFI_DISABLED
576*5113495bSYour Name 
dp_service_srngs(void * dp_ctx,uint32_t dp_budget,int cpu)577*5113495bSYour Name uint32_t dp_service_srngs(void *dp_ctx, uint32_t dp_budget, int cpu)
578*5113495bSYour Name {
579*5113495bSYour Name 	struct dp_intr *int_ctx = (struct dp_intr *)dp_ctx;
580*5113495bSYour Name 	struct dp_intr_stats *intr_stats = &int_ctx->intr_stats;
581*5113495bSYour Name 	struct dp_soc *soc = int_ctx->soc;
582*5113495bSYour Name 	int ring = 0;
583*5113495bSYour Name 	int index;
584*5113495bSYour Name 	uint32_t work_done  = 0;
585*5113495bSYour Name 	int budget = dp_budget;
586*5113495bSYour Name 	uint32_t remaining_quota = dp_budget;
587*5113495bSYour Name 	uint8_t tx_mask = 0;
588*5113495bSYour Name 	uint8_t rx_mask = 0;
589*5113495bSYour Name 	uint8_t rx_err_mask = 0;
590*5113495bSYour Name 	uint8_t rx_wbm_rel_mask = 0;
591*5113495bSYour Name 	uint8_t reo_status_mask = 0;
592*5113495bSYour Name 
593*5113495bSYour Name 	qdf_atomic_set_bit(cpu, &soc->service_rings_running);
594*5113495bSYour Name 
595*5113495bSYour Name 	tx_mask = int_ctx->tx_ring_mask;
596*5113495bSYour Name 	rx_mask = int_ctx->rx_ring_mask;
597*5113495bSYour Name 	rx_err_mask = int_ctx->rx_err_ring_mask;
598*5113495bSYour Name 	rx_wbm_rel_mask = int_ctx->rx_wbm_rel_ring_mask;
599*5113495bSYour Name 	reo_status_mask = int_ctx->reo_status_ring_mask;
600*5113495bSYour Name 
601*5113495bSYour Name 	dp_verbose_debug("tx %x rx %x rx_err %x rx_wbm_rel %x reo_status %x rx_mon_ring %x host2rxdma %x rxdma2host %x",
602*5113495bSYour Name 			 tx_mask, rx_mask, rx_err_mask, rx_wbm_rel_mask,
603*5113495bSYour Name 			 reo_status_mask,
604*5113495bSYour Name 			 int_ctx->rx_mon_ring_mask,
605*5113495bSYour Name 			 int_ctx->host2rxdma_ring_mask,
606*5113495bSYour Name 			 int_ctx->rxdma2host_ring_mask);
607*5113495bSYour Name 
608*5113495bSYour Name 	/* Process Tx completion interrupts first to return back buffers */
609*5113495bSYour Name 	for (index = 0; index < soc->num_tx_comp_rings; index++) {
610*5113495bSYour Name 		if (!(1 << wlan_cfg_get_wbm_ring_num_for_index(soc->wlan_cfg_ctx, index) & tx_mask))
611*5113495bSYour Name 			continue;
612*5113495bSYour Name 		work_done = dp_tx_comp_handler(int_ctx,
613*5113495bSYour Name 					       soc,
614*5113495bSYour Name 					       soc->tx_comp_ring[index].hal_srng,
615*5113495bSYour Name 					       index, remaining_quota);
616*5113495bSYour Name 		if (work_done) {
617*5113495bSYour Name 			intr_stats->num_tx_ring_masks[index]++;
618*5113495bSYour Name 			dp_verbose_debug("tx mask 0x%x index %d, budget %d, work_done %d",
619*5113495bSYour Name 					 tx_mask, index, budget,
620*5113495bSYour Name 					 work_done);
621*5113495bSYour Name 		}
622*5113495bSYour Name 		budget -= work_done;
623*5113495bSYour Name 		if (budget <= 0)
624*5113495bSYour Name 			goto budget_done;
625*5113495bSYour Name 
626*5113495bSYour Name 		remaining_quota = budget;
627*5113495bSYour Name 	}
628*5113495bSYour Name 
629*5113495bSYour Name 	/* Process REO Exception ring interrupt */
630*5113495bSYour Name 	if (rx_err_mask) {
631*5113495bSYour Name 		work_done = dp_rx_err_process(int_ctx, soc,
632*5113495bSYour Name 					      soc->reo_exception_ring.hal_srng,
633*5113495bSYour Name 					      remaining_quota);
634*5113495bSYour Name 
635*5113495bSYour Name 		if (work_done) {
636*5113495bSYour Name 			intr_stats->num_rx_err_ring_masks++;
637*5113495bSYour Name 			dp_verbose_debug("REO Exception Ring: work_done %d budget %d",
638*5113495bSYour Name 					 work_done, budget);
639*5113495bSYour Name 		}
640*5113495bSYour Name 
641*5113495bSYour Name 		budget -=  work_done;
642*5113495bSYour Name 		if (budget <= 0) {
643*5113495bSYour Name 			goto budget_done;
644*5113495bSYour Name 		}
645*5113495bSYour Name 		remaining_quota = budget;
646*5113495bSYour Name 	}
647*5113495bSYour Name 
648*5113495bSYour Name 	/* Process Rx WBM release ring interrupt */
649*5113495bSYour Name 	if (rx_wbm_rel_mask) {
650*5113495bSYour Name 		work_done = dp_rx_wbm_err_process(int_ctx, soc,
651*5113495bSYour Name 						  soc->rx_rel_ring.hal_srng,
652*5113495bSYour Name 						  remaining_quota);
653*5113495bSYour Name 
654*5113495bSYour Name 		if (work_done) {
655*5113495bSYour Name 			intr_stats->num_rx_wbm_rel_ring_masks++;
656*5113495bSYour Name 			dp_verbose_debug("WBM Release Ring: work_done %d budget %d",
657*5113495bSYour Name 					 work_done, budget);
658*5113495bSYour Name 		}
659*5113495bSYour Name 
660*5113495bSYour Name 		budget -=  work_done;
661*5113495bSYour Name 		if (budget <= 0) {
662*5113495bSYour Name 			goto budget_done;
663*5113495bSYour Name 		}
664*5113495bSYour Name 		remaining_quota = budget;
665*5113495bSYour Name 	}
666*5113495bSYour Name 
667*5113495bSYour Name 	/* Process Rx interrupts */
668*5113495bSYour Name 	if (rx_mask) {
669*5113495bSYour Name 		for (ring = 0; ring < soc->num_reo_dest_rings; ring++) {
670*5113495bSYour Name 			if (!(rx_mask & (1 << ring)))
671*5113495bSYour Name 				continue;
672*5113495bSYour Name 			work_done = soc->arch_ops.dp_rx_process(int_ctx,
673*5113495bSYour Name 						  soc->reo_dest_ring[ring].hal_srng,
674*5113495bSYour Name 						  ring,
675*5113495bSYour Name 						  remaining_quota);
676*5113495bSYour Name 			if (work_done) {
677*5113495bSYour Name 				intr_stats->num_rx_ring_masks[ring]++;
678*5113495bSYour Name 				dp_verbose_debug("rx mask 0x%x ring %d, work_done %d budget %d",
679*5113495bSYour Name 						 rx_mask, ring,
680*5113495bSYour Name 						 work_done, budget);
681*5113495bSYour Name 				budget -=  work_done;
682*5113495bSYour Name 				if (budget <= 0)
683*5113495bSYour Name 					goto budget_done;
684*5113495bSYour Name 				remaining_quota = budget;
685*5113495bSYour Name 			}
686*5113495bSYour Name 		}
687*5113495bSYour Name 	}
688*5113495bSYour Name 
689*5113495bSYour Name 	if (reo_status_mask) {
690*5113495bSYour Name 		if (dp_reo_status_ring_handler(int_ctx, soc))
691*5113495bSYour Name 			int_ctx->intr_stats.num_reo_status_ring_masks++;
692*5113495bSYour Name 	}
693*5113495bSYour Name 
694*5113495bSYour Name 	if (qdf_unlikely(!dp_monitor_is_vdev_timer_running(soc))) {
695*5113495bSYour Name 		work_done = dp_process_lmac_rings(int_ctx, remaining_quota);
696*5113495bSYour Name 		if (work_done) {
697*5113495bSYour Name 			budget -=  work_done;
698*5113495bSYour Name 			if (budget <= 0)
699*5113495bSYour Name 				goto budget_done;
700*5113495bSYour Name 			remaining_quota = budget;
701*5113495bSYour Name 		}
702*5113495bSYour Name 	}
703*5113495bSYour Name 
704*5113495bSYour Name 	qdf_lro_flush(int_ctx->lro_ctx);
705*5113495bSYour Name 	intr_stats->num_masks++;
706*5113495bSYour Name 
707*5113495bSYour Name budget_done:
708*5113495bSYour Name 	qdf_atomic_clear_bit(cpu, &soc->service_rings_running);
709*5113495bSYour Name 
710*5113495bSYour Name 	dp_umac_reset_trigger_pre_reset_notify_cb(soc);
711*5113495bSYour Name 
712*5113495bSYour Name 	return dp_budget - budget;
713*5113495bSYour Name }
714*5113495bSYour Name 
715*5113495bSYour Name #else /* QCA_HOST_MODE_WIFI_DISABLED */
716*5113495bSYour Name 
dp_service_srngs(void * dp_ctx,uint32_t dp_budget,int cpu)717*5113495bSYour Name uint32_t dp_service_srngs(void *dp_ctx, uint32_t dp_budget, int cpu)
718*5113495bSYour Name {
719*5113495bSYour Name 	struct dp_intr *int_ctx = (struct dp_intr *)dp_ctx;
720*5113495bSYour Name 	struct dp_intr_stats *intr_stats = &int_ctx->intr_stats;
721*5113495bSYour Name 	struct dp_soc *soc = int_ctx->soc;
722*5113495bSYour Name 	uint32_t remaining_quota = dp_budget;
723*5113495bSYour Name 	uint32_t work_done  = 0;
724*5113495bSYour Name 	int budget = dp_budget;
725*5113495bSYour Name 	uint8_t reo_status_mask = int_ctx->reo_status_ring_mask;
726*5113495bSYour Name 
727*5113495bSYour Name 	if (reo_status_mask) {
728*5113495bSYour Name 		if (dp_reo_status_ring_handler(int_ctx, soc))
729*5113495bSYour Name 			int_ctx->intr_stats.num_reo_status_ring_masks++;
730*5113495bSYour Name 	}
731*5113495bSYour Name 
732*5113495bSYour Name 	if (qdf_unlikely(!dp_monitor_is_vdev_timer_running(soc))) {
733*5113495bSYour Name 		work_done = dp_process_lmac_rings(int_ctx, remaining_quota);
734*5113495bSYour Name 		if (work_done) {
735*5113495bSYour Name 			budget -=  work_done;
736*5113495bSYour Name 			if (budget <= 0)
737*5113495bSYour Name 				goto budget_done;
738*5113495bSYour Name 			remaining_quota = budget;
739*5113495bSYour Name 		}
740*5113495bSYour Name 	}
741*5113495bSYour Name 
742*5113495bSYour Name 	qdf_lro_flush(int_ctx->lro_ctx);
743*5113495bSYour Name 	intr_stats->num_masks++;
744*5113495bSYour Name 
745*5113495bSYour Name budget_done:
746*5113495bSYour Name 	return dp_budget - budget;
747*5113495bSYour Name }
748*5113495bSYour Name 
749*5113495bSYour Name #endif /* QCA_HOST_MODE_WIFI_DISABLED */
750*5113495bSYour Name 
dp_soc_attach_poll(struct cdp_soc_t * txrx_soc)751*5113495bSYour Name QDF_STATUS dp_soc_attach_poll(struct cdp_soc_t *txrx_soc)
752*5113495bSYour Name {
753*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)txrx_soc;
754*5113495bSYour Name 	int i;
755*5113495bSYour Name 	int lmac_id = 0;
756*5113495bSYour Name 
757*5113495bSYour Name 	qdf_mem_set(&soc->mon_intr_id_lmac_map,
758*5113495bSYour Name 		    sizeof(soc->mon_intr_id_lmac_map), DP_MON_INVALID_LMAC_ID);
759*5113495bSYour Name 	soc->intr_mode = DP_INTR_POLL;
760*5113495bSYour Name 
761*5113495bSYour Name 	for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
762*5113495bSYour Name 		soc->intr_ctx[i].dp_intr_id = i;
763*5113495bSYour Name 		soc->intr_ctx[i].tx_ring_mask =
764*5113495bSYour Name 			wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, i);
765*5113495bSYour Name 		soc->intr_ctx[i].rx_ring_mask =
766*5113495bSYour Name 			wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, i);
767*5113495bSYour Name 		soc->intr_ctx[i].rx_mon_ring_mask =
768*5113495bSYour Name 			wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, i);
769*5113495bSYour Name 		soc->intr_ctx[i].rx_err_ring_mask =
770*5113495bSYour Name 			wlan_cfg_get_rx_err_ring_mask(soc->wlan_cfg_ctx, i);
771*5113495bSYour Name 		soc->intr_ctx[i].rx_wbm_rel_ring_mask =
772*5113495bSYour Name 			wlan_cfg_get_rx_wbm_rel_ring_mask(soc->wlan_cfg_ctx, i);
773*5113495bSYour Name 		soc->intr_ctx[i].reo_status_ring_mask =
774*5113495bSYour Name 			wlan_cfg_get_reo_status_ring_mask(soc->wlan_cfg_ctx, i);
775*5113495bSYour Name 		soc->intr_ctx[i].rxdma2host_ring_mask =
776*5113495bSYour Name 			wlan_cfg_get_rxdma2host_ring_mask(soc->wlan_cfg_ctx, i);
777*5113495bSYour Name 		soc->intr_ctx[i].soc = soc;
778*5113495bSYour Name 		soc->intr_ctx[i].lro_ctx = qdf_lro_init();
779*5113495bSYour Name 
780*5113495bSYour Name 		if (dp_is_mon_mask_valid(soc, &soc->intr_ctx[i])) {
781*5113495bSYour Name 			hif_event_history_init(soc->hif_handle, i);
782*5113495bSYour Name 			soc->mon_intr_id_lmac_map[lmac_id] = i;
783*5113495bSYour Name 			lmac_id++;
784*5113495bSYour Name 		}
785*5113495bSYour Name 	}
786*5113495bSYour Name 
787*5113495bSYour Name 	qdf_timer_init(soc->osdev, &soc->int_timer,
788*5113495bSYour Name 		       dp_interrupt_timer, (void *)soc,
789*5113495bSYour Name 		       QDF_TIMER_TYPE_WAKE_APPS);
790*5113495bSYour Name 
791*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
792*5113495bSYour Name }
793*5113495bSYour Name 
794*5113495bSYour Name #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
795*5113495bSYour Name /**
796*5113495bSYour Name  * dp_soc_near_full_interrupt_attach() - Register handler for DP near fill irq
797*5113495bSYour Name  * @soc: DP soc handle
798*5113495bSYour Name  * @num_irq: IRQ number
799*5113495bSYour Name  * @irq_id_map: IRQ map
800*5113495bSYour Name  * @intr_id: interrupt context ID
801*5113495bSYour Name  *
802*5113495bSYour Name  * Return: 0 for success. nonzero for failure.
803*5113495bSYour Name  */
804*5113495bSYour Name static inline int
dp_soc_near_full_interrupt_attach(struct dp_soc * soc,int num_irq,int irq_id_map[],int intr_id)805*5113495bSYour Name dp_soc_near_full_interrupt_attach(struct dp_soc *soc, int num_irq,
806*5113495bSYour Name 				  int irq_id_map[], int intr_id)
807*5113495bSYour Name {
808*5113495bSYour Name 	return hif_register_ext_group(soc->hif_handle,
809*5113495bSYour Name 				      num_irq, irq_id_map,
810*5113495bSYour Name 				      dp_service_near_full_srngs,
811*5113495bSYour Name 				      &soc->intr_ctx[intr_id], "dp_nf_intr",
812*5113495bSYour Name 				      HIF_EXEC_NAPI_TYPE,
813*5113495bSYour Name 				      QCA_NAPI_DEF_SCALE_BIN_SHIFT);
814*5113495bSYour Name }
815*5113495bSYour Name #else
816*5113495bSYour Name static inline int
dp_soc_near_full_interrupt_attach(struct dp_soc * soc,int num_irq,int * irq_id_map,int intr_id)817*5113495bSYour Name dp_soc_near_full_interrupt_attach(struct dp_soc *soc, int num_irq,
818*5113495bSYour Name 				  int *irq_id_map, int intr_id)
819*5113495bSYour Name {
820*5113495bSYour Name 	return 0;
821*5113495bSYour Name }
822*5113495bSYour Name #endif
823*5113495bSYour Name 
824*5113495bSYour Name #ifdef DP_CON_MON_MSI_SKIP_SET
dp_skip_rx_mon_ring_mask_set(struct dp_soc * soc)825*5113495bSYour Name static inline bool dp_skip_rx_mon_ring_mask_set(struct dp_soc *soc)
826*5113495bSYour Name {
827*5113495bSYour Name 	return !!(soc->cdp_soc.ol_ops->get_con_mode() !=
828*5113495bSYour Name 		 QDF_GLOBAL_MONITOR_MODE &&
829*5113495bSYour Name 		 !dp_mon_mode_local_pkt_capture(soc));
830*5113495bSYour Name }
831*5113495bSYour Name #else
dp_skip_rx_mon_ring_mask_set(struct dp_soc * soc)832*5113495bSYour Name static inline bool dp_skip_rx_mon_ring_mask_set(struct dp_soc *soc)
833*5113495bSYour Name {
834*5113495bSYour Name 	return false;
835*5113495bSYour Name }
836*5113495bSYour Name #endif
837*5113495bSYour Name 
dp_soc_interrupt_detach(struct cdp_soc_t * txrx_soc)838*5113495bSYour Name void dp_soc_interrupt_detach(struct cdp_soc_t *txrx_soc)
839*5113495bSYour Name {
840*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)txrx_soc;
841*5113495bSYour Name 	int i;
842*5113495bSYour Name 
843*5113495bSYour Name 	if (soc->intr_mode == DP_INTR_POLL) {
844*5113495bSYour Name 		qdf_timer_free(&soc->int_timer);
845*5113495bSYour Name 	} else {
846*5113495bSYour Name 		hif_deconfigure_ext_group_interrupts(soc->hif_handle);
847*5113495bSYour Name 		hif_deregister_exec_group(soc->hif_handle, "dp_intr");
848*5113495bSYour Name 		hif_deregister_exec_group(soc->hif_handle, "dp_nf_intr");
849*5113495bSYour Name 	}
850*5113495bSYour Name 
851*5113495bSYour Name 	for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
852*5113495bSYour Name 		soc->intr_ctx[i].tx_ring_mask = 0;
853*5113495bSYour Name 		soc->intr_ctx[i].rx_ring_mask = 0;
854*5113495bSYour Name 		soc->intr_ctx[i].rx_mon_ring_mask = 0;
855*5113495bSYour Name 		soc->intr_ctx[i].rx_err_ring_mask = 0;
856*5113495bSYour Name 		soc->intr_ctx[i].rx_wbm_rel_ring_mask = 0;
857*5113495bSYour Name 		soc->intr_ctx[i].reo_status_ring_mask = 0;
858*5113495bSYour Name 		soc->intr_ctx[i].rxdma2host_ring_mask = 0;
859*5113495bSYour Name 		soc->intr_ctx[i].host2rxdma_ring_mask = 0;
860*5113495bSYour Name 		soc->intr_ctx[i].host2rxdma_mon_ring_mask = 0;
861*5113495bSYour Name 		soc->intr_ctx[i].rx_near_full_grp_1_mask = 0;
862*5113495bSYour Name 		soc->intr_ctx[i].rx_near_full_grp_2_mask = 0;
863*5113495bSYour Name 		soc->intr_ctx[i].tx_ring_near_full_mask = 0;
864*5113495bSYour Name 		soc->intr_ctx[i].tx_mon_ring_mask = 0;
865*5113495bSYour Name 		soc->intr_ctx[i].host2txmon_ring_mask = 0;
866*5113495bSYour Name 		soc->intr_ctx[i].umac_reset_intr_mask = 0;
867*5113495bSYour Name 
868*5113495bSYour Name 		hif_event_history_deinit(soc->hif_handle, i);
869*5113495bSYour Name 		qdf_lro_deinit(soc->intr_ctx[i].lro_ctx);
870*5113495bSYour Name 	}
871*5113495bSYour Name 
872*5113495bSYour Name 	qdf_mem_set(&soc->mon_intr_id_lmac_map,
873*5113495bSYour Name 		    sizeof(soc->mon_intr_id_lmac_map),
874*5113495bSYour Name 		    DP_MON_INVALID_LMAC_ID);
875*5113495bSYour Name }
876*5113495bSYour Name 
dp_soc_interrupt_attach(struct cdp_soc_t * txrx_soc)877*5113495bSYour Name QDF_STATUS dp_soc_interrupt_attach(struct cdp_soc_t *txrx_soc)
878*5113495bSYour Name {
879*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)txrx_soc;
880*5113495bSYour Name 
881*5113495bSYour Name 	int i = 0;
882*5113495bSYour Name 	int num_irq = 0;
883*5113495bSYour Name 	int rx_err_ring_intr_ctxt_id = HIF_MAX_GROUP;
884*5113495bSYour Name 	int lmac_id = 0;
885*5113495bSYour Name 	int napi_scale;
886*5113495bSYour Name 
887*5113495bSYour Name 	qdf_mem_set(&soc->mon_intr_id_lmac_map,
888*5113495bSYour Name 		    sizeof(soc->mon_intr_id_lmac_map), DP_MON_INVALID_LMAC_ID);
889*5113495bSYour Name 
890*5113495bSYour Name 	for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
891*5113495bSYour Name 		int ret = 0;
892*5113495bSYour Name 
893*5113495bSYour Name 		/* Map of IRQ ids registered with one interrupt context */
894*5113495bSYour Name 		int irq_id_map[HIF_MAX_GRP_IRQ];
895*5113495bSYour Name 
896*5113495bSYour Name 		int tx_mask =
897*5113495bSYour Name 			wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, i);
898*5113495bSYour Name 		int rx_mask =
899*5113495bSYour Name 			wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, i);
900*5113495bSYour Name 		int rx_mon_mask =
901*5113495bSYour Name 			dp_soc_get_mon_mask_for_interrupt_mode(soc, i);
902*5113495bSYour Name 		int tx_mon_ring_mask =
903*5113495bSYour Name 			wlan_cfg_get_tx_mon_ring_mask(soc->wlan_cfg_ctx, i);
904*5113495bSYour Name 		int rx_err_ring_mask =
905*5113495bSYour Name 			wlan_cfg_get_rx_err_ring_mask(soc->wlan_cfg_ctx, i);
906*5113495bSYour Name 		int rx_wbm_rel_ring_mask =
907*5113495bSYour Name 			wlan_cfg_get_rx_wbm_rel_ring_mask(soc->wlan_cfg_ctx, i);
908*5113495bSYour Name 		int reo_status_ring_mask =
909*5113495bSYour Name 			wlan_cfg_get_reo_status_ring_mask(soc->wlan_cfg_ctx, i);
910*5113495bSYour Name 		int rxdma2host_ring_mask =
911*5113495bSYour Name 			wlan_cfg_get_rxdma2host_ring_mask(soc->wlan_cfg_ctx, i);
912*5113495bSYour Name 		int host2rxdma_ring_mask =
913*5113495bSYour Name 			wlan_cfg_get_host2rxdma_ring_mask(soc->wlan_cfg_ctx, i);
914*5113495bSYour Name 		int host2rxdma_mon_ring_mask =
915*5113495bSYour Name 			wlan_cfg_get_host2rxdma_mon_ring_mask(
916*5113495bSYour Name 				soc->wlan_cfg_ctx, i);
917*5113495bSYour Name 		int rx_near_full_grp_1_mask =
918*5113495bSYour Name 			wlan_cfg_get_rx_near_full_grp_1_mask(soc->wlan_cfg_ctx,
919*5113495bSYour Name 							     i);
920*5113495bSYour Name 		int rx_near_full_grp_2_mask =
921*5113495bSYour Name 			wlan_cfg_get_rx_near_full_grp_2_mask(soc->wlan_cfg_ctx,
922*5113495bSYour Name 							     i);
923*5113495bSYour Name 		int tx_ring_near_full_mask =
924*5113495bSYour Name 			wlan_cfg_get_tx_ring_near_full_mask(soc->wlan_cfg_ctx,
925*5113495bSYour Name 							    i);
926*5113495bSYour Name 		int host2txmon_ring_mask =
927*5113495bSYour Name 			wlan_cfg_get_host2txmon_ring_mask(soc->wlan_cfg_ctx, i);
928*5113495bSYour Name 		int umac_reset_intr_mask =
929*5113495bSYour Name 			wlan_cfg_get_umac_reset_intr_mask(soc->wlan_cfg_ctx, i);
930*5113495bSYour Name 
931*5113495bSYour Name 		if (dp_skip_rx_mon_ring_mask_set(soc))
932*5113495bSYour Name 			rx_mon_mask = 0;
933*5113495bSYour Name 
934*5113495bSYour Name 		soc->intr_ctx[i].dp_intr_id = i;
935*5113495bSYour Name 		soc->intr_ctx[i].tx_ring_mask = tx_mask;
936*5113495bSYour Name 		soc->intr_ctx[i].rx_ring_mask = rx_mask;
937*5113495bSYour Name 		soc->intr_ctx[i].rx_mon_ring_mask = rx_mon_mask;
938*5113495bSYour Name 		soc->intr_ctx[i].rx_err_ring_mask = rx_err_ring_mask;
939*5113495bSYour Name 		soc->intr_ctx[i].rxdma2host_ring_mask = rxdma2host_ring_mask;
940*5113495bSYour Name 		soc->intr_ctx[i].host2rxdma_ring_mask = host2rxdma_ring_mask;
941*5113495bSYour Name 		soc->intr_ctx[i].rx_wbm_rel_ring_mask = rx_wbm_rel_ring_mask;
942*5113495bSYour Name 		soc->intr_ctx[i].reo_status_ring_mask = reo_status_ring_mask;
943*5113495bSYour Name 		soc->intr_ctx[i].host2rxdma_mon_ring_mask =
944*5113495bSYour Name 			 host2rxdma_mon_ring_mask;
945*5113495bSYour Name 		soc->intr_ctx[i].rx_near_full_grp_1_mask =
946*5113495bSYour Name 						rx_near_full_grp_1_mask;
947*5113495bSYour Name 		soc->intr_ctx[i].rx_near_full_grp_2_mask =
948*5113495bSYour Name 						rx_near_full_grp_2_mask;
949*5113495bSYour Name 		soc->intr_ctx[i].tx_ring_near_full_mask =
950*5113495bSYour Name 						tx_ring_near_full_mask;
951*5113495bSYour Name 		soc->intr_ctx[i].tx_mon_ring_mask = tx_mon_ring_mask;
952*5113495bSYour Name 		soc->intr_ctx[i].host2txmon_ring_mask = host2txmon_ring_mask;
953*5113495bSYour Name 		soc->intr_ctx[i].umac_reset_intr_mask = umac_reset_intr_mask;
954*5113495bSYour Name 
955*5113495bSYour Name 		soc->intr_ctx[i].soc = soc;
956*5113495bSYour Name 
957*5113495bSYour Name 		num_irq = 0;
958*5113495bSYour Name 
959*5113495bSYour Name 		dp_soc_interrupt_map_calculate(soc, i, &irq_id_map[0],
960*5113495bSYour Name 					       &num_irq);
961*5113495bSYour Name 
962*5113495bSYour Name 		if (rx_near_full_grp_1_mask | rx_near_full_grp_2_mask |
963*5113495bSYour Name 		    tx_ring_near_full_mask) {
964*5113495bSYour Name 			dp_soc_near_full_interrupt_attach(soc, num_irq,
965*5113495bSYour Name 							  irq_id_map, i);
966*5113495bSYour Name 		} else {
967*5113495bSYour Name 			napi_scale = wlan_cfg_get_napi_scale_factor(
968*5113495bSYour Name 							    soc->wlan_cfg_ctx);
969*5113495bSYour Name 			if (!napi_scale)
970*5113495bSYour Name 				napi_scale = QCA_NAPI_DEF_SCALE_BIN_SHIFT;
971*5113495bSYour Name 
972*5113495bSYour Name 			ret = hif_register_ext_group(soc->hif_handle,
973*5113495bSYour Name 				num_irq, irq_id_map, dp_service_srngs_wrapper,
974*5113495bSYour Name 				&soc->intr_ctx[i], "dp_intr",
975*5113495bSYour Name 				HIF_EXEC_NAPI_TYPE, napi_scale);
976*5113495bSYour Name 		}
977*5113495bSYour Name 
978*5113495bSYour Name 		dp_debug(" int ctx %u num_irq %u irq_id_map %u %u",
979*5113495bSYour Name 			 i, num_irq, irq_id_map[0], irq_id_map[1]);
980*5113495bSYour Name 
981*5113495bSYour Name 		if (ret) {
982*5113495bSYour Name 			dp_init_err("%pK: failed, ret = %d", soc, ret);
983*5113495bSYour Name 			dp_soc_interrupt_detach(txrx_soc);
984*5113495bSYour Name 			return QDF_STATUS_E_FAILURE;
985*5113495bSYour Name 		}
986*5113495bSYour Name 
987*5113495bSYour Name 		hif_event_history_init(soc->hif_handle, i);
988*5113495bSYour Name 		soc->intr_ctx[i].lro_ctx = qdf_lro_init();
989*5113495bSYour Name 
990*5113495bSYour Name 		if (rx_err_ring_mask)
991*5113495bSYour Name 			rx_err_ring_intr_ctxt_id = i;
992*5113495bSYour Name 
993*5113495bSYour Name 		if (dp_is_mon_mask_valid(soc, &soc->intr_ctx[i])) {
994*5113495bSYour Name 			soc->mon_intr_id_lmac_map[lmac_id] = i;
995*5113495bSYour Name 			lmac_id++;
996*5113495bSYour Name 		}
997*5113495bSYour Name 	}
998*5113495bSYour Name 
999*5113495bSYour Name 	hif_configure_ext_group_interrupts(soc->hif_handle);
1000*5113495bSYour Name 	if (rx_err_ring_intr_ctxt_id != HIF_MAX_GROUP)
1001*5113495bSYour Name 		hif_config_irq_clear_cpu_affinity(soc->hif_handle,
1002*5113495bSYour Name 						  rx_err_ring_intr_ctxt_id, 0);
1003*5113495bSYour Name 
1004*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
1005*5113495bSYour Name }
1006*5113495bSYour Name 
1007*5113495bSYour Name #define AVG_MAX_MPDUS_PER_TID 128
1008*5113495bSYour Name #define AVG_TIDS_PER_CLIENT 2
1009*5113495bSYour Name #define AVG_FLOWS_PER_TID 2
1010*5113495bSYour Name #define AVG_MSDUS_PER_FLOW 128
1011*5113495bSYour Name #define AVG_MSDUS_PER_MPDU 4
1012*5113495bSYour Name 
dp_hw_link_desc_pool_banks_free(struct dp_soc * soc,uint32_t mac_id)1013*5113495bSYour Name void dp_hw_link_desc_pool_banks_free(struct dp_soc *soc, uint32_t mac_id)
1014*5113495bSYour Name {
1015*5113495bSYour Name 	struct qdf_mem_multi_page_t *pages;
1016*5113495bSYour Name 
1017*5113495bSYour Name 	if (mac_id != WLAN_INVALID_PDEV_ID) {
1018*5113495bSYour Name 		pages = dp_monitor_get_link_desc_pages(soc, mac_id);
1019*5113495bSYour Name 	} else {
1020*5113495bSYour Name 		pages = &soc->link_desc_pages;
1021*5113495bSYour Name 	}
1022*5113495bSYour Name 
1023*5113495bSYour Name 	if (!pages) {
1024*5113495bSYour Name 		dp_err("can not get link desc pages");
1025*5113495bSYour Name 		QDF_ASSERT(0);
1026*5113495bSYour Name 		return;
1027*5113495bSYour Name 	}
1028*5113495bSYour Name 
1029*5113495bSYour Name 	if (pages->dma_pages) {
1030*5113495bSYour Name 		wlan_minidump_remove((void *)
1031*5113495bSYour Name 				     pages->dma_pages->page_v_addr_start,
1032*5113495bSYour Name 				     pages->num_pages * pages->page_size,
1033*5113495bSYour Name 				     soc->ctrl_psoc,
1034*5113495bSYour Name 				     WLAN_MD_DP_SRNG_WBM_IDLE_LINK,
1035*5113495bSYour Name 				     "hw_link_desc_bank");
1036*5113495bSYour Name 		dp_desc_multi_pages_mem_free(soc, QDF_DP_HW_LINK_DESC_TYPE,
1037*5113495bSYour Name 					     pages, 0, false);
1038*5113495bSYour Name 	}
1039*5113495bSYour Name }
1040*5113495bSYour Name 
1041*5113495bSYour Name qdf_export_symbol(dp_hw_link_desc_pool_banks_free);
1042*5113495bSYour Name 
dp_hw_link_desc_pool_banks_alloc(struct dp_soc * soc,uint32_t mac_id)1043*5113495bSYour Name QDF_STATUS dp_hw_link_desc_pool_banks_alloc(struct dp_soc *soc, uint32_t mac_id)
1044*5113495bSYour Name {
1045*5113495bSYour Name 	hal_soc_handle_t hal_soc = soc->hal_soc;
1046*5113495bSYour Name 	int link_desc_size = hal_get_link_desc_size(soc->hal_soc);
1047*5113495bSYour Name 	int link_desc_align = hal_get_link_desc_align(soc->hal_soc);
1048*5113495bSYour Name 	uint32_t max_clients = wlan_cfg_get_max_clients(soc->wlan_cfg_ctx);
1049*5113495bSYour Name 	uint32_t num_mpdus_per_link_desc = hal_num_mpdus_per_link_desc(hal_soc);
1050*5113495bSYour Name 	uint32_t num_msdus_per_link_desc = hal_num_msdus_per_link_desc(hal_soc);
1051*5113495bSYour Name 	uint32_t num_mpdu_links_per_queue_desc =
1052*5113495bSYour Name 		hal_num_mpdu_links_per_queue_desc(hal_soc);
1053*5113495bSYour Name 	uint32_t max_alloc_size = wlan_cfg_max_alloc_size(soc->wlan_cfg_ctx);
1054*5113495bSYour Name 	uint32_t *total_link_descs, total_mem_size;
1055*5113495bSYour Name 	uint32_t num_mpdu_link_descs, num_mpdu_queue_descs;
1056*5113495bSYour Name 	uint32_t num_tx_msdu_link_descs, num_rx_msdu_link_descs;
1057*5113495bSYour Name 	uint32_t num_entries;
1058*5113495bSYour Name 	struct qdf_mem_multi_page_t *pages;
1059*5113495bSYour Name 	struct dp_srng *dp_srng;
1060*5113495bSYour Name 	uint8_t minidump_str[MINIDUMP_STR_SIZE];
1061*5113495bSYour Name 
1062*5113495bSYour Name 	/* Only Tx queue descriptors are allocated from common link descriptor
1063*5113495bSYour Name 	 * pool Rx queue descriptors are not included in this because (REO queue
1064*5113495bSYour Name 	 * extension descriptors) they are expected to be allocated contiguously
1065*5113495bSYour Name 	 * with REO queue descriptors
1066*5113495bSYour Name 	 */
1067*5113495bSYour Name 	if (mac_id != WLAN_INVALID_PDEV_ID) {
1068*5113495bSYour Name 		pages = dp_monitor_get_link_desc_pages(soc, mac_id);
1069*5113495bSYour Name 		/* dp_monitor_get_link_desc_pages returns NULL only
1070*5113495bSYour Name 		 * if monitor SOC is  NULL
1071*5113495bSYour Name 		 */
1072*5113495bSYour Name 		if (!pages) {
1073*5113495bSYour Name 			dp_err("can not get link desc pages");
1074*5113495bSYour Name 			QDF_ASSERT(0);
1075*5113495bSYour Name 			return QDF_STATUS_E_FAULT;
1076*5113495bSYour Name 		}
1077*5113495bSYour Name 		dp_srng = &soc->rxdma_mon_desc_ring[mac_id];
1078*5113495bSYour Name 		num_entries = dp_srng->alloc_size /
1079*5113495bSYour Name 			hal_srng_get_entrysize(soc->hal_soc,
1080*5113495bSYour Name 					       RXDMA_MONITOR_DESC);
1081*5113495bSYour Name 		total_link_descs = dp_monitor_get_total_link_descs(soc, mac_id);
1082*5113495bSYour Name 		qdf_str_lcopy(minidump_str, "mon_link_desc_bank",
1083*5113495bSYour Name 			      MINIDUMP_STR_SIZE);
1084*5113495bSYour Name 	} else {
1085*5113495bSYour Name 		num_mpdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT *
1086*5113495bSYour Name 			AVG_MAX_MPDUS_PER_TID) / num_mpdus_per_link_desc;
1087*5113495bSYour Name 
1088*5113495bSYour Name 		num_mpdu_queue_descs = num_mpdu_link_descs /
1089*5113495bSYour Name 			num_mpdu_links_per_queue_desc;
1090*5113495bSYour Name 
1091*5113495bSYour Name 		num_tx_msdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT *
1092*5113495bSYour Name 			AVG_FLOWS_PER_TID * AVG_MSDUS_PER_FLOW) /
1093*5113495bSYour Name 			num_msdus_per_link_desc;
1094*5113495bSYour Name 
1095*5113495bSYour Name 		num_rx_msdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT *
1096*5113495bSYour Name 			AVG_MAX_MPDUS_PER_TID * AVG_MSDUS_PER_MPDU) / 6;
1097*5113495bSYour Name 
1098*5113495bSYour Name 		num_entries = num_mpdu_link_descs + num_mpdu_queue_descs +
1099*5113495bSYour Name 			num_tx_msdu_link_descs + num_rx_msdu_link_descs;
1100*5113495bSYour Name 
1101*5113495bSYour Name 		pages = &soc->link_desc_pages;
1102*5113495bSYour Name 		total_link_descs = &soc->total_link_descs;
1103*5113495bSYour Name 		qdf_str_lcopy(minidump_str, "link_desc_bank",
1104*5113495bSYour Name 			      MINIDUMP_STR_SIZE);
1105*5113495bSYour Name 	}
1106*5113495bSYour Name 
1107*5113495bSYour Name 	/* If link descriptor banks are allocated, return from here */
1108*5113495bSYour Name 	if (pages->num_pages)
1109*5113495bSYour Name 		return QDF_STATUS_SUCCESS;
1110*5113495bSYour Name 
1111*5113495bSYour Name 	/* Round up to power of 2 */
1112*5113495bSYour Name 	*total_link_descs = 1;
1113*5113495bSYour Name 	while (*total_link_descs < num_entries)
1114*5113495bSYour Name 		*total_link_descs <<= 1;
1115*5113495bSYour Name 
1116*5113495bSYour Name 	dp_init_info("%pK: total_link_descs: %u, link_desc_size: %d",
1117*5113495bSYour Name 		     soc, *total_link_descs, link_desc_size);
1118*5113495bSYour Name 	total_mem_size =  *total_link_descs * link_desc_size;
1119*5113495bSYour Name 	total_mem_size += link_desc_align;
1120*5113495bSYour Name 
1121*5113495bSYour Name 	dp_init_info("%pK: total_mem_size: %d",
1122*5113495bSYour Name 		     soc, total_mem_size);
1123*5113495bSYour Name 
1124*5113495bSYour Name 	dp_set_max_page_size(pages, max_alloc_size);
1125*5113495bSYour Name 	dp_desc_multi_pages_mem_alloc(soc, QDF_DP_HW_LINK_DESC_TYPE,
1126*5113495bSYour Name 				      pages,
1127*5113495bSYour Name 				      link_desc_size,
1128*5113495bSYour Name 				      *total_link_descs,
1129*5113495bSYour Name 				      0, false);
1130*5113495bSYour Name 	if (!pages->num_pages) {
1131*5113495bSYour Name 		dp_err("Multi page alloc fail for hw link desc pool");
1132*5113495bSYour Name 		return QDF_STATUS_E_FAULT;
1133*5113495bSYour Name 	}
1134*5113495bSYour Name 
1135*5113495bSYour Name 	wlan_minidump_log(pages->dma_pages->page_v_addr_start,
1136*5113495bSYour Name 			  pages->num_pages * pages->page_size,
1137*5113495bSYour Name 			  soc->ctrl_psoc,
1138*5113495bSYour Name 			  WLAN_MD_DP_SRNG_WBM_IDLE_LINK,
1139*5113495bSYour Name 			  "hw_link_desc_bank");
1140*5113495bSYour Name 
1141*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
1142*5113495bSYour Name }
1143*5113495bSYour Name 
dp_hw_link_desc_ring_free(struct dp_soc * soc)1144*5113495bSYour Name void dp_hw_link_desc_ring_free(struct dp_soc *soc)
1145*5113495bSYour Name {
1146*5113495bSYour Name 	uint32_t i;
1147*5113495bSYour Name 	uint32_t size = soc->wbm_idle_scatter_buf_size;
1148*5113495bSYour Name 	void *vaddr = soc->wbm_idle_link_ring.base_vaddr_unaligned;
1149*5113495bSYour Name 	qdf_dma_addr_t paddr;
1150*5113495bSYour Name 
1151*5113495bSYour Name 	if (soc->wbm_idle_scatter_buf_base_vaddr[0]) {
1152*5113495bSYour Name 		for (i = 0; i < MAX_IDLE_SCATTER_BUFS; i++) {
1153*5113495bSYour Name 			vaddr = soc->wbm_idle_scatter_buf_base_vaddr[i];
1154*5113495bSYour Name 			paddr = soc->wbm_idle_scatter_buf_base_paddr[i];
1155*5113495bSYour Name 			if (vaddr) {
1156*5113495bSYour Name 				qdf_mem_free_consistent(soc->osdev,
1157*5113495bSYour Name 							soc->osdev->dev,
1158*5113495bSYour Name 							size,
1159*5113495bSYour Name 							vaddr,
1160*5113495bSYour Name 							paddr,
1161*5113495bSYour Name 							0);
1162*5113495bSYour Name 				vaddr = NULL;
1163*5113495bSYour Name 			}
1164*5113495bSYour Name 		}
1165*5113495bSYour Name 	} else {
1166*5113495bSYour Name 		wlan_minidump_remove(soc->wbm_idle_link_ring.base_vaddr_unaligned,
1167*5113495bSYour Name 				     soc->wbm_idle_link_ring.alloc_size,
1168*5113495bSYour Name 				     soc->ctrl_psoc,
1169*5113495bSYour Name 				     WLAN_MD_DP_SRNG_WBM_IDLE_LINK,
1170*5113495bSYour Name 				     "wbm_idle_link_ring");
1171*5113495bSYour Name 		dp_srng_free(soc, &soc->wbm_idle_link_ring);
1172*5113495bSYour Name 	}
1173*5113495bSYour Name }
1174*5113495bSYour Name 
dp_hw_link_desc_ring_alloc(struct dp_soc * soc)1175*5113495bSYour Name QDF_STATUS dp_hw_link_desc_ring_alloc(struct dp_soc *soc)
1176*5113495bSYour Name {
1177*5113495bSYour Name 	uint32_t entry_size, i;
1178*5113495bSYour Name 	uint32_t total_mem_size;
1179*5113495bSYour Name 	qdf_dma_addr_t *baseaddr = NULL;
1180*5113495bSYour Name 	struct dp_srng *dp_srng;
1181*5113495bSYour Name 	uint32_t ring_type;
1182*5113495bSYour Name 	uint32_t max_alloc_size = wlan_cfg_max_alloc_size(soc->wlan_cfg_ctx);
1183*5113495bSYour Name 	uint32_t tlds;
1184*5113495bSYour Name 
1185*5113495bSYour Name 	ring_type = WBM_IDLE_LINK;
1186*5113495bSYour Name 	dp_srng = &soc->wbm_idle_link_ring;
1187*5113495bSYour Name 	tlds = soc->total_link_descs;
1188*5113495bSYour Name 
1189*5113495bSYour Name 	entry_size = hal_srng_get_entrysize(soc->hal_soc, ring_type);
1190*5113495bSYour Name 	total_mem_size = entry_size * tlds;
1191*5113495bSYour Name 
1192*5113495bSYour Name 	if (total_mem_size <= max_alloc_size) {
1193*5113495bSYour Name 		if (dp_srng_alloc(soc, dp_srng, ring_type, tlds, 0)) {
1194*5113495bSYour Name 			dp_init_err("%pK: Link desc idle ring setup failed",
1195*5113495bSYour Name 				    soc);
1196*5113495bSYour Name 			goto fail;
1197*5113495bSYour Name 		}
1198*5113495bSYour Name 
1199*5113495bSYour Name 		wlan_minidump_log(soc->wbm_idle_link_ring.base_vaddr_unaligned,
1200*5113495bSYour Name 				  soc->wbm_idle_link_ring.alloc_size,
1201*5113495bSYour Name 				  soc->ctrl_psoc,
1202*5113495bSYour Name 				  WLAN_MD_DP_SRNG_WBM_IDLE_LINK,
1203*5113495bSYour Name 				  "wbm_idle_link_ring");
1204*5113495bSYour Name 	} else {
1205*5113495bSYour Name 		uint32_t num_scatter_bufs;
1206*5113495bSYour Name 		uint32_t buf_size = 0;
1207*5113495bSYour Name 
1208*5113495bSYour Name 		soc->wbm_idle_scatter_buf_size =
1209*5113495bSYour Name 			hal_idle_list_scatter_buf_size(soc->hal_soc);
1210*5113495bSYour Name 		num_scatter_bufs = hal_idle_list_num_scatter_bufs(
1211*5113495bSYour Name 					soc->hal_soc, total_mem_size,
1212*5113495bSYour Name 					soc->wbm_idle_scatter_buf_size);
1213*5113495bSYour Name 
1214*5113495bSYour Name 		if (num_scatter_bufs > MAX_IDLE_SCATTER_BUFS) {
1215*5113495bSYour Name 			QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
1216*5113495bSYour Name 				  FL("scatter bufs size out of bounds"));
1217*5113495bSYour Name 			goto fail;
1218*5113495bSYour Name 		}
1219*5113495bSYour Name 
1220*5113495bSYour Name 		for (i = 0; i < num_scatter_bufs; i++) {
1221*5113495bSYour Name 			baseaddr = &soc->wbm_idle_scatter_buf_base_paddr[i];
1222*5113495bSYour Name 			buf_size = soc->wbm_idle_scatter_buf_size;
1223*5113495bSYour Name 			soc->wbm_idle_scatter_buf_base_vaddr[i] =
1224*5113495bSYour Name 				qdf_mem_alloc_consistent(soc->osdev,
1225*5113495bSYour Name 							 soc->osdev->dev,
1226*5113495bSYour Name 							 buf_size,
1227*5113495bSYour Name 							 baseaddr);
1228*5113495bSYour Name 
1229*5113495bSYour Name 			if (!soc->wbm_idle_scatter_buf_base_vaddr[i]) {
1230*5113495bSYour Name 				QDF_TRACE(QDF_MODULE_ID_DP,
1231*5113495bSYour Name 					  QDF_TRACE_LEVEL_ERROR,
1232*5113495bSYour Name 					  FL("Scatter lst memory alloc fail"));
1233*5113495bSYour Name 				goto fail;
1234*5113495bSYour Name 			}
1235*5113495bSYour Name 		}
1236*5113495bSYour Name 		soc->num_scatter_bufs = num_scatter_bufs;
1237*5113495bSYour Name 	}
1238*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
1239*5113495bSYour Name 
1240*5113495bSYour Name fail:
1241*5113495bSYour Name 	for (i = 0; i < MAX_IDLE_SCATTER_BUFS; i++) {
1242*5113495bSYour Name 		void *vaddr = soc->wbm_idle_scatter_buf_base_vaddr[i];
1243*5113495bSYour Name 		qdf_dma_addr_t paddr = soc->wbm_idle_scatter_buf_base_paddr[i];
1244*5113495bSYour Name 
1245*5113495bSYour Name 		if (vaddr) {
1246*5113495bSYour Name 			qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
1247*5113495bSYour Name 						soc->wbm_idle_scatter_buf_size,
1248*5113495bSYour Name 						vaddr,
1249*5113495bSYour Name 						paddr, 0);
1250*5113495bSYour Name 			vaddr = NULL;
1251*5113495bSYour Name 		}
1252*5113495bSYour Name 	}
1253*5113495bSYour Name 	return QDF_STATUS_E_NOMEM;
1254*5113495bSYour Name }
1255*5113495bSYour Name 
1256*5113495bSYour Name qdf_export_symbol(dp_hw_link_desc_pool_banks_alloc);
1257*5113495bSYour Name 
dp_hw_link_desc_ring_init(struct dp_soc * soc)1258*5113495bSYour Name QDF_STATUS dp_hw_link_desc_ring_init(struct dp_soc *soc)
1259*5113495bSYour Name {
1260*5113495bSYour Name 	struct dp_srng *dp_srng = &soc->wbm_idle_link_ring;
1261*5113495bSYour Name 
1262*5113495bSYour Name 	if (dp_srng->base_vaddr_unaligned) {
1263*5113495bSYour Name 		if (dp_srng_init(soc, dp_srng, WBM_IDLE_LINK, 0, 0))
1264*5113495bSYour Name 			return QDF_STATUS_E_FAILURE;
1265*5113495bSYour Name 	}
1266*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
1267*5113495bSYour Name }
1268*5113495bSYour Name 
dp_hw_link_desc_ring_deinit(struct dp_soc * soc)1269*5113495bSYour Name void dp_hw_link_desc_ring_deinit(struct dp_soc *soc)
1270*5113495bSYour Name {
1271*5113495bSYour Name 	dp_srng_deinit(soc, &soc->wbm_idle_link_ring, WBM_IDLE_LINK, 0);
1272*5113495bSYour Name }
1273*5113495bSYour Name 
1274*5113495bSYour Name #ifdef IPA_OFFLOAD
1275*5113495bSYour Name #define USE_1_IPA_RX_REO_RING 1
1276*5113495bSYour Name #define USE_2_IPA_RX_REO_RINGS 2
1277*5113495bSYour Name #define REO_DST_RING_SIZE_QCA6290 1023
1278*5113495bSYour Name #ifndef CONFIG_WIFI_EMULATION_WIFI_3_0
1279*5113495bSYour Name #define REO_DST_RING_SIZE_QCA8074 1023
1280*5113495bSYour Name #define REO_DST_RING_SIZE_QCN9000 2048
1281*5113495bSYour Name #else
1282*5113495bSYour Name #define REO_DST_RING_SIZE_QCA8074 8
1283*5113495bSYour Name #define REO_DST_RING_SIZE_QCN9000 8
1284*5113495bSYour Name #endif /* CONFIG_WIFI_EMULATION_WIFI_3_0 */
1285*5113495bSYour Name 
1286*5113495bSYour Name #ifdef IPA_WDI3_TX_TWO_PIPES
1287*5113495bSYour Name #ifdef DP_MEMORY_OPT
dp_ipa_init_alt_tx_ring(struct dp_soc * soc)1288*5113495bSYour Name static int dp_ipa_init_alt_tx_ring(struct dp_soc *soc)
1289*5113495bSYour Name {
1290*5113495bSYour Name 	return dp_init_tx_ring_pair_by_index(soc, IPA_TX_ALT_RING_IDX);
1291*5113495bSYour Name }
1292*5113495bSYour Name 
dp_ipa_deinit_alt_tx_ring(struct dp_soc * soc)1293*5113495bSYour Name static void dp_ipa_deinit_alt_tx_ring(struct dp_soc *soc)
1294*5113495bSYour Name {
1295*5113495bSYour Name 	dp_deinit_tx_pair_by_index(soc, IPA_TX_ALT_RING_IDX);
1296*5113495bSYour Name }
1297*5113495bSYour Name 
dp_ipa_alloc_alt_tx_ring(struct dp_soc * soc)1298*5113495bSYour Name static int dp_ipa_alloc_alt_tx_ring(struct dp_soc *soc)
1299*5113495bSYour Name {
1300*5113495bSYour Name 	return dp_alloc_tx_ring_pair_by_index(soc, IPA_TX_ALT_RING_IDX);
1301*5113495bSYour Name }
1302*5113495bSYour Name 
dp_ipa_free_alt_tx_ring(struct dp_soc * soc)1303*5113495bSYour Name static void dp_ipa_free_alt_tx_ring(struct dp_soc *soc)
1304*5113495bSYour Name {
1305*5113495bSYour Name 	dp_free_tx_ring_pair_by_index(soc, IPA_TX_ALT_RING_IDX);
1306*5113495bSYour Name }
1307*5113495bSYour Name 
1308*5113495bSYour Name #else /* !DP_MEMORY_OPT */
dp_ipa_init_alt_tx_ring(struct dp_soc * soc)1309*5113495bSYour Name static int dp_ipa_init_alt_tx_ring(struct dp_soc *soc)
1310*5113495bSYour Name {
1311*5113495bSYour Name 	return 0;
1312*5113495bSYour Name }
1313*5113495bSYour Name 
dp_ipa_deinit_alt_tx_ring(struct dp_soc * soc)1314*5113495bSYour Name static void dp_ipa_deinit_alt_tx_ring(struct dp_soc *soc)
1315*5113495bSYour Name {
1316*5113495bSYour Name }
1317*5113495bSYour Name 
dp_ipa_alloc_alt_tx_ring(struct dp_soc * soc)1318*5113495bSYour Name static int dp_ipa_alloc_alt_tx_ring(struct dp_soc *soc)
1319*5113495bSYour Name {
1320*5113495bSYour Name 	return 0;
1321*5113495bSYour Name }
1322*5113495bSYour Name 
dp_ipa_free_alt_tx_ring(struct dp_soc * soc)1323*5113495bSYour Name static void dp_ipa_free_alt_tx_ring(struct dp_soc *soc)
1324*5113495bSYour Name {
1325*5113495bSYour Name }
1326*5113495bSYour Name #endif /* DP_MEMORY_OPT */
1327*5113495bSYour Name 
dp_ipa_hal_tx_init_alt_data_ring(struct dp_soc * soc)1328*5113495bSYour Name void dp_ipa_hal_tx_init_alt_data_ring(struct dp_soc *soc)
1329*5113495bSYour Name {
1330*5113495bSYour Name 	hal_tx_init_data_ring(soc->hal_soc,
1331*5113495bSYour Name 			      soc->tcl_data_ring[IPA_TX_ALT_RING_IDX].hal_srng);
1332*5113495bSYour Name }
1333*5113495bSYour Name 
1334*5113495bSYour Name #else /* !IPA_WDI3_TX_TWO_PIPES */
dp_ipa_init_alt_tx_ring(struct dp_soc * soc)1335*5113495bSYour Name static int dp_ipa_init_alt_tx_ring(struct dp_soc *soc)
1336*5113495bSYour Name {
1337*5113495bSYour Name 	return 0;
1338*5113495bSYour Name }
1339*5113495bSYour Name 
dp_ipa_deinit_alt_tx_ring(struct dp_soc * soc)1340*5113495bSYour Name static void dp_ipa_deinit_alt_tx_ring(struct dp_soc *soc)
1341*5113495bSYour Name {
1342*5113495bSYour Name }
1343*5113495bSYour Name 
dp_ipa_alloc_alt_tx_ring(struct dp_soc * soc)1344*5113495bSYour Name static int dp_ipa_alloc_alt_tx_ring(struct dp_soc *soc)
1345*5113495bSYour Name {
1346*5113495bSYour Name 	return 0;
1347*5113495bSYour Name }
1348*5113495bSYour Name 
dp_ipa_free_alt_tx_ring(struct dp_soc * soc)1349*5113495bSYour Name static void dp_ipa_free_alt_tx_ring(struct dp_soc *soc)
1350*5113495bSYour Name {
1351*5113495bSYour Name }
1352*5113495bSYour Name 
dp_ipa_hal_tx_init_alt_data_ring(struct dp_soc * soc)1353*5113495bSYour Name void dp_ipa_hal_tx_init_alt_data_ring(struct dp_soc *soc)
1354*5113495bSYour Name {
1355*5113495bSYour Name }
1356*5113495bSYour Name 
1357*5113495bSYour Name #endif /* IPA_WDI3_TX_TWO_PIPES */
1358*5113495bSYour Name 
1359*5113495bSYour Name #else
1360*5113495bSYour Name 
1361*5113495bSYour Name #define REO_DST_RING_SIZE_QCA6290 1024
1362*5113495bSYour Name 
dp_ipa_init_alt_tx_ring(struct dp_soc * soc)1363*5113495bSYour Name static int dp_ipa_init_alt_tx_ring(struct dp_soc *soc)
1364*5113495bSYour Name {
1365*5113495bSYour Name 	return 0;
1366*5113495bSYour Name }
1367*5113495bSYour Name 
dp_ipa_deinit_alt_tx_ring(struct dp_soc * soc)1368*5113495bSYour Name static void dp_ipa_deinit_alt_tx_ring(struct dp_soc *soc)
1369*5113495bSYour Name {
1370*5113495bSYour Name }
1371*5113495bSYour Name 
dp_ipa_alloc_alt_tx_ring(struct dp_soc * soc)1372*5113495bSYour Name static int dp_ipa_alloc_alt_tx_ring(struct dp_soc *soc)
1373*5113495bSYour Name {
1374*5113495bSYour Name 	return 0;
1375*5113495bSYour Name }
1376*5113495bSYour Name 
dp_ipa_free_alt_tx_ring(struct dp_soc * soc)1377*5113495bSYour Name static void dp_ipa_free_alt_tx_ring(struct dp_soc *soc)
1378*5113495bSYour Name {
1379*5113495bSYour Name }
1380*5113495bSYour Name 
dp_ipa_hal_tx_init_alt_data_ring(struct dp_soc * soc)1381*5113495bSYour Name void dp_ipa_hal_tx_init_alt_data_ring(struct dp_soc *soc)
1382*5113495bSYour Name {
1383*5113495bSYour Name }
1384*5113495bSYour Name 
1385*5113495bSYour Name #endif /* IPA_OFFLOAD */
1386*5113495bSYour Name 
1387*5113495bSYour Name /**
1388*5113495bSYour Name  * dp_soc_reset_cpu_ring_map() - Reset cpu ring map
1389*5113495bSYour Name  * @soc: Datapath soc handler
1390*5113495bSYour Name  *
1391*5113495bSYour Name  * This api resets the default cpu ring map
1392*5113495bSYour Name  */
dp_soc_reset_cpu_ring_map(struct dp_soc * soc)1393*5113495bSYour Name void dp_soc_reset_cpu_ring_map(struct dp_soc *soc)
1394*5113495bSYour Name {
1395*5113495bSYour Name 	uint8_t i;
1396*5113495bSYour Name 	int nss_config = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
1397*5113495bSYour Name 
1398*5113495bSYour Name 	for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
1399*5113495bSYour Name 		switch (nss_config) {
1400*5113495bSYour Name 		case dp_nss_cfg_first_radio:
1401*5113495bSYour Name 			/*
1402*5113495bSYour Name 			 * Setting Tx ring map for one nss offloaded radio
1403*5113495bSYour Name 			 */
1404*5113495bSYour Name 			soc->tx_ring_map[i] = dp_cpu_ring_map[DP_NSS_FIRST_RADIO_OFFLOADED_MAP][i];
1405*5113495bSYour Name 			break;
1406*5113495bSYour Name 
1407*5113495bSYour Name 		case dp_nss_cfg_second_radio:
1408*5113495bSYour Name 			/*
1409*5113495bSYour Name 			 * Setting Tx ring for two nss offloaded radios
1410*5113495bSYour Name 			 */
1411*5113495bSYour Name 			soc->tx_ring_map[i] = dp_cpu_ring_map[DP_NSS_SECOND_RADIO_OFFLOADED_MAP][i];
1412*5113495bSYour Name 			break;
1413*5113495bSYour Name 
1414*5113495bSYour Name 		case dp_nss_cfg_dbdc:
1415*5113495bSYour Name 			/*
1416*5113495bSYour Name 			 * Setting Tx ring map for 2 nss offloaded radios
1417*5113495bSYour Name 			 */
1418*5113495bSYour Name 			soc->tx_ring_map[i] =
1419*5113495bSYour Name 				dp_cpu_ring_map[DP_NSS_DBDC_OFFLOADED_MAP][i];
1420*5113495bSYour Name 			break;
1421*5113495bSYour Name 
1422*5113495bSYour Name 		case dp_nss_cfg_dbtc:
1423*5113495bSYour Name 			/*
1424*5113495bSYour Name 			 * Setting Tx ring map for 3 nss offloaded radios
1425*5113495bSYour Name 			 */
1426*5113495bSYour Name 			soc->tx_ring_map[i] =
1427*5113495bSYour Name 				dp_cpu_ring_map[DP_NSS_DBTC_OFFLOADED_MAP][i];
1428*5113495bSYour Name 			break;
1429*5113495bSYour Name 
1430*5113495bSYour Name 		default:
1431*5113495bSYour Name 			dp_err("tx_ring_map failed due to invalid nss cfg");
1432*5113495bSYour Name 			break;
1433*5113495bSYour Name 		}
1434*5113495bSYour Name 	}
1435*5113495bSYour Name }
1436*5113495bSYour Name 
1437*5113495bSYour Name /**
1438*5113495bSYour Name  * dp_soc_disable_unused_mac_intr_mask() - reset interrupt mask for
1439*5113495bSYour Name  *					  unused WMAC hw rings
1440*5113495bSYour Name  * @soc: DP Soc handle
1441*5113495bSYour Name  * @mac_num: wmac num
1442*5113495bSYour Name  *
1443*5113495bSYour Name  * Return: Return void
1444*5113495bSYour Name  */
dp_soc_disable_unused_mac_intr_mask(struct dp_soc * soc,int mac_num)1445*5113495bSYour Name static void dp_soc_disable_unused_mac_intr_mask(struct dp_soc *soc,
1446*5113495bSYour Name 						int mac_num)
1447*5113495bSYour Name {
1448*5113495bSYour Name 	uint8_t *grp_mask = NULL;
1449*5113495bSYour Name 	int group_number;
1450*5113495bSYour Name 
1451*5113495bSYour Name 	grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_ring_mask[0];
1452*5113495bSYour Name 	group_number = dp_srng_find_ring_in_mask(mac_num, grp_mask);
1453*5113495bSYour Name 	if (group_number < 0)
1454*5113495bSYour Name 		dp_init_debug("%pK: ring not part of any group; ring_type: RXDMA_BUF, mac_num %d",
1455*5113495bSYour Name 			      soc, mac_num);
1456*5113495bSYour Name 	else
1457*5113495bSYour Name 		wlan_cfg_set_host2rxdma_ring_mask(soc->wlan_cfg_ctx,
1458*5113495bSYour Name 						  group_number, 0x0);
1459*5113495bSYour Name 
1460*5113495bSYour Name 	grp_mask = &soc->wlan_cfg_ctx->int_rx_mon_ring_mask[0];
1461*5113495bSYour Name 	group_number = dp_srng_find_ring_in_mask(mac_num, grp_mask);
1462*5113495bSYour Name 	if (group_number < 0)
1463*5113495bSYour Name 		dp_init_debug("%pK: ring not part of any group; ring_type: RXDMA_MONITOR_DST, mac_num %d",
1464*5113495bSYour Name 			      soc, mac_num);
1465*5113495bSYour Name 	else
1466*5113495bSYour Name 		wlan_cfg_set_rx_mon_ring_mask(soc->wlan_cfg_ctx,
1467*5113495bSYour Name 					      group_number, 0x0);
1468*5113495bSYour Name 
1469*5113495bSYour Name 	grp_mask = &soc->wlan_cfg_ctx->int_rxdma2host_ring_mask[0];
1470*5113495bSYour Name 	group_number = dp_srng_find_ring_in_mask(mac_num, grp_mask);
1471*5113495bSYour Name 	if (group_number < 0)
1472*5113495bSYour Name 		dp_init_debug("%pK: ring not part of any group; ring_type: RXDMA_DST, mac_num %d",
1473*5113495bSYour Name 			      soc, mac_num);
1474*5113495bSYour Name 	else
1475*5113495bSYour Name 		wlan_cfg_set_rxdma2host_ring_mask(soc->wlan_cfg_ctx,
1476*5113495bSYour Name 						  group_number, 0x0);
1477*5113495bSYour Name 
1478*5113495bSYour Name 	grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_mon_ring_mask[0];
1479*5113495bSYour Name 	group_number = dp_srng_find_ring_in_mask(mac_num, grp_mask);
1480*5113495bSYour Name 	if (group_number < 0)
1481*5113495bSYour Name 		dp_init_debug("%pK: ring not part of any group; ring_type: RXDMA_MONITOR_BUF, mac_num %d",
1482*5113495bSYour Name 			      soc, mac_num);
1483*5113495bSYour Name 	else
1484*5113495bSYour Name 		wlan_cfg_set_host2rxdma_mon_ring_mask(soc->wlan_cfg_ctx,
1485*5113495bSYour Name 						      group_number, 0x0);
1486*5113495bSYour Name }
1487*5113495bSYour Name 
1488*5113495bSYour Name #ifdef IPA_OFFLOAD
1489*5113495bSYour Name #ifdef IPA_WDI3_VLAN_SUPPORT
1490*5113495bSYour Name /**
1491*5113495bSYour Name  * dp_soc_reset_ipa_vlan_intr_mask() - reset interrupt mask for IPA offloaded
1492*5113495bSYour Name  *                                     ring for vlan tagged traffic
1493*5113495bSYour Name  * @soc: DP Soc handle
1494*5113495bSYour Name  *
1495*5113495bSYour Name  * Return: Return void
1496*5113495bSYour Name  */
dp_soc_reset_ipa_vlan_intr_mask(struct dp_soc * soc)1497*5113495bSYour Name void dp_soc_reset_ipa_vlan_intr_mask(struct dp_soc *soc)
1498*5113495bSYour Name {
1499*5113495bSYour Name 	uint8_t *grp_mask = NULL;
1500*5113495bSYour Name 	int group_number, mask;
1501*5113495bSYour Name 
1502*5113495bSYour Name 	if (!wlan_ipa_is_vlan_enabled())
1503*5113495bSYour Name 		return;
1504*5113495bSYour Name 
1505*5113495bSYour Name 	grp_mask = &soc->wlan_cfg_ctx->int_rx_ring_mask[0];
1506*5113495bSYour Name 
1507*5113495bSYour Name 	group_number = dp_srng_find_ring_in_mask(IPA_ALT_REO_DEST_RING_IDX, grp_mask);
1508*5113495bSYour Name 	if (group_number < 0) {
1509*5113495bSYour Name 		dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d",
1510*5113495bSYour Name 			      soc, REO_DST, IPA_ALT_REO_DEST_RING_IDX);
1511*5113495bSYour Name 		return;
1512*5113495bSYour Name 	}
1513*5113495bSYour Name 
1514*5113495bSYour Name 	mask =  wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, group_number);
1515*5113495bSYour Name 
1516*5113495bSYour Name 	/* reset the interrupt mask for offloaded ring */
1517*5113495bSYour Name 	mask &= (~(1 << IPA_ALT_REO_DEST_RING_IDX));
1518*5113495bSYour Name 
1519*5113495bSYour Name 	/*
1520*5113495bSYour Name 	 * set the interrupt mask to zero for rx offloaded radio.
1521*5113495bSYour Name 	 */
1522*5113495bSYour Name 	wlan_cfg_set_rx_ring_mask(soc->wlan_cfg_ctx, group_number, mask);
1523*5113495bSYour Name }
1524*5113495bSYour Name #else
1525*5113495bSYour Name inline
dp_soc_reset_ipa_vlan_intr_mask(struct dp_soc * soc)1526*5113495bSYour Name void dp_soc_reset_ipa_vlan_intr_mask(struct dp_soc *soc)
1527*5113495bSYour Name { }
1528*5113495bSYour Name #endif /* IPA_WDI3_VLAN_SUPPORT */
1529*5113495bSYour Name #else
1530*5113495bSYour Name inline
dp_soc_reset_ipa_vlan_intr_mask(struct dp_soc * soc)1531*5113495bSYour Name void dp_soc_reset_ipa_vlan_intr_mask(struct dp_soc *soc)
1532*5113495bSYour Name { }
1533*5113495bSYour Name #endif /* IPA_OFFLOAD */
1534*5113495bSYour Name 
1535*5113495bSYour Name /**
1536*5113495bSYour Name  * dp_soc_reset_intr_mask() - reset interrupt mask
1537*5113495bSYour Name  * @soc: DP Soc handle
1538*5113495bSYour Name  *
1539*5113495bSYour Name  * Return: Return void
1540*5113495bSYour Name  */
dp_soc_reset_intr_mask(struct dp_soc * soc)1541*5113495bSYour Name void dp_soc_reset_intr_mask(struct dp_soc *soc)
1542*5113495bSYour Name {
1543*5113495bSYour Name 	uint8_t j;
1544*5113495bSYour Name 	uint8_t *grp_mask = NULL;
1545*5113495bSYour Name 	int group_number, mask, num_ring;
1546*5113495bSYour Name 
1547*5113495bSYour Name 	/* number of tx ring */
1548*5113495bSYour Name 	num_ring = soc->num_tcl_data_rings;
1549*5113495bSYour Name 
1550*5113495bSYour Name 	/*
1551*5113495bSYour Name 	 * group mask for tx completion  ring.
1552*5113495bSYour Name 	 */
1553*5113495bSYour Name 	grp_mask =  &soc->wlan_cfg_ctx->int_tx_ring_mask[0];
1554*5113495bSYour Name 
1555*5113495bSYour Name 	/* loop and reset the mask for only offloaded ring */
1556*5113495bSYour Name 	for (j = 0; j < WLAN_CFG_NUM_TCL_DATA_RINGS; j++) {
1557*5113495bSYour Name 		/*
1558*5113495bSYour Name 		 * Group number corresponding to tx offloaded ring.
1559*5113495bSYour Name 		 */
1560*5113495bSYour Name 		group_number = dp_srng_find_ring_in_mask(j, grp_mask);
1561*5113495bSYour Name 		if (group_number < 0) {
1562*5113495bSYour Name 			dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d",
1563*5113495bSYour Name 				      soc, WBM2SW_RELEASE, j);
1564*5113495bSYour Name 			continue;
1565*5113495bSYour Name 		}
1566*5113495bSYour Name 
1567*5113495bSYour Name 		mask = wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, group_number);
1568*5113495bSYour Name 		if (!dp_soc_ring_if_nss_offloaded(soc, WBM2SW_RELEASE, j) &&
1569*5113495bSYour Name 		    (!mask)) {
1570*5113495bSYour Name 			continue;
1571*5113495bSYour Name 		}
1572*5113495bSYour Name 
1573*5113495bSYour Name 		/* reset the tx mask for offloaded ring */
1574*5113495bSYour Name 		mask &= (~(1 << j));
1575*5113495bSYour Name 
1576*5113495bSYour Name 		/*
1577*5113495bSYour Name 		 * reset the interrupt mask for offloaded ring.
1578*5113495bSYour Name 		 */
1579*5113495bSYour Name 		wlan_cfg_set_tx_ring_mask(soc->wlan_cfg_ctx, group_number, mask);
1580*5113495bSYour Name 	}
1581*5113495bSYour Name 
1582*5113495bSYour Name 	/* number of rx rings */
1583*5113495bSYour Name 	num_ring = soc->num_reo_dest_rings;
1584*5113495bSYour Name 
1585*5113495bSYour Name 	/*
1586*5113495bSYour Name 	 * group mask for reo destination ring.
1587*5113495bSYour Name 	 */
1588*5113495bSYour Name 	grp_mask = &soc->wlan_cfg_ctx->int_rx_ring_mask[0];
1589*5113495bSYour Name 
1590*5113495bSYour Name 	/* loop and reset the mask for only offloaded ring */
1591*5113495bSYour Name 	for (j = 0; j < WLAN_CFG_NUM_REO_DEST_RING; j++) {
1592*5113495bSYour Name 		/*
1593*5113495bSYour Name 		 * Group number corresponding to rx offloaded ring.
1594*5113495bSYour Name 		 */
1595*5113495bSYour Name 		group_number = dp_srng_find_ring_in_mask(j, grp_mask);
1596*5113495bSYour Name 		if (group_number < 0) {
1597*5113495bSYour Name 			dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d",
1598*5113495bSYour Name 				      soc, REO_DST, j);
1599*5113495bSYour Name 			continue;
1600*5113495bSYour Name 		}
1601*5113495bSYour Name 
1602*5113495bSYour Name 		mask =  wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, group_number);
1603*5113495bSYour Name 		if (!dp_soc_ring_if_nss_offloaded(soc, REO_DST, j) &&
1604*5113495bSYour Name 		    (!mask)) {
1605*5113495bSYour Name 			continue;
1606*5113495bSYour Name 		}
1607*5113495bSYour Name 
1608*5113495bSYour Name 		/* reset the interrupt mask for offloaded ring */
1609*5113495bSYour Name 		mask &= (~(1 << j));
1610*5113495bSYour Name 
1611*5113495bSYour Name 		/*
1612*5113495bSYour Name 		 * set the interrupt mask to zero for rx offloaded radio.
1613*5113495bSYour Name 		 */
1614*5113495bSYour Name 		wlan_cfg_set_rx_ring_mask(soc->wlan_cfg_ctx, group_number, mask);
1615*5113495bSYour Name 	}
1616*5113495bSYour Name 
1617*5113495bSYour Name 	/*
1618*5113495bSYour Name 	 * group mask for Rx buffer refill ring
1619*5113495bSYour Name 	 */
1620*5113495bSYour Name 	grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_ring_mask[0];
1621*5113495bSYour Name 
1622*5113495bSYour Name 	/* loop and reset the mask for only offloaded ring */
1623*5113495bSYour Name 	for (j = 0; j < MAX_PDEV_CNT; j++) {
1624*5113495bSYour Name 		int lmac_id = wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx, j);
1625*5113495bSYour Name 
1626*5113495bSYour Name 		if (!dp_soc_ring_if_nss_offloaded(soc, RXDMA_BUF, j)) {
1627*5113495bSYour Name 			continue;
1628*5113495bSYour Name 		}
1629*5113495bSYour Name 
1630*5113495bSYour Name 		/*
1631*5113495bSYour Name 		 * Group number corresponding to rx offloaded ring.
1632*5113495bSYour Name 		 */
1633*5113495bSYour Name 		group_number = dp_srng_find_ring_in_mask(lmac_id, grp_mask);
1634*5113495bSYour Name 		if (group_number < 0) {
1635*5113495bSYour Name 			dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d",
1636*5113495bSYour Name 				      soc, REO_DST, lmac_id);
1637*5113495bSYour Name 			continue;
1638*5113495bSYour Name 		}
1639*5113495bSYour Name 
1640*5113495bSYour Name 		/* set the interrupt mask for offloaded ring */
1641*5113495bSYour Name 		mask =  wlan_cfg_get_host2rxdma_ring_mask(soc->wlan_cfg_ctx,
1642*5113495bSYour Name 							  group_number);
1643*5113495bSYour Name 		mask &= (~(1 << lmac_id));
1644*5113495bSYour Name 
1645*5113495bSYour Name 		/*
1646*5113495bSYour Name 		 * set the interrupt mask to zero for rx offloaded radio.
1647*5113495bSYour Name 		 */
1648*5113495bSYour Name 		wlan_cfg_set_host2rxdma_ring_mask(soc->wlan_cfg_ctx,
1649*5113495bSYour Name 						  group_number, mask);
1650*5113495bSYour Name 	}
1651*5113495bSYour Name 
1652*5113495bSYour Name 	grp_mask = &soc->wlan_cfg_ctx->int_rx_err_ring_mask[0];
1653*5113495bSYour Name 
1654*5113495bSYour Name 	for (j = 0; j < num_ring; j++) {
1655*5113495bSYour Name 		if (!dp_soc_ring_if_nss_offloaded(soc, REO_EXCEPTION, j)) {
1656*5113495bSYour Name 			continue;
1657*5113495bSYour Name 		}
1658*5113495bSYour Name 
1659*5113495bSYour Name 		/*
1660*5113495bSYour Name 		 * Group number corresponding to rx err ring.
1661*5113495bSYour Name 		 */
1662*5113495bSYour Name 		group_number = dp_srng_find_ring_in_mask(j, grp_mask);
1663*5113495bSYour Name 		if (group_number < 0) {
1664*5113495bSYour Name 			dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d",
1665*5113495bSYour Name 				      soc, REO_EXCEPTION, j);
1666*5113495bSYour Name 			continue;
1667*5113495bSYour Name 		}
1668*5113495bSYour Name 
1669*5113495bSYour Name 		wlan_cfg_set_rx_err_ring_mask(soc->wlan_cfg_ctx,
1670*5113495bSYour Name 					      group_number, 0);
1671*5113495bSYour Name 	}
1672*5113495bSYour Name }
1673*5113495bSYour Name 
1674*5113495bSYour Name #ifdef IPA_OFFLOAD
dp_reo_remap_config(struct dp_soc * soc,uint32_t * remap0,uint32_t * remap1,uint32_t * remap2)1675*5113495bSYour Name bool dp_reo_remap_config(struct dp_soc *soc, uint32_t *remap0,
1676*5113495bSYour Name 			 uint32_t *remap1, uint32_t *remap2)
1677*5113495bSYour Name {
1678*5113495bSYour Name 	uint32_t ring[WLAN_CFG_NUM_REO_DEST_RING_MAX] = {
1679*5113495bSYour Name 				REO_REMAP_SW1, REO_REMAP_SW2, REO_REMAP_SW3,
1680*5113495bSYour Name 				REO_REMAP_SW5, REO_REMAP_SW6, REO_REMAP_SW7};
1681*5113495bSYour Name 
1682*5113495bSYour Name 	switch (soc->arch_id) {
1683*5113495bSYour Name 	case CDP_ARCH_TYPE_BE:
1684*5113495bSYour Name 		hal_compute_reo_remap_ix2_ix3(soc->hal_soc, ring,
1685*5113495bSYour Name 					      soc->num_reo_dest_rings -
1686*5113495bSYour Name 					      USE_2_IPA_RX_REO_RINGS, remap1,
1687*5113495bSYour Name 					      remap2);
1688*5113495bSYour Name 		break;
1689*5113495bSYour Name 
1690*5113495bSYour Name 	case CDP_ARCH_TYPE_LI:
1691*5113495bSYour Name 		if (wlan_ipa_is_vlan_enabled()) {
1692*5113495bSYour Name 			hal_compute_reo_remap_ix2_ix3(
1693*5113495bSYour Name 					soc->hal_soc, ring,
1694*5113495bSYour Name 					soc->num_reo_dest_rings -
1695*5113495bSYour Name 					USE_2_IPA_RX_REO_RINGS, remap1,
1696*5113495bSYour Name 					remap2);
1697*5113495bSYour Name 
1698*5113495bSYour Name 		} else {
1699*5113495bSYour Name 			hal_compute_reo_remap_ix2_ix3(
1700*5113495bSYour Name 					soc->hal_soc, ring,
1701*5113495bSYour Name 					soc->num_reo_dest_rings -
1702*5113495bSYour Name 					USE_1_IPA_RX_REO_RING, remap1,
1703*5113495bSYour Name 					remap2);
1704*5113495bSYour Name 		}
1705*5113495bSYour Name 
1706*5113495bSYour Name 		hal_compute_reo_remap_ix0(soc->hal_soc, remap0);
1707*5113495bSYour Name 		break;
1708*5113495bSYour Name 	default:
1709*5113495bSYour Name 		dp_err("unknown arch_id 0x%x", soc->arch_id);
1710*5113495bSYour Name 		QDF_BUG(0);
1711*5113495bSYour Name 	}
1712*5113495bSYour Name 
1713*5113495bSYour Name 	dp_debug("remap1 %x remap2 %x", *remap1, *remap2);
1714*5113495bSYour Name 
1715*5113495bSYour Name 	return true;
1716*5113495bSYour Name }
1717*5113495bSYour Name 
1718*5113495bSYour Name #ifdef IPA_WDI3_TX_TWO_PIPES
dp_ipa_is_alt_tx_ring(int index)1719*5113495bSYour Name static bool dp_ipa_is_alt_tx_ring(int index)
1720*5113495bSYour Name {
1721*5113495bSYour Name 	return index == IPA_TX_ALT_RING_IDX;
1722*5113495bSYour Name }
1723*5113495bSYour Name 
dp_ipa_is_alt_tx_comp_ring(int index)1724*5113495bSYour Name static bool dp_ipa_is_alt_tx_comp_ring(int index)
1725*5113495bSYour Name {
1726*5113495bSYour Name 	return index == IPA_TX_ALT_COMP_RING_IDX;
1727*5113495bSYour Name }
1728*5113495bSYour Name #else /* !IPA_WDI3_TX_TWO_PIPES */
dp_ipa_is_alt_tx_ring(int index)1729*5113495bSYour Name static bool dp_ipa_is_alt_tx_ring(int index)
1730*5113495bSYour Name {
1731*5113495bSYour Name 	return false;
1732*5113495bSYour Name }
1733*5113495bSYour Name 
dp_ipa_is_alt_tx_comp_ring(int index)1734*5113495bSYour Name static bool dp_ipa_is_alt_tx_comp_ring(int index)
1735*5113495bSYour Name {
1736*5113495bSYour Name 	return false;
1737*5113495bSYour Name }
1738*5113495bSYour Name #endif /* IPA_WDI3_TX_TWO_PIPES */
1739*5113495bSYour Name 
1740*5113495bSYour Name /**
1741*5113495bSYour Name  * dp_ipa_get_tx_ring_size() - Get Tx ring size for IPA
1742*5113495bSYour Name  *
1743*5113495bSYour Name  * @tx_ring_num: Tx ring number
1744*5113495bSYour Name  * @tx_ipa_ring_sz: Return param only updated for IPA.
1745*5113495bSYour Name  * @soc_cfg_ctx: dp soc cfg context
1746*5113495bSYour Name  *
1747*5113495bSYour Name  * Return: None
1748*5113495bSYour Name  */
dp_ipa_get_tx_ring_size(int tx_ring_num,int * tx_ipa_ring_sz,struct wlan_cfg_dp_soc_ctxt * soc_cfg_ctx)1749*5113495bSYour Name static void dp_ipa_get_tx_ring_size(int tx_ring_num, int *tx_ipa_ring_sz,
1750*5113495bSYour Name 				    struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx)
1751*5113495bSYour Name {
1752*5113495bSYour Name 	if (!soc_cfg_ctx->ipa_enabled)
1753*5113495bSYour Name 		return;
1754*5113495bSYour Name 
1755*5113495bSYour Name 	if (tx_ring_num == IPA_TCL_DATA_RING_IDX)
1756*5113495bSYour Name 		*tx_ipa_ring_sz = wlan_cfg_ipa_tx_ring_size(soc_cfg_ctx);
1757*5113495bSYour Name 	else if (dp_ipa_is_alt_tx_ring(tx_ring_num))
1758*5113495bSYour Name 		*tx_ipa_ring_sz = wlan_cfg_ipa_tx_alt_ring_size(soc_cfg_ctx);
1759*5113495bSYour Name }
1760*5113495bSYour Name 
1761*5113495bSYour Name /**
1762*5113495bSYour Name  * dp_ipa_get_tx_comp_ring_size() - Get Tx comp ring size for IPA
1763*5113495bSYour Name  *
1764*5113495bSYour Name  * @tx_comp_ring_num: Tx comp ring number
1765*5113495bSYour Name  * @tx_comp_ipa_ring_sz: Return param only updated for IPA.
1766*5113495bSYour Name  * @soc_cfg_ctx: dp soc cfg context
1767*5113495bSYour Name  *
1768*5113495bSYour Name  * Return: None
1769*5113495bSYour Name  */
dp_ipa_get_tx_comp_ring_size(int tx_comp_ring_num,int * tx_comp_ipa_ring_sz,struct wlan_cfg_dp_soc_ctxt * soc_cfg_ctx)1770*5113495bSYour Name static void dp_ipa_get_tx_comp_ring_size(int tx_comp_ring_num,
1771*5113495bSYour Name 					 int *tx_comp_ipa_ring_sz,
1772*5113495bSYour Name 				       struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx)
1773*5113495bSYour Name {
1774*5113495bSYour Name 	if (!soc_cfg_ctx->ipa_enabled)
1775*5113495bSYour Name 		return;
1776*5113495bSYour Name 
1777*5113495bSYour Name 	if (tx_comp_ring_num == IPA_TCL_DATA_RING_IDX)
1778*5113495bSYour Name 		*tx_comp_ipa_ring_sz =
1779*5113495bSYour Name 				wlan_cfg_ipa_tx_comp_ring_size(soc_cfg_ctx);
1780*5113495bSYour Name 	else if (dp_ipa_is_alt_tx_comp_ring(tx_comp_ring_num))
1781*5113495bSYour Name 		*tx_comp_ipa_ring_sz =
1782*5113495bSYour Name 				wlan_cfg_ipa_tx_alt_comp_ring_size(soc_cfg_ctx);
1783*5113495bSYour Name }
1784*5113495bSYour Name #else
dp_reo_ring_selection(uint32_t value,uint32_t * ring)1785*5113495bSYour Name static uint8_t dp_reo_ring_selection(uint32_t value, uint32_t *ring)
1786*5113495bSYour Name {
1787*5113495bSYour Name 	uint8_t num = 0;
1788*5113495bSYour Name 
1789*5113495bSYour Name 	switch (value) {
1790*5113495bSYour Name 	/* should we have all the different possible ring configs */
1791*5113495bSYour Name 	case 0xFF:
1792*5113495bSYour Name 		num = 8;
1793*5113495bSYour Name 		ring[0] = REO_REMAP_SW1;
1794*5113495bSYour Name 		ring[1] = REO_REMAP_SW2;
1795*5113495bSYour Name 		ring[2] = REO_REMAP_SW3;
1796*5113495bSYour Name 		ring[3] = REO_REMAP_SW4;
1797*5113495bSYour Name 		ring[4] = REO_REMAP_SW5;
1798*5113495bSYour Name 		ring[5] = REO_REMAP_SW6;
1799*5113495bSYour Name 		ring[6] = REO_REMAP_SW7;
1800*5113495bSYour Name 		ring[7] = REO_REMAP_SW8;
1801*5113495bSYour Name 		break;
1802*5113495bSYour Name 
1803*5113495bSYour Name 	case 0x3F:
1804*5113495bSYour Name 		num = 6;
1805*5113495bSYour Name 		ring[0] = REO_REMAP_SW1;
1806*5113495bSYour Name 		ring[1] = REO_REMAP_SW2;
1807*5113495bSYour Name 		ring[2] = REO_REMAP_SW3;
1808*5113495bSYour Name 		ring[3] = REO_REMAP_SW4;
1809*5113495bSYour Name 		ring[4] = REO_REMAP_SW5;
1810*5113495bSYour Name 		ring[5] = REO_REMAP_SW6;
1811*5113495bSYour Name 		break;
1812*5113495bSYour Name 
1813*5113495bSYour Name 	case 0xF:
1814*5113495bSYour Name 		num = 4;
1815*5113495bSYour Name 		ring[0] = REO_REMAP_SW1;
1816*5113495bSYour Name 		ring[1] = REO_REMAP_SW2;
1817*5113495bSYour Name 		ring[2] = REO_REMAP_SW3;
1818*5113495bSYour Name 		ring[3] = REO_REMAP_SW4;
1819*5113495bSYour Name 		break;
1820*5113495bSYour Name 	case 0xE:
1821*5113495bSYour Name 		num = 3;
1822*5113495bSYour Name 		ring[0] = REO_REMAP_SW2;
1823*5113495bSYour Name 		ring[1] = REO_REMAP_SW3;
1824*5113495bSYour Name 		ring[2] = REO_REMAP_SW4;
1825*5113495bSYour Name 		break;
1826*5113495bSYour Name 	case 0xD:
1827*5113495bSYour Name 		num = 3;
1828*5113495bSYour Name 		ring[0] = REO_REMAP_SW1;
1829*5113495bSYour Name 		ring[1] = REO_REMAP_SW3;
1830*5113495bSYour Name 		ring[2] = REO_REMAP_SW4;
1831*5113495bSYour Name 		break;
1832*5113495bSYour Name 	case 0xC:
1833*5113495bSYour Name 		num = 2;
1834*5113495bSYour Name 		ring[0] = REO_REMAP_SW3;
1835*5113495bSYour Name 		ring[1] = REO_REMAP_SW4;
1836*5113495bSYour Name 		break;
1837*5113495bSYour Name 	case 0xB:
1838*5113495bSYour Name 		num = 3;
1839*5113495bSYour Name 		ring[0] = REO_REMAP_SW1;
1840*5113495bSYour Name 		ring[1] = REO_REMAP_SW2;
1841*5113495bSYour Name 		ring[2] = REO_REMAP_SW4;
1842*5113495bSYour Name 		break;
1843*5113495bSYour Name 	case 0xA:
1844*5113495bSYour Name 		num = 2;
1845*5113495bSYour Name 		ring[0] = REO_REMAP_SW2;
1846*5113495bSYour Name 		ring[1] = REO_REMAP_SW4;
1847*5113495bSYour Name 		break;
1848*5113495bSYour Name 	case 0x9:
1849*5113495bSYour Name 		num = 2;
1850*5113495bSYour Name 		ring[0] = REO_REMAP_SW1;
1851*5113495bSYour Name 		ring[1] = REO_REMAP_SW4;
1852*5113495bSYour Name 		break;
1853*5113495bSYour Name 	case 0x8:
1854*5113495bSYour Name 		num = 1;
1855*5113495bSYour Name 		ring[0] = REO_REMAP_SW4;
1856*5113495bSYour Name 		break;
1857*5113495bSYour Name 	case 0x7:
1858*5113495bSYour Name 		num = 3;
1859*5113495bSYour Name 		ring[0] = REO_REMAP_SW1;
1860*5113495bSYour Name 		ring[1] = REO_REMAP_SW2;
1861*5113495bSYour Name 		ring[2] = REO_REMAP_SW3;
1862*5113495bSYour Name 		break;
1863*5113495bSYour Name 	case 0x6:
1864*5113495bSYour Name 		num = 2;
1865*5113495bSYour Name 		ring[0] = REO_REMAP_SW2;
1866*5113495bSYour Name 		ring[1] = REO_REMAP_SW3;
1867*5113495bSYour Name 		break;
1868*5113495bSYour Name 	case 0x5:
1869*5113495bSYour Name 		num = 2;
1870*5113495bSYour Name 		ring[0] = REO_REMAP_SW1;
1871*5113495bSYour Name 		ring[1] = REO_REMAP_SW3;
1872*5113495bSYour Name 		break;
1873*5113495bSYour Name 	case 0x4:
1874*5113495bSYour Name 		num = 1;
1875*5113495bSYour Name 		ring[0] = REO_REMAP_SW3;
1876*5113495bSYour Name 		break;
1877*5113495bSYour Name 	case 0x3:
1878*5113495bSYour Name 		num = 2;
1879*5113495bSYour Name 		ring[0] = REO_REMAP_SW1;
1880*5113495bSYour Name 		ring[1] = REO_REMAP_SW2;
1881*5113495bSYour Name 		break;
1882*5113495bSYour Name 	case 0x2:
1883*5113495bSYour Name 		num = 1;
1884*5113495bSYour Name 		ring[0] = REO_REMAP_SW2;
1885*5113495bSYour Name 		break;
1886*5113495bSYour Name 	case 0x1:
1887*5113495bSYour Name 		num = 1;
1888*5113495bSYour Name 		ring[0] = REO_REMAP_SW1;
1889*5113495bSYour Name 		break;
1890*5113495bSYour Name 	default:
1891*5113495bSYour Name 		dp_err("unknown reo ring map 0x%x", value);
1892*5113495bSYour Name 		QDF_BUG(0);
1893*5113495bSYour Name 	}
1894*5113495bSYour Name 	return num;
1895*5113495bSYour Name }
1896*5113495bSYour Name 
dp_reo_remap_config(struct dp_soc * soc,uint32_t * remap0,uint32_t * remap1,uint32_t * remap2)1897*5113495bSYour Name bool dp_reo_remap_config(struct dp_soc *soc,
1898*5113495bSYour Name 			 uint32_t *remap0,
1899*5113495bSYour Name 			 uint32_t *remap1,
1900*5113495bSYour Name 			 uint32_t *remap2)
1901*5113495bSYour Name {
1902*5113495bSYour Name 	uint8_t offload_radio = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
1903*5113495bSYour Name 	uint32_t reo_config = wlan_cfg_get_reo_rings_mapping(soc->wlan_cfg_ctx);
1904*5113495bSYour Name 	uint8_t num;
1905*5113495bSYour Name 	uint32_t ring[WLAN_CFG_NUM_REO_DEST_RING_MAX];
1906*5113495bSYour Name 	uint32_t value;
1907*5113495bSYour Name 
1908*5113495bSYour Name 	switch (offload_radio) {
1909*5113495bSYour Name 	case dp_nss_cfg_default:
1910*5113495bSYour Name 		value = reo_config & WLAN_CFG_NUM_REO_RINGS_MAP_MAX;
1911*5113495bSYour Name 		num = dp_reo_ring_selection(value, ring);
1912*5113495bSYour Name 		hal_compute_reo_remap_ix2_ix3(soc->hal_soc, ring,
1913*5113495bSYour Name 					      num, remap1, remap2);
1914*5113495bSYour Name 		hal_compute_reo_remap_ix0(soc->hal_soc, remap0);
1915*5113495bSYour Name 
1916*5113495bSYour Name 		break;
1917*5113495bSYour Name 	case dp_nss_cfg_first_radio:
1918*5113495bSYour Name 		value = reo_config & 0xE;
1919*5113495bSYour Name 		num = dp_reo_ring_selection(value, ring);
1920*5113495bSYour Name 		hal_compute_reo_remap_ix2_ix3(soc->hal_soc, ring,
1921*5113495bSYour Name 					      num, remap1, remap2);
1922*5113495bSYour Name 
1923*5113495bSYour Name 		break;
1924*5113495bSYour Name 	case dp_nss_cfg_second_radio:
1925*5113495bSYour Name 		value = reo_config & 0xD;
1926*5113495bSYour Name 		num = dp_reo_ring_selection(value, ring);
1927*5113495bSYour Name 		hal_compute_reo_remap_ix2_ix3(soc->hal_soc, ring,
1928*5113495bSYour Name 					      num, remap1, remap2);
1929*5113495bSYour Name 
1930*5113495bSYour Name 		break;
1931*5113495bSYour Name 	case dp_nss_cfg_dbdc:
1932*5113495bSYour Name 	case dp_nss_cfg_dbtc:
1933*5113495bSYour Name 		/* return false if both or all are offloaded to NSS */
1934*5113495bSYour Name 		return false;
1935*5113495bSYour Name 	}
1936*5113495bSYour Name 
1937*5113495bSYour Name 	dp_debug("remap1 %x remap2 %x offload_radio %u",
1938*5113495bSYour Name 		 *remap1, *remap2, offload_radio);
1939*5113495bSYour Name 	return true;
1940*5113495bSYour Name }
1941*5113495bSYour Name 
dp_ipa_get_tx_ring_size(int ring_num,int * tx_ipa_ring_sz,struct wlan_cfg_dp_soc_ctxt * soc_cfg_ctx)1942*5113495bSYour Name static void dp_ipa_get_tx_ring_size(int ring_num, int *tx_ipa_ring_sz,
1943*5113495bSYour Name 				    struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx)
1944*5113495bSYour Name {
1945*5113495bSYour Name }
1946*5113495bSYour Name 
dp_ipa_get_tx_comp_ring_size(int tx_comp_ring_num,int * tx_comp_ipa_ring_sz,struct wlan_cfg_dp_soc_ctxt * soc_cfg_ctx)1947*5113495bSYour Name static void dp_ipa_get_tx_comp_ring_size(int tx_comp_ring_num,
1948*5113495bSYour Name 					 int *tx_comp_ipa_ring_sz,
1949*5113495bSYour Name 				       struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx)
1950*5113495bSYour Name {
1951*5113495bSYour Name }
1952*5113495bSYour Name #endif /* IPA_OFFLOAD */
1953*5113495bSYour Name 
1954*5113495bSYour Name /**
1955*5113495bSYour Name  * dp_reo_frag_dst_set() - configure reo register to set the
1956*5113495bSYour Name  *                        fragment destination ring
1957*5113495bSYour Name  * @soc: Datapath soc
1958*5113495bSYour Name  * @frag_dst_ring: output parameter to set fragment destination ring
1959*5113495bSYour Name  *
1960*5113495bSYour Name  * Based on offload_radio below fragment destination rings is selected
1961*5113495bSYour Name  * 0 - TCL
1962*5113495bSYour Name  * 1 - SW1
1963*5113495bSYour Name  * 2 - SW2
1964*5113495bSYour Name  * 3 - SW3
1965*5113495bSYour Name  * 4 - SW4
1966*5113495bSYour Name  * 5 - Release
1967*5113495bSYour Name  * 6 - FW
1968*5113495bSYour Name  * 7 - alternate select
1969*5113495bSYour Name  *
1970*5113495bSYour Name  * Return: void
1971*5113495bSYour Name  */
dp_reo_frag_dst_set(struct dp_soc * soc,uint8_t * frag_dst_ring)1972*5113495bSYour Name void dp_reo_frag_dst_set(struct dp_soc *soc, uint8_t *frag_dst_ring)
1973*5113495bSYour Name {
1974*5113495bSYour Name 	uint8_t offload_radio = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
1975*5113495bSYour Name 
1976*5113495bSYour Name 	switch (offload_radio) {
1977*5113495bSYour Name 	case dp_nss_cfg_default:
1978*5113495bSYour Name 		*frag_dst_ring = REO_REMAP_TCL;
1979*5113495bSYour Name 		break;
1980*5113495bSYour Name 	case dp_nss_cfg_first_radio:
1981*5113495bSYour Name 		/*
1982*5113495bSYour Name 		 * This configuration is valid for single band radio which
1983*5113495bSYour Name 		 * is also NSS offload.
1984*5113495bSYour Name 		 */
1985*5113495bSYour Name 	case dp_nss_cfg_dbdc:
1986*5113495bSYour Name 	case dp_nss_cfg_dbtc:
1987*5113495bSYour Name 		*frag_dst_ring = HAL_SRNG_REO_ALTERNATE_SELECT;
1988*5113495bSYour Name 		break;
1989*5113495bSYour Name 	default:
1990*5113495bSYour Name 		dp_init_err("%pK: dp_reo_frag_dst_set invalid offload radio config", soc);
1991*5113495bSYour Name 		break;
1992*5113495bSYour Name 	}
1993*5113495bSYour Name }
1994*5113495bSYour Name 
1995*5113495bSYour Name #ifdef WLAN_FEATURE_STATS_EXT
dp_create_ext_stats_event(struct dp_soc * soc)1996*5113495bSYour Name static inline void dp_create_ext_stats_event(struct dp_soc *soc)
1997*5113495bSYour Name {
1998*5113495bSYour Name 	qdf_event_create(&soc->rx_hw_stats_event);
1999*5113495bSYour Name }
2000*5113495bSYour Name #else
dp_create_ext_stats_event(struct dp_soc * soc)2001*5113495bSYour Name static inline void dp_create_ext_stats_event(struct dp_soc *soc)
2002*5113495bSYour Name {
2003*5113495bSYour Name }
2004*5113495bSYour Name #endif
2005*5113495bSYour Name 
dp_deinit_tx_pair_by_index(struct dp_soc * soc,int index)2006*5113495bSYour Name static void dp_deinit_tx_pair_by_index(struct dp_soc *soc, int index)
2007*5113495bSYour Name {
2008*5113495bSYour Name 	int tcl_ring_num, wbm_ring_num;
2009*5113495bSYour Name 
2010*5113495bSYour Name 	wlan_cfg_get_tcl_wbm_ring_num_for_index(soc->wlan_cfg_ctx,
2011*5113495bSYour Name 						index,
2012*5113495bSYour Name 						&tcl_ring_num,
2013*5113495bSYour Name 						&wbm_ring_num);
2014*5113495bSYour Name 
2015*5113495bSYour Name 	if (tcl_ring_num == -1) {
2016*5113495bSYour Name 		dp_err("incorrect tcl ring num for index %u", index);
2017*5113495bSYour Name 		return;
2018*5113495bSYour Name 	}
2019*5113495bSYour Name 
2020*5113495bSYour Name 	dp_ssr_dump_srng_unregister("tcl_data_ring", index);
2021*5113495bSYour Name 	dp_ssr_dump_srng_unregister("tx_comp_ring", index);
2022*5113495bSYour Name 
2023*5113495bSYour Name 	wlan_minidump_remove(soc->tcl_data_ring[index].base_vaddr_unaligned,
2024*5113495bSYour Name 			     soc->tcl_data_ring[index].alloc_size,
2025*5113495bSYour Name 			     soc->ctrl_psoc,
2026*5113495bSYour Name 			     WLAN_MD_DP_SRNG_TCL_DATA,
2027*5113495bSYour Name 			     "tcl_data_ring");
2028*5113495bSYour Name 	dp_info("index %u tcl %u wbm %u", index, tcl_ring_num, wbm_ring_num);
2029*5113495bSYour Name 	dp_srng_deinit(soc, &soc->tcl_data_ring[index], TCL_DATA,
2030*5113495bSYour Name 		       tcl_ring_num);
2031*5113495bSYour Name 
2032*5113495bSYour Name 	if (wbm_ring_num == INVALID_WBM_RING_NUM)
2033*5113495bSYour Name 		return;
2034*5113495bSYour Name 
2035*5113495bSYour Name 	wlan_minidump_remove(soc->tx_comp_ring[index].base_vaddr_unaligned,
2036*5113495bSYour Name 			     soc->tx_comp_ring[index].alloc_size,
2037*5113495bSYour Name 			     soc->ctrl_psoc,
2038*5113495bSYour Name 			     WLAN_MD_DP_SRNG_TX_COMP,
2039*5113495bSYour Name 			     "tcl_comp_ring");
2040*5113495bSYour Name 	dp_srng_deinit(soc, &soc->tx_comp_ring[index], WBM2SW_RELEASE,
2041*5113495bSYour Name 		       wbm_ring_num);
2042*5113495bSYour Name }
2043*5113495bSYour Name 
2044*5113495bSYour Name /**
2045*5113495bSYour Name  * dp_init_tx_ring_pair_by_index() - The function inits tcl data/wbm completion
2046*5113495bSYour Name  * ring pair
2047*5113495bSYour Name  * @soc: DP soc pointer
2048*5113495bSYour Name  * @index: index of soc->tcl_data or soc->tx_comp to initialize
2049*5113495bSYour Name  *
2050*5113495bSYour Name  * Return: QDF_STATUS_SUCCESS on success, error code otherwise.
2051*5113495bSYour Name  */
dp_init_tx_ring_pair_by_index(struct dp_soc * soc,uint8_t index)2052*5113495bSYour Name static QDF_STATUS dp_init_tx_ring_pair_by_index(struct dp_soc *soc,
2053*5113495bSYour Name 						uint8_t index)
2054*5113495bSYour Name {
2055*5113495bSYour Name 	int tcl_ring_num, wbm_ring_num;
2056*5113495bSYour Name 	uint8_t bm_id;
2057*5113495bSYour Name 
2058*5113495bSYour Name 	if (index >= MAX_TCL_DATA_RINGS) {
2059*5113495bSYour Name 		dp_err("unexpected index!");
2060*5113495bSYour Name 		QDF_BUG(0);
2061*5113495bSYour Name 		goto fail1;
2062*5113495bSYour Name 	}
2063*5113495bSYour Name 
2064*5113495bSYour Name 	wlan_cfg_get_tcl_wbm_ring_num_for_index(soc->wlan_cfg_ctx,
2065*5113495bSYour Name 						index,
2066*5113495bSYour Name 						&tcl_ring_num,
2067*5113495bSYour Name 						&wbm_ring_num);
2068*5113495bSYour Name 
2069*5113495bSYour Name 	if (tcl_ring_num == -1) {
2070*5113495bSYour Name 		dp_err("incorrect tcl ring num for index %u", index);
2071*5113495bSYour Name 		goto fail1;
2072*5113495bSYour Name 	}
2073*5113495bSYour Name 
2074*5113495bSYour Name 	dp_info("index %u tcl %u wbm %u", index, tcl_ring_num, wbm_ring_num);
2075*5113495bSYour Name 	if (dp_srng_init(soc, &soc->tcl_data_ring[index], TCL_DATA,
2076*5113495bSYour Name 			 tcl_ring_num, 0)) {
2077*5113495bSYour Name 		dp_err("dp_srng_init failed for tcl_data_ring");
2078*5113495bSYour Name 		goto fail1;
2079*5113495bSYour Name 	}
2080*5113495bSYour Name 	wlan_minidump_log(soc->tcl_data_ring[index].base_vaddr_unaligned,
2081*5113495bSYour Name 			  soc->tcl_data_ring[index].alloc_size,
2082*5113495bSYour Name 			  soc->ctrl_psoc,
2083*5113495bSYour Name 			  WLAN_MD_DP_SRNG_TCL_DATA,
2084*5113495bSYour Name 			  "tcl_data_ring");
2085*5113495bSYour Name 
2086*5113495bSYour Name 	if (wbm_ring_num == INVALID_WBM_RING_NUM)
2087*5113495bSYour Name 		goto set_rbm;
2088*5113495bSYour Name 
2089*5113495bSYour Name 	if (dp_srng_init(soc, &soc->tx_comp_ring[index], WBM2SW_RELEASE,
2090*5113495bSYour Name 			 wbm_ring_num, 0)) {
2091*5113495bSYour Name 		dp_err("dp_srng_init failed for tx_comp_ring");
2092*5113495bSYour Name 		goto fail1;
2093*5113495bSYour Name 	}
2094*5113495bSYour Name 
2095*5113495bSYour Name 	dp_ssr_dump_srng_register("tcl_data_ring",
2096*5113495bSYour Name 				  &soc->tcl_data_ring[index], index);
2097*5113495bSYour Name 	dp_ssr_dump_srng_register("tx_comp_ring",
2098*5113495bSYour Name 				  &soc->tx_comp_ring[index], index);
2099*5113495bSYour Name 
2100*5113495bSYour Name 	wlan_minidump_log(soc->tx_comp_ring[index].base_vaddr_unaligned,
2101*5113495bSYour Name 			  soc->tx_comp_ring[index].alloc_size,
2102*5113495bSYour Name 			  soc->ctrl_psoc,
2103*5113495bSYour Name 			  WLAN_MD_DP_SRNG_TX_COMP,
2104*5113495bSYour Name 			  "tcl_comp_ring");
2105*5113495bSYour Name set_rbm:
2106*5113495bSYour Name 	bm_id = wlan_cfg_get_rbm_id_for_index(soc->wlan_cfg_ctx, tcl_ring_num);
2107*5113495bSYour Name 
2108*5113495bSYour Name 	soc->arch_ops.tx_implicit_rbm_set(soc, tcl_ring_num, bm_id);
2109*5113495bSYour Name 
2110*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
2111*5113495bSYour Name 
2112*5113495bSYour Name fail1:
2113*5113495bSYour Name 	return QDF_STATUS_E_FAILURE;
2114*5113495bSYour Name }
2115*5113495bSYour Name 
dp_free_tx_ring_pair_by_index(struct dp_soc * soc,uint8_t index)2116*5113495bSYour Name static void dp_free_tx_ring_pair_by_index(struct dp_soc *soc, uint8_t index)
2117*5113495bSYour Name {
2118*5113495bSYour Name 	dp_debug("index %u", index);
2119*5113495bSYour Name 	dp_srng_free(soc, &soc->tcl_data_ring[index]);
2120*5113495bSYour Name 	dp_srng_free(soc, &soc->tx_comp_ring[index]);
2121*5113495bSYour Name }
2122*5113495bSYour Name 
2123*5113495bSYour Name /**
2124*5113495bSYour Name  * dp_alloc_tx_ring_pair_by_index() - The function allocs tcl data/wbm2sw
2125*5113495bSYour Name  * ring pair for the given "index"
2126*5113495bSYour Name  * @soc: DP soc pointer
2127*5113495bSYour Name  * @index: index of soc->tcl_data or soc->tx_comp to initialize
2128*5113495bSYour Name  *
2129*5113495bSYour Name  * Return: QDF_STATUS_SUCCESS on success, error code otherwise.
2130*5113495bSYour Name  */
dp_alloc_tx_ring_pair_by_index(struct dp_soc * soc,uint8_t index)2131*5113495bSYour Name static QDF_STATUS dp_alloc_tx_ring_pair_by_index(struct dp_soc *soc,
2132*5113495bSYour Name 						 uint8_t index)
2133*5113495bSYour Name {
2134*5113495bSYour Name 	int tx_ring_size;
2135*5113495bSYour Name 	int tx_comp_ring_size;
2136*5113495bSYour Name 	struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx = soc->wlan_cfg_ctx;
2137*5113495bSYour Name 	int cached = 0;
2138*5113495bSYour Name 
2139*5113495bSYour Name 	if (index >= MAX_TCL_DATA_RINGS) {
2140*5113495bSYour Name 		dp_err("unexpected index!");
2141*5113495bSYour Name 		QDF_BUG(0);
2142*5113495bSYour Name 		goto fail1;
2143*5113495bSYour Name 	}
2144*5113495bSYour Name 
2145*5113495bSYour Name 	dp_debug("index %u", index);
2146*5113495bSYour Name 	tx_ring_size = wlan_cfg_tx_ring_size(soc_cfg_ctx);
2147*5113495bSYour Name 	dp_ipa_get_tx_ring_size(index, &tx_ring_size, soc_cfg_ctx);
2148*5113495bSYour Name 
2149*5113495bSYour Name 	if (dp_srng_alloc(soc, &soc->tcl_data_ring[index], TCL_DATA,
2150*5113495bSYour Name 			  tx_ring_size, cached)) {
2151*5113495bSYour Name 		dp_err("dp_srng_alloc failed for tcl_data_ring");
2152*5113495bSYour Name 		goto fail1;
2153*5113495bSYour Name 	}
2154*5113495bSYour Name 
2155*5113495bSYour Name 	tx_comp_ring_size = wlan_cfg_tx_comp_ring_size(soc_cfg_ctx);
2156*5113495bSYour Name 	dp_ipa_get_tx_comp_ring_size(index, &tx_comp_ring_size, soc_cfg_ctx);
2157*5113495bSYour Name 	/* Enable cached TCL desc if NSS offload is disabled */
2158*5113495bSYour Name 	if (!wlan_cfg_get_dp_soc_nss_cfg(soc_cfg_ctx))
2159*5113495bSYour Name 		cached = WLAN_CFG_DST_RING_CACHED_DESC;
2160*5113495bSYour Name 
2161*5113495bSYour Name 	if (wlan_cfg_get_wbm_ring_num_for_index(soc->wlan_cfg_ctx, index) ==
2162*5113495bSYour Name 	    INVALID_WBM_RING_NUM)
2163*5113495bSYour Name 		return QDF_STATUS_SUCCESS;
2164*5113495bSYour Name 
2165*5113495bSYour Name 	if (dp_srng_alloc(soc, &soc->tx_comp_ring[index], WBM2SW_RELEASE,
2166*5113495bSYour Name 			  tx_comp_ring_size, cached)) {
2167*5113495bSYour Name 		dp_err("dp_srng_alloc failed for tx_comp_ring");
2168*5113495bSYour Name 		goto fail1;
2169*5113495bSYour Name 	}
2170*5113495bSYour Name 
2171*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
2172*5113495bSYour Name 
2173*5113495bSYour Name fail1:
2174*5113495bSYour Name 	return QDF_STATUS_E_FAILURE;
2175*5113495bSYour Name }
2176*5113495bSYour Name 
2177*5113495bSYour Name /**
2178*5113495bSYour Name  * dp_dscp_tid_map_setup() - Initialize the dscp-tid maps
2179*5113495bSYour Name  * @pdev: DP_PDEV handle
2180*5113495bSYour Name  *
2181*5113495bSYour Name  * Return: void
2182*5113495bSYour Name  */
2183*5113495bSYour Name void
dp_dscp_tid_map_setup(struct dp_pdev * pdev)2184*5113495bSYour Name dp_dscp_tid_map_setup(struct dp_pdev *pdev)
2185*5113495bSYour Name {
2186*5113495bSYour Name 	uint8_t map_id;
2187*5113495bSYour Name 	struct dp_soc *soc = pdev->soc;
2188*5113495bSYour Name 
2189*5113495bSYour Name 	if (!soc)
2190*5113495bSYour Name 		return;
2191*5113495bSYour Name 
2192*5113495bSYour Name 	for (map_id = 0; map_id < DP_MAX_TID_MAPS; map_id++) {
2193*5113495bSYour Name 		qdf_mem_copy(pdev->dscp_tid_map[map_id],
2194*5113495bSYour Name 			     default_dscp_tid_map,
2195*5113495bSYour Name 			     sizeof(default_dscp_tid_map));
2196*5113495bSYour Name 	}
2197*5113495bSYour Name 
2198*5113495bSYour Name 	for (map_id = 0; map_id < soc->num_hw_dscp_tid_map; map_id++) {
2199*5113495bSYour Name 		hal_tx_set_dscp_tid_map(soc->hal_soc,
2200*5113495bSYour Name 					default_dscp_tid_map,
2201*5113495bSYour Name 					map_id);
2202*5113495bSYour Name 	}
2203*5113495bSYour Name }
2204*5113495bSYour Name 
2205*5113495bSYour Name /**
2206*5113495bSYour Name  * dp_pcp_tid_map_setup() - Initialize the pcp-tid maps
2207*5113495bSYour Name  * @pdev: DP_PDEV handle
2208*5113495bSYour Name  *
2209*5113495bSYour Name  * Return: void
2210*5113495bSYour Name  */
2211*5113495bSYour Name void
dp_pcp_tid_map_setup(struct dp_pdev * pdev)2212*5113495bSYour Name dp_pcp_tid_map_setup(struct dp_pdev *pdev)
2213*5113495bSYour Name {
2214*5113495bSYour Name 	struct dp_soc *soc = pdev->soc;
2215*5113495bSYour Name 
2216*5113495bSYour Name 	if (!soc)
2217*5113495bSYour Name 		return;
2218*5113495bSYour Name 
2219*5113495bSYour Name 	qdf_mem_copy(soc->pcp_tid_map, default_pcp_tid_map,
2220*5113495bSYour Name 		     sizeof(default_pcp_tid_map));
2221*5113495bSYour Name 	hal_tx_set_pcp_tid_map_default(soc->hal_soc, default_pcp_tid_map);
2222*5113495bSYour Name }
2223*5113495bSYour Name 
2224*5113495bSYour Name #ifndef DP_UMAC_HW_RESET_SUPPORT
2225*5113495bSYour Name static inline
2226*5113495bSYour Name #endif
dp_reo_desc_freelist_destroy(struct dp_soc * soc)2227*5113495bSYour Name void dp_reo_desc_freelist_destroy(struct dp_soc *soc)
2228*5113495bSYour Name {
2229*5113495bSYour Name 	struct reo_desc_list_node *desc;
2230*5113495bSYour Name 	struct dp_rx_tid *rx_tid;
2231*5113495bSYour Name 
2232*5113495bSYour Name 	qdf_spin_lock_bh(&soc->reo_desc_freelist_lock);
2233*5113495bSYour Name 	while (qdf_list_remove_front(&soc->reo_desc_freelist,
2234*5113495bSYour Name 		(qdf_list_node_t **)&desc) == QDF_STATUS_SUCCESS) {
2235*5113495bSYour Name 		rx_tid = &desc->rx_tid;
2236*5113495bSYour Name 		qdf_mem_unmap_nbytes_single(soc->osdev,
2237*5113495bSYour Name 			rx_tid->hw_qdesc_paddr,
2238*5113495bSYour Name 			QDF_DMA_BIDIRECTIONAL,
2239*5113495bSYour Name 			rx_tid->hw_qdesc_alloc_size);
2240*5113495bSYour Name 		qdf_mem_free(rx_tid->hw_qdesc_vaddr_unaligned);
2241*5113495bSYour Name 		qdf_mem_free(desc);
2242*5113495bSYour Name 	}
2243*5113495bSYour Name 	qdf_spin_unlock_bh(&soc->reo_desc_freelist_lock);
2244*5113495bSYour Name 	qdf_list_destroy(&soc->reo_desc_freelist);
2245*5113495bSYour Name 	qdf_spinlock_destroy(&soc->reo_desc_freelist_lock);
2246*5113495bSYour Name }
2247*5113495bSYour Name 
2248*5113495bSYour Name #ifdef WLAN_DP_FEATURE_DEFERRED_REO_QDESC_DESTROY
2249*5113495bSYour Name /**
2250*5113495bSYour Name  * dp_reo_desc_deferred_freelist_create() - Initialize the resources used
2251*5113495bSYour Name  *                                          for deferred reo desc list
2252*5113495bSYour Name  * @soc: Datapath soc handle
2253*5113495bSYour Name  *
2254*5113495bSYour Name  * Return: void
2255*5113495bSYour Name  */
dp_reo_desc_deferred_freelist_create(struct dp_soc * soc)2256*5113495bSYour Name static void dp_reo_desc_deferred_freelist_create(struct dp_soc *soc)
2257*5113495bSYour Name {
2258*5113495bSYour Name 	qdf_spinlock_create(&soc->reo_desc_deferred_freelist_lock);
2259*5113495bSYour Name 	qdf_list_create(&soc->reo_desc_deferred_freelist,
2260*5113495bSYour Name 			REO_DESC_DEFERRED_FREELIST_SIZE);
2261*5113495bSYour Name 	soc->reo_desc_deferred_freelist_init = true;
2262*5113495bSYour Name }
2263*5113495bSYour Name 
2264*5113495bSYour Name /**
2265*5113495bSYour Name  * dp_reo_desc_deferred_freelist_destroy() - loop the deferred free list &
2266*5113495bSYour Name  *                                           free the leftover REO QDESCs
2267*5113495bSYour Name  * @soc: Datapath soc handle
2268*5113495bSYour Name  *
2269*5113495bSYour Name  * Return: void
2270*5113495bSYour Name  */
dp_reo_desc_deferred_freelist_destroy(struct dp_soc * soc)2271*5113495bSYour Name static void dp_reo_desc_deferred_freelist_destroy(struct dp_soc *soc)
2272*5113495bSYour Name {
2273*5113495bSYour Name 	struct reo_desc_deferred_freelist_node *desc;
2274*5113495bSYour Name 
2275*5113495bSYour Name 	qdf_spin_lock_bh(&soc->reo_desc_deferred_freelist_lock);
2276*5113495bSYour Name 	soc->reo_desc_deferred_freelist_init = false;
2277*5113495bSYour Name 	while (qdf_list_remove_front(&soc->reo_desc_deferred_freelist,
2278*5113495bSYour Name 	       (qdf_list_node_t **)&desc) == QDF_STATUS_SUCCESS) {
2279*5113495bSYour Name 		qdf_mem_unmap_nbytes_single(soc->osdev,
2280*5113495bSYour Name 					    desc->hw_qdesc_paddr,
2281*5113495bSYour Name 					    QDF_DMA_BIDIRECTIONAL,
2282*5113495bSYour Name 					    desc->hw_qdesc_alloc_size);
2283*5113495bSYour Name 		qdf_mem_free(desc->hw_qdesc_vaddr_unaligned);
2284*5113495bSYour Name 		qdf_mem_free(desc);
2285*5113495bSYour Name 	}
2286*5113495bSYour Name 	qdf_spin_unlock_bh(&soc->reo_desc_deferred_freelist_lock);
2287*5113495bSYour Name 
2288*5113495bSYour Name 	qdf_list_destroy(&soc->reo_desc_deferred_freelist);
2289*5113495bSYour Name 	qdf_spinlock_destroy(&soc->reo_desc_deferred_freelist_lock);
2290*5113495bSYour Name }
2291*5113495bSYour Name #else
dp_reo_desc_deferred_freelist_create(struct dp_soc * soc)2292*5113495bSYour Name static inline void dp_reo_desc_deferred_freelist_create(struct dp_soc *soc)
2293*5113495bSYour Name {
2294*5113495bSYour Name }
2295*5113495bSYour Name 
dp_reo_desc_deferred_freelist_destroy(struct dp_soc * soc)2296*5113495bSYour Name static inline void dp_reo_desc_deferred_freelist_destroy(struct dp_soc *soc)
2297*5113495bSYour Name {
2298*5113495bSYour Name }
2299*5113495bSYour Name #endif /* !WLAN_DP_FEATURE_DEFERRED_REO_QDESC_DESTROY */
2300*5113495bSYour Name 
2301*5113495bSYour Name /**
2302*5113495bSYour Name  * dp_soc_reset_txrx_ring_map() - reset tx ring map
2303*5113495bSYour Name  * @soc: DP SOC handle
2304*5113495bSYour Name  *
2305*5113495bSYour Name  */
dp_soc_reset_txrx_ring_map(struct dp_soc * soc)2306*5113495bSYour Name static void dp_soc_reset_txrx_ring_map(struct dp_soc *soc)
2307*5113495bSYour Name {
2308*5113495bSYour Name 	uint32_t i;
2309*5113495bSYour Name 
2310*5113495bSYour Name 	for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++)
2311*5113495bSYour Name 		soc->tx_ring_map[i] = 0;
2312*5113495bSYour Name }
2313*5113495bSYour Name 
2314*5113495bSYour Name /**
2315*5113495bSYour Name  * dp_soc_deinit() - Deinitialize txrx SOC
2316*5113495bSYour Name  * @txrx_soc: Opaque DP SOC handle
2317*5113495bSYour Name  *
2318*5113495bSYour Name  * Return: None
2319*5113495bSYour Name  */
dp_soc_deinit(void * txrx_soc)2320*5113495bSYour Name void dp_soc_deinit(void *txrx_soc)
2321*5113495bSYour Name {
2322*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)txrx_soc;
2323*5113495bSYour Name 	struct htt_soc *htt_soc = soc->htt_handle;
2324*5113495bSYour Name 
2325*5113495bSYour Name 	dp_monitor_soc_deinit(soc);
2326*5113495bSYour Name 
2327*5113495bSYour Name 	/* free peer tables & AST tables allocated during peer_map_attach */
2328*5113495bSYour Name 	if (soc->peer_map_attach_success) {
2329*5113495bSYour Name 		dp_peer_find_detach(soc);
2330*5113495bSYour Name 		soc->arch_ops.txrx_peer_map_detach(soc);
2331*5113495bSYour Name 		soc->peer_map_attach_success = FALSE;
2332*5113495bSYour Name 	}
2333*5113495bSYour Name 
2334*5113495bSYour Name 	qdf_flush_work(&soc->htt_stats.work);
2335*5113495bSYour Name 	qdf_disable_work(&soc->htt_stats.work);
2336*5113495bSYour Name 
2337*5113495bSYour Name 	qdf_spinlock_destroy(&soc->htt_stats.lock);
2338*5113495bSYour Name 
2339*5113495bSYour Name 	dp_soc_reset_txrx_ring_map(soc);
2340*5113495bSYour Name 
2341*5113495bSYour Name 	dp_reo_desc_freelist_destroy(soc);
2342*5113495bSYour Name 	dp_reo_desc_deferred_freelist_destroy(soc);
2343*5113495bSYour Name 
2344*5113495bSYour Name 	DEINIT_RX_HW_STATS_LOCK(soc);
2345*5113495bSYour Name 
2346*5113495bSYour Name 	qdf_spinlock_destroy(&soc->ast_lock);
2347*5113495bSYour Name 
2348*5113495bSYour Name 	dp_peer_mec_spinlock_destroy(soc);
2349*5113495bSYour Name 
2350*5113495bSYour Name 	qdf_nbuf_queue_free(&soc->htt_stats.msg);
2351*5113495bSYour Name 
2352*5113495bSYour Name 	qdf_nbuf_queue_free(&soc->invalid_buf_queue);
2353*5113495bSYour Name 
2354*5113495bSYour Name 	qdf_spinlock_destroy(&soc->rx.defrag.defrag_lock);
2355*5113495bSYour Name 
2356*5113495bSYour Name 	qdf_spinlock_destroy(&soc->vdev_map_lock);
2357*5113495bSYour Name 
2358*5113495bSYour Name 	dp_reo_cmdlist_destroy(soc);
2359*5113495bSYour Name 	qdf_spinlock_destroy(&soc->rx.reo_cmd_lock);
2360*5113495bSYour Name 
2361*5113495bSYour Name 	dp_soc_tx_desc_sw_pools_deinit(soc);
2362*5113495bSYour Name 
2363*5113495bSYour Name 	dp_soc_srng_deinit(soc);
2364*5113495bSYour Name 
2365*5113495bSYour Name 	dp_hw_link_desc_ring_deinit(soc);
2366*5113495bSYour Name 
2367*5113495bSYour Name 	dp_soc_print_inactive_objects(soc);
2368*5113495bSYour Name 	qdf_spinlock_destroy(&soc->inactive_peer_list_lock);
2369*5113495bSYour Name 	qdf_spinlock_destroy(&soc->inactive_vdev_list_lock);
2370*5113495bSYour Name 
2371*5113495bSYour Name 	htt_soc_htc_dealloc(soc->htt_handle);
2372*5113495bSYour Name 
2373*5113495bSYour Name 	htt_soc_detach(htt_soc);
2374*5113495bSYour Name 
2375*5113495bSYour Name 	/* Free wbm sg list and reset flags in down path */
2376*5113495bSYour Name 	dp_rx_wbm_sg_list_deinit(soc);
2377*5113495bSYour Name 
2378*5113495bSYour Name 	wlan_minidump_remove(soc, sizeof(*soc), soc->ctrl_psoc,
2379*5113495bSYour Name 			     WLAN_MD_DP_SOC, "dp_soc");
2380*5113495bSYour Name }
2381*5113495bSYour Name 
2382*5113495bSYour Name #ifdef QCA_HOST2FW_RXBUF_RING
2383*5113495bSYour Name void
dp_htt_setup_rxdma_err_dst_ring(struct dp_soc * soc,int mac_id,int lmac_id)2384*5113495bSYour Name dp_htt_setup_rxdma_err_dst_ring(struct dp_soc *soc, int mac_id,
2385*5113495bSYour Name 				int lmac_id)
2386*5113495bSYour Name {
2387*5113495bSYour Name 	if (soc->rxdma_err_dst_ring[lmac_id].hal_srng)
2388*5113495bSYour Name 		htt_srng_setup(soc->htt_handle, mac_id,
2389*5113495bSYour Name 			       soc->rxdma_err_dst_ring[lmac_id].hal_srng,
2390*5113495bSYour Name 			       RXDMA_DST);
2391*5113495bSYour Name }
2392*5113495bSYour Name #endif
2393*5113495bSYour Name 
dp_vdev_get_default_reo_hash(struct dp_vdev * vdev,enum cdp_host_reo_dest_ring * reo_dest,bool * hash_based)2394*5113495bSYour Name void dp_vdev_get_default_reo_hash(struct dp_vdev *vdev,
2395*5113495bSYour Name 				  enum cdp_host_reo_dest_ring *reo_dest,
2396*5113495bSYour Name 				  bool *hash_based)
2397*5113495bSYour Name {
2398*5113495bSYour Name 	struct dp_soc *soc;
2399*5113495bSYour Name 	struct dp_pdev *pdev;
2400*5113495bSYour Name 
2401*5113495bSYour Name 	pdev = vdev->pdev;
2402*5113495bSYour Name 	soc = pdev->soc;
2403*5113495bSYour Name 	/*
2404*5113495bSYour Name 	 * hash based steering is disabled for Radios which are offloaded
2405*5113495bSYour Name 	 * to NSS
2406*5113495bSYour Name 	 */
2407*5113495bSYour Name 	if (!wlan_cfg_get_dp_pdev_nss_enabled(pdev->wlan_cfg_ctx))
2408*5113495bSYour Name 		*hash_based = wlan_cfg_is_rx_hash_enabled(soc->wlan_cfg_ctx);
2409*5113495bSYour Name 
2410*5113495bSYour Name 	/*
2411*5113495bSYour Name 	 * Below line of code will ensure the proper reo_dest ring is chosen
2412*5113495bSYour Name 	 * for cases where toeplitz hash cannot be generated (ex: non TCP/UDP)
2413*5113495bSYour Name 	 */
2414*5113495bSYour Name 	*reo_dest = pdev->reo_dest;
2415*5113495bSYour Name }
2416*5113495bSYour Name 
2417*5113495bSYour Name #ifdef IPA_OFFLOAD
2418*5113495bSYour Name /**
2419*5113495bSYour Name  * dp_is_vdev_subtype_p2p() - Check if the subtype for vdev is P2P
2420*5113495bSYour Name  * @vdev: Virtual device
2421*5113495bSYour Name  *
2422*5113495bSYour Name  * Return: true if the vdev is of subtype P2P
2423*5113495bSYour Name  *	   false if the vdev is of any other subtype
2424*5113495bSYour Name  */
dp_is_vdev_subtype_p2p(struct dp_vdev * vdev)2425*5113495bSYour Name static inline bool dp_is_vdev_subtype_p2p(struct dp_vdev *vdev)
2426*5113495bSYour Name {
2427*5113495bSYour Name 	if (vdev->subtype == wlan_op_subtype_p2p_device ||
2428*5113495bSYour Name 	    vdev->subtype == wlan_op_subtype_p2p_cli ||
2429*5113495bSYour Name 	    vdev->subtype == wlan_op_subtype_p2p_go)
2430*5113495bSYour Name 		return true;
2431*5113495bSYour Name 
2432*5113495bSYour Name 	return false;
2433*5113495bSYour Name }
2434*5113495bSYour Name 
2435*5113495bSYour Name /**
2436*5113495bSYour Name  * dp_peer_setup_get_reo_hash() - get reo dest ring and hash values for a peer
2437*5113495bSYour Name  * @vdev: Datapath VDEV handle
2438*5113495bSYour Name  * @setup_info:
2439*5113495bSYour Name  * @reo_dest: pointer to default reo_dest ring for vdev to be populated
2440*5113495bSYour Name  * @hash_based: pointer to hash value (enabled/disabled) to be populated
2441*5113495bSYour Name  * @lmac_peer_id_msb:
2442*5113495bSYour Name  *
2443*5113495bSYour Name  * If IPA is enabled in ini, for SAP mode, disable hash based
2444*5113495bSYour Name  * steering, use default reo_dst ring for RX. Use config values for other modes.
2445*5113495bSYour Name  *
2446*5113495bSYour Name  * Return: None
2447*5113495bSYour Name  */
dp_peer_setup_get_reo_hash(struct dp_vdev * vdev,struct cdp_peer_setup_info * setup_info,enum cdp_host_reo_dest_ring * reo_dest,bool * hash_based,uint8_t * lmac_peer_id_msb)2448*5113495bSYour Name static void dp_peer_setup_get_reo_hash(struct dp_vdev *vdev,
2449*5113495bSYour Name 				       struct cdp_peer_setup_info *setup_info,
2450*5113495bSYour Name 				       enum cdp_host_reo_dest_ring *reo_dest,
2451*5113495bSYour Name 				       bool *hash_based,
2452*5113495bSYour Name 				       uint8_t *lmac_peer_id_msb)
2453*5113495bSYour Name {
2454*5113495bSYour Name 	struct dp_soc *soc;
2455*5113495bSYour Name 	struct dp_pdev *pdev;
2456*5113495bSYour Name 
2457*5113495bSYour Name 	pdev = vdev->pdev;
2458*5113495bSYour Name 	soc = pdev->soc;
2459*5113495bSYour Name 
2460*5113495bSYour Name 	dp_vdev_get_default_reo_hash(vdev, reo_dest, hash_based);
2461*5113495bSYour Name 
2462*5113495bSYour Name 	/* For P2P-GO interfaces we do not need to change the REO
2463*5113495bSYour Name 	 * configuration even if IPA config is enabled
2464*5113495bSYour Name 	 */
2465*5113495bSYour Name 	if (dp_is_vdev_subtype_p2p(vdev))
2466*5113495bSYour Name 		return;
2467*5113495bSYour Name 
2468*5113495bSYour Name 	/*
2469*5113495bSYour Name 	 * If IPA is enabled, disable hash-based flow steering and set
2470*5113495bSYour Name 	 * reo_dest_ring_4 as the REO ring to receive packets on.
2471*5113495bSYour Name 	 * IPA is configured to reap reo_dest_ring_4.
2472*5113495bSYour Name 	 *
2473*5113495bSYour Name 	 * Note - REO DST indexes are from 0 - 3, while cdp_host_reo_dest_ring
2474*5113495bSYour Name 	 * value enum value is from 1 - 4.
2475*5113495bSYour Name 	 * Hence, *reo_dest = IPA_REO_DEST_RING_IDX + 1
2476*5113495bSYour Name 	 */
2477*5113495bSYour Name 	if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) {
2478*5113495bSYour Name 		if (dp_ipa_is_mdm_platform()) {
2479*5113495bSYour Name 			*reo_dest = IPA_REO_DEST_RING_IDX + 1;
2480*5113495bSYour Name 			if (vdev->opmode == wlan_op_mode_ap)
2481*5113495bSYour Name 				*hash_based = 0;
2482*5113495bSYour Name 		} else {
2483*5113495bSYour Name 			dp_debug("opt_dp: default HOST reo ring is set");
2484*5113495bSYour Name 		}
2485*5113495bSYour Name 	}
2486*5113495bSYour Name }
2487*5113495bSYour Name 
2488*5113495bSYour Name #else
2489*5113495bSYour Name 
2490*5113495bSYour Name /**
2491*5113495bSYour Name  * dp_peer_setup_get_reo_hash() - get reo dest ring and hash values for a peer
2492*5113495bSYour Name  * @vdev: Datapath VDEV handle
2493*5113495bSYour Name  * @setup_info:
2494*5113495bSYour Name  * @reo_dest: pointer to default reo_dest ring for vdev to be populated
2495*5113495bSYour Name  * @hash_based: pointer to hash value (enabled/disabled) to be populated
2496*5113495bSYour Name  * @lmac_peer_id_msb:
2497*5113495bSYour Name  *
2498*5113495bSYour Name  * Use system config values for hash based steering.
2499*5113495bSYour Name  * Return: None
2500*5113495bSYour Name  */
dp_peer_setup_get_reo_hash(struct dp_vdev * vdev,struct cdp_peer_setup_info * setup_info,enum cdp_host_reo_dest_ring * reo_dest,bool * hash_based,uint8_t * lmac_peer_id_msb)2501*5113495bSYour Name static void dp_peer_setup_get_reo_hash(struct dp_vdev *vdev,
2502*5113495bSYour Name 				       struct cdp_peer_setup_info *setup_info,
2503*5113495bSYour Name 				       enum cdp_host_reo_dest_ring *reo_dest,
2504*5113495bSYour Name 				       bool *hash_based,
2505*5113495bSYour Name 				       uint8_t *lmac_peer_id_msb)
2506*5113495bSYour Name {
2507*5113495bSYour Name 	struct dp_soc *soc = vdev->pdev->soc;
2508*5113495bSYour Name 
2509*5113495bSYour Name 	soc->arch_ops.peer_get_reo_hash(vdev, setup_info, reo_dest, hash_based,
2510*5113495bSYour Name 					lmac_peer_id_msb);
2511*5113495bSYour Name }
2512*5113495bSYour Name #endif /* IPA_OFFLOAD */
2513*5113495bSYour Name #if defined WLAN_FEATURE_11BE_MLO && defined DP_MLO_LINK_STATS_SUPPORT
2514*5113495bSYour Name 
2515*5113495bSYour Name static inline uint8_t
dp_peer_get_local_link_id(struct dp_peer * peer,struct dp_txrx_peer * txrx_peer)2516*5113495bSYour Name dp_peer_get_local_link_id(struct dp_peer *peer, struct dp_txrx_peer *txrx_peer)
2517*5113495bSYour Name {
2518*5113495bSYour Name 	struct dp_local_link_id_peer_map *ll_id_peer_map =
2519*5113495bSYour Name 						&txrx_peer->ll_id_peer_map[0];
2520*5113495bSYour Name 	int i;
2521*5113495bSYour Name 
2522*5113495bSYour Name 	/*
2523*5113495bSYour Name 	 * Search for the peer entry in the
2524*5113495bSYour Name 	 * local_link_id to peer mac_addr mapping table
2525*5113495bSYour Name 	 */
2526*5113495bSYour Name 	for (i = 0; i < DP_MAX_MLO_LINKS; i++) {
2527*5113495bSYour Name 		if (ll_id_peer_map[i].in_use &&
2528*5113495bSYour Name 		    !qdf_mem_cmp(&peer->mac_addr.raw[0],
2529*5113495bSYour Name 				 &ll_id_peer_map[i].mac_addr.raw[0],
2530*5113495bSYour Name 				 QDF_MAC_ADDR_SIZE))
2531*5113495bSYour Name 			return ll_id_peer_map[i].local_link_id + 1;
2532*5113495bSYour Name 	}
2533*5113495bSYour Name 
2534*5113495bSYour Name 	/*
2535*5113495bSYour Name 	 * Create new entry for peer in the
2536*5113495bSYour Name 	 * local_link_id to peer mac_addr mapping table
2537*5113495bSYour Name 	 */
2538*5113495bSYour Name 	for (i = 0; i < DP_MAX_MLO_LINKS; i++) {
2539*5113495bSYour Name 		if (ll_id_peer_map[i].in_use)
2540*5113495bSYour Name 			continue;
2541*5113495bSYour Name 
2542*5113495bSYour Name 		ll_id_peer_map[i].in_use = 1;
2543*5113495bSYour Name 		ll_id_peer_map[i].local_link_id = i;
2544*5113495bSYour Name 		qdf_mem_copy(&ll_id_peer_map[i].mac_addr.raw[0],
2545*5113495bSYour Name 			     &peer->mac_addr.raw[0], QDF_MAC_ADDR_SIZE);
2546*5113495bSYour Name 		return ll_id_peer_map[i].local_link_id + 1;
2547*5113495bSYour Name 	}
2548*5113495bSYour Name 
2549*5113495bSYour Name 	/* We should not hit this case..!! Assert ?? */
2550*5113495bSYour Name 	return 0;
2551*5113495bSYour Name }
2552*5113495bSYour Name 
2553*5113495bSYour Name /**
2554*5113495bSYour Name  *  dp_peer_set_local_link_id() - Set local link id
2555*5113495bSYour Name  *  @peer: dp peer handle
2556*5113495bSYour Name  *
2557*5113495bSYour Name  *  Return: None
2558*5113495bSYour Name  */
2559*5113495bSYour Name static inline void
dp_peer_set_local_link_id(struct dp_peer * peer)2560*5113495bSYour Name dp_peer_set_local_link_id(struct dp_peer *peer)
2561*5113495bSYour Name {
2562*5113495bSYour Name 	struct dp_txrx_peer *txrx_peer;
2563*5113495bSYour Name 
2564*5113495bSYour Name 	if (!IS_MLO_DP_LINK_PEER(peer))
2565*5113495bSYour Name 		return;
2566*5113495bSYour Name 
2567*5113495bSYour Name 	txrx_peer = dp_get_txrx_peer(peer);
2568*5113495bSYour Name 	if (txrx_peer)
2569*5113495bSYour Name 		peer->local_link_id = dp_peer_get_local_link_id(peer,
2570*5113495bSYour Name 								txrx_peer);
2571*5113495bSYour Name 
2572*5113495bSYour Name 	dp_info("Peer " QDF_MAC_ADDR_FMT " txrx_peer %pK local_link_id %d",
2573*5113495bSYour Name 		QDF_MAC_ADDR_REF(peer->mac_addr.raw), txrx_peer,
2574*5113495bSYour Name 		peer->local_link_id);
2575*5113495bSYour Name }
2576*5113495bSYour Name #else
2577*5113495bSYour Name static inline void
dp_peer_set_local_link_id(struct dp_peer * peer)2578*5113495bSYour Name dp_peer_set_local_link_id(struct dp_peer *peer)
2579*5113495bSYour Name {
2580*5113495bSYour Name }
2581*5113495bSYour Name #endif
2582*5113495bSYour Name 
2583*5113495bSYour Name /**
2584*5113495bSYour Name  * dp_peer_setup_wifi3() - initialize the peer
2585*5113495bSYour Name  * @soc_hdl: soc handle object
2586*5113495bSYour Name  * @vdev_id: vdev_id of vdev object
2587*5113495bSYour Name  * @peer_mac: Peer's mac address
2588*5113495bSYour Name  * @setup_info: peer setup info for MLO
2589*5113495bSYour Name  *
2590*5113495bSYour Name  * Return: QDF_STATUS
2591*5113495bSYour Name  */
2592*5113495bSYour Name QDF_STATUS
dp_peer_setup_wifi3(struct cdp_soc_t * soc_hdl,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_peer_setup_info * setup_info)2593*5113495bSYour Name dp_peer_setup_wifi3(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
2594*5113495bSYour Name 		    uint8_t *peer_mac,
2595*5113495bSYour Name 		    struct cdp_peer_setup_info *setup_info)
2596*5113495bSYour Name {
2597*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
2598*5113495bSYour Name 	struct dp_pdev *pdev;
2599*5113495bSYour Name 	bool hash_based = 0;
2600*5113495bSYour Name 	enum cdp_host_reo_dest_ring reo_dest;
2601*5113495bSYour Name 	QDF_STATUS status = QDF_STATUS_SUCCESS;
2602*5113495bSYour Name 	struct dp_vdev *vdev = NULL;
2603*5113495bSYour Name 	struct dp_peer *peer =
2604*5113495bSYour Name 			dp_peer_find_hash_find(soc, peer_mac, 0, vdev_id,
2605*5113495bSYour Name 					       DP_MOD_ID_CDP);
2606*5113495bSYour Name 	struct dp_peer *mld_peer = NULL;
2607*5113495bSYour Name 	enum wlan_op_mode vdev_opmode;
2608*5113495bSYour Name 	uint8_t lmac_peer_id_msb = 0;
2609*5113495bSYour Name 
2610*5113495bSYour Name 	if (!peer)
2611*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
2612*5113495bSYour Name 
2613*5113495bSYour Name 	vdev = peer->vdev;
2614*5113495bSYour Name 	if (!vdev) {
2615*5113495bSYour Name 		status = QDF_STATUS_E_FAILURE;
2616*5113495bSYour Name 		goto fail;
2617*5113495bSYour Name 	}
2618*5113495bSYour Name 
2619*5113495bSYour Name 	/* save vdev related member in case vdev freed */
2620*5113495bSYour Name 	vdev_opmode = vdev->opmode;
2621*5113495bSYour Name 	pdev = vdev->pdev;
2622*5113495bSYour Name 	dp_peer_setup_get_reo_hash(vdev, setup_info,
2623*5113495bSYour Name 				   &reo_dest, &hash_based,
2624*5113495bSYour Name 				   &lmac_peer_id_msb);
2625*5113495bSYour Name 
2626*5113495bSYour Name 	dp_cfg_event_record_peer_setup_evt(soc, DP_CFG_EVENT_PEER_SETUP,
2627*5113495bSYour Name 					   peer, vdev, vdev->vdev_id,
2628*5113495bSYour Name 					   setup_info);
2629*5113495bSYour Name 	dp_info("pdev: %d vdev :%d opmode:%u peer %pK (" QDF_MAC_ADDR_FMT ") "
2630*5113495bSYour Name 		"hash-based-steering:%d default-reo_dest:%u",
2631*5113495bSYour Name 		pdev->pdev_id, vdev->vdev_id,
2632*5113495bSYour Name 		vdev->opmode, peer,
2633*5113495bSYour Name 		QDF_MAC_ADDR_REF(peer->mac_addr.raw), hash_based, reo_dest);
2634*5113495bSYour Name 
2635*5113495bSYour Name 	/*
2636*5113495bSYour Name 	 * There are corner cases where the AD1 = AD2 = "VAPs address"
2637*5113495bSYour Name 	 * i.e both the devices have same MAC address. In these
2638*5113495bSYour Name 	 * cases we want such pkts to be processed in NULL Q handler
2639*5113495bSYour Name 	 * which is REO2TCL ring. for this reason we should
2640*5113495bSYour Name 	 * not setup reo_queues and default route for bss_peer.
2641*5113495bSYour Name 	 */
2642*5113495bSYour Name 	if (!IS_MLO_DP_MLD_PEER(peer))
2643*5113495bSYour Name 		dp_monitor_peer_tx_init(pdev, peer);
2644*5113495bSYour Name 
2645*5113495bSYour Name 	if (!setup_info)
2646*5113495bSYour Name 		if (dp_peer_legacy_setup(soc, peer) !=
2647*5113495bSYour Name 				QDF_STATUS_SUCCESS) {
2648*5113495bSYour Name 			status = QDF_STATUS_E_RESOURCES;
2649*5113495bSYour Name 			goto fail;
2650*5113495bSYour Name 		}
2651*5113495bSYour Name 
2652*5113495bSYour Name 	if (peer->bss_peer && vdev->opmode == wlan_op_mode_ap) {
2653*5113495bSYour Name 		status = QDF_STATUS_E_FAILURE;
2654*5113495bSYour Name 		goto fail;
2655*5113495bSYour Name 	}
2656*5113495bSYour Name 
2657*5113495bSYour Name 	if (soc->cdp_soc.ol_ops->peer_set_default_routing) {
2658*5113495bSYour Name 		/* TODO: Check the destination ring number to be passed to FW */
2659*5113495bSYour Name 		soc->cdp_soc.ol_ops->peer_set_default_routing(
2660*5113495bSYour Name 				soc->ctrl_psoc,
2661*5113495bSYour Name 				peer->vdev->pdev->pdev_id,
2662*5113495bSYour Name 				peer->mac_addr.raw,
2663*5113495bSYour Name 				peer->vdev->vdev_id, hash_based, reo_dest,
2664*5113495bSYour Name 				lmac_peer_id_msb);
2665*5113495bSYour Name 	}
2666*5113495bSYour Name 
2667*5113495bSYour Name 	qdf_atomic_set(&peer->is_default_route_set, 1);
2668*5113495bSYour Name 
2669*5113495bSYour Name 	status = dp_peer_mlo_setup(soc, peer, vdev->vdev_id, setup_info);
2670*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status)) {
2671*5113495bSYour Name 		dp_peer_err("peer mlo setup failed");
2672*5113495bSYour Name 		qdf_assert_always(0);
2673*5113495bSYour Name 	}
2674*5113495bSYour Name 
2675*5113495bSYour Name 	if (vdev_opmode != wlan_op_mode_monitor) {
2676*5113495bSYour Name 		/* In case of MLD peer, switch peer to mld peer and
2677*5113495bSYour Name 		 * do peer_rx_init.
2678*5113495bSYour Name 		 */
2679*5113495bSYour Name 		if (hal_reo_shared_qaddr_is_enable(soc->hal_soc) &&
2680*5113495bSYour Name 		    IS_MLO_DP_LINK_PEER(peer)) {
2681*5113495bSYour Name 			if (setup_info && setup_info->is_first_link) {
2682*5113495bSYour Name 				mld_peer = DP_GET_MLD_PEER_FROM_PEER(peer);
2683*5113495bSYour Name 				if (mld_peer)
2684*5113495bSYour Name 					dp_peer_rx_init(pdev, mld_peer);
2685*5113495bSYour Name 				else
2686*5113495bSYour Name 					dp_peer_err("MLD peer null. Primary link peer:%pK", peer);
2687*5113495bSYour Name 			}
2688*5113495bSYour Name 		} else {
2689*5113495bSYour Name 			dp_peer_rx_init_wrapper(pdev, peer, setup_info);
2690*5113495bSYour Name 		}
2691*5113495bSYour Name 	}
2692*5113495bSYour Name 
2693*5113495bSYour Name 	dp_peer_set_local_link_id(peer);
2694*5113495bSYour Name 
2695*5113495bSYour Name 	if (!IS_MLO_DP_MLD_PEER(peer))
2696*5113495bSYour Name 		dp_peer_ppdu_delayed_ba_init(peer);
2697*5113495bSYour Name 
2698*5113495bSYour Name fail:
2699*5113495bSYour Name 	dp_peer_unref_delete(peer, DP_MOD_ID_CDP);
2700*5113495bSYour Name 	return status;
2701*5113495bSYour Name }
2702*5113495bSYour Name 
2703*5113495bSYour Name /**
2704*5113495bSYour Name  * dp_set_ba_aging_timeout() - set ba aging timeout per AC
2705*5113495bSYour Name  * @txrx_soc: cdp soc handle
2706*5113495bSYour Name  * @ac: Access category
2707*5113495bSYour Name  * @value: timeout value in millisec
2708*5113495bSYour Name  *
2709*5113495bSYour Name  * Return: void
2710*5113495bSYour Name  */
dp_set_ba_aging_timeout(struct cdp_soc_t * txrx_soc,uint8_t ac,uint32_t value)2711*5113495bSYour Name void dp_set_ba_aging_timeout(struct cdp_soc_t *txrx_soc,
2712*5113495bSYour Name 			     uint8_t ac, uint32_t value)
2713*5113495bSYour Name {
2714*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)txrx_soc;
2715*5113495bSYour Name 
2716*5113495bSYour Name 	hal_set_ba_aging_timeout(soc->hal_soc, ac, value);
2717*5113495bSYour Name }
2718*5113495bSYour Name 
2719*5113495bSYour Name /**
2720*5113495bSYour Name  * dp_get_ba_aging_timeout() - get ba aging timeout per AC
2721*5113495bSYour Name  * @txrx_soc: cdp soc handle
2722*5113495bSYour Name  * @ac: access category
2723*5113495bSYour Name  * @value: timeout value in millisec
2724*5113495bSYour Name  *
2725*5113495bSYour Name  * Return: void
2726*5113495bSYour Name  */
dp_get_ba_aging_timeout(struct cdp_soc_t * txrx_soc,uint8_t ac,uint32_t * value)2727*5113495bSYour Name void dp_get_ba_aging_timeout(struct cdp_soc_t *txrx_soc,
2728*5113495bSYour Name 			     uint8_t ac, uint32_t *value)
2729*5113495bSYour Name {
2730*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)txrx_soc;
2731*5113495bSYour Name 
2732*5113495bSYour Name 	hal_get_ba_aging_timeout(soc->hal_soc, ac, value);
2733*5113495bSYour Name }
2734*5113495bSYour Name 
2735*5113495bSYour Name /**
2736*5113495bSYour Name  * dp_set_pdev_reo_dest() - set the reo destination ring for this pdev
2737*5113495bSYour Name  * @txrx_soc: cdp soc handle
2738*5113495bSYour Name  * @pdev_id: id of physical device object
2739*5113495bSYour Name  * @val: reo destination ring index (1 - 4)
2740*5113495bSYour Name  *
2741*5113495bSYour Name  * Return: QDF_STATUS
2742*5113495bSYour Name  */
2743*5113495bSYour Name QDF_STATUS
dp_set_pdev_reo_dest(struct cdp_soc_t * txrx_soc,uint8_t pdev_id,enum cdp_host_reo_dest_ring val)2744*5113495bSYour Name dp_set_pdev_reo_dest(struct cdp_soc_t *txrx_soc, uint8_t pdev_id,
2745*5113495bSYour Name 		     enum cdp_host_reo_dest_ring val)
2746*5113495bSYour Name {
2747*5113495bSYour Name 	struct dp_pdev *pdev =
2748*5113495bSYour Name 		dp_get_pdev_from_soc_pdev_id_wifi3((struct dp_soc *)txrx_soc,
2749*5113495bSYour Name 						   pdev_id);
2750*5113495bSYour Name 
2751*5113495bSYour Name 	if (pdev) {
2752*5113495bSYour Name 		pdev->reo_dest = val;
2753*5113495bSYour Name 		return QDF_STATUS_SUCCESS;
2754*5113495bSYour Name 	}
2755*5113495bSYour Name 
2756*5113495bSYour Name 	return QDF_STATUS_E_FAILURE;
2757*5113495bSYour Name }
2758*5113495bSYour Name 
2759*5113495bSYour Name /**
2760*5113495bSYour Name  * dp_get_pdev_reo_dest() - get the reo destination for this pdev
2761*5113495bSYour Name  * @txrx_soc: cdp soc handle
2762*5113495bSYour Name  * @pdev_id: id of physical device object
2763*5113495bSYour Name  *
2764*5113495bSYour Name  * Return: reo destination ring index
2765*5113495bSYour Name  */
2766*5113495bSYour Name enum cdp_host_reo_dest_ring
dp_get_pdev_reo_dest(struct cdp_soc_t * txrx_soc,uint8_t pdev_id)2767*5113495bSYour Name dp_get_pdev_reo_dest(struct cdp_soc_t *txrx_soc, uint8_t pdev_id)
2768*5113495bSYour Name {
2769*5113495bSYour Name 	struct dp_pdev *pdev =
2770*5113495bSYour Name 		dp_get_pdev_from_soc_pdev_id_wifi3((struct dp_soc *)txrx_soc,
2771*5113495bSYour Name 						   pdev_id);
2772*5113495bSYour Name 
2773*5113495bSYour Name 	if (pdev)
2774*5113495bSYour Name 		return pdev->reo_dest;
2775*5113495bSYour Name 	else
2776*5113495bSYour Name 		return cdp_host_reo_dest_ring_unknown;
2777*5113495bSYour Name }
2778*5113495bSYour Name 
dp_rx_bar_stats_cb(struct dp_soc * soc,void * cb_ctxt,union hal_reo_status * reo_status)2779*5113495bSYour Name void dp_rx_bar_stats_cb(struct dp_soc *soc, void *cb_ctxt,
2780*5113495bSYour Name 	union hal_reo_status *reo_status)
2781*5113495bSYour Name {
2782*5113495bSYour Name 	struct dp_pdev *pdev = (struct dp_pdev *)cb_ctxt;
2783*5113495bSYour Name 	struct hal_reo_queue_status *queue_status = &(reo_status->queue_status);
2784*5113495bSYour Name 
2785*5113495bSYour Name 	if (!dp_check_pdev_exists(soc, pdev)) {
2786*5113495bSYour Name 		dp_err_rl("pdev doesn't exist");
2787*5113495bSYour Name 		return;
2788*5113495bSYour Name 	}
2789*5113495bSYour Name 
2790*5113495bSYour Name 	if (!qdf_atomic_read(&soc->cmn_init_done))
2791*5113495bSYour Name 		return;
2792*5113495bSYour Name 
2793*5113495bSYour Name 	if (queue_status->header.status != HAL_REO_CMD_SUCCESS) {
2794*5113495bSYour Name 		DP_PRINT_STATS("REO stats failure %d",
2795*5113495bSYour Name 			       queue_status->header.status);
2796*5113495bSYour Name 		qdf_atomic_set(&(pdev->stats_cmd_complete), 1);
2797*5113495bSYour Name 		return;
2798*5113495bSYour Name 	}
2799*5113495bSYour Name 
2800*5113495bSYour Name 	pdev->stats.rx.bar_recv_cnt += queue_status->bar_rcvd_cnt;
2801*5113495bSYour Name 	qdf_atomic_set(&(pdev->stats_cmd_complete), 1);
2802*5113495bSYour Name }
2803*5113495bSYour Name 
2804*5113495bSYour Name /**
2805*5113495bSYour Name  * dp_dump_wbm_idle_hptp() - dump wbm idle ring, hw hp tp info.
2806*5113495bSYour Name  * @soc: dp soc.
2807*5113495bSYour Name  * @pdev: dp pdev.
2808*5113495bSYour Name  *
2809*5113495bSYour Name  * Return: None.
2810*5113495bSYour Name  */
2811*5113495bSYour Name void
dp_dump_wbm_idle_hptp(struct dp_soc * soc,struct dp_pdev * pdev)2812*5113495bSYour Name dp_dump_wbm_idle_hptp(struct dp_soc *soc, struct dp_pdev *pdev)
2813*5113495bSYour Name {
2814*5113495bSYour Name 	uint32_t hw_head;
2815*5113495bSYour Name 	uint32_t hw_tail;
2816*5113495bSYour Name 	struct dp_srng *srng;
2817*5113495bSYour Name 
2818*5113495bSYour Name 	if (!soc) {
2819*5113495bSYour Name 		dp_err("soc is NULL");
2820*5113495bSYour Name 		return;
2821*5113495bSYour Name 	}
2822*5113495bSYour Name 
2823*5113495bSYour Name 	if (!pdev) {
2824*5113495bSYour Name 		dp_err("pdev is NULL");
2825*5113495bSYour Name 		return;
2826*5113495bSYour Name 	}
2827*5113495bSYour Name 
2828*5113495bSYour Name 	srng = &pdev->soc->wbm_idle_link_ring;
2829*5113495bSYour Name 	if (!srng) {
2830*5113495bSYour Name 		dp_err("wbm_idle_link_ring srng is NULL");
2831*5113495bSYour Name 		return;
2832*5113495bSYour Name 	}
2833*5113495bSYour Name 
2834*5113495bSYour Name 	hal_get_hw_hptp(soc->hal_soc, srng->hal_srng, &hw_head,
2835*5113495bSYour Name 			&hw_tail, WBM_IDLE_LINK);
2836*5113495bSYour Name 
2837*5113495bSYour Name 	dp_debug("WBM_IDLE_LINK: HW hp: %d, HW tp: %d",
2838*5113495bSYour Name 		 hw_head, hw_tail);
2839*5113495bSYour Name }
2840*5113495bSYour Name 
2841*5113495bSYour Name #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
dp_update_soft_irq_limits(struct dp_soc * soc,uint32_t tx_limit,uint32_t rx_limit)2842*5113495bSYour Name static void dp_update_soft_irq_limits(struct dp_soc *soc, uint32_t tx_limit,
2843*5113495bSYour Name 				      uint32_t rx_limit)
2844*5113495bSYour Name {
2845*5113495bSYour Name 	soc->wlan_cfg_ctx->tx_comp_loop_pkt_limit = tx_limit;
2846*5113495bSYour Name 	soc->wlan_cfg_ctx->rx_reap_loop_pkt_limit = rx_limit;
2847*5113495bSYour Name }
2848*5113495bSYour Name 
2849*5113495bSYour Name #else
2850*5113495bSYour Name 
2851*5113495bSYour Name static inline
dp_update_soft_irq_limits(struct dp_soc * soc,uint32_t tx_limit,uint32_t rx_limit)2852*5113495bSYour Name void dp_update_soft_irq_limits(struct dp_soc *soc, uint32_t tx_limit,
2853*5113495bSYour Name 			       uint32_t rx_limit)
2854*5113495bSYour Name {
2855*5113495bSYour Name }
2856*5113495bSYour Name #endif /* WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT */
2857*5113495bSYour Name 
2858*5113495bSYour Name /**
2859*5113495bSYour Name  * dp_display_srng_info() - Dump the srng HP TP info
2860*5113495bSYour Name  * @soc_hdl: CDP Soc handle
2861*5113495bSYour Name  *
2862*5113495bSYour Name  * This function dumps the SW hp/tp values for the important rings.
2863*5113495bSYour Name  * HW hp/tp values are not being dumped, since it can lead to
2864*5113495bSYour Name  * READ NOC error when UMAC is in low power state. MCC does not have
2865*5113495bSYour Name  * device force wake working yet.
2866*5113495bSYour Name  *
2867*5113495bSYour Name  * Return: rings are empty
2868*5113495bSYour Name  */
dp_display_srng_info(struct cdp_soc_t * soc_hdl)2869*5113495bSYour Name bool dp_display_srng_info(struct cdp_soc_t *soc_hdl)
2870*5113495bSYour Name {
2871*5113495bSYour Name 	struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
2872*5113495bSYour Name 	hal_soc_handle_t hal_soc = soc->hal_soc;
2873*5113495bSYour Name 	uint32_t hp, tp, i;
2874*5113495bSYour Name 	bool ret = true;
2875*5113495bSYour Name 
2876*5113495bSYour Name 	dp_info("SRNG HP-TP data:");
2877*5113495bSYour Name 	for (i = 0; i < soc->num_tcl_data_rings; i++) {
2878*5113495bSYour Name 		hal_get_sw_hptp(hal_soc, soc->tcl_data_ring[i].hal_srng,
2879*5113495bSYour Name 				&tp, &hp);
2880*5113495bSYour Name 		dp_info("TCL DATA ring[%d]: hp=0x%x, tp=0x%x", i, hp, tp);
2881*5113495bSYour Name 
2882*5113495bSYour Name 		if (wlan_cfg_get_wbm_ring_num_for_index(soc->wlan_cfg_ctx, i) ==
2883*5113495bSYour Name 		    INVALID_WBM_RING_NUM)
2884*5113495bSYour Name 			continue;
2885*5113495bSYour Name 
2886*5113495bSYour Name 		hal_get_sw_hptp(hal_soc, soc->tx_comp_ring[i].hal_srng,
2887*5113495bSYour Name 				&tp, &hp);
2888*5113495bSYour Name 		dp_info("TX comp ring[%d]: hp=0x%x, tp=0x%x", i, hp, tp);
2889*5113495bSYour Name 	}
2890*5113495bSYour Name 
2891*5113495bSYour Name 	for (i = 0; i < soc->num_reo_dest_rings; i++) {
2892*5113495bSYour Name 		hal_get_sw_hptp(hal_soc, soc->reo_dest_ring[i].hal_srng,
2893*5113495bSYour Name 				&tp, &hp);
2894*5113495bSYour Name 		if (hp != tp)
2895*5113495bSYour Name 			ret = false;
2896*5113495bSYour Name 
2897*5113495bSYour Name 		dp_info("REO DST ring[%d]: hp=0x%x, tp=0x%x", i, hp, tp);
2898*5113495bSYour Name 	}
2899*5113495bSYour Name 
2900*5113495bSYour Name 	hal_get_sw_hptp(hal_soc, soc->reo_exception_ring.hal_srng, &tp, &hp);
2901*5113495bSYour Name 	dp_info("REO exception ring: hp=0x%x, tp=0x%x", hp, tp);
2902*5113495bSYour Name 
2903*5113495bSYour Name 	hal_get_sw_hptp(hal_soc, soc->rx_rel_ring.hal_srng, &tp, &hp);
2904*5113495bSYour Name 	dp_info("WBM RX release ring: hp=0x%x, tp=0x%x", hp, tp);
2905*5113495bSYour Name 
2906*5113495bSYour Name 	hal_get_sw_hptp(hal_soc, soc->wbm_desc_rel_ring.hal_srng, &tp, &hp);
2907*5113495bSYour Name 	dp_info("WBM desc release ring: hp=0x%x, tp=0x%x", hp, tp);
2908*5113495bSYour Name 
2909*5113495bSYour Name 	return ret;
2910*5113495bSYour Name }
2911*5113495bSYour Name 
2912*5113495bSYour Name /**
2913*5113495bSYour Name  * dp_set_pdev_pcp_tid_map_wifi3() - update pcp tid map in pdev
2914*5113495bSYour Name  * @psoc: dp soc handle
2915*5113495bSYour Name  * @pdev_id: id of DP_PDEV handle
2916*5113495bSYour Name  * @pcp: pcp value
2917*5113495bSYour Name  * @tid: tid value passed by the user
2918*5113495bSYour Name  *
2919*5113495bSYour Name  * Return: QDF_STATUS_SUCCESS on success
2920*5113495bSYour Name  */
dp_set_pdev_pcp_tid_map_wifi3(ol_txrx_soc_handle psoc,uint8_t pdev_id,uint8_t pcp,uint8_t tid)2921*5113495bSYour Name QDF_STATUS dp_set_pdev_pcp_tid_map_wifi3(ol_txrx_soc_handle psoc,
2922*5113495bSYour Name 					 uint8_t pdev_id,
2923*5113495bSYour Name 					 uint8_t pcp, uint8_t tid)
2924*5113495bSYour Name {
2925*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)psoc;
2926*5113495bSYour Name 
2927*5113495bSYour Name 	soc->pcp_tid_map[pcp] = tid;
2928*5113495bSYour Name 
2929*5113495bSYour Name 	hal_tx_update_pcp_tid_map(soc->hal_soc, pcp, tid);
2930*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
2931*5113495bSYour Name }
2932*5113495bSYour Name 
2933*5113495bSYour Name /**
2934*5113495bSYour Name  * dp_set_vdev_pcp_tid_map_wifi3() - update pcp tid map in vdev
2935*5113495bSYour Name  * @soc_hdl: DP soc handle
2936*5113495bSYour Name  * @vdev_id: id of DP_VDEV handle
2937*5113495bSYour Name  * @pcp: pcp value
2938*5113495bSYour Name  * @tid: tid value passed by the user
2939*5113495bSYour Name  *
2940*5113495bSYour Name  * Return: QDF_STATUS_SUCCESS on success
2941*5113495bSYour Name  */
dp_set_vdev_pcp_tid_map_wifi3(struct cdp_soc_t * soc_hdl,uint8_t vdev_id,uint8_t pcp,uint8_t tid)2942*5113495bSYour Name QDF_STATUS dp_set_vdev_pcp_tid_map_wifi3(struct cdp_soc_t *soc_hdl,
2943*5113495bSYour Name 					 uint8_t vdev_id,
2944*5113495bSYour Name 					 uint8_t pcp, uint8_t tid)
2945*5113495bSYour Name {
2946*5113495bSYour Name 	struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
2947*5113495bSYour Name 	struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
2948*5113495bSYour Name 						     DP_MOD_ID_CDP);
2949*5113495bSYour Name 
2950*5113495bSYour Name 	if (!vdev)
2951*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
2952*5113495bSYour Name 
2953*5113495bSYour Name 	vdev->pcp_tid_map[pcp] = tid;
2954*5113495bSYour Name 
2955*5113495bSYour Name 	dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
2956*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
2957*5113495bSYour Name }
2958*5113495bSYour Name 
2959*5113495bSYour Name #if defined(FEATURE_RUNTIME_PM) || defined(DP_POWER_SAVE)
dp_drain_txrx(struct cdp_soc_t * soc_handle,uint8_t rx_only)2960*5113495bSYour Name QDF_STATUS dp_drain_txrx(struct cdp_soc_t *soc_handle, uint8_t rx_only)
2961*5113495bSYour Name {
2962*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)soc_handle;
2963*5113495bSYour Name 	uint32_t cur_tx_limit, cur_rx_limit;
2964*5113495bSYour Name 	uint32_t budget = 0xffff;
2965*5113495bSYour Name 	uint32_t val;
2966*5113495bSYour Name 	int i;
2967*5113495bSYour Name 	int cpu = dp_srng_get_cpu();
2968*5113495bSYour Name 	QDF_STATUS status = QDF_STATUS_SUCCESS;
2969*5113495bSYour Name 
2970*5113495bSYour Name 	cur_tx_limit = soc->wlan_cfg_ctx->tx_comp_loop_pkt_limit;
2971*5113495bSYour Name 	cur_rx_limit = soc->wlan_cfg_ctx->rx_reap_loop_pkt_limit;
2972*5113495bSYour Name 
2973*5113495bSYour Name 	/* Temporarily increase soft irq limits when going to drain
2974*5113495bSYour Name 	 * the UMAC/LMAC SRNGs and restore them after polling.
2975*5113495bSYour Name 	 * Though the budget is on higher side, the TX/RX reaping loops
2976*5113495bSYour Name 	 * will not execute longer as both TX and RX would be suspended
2977*5113495bSYour Name 	 * by the time this API is called.
2978*5113495bSYour Name 	 */
2979*5113495bSYour Name 	dp_update_soft_irq_limits(soc, budget, budget);
2980*5113495bSYour Name 
2981*5113495bSYour Name 	for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
2982*5113495bSYour Name 		if (rx_only && !soc->intr_ctx[i].rx_ring_mask)
2983*5113495bSYour Name 			continue;
2984*5113495bSYour Name 		soc->arch_ops.dp_service_srngs(&soc->intr_ctx[i], budget, cpu);
2985*5113495bSYour Name 	}
2986*5113495bSYour Name 
2987*5113495bSYour Name 	dp_update_soft_irq_limits(soc, cur_tx_limit, cur_rx_limit);
2988*5113495bSYour Name 
2989*5113495bSYour Name 	status = hif_try_complete_dp_tasks(soc->hif_handle);
2990*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status)) {
2991*5113495bSYour Name 		dp_err("Failed to complete DP tasks");
2992*5113495bSYour Name 		return status;
2993*5113495bSYour Name 	}
2994*5113495bSYour Name 
2995*5113495bSYour Name 	/* Do a dummy read at offset 0; this will ensure all
2996*5113495bSYour Name 	 * pendings writes(HP/TP) are flushed before read returns.
2997*5113495bSYour Name 	 */
2998*5113495bSYour Name 	val = HAL_REG_READ((struct hal_soc *)soc->hal_soc, 0);
2999*5113495bSYour Name 	dp_debug("Register value at offset 0: %u", val);
3000*5113495bSYour Name 
3001*5113495bSYour Name 	return status;
3002*5113495bSYour Name }
3003*5113495bSYour Name #endif
3004*5113495bSYour Name 
3005*5113495bSYour Name #if defined(DP_POWER_SAVE) || defined(FEATURE_RUNTIME_PM)
3006*5113495bSYour Name /**
3007*5113495bSYour Name  * dp_flush_ring_hptp() - Update ring shadow
3008*5113495bSYour Name  *			  register HP/TP address when runtime
3009*5113495bSYour Name  *                        resume
3010*5113495bSYour Name  * @soc: DP soc context
3011*5113495bSYour Name  * @hal_srng: srng
3012*5113495bSYour Name  *
3013*5113495bSYour Name  * Return: None
3014*5113495bSYour Name  */
dp_flush_ring_hptp(struct dp_soc * soc,hal_ring_handle_t hal_srng)3015*5113495bSYour Name static void dp_flush_ring_hptp(struct dp_soc *soc, hal_ring_handle_t hal_srng)
3016*5113495bSYour Name {
3017*5113495bSYour Name 	if (hal_srng && hal_srng_get_clear_event(hal_srng,
3018*5113495bSYour Name 						 HAL_SRNG_FLUSH_EVENT)) {
3019*5113495bSYour Name 		/* Acquire the lock */
3020*5113495bSYour Name 		hal_srng_access_start(soc->hal_soc, hal_srng);
3021*5113495bSYour Name 
3022*5113495bSYour Name 		hal_srng_access_end(soc->hal_soc, hal_srng);
3023*5113495bSYour Name 
3024*5113495bSYour Name 		hal_srng_set_flush_last_ts(hal_srng);
3025*5113495bSYour Name 
3026*5113495bSYour Name 		dp_debug("flushed");
3027*5113495bSYour Name 	}
3028*5113495bSYour Name }
3029*5113495bSYour Name 
dp_update_ring_hptp(struct dp_soc * soc,bool force_flush_tx)3030*5113495bSYour Name void dp_update_ring_hptp(struct dp_soc *soc, bool force_flush_tx)
3031*5113495bSYour Name {
3032*5113495bSYour Name 	 uint8_t i;
3033*5113495bSYour Name 
3034*5113495bSYour Name 	if (force_flush_tx) {
3035*5113495bSYour Name 		for (i = 0; i < soc->num_tcl_data_rings; i++) {
3036*5113495bSYour Name 			hal_srng_set_event(soc->tcl_data_ring[i].hal_srng,
3037*5113495bSYour Name 					   HAL_SRNG_FLUSH_EVENT);
3038*5113495bSYour Name 			dp_flush_ring_hptp(soc, soc->tcl_data_ring[i].hal_srng);
3039*5113495bSYour Name 		}
3040*5113495bSYour Name 
3041*5113495bSYour Name 		return;
3042*5113495bSYour Name 	}
3043*5113495bSYour Name 
3044*5113495bSYour Name 	for (i = 0; i < soc->num_tcl_data_rings; i++)
3045*5113495bSYour Name 		dp_flush_ring_hptp(soc, soc->tcl_data_ring[i].hal_srng);
3046*5113495bSYour Name 
3047*5113495bSYour Name 	dp_flush_ring_hptp(soc, soc->reo_cmd_ring.hal_srng);
3048*5113495bSYour Name }
3049*5113495bSYour Name #endif
3050*5113495bSYour Name 
3051*5113495bSYour Name #ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR
3052*5113495bSYour Name /*
3053*5113495bSYour Name  * dp_flush_tcl_ring() - flush TCL ring hp
3054*5113495bSYour Name  * @pdev: dp pdev
3055*5113495bSYour Name  * @ring_id: TCL ring id
3056*5113495bSYour Name  *
3057*5113495bSYour Name  * Return: 0 on success and error code on failure
3058*5113495bSYour Name  */
dp_flush_tcl_ring(struct dp_pdev * pdev,int ring_id)3059*5113495bSYour Name int dp_flush_tcl_ring(struct dp_pdev *pdev, int ring_id)
3060*5113495bSYour Name {
3061*5113495bSYour Name 	struct dp_soc *soc = pdev->soc;
3062*5113495bSYour Name 	hal_ring_handle_t hal_ring_hdl =
3063*5113495bSYour Name 			soc->tcl_data_ring[ring_id].hal_srng;
3064*5113495bSYour Name 	int ret;
3065*5113495bSYour Name 
3066*5113495bSYour Name 	ret = hal_srng_try_access_start(soc->hal_soc, hal_ring_hdl);
3067*5113495bSYour Name 	if (ret)
3068*5113495bSYour Name 		return ret;
3069*5113495bSYour Name 
3070*5113495bSYour Name 	ret = hif_rtpm_get(HIF_RTPM_GET_ASYNC, HIF_RTPM_ID_DP);
3071*5113495bSYour Name 	if (ret) {
3072*5113495bSYour Name 		hal_srng_access_end_reap(soc->hal_soc, hal_ring_hdl);
3073*5113495bSYour Name 		hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
3074*5113495bSYour Name 		hal_srng_inc_flush_cnt(hal_ring_hdl);
3075*5113495bSYour Name 		return ret;
3076*5113495bSYour Name 	}
3077*5113495bSYour Name 
3078*5113495bSYour Name 	hal_srng_access_end(soc->hal_soc, hal_ring_hdl);
3079*5113495bSYour Name 	hif_rtpm_put(HIF_RTPM_PUT_ASYNC, HIF_RTPM_ID_DP);
3080*5113495bSYour Name 
3081*5113495bSYour Name 	return ret;
3082*5113495bSYour Name }
3083*5113495bSYour Name #else
dp_flush_tcl_ring(struct dp_pdev * pdev,int ring_id)3084*5113495bSYour Name int dp_flush_tcl_ring(struct dp_pdev *pdev, int ring_id)
3085*5113495bSYour Name {
3086*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
3087*5113495bSYour Name }
3088*5113495bSYour Name #endif
3089*5113495bSYour Name 
3090*5113495bSYour Name #ifdef WLAN_FEATURE_STATS_EXT
3091*5113495bSYour Name /* rx hw stats event wait timeout in ms */
3092*5113495bSYour Name #define DP_REO_STATUS_STATS_TIMEOUT 100
3093*5113495bSYour Name 
3094*5113495bSYour Name /**
3095*5113495bSYour Name  * dp_rx_hw_stats_cb() - request rx hw stats response callback
3096*5113495bSYour Name  * @soc: soc handle
3097*5113495bSYour Name  * @cb_ctxt: callback context
3098*5113495bSYour Name  * @reo_status: reo command response status
3099*5113495bSYour Name  *
3100*5113495bSYour Name  * Return: None
3101*5113495bSYour Name  */
dp_rx_hw_stats_cb(struct dp_soc * soc,void * cb_ctxt,union hal_reo_status * reo_status)3102*5113495bSYour Name static void dp_rx_hw_stats_cb(struct dp_soc *soc, void *cb_ctxt,
3103*5113495bSYour Name 			      union hal_reo_status *reo_status)
3104*5113495bSYour Name {
3105*5113495bSYour Name 	struct hal_reo_queue_status *queue_status = &reo_status->queue_status;
3106*5113495bSYour Name 	bool is_query_timeout;
3107*5113495bSYour Name 
3108*5113495bSYour Name 	qdf_spin_lock_bh(&soc->rx_hw_stats_lock);
3109*5113495bSYour Name 	is_query_timeout = soc->rx_hw_stats->is_query_timeout;
3110*5113495bSYour Name 	/* free the cb_ctxt if all pending tid stats query is received */
3111*5113495bSYour Name 	if (qdf_atomic_dec_and_test(&soc->rx_hw_stats->pending_tid_stats_cnt)) {
3112*5113495bSYour Name 		if (!is_query_timeout) {
3113*5113495bSYour Name 			qdf_event_set(&soc->rx_hw_stats_event);
3114*5113495bSYour Name 			soc->is_last_stats_ctx_init = false;
3115*5113495bSYour Name 		}
3116*5113495bSYour Name 
3117*5113495bSYour Name 		qdf_mem_free(soc->rx_hw_stats);
3118*5113495bSYour Name 		soc->rx_hw_stats = NULL;
3119*5113495bSYour Name 	}
3120*5113495bSYour Name 
3121*5113495bSYour Name 	if (queue_status->header.status != HAL_REO_CMD_SUCCESS) {
3122*5113495bSYour Name 		dp_info("REO stats failure %d",
3123*5113495bSYour Name 			queue_status->header.status);
3124*5113495bSYour Name 		qdf_spin_unlock_bh(&soc->rx_hw_stats_lock);
3125*5113495bSYour Name 		return;
3126*5113495bSYour Name 	}
3127*5113495bSYour Name 
3128*5113495bSYour Name 	if (!is_query_timeout) {
3129*5113495bSYour Name 		soc->ext_stats.rx_mpdu_received +=
3130*5113495bSYour Name 					queue_status->mpdu_frms_cnt;
3131*5113495bSYour Name 		soc->ext_stats.rx_mpdu_missed +=
3132*5113495bSYour Name 					queue_status->hole_cnt;
3133*5113495bSYour Name 	}
3134*5113495bSYour Name 	qdf_spin_unlock_bh(&soc->rx_hw_stats_lock);
3135*5113495bSYour Name }
3136*5113495bSYour Name 
3137*5113495bSYour Name /**
3138*5113495bSYour Name  * dp_request_rx_hw_stats() - request rx hardware stats
3139*5113495bSYour Name  * @soc_hdl: soc handle
3140*5113495bSYour Name  * @vdev_id: vdev id
3141*5113495bSYour Name  *
3142*5113495bSYour Name  * Return: None
3143*5113495bSYour Name  */
3144*5113495bSYour Name QDF_STATUS
dp_request_rx_hw_stats(struct cdp_soc_t * soc_hdl,uint8_t vdev_id)3145*5113495bSYour Name dp_request_rx_hw_stats(struct cdp_soc_t *soc_hdl, uint8_t vdev_id)
3146*5113495bSYour Name {
3147*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
3148*5113495bSYour Name 	struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
3149*5113495bSYour Name 						     DP_MOD_ID_CDP);
3150*5113495bSYour Name 	struct dp_peer *peer = NULL;
3151*5113495bSYour Name 	QDF_STATUS status;
3152*5113495bSYour Name 	int rx_stats_sent_cnt = 0;
3153*5113495bSYour Name 	uint32_t last_rx_mpdu_received;
3154*5113495bSYour Name 	uint32_t last_rx_mpdu_missed;
3155*5113495bSYour Name 
3156*5113495bSYour Name 	if (soc->rx_hw_stats) {
3157*5113495bSYour Name 		dp_err_rl("Stats already requested");
3158*5113495bSYour Name 		status = QDF_STATUS_E_ALREADY;
3159*5113495bSYour Name 		goto out;
3160*5113495bSYour Name 	}
3161*5113495bSYour Name 
3162*5113495bSYour Name 	if (!vdev) {
3163*5113495bSYour Name 		dp_err("vdev is null for vdev_id: %u", vdev_id);
3164*5113495bSYour Name 		status = QDF_STATUS_E_INVAL;
3165*5113495bSYour Name 		goto out;
3166*5113495bSYour Name 	}
3167*5113495bSYour Name 
3168*5113495bSYour Name 	peer = dp_vdev_bss_peer_ref_n_get(soc, vdev, DP_MOD_ID_CDP);
3169*5113495bSYour Name 
3170*5113495bSYour Name 	if (!peer) {
3171*5113495bSYour Name 		dp_err("Peer is NULL");
3172*5113495bSYour Name 		status = QDF_STATUS_E_INVAL;
3173*5113495bSYour Name 		goto out;
3174*5113495bSYour Name 	}
3175*5113495bSYour Name 
3176*5113495bSYour Name 	soc->rx_hw_stats = qdf_mem_malloc(sizeof(*soc->rx_hw_stats));
3177*5113495bSYour Name 
3178*5113495bSYour Name 	if (!soc->rx_hw_stats) {
3179*5113495bSYour Name 		dp_err("malloc failed for hw stats structure");
3180*5113495bSYour Name 		status = QDF_STATUS_E_INVAL;
3181*5113495bSYour Name 		goto out;
3182*5113495bSYour Name 	}
3183*5113495bSYour Name 
3184*5113495bSYour Name 	qdf_event_reset(&soc->rx_hw_stats_event);
3185*5113495bSYour Name 	qdf_spin_lock_bh(&soc->rx_hw_stats_lock);
3186*5113495bSYour Name 	/* save the last soc cumulative stats and reset it to 0 */
3187*5113495bSYour Name 	last_rx_mpdu_received = soc->ext_stats.rx_mpdu_received;
3188*5113495bSYour Name 	last_rx_mpdu_missed = soc->ext_stats.rx_mpdu_missed;
3189*5113495bSYour Name 	soc->ext_stats.rx_mpdu_received = 0;
3190*5113495bSYour Name 	soc->ext_stats.rx_mpdu_missed = 0;
3191*5113495bSYour Name 
3192*5113495bSYour Name 	dp_debug("HW stats query start");
3193*5113495bSYour Name 	rx_stats_sent_cnt =
3194*5113495bSYour Name 		dp_peer_rxtid_stats(peer, dp_rx_hw_stats_cb, soc->rx_hw_stats);
3195*5113495bSYour Name 	if (!rx_stats_sent_cnt) {
3196*5113495bSYour Name 		dp_err("no tid stats sent successfully");
3197*5113495bSYour Name 		qdf_mem_free(soc->rx_hw_stats);
3198*5113495bSYour Name 		soc->rx_hw_stats = NULL;
3199*5113495bSYour Name 		qdf_spin_unlock_bh(&soc->rx_hw_stats_lock);
3200*5113495bSYour Name 		status = QDF_STATUS_E_INVAL;
3201*5113495bSYour Name 		goto out;
3202*5113495bSYour Name 	}
3203*5113495bSYour Name 	qdf_atomic_set(&soc->rx_hw_stats->pending_tid_stats_cnt,
3204*5113495bSYour Name 		       rx_stats_sent_cnt);
3205*5113495bSYour Name 	soc->rx_hw_stats->is_query_timeout = false;
3206*5113495bSYour Name 	soc->is_last_stats_ctx_init = true;
3207*5113495bSYour Name 	qdf_spin_unlock_bh(&soc->rx_hw_stats_lock);
3208*5113495bSYour Name 
3209*5113495bSYour Name 	status = qdf_wait_single_event(&soc->rx_hw_stats_event,
3210*5113495bSYour Name 				       DP_REO_STATUS_STATS_TIMEOUT);
3211*5113495bSYour Name 	dp_debug("HW stats query end with %d", rx_stats_sent_cnt);
3212*5113495bSYour Name 
3213*5113495bSYour Name 	qdf_spin_lock_bh(&soc->rx_hw_stats_lock);
3214*5113495bSYour Name 	if (status != QDF_STATUS_SUCCESS) {
3215*5113495bSYour Name 		if (soc->rx_hw_stats) {
3216*5113495bSYour Name 			dp_info("partial rx hw stats event collected with %d",
3217*5113495bSYour Name 				qdf_atomic_read(
3218*5113495bSYour Name 				  &soc->rx_hw_stats->pending_tid_stats_cnt));
3219*5113495bSYour Name 			if (soc->is_last_stats_ctx_init)
3220*5113495bSYour Name 				soc->rx_hw_stats->is_query_timeout = true;
3221*5113495bSYour Name 		}
3222*5113495bSYour Name 
3223*5113495bSYour Name 		/*
3224*5113495bSYour Name 		 * If query timeout happened, use the last saved stats
3225*5113495bSYour Name 		 * for this time query.
3226*5113495bSYour Name 		 */
3227*5113495bSYour Name 		soc->ext_stats.rx_mpdu_received = last_rx_mpdu_received;
3228*5113495bSYour Name 		soc->ext_stats.rx_mpdu_missed = last_rx_mpdu_missed;
3229*5113495bSYour Name 		DP_STATS_INC(soc, rx.rx_hw_stats_timeout, 1);
3230*5113495bSYour Name 
3231*5113495bSYour Name 	}
3232*5113495bSYour Name 	qdf_spin_unlock_bh(&soc->rx_hw_stats_lock);
3233*5113495bSYour Name 
3234*5113495bSYour Name out:
3235*5113495bSYour Name 	if (peer)
3236*5113495bSYour Name 		dp_peer_unref_delete(peer, DP_MOD_ID_CDP);
3237*5113495bSYour Name 	if (vdev)
3238*5113495bSYour Name 		dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
3239*5113495bSYour Name 	DP_STATS_INC(soc, rx.rx_hw_stats_requested, 1);
3240*5113495bSYour Name 
3241*5113495bSYour Name 	return status;
3242*5113495bSYour Name }
3243*5113495bSYour Name 
3244*5113495bSYour Name /**
3245*5113495bSYour Name  * dp_reset_rx_hw_ext_stats() - Reset rx hardware ext stats
3246*5113495bSYour Name  * @soc_hdl: soc handle
3247*5113495bSYour Name  *
3248*5113495bSYour Name  * Return: None
3249*5113495bSYour Name  */
dp_reset_rx_hw_ext_stats(struct cdp_soc_t * soc_hdl)3250*5113495bSYour Name void dp_reset_rx_hw_ext_stats(struct cdp_soc_t *soc_hdl)
3251*5113495bSYour Name {
3252*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
3253*5113495bSYour Name 
3254*5113495bSYour Name 	soc->ext_stats.rx_mpdu_received = 0;
3255*5113495bSYour Name 	soc->ext_stats.rx_mpdu_missed = 0;
3256*5113495bSYour Name }
3257*5113495bSYour Name #endif /* WLAN_FEATURE_STATS_EXT */
3258*5113495bSYour Name 
dp_get_tx_rings_grp_bitmap(struct cdp_soc_t * soc_hdl)3259*5113495bSYour Name uint32_t dp_get_tx_rings_grp_bitmap(struct cdp_soc_t *soc_hdl)
3260*5113495bSYour Name {
3261*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
3262*5113495bSYour Name 
3263*5113495bSYour Name 	return soc->wlan_cfg_ctx->tx_rings_grp_bitmap;
3264*5113495bSYour Name }
3265*5113495bSYour Name 
dp_soc_set_txrx_ring_map(struct dp_soc * soc)3266*5113495bSYour Name void dp_soc_set_txrx_ring_map(struct dp_soc *soc)
3267*5113495bSYour Name {
3268*5113495bSYour Name 	uint32_t i;
3269*5113495bSYour Name 
3270*5113495bSYour Name 	for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
3271*5113495bSYour Name 		soc->tx_ring_map[i] = dp_cpu_ring_map[DP_NSS_DEFAULT_MAP][i];
3272*5113495bSYour Name 	}
3273*5113495bSYour Name }
3274*5113495bSYour Name 
3275*5113495bSYour Name qdf_export_symbol(dp_soc_set_txrx_ring_map);
3276*5113495bSYour Name 
dp_soc_cfg_dump(struct dp_soc * soc,uint32_t target_type)3277*5113495bSYour Name static void dp_soc_cfg_dump(struct dp_soc *soc, uint32_t target_type)
3278*5113495bSYour Name {
3279*5113495bSYour Name 	dp_init_info("DP soc Dump for Target = %d", target_type);
3280*5113495bSYour Name 	dp_init_info("ast_override_support = %d da_war_enabled = %d",
3281*5113495bSYour Name 		     soc->ast_override_support, soc->da_war_enabled);
3282*5113495bSYour Name 
3283*5113495bSYour Name 	wlan_cfg_dp_soc_ctx_dump(soc->wlan_cfg_ctx);
3284*5113495bSYour Name }
3285*5113495bSYour Name 
3286*5113495bSYour Name /**
3287*5113495bSYour Name  * dp_soc_cfg_init() - initialize target specific configuration
3288*5113495bSYour Name  *		       during dp_soc_init
3289*5113495bSYour Name  * @soc: dp soc handle
3290*5113495bSYour Name  */
dp_soc_cfg_init(struct dp_soc * soc)3291*5113495bSYour Name static void dp_soc_cfg_init(struct dp_soc *soc)
3292*5113495bSYour Name {
3293*5113495bSYour Name 	uint32_t target_type;
3294*5113495bSYour Name 
3295*5113495bSYour Name 	target_type = hal_get_target_type(soc->hal_soc);
3296*5113495bSYour Name 	switch (target_type) {
3297*5113495bSYour Name 	case TARGET_TYPE_QCA6290:
3298*5113495bSYour Name 		wlan_cfg_set_reo_dst_ring_size(soc->wlan_cfg_ctx,
3299*5113495bSYour Name 					       REO_DST_RING_SIZE_QCA6290);
3300*5113495bSYour Name 		soc->ast_override_support = 1;
3301*5113495bSYour Name 		soc->da_war_enabled = false;
3302*5113495bSYour Name 		break;
3303*5113495bSYour Name 	case TARGET_TYPE_QCA6390:
3304*5113495bSYour Name 	case TARGET_TYPE_QCA6490:
3305*5113495bSYour Name 	case TARGET_TYPE_QCA6750:
3306*5113495bSYour Name 		wlan_cfg_set_reo_dst_ring_size(soc->wlan_cfg_ctx,
3307*5113495bSYour Name 					       REO_DST_RING_SIZE_QCA6290);
3308*5113495bSYour Name 		wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, true);
3309*5113495bSYour Name 		soc->ast_override_support = 1;
3310*5113495bSYour Name 		if (soc->cdp_soc.ol_ops->get_con_mode &&
3311*5113495bSYour Name 		    soc->cdp_soc.ol_ops->get_con_mode() ==
3312*5113495bSYour Name 		    QDF_GLOBAL_MONITOR_MODE) {
3313*5113495bSYour Name 			int int_ctx;
3314*5113495bSYour Name 
3315*5113495bSYour Name 			for (int_ctx = 0; int_ctx < WLAN_CFG_INT_NUM_CONTEXTS; int_ctx++) {
3316*5113495bSYour Name 				soc->wlan_cfg_ctx->int_rx_ring_mask[int_ctx] = 0;
3317*5113495bSYour Name 				soc->wlan_cfg_ctx->int_rxdma2host_ring_mask[int_ctx] = 0;
3318*5113495bSYour Name 			}
3319*5113495bSYour Name 		}
3320*5113495bSYour Name 		soc->wlan_cfg_ctx->rxdma1_enable = 0;
3321*5113495bSYour Name 		break;
3322*5113495bSYour Name 	case TARGET_TYPE_KIWI:
3323*5113495bSYour Name 	case TARGET_TYPE_MANGO:
3324*5113495bSYour Name 	case TARGET_TYPE_PEACH:
3325*5113495bSYour Name 		soc->ast_override_support = 1;
3326*5113495bSYour Name 		soc->per_tid_basize_max_tid = 8;
3327*5113495bSYour Name 
3328*5113495bSYour Name 		if (soc->cdp_soc.ol_ops->get_con_mode &&
3329*5113495bSYour Name 		    soc->cdp_soc.ol_ops->get_con_mode() ==
3330*5113495bSYour Name 		    QDF_GLOBAL_MONITOR_MODE) {
3331*5113495bSYour Name 			int int_ctx;
3332*5113495bSYour Name 
3333*5113495bSYour Name 			for (int_ctx = 0; int_ctx < WLAN_CFG_INT_NUM_CONTEXTS;
3334*5113495bSYour Name 			     int_ctx++) {
3335*5113495bSYour Name 				soc->wlan_cfg_ctx->int_rx_ring_mask[int_ctx] = 0;
3336*5113495bSYour Name 				if (dp_is_monitor_mode_using_poll(soc))
3337*5113495bSYour Name 					soc->wlan_cfg_ctx->int_rxdma2host_ring_mask[int_ctx] = 0;
3338*5113495bSYour Name 			}
3339*5113495bSYour Name 		}
3340*5113495bSYour Name 
3341*5113495bSYour Name 		soc->wlan_cfg_ctx->rxdma1_enable = 0;
3342*5113495bSYour Name 		soc->wlan_cfg_ctx->num_rxdma_dst_rings_per_pdev = 1;
3343*5113495bSYour Name 		break;
3344*5113495bSYour Name 	case TARGET_TYPE_QCA8074:
3345*5113495bSYour Name 		wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, true);
3346*5113495bSYour Name 		soc->da_war_enabled = true;
3347*5113495bSYour Name 		soc->is_rx_fse_full_cache_invalidate_war_enabled = true;
3348*5113495bSYour Name 		break;
3349*5113495bSYour Name 	case TARGET_TYPE_QCA8074V2:
3350*5113495bSYour Name 	case TARGET_TYPE_QCA6018:
3351*5113495bSYour Name 	case TARGET_TYPE_QCA9574:
3352*5113495bSYour Name 		wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, false);
3353*5113495bSYour Name 		soc->ast_override_support = 1;
3354*5113495bSYour Name 		soc->per_tid_basize_max_tid = 8;
3355*5113495bSYour Name 		soc->num_hw_dscp_tid_map = HAL_MAX_HW_DSCP_TID_V2_MAPS;
3356*5113495bSYour Name 		soc->da_war_enabled = false;
3357*5113495bSYour Name 		soc->is_rx_fse_full_cache_invalidate_war_enabled = true;
3358*5113495bSYour Name 		break;
3359*5113495bSYour Name 	case TARGET_TYPE_QCN9000:
3360*5113495bSYour Name 		soc->ast_override_support = 1;
3361*5113495bSYour Name 		soc->da_war_enabled = false;
3362*5113495bSYour Name 		wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, false);
3363*5113495bSYour Name 		soc->per_tid_basize_max_tid = 8;
3364*5113495bSYour Name 		soc->num_hw_dscp_tid_map = HAL_MAX_HW_DSCP_TID_V2_MAPS;
3365*5113495bSYour Name 		soc->lmac_polled_mode = 0;
3366*5113495bSYour Name 		soc->wbm_release_desc_rx_sg_support = 1;
3367*5113495bSYour Name 		soc->is_rx_fse_full_cache_invalidate_war_enabled = true;
3368*5113495bSYour Name 		break;
3369*5113495bSYour Name 	case TARGET_TYPE_QCA5018:
3370*5113495bSYour Name 	case TARGET_TYPE_QCN6122:
3371*5113495bSYour Name 	case TARGET_TYPE_QCN9160:
3372*5113495bSYour Name 		soc->ast_override_support = 1;
3373*5113495bSYour Name 		soc->da_war_enabled = false;
3374*5113495bSYour Name 		wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, false);
3375*5113495bSYour Name 		soc->per_tid_basize_max_tid = 8;
3376*5113495bSYour Name 		soc->num_hw_dscp_tid_map = HAL_MAX_HW_DSCP_TID_MAPS_11AX;
3377*5113495bSYour Name 		soc->disable_mac1_intr = 1;
3378*5113495bSYour Name 		soc->disable_mac2_intr = 1;
3379*5113495bSYour Name 		soc->wbm_release_desc_rx_sg_support = 1;
3380*5113495bSYour Name 		break;
3381*5113495bSYour Name 	case TARGET_TYPE_QCN9224:
3382*5113495bSYour Name 		soc->umac_reset_supported = true;
3383*5113495bSYour Name 		soc->ast_override_support = 1;
3384*5113495bSYour Name 		soc->da_war_enabled = false;
3385*5113495bSYour Name 		wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, false);
3386*5113495bSYour Name 		soc->per_tid_basize_max_tid = 8;
3387*5113495bSYour Name 		soc->wbm_release_desc_rx_sg_support = 1;
3388*5113495bSYour Name 		soc->rxdma2sw_rings_not_supported = 1;
3389*5113495bSYour Name 		soc->wbm_sg_last_msdu_war = 1;
3390*5113495bSYour Name 		soc->ast_offload_support = AST_OFFLOAD_ENABLE_STATUS;
3391*5113495bSYour Name 		soc->mec_fw_offload = FW_MEC_FW_OFFLOAD_ENABLED;
3392*5113495bSYour Name 		soc->num_hw_dscp_tid_map = HAL_MAX_HW_DSCP_TID_V2_MAPS;
3393*5113495bSYour Name 		wlan_cfg_set_txmon_hw_support(soc->wlan_cfg_ctx, true);
3394*5113495bSYour Name 		soc->host_ast_db_enable = cfg_get(soc->ctrl_psoc,
3395*5113495bSYour Name 						  CFG_DP_HOST_AST_DB_ENABLE);
3396*5113495bSYour Name 		soc->features.wds_ext_ast_override_enable = true;
3397*5113495bSYour Name 		break;
3398*5113495bSYour Name 	case TARGET_TYPE_QCA5332:
3399*5113495bSYour Name 	case TARGET_TYPE_QCN6432:
3400*5113495bSYour Name 		soc->umac_reset_supported = true;
3401*5113495bSYour Name 		soc->ast_override_support = 1;
3402*5113495bSYour Name 		soc->da_war_enabled = false;
3403*5113495bSYour Name 		wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, false);
3404*5113495bSYour Name 		soc->per_tid_basize_max_tid = 8;
3405*5113495bSYour Name 		soc->wbm_release_desc_rx_sg_support = 1;
3406*5113495bSYour Name 		soc->rxdma2sw_rings_not_supported = 1;
3407*5113495bSYour Name 		soc->wbm_sg_last_msdu_war = 1;
3408*5113495bSYour Name 		soc->ast_offload_support = AST_OFFLOAD_ENABLE_STATUS;
3409*5113495bSYour Name 		soc->mec_fw_offload = FW_MEC_FW_OFFLOAD_ENABLED;
3410*5113495bSYour Name 		soc->num_hw_dscp_tid_map = HAL_MAX_HW_DSCP_TID_V2_MAPS_5332;
3411*5113495bSYour Name 		wlan_cfg_set_txmon_hw_support(soc->wlan_cfg_ctx, true);
3412*5113495bSYour Name 		soc->host_ast_db_enable = cfg_get(soc->ctrl_psoc,
3413*5113495bSYour Name 						  CFG_DP_HOST_AST_DB_ENABLE);
3414*5113495bSYour Name 		soc->features.wds_ext_ast_override_enable = true;
3415*5113495bSYour Name 		break;
3416*5113495bSYour Name 	default:
3417*5113495bSYour Name 		qdf_print("%s: Unknown tgt type %d\n", __func__, target_type);
3418*5113495bSYour Name 		qdf_assert_always(0);
3419*5113495bSYour Name 		break;
3420*5113495bSYour Name 	}
3421*5113495bSYour Name 	dp_soc_cfg_dump(soc, target_type);
3422*5113495bSYour Name }
3423*5113495bSYour Name 
3424*5113495bSYour Name /**
3425*5113495bSYour Name  * dp_soc_get_ap_mld_mode() - store ap mld mode from ini
3426*5113495bSYour Name  * @soc: Opaque DP SOC handle
3427*5113495bSYour Name  *
3428*5113495bSYour Name  * Return: none
3429*5113495bSYour Name  */
3430*5113495bSYour Name #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
dp_soc_get_ap_mld_mode(struct dp_soc * soc)3431*5113495bSYour Name static inline void dp_soc_get_ap_mld_mode(struct dp_soc *soc)
3432*5113495bSYour Name {
3433*5113495bSYour Name 	if (soc->cdp_soc.ol_ops->get_dp_cfg_param) {
3434*5113495bSYour Name 		soc->mld_mode_ap =
3435*5113495bSYour Name 		soc->cdp_soc.ol_ops->get_dp_cfg_param(soc->ctrl_psoc,
3436*5113495bSYour Name 					CDP_CFG_MLD_NETDEV_MODE_AP);
3437*5113495bSYour Name 	}
3438*5113495bSYour Name 	dp_info("DP mld_mode_ap-%u\n", soc->mld_mode_ap);
3439*5113495bSYour Name }
3440*5113495bSYour Name #else
dp_soc_get_ap_mld_mode(struct dp_soc * soc)3441*5113495bSYour Name static inline void dp_soc_get_ap_mld_mode(struct dp_soc *soc)
3442*5113495bSYour Name {
3443*5113495bSYour Name 	(void)soc;
3444*5113495bSYour Name }
3445*5113495bSYour Name #endif
3446*5113495bSYour Name 
3447*5113495bSYour Name #ifdef QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT
3448*5113495bSYour Name /**
3449*5113495bSYour Name  * dp_soc_hw_txrx_stats_init() - Initialize hw_txrx_stats_en in dp_soc
3450*5113495bSYour Name  * @soc: Datapath soc handle
3451*5113495bSYour Name  *
3452*5113495bSYour Name  * Return: none
3453*5113495bSYour Name  */
3454*5113495bSYour Name static inline
dp_soc_hw_txrx_stats_init(struct dp_soc * soc)3455*5113495bSYour Name void dp_soc_hw_txrx_stats_init(struct dp_soc *soc)
3456*5113495bSYour Name {
3457*5113495bSYour Name 	soc->hw_txrx_stats_en =
3458*5113495bSYour Name 		wlan_cfg_get_vdev_stats_hw_offload_config(soc->wlan_cfg_ctx);
3459*5113495bSYour Name }
3460*5113495bSYour Name #else
3461*5113495bSYour Name static inline
dp_soc_hw_txrx_stats_init(struct dp_soc * soc)3462*5113495bSYour Name void dp_soc_hw_txrx_stats_init(struct dp_soc *soc)
3463*5113495bSYour Name {
3464*5113495bSYour Name 	soc->hw_txrx_stats_en = 0;
3465*5113495bSYour Name }
3466*5113495bSYour Name #endif
3467*5113495bSYour Name 
3468*5113495bSYour Name /**
3469*5113495bSYour Name  * dp_soc_init() - Initialize txrx SOC
3470*5113495bSYour Name  * @soc: Opaque DP SOC handle
3471*5113495bSYour Name  * @htc_handle: Opaque HTC handle
3472*5113495bSYour Name  * @hif_handle: Opaque HIF handle
3473*5113495bSYour Name  *
3474*5113495bSYour Name  * Return: DP SOC handle on success, NULL on failure
3475*5113495bSYour Name  */
dp_soc_init(struct dp_soc * soc,HTC_HANDLE htc_handle,struct hif_opaque_softc * hif_handle)3476*5113495bSYour Name void *dp_soc_init(struct dp_soc *soc, HTC_HANDLE htc_handle,
3477*5113495bSYour Name 		  struct hif_opaque_softc *hif_handle)
3478*5113495bSYour Name {
3479*5113495bSYour Name 	struct htt_soc *htt_soc = (struct htt_soc *)soc->htt_handle;
3480*5113495bSYour Name 	bool is_monitor_mode = false;
3481*5113495bSYour Name 	uint8_t i;
3482*5113495bSYour Name 	int num_dp_msi;
3483*5113495bSYour Name 	bool ppeds_attached = false;
3484*5113495bSYour Name 
3485*5113495bSYour Name 	htt_soc = htt_soc_attach(soc, htc_handle);
3486*5113495bSYour Name 	if (!htt_soc)
3487*5113495bSYour Name 		goto fail1;
3488*5113495bSYour Name 
3489*5113495bSYour Name 	soc->htt_handle = htt_soc;
3490*5113495bSYour Name 
3491*5113495bSYour Name 	if (htt_soc_htc_prealloc(htt_soc) != QDF_STATUS_SUCCESS)
3492*5113495bSYour Name 		goto fail2;
3493*5113495bSYour Name 
3494*5113495bSYour Name 	htt_set_htc_handle(htt_soc, htc_handle);
3495*5113495bSYour Name 
3496*5113495bSYour Name 	dp_soc_cfg_init(soc);
3497*5113495bSYour Name 
3498*5113495bSYour Name 	dp_monitor_soc_cfg_init(soc);
3499*5113495bSYour Name 	/* Reset/Initialize wbm sg list and flags */
3500*5113495bSYour Name 	dp_rx_wbm_sg_list_reset(soc);
3501*5113495bSYour Name 
3502*5113495bSYour Name 	/* Note: Any SRNG ring initialization should happen only after
3503*5113495bSYour Name 	 * Interrupt mode is set and followed by filling up the
3504*5113495bSYour Name 	 * interrupt mask. IT SHOULD ALWAYS BE IN THIS ORDER.
3505*5113495bSYour Name 	 */
3506*5113495bSYour Name 	dp_soc_set_interrupt_mode(soc);
3507*5113495bSYour Name 	if (soc->cdp_soc.ol_ops->get_con_mode &&
3508*5113495bSYour Name 	    soc->cdp_soc.ol_ops->get_con_mode() ==
3509*5113495bSYour Name 	    QDF_GLOBAL_MONITOR_MODE) {
3510*5113495bSYour Name 		is_monitor_mode = true;
3511*5113495bSYour Name 		soc->curr_rx_pkt_tlv_size = soc->rx_mon_pkt_tlv_size;
3512*5113495bSYour Name 	} else {
3513*5113495bSYour Name 		soc->curr_rx_pkt_tlv_size = soc->rx_pkt_tlv_size;
3514*5113495bSYour Name 	}
3515*5113495bSYour Name 
3516*5113495bSYour Name 	num_dp_msi = dp_get_num_msi_available(soc, soc->intr_mode);
3517*5113495bSYour Name 	if (num_dp_msi < 0) {
3518*5113495bSYour Name 		dp_init_err("%pK: dp_interrupt assignment failed", soc);
3519*5113495bSYour Name 		goto fail3;
3520*5113495bSYour Name 	}
3521*5113495bSYour Name 
3522*5113495bSYour Name 	if (soc->arch_ops.ppeds_handle_attached)
3523*5113495bSYour Name 		ppeds_attached = soc->arch_ops.ppeds_handle_attached(soc);
3524*5113495bSYour Name 
3525*5113495bSYour Name 	wlan_cfg_fill_interrupt_mask(soc->wlan_cfg_ctx, num_dp_msi,
3526*5113495bSYour Name 				     soc->intr_mode, is_monitor_mode,
3527*5113495bSYour Name 				     ppeds_attached,
3528*5113495bSYour Name 				     soc->umac_reset_supported);
3529*5113495bSYour Name 
3530*5113495bSYour Name 	/* initialize WBM_IDLE_LINK ring */
3531*5113495bSYour Name 	if (dp_hw_link_desc_ring_init(soc)) {
3532*5113495bSYour Name 		dp_init_err("%pK: dp_hw_link_desc_ring_init failed", soc);
3533*5113495bSYour Name 		goto fail3;
3534*5113495bSYour Name 	}
3535*5113495bSYour Name 
3536*5113495bSYour Name 	dp_link_desc_ring_replenish(soc, WLAN_INVALID_PDEV_ID);
3537*5113495bSYour Name 
3538*5113495bSYour Name 	if (dp_soc_srng_init(soc)) {
3539*5113495bSYour Name 		dp_init_err("%pK: dp_soc_srng_init failed", soc);
3540*5113495bSYour Name 		goto fail4;
3541*5113495bSYour Name 	}
3542*5113495bSYour Name 
3543*5113495bSYour Name 	if (htt_soc_initialize(soc->htt_handle, soc->ctrl_psoc,
3544*5113495bSYour Name 			       htt_get_htc_handle(htt_soc),
3545*5113495bSYour Name 			       soc->hal_soc, soc->osdev) == NULL)
3546*5113495bSYour Name 		goto fail5;
3547*5113495bSYour Name 
3548*5113495bSYour Name 	/* Initialize descriptors in TCL Rings */
3549*5113495bSYour Name 	for (i = 0; i < soc->num_tcl_data_rings; i++) {
3550*5113495bSYour Name 		hal_tx_init_data_ring(soc->hal_soc,
3551*5113495bSYour Name 				      soc->tcl_data_ring[i].hal_srng);
3552*5113495bSYour Name 	}
3553*5113495bSYour Name 
3554*5113495bSYour Name 	if (dp_soc_tx_desc_sw_pools_init(soc)) {
3555*5113495bSYour Name 		dp_init_err("%pK: dp_tx_soc_attach failed", soc);
3556*5113495bSYour Name 		goto fail6;
3557*5113495bSYour Name 	}
3558*5113495bSYour Name 
3559*5113495bSYour Name 	if (soc->arch_ops.txrx_soc_ppeds_start) {
3560*5113495bSYour Name 		if (soc->arch_ops.txrx_soc_ppeds_start(soc)) {
3561*5113495bSYour Name 			dp_init_err("%pK: ppeds start failed", soc);
3562*5113495bSYour Name 			goto fail7;
3563*5113495bSYour Name 		}
3564*5113495bSYour Name 	}
3565*5113495bSYour Name 
3566*5113495bSYour Name 	wlan_cfg_set_rx_hash(soc->wlan_cfg_ctx,
3567*5113495bSYour Name 			     cfg_get(soc->ctrl_psoc, CFG_DP_RX_HASH));
3568*5113495bSYour Name #ifdef WLAN_SUPPORT_RX_FLOW_TAG
3569*5113495bSYour Name 	wlan_cfg_set_rx_rr(soc->wlan_cfg_ctx,
3570*5113495bSYour Name 			   cfg_get(soc->ctrl_psoc, CFG_DP_RX_RR));
3571*5113495bSYour Name #endif
3572*5113495bSYour Name 	soc->cce_disable = false;
3573*5113495bSYour Name 	soc->max_ast_ageout_count = MAX_AST_AGEOUT_COUNT;
3574*5113495bSYour Name 
3575*5113495bSYour Name 	soc->sta_mode_search_policy = DP_TX_ADDR_SEARCH_ADDR_POLICY;
3576*5113495bSYour Name 	qdf_mem_zero(&soc->vdev_id_map, sizeof(soc->vdev_id_map));
3577*5113495bSYour Name 	qdf_spinlock_create(&soc->vdev_map_lock);
3578*5113495bSYour Name 	qdf_atomic_init(&soc->num_tx_outstanding);
3579*5113495bSYour Name 	qdf_atomic_init(&soc->num_tx_exception);
3580*5113495bSYour Name 	soc->num_tx_allowed =
3581*5113495bSYour Name 		wlan_cfg_get_dp_soc_tx_device_limit(soc->wlan_cfg_ctx);
3582*5113495bSYour Name 	soc->num_tx_spl_allowed =
3583*5113495bSYour Name 		wlan_cfg_get_dp_soc_tx_spl_device_limit(soc->wlan_cfg_ctx);
3584*5113495bSYour Name 	soc->num_reg_tx_allowed = soc->num_tx_allowed - soc->num_tx_spl_allowed;
3585*5113495bSYour Name 	if (soc->cdp_soc.ol_ops->get_dp_cfg_param) {
3586*5113495bSYour Name 		int ret = soc->cdp_soc.ol_ops->get_dp_cfg_param(soc->ctrl_psoc,
3587*5113495bSYour Name 				CDP_CFG_MAX_PEER_ID);
3588*5113495bSYour Name 
3589*5113495bSYour Name 		if (ret != -EINVAL)
3590*5113495bSYour Name 			wlan_cfg_set_max_peer_id(soc->wlan_cfg_ctx, ret);
3591*5113495bSYour Name 
3592*5113495bSYour Name 		ret = soc->cdp_soc.ol_ops->get_dp_cfg_param(soc->ctrl_psoc,
3593*5113495bSYour Name 				CDP_CFG_CCE_DISABLE);
3594*5113495bSYour Name 		if (ret == 1)
3595*5113495bSYour Name 			soc->cce_disable = true;
3596*5113495bSYour Name 	}
3597*5113495bSYour Name 
3598*5113495bSYour Name 	/*
3599*5113495bSYour Name 	 * Skip registering hw ring interrupts for WMAC2 on IPQ6018
3600*5113495bSYour Name 	 * and IPQ5018 WMAC2 is not there in these platforms.
3601*5113495bSYour Name 	 */
3602*5113495bSYour Name 	if (hal_get_target_type(soc->hal_soc) == TARGET_TYPE_QCA6018 ||
3603*5113495bSYour Name 	    soc->disable_mac2_intr)
3604*5113495bSYour Name 		dp_soc_disable_unused_mac_intr_mask(soc, 0x2);
3605*5113495bSYour Name 
3606*5113495bSYour Name 	/*
3607*5113495bSYour Name 	 * Skip registering hw ring interrupts for WMAC1 on IPQ5018
3608*5113495bSYour Name 	 * WMAC1 is not there in this platform.
3609*5113495bSYour Name 	 */
3610*5113495bSYour Name 	if (soc->disable_mac1_intr)
3611*5113495bSYour Name 		dp_soc_disable_unused_mac_intr_mask(soc, 0x1);
3612*5113495bSYour Name 
3613*5113495bSYour Name 	/* setup the global rx defrag waitlist */
3614*5113495bSYour Name 	TAILQ_INIT(&soc->rx.defrag.waitlist);
3615*5113495bSYour Name 	soc->rx.defrag.timeout_ms =
3616*5113495bSYour Name 		wlan_cfg_get_rx_defrag_min_timeout(soc->wlan_cfg_ctx);
3617*5113495bSYour Name 	soc->rx.defrag.next_flush_ms = 0;
3618*5113495bSYour Name 	soc->rx.flags.defrag_timeout_check =
3619*5113495bSYour Name 		wlan_cfg_get_defrag_timeout_check(soc->wlan_cfg_ctx);
3620*5113495bSYour Name 	qdf_spinlock_create(&soc->rx.defrag.defrag_lock);
3621*5113495bSYour Name 
3622*5113495bSYour Name 	dp_monitor_soc_init(soc);
3623*5113495bSYour Name 
3624*5113495bSYour Name 	qdf_atomic_set(&soc->cmn_init_done, 1);
3625*5113495bSYour Name 
3626*5113495bSYour Name 	qdf_nbuf_queue_init(&soc->htt_stats.msg);
3627*5113495bSYour Name 
3628*5113495bSYour Name 	qdf_spinlock_create(&soc->ast_lock);
3629*5113495bSYour Name 	dp_peer_mec_spinlock_create(soc);
3630*5113495bSYour Name 
3631*5113495bSYour Name 	qdf_spinlock_create(&soc->reo_desc_freelist_lock);
3632*5113495bSYour Name 	qdf_list_create(&soc->reo_desc_freelist, REO_DESC_FREELIST_SIZE);
3633*5113495bSYour Name 	INIT_RX_HW_STATS_LOCK(soc);
3634*5113495bSYour Name 
3635*5113495bSYour Name 	qdf_nbuf_queue_init(&soc->invalid_buf_queue);
3636*5113495bSYour Name 	/* fill the tx/rx cpu ring map*/
3637*5113495bSYour Name 	dp_soc_set_txrx_ring_map(soc);
3638*5113495bSYour Name 
3639*5113495bSYour Name 	TAILQ_INIT(&soc->inactive_peer_list);
3640*5113495bSYour Name 	qdf_spinlock_create(&soc->inactive_peer_list_lock);
3641*5113495bSYour Name 	TAILQ_INIT(&soc->inactive_vdev_list);
3642*5113495bSYour Name 	qdf_spinlock_create(&soc->inactive_vdev_list_lock);
3643*5113495bSYour Name 	qdf_spinlock_create(&soc->htt_stats.lock);
3644*5113495bSYour Name 	/* initialize work queue for stats processing */
3645*5113495bSYour Name 	qdf_create_work(0, &soc->htt_stats.work, htt_t2h_stats_handler, soc);
3646*5113495bSYour Name 
3647*5113495bSYour Name 	dp_reo_desc_deferred_freelist_create(soc);
3648*5113495bSYour Name 
3649*5113495bSYour Name 	dp_info("Mem stats: DMA = %u HEAP = %u SKB = %u",
3650*5113495bSYour Name 		qdf_dma_mem_stats_read(),
3651*5113495bSYour Name 		qdf_heap_mem_stats_read(),
3652*5113495bSYour Name 		qdf_skb_total_mem_stats_read());
3653*5113495bSYour Name 
3654*5113495bSYour Name 	soc->vdev_stats_id_map = 0;
3655*5113495bSYour Name 
3656*5113495bSYour Name 	dp_soc_hw_txrx_stats_init(soc);
3657*5113495bSYour Name 
3658*5113495bSYour Name 	dp_soc_get_ap_mld_mode(soc);
3659*5113495bSYour Name 
3660*5113495bSYour Name 	return soc;
3661*5113495bSYour Name fail7:
3662*5113495bSYour Name 	dp_soc_tx_desc_sw_pools_deinit(soc);
3663*5113495bSYour Name fail6:
3664*5113495bSYour Name 	htt_soc_htc_dealloc(soc->htt_handle);
3665*5113495bSYour Name fail5:
3666*5113495bSYour Name 	dp_soc_srng_deinit(soc);
3667*5113495bSYour Name fail4:
3668*5113495bSYour Name 	dp_hw_link_desc_ring_deinit(soc);
3669*5113495bSYour Name fail3:
3670*5113495bSYour Name 	htt_htc_pkt_pool_free(htt_soc);
3671*5113495bSYour Name fail2:
3672*5113495bSYour Name 	htt_soc_detach(htt_soc);
3673*5113495bSYour Name fail1:
3674*5113495bSYour Name 	return NULL;
3675*5113495bSYour Name }
3676*5113495bSYour Name 
3677*5113495bSYour Name #ifndef WLAN_DP_DISABLE_TCL_CMD_CRED_SRNG
dp_soc_tcl_cmd_cred_srng_init(struct dp_soc * soc)3678*5113495bSYour Name static inline QDF_STATUS dp_soc_tcl_cmd_cred_srng_init(struct dp_soc *soc)
3679*5113495bSYour Name {
3680*5113495bSYour Name 	QDF_STATUS status;
3681*5113495bSYour Name 
3682*5113495bSYour Name 	if (soc->init_tcl_cmd_cred_ring) {
3683*5113495bSYour Name 		status =  dp_srng_init(soc, &soc->tcl_cmd_credit_ring,
3684*5113495bSYour Name 				       TCL_CMD_CREDIT, 0, 0);
3685*5113495bSYour Name 		if (QDF_IS_STATUS_ERROR(status))
3686*5113495bSYour Name 			return status;
3687*5113495bSYour Name 
3688*5113495bSYour Name 		wlan_minidump_log(soc->tcl_cmd_credit_ring.base_vaddr_unaligned,
3689*5113495bSYour Name 				  soc->tcl_cmd_credit_ring.alloc_size,
3690*5113495bSYour Name 				  soc->ctrl_psoc,
3691*5113495bSYour Name 				  WLAN_MD_DP_SRNG_TCL_CMD,
3692*5113495bSYour Name 				  "wbm_desc_rel_ring");
3693*5113495bSYour Name 	}
3694*5113495bSYour Name 
3695*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
3696*5113495bSYour Name }
3697*5113495bSYour Name 
dp_soc_tcl_cmd_cred_srng_deinit(struct dp_soc * soc)3698*5113495bSYour Name static inline void dp_soc_tcl_cmd_cred_srng_deinit(struct dp_soc *soc)
3699*5113495bSYour Name {
3700*5113495bSYour Name 	if (soc->init_tcl_cmd_cred_ring) {
3701*5113495bSYour Name 		wlan_minidump_remove(soc->tcl_cmd_credit_ring.base_vaddr_unaligned,
3702*5113495bSYour Name 				     soc->tcl_cmd_credit_ring.alloc_size,
3703*5113495bSYour Name 				     soc->ctrl_psoc, WLAN_MD_DP_SRNG_TCL_CMD,
3704*5113495bSYour Name 				     "wbm_desc_rel_ring");
3705*5113495bSYour Name 		dp_srng_deinit(soc, &soc->tcl_cmd_credit_ring,
3706*5113495bSYour Name 			       TCL_CMD_CREDIT, 0);
3707*5113495bSYour Name 	}
3708*5113495bSYour Name }
3709*5113495bSYour Name 
dp_soc_tcl_cmd_cred_srng_alloc(struct dp_soc * soc)3710*5113495bSYour Name static inline QDF_STATUS dp_soc_tcl_cmd_cred_srng_alloc(struct dp_soc *soc)
3711*5113495bSYour Name {
3712*5113495bSYour Name 	struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx = soc->wlan_cfg_ctx;
3713*5113495bSYour Name 	uint32_t entries;
3714*5113495bSYour Name 	QDF_STATUS status;
3715*5113495bSYour Name 
3716*5113495bSYour Name 	entries = wlan_cfg_get_dp_soc_tcl_cmd_credit_ring_size(soc_cfg_ctx);
3717*5113495bSYour Name 	if (soc->init_tcl_cmd_cred_ring) {
3718*5113495bSYour Name 		status = dp_srng_alloc(soc, &soc->tcl_cmd_credit_ring,
3719*5113495bSYour Name 				       TCL_CMD_CREDIT, entries, 0);
3720*5113495bSYour Name 		if (QDF_IS_STATUS_ERROR(status))
3721*5113495bSYour Name 			return status;
3722*5113495bSYour Name 	}
3723*5113495bSYour Name 
3724*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
3725*5113495bSYour Name }
3726*5113495bSYour Name 
dp_soc_tcl_cmd_cred_srng_free(struct dp_soc * soc)3727*5113495bSYour Name static inline void dp_soc_tcl_cmd_cred_srng_free(struct dp_soc *soc)
3728*5113495bSYour Name {
3729*5113495bSYour Name 	if (soc->init_tcl_cmd_cred_ring)
3730*5113495bSYour Name 		dp_srng_free(soc, &soc->tcl_cmd_credit_ring);
3731*5113495bSYour Name }
3732*5113495bSYour Name 
dp_tx_init_cmd_credit_ring(struct dp_soc * soc)3733*5113495bSYour Name inline void dp_tx_init_cmd_credit_ring(struct dp_soc *soc)
3734*5113495bSYour Name {
3735*5113495bSYour Name 	if (soc->init_tcl_cmd_cred_ring)
3736*5113495bSYour Name 		hal_tx_init_cmd_credit_ring(soc->hal_soc,
3737*5113495bSYour Name 					    soc->tcl_cmd_credit_ring.hal_srng);
3738*5113495bSYour Name }
3739*5113495bSYour Name #else
dp_soc_tcl_cmd_cred_srng_init(struct dp_soc * soc)3740*5113495bSYour Name static inline QDF_STATUS dp_soc_tcl_cmd_cred_srng_init(struct dp_soc *soc)
3741*5113495bSYour Name {
3742*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
3743*5113495bSYour Name }
3744*5113495bSYour Name 
dp_soc_tcl_cmd_cred_srng_deinit(struct dp_soc * soc)3745*5113495bSYour Name static inline void dp_soc_tcl_cmd_cred_srng_deinit(struct dp_soc *soc)
3746*5113495bSYour Name {
3747*5113495bSYour Name }
3748*5113495bSYour Name 
dp_soc_tcl_cmd_cred_srng_alloc(struct dp_soc * soc)3749*5113495bSYour Name static inline QDF_STATUS dp_soc_tcl_cmd_cred_srng_alloc(struct dp_soc *soc)
3750*5113495bSYour Name {
3751*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
3752*5113495bSYour Name }
3753*5113495bSYour Name 
dp_soc_tcl_cmd_cred_srng_free(struct dp_soc * soc)3754*5113495bSYour Name static inline void dp_soc_tcl_cmd_cred_srng_free(struct dp_soc *soc)
3755*5113495bSYour Name {
3756*5113495bSYour Name }
3757*5113495bSYour Name 
dp_tx_init_cmd_credit_ring(struct dp_soc * soc)3758*5113495bSYour Name inline void dp_tx_init_cmd_credit_ring(struct dp_soc *soc)
3759*5113495bSYour Name {
3760*5113495bSYour Name }
3761*5113495bSYour Name #endif
3762*5113495bSYour Name 
3763*5113495bSYour Name #ifndef WLAN_DP_DISABLE_TCL_STATUS_SRNG
dp_soc_tcl_status_srng_init(struct dp_soc * soc)3764*5113495bSYour Name static inline QDF_STATUS dp_soc_tcl_status_srng_init(struct dp_soc *soc)
3765*5113495bSYour Name {
3766*5113495bSYour Name 	QDF_STATUS status;
3767*5113495bSYour Name 
3768*5113495bSYour Name 	status =  dp_srng_init(soc, &soc->tcl_status_ring, TCL_STATUS, 0, 0);
3769*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status))
3770*5113495bSYour Name 		return status;
3771*5113495bSYour Name 
3772*5113495bSYour Name 	wlan_minidump_log(soc->tcl_status_ring.base_vaddr_unaligned,
3773*5113495bSYour Name 			  soc->tcl_status_ring.alloc_size,
3774*5113495bSYour Name 			  soc->ctrl_psoc,
3775*5113495bSYour Name 			  WLAN_MD_DP_SRNG_TCL_STATUS,
3776*5113495bSYour Name 			  "wbm_desc_rel_ring");
3777*5113495bSYour Name 
3778*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
3779*5113495bSYour Name }
3780*5113495bSYour Name 
dp_soc_tcl_status_srng_deinit(struct dp_soc * soc)3781*5113495bSYour Name static inline void dp_soc_tcl_status_srng_deinit(struct dp_soc *soc)
3782*5113495bSYour Name {
3783*5113495bSYour Name 	wlan_minidump_remove(soc->tcl_status_ring.base_vaddr_unaligned,
3784*5113495bSYour Name 			     soc->tcl_status_ring.alloc_size,
3785*5113495bSYour Name 			     soc->ctrl_psoc, WLAN_MD_DP_SRNG_TCL_STATUS,
3786*5113495bSYour Name 			     "wbm_desc_rel_ring");
3787*5113495bSYour Name 	dp_srng_deinit(soc, &soc->tcl_status_ring, TCL_STATUS, 0);
3788*5113495bSYour Name }
3789*5113495bSYour Name 
dp_soc_tcl_status_srng_alloc(struct dp_soc * soc)3790*5113495bSYour Name static inline QDF_STATUS dp_soc_tcl_status_srng_alloc(struct dp_soc *soc)
3791*5113495bSYour Name {
3792*5113495bSYour Name 	struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx = soc->wlan_cfg_ctx;
3793*5113495bSYour Name 	uint32_t entries;
3794*5113495bSYour Name 	QDF_STATUS status = QDF_STATUS_SUCCESS;
3795*5113495bSYour Name 
3796*5113495bSYour Name 	entries = wlan_cfg_get_dp_soc_tcl_status_ring_size(soc_cfg_ctx);
3797*5113495bSYour Name 	status = dp_srng_alloc(soc, &soc->tcl_status_ring,
3798*5113495bSYour Name 			       TCL_STATUS, entries, 0);
3799*5113495bSYour Name 
3800*5113495bSYour Name 	return status;
3801*5113495bSYour Name }
3802*5113495bSYour Name 
dp_soc_tcl_status_srng_free(struct dp_soc * soc)3803*5113495bSYour Name static inline void dp_soc_tcl_status_srng_free(struct dp_soc *soc)
3804*5113495bSYour Name {
3805*5113495bSYour Name 	dp_srng_free(soc, &soc->tcl_status_ring);
3806*5113495bSYour Name }
3807*5113495bSYour Name #else
dp_soc_tcl_status_srng_init(struct dp_soc * soc)3808*5113495bSYour Name static inline QDF_STATUS dp_soc_tcl_status_srng_init(struct dp_soc *soc)
3809*5113495bSYour Name {
3810*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
3811*5113495bSYour Name }
3812*5113495bSYour Name 
dp_soc_tcl_status_srng_deinit(struct dp_soc * soc)3813*5113495bSYour Name static inline void dp_soc_tcl_status_srng_deinit(struct dp_soc *soc)
3814*5113495bSYour Name {
3815*5113495bSYour Name }
3816*5113495bSYour Name 
dp_soc_tcl_status_srng_alloc(struct dp_soc * soc)3817*5113495bSYour Name static inline QDF_STATUS dp_soc_tcl_status_srng_alloc(struct dp_soc *soc)
3818*5113495bSYour Name {
3819*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
3820*5113495bSYour Name }
3821*5113495bSYour Name 
dp_soc_tcl_status_srng_free(struct dp_soc * soc)3822*5113495bSYour Name static inline void dp_soc_tcl_status_srng_free(struct dp_soc *soc)
3823*5113495bSYour Name {
3824*5113495bSYour Name }
3825*5113495bSYour Name #endif
3826*5113495bSYour Name 
3827*5113495bSYour Name /**
3828*5113495bSYour Name  * dp_soc_srng_deinit() - de-initialize soc srng rings
3829*5113495bSYour Name  * @soc: Datapath soc handle
3830*5113495bSYour Name  *
3831*5113495bSYour Name  */
dp_soc_srng_deinit(struct dp_soc * soc)3832*5113495bSYour Name void dp_soc_srng_deinit(struct dp_soc *soc)
3833*5113495bSYour Name {
3834*5113495bSYour Name 	uint32_t i;
3835*5113495bSYour Name 
3836*5113495bSYour Name 	if (soc->arch_ops.txrx_soc_srng_deinit)
3837*5113495bSYour Name 		soc->arch_ops.txrx_soc_srng_deinit(soc);
3838*5113495bSYour Name 
3839*5113495bSYour Name 	/* Free the ring memories */
3840*5113495bSYour Name 	/* Common rings */
3841*5113495bSYour Name 	wlan_minidump_remove(soc->wbm_desc_rel_ring.base_vaddr_unaligned,
3842*5113495bSYour Name 			     soc->wbm_desc_rel_ring.alloc_size,
3843*5113495bSYour Name 			     soc->ctrl_psoc, WLAN_MD_DP_SRNG_WBM_DESC_REL,
3844*5113495bSYour Name 			     "wbm_desc_rel_ring");
3845*5113495bSYour Name 	dp_srng_deinit(soc, &soc->wbm_desc_rel_ring, SW2WBM_RELEASE, 0);
3846*5113495bSYour Name 	dp_ssr_dump_srng_unregister("wbm_desc_rel_ring", -1);
3847*5113495bSYour Name 
3848*5113495bSYour Name 	/* Tx data rings */
3849*5113495bSYour Name 	for (i = 0; i < soc->num_tcl_data_rings; i++)
3850*5113495bSYour Name 		dp_deinit_tx_pair_by_index(soc, i);
3851*5113495bSYour Name 
3852*5113495bSYour Name 	if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) {
3853*5113495bSYour Name 		dp_deinit_tx_pair_by_index(soc, IPA_TCL_DATA_RING_IDX);
3854*5113495bSYour Name 		dp_ipa_deinit_alt_tx_ring(soc);
3855*5113495bSYour Name 	}
3856*5113495bSYour Name 
3857*5113495bSYour Name 	/* TCL command and status rings */
3858*5113495bSYour Name 	dp_soc_tcl_cmd_cred_srng_deinit(soc);
3859*5113495bSYour Name 	dp_soc_tcl_status_srng_deinit(soc);
3860*5113495bSYour Name 
3861*5113495bSYour Name 	for (i = 0; i < soc->num_reo_dest_rings; i++) {
3862*5113495bSYour Name 		/* TODO: Get number of rings and ring sizes
3863*5113495bSYour Name 		 * from wlan_cfg
3864*5113495bSYour Name 		 */
3865*5113495bSYour Name 		dp_ssr_dump_srng_unregister("reo_dest_ring", i);
3866*5113495bSYour Name 		wlan_minidump_remove(soc->reo_dest_ring[i].base_vaddr_unaligned,
3867*5113495bSYour Name 				     soc->reo_dest_ring[i].alloc_size,
3868*5113495bSYour Name 				     soc->ctrl_psoc, WLAN_MD_DP_SRNG_REO_DEST,
3869*5113495bSYour Name 				     "reo_dest_ring");
3870*5113495bSYour Name 		dp_srng_deinit(soc, &soc->reo_dest_ring[i], REO_DST, i);
3871*5113495bSYour Name 	}
3872*5113495bSYour Name 
3873*5113495bSYour Name 	dp_ssr_dump_srng_unregister("reo_reinject_ring", -1);
3874*5113495bSYour Name 	/* REO reinjection ring */
3875*5113495bSYour Name 	wlan_minidump_remove(soc->reo_reinject_ring.base_vaddr_unaligned,
3876*5113495bSYour Name 			     soc->reo_reinject_ring.alloc_size,
3877*5113495bSYour Name 			     soc->ctrl_psoc, WLAN_MD_DP_SRNG_REO_REINJECT,
3878*5113495bSYour Name 			     "reo_reinject_ring");
3879*5113495bSYour Name 	dp_srng_deinit(soc, &soc->reo_reinject_ring, REO_REINJECT, 0);
3880*5113495bSYour Name 
3881*5113495bSYour Name 	dp_ssr_dump_srng_unregister("rx_rel_ring", -1);
3882*5113495bSYour Name 	/* Rx release ring */
3883*5113495bSYour Name 	wlan_minidump_remove(soc->rx_rel_ring.base_vaddr_unaligned,
3884*5113495bSYour Name 			     soc->rx_rel_ring.alloc_size,
3885*5113495bSYour Name 			     soc->ctrl_psoc, WLAN_MD_DP_SRNG_RX_REL,
3886*5113495bSYour Name 			     "reo_release_ring");
3887*5113495bSYour Name 	dp_srng_deinit(soc, &soc->rx_rel_ring, WBM2SW_RELEASE, 0);
3888*5113495bSYour Name 
3889*5113495bSYour Name 	/* Rx exception ring */
3890*5113495bSYour Name 	/* TODO: Better to store ring_type and ring_num in
3891*5113495bSYour Name 	 * dp_srng during setup
3892*5113495bSYour Name 	 */
3893*5113495bSYour Name 	dp_ssr_dump_srng_unregister("reo_exception_ring", -1);
3894*5113495bSYour Name 	wlan_minidump_remove(soc->reo_exception_ring.base_vaddr_unaligned,
3895*5113495bSYour Name 			     soc->reo_exception_ring.alloc_size,
3896*5113495bSYour Name 			     soc->ctrl_psoc, WLAN_MD_DP_SRNG_REO_EXCEPTION,
3897*5113495bSYour Name 			     "reo_exception_ring");
3898*5113495bSYour Name 	dp_srng_deinit(soc, &soc->reo_exception_ring, REO_EXCEPTION, 0);
3899*5113495bSYour Name 
3900*5113495bSYour Name 	/* REO command and status rings */
3901*5113495bSYour Name 	dp_ssr_dump_srng_unregister("reo_cmd_ring", -1);
3902*5113495bSYour Name 	wlan_minidump_remove(soc->reo_cmd_ring.base_vaddr_unaligned,
3903*5113495bSYour Name 			     soc->reo_cmd_ring.alloc_size,
3904*5113495bSYour Name 			     soc->ctrl_psoc, WLAN_MD_DP_SRNG_REO_CMD,
3905*5113495bSYour Name 			     "reo_cmd_ring");
3906*5113495bSYour Name 	dp_srng_deinit(soc, &soc->reo_cmd_ring, REO_CMD, 0);
3907*5113495bSYour Name 	dp_ssr_dump_srng_unregister("reo_status_ring", -1);
3908*5113495bSYour Name 	wlan_minidump_remove(soc->reo_status_ring.base_vaddr_unaligned,
3909*5113495bSYour Name 			     soc->reo_status_ring.alloc_size,
3910*5113495bSYour Name 			     soc->ctrl_psoc, WLAN_MD_DP_SRNG_REO_STATUS,
3911*5113495bSYour Name 			     "reo_status_ring");
3912*5113495bSYour Name 	dp_srng_deinit(soc, &soc->reo_status_ring, REO_STATUS, 0);
3913*5113495bSYour Name }
3914*5113495bSYour Name 
3915*5113495bSYour Name /**
3916*5113495bSYour Name  * dp_soc_srng_init() - Initialize soc level srng rings
3917*5113495bSYour Name  * @soc: Datapath soc handle
3918*5113495bSYour Name  *
3919*5113495bSYour Name  * Return: QDF_STATUS_SUCCESS on success
3920*5113495bSYour Name  *	   QDF_STATUS_E_FAILURE on failure
3921*5113495bSYour Name  */
dp_soc_srng_init(struct dp_soc * soc)3922*5113495bSYour Name QDF_STATUS dp_soc_srng_init(struct dp_soc *soc)
3923*5113495bSYour Name {
3924*5113495bSYour Name 	struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
3925*5113495bSYour Name 	uint8_t i;
3926*5113495bSYour Name 	uint8_t wbm2_sw_rx_rel_ring_id;
3927*5113495bSYour Name 
3928*5113495bSYour Name 	soc_cfg_ctx = soc->wlan_cfg_ctx;
3929*5113495bSYour Name 
3930*5113495bSYour Name 	dp_enable_verbose_debug(soc);
3931*5113495bSYour Name 
3932*5113495bSYour Name 	/* WBM descriptor release ring */
3933*5113495bSYour Name 	if (dp_srng_init(soc, &soc->wbm_desc_rel_ring, SW2WBM_RELEASE, 0, 0)) {
3934*5113495bSYour Name 		dp_init_err("%pK: dp_srng_init failed for wbm_desc_rel_ring", soc);
3935*5113495bSYour Name 		goto fail1;
3936*5113495bSYour Name 	}
3937*5113495bSYour Name 	dp_ssr_dump_srng_register("wbm_desc_rel_ring",
3938*5113495bSYour Name 				  &soc->wbm_desc_rel_ring, -1);
3939*5113495bSYour Name 
3940*5113495bSYour Name 	wlan_minidump_log(soc->wbm_desc_rel_ring.base_vaddr_unaligned,
3941*5113495bSYour Name 			  soc->wbm_desc_rel_ring.alloc_size,
3942*5113495bSYour Name 			  soc->ctrl_psoc,
3943*5113495bSYour Name 			  WLAN_MD_DP_SRNG_WBM_DESC_REL,
3944*5113495bSYour Name 			  "wbm_desc_rel_ring");
3945*5113495bSYour Name 
3946*5113495bSYour Name 	/* TCL command and status rings */
3947*5113495bSYour Name 	if (dp_soc_tcl_cmd_cred_srng_init(soc)) {
3948*5113495bSYour Name 		dp_init_err("%pK: dp_srng_init failed for tcl_cmd_ring", soc);
3949*5113495bSYour Name 		goto fail1;
3950*5113495bSYour Name 	}
3951*5113495bSYour Name 
3952*5113495bSYour Name 	if (dp_soc_tcl_status_srng_init(soc)) {
3953*5113495bSYour Name 		dp_init_err("%pK: dp_srng_init failed for tcl_status_ring", soc);
3954*5113495bSYour Name 		goto fail1;
3955*5113495bSYour Name 	}
3956*5113495bSYour Name 
3957*5113495bSYour Name 	/* REO reinjection ring */
3958*5113495bSYour Name 	if (dp_srng_init(soc, &soc->reo_reinject_ring, REO_REINJECT, 0, 0)) {
3959*5113495bSYour Name 		dp_init_err("%pK: dp_srng_init failed for reo_reinject_ring", soc);
3960*5113495bSYour Name 		goto fail1;
3961*5113495bSYour Name 	}
3962*5113495bSYour Name 	dp_ssr_dump_srng_register("reo_reinject_ring",
3963*5113495bSYour Name 				  &soc->reo_reinject_ring, -1);
3964*5113495bSYour Name 
3965*5113495bSYour Name 	wlan_minidump_log(soc->reo_reinject_ring.base_vaddr_unaligned,
3966*5113495bSYour Name 			  soc->reo_reinject_ring.alloc_size,
3967*5113495bSYour Name 			  soc->ctrl_psoc,
3968*5113495bSYour Name 			  WLAN_MD_DP_SRNG_REO_REINJECT,
3969*5113495bSYour Name 			  "reo_reinject_ring");
3970*5113495bSYour Name 
3971*5113495bSYour Name 	wbm2_sw_rx_rel_ring_id = wlan_cfg_get_rx_rel_ring_id(soc_cfg_ctx);
3972*5113495bSYour Name 	/* Rx release ring */
3973*5113495bSYour Name 	if (dp_srng_init(soc, &soc->rx_rel_ring, WBM2SW_RELEASE,
3974*5113495bSYour Name 			 wbm2_sw_rx_rel_ring_id, 0)) {
3975*5113495bSYour Name 		dp_init_err("%pK: dp_srng_init failed for rx_rel_ring", soc);
3976*5113495bSYour Name 		goto fail1;
3977*5113495bSYour Name 	}
3978*5113495bSYour Name 	dp_ssr_dump_srng_register("rx_rel_ring", &soc->rx_rel_ring, -1);
3979*5113495bSYour Name 
3980*5113495bSYour Name 	wlan_minidump_log(soc->rx_rel_ring.base_vaddr_unaligned,
3981*5113495bSYour Name 			  soc->rx_rel_ring.alloc_size,
3982*5113495bSYour Name 			  soc->ctrl_psoc,
3983*5113495bSYour Name 			  WLAN_MD_DP_SRNG_RX_REL,
3984*5113495bSYour Name 			  "reo_release_ring");
3985*5113495bSYour Name 
3986*5113495bSYour Name 	/* Rx exception ring */
3987*5113495bSYour Name 	if (dp_srng_init(soc, &soc->reo_exception_ring,
3988*5113495bSYour Name 			 REO_EXCEPTION, 0, MAX_REO_DEST_RINGS)) {
3989*5113495bSYour Name 		dp_init_err("%pK: dp_srng_init failed - reo_exception", soc);
3990*5113495bSYour Name 		goto fail1;
3991*5113495bSYour Name 	}
3992*5113495bSYour Name 	dp_ssr_dump_srng_register("reo_exception_ring",
3993*5113495bSYour Name 				  &soc->reo_exception_ring, -1);
3994*5113495bSYour Name 
3995*5113495bSYour Name 	wlan_minidump_log(soc->reo_exception_ring.base_vaddr_unaligned,
3996*5113495bSYour Name 			  soc->reo_exception_ring.alloc_size,
3997*5113495bSYour Name 			  soc->ctrl_psoc,
3998*5113495bSYour Name 			  WLAN_MD_DP_SRNG_REO_EXCEPTION,
3999*5113495bSYour Name 			  "reo_exception_ring");
4000*5113495bSYour Name 
4001*5113495bSYour Name 	/* REO command and status rings */
4002*5113495bSYour Name 	if (dp_srng_init(soc, &soc->reo_cmd_ring, REO_CMD, 0, 0)) {
4003*5113495bSYour Name 		dp_init_err("%pK: dp_srng_init failed for reo_cmd_ring", soc);
4004*5113495bSYour Name 		goto fail1;
4005*5113495bSYour Name 	}
4006*5113495bSYour Name 	dp_ssr_dump_srng_register("reo_cmd_ring", &soc->reo_cmd_ring, -1);
4007*5113495bSYour Name 
4008*5113495bSYour Name 	wlan_minidump_log(soc->reo_cmd_ring.base_vaddr_unaligned,
4009*5113495bSYour Name 			  soc->reo_cmd_ring.alloc_size,
4010*5113495bSYour Name 			  soc->ctrl_psoc,
4011*5113495bSYour Name 			  WLAN_MD_DP_SRNG_REO_CMD,
4012*5113495bSYour Name 			  "reo_cmd_ring");
4013*5113495bSYour Name 
4014*5113495bSYour Name 	hal_reo_init_cmd_ring(soc->hal_soc, soc->reo_cmd_ring.hal_srng);
4015*5113495bSYour Name 	TAILQ_INIT(&soc->rx.reo_cmd_list);
4016*5113495bSYour Name 	qdf_spinlock_create(&soc->rx.reo_cmd_lock);
4017*5113495bSYour Name 
4018*5113495bSYour Name 	if (dp_srng_init(soc, &soc->reo_status_ring, REO_STATUS, 0, 0)) {
4019*5113495bSYour Name 		dp_init_err("%pK: dp_srng_init failed for reo_status_ring", soc);
4020*5113495bSYour Name 		goto fail1;
4021*5113495bSYour Name 	}
4022*5113495bSYour Name 	dp_ssr_dump_srng_register("reo_status_ring", &soc->reo_status_ring, -1);
4023*5113495bSYour Name 
4024*5113495bSYour Name 	wlan_minidump_log(soc->reo_status_ring.base_vaddr_unaligned,
4025*5113495bSYour Name 			  soc->reo_status_ring.alloc_size,
4026*5113495bSYour Name 			  soc->ctrl_psoc,
4027*5113495bSYour Name 			  WLAN_MD_DP_SRNG_REO_STATUS,
4028*5113495bSYour Name 			  "reo_status_ring");
4029*5113495bSYour Name 
4030*5113495bSYour Name 	for (i = 0; i < soc->num_tcl_data_rings; i++) {
4031*5113495bSYour Name 		if (dp_init_tx_ring_pair_by_index(soc, i))
4032*5113495bSYour Name 			goto fail1;
4033*5113495bSYour Name 	}
4034*5113495bSYour Name 
4035*5113495bSYour Name 	if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) {
4036*5113495bSYour Name 		if (dp_init_tx_ring_pair_by_index(soc, IPA_TCL_DATA_RING_IDX))
4037*5113495bSYour Name 			goto fail1;
4038*5113495bSYour Name 
4039*5113495bSYour Name 		if (dp_ipa_init_alt_tx_ring(soc))
4040*5113495bSYour Name 			goto fail1;
4041*5113495bSYour Name 	}
4042*5113495bSYour Name 
4043*5113495bSYour Name 	dp_create_ext_stats_event(soc);
4044*5113495bSYour Name 
4045*5113495bSYour Name 	for (i = 0; i < soc->num_reo_dest_rings; i++) {
4046*5113495bSYour Name 		/* Initialize REO destination ring */
4047*5113495bSYour Name 		if (dp_srng_init(soc, &soc->reo_dest_ring[i], REO_DST, i, 0)) {
4048*5113495bSYour Name 			dp_init_err("%pK: dp_srng_init failed for reo_dest_ringn", soc);
4049*5113495bSYour Name 			goto fail1;
4050*5113495bSYour Name 		}
4051*5113495bSYour Name 
4052*5113495bSYour Name 		dp_ssr_dump_srng_register("reo_dest_ring",
4053*5113495bSYour Name 					  &soc->reo_dest_ring[i], i);
4054*5113495bSYour Name 		wlan_minidump_log(soc->reo_dest_ring[i].base_vaddr_unaligned,
4055*5113495bSYour Name 				  soc->reo_dest_ring[i].alloc_size,
4056*5113495bSYour Name 				  soc->ctrl_psoc,
4057*5113495bSYour Name 				  WLAN_MD_DP_SRNG_REO_DEST,
4058*5113495bSYour Name 				  "reo_dest_ring");
4059*5113495bSYour Name 	}
4060*5113495bSYour Name 
4061*5113495bSYour Name 	if (soc->arch_ops.txrx_soc_srng_init) {
4062*5113495bSYour Name 		if (soc->arch_ops.txrx_soc_srng_init(soc)) {
4063*5113495bSYour Name 			dp_init_err("%pK: dp_srng_init failed for arch rings",
4064*5113495bSYour Name 				    soc);
4065*5113495bSYour Name 			goto fail1;
4066*5113495bSYour Name 		}
4067*5113495bSYour Name 	}
4068*5113495bSYour Name 
4069*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
4070*5113495bSYour Name fail1:
4071*5113495bSYour Name 	/*
4072*5113495bSYour Name 	 * Cleanup will be done as part of soc_detach, which will
4073*5113495bSYour Name 	 * be called on pdev attach failure
4074*5113495bSYour Name 	 */
4075*5113495bSYour Name 	dp_soc_srng_deinit(soc);
4076*5113495bSYour Name 	return QDF_STATUS_E_FAILURE;
4077*5113495bSYour Name }
4078*5113495bSYour Name 
4079*5113495bSYour Name /**
4080*5113495bSYour Name  * dp_soc_srng_free() - free soc level srng rings
4081*5113495bSYour Name  * @soc: Datapath soc handle
4082*5113495bSYour Name  *
4083*5113495bSYour Name  */
dp_soc_srng_free(struct dp_soc * soc)4084*5113495bSYour Name void dp_soc_srng_free(struct dp_soc *soc)
4085*5113495bSYour Name {
4086*5113495bSYour Name 	uint32_t i;
4087*5113495bSYour Name 
4088*5113495bSYour Name 	if (soc->arch_ops.txrx_soc_srng_free)
4089*5113495bSYour Name 		soc->arch_ops.txrx_soc_srng_free(soc);
4090*5113495bSYour Name 
4091*5113495bSYour Name 	dp_srng_free(soc, &soc->wbm_desc_rel_ring);
4092*5113495bSYour Name 
4093*5113495bSYour Name 	for (i = 0; i < soc->num_tcl_data_rings; i++)
4094*5113495bSYour Name 		dp_free_tx_ring_pair_by_index(soc, i);
4095*5113495bSYour Name 
4096*5113495bSYour Name 	/* Free IPA rings for TCL_TX and TCL_COMPL ring */
4097*5113495bSYour Name 	if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) {
4098*5113495bSYour Name 		dp_free_tx_ring_pair_by_index(soc, IPA_TCL_DATA_RING_IDX);
4099*5113495bSYour Name 		dp_ipa_free_alt_tx_ring(soc);
4100*5113495bSYour Name 	}
4101*5113495bSYour Name 
4102*5113495bSYour Name 	dp_soc_tcl_cmd_cred_srng_free(soc);
4103*5113495bSYour Name 	dp_soc_tcl_status_srng_free(soc);
4104*5113495bSYour Name 
4105*5113495bSYour Name 	for (i = 0; i < soc->num_reo_dest_rings; i++)
4106*5113495bSYour Name 		dp_srng_free(soc, &soc->reo_dest_ring[i]);
4107*5113495bSYour Name 
4108*5113495bSYour Name 	dp_srng_free(soc, &soc->reo_reinject_ring);
4109*5113495bSYour Name 	dp_srng_free(soc, &soc->rx_rel_ring);
4110*5113495bSYour Name 
4111*5113495bSYour Name 	dp_srng_free(soc, &soc->reo_exception_ring);
4112*5113495bSYour Name 
4113*5113495bSYour Name 	dp_srng_free(soc, &soc->reo_cmd_ring);
4114*5113495bSYour Name 	dp_srng_free(soc, &soc->reo_status_ring);
4115*5113495bSYour Name }
4116*5113495bSYour Name 
4117*5113495bSYour Name /**
4118*5113495bSYour Name  * dp_soc_srng_alloc() - Allocate memory for soc level srng rings
4119*5113495bSYour Name  * @soc: Datapath soc handle
4120*5113495bSYour Name  *
4121*5113495bSYour Name  * Return: QDF_STATUS_SUCCESS on success
4122*5113495bSYour Name  *	   QDF_STATUS_E_NOMEM on failure
4123*5113495bSYour Name  */
dp_soc_srng_alloc(struct dp_soc * soc)4124*5113495bSYour Name QDF_STATUS dp_soc_srng_alloc(struct dp_soc *soc)
4125*5113495bSYour Name {
4126*5113495bSYour Name 	uint32_t entries;
4127*5113495bSYour Name 	uint32_t i;
4128*5113495bSYour Name 	struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
4129*5113495bSYour Name 	uint32_t cached = WLAN_CFG_DST_RING_CACHED_DESC;
4130*5113495bSYour Name 	uint32_t reo_dst_ring_size;
4131*5113495bSYour Name 
4132*5113495bSYour Name 	soc_cfg_ctx = soc->wlan_cfg_ctx;
4133*5113495bSYour Name 
4134*5113495bSYour Name 	/* sw2wbm link descriptor release ring */
4135*5113495bSYour Name 	entries = wlan_cfg_get_dp_soc_wbm_release_ring_size(soc_cfg_ctx);
4136*5113495bSYour Name 	if (dp_srng_alloc(soc, &soc->wbm_desc_rel_ring, SW2WBM_RELEASE,
4137*5113495bSYour Name 			  entries, 0)) {
4138*5113495bSYour Name 		dp_init_err("%pK: dp_srng_alloc failed for wbm_desc_rel_ring", soc);
4139*5113495bSYour Name 		goto fail1;
4140*5113495bSYour Name 	}
4141*5113495bSYour Name 
4142*5113495bSYour Name 	/* TCL command and status rings */
4143*5113495bSYour Name 	if (dp_soc_tcl_cmd_cred_srng_alloc(soc)) {
4144*5113495bSYour Name 		dp_init_err("%pK: dp_srng_alloc failed for tcl_cmd_ring", soc);
4145*5113495bSYour Name 		goto fail1;
4146*5113495bSYour Name 	}
4147*5113495bSYour Name 
4148*5113495bSYour Name 	if (dp_soc_tcl_status_srng_alloc(soc)) {
4149*5113495bSYour Name 		dp_init_err("%pK: dp_srng_alloc failed for tcl_status_ring", soc);
4150*5113495bSYour Name 		goto fail1;
4151*5113495bSYour Name 	}
4152*5113495bSYour Name 
4153*5113495bSYour Name 	/* REO reinjection ring */
4154*5113495bSYour Name 	entries = wlan_cfg_get_dp_soc_reo_reinject_ring_size(soc_cfg_ctx);
4155*5113495bSYour Name 	if (dp_srng_alloc(soc, &soc->reo_reinject_ring, REO_REINJECT,
4156*5113495bSYour Name 			  entries, 0)) {
4157*5113495bSYour Name 		dp_init_err("%pK: dp_srng_alloc failed for reo_reinject_ring", soc);
4158*5113495bSYour Name 		goto fail1;
4159*5113495bSYour Name 	}
4160*5113495bSYour Name 
4161*5113495bSYour Name 	/* Rx release ring */
4162*5113495bSYour Name 	entries = wlan_cfg_get_dp_soc_rx_release_ring_size(soc_cfg_ctx);
4163*5113495bSYour Name 	if (dp_srng_alloc(soc, &soc->rx_rel_ring, WBM2SW_RELEASE,
4164*5113495bSYour Name 			  entries, 0)) {
4165*5113495bSYour Name 		dp_init_err("%pK: dp_srng_alloc failed for rx_rel_ring", soc);
4166*5113495bSYour Name 		goto fail1;
4167*5113495bSYour Name 	}
4168*5113495bSYour Name 
4169*5113495bSYour Name 	/* Rx exception ring */
4170*5113495bSYour Name 	entries = wlan_cfg_get_dp_soc_reo_exception_ring_size(soc_cfg_ctx);
4171*5113495bSYour Name 	if (dp_srng_alloc(soc, &soc->reo_exception_ring, REO_EXCEPTION,
4172*5113495bSYour Name 			  entries, 0)) {
4173*5113495bSYour Name 		dp_init_err("%pK: dp_srng_alloc failed - reo_exception", soc);
4174*5113495bSYour Name 		goto fail1;
4175*5113495bSYour Name 	}
4176*5113495bSYour Name 
4177*5113495bSYour Name 	/* REO command and status rings */
4178*5113495bSYour Name 	entries = wlan_cfg_get_dp_soc_reo_cmd_ring_size(soc_cfg_ctx);
4179*5113495bSYour Name 	if (dp_srng_alloc(soc, &soc->reo_cmd_ring, REO_CMD, entries, 0)) {
4180*5113495bSYour Name 		dp_init_err("%pK: dp_srng_alloc failed for reo_cmd_ring", soc);
4181*5113495bSYour Name 		goto fail1;
4182*5113495bSYour Name 	}
4183*5113495bSYour Name 
4184*5113495bSYour Name 	entries = wlan_cfg_get_dp_soc_reo_status_ring_size(soc_cfg_ctx);
4185*5113495bSYour Name 	if (dp_srng_alloc(soc, &soc->reo_status_ring, REO_STATUS,
4186*5113495bSYour Name 			  entries, 0)) {
4187*5113495bSYour Name 		dp_init_err("%pK: dp_srng_alloc failed for reo_status_ring", soc);
4188*5113495bSYour Name 		goto fail1;
4189*5113495bSYour Name 	}
4190*5113495bSYour Name 
4191*5113495bSYour Name 	reo_dst_ring_size = wlan_cfg_get_reo_dst_ring_size(soc_cfg_ctx);
4192*5113495bSYour Name 
4193*5113495bSYour Name 	/* Disable cached desc if NSS offload is enabled */
4194*5113495bSYour Name 	if (wlan_cfg_get_dp_soc_nss_cfg(soc_cfg_ctx))
4195*5113495bSYour Name 		cached = 0;
4196*5113495bSYour Name 
4197*5113495bSYour Name 	for (i = 0; i < soc->num_tcl_data_rings; i++) {
4198*5113495bSYour Name 		if (dp_alloc_tx_ring_pair_by_index(soc, i))
4199*5113495bSYour Name 			goto fail1;
4200*5113495bSYour Name 	}
4201*5113495bSYour Name 
4202*5113495bSYour Name 	/* IPA rings for TCL_TX and TX_COMP will be allocated here */
4203*5113495bSYour Name 	if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) {
4204*5113495bSYour Name 		if (dp_alloc_tx_ring_pair_by_index(soc, IPA_TCL_DATA_RING_IDX))
4205*5113495bSYour Name 			goto fail1;
4206*5113495bSYour Name 
4207*5113495bSYour Name 		if (dp_ipa_alloc_alt_tx_ring(soc))
4208*5113495bSYour Name 			goto fail1;
4209*5113495bSYour Name 	}
4210*5113495bSYour Name 
4211*5113495bSYour Name 	for (i = 0; i < soc->num_reo_dest_rings; i++) {
4212*5113495bSYour Name 		/* Setup REO destination ring */
4213*5113495bSYour Name 		if (dp_srng_alloc(soc, &soc->reo_dest_ring[i], REO_DST,
4214*5113495bSYour Name 				  reo_dst_ring_size, cached)) {
4215*5113495bSYour Name 			dp_init_err("%pK: dp_srng_alloc failed for reo_dest_ring", soc);
4216*5113495bSYour Name 			goto fail1;
4217*5113495bSYour Name 		}
4218*5113495bSYour Name 	}
4219*5113495bSYour Name 
4220*5113495bSYour Name 	if (soc->arch_ops.txrx_soc_srng_alloc) {
4221*5113495bSYour Name 		if (soc->arch_ops.txrx_soc_srng_alloc(soc)) {
4222*5113495bSYour Name 			dp_init_err("%pK: dp_srng_alloc failed for arch rings",
4223*5113495bSYour Name 				    soc);
4224*5113495bSYour Name 			goto fail1;
4225*5113495bSYour Name 		}
4226*5113495bSYour Name 	}
4227*5113495bSYour Name 
4228*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
4229*5113495bSYour Name 
4230*5113495bSYour Name fail1:
4231*5113495bSYour Name 	dp_soc_srng_free(soc);
4232*5113495bSYour Name 	return QDF_STATUS_E_NOMEM;
4233*5113495bSYour Name }
4234*5113495bSYour Name 
4235*5113495bSYour Name /**
4236*5113495bSYour Name  * dp_soc_cfg_attach() - set target specific configuration in
4237*5113495bSYour Name  *			 dp soc cfg.
4238*5113495bSYour Name  * @soc: dp soc handle
4239*5113495bSYour Name  */
dp_soc_cfg_attach(struct dp_soc * soc)4240*5113495bSYour Name void dp_soc_cfg_attach(struct dp_soc *soc)
4241*5113495bSYour Name {
4242*5113495bSYour Name 	int target_type;
4243*5113495bSYour Name 	int nss_cfg = 0;
4244*5113495bSYour Name 
4245*5113495bSYour Name 	target_type = hal_get_target_type(soc->hal_soc);
4246*5113495bSYour Name 	switch (target_type) {
4247*5113495bSYour Name 	case TARGET_TYPE_QCA6290:
4248*5113495bSYour Name 		wlan_cfg_set_reo_dst_ring_size(soc->wlan_cfg_ctx,
4249*5113495bSYour Name 					       REO_DST_RING_SIZE_QCA6290);
4250*5113495bSYour Name 		break;
4251*5113495bSYour Name 	case TARGET_TYPE_QCA6390:
4252*5113495bSYour Name 	case TARGET_TYPE_QCA6490:
4253*5113495bSYour Name 	case TARGET_TYPE_QCA6750:
4254*5113495bSYour Name 		wlan_cfg_set_reo_dst_ring_size(soc->wlan_cfg_ctx,
4255*5113495bSYour Name 					       REO_DST_RING_SIZE_QCA6290);
4256*5113495bSYour Name 		soc->wlan_cfg_ctx->rxdma1_enable = 0;
4257*5113495bSYour Name 		break;
4258*5113495bSYour Name 	case TARGET_TYPE_KIWI:
4259*5113495bSYour Name 	case TARGET_TYPE_MANGO:
4260*5113495bSYour Name 	case TARGET_TYPE_PEACH:
4261*5113495bSYour Name 		soc->wlan_cfg_ctx->rxdma1_enable = 0;
4262*5113495bSYour Name 		break;
4263*5113495bSYour Name 	case TARGET_TYPE_QCA8074:
4264*5113495bSYour Name 		wlan_cfg_set_tso_desc_attach_defer(soc->wlan_cfg_ctx, 1);
4265*5113495bSYour Name 		break;
4266*5113495bSYour Name 	case TARGET_TYPE_QCA8074V2:
4267*5113495bSYour Name 	case TARGET_TYPE_QCA6018:
4268*5113495bSYour Name 	case TARGET_TYPE_QCA9574:
4269*5113495bSYour Name 	case TARGET_TYPE_QCN6122:
4270*5113495bSYour Name 	case TARGET_TYPE_QCA5018:
4271*5113495bSYour Name 		wlan_cfg_set_tso_desc_attach_defer(soc->wlan_cfg_ctx, 1);
4272*5113495bSYour Name 		wlan_cfg_set_rxdma1_enable(soc->wlan_cfg_ctx);
4273*5113495bSYour Name 		break;
4274*5113495bSYour Name 	case TARGET_TYPE_QCN9160:
4275*5113495bSYour Name 		wlan_cfg_set_tso_desc_attach_defer(soc->wlan_cfg_ctx, 1);
4276*5113495bSYour Name 		soc->wlan_cfg_ctx->rxdma1_enable = 0;
4277*5113495bSYour Name 		break;
4278*5113495bSYour Name 	case TARGET_TYPE_QCN9000:
4279*5113495bSYour Name 		wlan_cfg_set_tso_desc_attach_defer(soc->wlan_cfg_ctx, 1);
4280*5113495bSYour Name 		wlan_cfg_set_rxdma1_enable(soc->wlan_cfg_ctx);
4281*5113495bSYour Name 		break;
4282*5113495bSYour Name 	case TARGET_TYPE_QCN9224:
4283*5113495bSYour Name 	case TARGET_TYPE_QCA5332:
4284*5113495bSYour Name 	case TARGET_TYPE_QCN6432:
4285*5113495bSYour Name 		wlan_cfg_set_tso_desc_attach_defer(soc->wlan_cfg_ctx, 1);
4286*5113495bSYour Name 		wlan_cfg_set_rxdma1_enable(soc->wlan_cfg_ctx);
4287*5113495bSYour Name 		break;
4288*5113495bSYour Name 	default:
4289*5113495bSYour Name 		qdf_print("%s: Unknown tgt type %d\n", __func__, target_type);
4290*5113495bSYour Name 		qdf_assert_always(0);
4291*5113495bSYour Name 		break;
4292*5113495bSYour Name 	}
4293*5113495bSYour Name 
4294*5113495bSYour Name 	if (soc->cdp_soc.ol_ops->get_soc_nss_cfg)
4295*5113495bSYour Name 		nss_cfg = soc->cdp_soc.ol_ops->get_soc_nss_cfg(soc->ctrl_psoc);
4296*5113495bSYour Name 
4297*5113495bSYour Name 	wlan_cfg_set_dp_soc_nss_cfg(soc->wlan_cfg_ctx, nss_cfg);
4298*5113495bSYour Name 
4299*5113495bSYour Name 	if (wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx)) {
4300*5113495bSYour Name 		wlan_cfg_set_num_tx_desc_pool(soc->wlan_cfg_ctx, 0);
4301*5113495bSYour Name 		wlan_cfg_set_num_tx_ext_desc_pool(soc->wlan_cfg_ctx, 0);
4302*5113495bSYour Name 		wlan_cfg_set_num_tx_desc(soc->wlan_cfg_ctx, 0);
4303*5113495bSYour Name 		wlan_cfg_set_num_tx_spl_desc(soc->wlan_cfg_ctx, 0);
4304*5113495bSYour Name 		wlan_cfg_set_num_tx_ext_desc(soc->wlan_cfg_ctx, 0);
4305*5113495bSYour Name 		soc->init_tcl_cmd_cred_ring = false;
4306*5113495bSYour Name 		soc->num_tcl_data_rings =
4307*5113495bSYour Name 			wlan_cfg_num_nss_tcl_data_rings(soc->wlan_cfg_ctx);
4308*5113495bSYour Name 		soc->num_reo_dest_rings =
4309*5113495bSYour Name 			wlan_cfg_num_nss_reo_dest_rings(soc->wlan_cfg_ctx);
4310*5113495bSYour Name 
4311*5113495bSYour Name 	} else {
4312*5113495bSYour Name 		soc->init_tcl_cmd_cred_ring = true;
4313*5113495bSYour Name 		soc->num_tx_comp_rings =
4314*5113495bSYour Name 			wlan_cfg_num_tx_comp_rings(soc->wlan_cfg_ctx);
4315*5113495bSYour Name 		soc->num_tcl_data_rings =
4316*5113495bSYour Name 			wlan_cfg_num_tcl_data_rings(soc->wlan_cfg_ctx);
4317*5113495bSYour Name 		soc->num_reo_dest_rings =
4318*5113495bSYour Name 			wlan_cfg_num_reo_dest_rings(soc->wlan_cfg_ctx);
4319*5113495bSYour Name 	}
4320*5113495bSYour Name 
4321*5113495bSYour Name }
4322*5113495bSYour Name 
dp_pdev_set_default_reo(struct dp_pdev * pdev)4323*5113495bSYour Name void dp_pdev_set_default_reo(struct dp_pdev *pdev)
4324*5113495bSYour Name {
4325*5113495bSYour Name 	struct dp_soc *soc = pdev->soc;
4326*5113495bSYour Name 
4327*5113495bSYour Name 	switch (pdev->pdev_id) {
4328*5113495bSYour Name 	case 0:
4329*5113495bSYour Name 		pdev->reo_dest =
4330*5113495bSYour Name 			wlan_cfg_radio0_default_reo_get(soc->wlan_cfg_ctx);
4331*5113495bSYour Name 		break;
4332*5113495bSYour Name 
4333*5113495bSYour Name 	case 1:
4334*5113495bSYour Name 		pdev->reo_dest =
4335*5113495bSYour Name 			wlan_cfg_radio1_default_reo_get(soc->wlan_cfg_ctx);
4336*5113495bSYour Name 		break;
4337*5113495bSYour Name 
4338*5113495bSYour Name 	case 2:
4339*5113495bSYour Name 		pdev->reo_dest =
4340*5113495bSYour Name 			wlan_cfg_radio2_default_reo_get(soc->wlan_cfg_ctx);
4341*5113495bSYour Name 		break;
4342*5113495bSYour Name 
4343*5113495bSYour Name 	default:
4344*5113495bSYour Name 		dp_init_err("%pK: Invalid pdev_id %d for reo selection",
4345*5113495bSYour Name 			    soc, pdev->pdev_id);
4346*5113495bSYour Name 		break;
4347*5113495bSYour Name 	}
4348*5113495bSYour Name }
4349*5113495bSYour Name 
4350*5113495bSYour Name #ifdef WLAN_SUPPORT_DPDK
dp_soc_reset_dpdk_intr_mask(struct dp_soc * soc)4351*5113495bSYour Name void dp_soc_reset_dpdk_intr_mask(struct dp_soc *soc)
4352*5113495bSYour Name {
4353*5113495bSYour Name 	uint8_t j;
4354*5113495bSYour Name 	uint8_t *grp_mask = NULL;
4355*5113495bSYour Name 	int group_number, mask, num_ring;
4356*5113495bSYour Name 
4357*5113495bSYour Name 	/* number of tx ring */
4358*5113495bSYour Name 	num_ring = soc->num_tcl_data_rings;
4359*5113495bSYour Name 
4360*5113495bSYour Name 	/*
4361*5113495bSYour Name 	 * group mask for tx completion  ring.
4362*5113495bSYour Name 	 */
4363*5113495bSYour Name 	grp_mask =  &soc->wlan_cfg_ctx->int_tx_ring_mask[0];
4364*5113495bSYour Name 
4365*5113495bSYour Name 	for (j = 0; j < WLAN_CFG_NUM_TCL_DATA_RINGS; j++) {
4366*5113495bSYour Name 		/*
4367*5113495bSYour Name 		 * Group number corresponding to tx offloaded ring.
4368*5113495bSYour Name 		 */
4369*5113495bSYour Name 		group_number = dp_srng_find_ring_in_mask(j, grp_mask);
4370*5113495bSYour Name 		if (group_number < 0) {
4371*5113495bSYour Name 			dp_init_debug("%pK: ring not part of any group; ring_type: %d, ring_num %d",
4372*5113495bSYour Name 				      soc, WBM2SW_RELEASE, j);
4373*5113495bSYour Name 			continue;
4374*5113495bSYour Name 		}
4375*5113495bSYour Name 
4376*5113495bSYour Name 		mask = wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx,
4377*5113495bSYour Name 						 group_number);
4378*5113495bSYour Name 
4379*5113495bSYour Name 		/* reset the tx mask for offloaded ring */
4380*5113495bSYour Name 		mask &= (~(1 << j));
4381*5113495bSYour Name 
4382*5113495bSYour Name 		/*
4383*5113495bSYour Name 		 * reset the interrupt mask for offloaded ring.
4384*5113495bSYour Name 		 */
4385*5113495bSYour Name 		wlan_cfg_set_tx_ring_mask(soc->wlan_cfg_ctx,
4386*5113495bSYour Name 					  group_number, mask);
4387*5113495bSYour Name 	}
4388*5113495bSYour Name 
4389*5113495bSYour Name 	/* number of rx rings */
4390*5113495bSYour Name 	num_ring = soc->num_reo_dest_rings;
4391*5113495bSYour Name 
4392*5113495bSYour Name 	/*
4393*5113495bSYour Name 	 * group mask for reo destination ring.
4394*5113495bSYour Name 	 */
4395*5113495bSYour Name 	grp_mask = &soc->wlan_cfg_ctx->int_rx_ring_mask[0];
4396*5113495bSYour Name 
4397*5113495bSYour Name 	for (j = 0; j < WLAN_CFG_NUM_REO_DEST_RING; j++) {
4398*5113495bSYour Name 		/*
4399*5113495bSYour Name 		 * Group number corresponding to rx offloaded ring.
4400*5113495bSYour Name 		 */
4401*5113495bSYour Name 		group_number = dp_srng_find_ring_in_mask(j, grp_mask);
4402*5113495bSYour Name 		if (group_number < 0) {
4403*5113495bSYour Name 			dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d",
4404*5113495bSYour Name 				      soc, REO_DST, j);
4405*5113495bSYour Name 			continue;
4406*5113495bSYour Name 		}
4407*5113495bSYour Name 
4408*5113495bSYour Name 		mask =  wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx,
4409*5113495bSYour Name 						  group_number);
4410*5113495bSYour Name 
4411*5113495bSYour Name 		/* reset the interrupt mask for offloaded ring */
4412*5113495bSYour Name 		mask &= (~(1 << j));
4413*5113495bSYour Name 
4414*5113495bSYour Name 		/*
4415*5113495bSYour Name 		 * set the interrupt mask to zero for rx offloaded radio.
4416*5113495bSYour Name 		 */
4417*5113495bSYour Name 		wlan_cfg_set_rx_ring_mask(soc->wlan_cfg_ctx,
4418*5113495bSYour Name 					  group_number, mask);
4419*5113495bSYour Name 	}
4420*5113495bSYour Name 
4421*5113495bSYour Name 	/*
4422*5113495bSYour Name 	 * group mask for Rx buffer refill ring
4423*5113495bSYour Name 	 */
4424*5113495bSYour Name 	grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_ring_mask[0];
4425*5113495bSYour Name 
4426*5113495bSYour Name 	for (j = 0; j < MAX_PDEV_CNT; j++) {
4427*5113495bSYour Name 		int lmac_id = wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx, j);
4428*5113495bSYour Name 
4429*5113495bSYour Name 		/*
4430*5113495bSYour Name 		 * Group number corresponding to rx offloaded ring.
4431*5113495bSYour Name 		 */
4432*5113495bSYour Name 		group_number = dp_srng_find_ring_in_mask(lmac_id, grp_mask);
4433*5113495bSYour Name 		if (group_number < 0) {
4434*5113495bSYour Name 			dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d",
4435*5113495bSYour Name 				      soc, REO_DST, lmac_id);
4436*5113495bSYour Name 			continue;
4437*5113495bSYour Name 		}
4438*5113495bSYour Name 
4439*5113495bSYour Name 		/* set the interrupt mask for offloaded ring */
4440*5113495bSYour Name 		mask =  wlan_cfg_get_host2rxdma_ring_mask(soc->wlan_cfg_ctx,
4441*5113495bSYour Name 							  group_number);
4442*5113495bSYour Name 		mask &= (~(1 << lmac_id));
4443*5113495bSYour Name 
4444*5113495bSYour Name 		/*
4445*5113495bSYour Name 		 * set the interrupt mask to zero for rx offloaded radio.
4446*5113495bSYour Name 		 */
4447*5113495bSYour Name 		wlan_cfg_set_host2rxdma_ring_mask(soc->wlan_cfg_ctx,
4448*5113495bSYour Name 						  group_number, mask);
4449*5113495bSYour Name 	}
4450*5113495bSYour Name 
4451*5113495bSYour Name 	grp_mask = &soc->wlan_cfg_ctx->int_rx_err_ring_mask[0];
4452*5113495bSYour Name 
4453*5113495bSYour Name 	for (j = 0; j < num_ring; j++) {
4454*5113495bSYour Name 		/*
4455*5113495bSYour Name 		 * Group number corresponding to rx err ring.
4456*5113495bSYour Name 		 */
4457*5113495bSYour Name 		group_number = dp_srng_find_ring_in_mask(j, grp_mask);
4458*5113495bSYour Name 		if (group_number < 0) {
4459*5113495bSYour Name 			dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d",
4460*5113495bSYour Name 				      soc, REO_EXCEPTION, j);
4461*5113495bSYour Name 			continue;
4462*5113495bSYour Name 		}
4463*5113495bSYour Name 
4464*5113495bSYour Name 		wlan_cfg_set_rx_err_ring_mask(soc->wlan_cfg_ctx,
4465*5113495bSYour Name 					      group_number, 0);
4466*5113495bSYour Name 	}
4467*5113495bSYour Name }
4468*5113495bSYour Name #endif
4469