xref: /wlan-driver/qca-wifi-host-cmn/target_if/cfr/src/target_if_cfr_6490.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-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: target_if_cfr_6490.c
22  *
23  * Target interface of CFR for QCA6490 implementation
24  *
25  */
26 
27 #include <cdp_txrx_ctrl.h>
28 #include "target_if_cfr.h"
29 #include <qdf_nbuf.h>
30 #include "wlan_cfr_utils_api.h"
31 #include "target_if_cfr_6490.h"
32 #include "target_if_cfr_enh.h"
33 #include "init_deinit_lmac.h"
34 #include "cfg_ucfg_api.h"
35 #include "cfr_cfg.h"
36 
37 #ifdef WLAN_ENH_CFR_ENABLE
38 #ifdef CFR_USE_FIXED_FOLDER
39 static wdi_event_subscribe g_cfr_subscribe;
40 
target_cfr_callback(void * pdev_obj,enum WDI_EVENT event,void * data,u_int16_t peer_id,uint32_t status)41 static void target_cfr_callback(void *pdev_obj, enum WDI_EVENT event,
42 				void *data, u_int16_t peer_id,
43 				uint32_t status)
44 {
45 	struct wlan_objmgr_pdev *pdev;
46 	qdf_nbuf_t nbuf = (qdf_nbuf_t)data;
47 	qdf_nbuf_t data_clone;
48 
49 	pdev = (struct wlan_objmgr_pdev *)pdev_obj;
50 	if (qdf_unlikely((!pdev || !data))) {
51 		cfr_err("Invalid pdev %pK or data %pK for event %d",
52 			pdev, data, event);
53 		qdf_nbuf_free(nbuf);
54 		return;
55 	}
56 
57 	if (event != WDI_EVENT_RX_PPDU_DESC) {
58 		cfr_debug("event is %d", event);
59 		qdf_nbuf_free(nbuf);
60 		return;
61 	}
62 
63 	data_clone = qdf_nbuf_clone(nbuf);
64 	if (data_clone)
65 		wlan_cfr_rx_tlv_process(pdev, (void *)data_clone);
66 
67 	qdf_nbuf_free(nbuf);
68 }
69 
70 QDF_STATUS
target_if_cfr_subscribe_ppdu_desc(struct wlan_objmgr_pdev * pdev,bool is_subscribe)71 target_if_cfr_subscribe_ppdu_desc(struct wlan_objmgr_pdev *pdev,
72 				  bool is_subscribe)
73 {
74 	ol_txrx_soc_handle soc;
75 	struct wlan_objmgr_psoc *psoc;
76 	struct pdev_cfr *pcfr;
77 
78 	if (!pdev) {
79 		cfr_err("Null pdev");
80 		return QDF_STATUS_E_INVAL;
81 	}
82 
83 	pcfr = wlan_objmgr_pdev_get_comp_private_obj(
84 				pdev, WLAN_UMAC_COMP_CFR);
85 	if (!pcfr) {
86 		cfr_err("pcfr is NULL");
87 		return QDF_STATUS_E_INVAL;
88 	}
89 
90 	psoc = wlan_pdev_get_psoc(pdev);
91 	if (!psoc) {
92 		cfr_err("Null psoc");
93 		return QDF_STATUS_E_INVAL;
94 	}
95 
96 	soc = wlan_psoc_get_dp_handle(psoc);
97 	if (!soc) {
98 		cfr_err("Null soc");
99 		return QDF_STATUS_E_INVAL;
100 	}
101 
102 	g_cfr_subscribe.callback = target_cfr_callback;
103 	g_cfr_subscribe.context = pdev;
104 	cdp_set_cfr_rcc(soc, 0, is_subscribe);
105 	cdp_enable_mon_reap_timer(soc, CDP_MON_REAP_SOURCE_CFR, is_subscribe);
106 	if (is_subscribe) {
107 		if (cdp_wdi_event_sub(soc, 0, &g_cfr_subscribe,
108 				      WDI_EVENT_RX_PPDU_DESC)) {
109 			cfr_err("wdi event sub fail");
110 			return QDF_STATUS_E_FAILURE;
111 		}
112 	} else {
113 		if (cdp_wdi_event_unsub(soc, 0, &g_cfr_subscribe,
114 					WDI_EVENT_RX_PPDU_DESC)) {
115 			cfr_err("wdi event unsub fail");
116 			return QDF_STATUS_E_FAILURE;
117 		}
118 	}
119 
120 	return QDF_STATUS_SUCCESS;
121 }
122 #endif
123 #endif
124 
125 
126