xref: /wlan-driver/qca-wifi-host-cmn/dp/wifi3.0/rh/dp_rh.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
3*5113495bSYour Name  *
4*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
5*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
6*5113495bSYour Name  * above copyright notice and this permission notice appear in all
7*5113495bSYour Name  * copies.
8*5113495bSYour Name  *
9*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
17*5113495bSYour Name  */
18*5113495bSYour Name 
19*5113495bSYour Name #include "dp_types.h"
20*5113495bSYour Name #include <dp_internal.h>
21*5113495bSYour Name #include <dp_htt.h>
22*5113495bSYour Name #include "dp_rh.h"
23*5113495bSYour Name #include "dp_rh_tx.h"
24*5113495bSYour Name #include "dp_rh_htt.h"
25*5113495bSYour Name #include "dp_tx_desc.h"
26*5113495bSYour Name #include "dp_rh_rx.h"
27*5113495bSYour Name #include "dp_peer.h"
28*5113495bSYour Name #include <wlan_utility.h>
29*5113495bSYour Name #include <dp_rings.h>
30*5113495bSYour Name #include <ce_api.h>
31*5113495bSYour Name #include <ce_internal.h>
32*5113495bSYour Name 
33*5113495bSYour Name static QDF_STATUS
dp_srng_init_rh(struct dp_soc * soc,struct dp_srng * srng,int ring_type,int ring_num,int mac_id)34*5113495bSYour Name dp_srng_init_rh(struct dp_soc *soc, struct dp_srng *srng, int ring_type,
35*5113495bSYour Name 		int ring_num, int mac_id)
36*5113495bSYour Name {
37*5113495bSYour Name 	hal_soc_handle_t hal_soc = soc->hal_soc;
38*5113495bSYour Name 	struct hal_srng_params ring_params;
39*5113495bSYour Name 
40*5113495bSYour Name 	if (srng->hal_srng) {
41*5113495bSYour Name 		dp_init_err("%pK: Ring type: %d, num:%d is already initialized",
42*5113495bSYour Name 			    soc, ring_type, ring_num);
43*5113495bSYour Name 		return QDF_STATUS_SUCCESS;
44*5113495bSYour Name 	}
45*5113495bSYour Name 
46*5113495bSYour Name 	/* memset the srng ring to zero */
47*5113495bSYour Name 	qdf_mem_zero(srng->base_vaddr_unaligned, srng->alloc_size);
48*5113495bSYour Name 
49*5113495bSYour Name 	qdf_mem_zero(&ring_params, sizeof(struct hal_srng_params));
50*5113495bSYour Name 	ring_params.ring_base_paddr = srng->base_paddr_aligned;
51*5113495bSYour Name 	ring_params.ring_base_vaddr = srng->base_vaddr_aligned;
52*5113495bSYour Name 
53*5113495bSYour Name 	ring_params.num_entries = srng->num_entries;
54*5113495bSYour Name 
55*5113495bSYour Name 	dp_info("Ring type: %d, num:%d vaddr %pK paddr %pK entries %u",
56*5113495bSYour Name 		ring_type, ring_num,
57*5113495bSYour Name 		(void *)ring_params.ring_base_vaddr,
58*5113495bSYour Name 		(void *)ring_params.ring_base_paddr,
59*5113495bSYour Name 		ring_params.num_entries);
60*5113495bSYour Name 
61*5113495bSYour Name 	if (soc->cdp_soc.ol_ops->get_con_mode &&
62*5113495bSYour Name 	    soc->cdp_soc.ol_ops->get_con_mode() ==
63*5113495bSYour Name 	    QDF_GLOBAL_MONITOR_MODE) {
64*5113495bSYour Name 		if (soc->intr_mode == DP_INTR_MSI &&
65*5113495bSYour Name 		    !dp_skip_msi_cfg(soc, ring_type)) {
66*5113495bSYour Name 			dp_srng_msi_setup(soc, srng, &ring_params,
67*5113495bSYour Name 					  ring_type, ring_num);
68*5113495bSYour Name 			dp_verbose_debug("Using MSI for ring_type: %d, ring_num %d",
69*5113495bSYour Name 					 ring_type, ring_num);
70*5113495bSYour Name 		} else {
71*5113495bSYour Name 			ring_params.msi_data = 0;
72*5113495bSYour Name 			ring_params.msi_addr = 0;
73*5113495bSYour Name 			dp_srng_set_msi2_ring_params(soc, &ring_params, 0, 0);
74*5113495bSYour Name 			dp_verbose_debug("Skipping MSI for ring_type: %d, ring_num %d",
75*5113495bSYour Name 					 ring_type, ring_num);
76*5113495bSYour Name 		}
77*5113495bSYour Name 
78*5113495bSYour Name 		dp_srng_configure_interrupt_thresholds(soc, &ring_params,
79*5113495bSYour Name 						       ring_type, ring_num,
80*5113495bSYour Name 						       srng->num_entries);
81*5113495bSYour Name 	}
82*5113495bSYour Name 
83*5113495bSYour Name 	srng->hal_srng = hal_srng_setup(hal_soc, ring_type, ring_num,
84*5113495bSYour Name 					mac_id, &ring_params, 0);
85*5113495bSYour Name 
86*5113495bSYour Name 	if (!srng->hal_srng) {
87*5113495bSYour Name 		dp_srng_free(soc, srng);
88*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
89*5113495bSYour Name 	}
90*5113495bSYour Name 
91*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
92*5113495bSYour Name }
93*5113495bSYour Name 
94*5113495bSYour Name static QDF_STATUS
dp_peer_setup_rh(struct cdp_soc_t * soc_hdl,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_peer_setup_info * setup_info)95*5113495bSYour Name dp_peer_setup_rh(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
96*5113495bSYour Name 		 uint8_t *peer_mac,
97*5113495bSYour Name 		 struct cdp_peer_setup_info *setup_info)
98*5113495bSYour Name {
99*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
100*5113495bSYour Name 	struct dp_pdev *pdev;
101*5113495bSYour Name 	QDF_STATUS status = QDF_STATUS_SUCCESS;
102*5113495bSYour Name 	struct dp_vdev *vdev = NULL;
103*5113495bSYour Name 	struct dp_peer *peer =
104*5113495bSYour Name 			dp_peer_find_hash_find(soc, peer_mac, 0, vdev_id,
105*5113495bSYour Name 					       DP_MOD_ID_CDP);
106*5113495bSYour Name 	enum wlan_op_mode vdev_opmode;
107*5113495bSYour Name 
108*5113495bSYour Name 	if (!peer)
109*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
110*5113495bSYour Name 
111*5113495bSYour Name 	vdev = peer->vdev;
112*5113495bSYour Name 	if (!vdev) {
113*5113495bSYour Name 		status = QDF_STATUS_E_FAILURE;
114*5113495bSYour Name 		goto fail;
115*5113495bSYour Name 	}
116*5113495bSYour Name 
117*5113495bSYour Name 	/* save vdev related member in case vdev freed */
118*5113495bSYour Name 	vdev_opmode = vdev->opmode;
119*5113495bSYour Name 	pdev = vdev->pdev;
120*5113495bSYour Name 
121*5113495bSYour Name 	dp_info("pdev: %d vdev :%d opmode:%u",
122*5113495bSYour Name 		pdev->pdev_id, vdev->vdev_id, vdev->opmode);
123*5113495bSYour Name 
124*5113495bSYour Name 	/*
125*5113495bSYour Name 	 * There are corner cases where the AD1 = AD2 = "VAPs address"
126*5113495bSYour Name 	 * i.e both the devices have same MAC address. In these
127*5113495bSYour Name 	 * cases we want such pkts to be processed in NULL Q handler
128*5113495bSYour Name 	 * which is REO2TCL ring. for this reason we should
129*5113495bSYour Name 	 * not setup reo_queues and default route for bss_peer.
130*5113495bSYour Name 	 */
131*5113495bSYour Name 	dp_monitor_peer_tx_init(pdev, peer);
132*5113495bSYour Name 
133*5113495bSYour Name 	if (!setup_info)
134*5113495bSYour Name 		if (dp_peer_legacy_setup(soc, peer) !=
135*5113495bSYour Name 				QDF_STATUS_SUCCESS) {
136*5113495bSYour Name 			status = QDF_STATUS_E_RESOURCES;
137*5113495bSYour Name 			goto fail;
138*5113495bSYour Name 		}
139*5113495bSYour Name 
140*5113495bSYour Name 	if (peer->bss_peer && vdev->opmode == wlan_op_mode_ap) {
141*5113495bSYour Name 		status = QDF_STATUS_E_FAILURE;
142*5113495bSYour Name 		goto fail;
143*5113495bSYour Name 	}
144*5113495bSYour Name 
145*5113495bSYour Name 	if (vdev_opmode != wlan_op_mode_monitor)
146*5113495bSYour Name 		dp_peer_rx_init(pdev, peer);
147*5113495bSYour Name 
148*5113495bSYour Name 	dp_peer_ppdu_delayed_ba_init(peer);
149*5113495bSYour Name 
150*5113495bSYour Name fail:
151*5113495bSYour Name 	dp_peer_unref_delete(peer, DP_MOD_ID_CDP);
152*5113495bSYour Name 	return status;
153*5113495bSYour Name }
154*5113495bSYour Name 
155*5113495bSYour Name #ifdef AST_OFFLOAD_ENABLE
dp_peer_map_detach_rh(struct dp_soc * soc)156*5113495bSYour Name static void dp_peer_map_detach_rh(struct dp_soc *soc)
157*5113495bSYour Name {
158*5113495bSYour Name 	dp_soc_wds_detach(soc);
159*5113495bSYour Name 	dp_peer_ast_table_detach(soc);
160*5113495bSYour Name 	dp_peer_ast_hash_detach(soc);
161*5113495bSYour Name 	dp_peer_mec_hash_detach(soc);
162*5113495bSYour Name }
163*5113495bSYour Name 
dp_peer_map_attach_rh(struct dp_soc * soc)164*5113495bSYour Name static QDF_STATUS dp_peer_map_attach_rh(struct dp_soc *soc)
165*5113495bSYour Name {
166*5113495bSYour Name 	QDF_STATUS status;
167*5113495bSYour Name 
168*5113495bSYour Name 	soc->max_peer_id = soc->max_peers;
169*5113495bSYour Name 
170*5113495bSYour Name 	status = dp_peer_ast_table_attach(soc);
171*5113495bSYour Name 	if (!QDF_IS_STATUS_SUCCESS(status))
172*5113495bSYour Name 		return status;
173*5113495bSYour Name 
174*5113495bSYour Name 	status = dp_peer_ast_hash_attach(soc);
175*5113495bSYour Name 	if (!QDF_IS_STATUS_SUCCESS(status))
176*5113495bSYour Name 		goto ast_table_detach;
177*5113495bSYour Name 
178*5113495bSYour Name 	status = dp_peer_mec_hash_attach(soc);
179*5113495bSYour Name 	if (!QDF_IS_STATUS_SUCCESS(status))
180*5113495bSYour Name 		goto hash_detach;
181*5113495bSYour Name 
182*5113495bSYour Name 	dp_soc_wds_attach(soc);
183*5113495bSYour Name 
184*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
185*5113495bSYour Name 
186*5113495bSYour Name hash_detach:
187*5113495bSYour Name 	dp_peer_ast_hash_detach(soc);
188*5113495bSYour Name ast_table_detach:
189*5113495bSYour Name 	dp_peer_ast_table_detach(soc);
190*5113495bSYour Name 
191*5113495bSYour Name 	return status;
192*5113495bSYour Name }
193*5113495bSYour Name #else
dp_peer_map_detach_rh(struct dp_soc * soc)194*5113495bSYour Name static void dp_peer_map_detach_rh(struct dp_soc *soc)
195*5113495bSYour Name {
196*5113495bSYour Name }
197*5113495bSYour Name 
dp_peer_map_attach_rh(struct dp_soc * soc)198*5113495bSYour Name static QDF_STATUS dp_peer_map_attach_rh(struct dp_soc *soc)
199*5113495bSYour Name {
200*5113495bSYour Name 	soc->max_peer_id = soc->max_peers;
201*5113495bSYour Name 
202*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
203*5113495bSYour Name }
204*5113495bSYour Name #endif
205*5113495bSYour Name 
206*5113495bSYour Name /**
207*5113495bSYour Name  * dp_soc_cfg_init_rh() - initialize target specific configuration
208*5113495bSYour Name  *		       during dp_soc_init
209*5113495bSYour Name  * @soc: dp soc handle
210*5113495bSYour Name  */
dp_soc_cfg_init_rh(struct dp_soc * soc)211*5113495bSYour Name static void dp_soc_cfg_init_rh(struct dp_soc *soc)
212*5113495bSYour Name {
213*5113495bSYour Name 	uint32_t target_type;
214*5113495bSYour Name 
215*5113495bSYour Name 	target_type = hal_get_target_type(soc->hal_soc);
216*5113495bSYour Name 	switch (target_type) {
217*5113495bSYour Name 	case TARGET_TYPE_WCN6450:
218*5113495bSYour Name 		wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, true);
219*5113495bSYour Name 		soc->ast_override_support = 1;
220*5113495bSYour Name 		soc->wlan_cfg_ctx->rxdma1_enable = 0;
221*5113495bSYour Name 		break;
222*5113495bSYour Name 	default:
223*5113495bSYour Name 		qdf_print("%s: Unknown tgt type %d\n", __func__, target_type);
224*5113495bSYour Name 		qdf_assert_always(0);
225*5113495bSYour Name 		break;
226*5113495bSYour Name 	}
227*5113495bSYour Name }
228*5113495bSYour Name 
dp_soc_cfg_attach_rh(struct dp_soc * soc)229*5113495bSYour Name static void dp_soc_cfg_attach_rh(struct dp_soc *soc)
230*5113495bSYour Name {
231*5113495bSYour Name 	int target_type;
232*5113495bSYour Name 
233*5113495bSYour Name 	target_type = hal_get_target_type(soc->hal_soc);
234*5113495bSYour Name 	switch (target_type) {
235*5113495bSYour Name 	case TARGET_TYPE_WCN6450:
236*5113495bSYour Name 		soc->wlan_cfg_ctx->rxdma1_enable = 0;
237*5113495bSYour Name 		break;
238*5113495bSYour Name 	default:
239*5113495bSYour Name 		qdf_print("%s: Unknown tgt type %d\n", __func__, target_type);
240*5113495bSYour Name 		qdf_assert_always(0);
241*5113495bSYour Name 		break;
242*5113495bSYour Name 	}
243*5113495bSYour Name 
244*5113495bSYour Name 	/*
245*5113495bSYour Name 	 * keeping TCL and completion rings number, this data
246*5113495bSYour Name 	 * is equivalent number of TX interface rings.
247*5113495bSYour Name 	 */
248*5113495bSYour Name 	soc->num_tx_comp_rings =
249*5113495bSYour Name 		wlan_cfg_num_tx_comp_rings(soc->wlan_cfg_ctx);
250*5113495bSYour Name 	soc->num_tcl_data_rings =
251*5113495bSYour Name 		wlan_cfg_num_tcl_data_rings(soc->wlan_cfg_ctx);
252*5113495bSYour Name }
253*5113495bSYour Name 
dp_get_context_size_rh(enum dp_context_type context_type)254*5113495bSYour Name qdf_size_t dp_get_context_size_rh(enum dp_context_type context_type)
255*5113495bSYour Name {
256*5113495bSYour Name 	switch (context_type) {
257*5113495bSYour Name 	case DP_CONTEXT_TYPE_SOC:
258*5113495bSYour Name 		return sizeof(struct dp_soc_rh);
259*5113495bSYour Name 	case DP_CONTEXT_TYPE_PDEV:
260*5113495bSYour Name 		return sizeof(struct dp_pdev_rh);
261*5113495bSYour Name 	case DP_CONTEXT_TYPE_VDEV:
262*5113495bSYour Name 		return sizeof(struct dp_vdev_rh);
263*5113495bSYour Name 	case DP_CONTEXT_TYPE_PEER:
264*5113495bSYour Name 		return sizeof(struct dp_peer_rh);
265*5113495bSYour Name 	default:
266*5113495bSYour Name 		return 0;
267*5113495bSYour Name 	}
268*5113495bSYour Name }
269*5113495bSYour Name 
dp_mon_get_context_size_rh(enum dp_context_type context_type)270*5113495bSYour Name qdf_size_t dp_mon_get_context_size_rh(enum dp_context_type context_type)
271*5113495bSYour Name {
272*5113495bSYour Name 	switch (context_type) {
273*5113495bSYour Name 	case DP_CONTEXT_TYPE_MON_PDEV:
274*5113495bSYour Name 		return sizeof(struct dp_mon_pdev_rh);
275*5113495bSYour Name 	case DP_CONTEXT_TYPE_MON_SOC:
276*5113495bSYour Name 		return sizeof(struct dp_mon_soc_rh);
277*5113495bSYour Name 	default:
278*5113495bSYour Name 		return 0;
279*5113495bSYour Name 	}
280*5113495bSYour Name }
281*5113495bSYour Name 
dp_soc_attach_rh(struct dp_soc * soc,struct cdp_soc_attach_params * params)282*5113495bSYour Name static QDF_STATUS dp_soc_attach_rh(struct dp_soc *soc,
283*5113495bSYour Name 				   struct cdp_soc_attach_params *params)
284*5113495bSYour Name {
285*5113495bSYour Name 	soc->wbm_sw0_bm_id = hal_tx_get_wbm_sw0_bm_id();
286*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
287*5113495bSYour Name }
288*5113495bSYour Name 
dp_soc_detach_rh(struct dp_soc * soc)289*5113495bSYour Name static QDF_STATUS dp_soc_detach_rh(struct dp_soc *soc)
290*5113495bSYour Name {
291*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
292*5113495bSYour Name }
293*5113495bSYour Name 
dp_soc_deinit_rh(struct dp_soc * soc)294*5113495bSYour Name static QDF_STATUS dp_soc_deinit_rh(struct dp_soc *soc)
295*5113495bSYour Name {
296*5113495bSYour Name 	struct htt_soc *htt_soc = soc->htt_handle;
297*5113495bSYour Name 
298*5113495bSYour Name 	qdf_atomic_set(&soc->cmn_init_done, 0);
299*5113495bSYour Name 
300*5113495bSYour Name 	/*Degister RX offload flush handlers*/
301*5113495bSYour Name 	hif_offld_flush_cb_deregister(soc->hif_handle);
302*5113495bSYour Name 
303*5113495bSYour Name 	dp_monitor_soc_deinit(soc);
304*5113495bSYour Name 
305*5113495bSYour Name 	/* free peer tables & AST tables allocated during peer_map_attach */
306*5113495bSYour Name 	if (soc->peer_map_attach_success) {
307*5113495bSYour Name 		dp_peer_find_detach(soc);
308*5113495bSYour Name 		dp_peer_map_detach_rh(soc);
309*5113495bSYour Name 		soc->peer_map_attach_success = FALSE;
310*5113495bSYour Name 	}
311*5113495bSYour Name 
312*5113495bSYour Name 	qdf_flush_work(&soc->htt_stats.work);
313*5113495bSYour Name 	qdf_disable_work(&soc->htt_stats.work);
314*5113495bSYour Name 
315*5113495bSYour Name 	qdf_spinlock_destroy(&soc->htt_stats.lock);
316*5113495bSYour Name 
317*5113495bSYour Name 	qdf_spinlock_destroy(&soc->ast_lock);
318*5113495bSYour Name 
319*5113495bSYour Name 	dp_peer_mec_spinlock_destroy(soc);
320*5113495bSYour Name 
321*5113495bSYour Name 	qdf_nbuf_queue_free(&soc->htt_stats.msg);
322*5113495bSYour Name 
323*5113495bSYour Name 	qdf_nbuf_queue_free(&soc->invalid_buf_queue);
324*5113495bSYour Name 
325*5113495bSYour Name 	qdf_spinlock_destroy(&soc->rx.defrag.defrag_lock);
326*5113495bSYour Name 
327*5113495bSYour Name 	qdf_spinlock_destroy(&soc->vdev_map_lock);
328*5113495bSYour Name 
329*5113495bSYour Name 	dp_soc_tx_desc_sw_pools_deinit(soc);
330*5113495bSYour Name 
331*5113495bSYour Name 	dp_soc_srng_deinit(soc);
332*5113495bSYour Name 
333*5113495bSYour Name 	dp_hw_link_desc_ring_deinit(soc);
334*5113495bSYour Name 
335*5113495bSYour Name 	dp_soc_print_inactive_objects(soc);
336*5113495bSYour Name 	qdf_spinlock_destroy(&soc->inactive_peer_list_lock);
337*5113495bSYour Name 	qdf_spinlock_destroy(&soc->inactive_vdev_list_lock);
338*5113495bSYour Name 
339*5113495bSYour Name 	htt_soc_htc_dealloc(soc->htt_handle);
340*5113495bSYour Name 
341*5113495bSYour Name 	htt_soc_detach(htt_soc);
342*5113495bSYour Name 
343*5113495bSYour Name 	wlan_minidump_remove(soc, sizeof(*soc), soc->ctrl_psoc,
344*5113495bSYour Name 			     WLAN_MD_DP_SOC, "dp_soc");
345*5113495bSYour Name 
346*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
347*5113495bSYour Name }
348*5113495bSYour Name 
dp_soc_init_rh(struct dp_soc * soc,HTC_HANDLE htc_handle,struct hif_opaque_softc * hif_handle)349*5113495bSYour Name static void *dp_soc_init_rh(struct dp_soc *soc, HTC_HANDLE htc_handle,
350*5113495bSYour Name 			    struct hif_opaque_softc *hif_handle)
351*5113495bSYour Name {
352*5113495bSYour Name 	struct htt_soc *htt_soc = (struct htt_soc *)soc->htt_handle;
353*5113495bSYour Name 	bool is_monitor_mode = false;
354*5113495bSYour Name 	uint8_t i;
355*5113495bSYour Name 
356*5113495bSYour Name 	wlan_minidump_log(soc, sizeof(*soc), soc->ctrl_psoc,
357*5113495bSYour Name 			  WLAN_MD_DP_SOC, "dp_soc");
358*5113495bSYour Name 
359*5113495bSYour Name 	soc->hif_handle = hif_handle;
360*5113495bSYour Name 
361*5113495bSYour Name 	soc->hal_soc = hif_get_hal_handle(soc->hif_handle);
362*5113495bSYour Name 	if (!soc->hal_soc)
363*5113495bSYour Name 		goto fail1;
364*5113495bSYour Name 
365*5113495bSYour Name 	htt_soc = htt_soc_attach(soc, htc_handle);
366*5113495bSYour Name 	if (!htt_soc)
367*5113495bSYour Name 		goto fail1;
368*5113495bSYour Name 
369*5113495bSYour Name 	soc->htt_handle = htt_soc;
370*5113495bSYour Name 
371*5113495bSYour Name 	if (htt_soc_htc_prealloc(htt_soc) != QDF_STATUS_SUCCESS)
372*5113495bSYour Name 		goto fail2;
373*5113495bSYour Name 
374*5113495bSYour Name 	htt_set_htc_handle(htt_soc, htc_handle);
375*5113495bSYour Name 
376*5113495bSYour Name 	dp_soc_cfg_init_rh(soc);
377*5113495bSYour Name 
378*5113495bSYour Name 	dp_monitor_soc_cfg_init(soc);
379*5113495bSYour Name 
380*5113495bSYour Name 	/* Note: Any SRNG ring initialization should happen only after
381*5113495bSYour Name 	 * Interrupt mode is set and followed by filling up the
382*5113495bSYour Name 	 * interrupt mask. IT SHOULD ALWAYS BE IN THIS ORDER.
383*5113495bSYour Name 	 */
384*5113495bSYour Name 	dp_soc_set_interrupt_mode(soc);
385*5113495bSYour Name 	if (soc->cdp_soc.ol_ops->get_con_mode &&
386*5113495bSYour Name 	    soc->cdp_soc.ol_ops->get_con_mode() ==
387*5113495bSYour Name 	    QDF_GLOBAL_MONITOR_MODE) {
388*5113495bSYour Name 		is_monitor_mode = true;
389*5113495bSYour Name 		soc->curr_rx_pkt_tlv_size = soc->rx_mon_pkt_tlv_size;
390*5113495bSYour Name 	} else {
391*5113495bSYour Name 		soc->curr_rx_pkt_tlv_size = soc->rx_pkt_tlv_size;
392*5113495bSYour Name 	}
393*5113495bSYour Name 
394*5113495bSYour Name 	if (is_monitor_mode)
395*5113495bSYour Name 		wlan_cfg_fill_interrupt_mask(soc->wlan_cfg_ctx, 0,
396*5113495bSYour Name 					     soc->intr_mode, is_monitor_mode,
397*5113495bSYour Name 					     false, soc->umac_reset_supported);
398*5113495bSYour Name 	if (dp_soc_srng_init(soc)) {
399*5113495bSYour Name 		dp_init_err("%pK: dp_soc_srng_init failed", soc);
400*5113495bSYour Name 		goto fail3;
401*5113495bSYour Name 	}
402*5113495bSYour Name 
403*5113495bSYour Name 	if (dp_htt_soc_initialize_rh(soc->htt_handle, soc->ctrl_psoc,
404*5113495bSYour Name 				     htt_get_htc_handle(htt_soc),
405*5113495bSYour Name 				     soc->hal_soc, soc->osdev) == NULL)
406*5113495bSYour Name 		goto fail4;
407*5113495bSYour Name 
408*5113495bSYour Name 	/* Initialize descriptors in TCL Rings */
409*5113495bSYour Name 	for (i = 0; i < soc->num_tcl_data_rings; i++) {
410*5113495bSYour Name 		hal_tx_init_data_ring(soc->hal_soc,
411*5113495bSYour Name 				      soc->tcl_data_ring[i].hal_srng);
412*5113495bSYour Name 	}
413*5113495bSYour Name 
414*5113495bSYour Name 	if (dp_soc_tx_desc_sw_pools_init(soc)) {
415*5113495bSYour Name 		dp_init_err("%pK: dp_tx_soc_attach failed", soc);
416*5113495bSYour Name 		goto fail5;
417*5113495bSYour Name 	}
418*5113495bSYour Name 
419*5113495bSYour Name 	wlan_cfg_set_rx_hash(soc->wlan_cfg_ctx,
420*5113495bSYour Name 			     cfg_get(soc->ctrl_psoc, CFG_DP_RX_HASH));
421*5113495bSYour Name 	soc->cce_disable = false;
422*5113495bSYour Name 	soc->max_ast_ageout_count = MAX_AST_AGEOUT_COUNT;
423*5113495bSYour Name 
424*5113495bSYour Name 	soc->sta_mode_search_policy = DP_TX_ADDR_SEARCH_ADDR_POLICY;
425*5113495bSYour Name 	qdf_mem_zero(&soc->vdev_id_map, sizeof(soc->vdev_id_map));
426*5113495bSYour Name 	qdf_spinlock_create(&soc->vdev_map_lock);
427*5113495bSYour Name 	qdf_atomic_init(&soc->num_tx_outstanding);
428*5113495bSYour Name 	qdf_atomic_init(&soc->num_tx_exception);
429*5113495bSYour Name 	soc->num_tx_allowed =
430*5113495bSYour Name 		wlan_cfg_get_dp_soc_tx_device_limit(soc->wlan_cfg_ctx);
431*5113495bSYour Name 
432*5113495bSYour Name 	if (soc->cdp_soc.ol_ops->get_dp_cfg_param) {
433*5113495bSYour Name 		int ret = soc->cdp_soc.ol_ops->get_dp_cfg_param(soc->ctrl_psoc,
434*5113495bSYour Name 				CDP_CFG_MAX_PEER_ID);
435*5113495bSYour Name 
436*5113495bSYour Name 		if (ret != -EINVAL)
437*5113495bSYour Name 			wlan_cfg_set_max_peer_id(soc->wlan_cfg_ctx, ret);
438*5113495bSYour Name 
439*5113495bSYour Name 		ret = soc->cdp_soc.ol_ops->get_dp_cfg_param(soc->ctrl_psoc,
440*5113495bSYour Name 				CDP_CFG_CCE_DISABLE);
441*5113495bSYour Name 		if (ret == 1)
442*5113495bSYour Name 			soc->cce_disable = true;
443*5113495bSYour Name 	}
444*5113495bSYour Name 
445*5113495bSYour Name 	/* setup the global rx defrag waitlist */
446*5113495bSYour Name 	TAILQ_INIT(&soc->rx.defrag.waitlist);
447*5113495bSYour Name 	soc->rx.defrag.timeout_ms =
448*5113495bSYour Name 		wlan_cfg_get_rx_defrag_min_timeout(soc->wlan_cfg_ctx);
449*5113495bSYour Name 	soc->rx.defrag.next_flush_ms = 0;
450*5113495bSYour Name 	soc->rx.flags.defrag_timeout_check =
451*5113495bSYour Name 		wlan_cfg_get_defrag_timeout_check(soc->wlan_cfg_ctx);
452*5113495bSYour Name 	qdf_spinlock_create(&soc->rx.defrag.defrag_lock);
453*5113495bSYour Name 
454*5113495bSYour Name 	dp_monitor_soc_init(soc);
455*5113495bSYour Name 
456*5113495bSYour Name 	qdf_atomic_set(&soc->cmn_init_done, 1);
457*5113495bSYour Name 
458*5113495bSYour Name 	qdf_nbuf_queue_init(&soc->htt_stats.msg);
459*5113495bSYour Name 
460*5113495bSYour Name 	qdf_spinlock_create(&soc->ast_lock);
461*5113495bSYour Name 	dp_peer_mec_spinlock_create(soc);
462*5113495bSYour Name 
463*5113495bSYour Name 	qdf_nbuf_queue_init(&soc->invalid_buf_queue);
464*5113495bSYour Name 
465*5113495bSYour Name 	TAILQ_INIT(&soc->inactive_peer_list);
466*5113495bSYour Name 	qdf_spinlock_create(&soc->inactive_peer_list_lock);
467*5113495bSYour Name 	TAILQ_INIT(&soc->inactive_vdev_list);
468*5113495bSYour Name 	qdf_spinlock_create(&soc->inactive_vdev_list_lock);
469*5113495bSYour Name 	qdf_spinlock_create(&soc->htt_stats.lock);
470*5113495bSYour Name 	/* initialize work queue for stats processing */
471*5113495bSYour Name 	qdf_create_work(0, &soc->htt_stats.work, htt_t2h_stats_handler, soc);
472*5113495bSYour Name 
473*5113495bSYour Name 	/*Register RX offload flush handlers*/
474*5113495bSYour Name 	hif_offld_flush_cb_register(soc->hif_handle, dp_rx_data_flush);
475*5113495bSYour Name 
476*5113495bSYour Name 	dp_info("Mem stats: DMA = %u HEAP = %u SKB = %u",
477*5113495bSYour Name 		qdf_dma_mem_stats_read(),
478*5113495bSYour Name 		qdf_heap_mem_stats_read(),
479*5113495bSYour Name 		qdf_skb_total_mem_stats_read());
480*5113495bSYour Name 
481*5113495bSYour Name 	soc->vdev_stats_id_map = 0;
482*5113495bSYour Name 
483*5113495bSYour Name 	return soc;
484*5113495bSYour Name fail5:
485*5113495bSYour Name 	htt_soc_htc_dealloc(soc->htt_handle);
486*5113495bSYour Name fail4:
487*5113495bSYour Name 	dp_soc_srng_deinit(soc);
488*5113495bSYour Name fail3:
489*5113495bSYour Name 	htt_htc_pkt_pool_free(htt_soc);
490*5113495bSYour Name fail2:
491*5113495bSYour Name 	htt_soc_detach(htt_soc);
492*5113495bSYour Name fail1:
493*5113495bSYour Name 	return NULL;
494*5113495bSYour Name }
495*5113495bSYour Name 
dp_soc_interrupt_detach_rh(struct cdp_soc_t * txrx_soc)496*5113495bSYour Name static void dp_soc_interrupt_detach_rh(struct cdp_soc_t *txrx_soc)
497*5113495bSYour Name {
498*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)txrx_soc;
499*5113495bSYour Name 	int i;
500*5113495bSYour Name 
501*5113495bSYour Name 	if (soc->intr_mode == DP_INTR_POLL) {
502*5113495bSYour Name 		qdf_timer_free(&soc->int_timer);
503*5113495bSYour Name 	} else {
504*5113495bSYour Name 		hif_deconfigure_ext_group_interrupts(soc->hif_handle);
505*5113495bSYour Name 		hif_deregister_exec_group(soc->hif_handle, "dp_intr");
506*5113495bSYour Name 	}
507*5113495bSYour Name 
508*5113495bSYour Name 	for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
509*5113495bSYour Name 		soc->intr_ctx[i].rx_mon_ring_mask = 0;
510*5113495bSYour Name 		soc->intr_ctx[i].rxdma2host_ring_mask = 0;
511*5113495bSYour Name 
512*5113495bSYour Name 		hif_event_history_deinit(soc->hif_handle, i);
513*5113495bSYour Name 		qdf_lro_deinit(soc->intr_ctx[i].lro_ctx);
514*5113495bSYour Name 	}
515*5113495bSYour Name 
516*5113495bSYour Name 	qdf_mem_set(&soc->mon_intr_id_lmac_map,
517*5113495bSYour Name 		    sizeof(soc->mon_intr_id_lmac_map),
518*5113495bSYour Name 		    DP_MON_INVALID_LMAC_ID);
519*5113495bSYour Name }
520*5113495bSYour Name 
dp_soc_interrupt_attach_rh(struct cdp_soc_t * txrx_soc)521*5113495bSYour Name static QDF_STATUS dp_soc_interrupt_attach_rh(struct cdp_soc_t *txrx_soc)
522*5113495bSYour Name {
523*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)txrx_soc;
524*5113495bSYour Name 	int i = 0;
525*5113495bSYour Name 	int num_irq = 0;
526*5113495bSYour Name 	int lmac_id = 0;
527*5113495bSYour Name 	int napi_scale;
528*5113495bSYour Name 
529*5113495bSYour Name 	qdf_mem_set(&soc->mon_intr_id_lmac_map,
530*5113495bSYour Name 		    sizeof(soc->mon_intr_id_lmac_map), DP_MON_INVALID_LMAC_ID);
531*5113495bSYour Name 
532*5113495bSYour Name 	if (soc->cdp_soc.ol_ops->get_con_mode &&
533*5113495bSYour Name 	    soc->cdp_soc.ol_ops->get_con_mode() !=
534*5113495bSYour Name 	    QDF_GLOBAL_MONITOR_MODE)
535*5113495bSYour Name 		return QDF_STATUS_SUCCESS;
536*5113495bSYour Name 
537*5113495bSYour Name 	for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
538*5113495bSYour Name 		int ret = 0;
539*5113495bSYour Name 
540*5113495bSYour Name 		/* Map of IRQ ids registered with one interrupt context */
541*5113495bSYour Name 		int irq_id_map[HIF_MAX_GRP_IRQ];
542*5113495bSYour Name 
543*5113495bSYour Name 		int rx_mon_mask =
544*5113495bSYour Name 			dp_soc_get_mon_mask_for_interrupt_mode(soc, i);
545*5113495bSYour Name 		int rxdma2host_ring_mask =
546*5113495bSYour Name 			wlan_cfg_get_rxdma2host_ring_mask(soc->wlan_cfg_ctx, i);
547*5113495bSYour Name 
548*5113495bSYour Name 		soc->intr_ctx[i].dp_intr_id = i;
549*5113495bSYour Name 		soc->intr_ctx[i].rx_mon_ring_mask = rx_mon_mask;
550*5113495bSYour Name 		soc->intr_ctx[i].rxdma2host_ring_mask = rxdma2host_ring_mask;
551*5113495bSYour Name 		soc->intr_ctx[i].soc = soc;
552*5113495bSYour Name 
553*5113495bSYour Name 		num_irq = 0;
554*5113495bSYour Name 
555*5113495bSYour Name 		dp_soc_interrupt_map_calculate(soc, i, &irq_id_map[0],
556*5113495bSYour Name 					       &num_irq);
557*5113495bSYour Name 
558*5113495bSYour Name 		napi_scale = wlan_cfg_get_napi_scale_factor(soc->wlan_cfg_ctx);
559*5113495bSYour Name 		if (!napi_scale)
560*5113495bSYour Name 			napi_scale = QCA_NAPI_DEF_SCALE_BIN_SHIFT;
561*5113495bSYour Name 
562*5113495bSYour Name 		ret = hif_register_ext_group(soc->hif_handle,
563*5113495bSYour Name 					     num_irq, irq_id_map, dp_service_srngs_wrapper,
564*5113495bSYour Name 					     &soc->intr_ctx[i], "dp_intr",
565*5113495bSYour Name 					     HIF_EXEC_NAPI_TYPE, napi_scale);
566*5113495bSYour Name 
567*5113495bSYour Name 		dp_debug(" int ctx %u num_irq %u irq_id_map %u %u",
568*5113495bSYour Name 			 i, num_irq, irq_id_map[0], irq_id_map[1]);
569*5113495bSYour Name 
570*5113495bSYour Name 		if (ret) {
571*5113495bSYour Name 			dp_init_err("%pK: failed, ret = %d", soc, ret);
572*5113495bSYour Name 			dp_soc_interrupt_detach_rh(txrx_soc);
573*5113495bSYour Name 			return QDF_STATUS_E_FAILURE;
574*5113495bSYour Name 		}
575*5113495bSYour Name 
576*5113495bSYour Name 		hif_event_history_init(soc->hif_handle, i);
577*5113495bSYour Name 		soc->intr_ctx[i].lro_ctx = qdf_lro_init();
578*5113495bSYour Name 
579*5113495bSYour Name 		if (dp_is_mon_mask_valid(soc, &soc->intr_ctx[i])) {
580*5113495bSYour Name 			soc->mon_intr_id_lmac_map[lmac_id] = i;
581*5113495bSYour Name 			lmac_id++;
582*5113495bSYour Name 		}
583*5113495bSYour Name 	}
584*5113495bSYour Name 
585*5113495bSYour Name 	hif_configure_ext_group_interrupts(soc->hif_handle);
586*5113495bSYour Name 
587*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
588*5113495bSYour Name }
589*5113495bSYour Name 
dp_soc_attach_poll_rh(struct cdp_soc_t * txrx_soc)590*5113495bSYour Name static QDF_STATUS dp_soc_attach_poll_rh(struct cdp_soc_t *txrx_soc)
591*5113495bSYour Name {
592*5113495bSYour Name 	struct dp_soc *soc = (struct dp_soc *)txrx_soc;
593*5113495bSYour Name 	uint32_t lmac_id = 0;
594*5113495bSYour Name 	int i;
595*5113495bSYour Name 
596*5113495bSYour Name 	qdf_mem_set(&soc->mon_intr_id_lmac_map,
597*5113495bSYour Name 		    sizeof(soc->mon_intr_id_lmac_map), DP_MON_INVALID_LMAC_ID);
598*5113495bSYour Name 	soc->intr_mode = DP_INTR_POLL;
599*5113495bSYour Name 
600*5113495bSYour Name 	for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
601*5113495bSYour Name 		soc->intr_ctx[i].rx_mon_ring_mask =
602*5113495bSYour Name 				wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, i);
603*5113495bSYour Name 
604*5113495bSYour Name 		if (dp_is_mon_mask_valid(soc, &soc->intr_ctx[i])) {
605*5113495bSYour Name 			hif_event_history_init(soc->hif_handle, i);
606*5113495bSYour Name 			soc->mon_intr_id_lmac_map[lmac_id] = i;
607*5113495bSYour Name 			lmac_id++;
608*5113495bSYour Name 		}
609*5113495bSYour Name 	}
610*5113495bSYour Name 
611*5113495bSYour Name 	qdf_timer_init(soc->osdev, &soc->int_timer,
612*5113495bSYour Name 		       dp_interrupt_timer, (void *)soc,
613*5113495bSYour Name 		       QDF_TIMER_TYPE_WAKE_APPS);
614*5113495bSYour Name 
615*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
616*5113495bSYour Name }
617*5113495bSYour Name 
dp_service_srngs_rh(void * dp_ctx,uint32_t dp_budget,int cpu)618*5113495bSYour Name static uint32_t dp_service_srngs_rh(void *dp_ctx, uint32_t dp_budget, int cpu)
619*5113495bSYour Name {
620*5113495bSYour Name 	struct dp_intr *int_ctx = (struct dp_intr *)dp_ctx;
621*5113495bSYour Name 	struct dp_soc *soc = int_ctx->soc;
622*5113495bSYour Name 	uint32_t work_done  = 0;
623*5113495bSYour Name 	int budget = dp_budget;
624*5113495bSYour Name 	uint32_t remaining_quota = dp_budget;
625*5113495bSYour Name 
626*5113495bSYour Name 	if (qdf_unlikely(!dp_monitor_is_vdev_timer_running(soc))) {
627*5113495bSYour Name 		work_done = dp_process_lmac_rings(int_ctx, remaining_quota);
628*5113495bSYour Name 		if (work_done) {
629*5113495bSYour Name 			budget -=  work_done;
630*5113495bSYour Name 			if (budget <= 0)
631*5113495bSYour Name 				goto budget_done;
632*5113495bSYour Name 			remaining_quota = budget;
633*5113495bSYour Name 		}
634*5113495bSYour Name 	}
635*5113495bSYour Name 
636*5113495bSYour Name budget_done:
637*5113495bSYour Name 	qdf_atomic_clear_bit(cpu, &soc->service_rings_running);
638*5113495bSYour Name 
639*5113495bSYour Name 	if (soc->notify_fw_callback)
640*5113495bSYour Name 		soc->notify_fw_callback(soc);
641*5113495bSYour Name 
642*5113495bSYour Name 	return dp_budget - budget;
643*5113495bSYour Name }
644*5113495bSYour Name 
645*5113495bSYour Name /**
646*5113495bSYour Name  * dp_pdev_fill_tx_endpoint_info_rh() - Prefill fixed TX endpoint information
647*5113495bSYour Name  *					that is used during packet transmit
648*5113495bSYour Name  * @pdev: Handle to DP pdev struct
649*5113495bSYour Name  *
650*5113495bSYour Name  * Return: QDF_STATUS_SUCCESS/QDF_STATUS_E_NOENT
651*5113495bSYour Name  */
dp_pdev_fill_tx_endpoint_info_rh(struct dp_pdev * pdev)652*5113495bSYour Name static QDF_STATUS dp_pdev_fill_tx_endpoint_info_rh(struct dp_pdev *pdev)
653*5113495bSYour Name {
654*5113495bSYour Name 	struct dp_pdev_rh *rh_pdev = dp_get_rh_pdev_from_dp_pdev(pdev);
655*5113495bSYour Name 	struct dp_soc_rh *rh_soc = dp_get_rh_soc_from_dp_soc(pdev->soc);
656*5113495bSYour Name 	struct dp_tx_ep_info_rh *tx_ep_info = &rh_pdev->tx_ep_info;
657*5113495bSYour Name 	struct hif_opaque_softc *hif_handle = pdev->soc->hif_handle;
658*5113495bSYour Name 	int ul_is_polled, dl_is_polled;
659*5113495bSYour Name 	uint8_t ul_pipe, dl_pipe;
660*5113495bSYour Name 	int status;
661*5113495bSYour Name 
662*5113495bSYour Name 	status = hif_map_service_to_pipe(hif_handle, HTT_DATA2_MSG_SVC,
663*5113495bSYour Name 					 &ul_pipe, &dl_pipe,
664*5113495bSYour Name 					 &ul_is_polled, &dl_is_polled);
665*5113495bSYour Name 	if (status) {
666*5113495bSYour Name 		hif_err("Failed to map tx pipe: %d", status);
667*5113495bSYour Name 		return QDF_STATUS_E_NOENT;
668*5113495bSYour Name 	}
669*5113495bSYour Name 
670*5113495bSYour Name 	tx_ep_info->ce_tx_hdl = hif_get_ce_handle(hif_handle, ul_pipe);
671*5113495bSYour Name 
672*5113495bSYour Name 	tx_ep_info->download_len = HAL_TX_DESC_LEN_BYTES +
673*5113495bSYour Name 				   sizeof(struct tlv_32_hdr) +
674*5113495bSYour Name 				   DP_RH_TX_HDR_SIZE_OUTER_HDR_MAX +
675*5113495bSYour Name 				   DP_RH_TX_HDR_SIZE_802_1Q +
676*5113495bSYour Name 				   DP_RH_TX_HDR_SIZE_LLC_SNAP +
677*5113495bSYour Name 				   DP_RH_TX_HDR_SIZE_IP;
678*5113495bSYour Name 
679*5113495bSYour Name 	tx_ep_info->tx_endpoint = rh_soc->tx_endpoint;
680*5113495bSYour Name 
681*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
682*5113495bSYour Name }
683*5113495bSYour Name 
dp_pdev_attach_rh(struct dp_pdev * pdev,struct cdp_pdev_attach_params * params)684*5113495bSYour Name static QDF_STATUS dp_pdev_attach_rh(struct dp_pdev *pdev,
685*5113495bSYour Name 				    struct cdp_pdev_attach_params *params)
686*5113495bSYour Name {
687*5113495bSYour Name 	return dp_pdev_fill_tx_endpoint_info_rh(pdev);
688*5113495bSYour Name }
689*5113495bSYour Name 
dp_pdev_detach_rh(struct dp_pdev * pdev)690*5113495bSYour Name static QDF_STATUS dp_pdev_detach_rh(struct dp_pdev *pdev)
691*5113495bSYour Name {
692*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
693*5113495bSYour Name }
694*5113495bSYour Name 
dp_vdev_attach_rh(struct dp_soc * soc,struct dp_vdev * vdev)695*5113495bSYour Name static QDF_STATUS dp_vdev_attach_rh(struct dp_soc *soc, struct dp_vdev *vdev)
696*5113495bSYour Name {
697*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
698*5113495bSYour Name }
699*5113495bSYour Name 
dp_vdev_detach_rh(struct dp_soc * soc,struct dp_vdev * vdev)700*5113495bSYour Name static QDF_STATUS dp_vdev_detach_rh(struct dp_soc *soc, struct dp_vdev *vdev)
701*5113495bSYour Name {
702*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
703*5113495bSYour Name }
704*5113495bSYour Name 
dp_get_soc_context_size_rh(void)705*5113495bSYour Name qdf_size_t dp_get_soc_context_size_rh(void)
706*5113495bSYour Name {
707*5113495bSYour Name 	return sizeof(struct dp_soc_rh);
708*5113495bSYour Name }
709*5113495bSYour Name 
710*5113495bSYour Name #ifdef NO_RX_PKT_HDR_TLV
711*5113495bSYour Name /**
712*5113495bSYour Name  * dp_rxdma_ring_sel_cfg_rh() - Setup RXDMA ring config
713*5113495bSYour Name  * @soc: Common DP soc handle
714*5113495bSYour Name  *
715*5113495bSYour Name  * Return: QDF_STATUS
716*5113495bSYour Name  */
717*5113495bSYour Name static QDF_STATUS
dp_rxdma_ring_sel_cfg_rh(struct dp_soc * soc)718*5113495bSYour Name dp_rxdma_ring_sel_cfg_rh(struct dp_soc *soc)
719*5113495bSYour Name {
720*5113495bSYour Name 	int i;
721*5113495bSYour Name 	int mac_id;
722*5113495bSYour Name 	struct htt_rx_ring_tlv_filter htt_tlv_filter = {0};
723*5113495bSYour Name 	struct dp_srng *rx_mac_srng;
724*5113495bSYour Name 	QDF_STATUS status = QDF_STATUS_SUCCESS;
725*5113495bSYour Name 	uint16_t buf_size;
726*5113495bSYour Name 
727*5113495bSYour Name 	buf_size = wlan_cfg_rx_buffer_size(soc->wlan_cfg_ctx);
728*5113495bSYour Name 
729*5113495bSYour Name 	htt_tlv_filter.mpdu_start = 1;
730*5113495bSYour Name 	htt_tlv_filter.msdu_start = 1;
731*5113495bSYour Name 	htt_tlv_filter.mpdu_end = 1;
732*5113495bSYour Name 	htt_tlv_filter.msdu_end = 1;
733*5113495bSYour Name 	htt_tlv_filter.attention = 1;
734*5113495bSYour Name 	htt_tlv_filter.packet = 1;
735*5113495bSYour Name 	htt_tlv_filter.packet_header = 0;
736*5113495bSYour Name 
737*5113495bSYour Name 	htt_tlv_filter.ppdu_start = 0;
738*5113495bSYour Name 	htt_tlv_filter.ppdu_end = 0;
739*5113495bSYour Name 	htt_tlv_filter.ppdu_end_user_stats = 0;
740*5113495bSYour Name 	htt_tlv_filter.ppdu_end_user_stats_ext = 0;
741*5113495bSYour Name 	htt_tlv_filter.ppdu_end_status_done = 0;
742*5113495bSYour Name 	htt_tlv_filter.enable_fp = 1;
743*5113495bSYour Name 	htt_tlv_filter.enable_md = 0;
744*5113495bSYour Name 	htt_tlv_filter.enable_md = 0;
745*5113495bSYour Name 	htt_tlv_filter.enable_mo = 0;
746*5113495bSYour Name 
747*5113495bSYour Name 	htt_tlv_filter.fp_mgmt_filter = 0;
748*5113495bSYour Name 	htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_BA_REQ;
749*5113495bSYour Name 	htt_tlv_filter.fp_data_filter = (FILTER_DATA_UCAST |
750*5113495bSYour Name 					 FILTER_DATA_MCAST |
751*5113495bSYour Name 					 FILTER_DATA_DATA);
752*5113495bSYour Name 	htt_tlv_filter.mo_mgmt_filter = 0;
753*5113495bSYour Name 	htt_tlv_filter.mo_ctrl_filter = 0;
754*5113495bSYour Name 	htt_tlv_filter.mo_data_filter = 0;
755*5113495bSYour Name 	htt_tlv_filter.md_data_filter = 0;
756*5113495bSYour Name 
757*5113495bSYour Name 	htt_tlv_filter.offset_valid = true;
758*5113495bSYour Name 
759*5113495bSYour Name 	htt_tlv_filter.rx_packet_offset = soc->rx_pkt_tlv_size;
760*5113495bSYour Name 	/*Not subscribing rx_pkt_header*/
761*5113495bSYour Name 	htt_tlv_filter.rx_header_offset = 0;
762*5113495bSYour Name 	htt_tlv_filter.rx_mpdu_start_offset =
763*5113495bSYour Name 				hal_rx_mpdu_start_offset_get(soc->hal_soc);
764*5113495bSYour Name 	htt_tlv_filter.rx_mpdu_end_offset =
765*5113495bSYour Name 				hal_rx_mpdu_end_offset_get(soc->hal_soc);
766*5113495bSYour Name 	htt_tlv_filter.rx_msdu_start_offset =
767*5113495bSYour Name 				hal_rx_msdu_start_offset_get(soc->hal_soc);
768*5113495bSYour Name 	htt_tlv_filter.rx_msdu_end_offset =
769*5113495bSYour Name 				hal_rx_msdu_end_offset_get(soc->hal_soc);
770*5113495bSYour Name 	htt_tlv_filter.rx_attn_offset =
771*5113495bSYour Name 				hal_rx_attn_offset_get(soc->hal_soc);
772*5113495bSYour Name 
773*5113495bSYour Name 	for (i = 0; i < MAX_PDEV_CNT; i++) {
774*5113495bSYour Name 		struct dp_pdev *pdev = soc->pdev_list[i];
775*5113495bSYour Name 
776*5113495bSYour Name 		if (!pdev)
777*5113495bSYour Name 			continue;
778*5113495bSYour Name 
779*5113495bSYour Name 		for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
780*5113495bSYour Name 			int mac_for_pdev =
781*5113495bSYour Name 				dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
782*5113495bSYour Name 			/*
783*5113495bSYour Name 			 * Obtain lmac id from pdev to access the LMAC ring
784*5113495bSYour Name 			 * in soc context
785*5113495bSYour Name 			 */
786*5113495bSYour Name 			int lmac_id =
787*5113495bSYour Name 				dp_get_lmac_id_for_pdev_id(soc, mac_id,
788*5113495bSYour Name 							   pdev->pdev_id);
789*5113495bSYour Name 
790*5113495bSYour Name 			rx_mac_srng = dp_get_rxdma_ring(pdev, lmac_id);
791*5113495bSYour Name 			htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
792*5113495bSYour Name 					    rx_mac_srng->hal_srng,
793*5113495bSYour Name 					    RXDMA_BUF, buf_size,
794*5113495bSYour Name 					    &htt_tlv_filter);
795*5113495bSYour Name 		}
796*5113495bSYour Name 	}
797*5113495bSYour Name 
798*5113495bSYour Name 	if (QDF_IS_STATUS_SUCCESS(status))
799*5113495bSYour Name 		status = dp_htt_h2t_rx_ring_rfs_cfg(soc->htt_handle);
800*5113495bSYour Name 
801*5113495bSYour Name 	return status;
802*5113495bSYour Name }
803*5113495bSYour Name #else
804*5113495bSYour Name 
805*5113495bSYour Name static QDF_STATUS
dp_rxdma_ring_sel_cfg_rh(struct dp_soc * soc)806*5113495bSYour Name dp_rxdma_ring_sel_cfg_rh(struct dp_soc *soc)
807*5113495bSYour Name {
808*5113495bSYour Name 	int i;
809*5113495bSYour Name 	int mac_id;
810*5113495bSYour Name 	struct htt_rx_ring_tlv_filter htt_tlv_filter = {0};
811*5113495bSYour Name 	struct dp_srng *rx_mac_srng;
812*5113495bSYour Name 	QDF_STATUS status = QDF_STATUS_SUCCESS;
813*5113495bSYour Name 	uint16_t buf_size;
814*5113495bSYour Name 
815*5113495bSYour Name 	buf_size = wlan_cfg_rx_buffer_size(soc->wlan_cfg_ctx);
816*5113495bSYour Name 
817*5113495bSYour Name 	htt_tlv_filter.mpdu_start = 1;
818*5113495bSYour Name 	htt_tlv_filter.msdu_start = 1;
819*5113495bSYour Name 	htt_tlv_filter.mpdu_end = 1;
820*5113495bSYour Name 	htt_tlv_filter.msdu_end = 1;
821*5113495bSYour Name 	htt_tlv_filter.attention = 1;
822*5113495bSYour Name 	htt_tlv_filter.packet = 1;
823*5113495bSYour Name 	htt_tlv_filter.packet_header = 1;
824*5113495bSYour Name 
825*5113495bSYour Name 	htt_tlv_filter.ppdu_start = 0;
826*5113495bSYour Name 	htt_tlv_filter.ppdu_end = 0;
827*5113495bSYour Name 	htt_tlv_filter.ppdu_end_user_stats = 0;
828*5113495bSYour Name 	htt_tlv_filter.ppdu_end_user_stats_ext = 0;
829*5113495bSYour Name 	htt_tlv_filter.ppdu_end_status_done = 0;
830*5113495bSYour Name 	htt_tlv_filter.enable_fp = 1;
831*5113495bSYour Name 	htt_tlv_filter.enable_md = 0;
832*5113495bSYour Name 	htt_tlv_filter.enable_md = 0;
833*5113495bSYour Name 	htt_tlv_filter.enable_mo = 0;
834*5113495bSYour Name 
835*5113495bSYour Name 	htt_tlv_filter.fp_mgmt_filter = 0;
836*5113495bSYour Name 	htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_BA_REQ;
837*5113495bSYour Name 	htt_tlv_filter.fp_data_filter = (FILTER_DATA_UCAST |
838*5113495bSYour Name 					 FILTER_DATA_MCAST |
839*5113495bSYour Name 					 FILTER_DATA_DATA);
840*5113495bSYour Name 	htt_tlv_filter.mo_mgmt_filter = 0;
841*5113495bSYour Name 	htt_tlv_filter.mo_ctrl_filter = 0;
842*5113495bSYour Name 	htt_tlv_filter.mo_data_filter = 0;
843*5113495bSYour Name 	htt_tlv_filter.md_data_filter = 0;
844*5113495bSYour Name 
845*5113495bSYour Name 	htt_tlv_filter.offset_valid = true;
846*5113495bSYour Name 
847*5113495bSYour Name 	htt_tlv_filter.rx_packet_offset = soc->rx_pkt_tlv_size;
848*5113495bSYour Name 	htt_tlv_filter.rx_header_offset =
849*5113495bSYour Name 				hal_rx_pkt_tlv_offset_get(soc->hal_soc);
850*5113495bSYour Name 	htt_tlv_filter.rx_mpdu_start_offset =
851*5113495bSYour Name 				hal_rx_mpdu_start_offset_get(soc->hal_soc);
852*5113495bSYour Name 	htt_tlv_filter.rx_mpdu_end_offset =
853*5113495bSYour Name 				hal_rx_mpdu_end_offset_get(soc->hal_soc);
854*5113495bSYour Name 	htt_tlv_filter.rx_msdu_start_offset =
855*5113495bSYour Name 				hal_rx_msdu_start_offset_get(soc->hal_soc);
856*5113495bSYour Name 	htt_tlv_filter.rx_msdu_end_offset =
857*5113495bSYour Name 				hal_rx_msdu_end_offset_get(soc->hal_soc);
858*5113495bSYour Name 	htt_tlv_filter.rx_attn_offset =
859*5113495bSYour Name 				hal_rx_attn_offset_get(soc->hal_soc);
860*5113495bSYour Name 
861*5113495bSYour Name 	for (i = 0; i < MAX_PDEV_CNT; i++) {
862*5113495bSYour Name 		struct dp_pdev *pdev = soc->pdev_list[i];
863*5113495bSYour Name 
864*5113495bSYour Name 		if (!pdev)
865*5113495bSYour Name 			continue;
866*5113495bSYour Name 
867*5113495bSYour Name 		for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
868*5113495bSYour Name 			int mac_for_pdev =
869*5113495bSYour Name 				dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
870*5113495bSYour Name 			/*
871*5113495bSYour Name 			 * Obtain lmac id from pdev to access the LMAC ring
872*5113495bSYour Name 			 * in soc context
873*5113495bSYour Name 			 */
874*5113495bSYour Name 			int lmac_id =
875*5113495bSYour Name 				dp_get_lmac_id_for_pdev_id(soc, mac_id,
876*5113495bSYour Name 							   pdev->pdev_id);
877*5113495bSYour Name 
878*5113495bSYour Name 			rx_mac_srng = dp_get_rxdma_ring(pdev, lmac_id);
879*5113495bSYour Name 			htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
880*5113495bSYour Name 					    rx_mac_srng->hal_srng,
881*5113495bSYour Name 					    RXDMA_BUF, buf_size,
882*5113495bSYour Name 					    &htt_tlv_filter);
883*5113495bSYour Name 		}
884*5113495bSYour Name 	}
885*5113495bSYour Name 
886*5113495bSYour Name 	if (QDF_IS_STATUS_SUCCESS(status))
887*5113495bSYour Name 		status = dp_htt_h2t_rx_ring_rfs_cfg(soc->htt_handle);
888*5113495bSYour Name 
889*5113495bSYour Name 	return status;
890*5113495bSYour Name }
891*5113495bSYour Name #endif
892*5113495bSYour Name 
dp_soc_srng_deinit_rh(struct dp_soc * soc)893*5113495bSYour Name static void dp_soc_srng_deinit_rh(struct dp_soc *soc)
894*5113495bSYour Name {
895*5113495bSYour Name }
896*5113495bSYour Name 
dp_soc_srng_free_rh(struct dp_soc * soc)897*5113495bSYour Name static void dp_soc_srng_free_rh(struct dp_soc *soc)
898*5113495bSYour Name {
899*5113495bSYour Name }
900*5113495bSYour Name 
dp_soc_srng_alloc_rh(struct dp_soc * soc)901*5113495bSYour Name static QDF_STATUS dp_soc_srng_alloc_rh(struct dp_soc *soc)
902*5113495bSYour Name {
903*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
904*5113495bSYour Name }
905*5113495bSYour Name 
dp_soc_srng_init_rh(struct dp_soc * soc)906*5113495bSYour Name static QDF_STATUS dp_soc_srng_init_rh(struct dp_soc *soc)
907*5113495bSYour Name {
908*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
909*5113495bSYour Name }
910*5113495bSYour Name 
dp_tx_implicit_rbm_set_rh(struct dp_soc * soc,uint8_t tx_ring_id,uint8_t bm_id)911*5113495bSYour Name static void dp_tx_implicit_rbm_set_rh(struct dp_soc *soc,
912*5113495bSYour Name 				      uint8_t tx_ring_id,
913*5113495bSYour Name 				      uint8_t bm_id)
914*5113495bSYour Name {
915*5113495bSYour Name }
916*5113495bSYour Name 
dp_txrx_set_vdev_param_rh(struct dp_soc * soc,struct dp_vdev * vdev,enum cdp_vdev_param_type param,cdp_config_param_type val)917*5113495bSYour Name static QDF_STATUS dp_txrx_set_vdev_param_rh(struct dp_soc *soc,
918*5113495bSYour Name 					    struct dp_vdev *vdev,
919*5113495bSYour Name 					    enum cdp_vdev_param_type param,
920*5113495bSYour Name 					    cdp_config_param_type val)
921*5113495bSYour Name {
922*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
923*5113495bSYour Name }
924*5113495bSYour Name 
dp_get_rx_hash_key_rh(struct dp_soc * soc,struct cdp_lro_hash_config * lro_hash)925*5113495bSYour Name static void dp_get_rx_hash_key_rh(struct dp_soc *soc,
926*5113495bSYour Name 				  struct cdp_lro_hash_config *lro_hash)
927*5113495bSYour Name {
928*5113495bSYour Name 	dp_get_rx_hash_key_bytes(lro_hash);
929*5113495bSYour Name }
930*5113495bSYour Name 
931*5113495bSYour Name #if defined(DP_POWER_SAVE) || defined(FEATURE_RUNTIME_PM)
dp_update_ring_hptp_rh(struct dp_soc * soc,bool force_flush)932*5113495bSYour Name static void dp_update_ring_hptp_rh(struct dp_soc *soc, bool force_flush)
933*5113495bSYour Name {
934*5113495bSYour Name 	struct dp_pdev_rh *rh_pdev =
935*5113495bSYour Name 			dp_get_rh_pdev_from_dp_pdev(soc->pdev_list[0]);
936*5113495bSYour Name 	struct dp_tx_ep_info_rh *tx_ep_info = &rh_pdev->tx_ep_info;
937*5113495bSYour Name 
938*5113495bSYour Name 	ce_flush_tx_ring_write_idx(tx_ep_info->ce_tx_hdl, force_flush);
939*5113495bSYour Name }
940*5113495bSYour Name #endif
941*5113495bSYour Name 
dp_initialize_arch_ops_rh(struct dp_arch_ops * arch_ops)942*5113495bSYour Name void dp_initialize_arch_ops_rh(struct dp_arch_ops *arch_ops)
943*5113495bSYour Name {
944*5113495bSYour Name 	arch_ops->tx_hw_enqueue = dp_tx_hw_enqueue_rh;
945*5113495bSYour Name 	arch_ops->tx_comp_get_params_from_hal_desc =
946*5113495bSYour Name 		dp_tx_comp_get_params_from_hal_desc_rh;
947*5113495bSYour Name 	arch_ops->dp_tx_process_htt_completion =
948*5113495bSYour Name 			dp_tx_process_htt_completion_rh;
949*5113495bSYour Name 	arch_ops->dp_wbm_get_rx_desc_from_hal_desc =
950*5113495bSYour Name 			dp_wbm_get_rx_desc_from_hal_desc_rh;
951*5113495bSYour Name 	arch_ops->dp_tx_desc_pool_alloc = dp_tx_desc_pool_alloc_rh;
952*5113495bSYour Name 	arch_ops->dp_tx_desc_pool_free = dp_tx_desc_pool_free_rh;
953*5113495bSYour Name 	arch_ops->dp_tx_desc_pool_init = dp_tx_desc_pool_init_rh;
954*5113495bSYour Name 	arch_ops->dp_tx_desc_pool_deinit = dp_tx_desc_pool_deinit_rh;
955*5113495bSYour Name 	arch_ops->dp_rx_desc_pool_init = dp_rx_desc_pool_init_rh;
956*5113495bSYour Name 	arch_ops->dp_rx_desc_pool_deinit = dp_rx_desc_pool_deinit_rh;
957*5113495bSYour Name 	arch_ops->dp_tx_compute_hw_delay = dp_tx_compute_tx_delay_rh;
958*5113495bSYour Name 	arch_ops->txrx_get_context_size = dp_get_context_size_rh;
959*5113495bSYour Name 	arch_ops->txrx_get_mon_context_size = dp_mon_get_context_size_rh;
960*5113495bSYour Name 	arch_ops->txrx_soc_attach = dp_soc_attach_rh;
961*5113495bSYour Name 	arch_ops->txrx_soc_detach = dp_soc_detach_rh;
962*5113495bSYour Name 	arch_ops->txrx_soc_init = dp_soc_init_rh;
963*5113495bSYour Name 	arch_ops->txrx_soc_deinit = dp_soc_deinit_rh;
964*5113495bSYour Name 	arch_ops->txrx_soc_srng_alloc = dp_soc_srng_alloc_rh;
965*5113495bSYour Name 	arch_ops->txrx_soc_srng_init = dp_soc_srng_init_rh;
966*5113495bSYour Name 	arch_ops->txrx_soc_srng_deinit = dp_soc_srng_deinit_rh;
967*5113495bSYour Name 	arch_ops->txrx_soc_srng_free = dp_soc_srng_free_rh;
968*5113495bSYour Name 	arch_ops->txrx_pdev_attach = dp_pdev_attach_rh;
969*5113495bSYour Name 	arch_ops->txrx_pdev_detach = dp_pdev_detach_rh;
970*5113495bSYour Name 	arch_ops->txrx_vdev_attach = dp_vdev_attach_rh;
971*5113495bSYour Name 	arch_ops->txrx_vdev_detach = dp_vdev_detach_rh;
972*5113495bSYour Name 	arch_ops->txrx_peer_map_attach = dp_peer_map_attach_rh;
973*5113495bSYour Name 	arch_ops->txrx_peer_map_detach = dp_peer_map_detach_rh;
974*5113495bSYour Name 	arch_ops->get_rx_hash_key = dp_get_rx_hash_key_rh;
975*5113495bSYour Name 	arch_ops->dp_rx_desc_cookie_2_va =
976*5113495bSYour Name 			dp_rx_desc_cookie_2_va_rh;
977*5113495bSYour Name 	arch_ops->dp_rx_intrabss_mcast_handler =
978*5113495bSYour Name 					dp_rx_intrabss_handle_nawds_rh;
979*5113495bSYour Name 	arch_ops->dp_rx_word_mask_subscribe = dp_rx_word_mask_subscribe_rh;
980*5113495bSYour Name 	arch_ops->dp_rxdma_ring_sel_cfg = dp_rxdma_ring_sel_cfg_rh;
981*5113495bSYour Name 	arch_ops->dp_rx_peer_metadata_peer_id_get =
982*5113495bSYour Name 					dp_rx_peer_metadata_peer_id_get_rh;
983*5113495bSYour Name 	arch_ops->soc_cfg_attach = dp_soc_cfg_attach_rh;
984*5113495bSYour Name 	arch_ops->tx_implicit_rbm_set = dp_tx_implicit_rbm_set_rh;
985*5113495bSYour Name 	arch_ops->txrx_set_vdev_param = dp_txrx_set_vdev_param_rh;
986*5113495bSYour Name 	arch_ops->txrx_print_peer_stats = dp_print_peer_txrx_stats_rh;
987*5113495bSYour Name 	arch_ops->dp_peer_rx_reorder_queue_setup =
988*5113495bSYour Name 					dp_peer_rx_reorder_queue_setup_rh;
989*5113495bSYour Name 	arch_ops->peer_get_reo_hash = dp_peer_get_reo_hash_rh;
990*5113495bSYour Name 	arch_ops->reo_remap_config = dp_reo_remap_config_rh;
991*5113495bSYour Name 	arch_ops->txrx_peer_setup = dp_peer_setup_rh;
992*5113495bSYour Name 	arch_ops->txrx_srng_init = dp_srng_init_rh;
993*5113495bSYour Name #if defined(DP_POWER_SAVE) || defined(FEATURE_RUNTIME_PM)
994*5113495bSYour Name 	arch_ops->dp_update_ring_hptp = dp_update_ring_hptp_rh;
995*5113495bSYour Name #endif
996*5113495bSYour Name 	arch_ops->dp_flush_tx_ring = dp_flush_tx_ring_rh;
997*5113495bSYour Name 	arch_ops->dp_soc_interrupt_attach = dp_soc_interrupt_attach_rh;
998*5113495bSYour Name 	arch_ops->dp_soc_attach_poll = dp_soc_attach_poll_rh;
999*5113495bSYour Name 	arch_ops->dp_soc_interrupt_detach = dp_soc_interrupt_detach_rh;
1000*5113495bSYour Name 	arch_ops->dp_service_srngs = dp_service_srngs_rh;
1001*5113495bSYour Name }
1002