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