xref: /wlan-dirver/qca-wifi-host-cmn/ipa/core/src/wlan_ipa_main.c (revision 536dd3af2c156b7fedaa2ec5c0da044b17f61d88)
1 /*
2  * Copyright (c) 2018-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: contains ipa component main function definitions
22  */
23 
24 #include "wlan_ipa_main.h"
25 #include "wlan_ipa_core.h"
26 #include "wlan_ipa_tgt_api.h"
27 #include "cfg_ucfg_api.h"
28 #include "wlan_ipa_obj_mgmt_api.h"
29 
30 static struct wlan_ipa_config *g_ipa_config;
31 static bool g_ipa_hw_support;
32 static bool g_ipa_pld_enable = true;
33 
34 void ipa_set_pld_enable(bool flag)
35 {
36 	g_ipa_pld_enable = flag;
37 }
38 
39 bool ipa_get_pld_enable(void)
40 {
41 	return g_ipa_pld_enable;
42 }
43 
44 bool ipa_check_hw_present(void)
45 {
46 	/* Check if ipa hw is enabled */
47 	if (qdf_ipa_uc_reg_rdyCB(NULL) != -EPERM) {
48 		g_ipa_hw_support = true;
49 		return true;
50 	} else {
51 		return false;
52 	}
53 }
54 
55 QDF_STATUS ipa_config_mem_alloc(void)
56 {
57 	struct wlan_ipa_config *ipa_cfg;
58 
59 	if (g_ipa_config)
60 		return QDF_STATUS_SUCCESS;
61 
62 	ipa_cfg = qdf_mem_malloc(sizeof(*ipa_cfg));
63 	if (!ipa_cfg)
64 		return QDF_STATUS_E_NOMEM;
65 
66 	g_ipa_config = ipa_cfg;
67 
68 	return QDF_STATUS_SUCCESS;
69 }
70 
71 void ipa_config_mem_free(void)
72 {
73 	if (!g_instances_added) {
74 		if (!g_ipa_config) {
75 			ipa_err("IPA config already freed");
76 			return;
77 		}
78 
79 		qdf_mem_free(g_ipa_config);
80 		g_ipa_config = NULL;
81 	}
82 }
83 
84 bool ipa_is_hw_support(void)
85 {
86 	return g_ipa_hw_support;
87 }
88 
89 bool ipa_config_is_enabled(void)
90 {
91 	return g_ipa_config ? wlan_ipa_is_enabled(g_ipa_config) : 0;
92 }
93 
94 bool ipa_config_is_uc_enabled(void)
95 {
96 	return g_ipa_config ? wlan_ipa_uc_is_enabled(g_ipa_config) : 0;
97 }
98 
99 bool ipa_config_is_opt_wifi_dp_enabled(void)
100 {
101 	return g_ipa_config ? wlan_ipa_is_opt_wifi_dp_enabled(g_ipa_config) : 0;
102 }
103 
104 bool ipa_config_is_vlan_enabled(void)
105 {
106 	if (!ipa_config_is_enabled())
107 		return false;
108 
109 	return g_ipa_config ? g_ipa_config->ipa_vlan_support : 0;
110 }
111 
112 QDF_STATUS ipa_obj_setup(struct wlan_ipa_priv *ipa_ctx)
113 {
114 	return wlan_ipa_setup(ipa_ctx, g_ipa_config);
115 }
116 
117 QDF_STATUS ipa_obj_cleanup(struct wlan_ipa_priv *ipa_ctx)
118 {
119 	return wlan_ipa_cleanup(ipa_ctx);
120 }
121 
122 QDF_STATUS ipa_send_uc_offload_enable_disable(struct wlan_objmgr_pdev *pdev,
123 				struct ipa_uc_offload_control_params *req)
124 {
125 	return tgt_ipa_uc_offload_enable_disable(pdev, req);
126 }
127 
128 QDF_STATUS
129 ipa_send_intrabss_enable_disable(struct wlan_objmgr_pdev *pdev,
130 				 struct ipa_intrabss_control_params *req)
131 {
132 	return tgt_ipa_intrabss_enable_disable(pdev, req);
133 }
134 
135 void ipa_set_dp_handle(struct wlan_objmgr_psoc *psoc, void *dp_soc)
136 {
137 	struct wlan_objmgr_pdev *pdev;
138 	struct wlan_ipa_priv *ipa_obj;
139 
140 	if (!ipa_config_is_enabled()) {
141 		ipa_debug("ipa is disabled");
142 		return;
143 	}
144 
145 	pdev = wlan_objmgr_get_pdev_by_id(psoc, 0,
146 					  WLAN_IPA_ID);
147 
148 	if (!pdev) {
149 		ipa_err("Failed to get pdev handle");
150 		return;
151 	}
152 
153 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
154 	if (!ipa_obj) {
155 		ipa_err("IPA object is NULL");
156 		wlan_objmgr_pdev_release_ref(pdev, WLAN_IPA_ID);
157 		return;
158 	}
159 
160 	ipa_obj->dp_soc = dp_soc;
161 	wlan_objmgr_pdev_release_ref(pdev, WLAN_IPA_ID);
162 }
163 
164 void ipa_set_pdev_id(struct wlan_objmgr_psoc *psoc, uint8_t pdev_id)
165 {
166 	struct wlan_objmgr_pdev *pdev;
167 	struct wlan_ipa_priv *ipa_obj;
168 
169 	if (!ipa_config_is_enabled()) {
170 		ipa_debug("ipa is disabled");
171 		return;
172 	}
173 
174 	pdev = wlan_objmgr_get_pdev_by_id(psoc, 0,
175 					  WLAN_IPA_ID);
176 
177 	if (!pdev) {
178 		ipa_err("Failed to get pdev handle");
179 		return;
180 	}
181 
182 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
183 	if (!ipa_obj) {
184 		ipa_err("IPA object is NULL");
185 		wlan_objmgr_pdev_release_ref(pdev, WLAN_IPA_ID);
186 		return;
187 	}
188 
189 	ipa_obj->dp_pdev_id = pdev_id;
190 	wlan_objmgr_pdev_release_ref(pdev, WLAN_IPA_ID);
191 }
192 
193 QDF_STATUS ipa_rm_set_perf_level(struct wlan_objmgr_pdev *pdev,
194 				 uint64_t tx_packets, uint64_t rx_packets)
195 {
196 	struct wlan_ipa_priv *ipa_obj;
197 
198 	if (!ipa_config_is_enabled()) {
199 		ipa_debug("ipa is disabled");
200 		return QDF_STATUS_SUCCESS;
201 	}
202 
203 	if (!ipa_cb_is_ready())
204 		return QDF_STATUS_SUCCESS;
205 
206 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
207 	if (!ipa_obj) {
208 		ipa_err("IPA object is NULL");
209 		return QDF_STATUS_E_FAILURE;
210 	}
211 
212 	return wlan_ipa_set_perf_level(ipa_obj, tx_packets, rx_packets);
213 }
214 
215 void ipa_uc_info(struct wlan_objmgr_pdev *pdev)
216 {
217 	struct wlan_ipa_priv *ipa_obj;
218 
219 	if (!ipa_config_is_enabled()) {
220 		ipa_debug("ipa is disabled");
221 		return;
222 	}
223 
224 	if (!ipa_cb_is_ready())
225 		return;
226 
227 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
228 	if (!ipa_obj) {
229 		ipa_err("IPA object is NULL");
230 		return;
231 	}
232 
233 	return wlan_ipa_uc_info(ipa_obj);
234 }
235 
236 void ipa_uc_stat(struct wlan_objmgr_pdev *pdev)
237 {
238 	struct wlan_ipa_priv *ipa_obj;
239 
240 	if (!ipa_config_is_enabled()) {
241 		ipa_debug("ipa is disabled");
242 		return;
243 	}
244 
245 	if (!ipa_cb_is_ready())
246 		return;
247 
248 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
249 	if (!ipa_obj) {
250 		ipa_err("IPA object is NULL");
251 		return;
252 	}
253 
254 	return wlan_ipa_uc_stat(ipa_obj);
255 }
256 
257 void ipa_uc_rt_debug_host_dump(struct wlan_objmgr_pdev *pdev)
258 {
259 	struct wlan_ipa_priv *ipa_obj;
260 
261 	if (!ipa_config_is_enabled()) {
262 		ipa_debug("ipa is disabled");
263 		return;
264 	}
265 
266 	if (!ipa_cb_is_ready())
267 		return;
268 
269 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
270 	if (!ipa_obj) {
271 		ipa_err("IPA object is NULL");
272 		return;
273 	}
274 
275 	return wlan_ipa_uc_rt_debug_host_dump(ipa_obj);
276 }
277 
278 void ipa_dump_info(struct wlan_objmgr_pdev *pdev)
279 {
280 	struct wlan_ipa_priv *ipa_obj;
281 
282 	if (!ipa_config_is_enabled()) {
283 		ipa_debug("ipa is disabled");
284 		return;
285 	}
286 
287 	if (!ipa_cb_is_ready())
288 		return;
289 
290 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
291 	if (!ipa_obj) {
292 		ipa_err("IPA object is NULL");
293 		return;
294 	}
295 
296 	return wlan_ipa_dump_info(ipa_obj);
297 }
298 
299 void ipa_uc_stat_request(struct wlan_objmgr_pdev *pdev, uint8_t reason)
300 {
301 	struct wlan_ipa_priv *ipa_obj;
302 
303 	if (!ipa_config_is_enabled()) {
304 		ipa_debug("ipa is disabled");
305 		return;
306 	}
307 
308 	if (!ipa_cb_is_ready())
309 		return;
310 
311 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
312 	if (!ipa_obj) {
313 		ipa_err("IPA object is NULL");
314 		return;
315 	}
316 
317 	return wlan_ipa_uc_stat_request(ipa_obj, reason);
318 }
319 
320 void ipa_uc_stat_query(struct wlan_objmgr_pdev *pdev,
321 		       uint32_t *ipa_tx_diff, uint32_t *ipa_rx_diff)
322 {
323 	struct wlan_ipa_priv *ipa_obj;
324 
325 	if (!ipa_config_is_enabled()) {
326 		ipa_debug("ipa is disabled");
327 		return;
328 	}
329 
330 	if (!ipa_cb_is_ready())
331 		return;
332 
333 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
334 	if (!ipa_obj) {
335 		ipa_err("IPA object is NULL");
336 		return;
337 	}
338 
339 	return wlan_ipa_uc_stat_query(ipa_obj, ipa_tx_diff, ipa_rx_diff);
340 }
341 
342 void ipa_reg_sap_xmit_cb(struct wlan_objmgr_pdev *pdev, wlan_ipa_softap_xmit cb)
343 {
344 	struct wlan_ipa_priv *ipa_obj;
345 
346 	if (!ipa_config_is_enabled()) {
347 		ipa_debug("ipa is disabled");
348 		return;
349 	}
350 
351 	if (!ipa_cb_is_ready())
352 		return;
353 
354 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
355 	if (!ipa_obj) {
356 		ipa_err("IPA object is NULL");
357 		return;
358 	}
359 
360 	return wlan_ipa_reg_sap_xmit_cb(ipa_obj, cb);
361 }
362 
363 void ipa_reg_send_to_nw_cb(struct wlan_objmgr_pdev *pdev,
364 			   wlan_ipa_send_to_nw cb)
365 {
366 	struct wlan_ipa_priv *ipa_obj;
367 
368 	if (!ipa_config_is_enabled()) {
369 		ipa_debug("ipa is disabled");
370 		return;
371 	}
372 
373 	if (!ipa_cb_is_ready())
374 		return;
375 
376 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
377 	if (!ipa_obj) {
378 		ipa_err("IPA object is NULL");
379 		return;
380 	}
381 
382 	return wlan_ipa_reg_send_to_nw_cb(ipa_obj, cb);
383 }
384 
385 #if defined(QCA_CONFIG_RPS) && !defined(MDM_PLATFORM)
386 void ipa_reg_rps_enable_cb(struct wlan_objmgr_pdev *pdev,
387 			   wlan_ipa_rps_enable cb)
388 {
389 	struct wlan_ipa_priv *ipa_obj;
390 
391 	if (!ipa_config_is_enabled()) {
392 		ipa_debug("ipa is disabled");
393 		return;
394 	}
395 
396 	if (!ipa_cb_is_ready())
397 		return;
398 
399 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
400 	if (!ipa_obj) {
401 		ipa_err("IPA object is NULL");
402 		return;
403 	}
404 
405 	return wlan_ipa_reg_rps_enable_cb(ipa_obj, cb);
406 }
407 #endif
408 
409 void ipa_reg_is_driver_unloading_cb(struct wlan_objmgr_pdev *pdev,
410 				    wlan_ipa_driver_unloading cb)
411 {
412 	struct wlan_ipa_priv *ipa_obj;
413 
414 	if (!ipa_config_is_enabled()) {
415 		ipa_debug("ipa is disabled");
416 		return;
417 	}
418 
419 	if (!ipa_cb_is_ready())
420 		return;
421 
422 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
423 	if (!ipa_obj) {
424 		ipa_err("IPA object is NULL");
425 		return;
426 	}
427 
428 	return wlan_ipa_reg_is_driver_unloading_cb(ipa_obj, cb);
429 }
430 
431 void ipa_set_mcc_mode(struct wlan_objmgr_pdev *pdev, bool mcc_mode)
432 {
433 	struct wlan_ipa_priv *ipa_obj;
434 
435 	if (!ipa_config_is_enabled()) {
436 		ipa_debug("ipa is disabled");
437 		return;
438 	}
439 
440 	if (!ipa_cb_is_ready())
441 		return;
442 
443 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
444 	if (!ipa_obj) {
445 		ipa_err("IPA object is NULL");
446 		return;
447 	}
448 
449 	return wlan_ipa_set_mcc_mode(ipa_obj, mcc_mode);
450 }
451 
452 void ipa_set_dfs_cac_tx(struct wlan_objmgr_pdev *pdev, bool tx_block)
453 {
454 	struct wlan_ipa_priv *ipa_obj;
455 
456 	if (!ipa_config_is_enabled()) {
457 		ipa_debug("ipa is disabled");
458 		return;
459 	}
460 
461 	if (!ipa_cb_is_ready())
462 		return;
463 
464 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
465 	if (!ipa_obj) {
466 		ipa_err("IPA object is NULL");
467 		return;
468 	}
469 
470 	return wlan_ipa_set_dfs_cac_tx(ipa_obj, tx_block);
471 }
472 
473 void ipa_set_ap_ibss_fwd(struct wlan_objmgr_pdev *pdev, uint8_t session_id,
474 			 bool intra_bss)
475 {
476 	struct wlan_ipa_priv *ipa_obj;
477 
478 	if (!ipa_config_is_enabled()) {
479 		ipa_debug("ipa is disabled");
480 		return;
481 	}
482 
483 	if (!ipa_cb_is_ready())
484 		return;
485 
486 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
487 	if (!ipa_obj) {
488 		ipa_err("IPA object is NULL");
489 		return;
490 	}
491 
492 	return wlan_ipa_set_ap_ibss_fwd(ipa_obj, session_id, intra_bss);
493 }
494 
495 void ipa_uc_force_pipe_shutdown(struct wlan_objmgr_pdev *pdev)
496 {
497 	struct wlan_ipa_priv *ipa_obj;
498 
499 	if (!pdev) {
500 		ipa_debug("objmgr pdev is null!");
501 		return;
502 	}
503 
504 	if (!ipa_config_is_enabled()) {
505 		ipa_debug("ipa is disabled");
506 		return;
507 	}
508 
509 	if (!ipa_cb_is_ready())
510 		return;
511 
512 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
513 	if (!ipa_obj) {
514 		ipa_err("IPA object is NULL");
515 		return;
516 	}
517 
518 	wlan_ipa_uc_disable_pipes(ipa_obj, true);
519 }
520 
521 void ipa_flush(struct wlan_objmgr_pdev *pdev)
522 {
523 	struct wlan_ipa_priv *ipa_obj;
524 
525 	if (!ipa_config_is_enabled()) {
526 		ipa_debug("ipa is disabled");
527 		return;
528 	}
529 
530 	if (!ipa_cb_is_ready())
531 		return;
532 
533 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
534 	if (!ipa_obj) {
535 		ipa_err("IPA object is NULL");
536 		return;
537 	}
538 
539 	return wlan_ipa_flush(ipa_obj);
540 }
541 
542 QDF_STATUS ipa_suspend(struct wlan_objmgr_pdev *pdev)
543 {
544 	struct wlan_ipa_priv *ipa_obj;
545 
546 	if (!ipa_config_is_enabled()) {
547 		ipa_debug("ipa is disabled");
548 		return QDF_STATUS_SUCCESS;
549 	}
550 
551 	if (!ipa_cb_is_ready())
552 		return QDF_STATUS_SUCCESS;
553 
554 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
555 	if (!ipa_obj) {
556 		ipa_err("IPA object is NULL");
557 		return QDF_STATUS_E_FAILURE;
558 	}
559 
560 	return wlan_ipa_suspend(ipa_obj);
561 }
562 
563 QDF_STATUS ipa_resume(struct wlan_objmgr_pdev *pdev)
564 {
565 	struct wlan_ipa_priv *ipa_obj;
566 
567 	if (!ipa_config_is_enabled()) {
568 		ipa_debug("ipa is disabled");
569 		return QDF_STATUS_SUCCESS;
570 	}
571 
572 	if (!ipa_cb_is_ready())
573 		return QDF_STATUS_SUCCESS;
574 
575 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
576 	if (!ipa_obj) {
577 		ipa_err("IPA object is NULL");
578 		return QDF_STATUS_E_FAILURE;
579 	}
580 
581 	return wlan_ipa_resume(ipa_obj);
582 }
583 
584 QDF_STATUS ipa_uc_ol_init(struct wlan_objmgr_pdev *pdev,
585 			  qdf_device_t osdev)
586 {
587 	struct wlan_ipa_priv *ipa_obj;
588 
589 	if (!ipa_config_is_enabled()) {
590 		ipa_debug("ipa is disabled");
591 		return QDF_STATUS_SUCCESS;
592 	}
593 
594 	if (!ipa_cb_is_ready())
595 		return QDF_STATUS_SUCCESS;
596 
597 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
598 	if (!ipa_obj) {
599 		ipa_err("IPA object is NULL");
600 		return QDF_STATUS_E_FAILURE;
601 	}
602 
603 	return wlan_ipa_uc_ol_init(ipa_obj, osdev);
604 }
605 
606 bool ipa_is_tx_pending(struct wlan_objmgr_pdev *pdev)
607 {
608 	struct wlan_ipa_priv *ipa_obj;
609 
610 	if (!ipa_config_is_enabled()) {
611 		ipa_debug("ipa is disabled");
612 		return QDF_STATUS_SUCCESS;
613 	}
614 
615 	if (!ipa_cb_is_ready())
616 		return QDF_STATUS_SUCCESS;
617 
618 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
619 
620 	return wlan_ipa_is_tx_pending(ipa_obj);
621 }
622 
623 QDF_STATUS ipa_uc_ol_deinit(struct wlan_objmgr_pdev *pdev)
624 {
625 	struct wlan_ipa_priv *ipa_obj;
626 	QDF_STATUS status;
627 
628 	if (!ipa_config_is_enabled()) {
629 		ipa_debug("ipa is disabled");
630 		return QDF_STATUS_SUCCESS;
631 	}
632 
633 	ipa_init_deinit_lock();
634 
635 	if (!ipa_cb_is_ready()) {
636 		ipa_debug("ipa is not ready");
637 		status = QDF_STATUS_SUCCESS;
638 		goto out;
639 	}
640 
641 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
642 	if (!ipa_obj) {
643 		ipa_err("IPA object is NULL");
644 		status = QDF_STATUS_E_FAILURE;
645 		goto out;
646 	}
647 
648 	if (!(ipa_obj->handle_initialized)) {
649 		ipa_debug("IPA is already deinit for hdl:%d", ipa_obj->hdl);
650 		status = QDF_STATUS_SUCCESS;
651 		goto out;
652 	}
653 
654 	status = wlan_ipa_uc_ol_deinit(ipa_obj);
655 	ipa_obj_cleanup(ipa_obj);
656 
657 out:
658 	if (g_instances_added)
659 		g_instances_added--;
660 
661 	if (!g_instances_added)
662 		ipa_disable_register_cb();
663 
664 	ipa_init_deinit_unlock();
665 	return status;
666 }
667 
668 QDF_STATUS ipa_send_mcc_scc_msg(struct wlan_objmgr_pdev *pdev,
669 				bool mcc_mode)
670 {
671 	struct wlan_ipa_priv *ipa_obj;
672 
673 	if (!ipa_config_is_enabled()) {
674 		ipa_debug("ipa is disabled");
675 		return QDF_STATUS_SUCCESS;
676 	}
677 
678 	if (!ipa_cb_is_ready())
679 		return QDF_STATUS_SUCCESS;
680 
681 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
682 	if (!ipa_obj) {
683 		ipa_err("IPA object is NULL");
684 		return QDF_STATUS_E_FAILURE;
685 	}
686 
687 	return wlan_ipa_send_mcc_scc_msg(ipa_obj, mcc_mode);
688 }
689 
690 QDF_STATUS ipa_wlan_evt(struct wlan_objmgr_pdev *pdev, qdf_netdev_t net_dev,
691 			uint8_t device_mode, uint8_t session_id,
692 			enum wlan_ipa_wlan_event ipa_event_type,
693 			const uint8_t *mac_addr, bool is_2g_iface)
694 {
695 	struct wlan_ipa_priv *ipa_obj;
696 
697 	if (!ipa_cb_is_ready())
698 		return QDF_STATUS_SUCCESS;
699 
700 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
701 	if (!ipa_obj) {
702 		ipa_err("IPA object is NULL");
703 		return QDF_STATUS_E_FAILURE;
704 	}
705 
706 	return wlan_ipa_wlan_evt(net_dev, device_mode, session_id,
707 				 ipa_event_type, mac_addr, is_2g_iface,
708 				 ipa_obj);
709 }
710 
711 int ipa_uc_smmu_map(bool map, uint32_t num_buf, qdf_mem_info_t *buf_arr)
712 {
713 	return wlan_ipa_uc_smmu_map(map, num_buf, buf_arr);
714 }
715 
716 bool ipa_is_fw_wdi_activated(struct wlan_objmgr_pdev *pdev)
717 {
718 	struct wlan_ipa_priv *ipa_obj;
719 
720 	if (!ipa_config_is_enabled()) {
721 		ipa_debug_rl("ipa is disabled");
722 		return false;
723 	}
724 
725 	if (!ipa_cb_is_ready()) {
726 		ipa_debug("ipa is not ready");
727 		return false;
728 	}
729 
730 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
731 	if (!ipa_obj) {
732 		ipa_err_rl("IPA object is NULL");
733 		return false;
734 	}
735 
736 	return wlan_ipa_is_fw_wdi_activated(ipa_obj);
737 }
738 
739 void ipa_uc_cleanup_sta(struct wlan_objmgr_pdev *pdev,
740 			qdf_netdev_t net_dev, uint8_t session_id)
741 {
742 	struct wlan_ipa_priv *ipa_obj;
743 
744 	if (!ipa_cb_is_ready()) {
745 		ipa_debug("ipa is not ready");
746 		return;
747 	}
748 
749 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
750 	if (!ipa_obj) {
751 		ipa_err("IPA object is NULL");
752 		return;
753 	}
754 
755 	return wlan_ipa_uc_cleanup_sta(ipa_obj, net_dev, session_id);
756 }
757 
758 QDF_STATUS ipa_uc_disconnect_ap(struct wlan_objmgr_pdev *pdev,
759 				qdf_netdev_t net_dev)
760 {
761 	struct wlan_ipa_priv *ipa_obj;
762 
763 	if (!ipa_cb_is_ready())
764 		return QDF_STATUS_SUCCESS;
765 
766 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
767 	if (!ipa_obj) {
768 		ipa_err("IPA object is NULL");
769 		return QDF_STATUS_E_FAILURE;
770 	}
771 
772 	return wlan_ipa_uc_disconnect_ap(ipa_obj, net_dev);
773 }
774 
775 void ipa_cleanup_dev_iface(struct wlan_objmgr_pdev *pdev,
776 			   qdf_netdev_t net_dev, uint8_t session_id)
777 {
778 	struct wlan_ipa_priv *ipa_obj;
779 
780 	if (!ipa_cb_is_ready())
781 		return;
782 
783 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
784 	if (!ipa_obj) {
785 		ipa_err("IPA object is NULL");
786 		return;
787 	}
788 
789 	return wlan_ipa_cleanup_dev_iface(ipa_obj, net_dev, session_id);
790 }
791 
792 void ipa_uc_ssr_cleanup(struct wlan_objmgr_pdev *pdev)
793 {
794 	struct wlan_ipa_priv *ipa_obj;
795 
796 	if (!ipa_cb_is_ready())
797 		return;
798 
799 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
800 	if (!ipa_obj) {
801 		ipa_err("IPA object is NULL");
802 		return;
803 	}
804 
805 	return wlan_ipa_uc_ssr_cleanup(ipa_obj);
806 }
807 
808 void ipa_fw_rejuvenate_send_msg(struct wlan_objmgr_pdev *pdev)
809 {
810 	struct wlan_ipa_priv *ipa_obj;
811 
812 	if (!pdev) {
813 		ipa_debug("objmgr pdev is null!");
814 		return;
815 	}
816 
817 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
818 	if (!ipa_obj) {
819 		ipa_err("IPA object is NULL");
820 		return;
821 	}
822 
823 	return wlan_ipa_fw_rejuvenate_send_msg(ipa_obj);
824 }
825 
826 #ifdef IPA_OPT_WIFI_DP
827 uint32_t get_ipa_config(struct wlan_objmgr_psoc *psoc)
828 {
829 	uint32_t val = cfg_get(psoc, CFG_DP_IPA_OFFLOAD_CONFIG);
830 
831 	if (val == INTRL_MODE_DISABLE) {
832 		val = 0;
833 	} else {
834 		if (val == IPA_OFFLOAD_CFG)
835 			ipa_err("Invalid IPA Config 0x%x", val);
836 		val = INTRL_MODE_ENABLE;
837 	}
838 	ipa_info("IPAConfig set as 0x%x", val);
839 	return val;
840 }
841 #else
842 uint32_t get_ipa_config(struct wlan_objmgr_psoc *psoc)
843 {
844 	uint32_t val = cfg_get(psoc, CFG_DP_IPA_OFFLOAD_CONFIG);
845 
846 	if (val & WLAN_IPA_OPT_WIFI_DP) {
847 		val &= ~WLAN_IPA_OPT_WIFI_DP;
848 		ipa_info("Resetting IPAConfig val to 0x%x", val);
849 	}
850 	return val;
851 }
852 #endif
853 
854 void ipa_component_config_update(struct wlan_objmgr_psoc *psoc)
855 {
856 	QDF_STATUS status;
857 
858 	status = ipa_config_mem_alloc();
859 	if (QDF_IS_STATUS_ERROR(status)) {
860 		ipa_err("Failed to alloc g_ipa_config");
861 		return;
862 	}
863 
864 	if (g_ipa_pld_enable) {
865 		g_ipa_config->ipa_config = get_ipa_config(psoc);
866 		ipa_info("IPA ini configuration: 0x%x",
867 			 g_ipa_config->ipa_config);
868 	} else {
869 		g_ipa_config->ipa_config = 0;
870 		ipa_info("IPA disabled from platform driver");
871 	}
872 
873 	g_ipa_config->desc_size =
874 		cfg_get(psoc, CFG_DP_IPA_DESC_SIZE);
875 	g_ipa_config->txbuf_count =
876 		qdf_rounddown_pow_of_two(cfg_get(psoc,
877 						 CFG_DP_IPA_UC_TX_BUF_COUNT));
878 	g_ipa_config->ipa_bw_high =
879 		cfg_get(psoc, CFG_DP_IPA_HIGH_BANDWIDTH_MBPS);
880 	g_ipa_config->ipa_bw_medium =
881 		cfg_get(psoc, CFG_DP_IPA_MEDIUM_BANDWIDTH_MBPS);
882 	g_ipa_config->ipa_bw_low =
883 		cfg_get(psoc, CFG_DP_IPA_LOW_BANDWIDTH_MBPS);
884 	g_ipa_config->bus_bw_high =
885 		cfg_get(psoc, CFG_DP_BUS_BANDWIDTH_HIGH_THRESHOLD);
886 	g_ipa_config->bus_bw_medium =
887 		cfg_get(psoc, CFG_DP_BUS_BANDWIDTH_MEDIUM_THRESHOLD);
888 	g_ipa_config->bus_bw_low =
889 		cfg_get(psoc, CFG_DP_BUS_BANDWIDTH_LOW_THRESHOLD);
890 	g_ipa_config->ipa_force_voting =
891 		cfg_get(psoc, CFG_DP_IPA_ENABLE_FORCE_VOTING);
892 	g_ipa_config->ipa_wds =
893 		cfg_get(psoc, CFG_DP_IPA_WDS_STATUS);
894 	g_ipa_config->ipa_vlan_support =
895 		cfg_get(psoc, CFG_DP_IPA_ENABLE_VLAN_SUPPORT);
896 }
897 
898 void ipa_component_config_free(void)
899 {
900 	ipa_info("Free the IPA config memory");
901 	ipa_config_mem_free();
902 }
903 
904 uint32_t ipa_get_tx_buf_count(void)
905 {
906 	return g_ipa_config ? g_ipa_config->txbuf_count : 0;
907 }
908 
909 void ipa_update_tx_stats(struct wlan_objmgr_pdev *pdev, uint64_t sta_tx,
910 			 uint64_t ap_tx)
911 {
912 	struct wlan_ipa_priv *ipa_obj;
913 
914 	if (!ipa_config_is_enabled())
915 		return;
916 
917 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
918 	if (!ipa_obj) {
919 		ipa_err("IPA object is NULL");
920 		return;
921 	}
922 
923 	wlan_ipa_update_tx_stats(ipa_obj, sta_tx, ap_tx);
924 }
925 
926 void ipa_flush_pending_vdev_events(struct wlan_objmgr_pdev *pdev,
927 				   uint8_t vdev_id)
928 {
929 	struct wlan_ipa_priv *ipa_obj;
930 
931 	if (!ipa_config_is_enabled())
932 		return;
933 
934 	if (!ipa_cb_is_ready())
935 		return;
936 
937 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
938 	if (!ipa_obj) {
939 		ipa_err("IPA object is NULL");
940 		return;
941 	}
942 
943 	wlan_ipa_flush_pending_vdev_events(ipa_obj, vdev_id);
944 }
945 
946 bool ipa_is_wds_enabled(void)
947 {
948 	return g_ipa_config ? g_ipa_config->ipa_wds : 0;
949 }
950 
951 QDF_STATUS ipa_get_alt_pipe(struct wlan_objmgr_pdev *pdev,
952 			    uint8_t vdev_id,
953 			    bool *alt_pipe)
954 {
955 	struct wlan_ipa_priv *ipa_obj;
956 
957 	if (!ipa_config_is_enabled())
958 		return QDF_STATUS_E_INVAL;
959 
960 	if (!ipa_cb_is_ready())
961 		return QDF_STATUS_E_INVAL;
962 
963 	ipa_obj = ipa_pdev_get_priv_obj(pdev);
964 	if (!ipa_obj) {
965 		ipa_err("IPA object is NULL");
966 		return QDF_STATUS_E_INVAL;
967 	}
968 
969 	return wlan_ipa_get_alt_pipe(ipa_obj, vdev_id, alt_pipe);
970 }
971 
972