xref: /wlan-driver/qca-wifi-host-cmn/dp/wifi3.0/li/dp_li.c (revision 5113495b16420b49004c444715d2daae2066e7dc) !
1 /*
2  * Copyright (c) 2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #include "dp_types.h"
21 #include "dp_rings.h"
22 #include <dp_internal.h>
23 #include <dp_htt.h>
24 #include "dp_li.h"
25 #include "dp_li_tx.h"
26 #include "dp_tx_desc.h"
27 #include "dp_li_rx.h"
28 #include "dp_peer.h"
29 #include <wlan_utility.h>
30 #include "dp_ipa.h"
31 #ifdef WIFI_MONITOR_SUPPORT
32 #include <dp_mon_1.0.h>
33 #endif
34 
35 #if defined(WLAN_MAX_PDEVS) && (WLAN_MAX_PDEVS == 1)
36 static struct wlan_cfg_tcl_wbm_ring_num_map g_tcl_wbm_map_array[MAX_TCL_DATA_RINGS] = {
37 	{.tcl_ring_num = 0, .wbm_ring_num = 0, .wbm_rbm_id = HAL_LI_WBM_SW0_BM_ID, .for_ipa = 0},
38 	/*
39 	 * INVALID_WBM_RING_NUM implies re-use of an existing WBM2SW ring
40 	 * as indicated by rbm id.
41 	 */
42 	{1, INVALID_WBM_RING_NUM, HAL_LI_WBM_SW0_BM_ID, 0},
43 	{2, 2, HAL_LI_WBM_SW2_BM_ID, 0}
44 };
45 #else
46 static struct wlan_cfg_tcl_wbm_ring_num_map g_tcl_wbm_map_array[MAX_TCL_DATA_RINGS] = {
47 	{.tcl_ring_num = 0, .wbm_ring_num = 0, .wbm_rbm_id = HAL_LI_WBM_SW0_BM_ID, .for_ipa = 0},
48 	{1, 1, HAL_LI_WBM_SW1_BM_ID, 0},
49 	{2, 2, HAL_LI_WBM_SW2_BM_ID, 0},
50 	/*
51 	 * Although using wbm_ring 4, wbm_ring 3 is mentioned in order to match
52 	 * with the tx_mask in dp_service_srngs. Please be careful while using
53 	 * this table anywhere else.
54 	 */
55 	{3, 3, HAL_LI_WBM_SW4_BM_ID, 0}
56 };
57 #endif
58 
59 #ifdef IPA_WDI3_TX_TWO_PIPES
60 static inline void
dp_soc_cfg_update_tcl_wbm_map_for_ipa(struct wlan_cfg_dp_soc_ctxt * cfg_ctx)61 dp_soc_cfg_update_tcl_wbm_map_for_ipa(struct wlan_cfg_dp_soc_ctxt *cfg_ctx)
62 {
63 	if (!cfg_ctx->ipa_enabled)
64 		return;
65 
66 	cfg_ctx->tcl_wbm_map_array[IPA_TX_ALT_RING_IDX].wbm_ring_num = 4;
67 	cfg_ctx->tcl_wbm_map_array[IPA_TX_ALT_RING_IDX].wbm_rbm_id =
68 							   HAL_LI_WBM_SW4_BM_ID;
69 }
70 #else
71 static inline void
dp_soc_cfg_update_tcl_wbm_map_for_ipa(struct wlan_cfg_dp_soc_ctxt * soc_cfg_ctx)72 dp_soc_cfg_update_tcl_wbm_map_for_ipa(struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx)
73 {
74 }
75 #endif
76 
dp_soc_cfg_attach_li(struct dp_soc * soc)77 static void dp_soc_cfg_attach_li(struct dp_soc *soc)
78 {
79 	struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx = soc->wlan_cfg_ctx;
80 
81 	dp_soc_cfg_attach(soc);
82 
83 	wlan_cfg_set_rx_rel_ring_id(soc_cfg_ctx, WBM2SW_REL_ERR_RING_NUM);
84 
85 	soc_cfg_ctx->tcl_wbm_map_array = g_tcl_wbm_map_array;
86 	dp_soc_cfg_update_tcl_wbm_map_for_ipa(soc_cfg_ctx);
87 }
88 
dp_get_context_size_li(enum dp_context_type context_type)89 qdf_size_t dp_get_context_size_li(enum dp_context_type context_type)
90 {
91 	switch (context_type) {
92 	case DP_CONTEXT_TYPE_SOC:
93 		return sizeof(struct dp_soc_li);
94 	case DP_CONTEXT_TYPE_PDEV:
95 		return sizeof(struct dp_pdev_li);
96 	case DP_CONTEXT_TYPE_VDEV:
97 		return sizeof(struct dp_vdev_li);
98 	case DP_CONTEXT_TYPE_PEER:
99 		return sizeof(struct dp_peer_li);
100 	default:
101 		return 0;
102 	}
103 }
104 
dp_soc_attach_li(struct dp_soc * soc,struct cdp_soc_attach_params * params)105 static QDF_STATUS dp_soc_attach_li(struct dp_soc *soc,
106 				   struct cdp_soc_attach_params *params)
107 {
108 	soc->wbm_sw0_bm_id = hal_tx_get_wbm_sw0_bm_id();
109 
110 	return QDF_STATUS_SUCCESS;
111 }
112 
dp_soc_detach_li(struct dp_soc * soc)113 static QDF_STATUS dp_soc_detach_li(struct dp_soc *soc)
114 {
115 	return QDF_STATUS_SUCCESS;
116 }
117 
dp_soc_interrupt_attach_li(struct cdp_soc_t * txrx_soc)118 static QDF_STATUS dp_soc_interrupt_attach_li(struct cdp_soc_t *txrx_soc)
119 {
120 	return dp_soc_interrupt_attach(txrx_soc);
121 }
122 
dp_soc_attach_poll_li(struct cdp_soc_t * txrx_soc)123 static QDF_STATUS dp_soc_attach_poll_li(struct cdp_soc_t *txrx_soc)
124 {
125 	return dp_soc_attach_poll(txrx_soc);
126 }
127 
dp_soc_interrupt_detach_li(struct cdp_soc_t * txrx_soc)128 static void dp_soc_interrupt_detach_li(struct cdp_soc_t *txrx_soc)
129 {
130 	return dp_soc_interrupt_detach(txrx_soc);
131 }
132 
dp_service_srngs_li(void * dp_ctx,uint32_t dp_budget,int cpu)133 static uint32_t dp_service_srngs_li(void *dp_ctx, uint32_t dp_budget, int cpu)
134 {
135 	return dp_service_srngs(dp_ctx, dp_budget, cpu);
136 }
137 
dp_soc_init_li(struct dp_soc * soc,HTC_HANDLE htc_handle,struct hif_opaque_softc * hif_handle)138 static void *dp_soc_init_li(struct dp_soc *soc, HTC_HANDLE htc_handle,
139 			    struct hif_opaque_softc *hif_handle)
140 {
141 	wlan_minidump_log(soc, sizeof(*soc), soc->ctrl_psoc,
142 			  WLAN_MD_DP_SOC, "dp_soc");
143 
144 	soc->hif_handle = hif_handle;
145 
146 	soc->hal_soc = hif_get_hal_handle(soc->hif_handle);
147 	if (!soc->hal_soc)
148 		return NULL;
149 
150 	return dp_soc_init(soc, htc_handle, hif_handle);
151 }
152 
dp_soc_deinit_li(struct dp_soc * soc)153 static QDF_STATUS dp_soc_deinit_li(struct dp_soc *soc)
154 {
155 	qdf_atomic_set(&soc->cmn_init_done, 0);
156 
157 	dp_soc_deinit(soc);
158 
159 	return QDF_STATUS_SUCCESS;
160 }
161 
dp_pdev_attach_li(struct dp_pdev * pdev,struct cdp_pdev_attach_params * params)162 static QDF_STATUS dp_pdev_attach_li(struct dp_pdev *pdev,
163 				    struct cdp_pdev_attach_params *params)
164 {
165 	return QDF_STATUS_SUCCESS;
166 }
167 
dp_pdev_detach_li(struct dp_pdev * pdev)168 static QDF_STATUS dp_pdev_detach_li(struct dp_pdev *pdev)
169 {
170 	return QDF_STATUS_SUCCESS;
171 }
172 
dp_vdev_attach_li(struct dp_soc * soc,struct dp_vdev * vdev)173 static QDF_STATUS dp_vdev_attach_li(struct dp_soc *soc, struct dp_vdev *vdev)
174 {
175 	return QDF_STATUS_SUCCESS;
176 }
177 
dp_vdev_detach_li(struct dp_soc * soc,struct dp_vdev * vdev)178 static QDF_STATUS dp_vdev_detach_li(struct dp_soc *soc, struct dp_vdev *vdev)
179 {
180 	return QDF_STATUS_SUCCESS;
181 }
182 
183 #ifdef AST_OFFLOAD_ENABLE
dp_peer_map_detach_li(struct dp_soc * soc)184 static void dp_peer_map_detach_li(struct dp_soc *soc)
185 {
186 	dp_soc_wds_detach(soc);
187 	dp_peer_ast_table_detach(soc);
188 	dp_peer_ast_hash_detach(soc);
189 	dp_peer_mec_hash_detach(soc);
190 }
191 
dp_peer_map_attach_li(struct dp_soc * soc)192 static QDF_STATUS dp_peer_map_attach_li(struct dp_soc *soc)
193 {
194 	QDF_STATUS status;
195 
196 	soc->max_peer_id = soc->max_peers;
197 
198 	status = dp_peer_ast_table_attach(soc);
199 	if (!QDF_IS_STATUS_SUCCESS(status))
200 		return status;
201 
202 	status = dp_peer_ast_hash_attach(soc);
203 	if (!QDF_IS_STATUS_SUCCESS(status))
204 		goto ast_table_detach;
205 
206 	status = dp_peer_mec_hash_attach(soc);
207 	if (!QDF_IS_STATUS_SUCCESS(status))
208 		goto hash_detach;
209 
210 	dp_soc_wds_attach(soc);
211 
212 	return QDF_STATUS_SUCCESS;
213 
214 hash_detach:
215 	dp_peer_ast_hash_detach(soc);
216 ast_table_detach:
217 	dp_peer_ast_table_detach(soc);
218 
219 	return status;
220 }
221 #else
dp_peer_map_detach_li(struct dp_soc * soc)222 static void dp_peer_map_detach_li(struct dp_soc *soc)
223 {
224 }
225 
dp_peer_map_attach_li(struct dp_soc * soc)226 static QDF_STATUS dp_peer_map_attach_li(struct dp_soc *soc)
227 {
228 	soc->max_peer_id = soc->max_peers;
229 
230 	return QDF_STATUS_SUCCESS;
231 }
232 #endif
233 
dp_peer_setup_li(struct cdp_soc_t * soc_hdl,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_peer_setup_info * setup_info)234 static QDF_STATUS dp_peer_setup_li(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
235 				   uint8_t *peer_mac,
236 				   struct cdp_peer_setup_info *setup_info)
237 {
238 	return dp_peer_setup_wifi3(soc_hdl, vdev_id, peer_mac, setup_info);
239 }
240 
dp_get_soc_context_size_li(void)241 qdf_size_t dp_get_soc_context_size_li(void)
242 {
243 	return sizeof(struct dp_soc);
244 }
245 
246 #ifdef NO_RX_PKT_HDR_TLV
247 /**
248  * dp_rxdma_ring_sel_cfg_li() - Setup RXDMA ring config
249  * @soc: Common DP soc handle
250  *
251  * Return: QDF_STATUS
252  */
253 static QDF_STATUS
dp_rxdma_ring_sel_cfg_li(struct dp_soc * soc)254 dp_rxdma_ring_sel_cfg_li(struct dp_soc *soc)
255 {
256 	int i;
257 	int mac_id;
258 	struct htt_rx_ring_tlv_filter htt_tlv_filter = {0};
259 	struct dp_srng *rx_mac_srng;
260 	QDF_STATUS status = QDF_STATUS_SUCCESS;
261 	uint32_t target_type = hal_get_target_type(soc->hal_soc);
262 	uint16_t buf_size;
263 
264 	buf_size = wlan_cfg_rx_buffer_size(soc->wlan_cfg_ctx);
265 
266 	if (target_type == TARGET_TYPE_QCN9160)
267 		return status;
268 
269 	htt_tlv_filter.mpdu_start = 1;
270 	htt_tlv_filter.msdu_start = 1;
271 	htt_tlv_filter.mpdu_end = 1;
272 	htt_tlv_filter.msdu_end = 1;
273 	htt_tlv_filter.attention = 1;
274 	htt_tlv_filter.packet = 1;
275 	htt_tlv_filter.packet_header = 0;
276 
277 	htt_tlv_filter.ppdu_start = 0;
278 	htt_tlv_filter.ppdu_end = 0;
279 	htt_tlv_filter.ppdu_end_user_stats = 0;
280 	htt_tlv_filter.ppdu_end_user_stats_ext = 0;
281 	htt_tlv_filter.ppdu_end_status_done = 0;
282 	htt_tlv_filter.enable_fp = 1;
283 	htt_tlv_filter.enable_md = 0;
284 	htt_tlv_filter.enable_md = 0;
285 	htt_tlv_filter.enable_mo = 0;
286 
287 	htt_tlv_filter.fp_mgmt_filter = 0;
288 	htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_BA_REQ;
289 	htt_tlv_filter.fp_data_filter = (FILTER_DATA_UCAST |
290 					 FILTER_DATA_MCAST |
291 					 FILTER_DATA_DATA);
292 	htt_tlv_filter.mo_mgmt_filter = 0;
293 	htt_tlv_filter.mo_ctrl_filter = 0;
294 	htt_tlv_filter.mo_data_filter = 0;
295 	htt_tlv_filter.md_data_filter = 0;
296 
297 	htt_tlv_filter.offset_valid = true;
298 
299 	htt_tlv_filter.rx_packet_offset = soc->rx_pkt_tlv_size;
300 	/*Not subscribing rx_pkt_header*/
301 	htt_tlv_filter.rx_header_offset = 0;
302 	htt_tlv_filter.rx_mpdu_start_offset =
303 				hal_rx_mpdu_start_offset_get(soc->hal_soc);
304 	htt_tlv_filter.rx_mpdu_end_offset =
305 				hal_rx_mpdu_end_offset_get(soc->hal_soc);
306 	htt_tlv_filter.rx_msdu_start_offset =
307 				hal_rx_msdu_start_offset_get(soc->hal_soc);
308 	htt_tlv_filter.rx_msdu_end_offset =
309 				hal_rx_msdu_end_offset_get(soc->hal_soc);
310 	htt_tlv_filter.rx_attn_offset =
311 				hal_rx_attn_offset_get(soc->hal_soc);
312 
313 	for (i = 0; i < MAX_PDEV_CNT; i++) {
314 		struct dp_pdev *pdev = soc->pdev_list[i];
315 
316 		if (!pdev)
317 			continue;
318 
319 		for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
320 			int mac_for_pdev =
321 				dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
322 			/*
323 			 * Obtain lmac id from pdev to access the LMAC ring
324 			 * in soc context
325 			 */
326 			int lmac_id =
327 				dp_get_lmac_id_for_pdev_id(soc, mac_id,
328 							   pdev->pdev_id);
329 
330 			rx_mac_srng = dp_get_rxdma_ring(pdev, lmac_id);
331 			htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
332 					    rx_mac_srng->hal_srng,
333 					    RXDMA_BUF, buf_size,
334 					    &htt_tlv_filter);
335 		}
336 	}
337 	return status;
338 }
339 #else
340 
341 static QDF_STATUS
dp_rxdma_ring_sel_cfg_li(struct dp_soc * soc)342 dp_rxdma_ring_sel_cfg_li(struct dp_soc *soc)
343 {
344 	int i;
345 	int mac_id;
346 	struct htt_rx_ring_tlv_filter htt_tlv_filter = {0};
347 	struct dp_srng *rx_mac_srng;
348 	QDF_STATUS status = QDF_STATUS_SUCCESS;
349 	uint32_t target_type = hal_get_target_type(soc->hal_soc);
350 	uint16_t buf_size;
351 
352 	buf_size = wlan_cfg_rx_buffer_size(soc->wlan_cfg_ctx);
353 
354 	if (target_type == TARGET_TYPE_QCN9160)
355 		return status;
356 
357 	htt_tlv_filter.mpdu_start = 1;
358 	htt_tlv_filter.msdu_start = 1;
359 	htt_tlv_filter.mpdu_end = 1;
360 	htt_tlv_filter.msdu_end = 1;
361 	htt_tlv_filter.attention = 1;
362 	htt_tlv_filter.packet = 1;
363 	htt_tlv_filter.packet_header = 1;
364 
365 	htt_tlv_filter.ppdu_start = 0;
366 	htt_tlv_filter.ppdu_end = 0;
367 	htt_tlv_filter.ppdu_end_user_stats = 0;
368 	htt_tlv_filter.ppdu_end_user_stats_ext = 0;
369 	htt_tlv_filter.ppdu_end_status_done = 0;
370 	htt_tlv_filter.enable_fp = 1;
371 	htt_tlv_filter.enable_md = 0;
372 	htt_tlv_filter.enable_md = 0;
373 	htt_tlv_filter.enable_mo = 0;
374 
375 	htt_tlv_filter.fp_mgmt_filter = 0;
376 	htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_BA_REQ;
377 	htt_tlv_filter.fp_data_filter = (FILTER_DATA_UCAST |
378 					 FILTER_DATA_MCAST |
379 					 FILTER_DATA_DATA);
380 	htt_tlv_filter.mo_mgmt_filter = 0;
381 	htt_tlv_filter.mo_ctrl_filter = 0;
382 	htt_tlv_filter.mo_data_filter = 0;
383 	htt_tlv_filter.md_data_filter = 0;
384 
385 	htt_tlv_filter.offset_valid = true;
386 
387 	htt_tlv_filter.rx_packet_offset = soc->rx_pkt_tlv_size;
388 	htt_tlv_filter.rx_header_offset =
389 				hal_rx_pkt_tlv_offset_get(soc->hal_soc);
390 	htt_tlv_filter.rx_mpdu_start_offset =
391 				hal_rx_mpdu_start_offset_get(soc->hal_soc);
392 	htt_tlv_filter.rx_mpdu_end_offset =
393 				hal_rx_mpdu_end_offset_get(soc->hal_soc);
394 	htt_tlv_filter.rx_msdu_start_offset =
395 				hal_rx_msdu_start_offset_get(soc->hal_soc);
396 	htt_tlv_filter.rx_msdu_end_offset =
397 				hal_rx_msdu_end_offset_get(soc->hal_soc);
398 	htt_tlv_filter.rx_attn_offset =
399 				hal_rx_attn_offset_get(soc->hal_soc);
400 
401 	for (i = 0; i < MAX_PDEV_CNT; i++) {
402 		struct dp_pdev *pdev = soc->pdev_list[i];
403 
404 		if (!pdev)
405 			continue;
406 
407 		for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
408 			int mac_for_pdev =
409 				dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
410 			/*
411 			 * Obtain lmac id from pdev to access the LMAC ring
412 			 * in soc context
413 			 */
414 			int lmac_id =
415 				dp_get_lmac_id_for_pdev_id(soc, mac_id,
416 							   pdev->pdev_id);
417 
418 			rx_mac_srng = dp_get_rxdma_ring(pdev, lmac_id);
419 			htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
420 					    rx_mac_srng->hal_srng,
421 					    RXDMA_BUF, buf_size,
422 					    &htt_tlv_filter);
423 		}
424 	}
425 	return status;
426 
427 }
428 #endif
429 
430 static inline
dp_srng_init_li(struct dp_soc * soc,struct dp_srng * srng,int ring_type,int ring_num,int mac_id)431 QDF_STATUS dp_srng_init_li(struct dp_soc *soc, struct dp_srng *srng,
432 			   int ring_type, int ring_num, int mac_id)
433 {
434 	return dp_srng_init_idx(soc, srng, ring_type, ring_num, mac_id, 0);
435 }
436 
437 #ifdef QCA_DP_ENABLE_TX_COMP_RING4
438 static inline
dp_deinit_txcomp_ring4(struct dp_soc * soc)439 void dp_deinit_txcomp_ring4(struct dp_soc *soc)
440 {
441 	if (soc) {
442 		wlan_minidump_remove(soc->tx_comp_ring[3].base_vaddr_unaligned,
443 				     soc->tx_comp_ring[3].alloc_size,
444 				     soc->ctrl_psoc, WLAN_MD_DP_SRNG_TX_COMP,
445 				     "Transmit_completion_ring");
446 		dp_srng_deinit(soc, &soc->tx_comp_ring[3], WBM2SW_RELEASE, 0);
447 	}
448 }
449 
450 static inline
dp_init_txcomp_ring4(struct dp_soc * soc)451 QDF_STATUS dp_init_txcomp_ring4(struct dp_soc *soc)
452 {
453 	if (soc) {
454 		if (dp_srng_init(soc, &soc->tx_comp_ring[3],
455 				 WBM2SW_RELEASE, WBM2SW_TXCOMP_RING4_NUM, 0)) {
456 			dp_err("%pK: dp_srng_init failed for rx_rel_ring",
457 			       soc);
458 			return QDF_STATUS_E_FAILURE;
459 		}
460 		wlan_minidump_log(soc->tx_comp_ring[3].base_vaddr_unaligned,
461 				  soc->tx_comp_ring[3].alloc_size,
462 				  soc->ctrl_psoc, WLAN_MD_DP_SRNG_TX_COMP,
463 				  "Transmit_completion_ring");
464 	}
465 	return QDF_STATUS_SUCCESS;
466 }
467 
468 static inline
dp_free_txcomp_ring4(struct dp_soc * soc)469 void dp_free_txcomp_ring4(struct dp_soc *soc)
470 {
471 	if (soc)
472 		dp_srng_free(soc, &soc->tx_comp_ring[3]);
473 }
474 
475 static inline
dp_alloc_txcomp_ring4(struct dp_soc * soc,uint32_t tx_comp_ring_size,uint32_t cached)476 QDF_STATUS dp_alloc_txcomp_ring4(struct dp_soc *soc, uint32_t tx_comp_ring_size,
477 				 uint32_t cached)
478 {
479 	if (soc) {
480 		if (dp_srng_alloc(soc, &soc->tx_comp_ring[3], WBM2SW_RELEASE,
481 				  tx_comp_ring_size, cached)) {
482 			dp_err("dp_srng_alloc failed for tx_comp_ring");
483 			return QDF_STATUS_E_FAILURE;
484 		}
485 	}
486 	return QDF_STATUS_SUCCESS;
487 }
488 #else
489 static inline
dp_deinit_txcomp_ring4(struct dp_soc * soc)490 void dp_deinit_txcomp_ring4(struct dp_soc *soc)
491 {
492 }
493 
494 static inline
dp_init_txcomp_ring4(struct dp_soc * soc)495 QDF_STATUS dp_init_txcomp_ring4(struct dp_soc *soc)
496 {
497 	return QDF_STATUS_SUCCESS;
498 }
499 
500 static inline
dp_free_txcomp_ring4(struct dp_soc * soc)501 void dp_free_txcomp_ring4(struct dp_soc *soc)
502 {
503 }
504 
505 static inline
dp_alloc_txcomp_ring4(struct dp_soc * soc,uint32_t tx_comp_ring_size,uint32_t cached)506 QDF_STATUS dp_alloc_txcomp_ring4(struct dp_soc *soc, uint32_t tx_comp_ring_size,
507 				 uint32_t cached)
508 {
509 	return QDF_STATUS_SUCCESS;
510 }
511 #endif
512 
dp_soc_srng_deinit_li(struct dp_soc * soc)513 static void dp_soc_srng_deinit_li(struct dp_soc *soc)
514 {
515 	/* Tx Complete ring */
516 	dp_deinit_txcomp_ring4(soc);
517 }
518 
dp_soc_srng_free_li(struct dp_soc * soc)519 static void dp_soc_srng_free_li(struct dp_soc *soc)
520 {
521 	dp_free_txcomp_ring4(soc);
522 }
523 
dp_soc_srng_alloc_li(struct dp_soc * soc)524 static QDF_STATUS dp_soc_srng_alloc_li(struct dp_soc *soc)
525 {
526 	uint32_t tx_comp_ring_size;
527 	uint32_t cached = WLAN_CFG_DST_RING_CACHED_DESC;
528 	struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
529 
530 	soc_cfg_ctx = soc->wlan_cfg_ctx;
531 
532 	tx_comp_ring_size = wlan_cfg_tx_comp_ring_size(soc_cfg_ctx);
533 	/* Disable cached desc if NSS offload is enabled */
534 	if (wlan_cfg_get_dp_soc_nss_cfg(soc_cfg_ctx))
535 		cached = 0;
536 
537 	if (dp_alloc_txcomp_ring4(soc, tx_comp_ring_size, cached))
538 		goto fail1;
539 	return QDF_STATUS_SUCCESS;
540 fail1:
541 	dp_soc_srng_free_li(soc);
542 	return QDF_STATUS_E_NOMEM;
543 }
544 
dp_soc_srng_init_li(struct dp_soc * soc)545 static QDF_STATUS dp_soc_srng_init_li(struct dp_soc *soc)
546 {
547 	/* Tx comp ring 3 */
548 	if (dp_init_txcomp_ring4(soc))
549 		goto fail1;
550 
551 	return QDF_STATUS_SUCCESS;
552 fail1:
553 	/*
554 	 * Cleanup will be done as part of soc_detach, which will
555 	 * be called on pdev attach failure
556 	 */
557 	dp_soc_srng_deinit_li(soc);
558 	return QDF_STATUS_E_FAILURE;
559 }
560 
dp_tx_implicit_rbm_set_li(struct dp_soc * soc,uint8_t tx_ring_id,uint8_t bm_id)561 static void dp_tx_implicit_rbm_set_li(struct dp_soc *soc,
562 				      uint8_t tx_ring_id,
563 				      uint8_t bm_id)
564 {
565 }
566 
dp_txrx_set_vdev_param_li(struct dp_soc * soc,struct dp_vdev * vdev,enum cdp_vdev_param_type param,cdp_config_param_type val)567 static QDF_STATUS dp_txrx_set_vdev_param_li(struct dp_soc *soc,
568 					    struct dp_vdev *vdev,
569 					    enum cdp_vdev_param_type param,
570 					    cdp_config_param_type val)
571 {
572 	return QDF_STATUS_SUCCESS;
573 }
574 
575 bool
dp_rx_intrabss_handle_nawds_li(struct dp_soc * soc,struct dp_txrx_peer * ta_peer,qdf_nbuf_t nbuf_copy,struct cdp_tid_rx_stats * tid_stats,uint8_t link_id)576 dp_rx_intrabss_handle_nawds_li(struct dp_soc *soc, struct dp_txrx_peer *ta_peer,
577 			       qdf_nbuf_t nbuf_copy,
578 			       struct cdp_tid_rx_stats *tid_stats,
579 			       uint8_t link_id)
580 {
581 	return false;
582 }
583 
dp_rx_word_mask_subscribe_li(struct dp_soc * soc,uint32_t * msg_word,void * rx_filter)584 static void dp_rx_word_mask_subscribe_li(struct dp_soc *soc,
585 					 uint32_t *msg_word,
586 					 void *rx_filter)
587 {
588 }
589 
dp_get_rx_hash_key_li(struct dp_soc * soc,struct cdp_lro_hash_config * lro_hash)590 static void dp_get_rx_hash_key_li(struct dp_soc *soc,
591 				  struct cdp_lro_hash_config *lro_hash)
592 {
593 	dp_get_rx_hash_key_bytes(lro_hash);
594 }
595 
dp_peer_get_reo_hash_li(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)596 static void dp_peer_get_reo_hash_li(struct dp_vdev *vdev,
597 				    struct cdp_peer_setup_info *setup_info,
598 				    enum cdp_host_reo_dest_ring *reo_dest,
599 				    bool *hash_based,
600 				    uint8_t *lmac_peer_id_msb)
601 {
602 	dp_vdev_get_default_reo_hash(vdev, reo_dest, hash_based);
603 }
604 
dp_reo_remap_config_li(struct dp_soc * soc,uint32_t * remap0,uint32_t * remap1,uint32_t * remap2)605 static bool dp_reo_remap_config_li(struct dp_soc *soc,
606 				   uint32_t *remap0,
607 				   uint32_t *remap1,
608 				   uint32_t *remap2)
609 {
610 	return dp_reo_remap_config(soc, remap0, remap1, remap2);
611 }
612 
dp_soc_get_num_soc_li(struct dp_soc * soc)613 static uint8_t dp_soc_get_num_soc_li(struct dp_soc *soc)
614 {
615 	return 1;
616 }
617 
dp_txrx_get_vdev_mcast_param_li(struct dp_soc * soc,struct dp_vdev * vdev,cdp_config_param_type * val)618 static QDF_STATUS dp_txrx_get_vdev_mcast_param_li(struct dp_soc *soc,
619 						  struct dp_vdev *vdev,
620 						  cdp_config_param_type *val)
621 {
622 	return QDF_STATUS_SUCCESS;
623 }
624 
dp_get_hw_link_id_li(struct dp_pdev * pdev)625 static uint8_t dp_get_hw_link_id_li(struct dp_pdev *pdev)
626 {
627 	return 0;
628 }
629 
dp_get_vdev_stats_for_unmap_peer_li(struct dp_vdev * vdev,struct dp_peer * peer)630 static void dp_get_vdev_stats_for_unmap_peer_li(
631 					struct dp_vdev *vdev,
632 					struct dp_peer *peer)
633 {
634 	dp_get_vdev_stats_for_unmap_peer_legacy(vdev, peer);
635 }
636 
637 static struct
dp_get_soc_by_chip_id_li(struct dp_soc * soc,uint8_t chip_id)638 dp_soc *dp_get_soc_by_chip_id_li(struct dp_soc *soc,
639 				 uint8_t chip_id)
640 {
641 	return soc;
642 }
643 
dp_initialize_arch_ops_li(struct dp_arch_ops * arch_ops)644 void dp_initialize_arch_ops_li(struct dp_arch_ops *arch_ops)
645 {
646 #ifndef QCA_HOST_MODE_WIFI_DISABLED
647 	arch_ops->tx_hw_enqueue = dp_tx_hw_enqueue_li;
648 	arch_ops->dp_rx_process = dp_rx_process_li;
649 	arch_ops->dp_tx_send_fast = dp_tx_send;
650 	arch_ops->tx_comp_get_params_from_hal_desc =
651 		dp_tx_comp_get_params_from_hal_desc_li;
652 	arch_ops->dp_tx_process_htt_completion =
653 			dp_tx_process_htt_completion_li;
654 	arch_ops->dp_wbm_get_rx_desc_from_hal_desc =
655 			dp_wbm_get_rx_desc_from_hal_desc_li;
656 	arch_ops->dp_tx_desc_pool_alloc = dp_tx_desc_pool_alloc_li;
657 	arch_ops->dp_tx_desc_pool_free = dp_tx_desc_pool_free_li;
658 	arch_ops->dp_tx_desc_pool_init = dp_tx_desc_pool_init_li;
659 	arch_ops->dp_tx_desc_pool_deinit = dp_tx_desc_pool_deinit_li;
660 	arch_ops->dp_rx_desc_pool_init = dp_rx_desc_pool_init_li;
661 	arch_ops->dp_rx_desc_pool_deinit = dp_rx_desc_pool_deinit_li;
662 	arch_ops->dp_tx_compute_hw_delay = dp_tx_compute_tx_delay_li;
663 	arch_ops->dp_rx_chain_msdus = dp_rx_chain_msdus_li;
664 	arch_ops->dp_rx_wbm_err_reap_desc = dp_rx_wbm_err_reap_desc_li;
665 	arch_ops->dp_rx_null_q_desc_handle = dp_rx_null_q_desc_handle_li;
666 #else
667 	arch_ops->dp_rx_desc_pool_init = dp_rx_desc_pool_init_generic;
668 	arch_ops->dp_rx_desc_pool_deinit = dp_rx_desc_pool_deinit_generic;
669 #endif
670 	arch_ops->txrx_get_context_size = dp_get_context_size_li;
671 #ifdef WIFI_MONITOR_SUPPORT
672 	arch_ops->txrx_get_mon_context_size = dp_mon_get_context_size_li;
673 #endif
674 	arch_ops->txrx_soc_attach = dp_soc_attach_li;
675 	arch_ops->txrx_soc_detach = dp_soc_detach_li;
676 	arch_ops->txrx_soc_init = dp_soc_init_li;
677 	arch_ops->txrx_soc_deinit = dp_soc_deinit_li;
678 	arch_ops->txrx_soc_srng_alloc = dp_soc_srng_alloc_li;
679 	arch_ops->txrx_soc_srng_init = dp_soc_srng_init_li;
680 	arch_ops->txrx_soc_srng_deinit = dp_soc_srng_deinit_li;
681 	arch_ops->txrx_soc_srng_free = dp_soc_srng_free_li;
682 	arch_ops->txrx_pdev_attach = dp_pdev_attach_li;
683 	arch_ops->txrx_pdev_detach = dp_pdev_detach_li;
684 	arch_ops->txrx_vdev_attach = dp_vdev_attach_li;
685 	arch_ops->txrx_vdev_detach = dp_vdev_detach_li;
686 	arch_ops->txrx_peer_map_attach = dp_peer_map_attach_li;
687 	arch_ops->txrx_peer_map_detach = dp_peer_map_detach_li;
688 	arch_ops->get_rx_hash_key = dp_get_rx_hash_key_li;
689 	arch_ops->dp_set_rx_fst = NULL;
690 	arch_ops->dp_get_rx_fst = NULL;
691 	arch_ops->dp_rx_fst_ref = NULL;
692 	arch_ops->dp_rx_fst_deref = NULL;
693 	arch_ops->txrx_peer_setup = dp_peer_setup_li;
694 	arch_ops->dp_rx_desc_cookie_2_va =
695 			dp_rx_desc_cookie_2_va_li;
696 	arch_ops->dp_rx_intrabss_mcast_handler =
697 					dp_rx_intrabss_handle_nawds_li;
698 	arch_ops->dp_rx_word_mask_subscribe = dp_rx_word_mask_subscribe_li;
699 	arch_ops->dp_rxdma_ring_sel_cfg = dp_rxdma_ring_sel_cfg_li;
700 	arch_ops->dp_rx_peer_metadata_peer_id_get =
701 					dp_rx_peer_metadata_peer_id_get_li;
702 	arch_ops->soc_cfg_attach = dp_soc_cfg_attach_li;
703 	arch_ops->tx_implicit_rbm_set = dp_tx_implicit_rbm_set_li;
704 	arch_ops->txrx_set_vdev_param = dp_txrx_set_vdev_param_li;
705 	arch_ops->txrx_print_peer_stats = dp_print_peer_txrx_stats_li;
706 	arch_ops->dp_peer_rx_reorder_queue_setup =
707 					dp_peer_rx_reorder_queue_setup_li;
708 	arch_ops->peer_get_reo_hash = dp_peer_get_reo_hash_li;
709 	arch_ops->reo_remap_config = dp_reo_remap_config_li;
710 	arch_ops->dp_get_soc_by_chip_id = dp_get_soc_by_chip_id_li;
711 	arch_ops->dp_soc_get_num_soc = dp_soc_get_num_soc_li;
712 	arch_ops->get_reo_qdesc_addr = dp_rx_get_reo_qdesc_addr_li;
713 	arch_ops->txrx_get_vdev_mcast_param = dp_txrx_get_vdev_mcast_param_li;
714 	arch_ops->get_hw_link_id = dp_get_hw_link_id_li;
715 	arch_ops->txrx_srng_init = dp_srng_init_li;
716 	arch_ops->dp_get_vdev_stats_for_unmap_peer =
717 					dp_get_vdev_stats_for_unmap_peer_li;
718 	arch_ops->dp_get_interface_stats = dp_txrx_get_vdev_stats;
719 #if defined(DP_POWER_SAVE) || defined(FEATURE_RUNTIME_PM)
720 	arch_ops->dp_update_ring_hptp = dp_update_ring_hptp;
721 #endif
722 	arch_ops->dp_flush_tx_ring = dp_flush_tcl_ring;
723 	arch_ops->dp_soc_interrupt_attach = dp_soc_interrupt_attach_li;
724 	arch_ops->dp_soc_attach_poll = dp_soc_attach_poll_li;
725 	arch_ops->dp_soc_interrupt_detach = dp_soc_interrupt_detach_li;
726 	arch_ops->dp_service_srngs = dp_service_srngs_li;
727 }
728 
729 #ifdef QCA_DP_TX_HW_SW_NBUF_DESC_PREFETCH
dp_tx_comp_get_prefetched_params_from_hal_desc(struct dp_soc * soc,void * tx_comp_hal_desc,struct dp_tx_desc_s ** r_tx_desc)730 void dp_tx_comp_get_prefetched_params_from_hal_desc(
731 					struct dp_soc *soc,
732 					void *tx_comp_hal_desc,
733 					struct dp_tx_desc_s **r_tx_desc)
734 {
735 	uint8_t pool_id;
736 	uint32_t tx_desc_id;
737 
738 	tx_desc_id = hal_tx_comp_get_desc_id(tx_comp_hal_desc);
739 	pool_id = (tx_desc_id & DP_TX_DESC_ID_POOL_MASK) >>
740 		DP_TX_DESC_ID_POOL_OS;
741 
742 	/* Find Tx descriptor */
743 	*r_tx_desc = dp_tx_desc_find(soc, pool_id,
744 			(tx_desc_id & DP_TX_DESC_ID_PAGE_MASK) >>
745 			DP_TX_DESC_ID_PAGE_OS,
746 			(tx_desc_id & DP_TX_DESC_ID_OFFSET_MASK) >>
747 			DP_TX_DESC_ID_OFFSET_OS,
748 			(tx_desc_id & DP_TX_DESC_ID_SPCL_MASK));
749 	qdf_prefetch((uint8_t *)*r_tx_desc);
750 }
751 #endif
752