1 /*
2  * Copyright (c) 2017-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 /**
21  * DOC: API for interacting with target interface.
22  *
23  */
24 
25 #include "target_if.h"
26 #include "target_type.h"
27 #ifdef WLAN_ATF_ENABLE
28 #include "target_if_atf.h"
29 #endif
30 #ifdef WLAN_SA_API_ENABLE
31 #include "target_if_sa_api.h"
32 #endif
33 #ifdef WLAN_CFR_ENABLE
34 #include "target_if_cfr.h"
35 #endif
36 #ifdef WLAN_CONV_SPECTRAL_ENABLE
37 #include "target_if_spectral.h"
38 #endif
39 
40 #ifdef WLAN_IOT_SIM_SUPPORT
41 #include <target_if_iot_sim.h>
42 #endif
43 #include <target_if_reg.h>
44 #include <target_if_scan.h>
45 #include <target_if_ftm.h>
46 #ifdef DFS_COMPONENT_ENABLE
47 #include <target_if_dfs.h>
48 #endif
49 
50 #ifdef CONVERGED_P2P_ENABLE
51 #include "target_if_p2p.h"
52 #endif
53 
54 #ifdef WIFI_POS_CONVERGED
55 #include "target_if_wifi_pos.h"
56 #include "target_if_wifi_pos_rx_ops.h"
57 #include "target_if_wifi_pos_tx_ops.h"
58 #endif
59 
60 #ifdef FEATURE_WLAN_TDLS
61 #include "target_if_tdls.h"
62 #endif
63 #if defined(QCA_SUPPORT_SON) || defined(WLAN_FEATURE_SON)
64 #include <target_if_son.h>
65 #endif
66 #if defined WLAN_FEATURE_11AX
67 #include <target_if_spatial_reuse.h>
68 #endif
69 #ifdef WLAN_OFFCHAN_TXRX_ENABLE
70 #include <target_if_offchan_txrx_api.h>
71 #endif
72 #ifdef WLAN_SUPPORT_GREEN_AP
73 #include <target_if_green_ap.h>
74 #endif
75 #include <init_deinit_lmac.h>
76 #include <service_ready_util.h>
77 
78 #ifdef DIRECT_BUF_RX_ENABLE
79 #include <target_if_direct_buf_rx_api.h>
80 #endif
81 
82 #ifdef WLAN_SUPPORT_FILS
83 #include <target_if_fd.h>
84 #endif
85 #include "qdf_module.h"
86 
87 #include <target_if_cp_stats.h>
88 #ifdef CRYPTO_SET_KEY_CONVERGED
89 #include <target_if_crypto.h>
90 #endif
91 #include <target_if_vdev_mgr_tx_ops.h>
92 
93 #ifdef FEATURE_COEX
94 #include <target_if_coex.h>
95 #endif
96 #include <wlan_utility.h>
97 
98 #ifdef DCS_INTERFERENCE_DETECTION
99 #include <target_if_dcs.h>
100 #endif
101 
102 #include <target_if_gpio.h>
103 #ifdef IPA_OFFLOAD
104 #include <target_if_ipa.h>
105 #endif
106 
107 #ifdef WLAN_MGMT_RX_REO_SUPPORT
108 #include <target_if_mgmt_txrx.h>
109 #endif /* WLAN_MGMT_RX_REO_SUPPORT */
110 
111 #include "wmi_unified_api.h"
112 #include <target_if_twt.h>
113 
114 #include <target_if_mlo_mgr.h>
115 
116 #ifdef WLAN_FEATURE_COAP
117 #include <target_if_coap.h>
118 #endif
119 
120 static struct target_if_ctx *g_target_if_ctx;
121 
target_if_get_ctx(void)122 struct target_if_ctx *target_if_get_ctx(void)
123 {
124 	return g_target_if_ctx;
125 }
126 
target_if_get_psoc_from_scn_hdl(void * scn_handle)127 struct wlan_objmgr_psoc *target_if_get_psoc_from_scn_hdl(void *scn_handle)
128 {
129 	struct wlan_objmgr_psoc *psoc;
130 
131 	qdf_spin_lock_bh(&g_target_if_ctx->lock);
132 	if (scn_handle && g_target_if_ctx->get_psoc_hdl_cb)
133 		psoc = g_target_if_ctx->get_psoc_hdl_cb(scn_handle);
134 	else
135 		psoc = NULL;
136 	qdf_spin_unlock_bh(&g_target_if_ctx->lock);
137 
138 	return psoc;
139 }
140 
target_if_get_pdev_from_scn_hdl(void * scn_handle)141 struct wlan_objmgr_pdev *target_if_get_pdev_from_scn_hdl(void *scn_handle)
142 {
143 	struct wlan_objmgr_pdev *pdev;
144 
145 	qdf_spin_lock_bh(&g_target_if_ctx->lock);
146 	if (scn_handle && g_target_if_ctx->get_pdev_hdl_cb)
147 		pdev = g_target_if_ctx->get_pdev_hdl_cb(scn_handle);
148 	else
149 		pdev = NULL;
150 	qdf_spin_unlock_bh(&g_target_if_ctx->lock);
151 
152 	return pdev;
153 }
154 
155 #ifdef DIRECT_BUF_RX_ENABLE
target_if_direct_buf_rx_init(void)156 static QDF_STATUS target_if_direct_buf_rx_init(void)
157 {
158 	return direct_buf_rx_init();
159 }
160 
target_if_direct_buf_rx_deinit(void)161 static QDF_STATUS target_if_direct_buf_rx_deinit(void)
162 {
163 	return direct_buf_rx_deinit();
164 }
165 #else
target_if_direct_buf_rx_init(void)166 static QDF_STATUS target_if_direct_buf_rx_init(void)
167 {
168 	return QDF_STATUS_SUCCESS;
169 }
170 
target_if_direct_buf_rx_deinit(void)171 static QDF_STATUS target_if_direct_buf_rx_deinit(void)
172 {
173 	return QDF_STATUS_SUCCESS;
174 }
175 #endif /* DIRECT_BUF_RX_ENABLE */
176 
target_if_init(get_psoc_handle_callback psoc_hdl_cb)177 QDF_STATUS target_if_init(get_psoc_handle_callback psoc_hdl_cb)
178 {
179 	g_target_if_ctx = qdf_mem_malloc(sizeof(*g_target_if_ctx));
180 	if (!g_target_if_ctx) {
181 		QDF_ASSERT(0);
182 		return QDF_STATUS_E_NOMEM;
183 	}
184 
185 	qdf_spinlock_create(&g_target_if_ctx->lock);
186 
187 	qdf_spin_lock_bh(&g_target_if_ctx->lock);
188 	g_target_if_ctx->magic = TGT_MAGIC;
189 	g_target_if_ctx->get_psoc_hdl_cb = psoc_hdl_cb;
190 	qdf_spin_unlock_bh(&g_target_if_ctx->lock);
191 
192 	target_if_direct_buf_rx_init();
193 
194 	return QDF_STATUS_SUCCESS;
195 }
196 
target_if_deinit(void)197 QDF_STATUS target_if_deinit(void)
198 {
199 	if (!g_target_if_ctx) {
200 		QDF_ASSERT(0);
201 		target_if_err("target if ctx is null");
202 		return QDF_STATUS_E_INVAL;
203 	}
204 
205 	qdf_spin_lock_bh(&g_target_if_ctx->lock);
206 	g_target_if_ctx->magic = 0;
207 	g_target_if_ctx->get_psoc_hdl_cb = NULL;
208 	g_target_if_ctx->get_pdev_hdl_cb = NULL;
209 	g_target_if_ctx->service_ready_cb = NULL;
210 	qdf_spin_unlock_bh(&g_target_if_ctx->lock);
211 
212 	qdf_spinlock_destroy(&g_target_if_ctx->lock);
213 	qdf_mem_free(g_target_if_ctx);
214 	g_target_if_ctx = NULL;
215 
216 	target_if_direct_buf_rx_deinit();
217 
218 	return QDF_STATUS_SUCCESS;
219 }
220 
221 qdf_export_symbol(target_if_deinit);
222 
target_if_store_pdev_target_if_ctx(get_pdev_handle_callback pdev_hdl_cb)223 QDF_STATUS target_if_store_pdev_target_if_ctx(
224 		get_pdev_handle_callback pdev_hdl_cb)
225 {
226 	if (!g_target_if_ctx) {
227 		QDF_ASSERT(0);
228 		target_if_err("target if ctx is null");
229 		return QDF_STATUS_E_INVAL;
230 	}
231 
232 	qdf_spin_lock_bh(&g_target_if_ctx->lock);
233 	g_target_if_ctx->get_pdev_hdl_cb = pdev_hdl_cb;
234 	qdf_spin_unlock_bh(&g_target_if_ctx->lock);
235 
236 	return QDF_STATUS_SUCCESS;
237 }
238 
239 #ifndef WLAN_OFFCHAN_TXRX_ENABLE
target_if_offchan_txrx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)240 static void target_if_offchan_txrx_ops_register(
241 					struct wlan_lmac_if_tx_ops *tx_ops)
242 {
243 }
244 #endif /* WLAN_OFFCHAN_TXRX_ENABLE */
245 
246 #ifndef WLAN_ATF_ENABLE
target_if_atf_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)247 static void target_if_atf_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
248 {
249 }
250 #endif /* WLAN_ATF_ENABLE */
251 
252 #ifndef WLAN_SA_API_ENABLE
target_if_sa_api_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)253 static void target_if_sa_api_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
254 {
255 }
256 #endif /* WLAN_SA_API_ENABLE */
257 
258 #ifndef WLAN_CFR_ENABLE
target_if_cfr_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)259 static void target_if_cfr_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
260 {
261 }
262 #endif
263 
264 #ifdef WLAN_SUPPORT_FILS
target_if_fd_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)265 static void target_if_fd_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
266 {
267 	target_if_fd_register_tx_ops(tx_ops);
268 }
269 #else
target_if_fd_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)270 static void target_if_fd_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
271 {
272 }
273 #endif
274 
275 #ifdef WIFI_POS_CONVERGED
276 static void
target_if_wifi_pos_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)277 target_if_wifi_pos_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
278 {
279 	target_if_wifi_pos_register_tx_ops(tx_ops);
280 }
281 #else
282 static void
target_if_wifi_pos_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)283 target_if_wifi_pos_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
284 {
285 }
286 #endif
287 
288 #if defined(QCA_SUPPORT_SON) || defined(WLAN_FEATURE_SON)
target_if_son_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)289 static void target_if_son_tx_ops_register(
290 			struct wlan_lmac_if_tx_ops *tx_ops)
291 {
292 	target_if_son_register_tx_ops(tx_ops);
293 	return;
294 }
295 #else
target_if_son_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)296 static void target_if_son_tx_ops_register(
297 			struct wlan_lmac_if_tx_ops *tx_ops)
298 {
299 	return;
300 }
301 #endif
302 
303 #if defined WLAN_FEATURE_SR
target_if_spatial_reuse_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)304 static void target_if_spatial_reuse_tx_ops_register(
305 			struct wlan_lmac_if_tx_ops *tx_ops)
306 {
307 	target_if_spatial_reuse_register_tx_ops(tx_ops);
308 }
309 
310 #else
target_if_spatial_reuse_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)311 static void target_if_spatial_reuse_tx_ops_register(
312 			struct wlan_lmac_if_tx_ops *tx_ops)
313 {
314 }
315 
316 #endif
317 
318 #ifdef FEATURE_WLAN_TDLS
target_if_tdls_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)319 static void target_if_tdls_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
320 {
321 	target_if_tdls_register_tx_ops(tx_ops);
322 }
323 #else
target_if_tdls_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)324 static void target_if_tdls_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
325 {
326 }
327 #endif /* FEATURE_WLAN_TDLS */
328 
329 #ifdef DFS_COMPONENT_ENABLE
target_if_dfs_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)330 static void target_if_dfs_tx_ops_register(
331 				struct wlan_lmac_if_tx_ops *tx_ops)
332 {
333 	target_if_register_dfs_tx_ops(tx_ops);
334 }
335 #else
target_if_dfs_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)336 static void target_if_dfs_tx_ops_register(
337 				struct wlan_lmac_if_tx_ops *tx_ops)
338 {
339 }
340 #endif /* DFS_COMPONENT_ENABLE */
341 
342 #ifdef WLAN_CONV_SPECTRAL_ENABLE
target_if_sptrl_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)343 static void target_if_sptrl_tx_ops_register(
344 				struct wlan_lmac_if_tx_ops *tx_ops)
345 {
346 	target_if_sptrl_register_tx_ops(tx_ops);
347 }
348 #else
target_if_sptrl_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)349 static void target_if_sptrl_tx_ops_register(
350 				struct wlan_lmac_if_tx_ops *tx_ops)
351 {
352 }
353 #endif /* WLAN_CONV_SPECTRAL_ENABLE */
354 
355 #ifdef WLAN_IOT_SIM_SUPPORT
target_if_iot_sim_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)356 static void target_if_iot_sim_tx_ops_register(
357 				struct wlan_lmac_if_tx_ops *tx_ops)
358 {
359 	target_if_iot_sim_register_tx_ops(tx_ops);
360 }
361 #else
target_if_iot_sim_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)362 static void target_if_iot_sim_tx_ops_register(
363 				struct wlan_lmac_if_tx_ops *tx_ops)
364 {
365 }
366 #endif
367 
368 #ifdef DIRECT_BUF_RX_ENABLE
target_if_direct_buf_rx_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)369 static void target_if_direct_buf_rx_tx_ops_register(
370 				struct wlan_lmac_if_tx_ops *tx_ops)
371 {
372 	target_if_direct_buf_rx_register_tx_ops(tx_ops);
373 }
374 #else
target_if_direct_buf_rx_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)375 static void target_if_direct_buf_rx_tx_ops_register(
376 				struct wlan_lmac_if_tx_ops *tx_ops)
377 {
378 }
379 #endif /* DIRECT_BUF_RX_ENABLE */
380 
381 #ifdef WLAN_SUPPORT_GREEN_AP
target_if_green_ap_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)382 static QDF_STATUS target_if_green_ap_tx_ops_register(
383 				struct wlan_lmac_if_tx_ops *tx_ops)
384 {
385 	return target_if_register_green_ap_tx_ops(tx_ops);
386 }
387 #else
target_if_green_ap_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)388 static QDF_STATUS target_if_green_ap_tx_ops_register(
389 				struct wlan_lmac_if_tx_ops *tx_ops)
390 {
391 	return QDF_STATUS_SUCCESS;
392 }
393 #endif /* WLAN_SUPPORT_GREEN_AP */
394 #if defined(CRYPTO_SET_KEY_CONVERGED)
target_if_crypto_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)395 static void target_if_crypto_tx_ops_register(
396 				struct wlan_lmac_if_tx_ops *tx_ops)
397 {
398 	target_if_crypto_register_tx_ops(tx_ops);
399 }
400 #else
target_if_crypto_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)401 static inline void target_if_crypto_tx_ops_register(
402 				struct wlan_lmac_if_tx_ops *tx_ops)
403 {
404 }
405 #endif
406 
407 #ifdef FEATURE_COEX
408 static QDF_STATUS
target_if_coex_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)409 target_if_coex_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
410 {
411 	return target_if_coex_register_tx_ops(tx_ops);
412 }
413 #else
414 static inline QDF_STATUS
target_if_coex_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)415 target_if_coex_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
416 {
417 	return QDF_STATUS_SUCCESS;
418 }
419 #endif
420 
421 #ifdef WLAN_FEATURE_DBAM_CONFIG
422 static QDF_STATUS
target_if_dbam_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)423 target_if_dbam_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
424 {
425 	return target_if_dbam_register_tx_ops(tx_ops);
426 }
427 #else
428 static inline QDF_STATUS
target_if_dbam_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)429 target_if_dbam_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
430 {
431 	return QDF_STATUS_SUCCESS;
432 }
433 #endif
434 
435 #ifdef WLAN_FEATURE_COAP
436 static QDF_STATUS
target_if_coap_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)437 target_if_coap_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
438 {
439 	return target_if_coap_register_tx_ops(tx_ops);
440 }
441 #else
442 static inline QDF_STATUS
target_if_coap_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)443 target_if_coap_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
444 {
445 	return QDF_STATUS_SUCCESS;
446 }
447 #endif
448 
target_if_target_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)449 static void target_if_target_tx_ops_register(
450 		struct wlan_lmac_if_tx_ops *tx_ops)
451 {
452 	struct wlan_lmac_if_target_tx_ops *target_tx_ops;
453 
454 	if (!tx_ops) {
455 		target_if_err("invalid tx_ops");
456 		return;
457 	}
458 
459 	target_tx_ops = &tx_ops->target_tx_ops;
460 
461 	target_tx_ops->tgt_is_tgt_type_ar900b =
462 		target_is_tgt_type_ar900b;
463 
464 	target_tx_ops->tgt_is_tgt_type_qca9984 =
465 		target_is_tgt_type_qca9984;
466 
467 	target_tx_ops->tgt_is_tgt_type_qca9888 =
468 		target_is_tgt_type_qca9888;
469 
470 	target_tx_ops->tgt_is_tgt_type_adrastea =
471 		target_is_tgt_type_adrastea;
472 
473 	target_tx_ops->tgt_is_tgt_type_qcn9000 =
474 		target_is_tgt_type_qcn9000;
475 
476 	target_tx_ops->tgt_is_tgt_type_qcn6122 =
477 		target_is_tgt_type_qcn6122;
478 
479 	target_tx_ops->tgt_is_tgt_type_qcn9160 =
480 		target_is_tgt_type_qcn9160;
481 
482 	target_tx_ops->tgt_is_tgt_type_qcn6432 =
483 		target_is_tgt_type_qcn6432;
484 
485 	target_tx_ops->tgt_is_tgt_type_qcn7605 =
486 		target_is_tgt_type_qcn7605;
487 
488 	target_tx_ops->tgt_get_tgt_type =
489 		lmac_get_tgt_type;
490 
491 	target_tx_ops->tgt_get_tgt_version =
492 		lmac_get_tgt_version;
493 
494 	target_tx_ops->tgt_get_tgt_revision =
495 		lmac_get_tgt_revision;
496 }
497 
498 static QDF_STATUS
target_if_cp_stats_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)499 target_if_cp_stats_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
500 {
501 	return target_if_cp_stats_register_tx_ops(tx_ops);
502 }
503 
504 #ifdef DCS_INTERFERENCE_DETECTION
505 static QDF_STATUS
target_if_dcs_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)506 target_if_dcs_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
507 {
508 	return target_if_dcs_register_tx_ops(tx_ops);
509 }
510 #else
511 static QDF_STATUS
target_if_dcs_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)512 target_if_dcs_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
513 {
514 	return QDF_STATUS_SUCCESS;
515 }
516 #endif
517 
518 static QDF_STATUS
target_if_vdev_mgr_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)519 target_if_vdev_mgr_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
520 {
521 	return target_if_vdev_mgr_register_tx_ops(tx_ops);
522 }
523 
524 #ifdef QCA_WIFI_FTM
525 static
target_if_ftm_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)526 void target_if_ftm_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
527 {
528 	target_if_ftm_register_tx_ops(tx_ops);
529 }
530 #else
531 static
target_if_ftm_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)532 void target_if_ftm_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
533 {
534 }
535 #endif
536 
537 #ifdef WLAN_FEATURE_GPIO_CFG
538 static
target_if_gpio_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)539 void target_if_gpio_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
540 {
541 	target_if_gpio_register_tx_ops(tx_ops);
542 }
543 #else
544 static
target_if_gpio_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)545 void target_if_gpio_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
546 {
547 }
548 #endif
549 
550 #ifdef WLAN_MGMT_RX_REO_SUPPORT
551 static
target_if_mgmt_txrx_register_tx_ops(struct wlan_lmac_if_tx_ops * tx_ops)552 void target_if_mgmt_txrx_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
553 {
554 	target_if_mgmt_txrx_tx_ops_register(tx_ops);
555 }
556 #else
557 static
target_if_mgmt_txrx_register_tx_ops(struct wlan_lmac_if_tx_ops * tx_ops)558 void target_if_mgmt_txrx_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
559 {
560 }
561 #endif /* WLAN_MGMT_RX_REO_SUPPORT */
562 
563 #ifdef WLAN_FEATURE_11BE_MLO
564 static QDF_STATUS
target_if_mlo_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)565 target_if_mlo_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
566 {
567 	return target_if_mlo_register_tx_ops(tx_ops);
568 }
569 #else
570 static QDF_STATUS
target_if_mlo_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)571 target_if_mlo_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
572 {
573 	return QDF_STATUS_SUCCESS;
574 }
575 #endif
576 
577 #ifdef IPA_OFFLOAD
target_if_ipa_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)578 static void target_if_ipa_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
579 {
580 	target_if_ipa_register_tx_ops(tx_ops);
581 }
582 #else
target_if_ipa_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)583 static void target_if_ipa_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
584 { }
585 #endif
586 
587 #if defined(WLAN_SUPPORT_TWT) && defined(WLAN_TWT_CONV_SUPPORTED)
588 static
target_if_twt_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)589 void target_if_twt_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
590 {
591 	target_if_twt_register_tx_ops(tx_ops);
592 }
593 #else
594 static
target_if_twt_tx_ops_register(struct wlan_lmac_if_tx_ops * tx_ops)595 void target_if_twt_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
596 {
597 }
598 #endif /* WLAN_SUPPORT_TWT && WLAN_TWT_CONV_SUPPORTED */
599 
600 static
target_if_register_umac_tx_ops(struct wlan_lmac_if_tx_ops * tx_ops)601 QDF_STATUS target_if_register_umac_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
602 {
603 	/* call regulatory callback to register tx ops */
604 	target_if_register_regulatory_tx_ops(tx_ops);
605 
606 	/* call umac callback to register legacy tx ops */
607 	wlan_lmac_if_umac_tx_ops_register(tx_ops);
608 
609 	/* Register scan tx ops */
610 	target_if_scan_tx_ops_register(tx_ops);
611 
612 	target_if_atf_tx_ops_register(tx_ops);
613 
614 	target_if_sa_api_tx_ops_register(tx_ops);
615 
616 	target_if_cfr_tx_ops_register(tx_ops);
617 
618 	target_if_wifi_pos_tx_ops_register(tx_ops);
619 
620 	target_if_dfs_tx_ops_register(tx_ops);
621 
622 	target_if_son_tx_ops_register(tx_ops);
623 
624 	target_if_spatial_reuse_tx_ops_register(tx_ops);
625 
626 	target_if_tdls_tx_ops_register(tx_ops);
627 
628 	target_if_fd_tx_ops_register(tx_ops);
629 
630 	target_if_target_tx_ops_register(tx_ops);
631 
632 	target_if_offchan_txrx_ops_register(tx_ops);
633 
634 	target_if_green_ap_tx_ops_register(tx_ops);
635 
636 	target_if_ftm_tx_ops_register(tx_ops);
637 
638 	target_if_cp_stats_tx_ops_register(tx_ops);
639 
640 	target_if_dcs_tx_ops_register(tx_ops);
641 
642 	target_if_crypto_tx_ops_register(tx_ops);
643 
644 	target_if_vdev_mgr_tx_ops_register(tx_ops);
645 
646 	target_if_coex_tx_ops_register(tx_ops);
647 
648 	target_if_gpio_tx_ops_register(tx_ops);
649 
650 	target_if_mgmt_txrx_register_tx_ops(tx_ops);
651 
652 	target_if_mlo_tx_ops_register(tx_ops);
653 
654 	target_if_ipa_tx_ops_register(tx_ops);
655 
656 	target_if_twt_tx_ops_register(tx_ops);
657 
658 	target_if_dbam_tx_ops_register(tx_ops);
659 
660 	target_if_coap_tx_ops_register(tx_ops);
661 
662 	/* Converged UMAC components to register their TX-ops here */
663 	return QDF_STATUS_SUCCESS;
664 }
665 
target_if_register_tx_ops(struct wlan_lmac_if_tx_ops * tx_ops)666 QDF_STATUS target_if_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
667 {
668 	/* Converged UMAC components to register their TX-ops */
669 	target_if_register_umac_tx_ops(tx_ops);
670 
671 	/* Components parallel to UMAC to register their TX-ops here */
672 	target_if_sptrl_tx_ops_register(tx_ops);
673 
674 	target_if_iot_sim_tx_ops_register(tx_ops);
675 
676 	/* Register direct buffer rx component tx ops here */
677 	target_if_direct_buf_rx_tx_ops_register(tx_ops);
678 
679 #ifdef CONVERGED_P2P_ENABLE
680 	/* Converged UMAC components to register P2P TX-ops */
681 	target_if_p2p_register_tx_ops(tx_ops);
682 #endif
683 
684 	return QDF_STATUS_SUCCESS;
685 }
686 qdf_export_symbol(target_if_register_tx_ops);
687 
688 wmi_legacy_service_ready_callback
target_if_get_psoc_legacy_service_ready_cb(void)689 target_if_get_psoc_legacy_service_ready_cb(void)
690 {
691 	wmi_legacy_service_ready_callback service_ready_cb;
692 
693 	qdf_spin_lock_bh(&g_target_if_ctx->lock);
694 	if (g_target_if_ctx->service_ready_cb)
695 		service_ready_cb = g_target_if_ctx->service_ready_cb;
696 	else
697 		service_ready_cb = NULL;
698 	qdf_spin_unlock_bh(&g_target_if_ctx->lock);
699 
700 	return service_ready_cb;
701 }
702 qdf_export_symbol(target_if_get_psoc_legacy_service_ready_cb);
703 
target_if_register_legacy_service_ready_cb(wmi_legacy_service_ready_callback service_ready_cb)704 QDF_STATUS target_if_register_legacy_service_ready_cb(
705 	wmi_legacy_service_ready_callback service_ready_cb)
706 {
707 	qdf_spin_lock_bh(&g_target_if_ctx->lock);
708 	g_target_if_ctx->service_ready_cb = service_ready_cb;
709 	qdf_spin_unlock_bh(&g_target_if_ctx->lock);
710 
711 	return QDF_STATUS_SUCCESS;
712 }
713 qdf_export_symbol(target_if_register_legacy_service_ready_cb);
714 
target_if_alloc_pdev_tgt_info(struct wlan_objmgr_pdev * pdev)715 QDF_STATUS target_if_alloc_pdev_tgt_info(struct wlan_objmgr_pdev *pdev)
716 {
717 	struct target_pdev_info *tgt_pdev_info;
718 
719 	if (!pdev) {
720 		target_if_err("pdev is null");
721 		return QDF_STATUS_E_INVAL;
722 	}
723 
724 	tgt_pdev_info = qdf_mem_malloc(sizeof(*tgt_pdev_info));
725 
726 	if (!tgt_pdev_info)
727 		return QDF_STATUS_E_NOMEM;
728 
729 	wlan_pdev_set_tgt_if_handle(pdev, tgt_pdev_info);
730 
731 	return QDF_STATUS_SUCCESS;
732 }
733 
target_if_free_pdev_tgt_info(struct wlan_objmgr_pdev * pdev)734 QDF_STATUS target_if_free_pdev_tgt_info(struct wlan_objmgr_pdev *pdev)
735 {
736 	struct target_pdev_info *tgt_pdev_info;
737 
738 	if (!pdev) {
739 		target_if_err("pdev is null");
740 		return QDF_STATUS_E_INVAL;
741 	}
742 
743 	tgt_pdev_info = wlan_pdev_get_tgt_if_handle(pdev);
744 
745 	wlan_pdev_set_tgt_if_handle(pdev, NULL);
746 
747 	qdf_mem_free(tgt_pdev_info);
748 
749 	return QDF_STATUS_SUCCESS;
750 }
751 
target_if_alloc_psoc_tgt_info(struct wlan_objmgr_psoc * psoc)752 QDF_STATUS target_if_alloc_psoc_tgt_info(struct wlan_objmgr_psoc *psoc)
753 {
754 	struct target_psoc_info *tgt_psoc_info;
755 
756 	if (!psoc) {
757 		target_if_err("psoc is null");
758 		return QDF_STATUS_E_INVAL;
759 	}
760 
761 	tgt_psoc_info = qdf_mem_malloc(sizeof(*tgt_psoc_info));
762 
763 	if (!tgt_psoc_info)
764 		return QDF_STATUS_E_NOMEM;
765 
766 	wlan_psoc_set_tgt_if_handle(psoc, tgt_psoc_info);
767 	target_psoc_set_preferred_hw_mode(tgt_psoc_info, WMI_HOST_HW_MODE_MAX);
768 	wlan_minidump_log(tgt_psoc_info,
769 			  sizeof(*tgt_psoc_info), psoc,
770 			  WLAN_MD_OBJMGR_PSOC_TGT_INFO, "target_psoc_info");
771 
772 	qdf_event_create(&tgt_psoc_info->info.event);
773 
774 	return QDF_STATUS_SUCCESS;
775 }
776 
target_if_psoc_tgt_info_mem_free(struct target_psoc_info * tgt_psoc_info)777 QDF_STATUS target_if_psoc_tgt_info_mem_free(
778 		struct target_psoc_info *tgt_psoc_info)
779 {
780 	struct wlan_psoc_host_service_ext_param *ext_param;
781 
782 	if (!tgt_psoc_info) {
783 		target_if_err("tgt_psoc_info is NULL");
784 		return QDF_STATUS_E_INVAL;
785 	}
786 
787 	/* reminder to move this into init_deinit_chainmask_table_free */
788 	ext_param = target_psoc_get_service_ext_param(tgt_psoc_info);
789 	if (ext_param)
790 		init_deinit_chainmask_table_free(ext_param);
791 
792 	init_deinit_dbr_ring_cap_free(tgt_psoc_info);
793 	init_deinit_spectral_scaling_params_free(tgt_psoc_info);
794 	init_deinit_scan_radio_cap_free(tgt_psoc_info);
795 	init_deinit_msdu_idx_qtype_map_free(tgt_psoc_info);
796 	init_deinit_aux_dev_cap_free(tgt_psoc_info);
797 	init_deinit_rcc_aoa_cap_ext2_free(tgt_psoc_info);
798 
799 	return QDF_STATUS_SUCCESS;
800 }
801 
target_if_free_psoc_tgt_info(struct wlan_objmgr_psoc * psoc)802 QDF_STATUS target_if_free_psoc_tgt_info(struct wlan_objmgr_psoc *psoc)
803 {
804 	struct target_psoc_info *tgt_psoc_info;
805 
806 	if (!psoc) {
807 		target_if_err("psoc is null");
808 		return QDF_STATUS_E_INVAL;
809 	}
810 
811 	tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc);
812 
813 	target_if_psoc_tgt_info_mem_free(tgt_psoc_info);
814 	qdf_event_destroy(&tgt_psoc_info->info.event);
815 
816 	wlan_psoc_set_tgt_if_handle(psoc, NULL);
817 
818 	wlan_minidump_remove(tgt_psoc_info,
819 			     sizeof(*tgt_psoc_info), psoc,
820 			     WLAN_MD_OBJMGR_PSOC_TGT_INFO, "target_psoc_info");
821 	qdf_mem_free(tgt_psoc_info);
822 
823 	return QDF_STATUS_SUCCESS;
824 }
825 
target_is_tgt_type_ar900b(uint32_t target_type)826 bool target_is_tgt_type_ar900b(uint32_t target_type)
827 {
828 	return target_type == TARGET_TYPE_AR900B;
829 }
830 
target_is_tgt_type_qca9984(uint32_t target_type)831 bool target_is_tgt_type_qca9984(uint32_t target_type)
832 {
833 	return target_type == TARGET_TYPE_QCA9984;
834 }
835 
target_is_tgt_type_qca9888(uint32_t target_type)836 bool target_is_tgt_type_qca9888(uint32_t target_type)
837 {
838 	return target_type == TARGET_TYPE_QCA9888;
839 }
840 
target_is_tgt_type_adrastea(uint32_t target_type)841 bool target_is_tgt_type_adrastea(uint32_t target_type)
842 {
843 	return target_type == TARGET_TYPE_ADRASTEA;
844 }
845 
target_is_tgt_type_qcn9000(uint32_t target_type)846 bool target_is_tgt_type_qcn9000(uint32_t target_type)
847 {
848 	return target_type == TARGET_TYPE_QCN9000;
849 }
850 
target_is_tgt_type_qcn6122(uint32_t target_type)851 bool target_is_tgt_type_qcn6122(uint32_t target_type)
852 {
853 	return target_type == TARGET_TYPE_QCN6122;
854 }
855 
target_is_tgt_type_qcn9160(uint32_t target_type)856 bool target_is_tgt_type_qcn9160(uint32_t target_type)
857 {
858 	return target_type == TARGET_TYPE_QCN9160;
859 }
860 
target_is_tgt_type_qcn6432(uint32_t target_type)861 bool target_is_tgt_type_qcn6432(uint32_t target_type)
862 {
863 	return target_type == TARGET_TYPE_QCN6432;
864 }
865 
target_is_tgt_type_qcn7605(uint32_t target_type)866 bool target_is_tgt_type_qcn7605(uint32_t target_type)
867 {
868 	return target_type == TARGET_TYPE_QCN7605;
869 }
870 
871 QDF_STATUS
target_pdev_is_scan_radio_supported(struct wlan_objmgr_pdev * pdev,bool * is_scan_radio_supported)872 target_pdev_is_scan_radio_supported(struct wlan_objmgr_pdev *pdev,
873 				    bool *is_scan_radio_supported)
874 {
875 	struct wlan_objmgr_psoc *psoc;
876 	struct wlan_psoc_host_scan_radio_caps *scan_radio_caps;
877 	uint8_t cap_idx;
878 	uint32_t num_scan_radio_caps;
879 	int32_t phy_id;
880 	struct target_psoc_info *tgt_psoc_info;
881 	struct target_pdev_info *tgt_pdev;
882 	uint32_t target_type = TARGET_TYPE_UNKNOWN;
883 	struct wlan_lmac_if_target_tx_ops *target_type_tx_ops;
884 	struct wlan_lmac_if_tx_ops *tx_ops;
885 
886 	if (!is_scan_radio_supported) {
887 		target_if_err("input argument is null");
888 		return QDF_STATUS_E_INVAL;
889 	}
890 	*is_scan_radio_supported = false;
891 
892 	if (!pdev) {
893 		target_if_err("pdev is null");
894 		return QDF_STATUS_E_INVAL;
895 	}
896 
897 	psoc = wlan_pdev_get_psoc(pdev);
898 	if (!psoc) {
899 		target_if_err("psoc is null");
900 		return QDF_STATUS_E_INVAL;
901 	}
902 
903 	tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc);
904 	if (!tgt_psoc_info) {
905 		target_if_err("target_psoc_info is null");
906 		return QDF_STATUS_E_INVAL;
907 	}
908 
909 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
910 	if (!tx_ops) {
911 		target_if_err("tx_ops is null");
912 		return QDF_STATUS_E_NULL_VALUE;
913 	}
914 
915 	target_type_tx_ops = &tx_ops->target_tx_ops;
916 	if (target_type_tx_ops->tgt_get_tgt_type)
917 		target_type = target_type_tx_ops->tgt_get_tgt_type(psoc);
918 
919 	if (target_type == TARGET_TYPE_AR9888) {
920 		*is_scan_radio_supported = true;
921 		return QDF_STATUS_SUCCESS;
922 	}
923 
924 	num_scan_radio_caps =
925 		target_psoc_get_num_scan_radio_caps(tgt_psoc_info);
926 	if (!num_scan_radio_caps)
927 		return QDF_STATUS_SUCCESS;
928 
929 	scan_radio_caps = target_psoc_get_scan_radio_caps(tgt_psoc_info);
930 	if (!scan_radio_caps) {
931 		target_if_err("scan radio capabilities is null");
932 		return QDF_STATUS_E_INVAL;
933 	}
934 
935 	tgt_pdev = (struct target_pdev_info *)wlan_pdev_get_tgt_if_handle(pdev);
936 	if (!tgt_pdev) {
937 		target_if_err("target_pdev_info is null");
938 		return QDF_STATUS_E_INVAL;
939 	}
940 
941 	phy_id = target_pdev_get_phy_idx(tgt_pdev);
942 	if (phy_id < 0) {
943 		target_if_err("phy_id is invalid");
944 		return QDF_STATUS_E_INVAL;
945 	}
946 
947 	for (cap_idx = 0; cap_idx < num_scan_radio_caps; cap_idx++)
948 		if (scan_radio_caps[cap_idx].phy_id == phy_id)
949 			*is_scan_radio_supported =
950 				scan_radio_caps[cap_idx].scan_radio_supported;
951 
952 	return QDF_STATUS_SUCCESS;
953 }
954 
955 QDF_STATUS
target_pdev_scan_radio_is_dfs_enabled(struct wlan_objmgr_pdev * pdev,bool * is_dfs_en)956 target_pdev_scan_radio_is_dfs_enabled(struct wlan_objmgr_pdev *pdev,
957 				      bool *is_dfs_en)
958 {
959 	struct wlan_objmgr_psoc *psoc;
960 	struct wlan_psoc_host_scan_radio_caps *scan_radio_caps;
961 	uint8_t cap_idx;
962 	uint32_t num_scan_radio_caps, pdev_id;
963 	int32_t phy_id;
964 	struct target_psoc_info *tgt_psoc_info;
965 	struct target_pdev_info *tgt_pdev;
966 	uint32_t target_type = TARGET_TYPE_UNKNOWN;
967 	struct wlan_lmac_if_target_tx_ops *target_type_tx_ops;
968 	struct wlan_lmac_if_tx_ops *tx_ops;
969 
970 	if (!is_dfs_en) {
971 		target_if_err("input argument is null");
972 		return QDF_STATUS_E_INVAL;
973 	}
974 	*is_dfs_en = true;
975 
976 	if (!pdev) {
977 		target_if_err("pdev is null");
978 		return QDF_STATUS_E_INVAL;
979 	}
980 
981 	psoc = wlan_pdev_get_psoc(pdev);
982 	if (!psoc) {
983 		target_if_err("psoc is null");
984 		return QDF_STATUS_E_INVAL;
985 	}
986 
987 	tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc);
988 	if (!tgt_psoc_info) {
989 		target_if_err("target_psoc_info is null");
990 		return QDF_STATUS_E_INVAL;
991 	}
992 
993 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
994 	if (!tx_ops) {
995 		target_if_err("tx_ops is null");
996 		return QDF_STATUS_E_NULL_VALUE;
997 	}
998 	target_type_tx_ops = &tx_ops->target_tx_ops;
999 	if (target_type_tx_ops->tgt_get_tgt_type)
1000 		target_type = target_type_tx_ops->tgt_get_tgt_type(psoc);
1001 
1002 	if (target_type == TARGET_TYPE_AR9888) {
1003 		*is_dfs_en = false;
1004 		return QDF_STATUS_SUCCESS;
1005 	}
1006 
1007 	num_scan_radio_caps =
1008 		target_psoc_get_num_scan_radio_caps(tgt_psoc_info);
1009 	if (!num_scan_radio_caps) {
1010 		target_if_err("scan radio not supported for psoc");
1011 		return QDF_STATUS_E_INVAL;
1012 	}
1013 
1014 	scan_radio_caps = target_psoc_get_scan_radio_caps(tgt_psoc_info);
1015 	if (!scan_radio_caps) {
1016 		target_if_err("scan radio capabilities is null");
1017 		return QDF_STATUS_E_INVAL;
1018 	}
1019 
1020 	tgt_pdev = (struct target_pdev_info *)wlan_pdev_get_tgt_if_handle(pdev);
1021 	if (!tgt_pdev) {
1022 		target_if_err("target_pdev_info is null");
1023 		return QDF_STATUS_E_INVAL;
1024 	}
1025 
1026 	pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
1027 	phy_id = target_pdev_get_phy_idx(tgt_pdev);
1028 	if (phy_id < 0) {
1029 		target_if_err("phy_id is invalid");
1030 		return QDF_STATUS_E_INVAL;
1031 	}
1032 
1033 	for (cap_idx = 0; cap_idx < num_scan_radio_caps; cap_idx++)
1034 		if (scan_radio_caps[cap_idx].phy_id == phy_id) {
1035 			*is_dfs_en = scan_radio_caps[cap_idx].dfs_en;
1036 			return QDF_STATUS_SUCCESS;
1037 		}
1038 
1039 	target_if_err("No scan radio cap found in pdev %d", pdev_id);
1040 
1041 	return QDF_STATUS_E_INVAL;
1042 }
1043 
1044 QDF_STATUS
target_is_scan_blanking_enabled(struct wlan_objmgr_pdev * pdev,bool * blanking_en)1045 target_is_scan_blanking_enabled(struct wlan_objmgr_pdev *pdev,
1046 				bool *blanking_en)
1047 {
1048 	struct wlan_objmgr_psoc *psoc;
1049 	struct wlan_psoc_host_scan_radio_caps *scan_radio_caps;
1050 	uint8_t cap_idx;
1051 	uint32_t num_scan_radio_caps, pdev_id;
1052 	int32_t phy_id;
1053 	struct target_psoc_info *tgt_psoc_info;
1054 	struct target_pdev_info *tgt_pdev;
1055 	uint32_t target_type = TARGET_TYPE_UNKNOWN;
1056 	struct wlan_lmac_if_target_tx_ops *target_type_tx_ops;
1057 	struct wlan_lmac_if_tx_ops *tx_ops;
1058 
1059 
1060 	if (!blanking_en) {
1061 		target_if_err("input argument is null");
1062 		return QDF_STATUS_E_NULL_VALUE;
1063 	}
1064 	*blanking_en = false;
1065 
1066 	if (!pdev) {
1067 		target_if_err("pdev is null");
1068 		return QDF_STATUS_E_NULL_VALUE;
1069 	}
1070 
1071 	psoc = wlan_pdev_get_psoc(pdev);
1072 	if (!psoc) {
1073 		target_if_err("psoc is null");
1074 		return QDF_STATUS_E_NULL_VALUE;
1075 	}
1076 
1077 	tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc);
1078 	if (!tgt_psoc_info) {
1079 		target_if_err("target_psoc_info is null");
1080 		return QDF_STATUS_E_NULL_VALUE;
1081 	}
1082 
1083 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
1084 	if (!tx_ops) {
1085 		target_if_err("tx_ops is null");
1086 		return QDF_STATUS_E_NULL_VALUE;
1087 	}
1088 
1089 	target_type_tx_ops = &tx_ops->target_tx_ops;
1090 	if (target_type_tx_ops->tgt_get_tgt_type)
1091 		target_type = target_type_tx_ops->tgt_get_tgt_type(psoc);
1092 
1093 	if (target_type == TARGET_TYPE_AR9888) {
1094 		*blanking_en = false;
1095 		return QDF_STATUS_SUCCESS;
1096 	}
1097 
1098 	num_scan_radio_caps =
1099 		target_psoc_get_num_scan_radio_caps(tgt_psoc_info);
1100 	if (!num_scan_radio_caps) {
1101 		target_if_err("scan radio not supported for psoc");
1102 		return QDF_STATUS_E_NULL_VALUE;
1103 	}
1104 
1105 	scan_radio_caps = target_psoc_get_scan_radio_caps(tgt_psoc_info);
1106 	if (!scan_radio_caps) {
1107 		target_if_err("scan radio capabilities is null");
1108 		return QDF_STATUS_E_NULL_VALUE;
1109 	}
1110 
1111 	tgt_pdev = (struct target_pdev_info *)wlan_pdev_get_tgt_if_handle(pdev);
1112 	if (!tgt_pdev) {
1113 		target_if_err("target_pdev_info is null");
1114 		return QDF_STATUS_E_NULL_VALUE;
1115 	}
1116 
1117 	pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
1118 	phy_id = target_pdev_get_phy_idx(tgt_pdev);
1119 	if (phy_id < 0) {
1120 		target_if_err("phy_id is invalid");
1121 		return QDF_STATUS_E_INVAL;
1122 	}
1123 
1124 	for (cap_idx = 0; cap_idx < num_scan_radio_caps; cap_idx++)
1125 		if (scan_radio_caps[cap_idx].phy_id == phy_id) {
1126 			*blanking_en = scan_radio_caps[cap_idx].blanking_en;
1127 			return QDF_STATUS_SUCCESS;
1128 		}
1129 
1130 	target_if_err("No scan radio cap found in pdev %d", pdev_id);
1131 
1132 	return QDF_STATUS_E_INVAL;
1133 }
1134 
target_if_set_reg_cc_ext_supp(struct target_psoc_info * tgt_hdl,struct wlan_objmgr_psoc * psoc)1135 void target_if_set_reg_cc_ext_supp(struct target_psoc_info *tgt_hdl,
1136 				   struct wlan_objmgr_psoc *psoc)
1137 {
1138 	struct tgt_info *info;
1139 
1140 	if (!tgt_hdl)
1141 		return;
1142 
1143 	info = (&tgt_hdl->info);
1144 
1145 	info->wlan_res_cfg.is_reg_cc_ext_event_supported =
1146 		target_if_reg_is_reg_cc_ext_event_host_supported(psoc);
1147 }
1148 
1149 #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
target_if_pdev_get_hw_link_id(struct wlan_objmgr_pdev * pdev)1150 uint16_t  target_if_pdev_get_hw_link_id(struct wlan_objmgr_pdev *pdev)
1151 {
1152 	struct target_pdev_info *tgt_pdev_info;
1153 
1154 	if (!pdev)
1155 		return PDEV_INVALID_HW_LINK_ID;
1156 
1157 	tgt_pdev_info = wlan_pdev_get_tgt_if_handle(pdev);
1158 	if (!tgt_pdev_info)
1159 		return PDEV_INVALID_HW_LINK_ID;
1160 
1161 	return tgt_pdev_info->hw_link_id;
1162 }
1163 
target_pdev_set_hw_link_id(struct wlan_objmgr_pdev * pdev,uint16_t hw_link_id)1164 void target_pdev_set_hw_link_id(struct wlan_objmgr_pdev *pdev,
1165 				uint16_t hw_link_id)
1166 {
1167 	struct target_pdev_info *tgt_pdev_info;
1168 
1169 	if (!pdev)
1170 		return;
1171 
1172 	tgt_pdev_info = wlan_pdev_get_tgt_if_handle(pdev);
1173 	if (!tgt_pdev_info)
1174 		return;
1175 
1176 	tgt_pdev_info->hw_link_id  = hw_link_id;
1177 }
1178 
target_if_mlo_setup_send(struct wlan_objmgr_pdev * pdev,struct wlan_objmgr_pdev ** pdev_list,uint8_t num_links,uint8_t grp_id)1179 static QDF_STATUS target_if_mlo_setup_send(struct wlan_objmgr_pdev *pdev,
1180 					   struct wlan_objmgr_pdev **pdev_list,
1181 					   uint8_t num_links, uint8_t grp_id)
1182 {
1183 	wmi_unified_t wmi_handle;
1184 	struct wmi_mlo_setup_params params = {0};
1185 	uint8_t idx, num_valid_links = 0;
1186 
1187 	wmi_handle = lmac_get_pdev_wmi_handle(pdev);
1188 	if (!wmi_handle)
1189 		return QDF_STATUS_E_INVAL;
1190 
1191 	params.mld_grp_id = grp_id;
1192 	params.pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
1193 
1194 	for (idx = 0; idx < num_links; idx++) {
1195 		if (pdev == pdev_list[idx])
1196 			continue;
1197 
1198 		params.partner_links[num_valid_links] =
1199 			target_if_pdev_get_hw_link_id(pdev_list[idx]);
1200 		num_valid_links++;
1201 	}
1202 	params.num_valid_hw_links = num_valid_links;
1203 
1204 	return wmi_mlo_setup_cmd_send(wmi_handle, &params);
1205 }
1206 
target_if_mlo_setup_req(struct wlan_objmgr_pdev ** pdev,uint8_t num_pdevs,uint8_t grp_id)1207 QDF_STATUS target_if_mlo_setup_req(struct wlan_objmgr_pdev **pdev,
1208 				   uint8_t num_pdevs, uint8_t grp_id)
1209 {
1210 	uint8_t idx;
1211 
1212 	for (idx = 0; idx < num_pdevs; idx++)
1213 		target_if_mlo_setup_send(pdev[idx], pdev, num_pdevs, grp_id);
1214 
1215 	return QDF_STATUS_SUCCESS;
1216 }
1217 
target_if_mlo_ready_send(struct wlan_objmgr_pdev * pdev)1218 static QDF_STATUS target_if_mlo_ready_send(struct wlan_objmgr_pdev *pdev)
1219 {
1220 	wmi_unified_t wmi_handle;
1221 	struct wmi_mlo_ready_params params = {0};
1222 
1223 	wmi_handle = lmac_get_pdev_wmi_handle(pdev);
1224 	if (!wmi_handle)
1225 		return QDF_STATUS_E_INVAL;
1226 
1227 	params.pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
1228 
1229 	return wmi_mlo_ready_cmd_send(wmi_handle, &params);
1230 }
1231 
target_if_mlo_ready(struct wlan_objmgr_pdev ** pdev,uint8_t num_pdevs)1232 QDF_STATUS target_if_mlo_ready(struct wlan_objmgr_pdev **pdev,
1233 			       uint8_t num_pdevs)
1234 {
1235 	uint8_t idx;
1236 
1237 	for (idx = 0; idx < num_pdevs; idx++)
1238 		target_if_mlo_ready_send(pdev[idx]);
1239 
1240 	return QDF_STATUS_SUCCESS;
1241 }
1242 
1243 QDF_STATUS
target_if_mlo_teardown_req(struct wlan_objmgr_pdev * pdev,enum wmi_mlo_teardown_reason reason,bool reset,bool standby_active)1244 target_if_mlo_teardown_req(struct wlan_objmgr_pdev *pdev,
1245 			   enum wmi_mlo_teardown_reason reason,
1246 			   bool reset, bool standby_active)
1247 {
1248 	wmi_unified_t wmi_handle;
1249 	struct wmi_mlo_teardown_params params = {0};
1250 
1251 	wmi_handle = lmac_get_pdev_wmi_handle(pdev);
1252 	if (!wmi_handle)
1253 		return QDF_STATUS_E_INVAL;
1254 
1255 	params.pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
1256 	params.reason = reason;
1257 	params.umac_reset = reset;
1258 	params.standby_active = standby_active;
1259 
1260 	return wmi_mlo_teardown_cmd_send(wmi_handle, &params);
1261 }
1262 #endif /*WLAN_FEATURE_11BE_MLO && WLAN_MLO_MULTI_CHIP*/
1263