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