xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_mon.h (revision 8cfe6b10058a04cafb17eed051f2ddf11bee8931)
1 /*
2  * Copyright (c) 2016-2021 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  * @file cdp_txrx_mon.h
22  * @brief Define the monitor mode API functions
23  * called by the host control SW and the OS interface module
24  */
25 
26 #ifndef _CDP_TXRX_MON_H_
27 #define _CDP_TXRX_MON_H_
28 #include "cdp_txrx_handle.h"
29 #include <cdp_txrx_cmn.h>
30 
31 static inline QDF_STATUS cdp_reset_monitor_mode(ol_txrx_soc_handle soc,
32 						uint8_t pdev_id,
33 						u_int8_t smart_monitor)
34 {
35 	if (!soc || !soc->ops) {
36 		dp_cdp_debug("Invalid Instance");
37 		QDF_BUG(0);
38 		return 0;
39 	}
40 
41 	if (!soc->ops->mon_ops ||
42 	    !soc->ops->mon_ops->txrx_reset_monitor_mode)
43 		return 0;
44 
45 	return soc->ops->mon_ops->txrx_reset_monitor_mode(soc, pdev_id,
46 							  smart_monitor);
47 }
48 
49 /**
50  * cdp_deliver_tx_mgmt() - Deliver mgmt frame for tx capture
51  * @soc: Datapath SOC handle
52  * @pdev_id: id of datapath PDEV handle
53  * @nbuf: Management frame buffer
54  */
55 static inline QDF_STATUS
56 cdp_deliver_tx_mgmt(ol_txrx_soc_handle soc, uint8_t pdev_id,
57 		    qdf_nbuf_t nbuf)
58 {
59 	if (!soc || !soc->ops) {
60 		dp_cdp_debug("Invalid Instance");
61 		QDF_BUG(0);
62 		return QDF_STATUS_E_FAILURE;
63 	}
64 
65 	if (!soc->ops->mon_ops ||
66 	    !soc->ops->mon_ops->txrx_deliver_tx_mgmt)
67 		return QDF_STATUS_E_FAILURE;
68 
69 	return soc->ops->mon_ops->txrx_deliver_tx_mgmt(soc, pdev_id, nbuf);
70 }
71 
72 #ifdef QCA_SUPPORT_LITE_MONITOR
73 /*
74  * cdp_set_lite_mon_config() - Set lite monitor config/filter
75  *
76  *@soc: dp soc handle
77  *@config: lite monitor config
78  *@pdev_id: pdev id
79  *
80  * This API is used to enable/disable lite monitor feature
81  *
82  * Return: QDF_STATUS_SUCCESS if value set successfully
83  *         QDF_STATUS_E_INVAL false if error
84  */
85 static inline QDF_STATUS
86 cdp_set_lite_mon_config(ol_txrx_soc_handle soc,
87 			struct cdp_lite_mon_filter_config *config,
88 			uint8_t pdev_id)
89 {
90 	if (!soc || !soc->ops) {
91 		dp_cdp_debug("Invalid Instance");
92 		return QDF_STATUS_E_INVAL;
93 	}
94 
95 	if (!soc->ops->mon_ops ||
96 	    !soc->ops->mon_ops->txrx_set_lite_mon_config)
97 		return QDF_STATUS_E_INVAL;
98 
99 	return soc->ops->mon_ops->txrx_set_lite_mon_config(soc, config,
100 							   pdev_id);
101 }
102 
103 /*
104  * cdp_get_lite_mon_config() - Get lite monitor config
105  *
106  *@soc: dp soc handle
107  *@config: lite monitor config
108  *@pdev_id: pdev id
109  *
110  * This API is used to get lite monitor feature config
111  *
112  * Return: QDF_STATUS_SUCCESS if get is successfully
113  *         QDF_STATUS_E_INVAL false if error
114  */
115 static inline QDF_STATUS
116 cdp_get_lite_mon_config(ol_txrx_soc_handle soc,
117 			struct cdp_lite_mon_filter_config *config,
118 			uint8_t pdev_id)
119 {
120 	if (!soc || !soc->ops) {
121 		dp_cdp_debug("Invalid Instance");
122 		return QDF_STATUS_E_INVAL;
123 	}
124 
125 	if (!soc->ops->mon_ops ||
126 	    !soc->ops->mon_ops->txrx_get_lite_mon_config)
127 		return QDF_STATUS_E_INVAL;
128 
129 	return soc->ops->mon_ops->txrx_get_lite_mon_config(soc, config,
130 							   pdev_id);
131 }
132 
133 /*
134  * cdp_set_lite_mon_peer_config() - Set lite monitor peer config
135  *
136  *@soc: dp soc handle
137  *@config: lite monitor peer config
138  *@pdev_id: pdev id
139  *
140  * This API is used to add/del lite monitor peers
141  *
142  * Return: QDF_STATUS_SUCCESS if value set successfully
143  *         QDF_STATUS_E_INVAL false if error
144  */
145 static inline QDF_STATUS
146 cdp_set_lite_mon_peer_config(ol_txrx_soc_handle soc,
147 			     struct cdp_lite_mon_peer_config *config,
148 			     uint8_t pdev_id)
149 {
150 	if (!soc || !soc->ops) {
151 		dp_cdp_debug("Invalid Instance");
152 		return QDF_STATUS_E_INVAL;
153 	}
154 
155 	if (!soc->ops->mon_ops ||
156 	    !soc->ops->mon_ops->txrx_set_lite_mon_peer_config)
157 		return QDF_STATUS_E_INVAL;
158 
159 	return soc->ops->mon_ops->txrx_set_lite_mon_peer_config(soc, config,
160 								pdev_id);
161 }
162 
163 /*
164  * cdp_get_lite_mon_peer_config() - Get lite monitor peer list
165  *
166  *@soc: dp soc handle
167  *@info: lite monitor peer info
168  *@pdev_id: pdev id
169  *
170  * This API is used to get lite monitor peers
171  *
172  * Return: QDF_STATUS_SUCCESS if value set successfully
173  *         QDF_STATUS_E_INVAL false if error
174  */
175 static inline QDF_STATUS
176 cdp_get_lite_mon_peer_config(ol_txrx_soc_handle soc,
177 			     struct cdp_lite_mon_peer_info *info,
178 			     uint8_t pdev_id)
179 {
180 	if (!soc || !soc->ops) {
181 		dp_cdp_debug("Invalid Instance");
182 		return QDF_STATUS_E_INVAL;
183 	}
184 
185 	if (!soc->ops->mon_ops ||
186 	    !soc->ops->mon_ops->txrx_get_lite_mon_peer_config)
187 		return QDF_STATUS_E_INVAL;
188 
189 	return soc->ops->mon_ops->txrx_get_lite_mon_peer_config(soc, info,
190 								pdev_id);
191 }
192 
193 /*
194  * cdp_is_lite_mon_enabled() - Get lite monitor enable status
195  *
196  *@soc: dp soc handle
197  *@pdev_id: pdev id
198  *@dir: direction tx/rx
199  *
200  * This API is used to get lite monitor enable status
201  *
202  * Return: 0 if disabled
203  *         1 if enabled
204  */
205 static inline int
206 cdp_is_lite_mon_enabled(ol_txrx_soc_handle soc,
207 			uint8_t pdev_id, uint8_t dir)
208 {
209 	if (!soc || !soc->ops) {
210 		dp_cdp_debug("Invalid Instance");
211 		return 0;
212 	}
213 
214 	if (!soc->ops->mon_ops ||
215 	    !soc->ops->mon_ops->txrx_is_lite_mon_enabled)
216 		return 0;
217 
218 	return soc->ops->mon_ops->txrx_is_lite_mon_enabled(soc, pdev_id, dir);
219 }
220 
221 /*
222  * cdp_get_lite_mon_legacy_feature_enabled() - Get the legacy feature enabled
223  *
224  * @soc: dp soc handle
225  * @pdev_id: pdev id
226  * @dir: direction tx/rx
227  *
228  *  This API is used to get the legacy feature enabled using lite_mon
229  *
230  * Return: legacy feature enabled
231  */
232 static inline int
233 cdp_get_lite_mon_legacy_feature_enabled(ol_txrx_soc_handle soc,
234 					uint8_t pdev_id, uint8_t dir)
235 {
236 	if (!soc || !soc->ops) {
237 		dp_cdp_debug("Invalid Instance");
238 		return 0;
239 	}
240 
241 	if (!soc->ops->mon_ops ||
242 	    !soc->ops->mon_ops->txrx_get_lite_mon_legacy_feature_enabled)
243 		return 0;
244 
245 	return soc->ops->mon_ops->txrx_get_lite_mon_legacy_feature_enabled(soc,
246 									   pdev_id,
247 									   dir);
248 }
249 #endif
250 
251 #ifdef QCA_RSSI_DB2DBM
252 /*
253  * cdp_set_params_rssi_dbm_conversion - Set the rssi dbm conversion params
254  *					into dp_pdev structure
255  * @soc: soc txrx handler
256  * @params: cdp_rssi_db2dbm_param_dp pointer
257  *
258  */
259 static inline QDF_STATUS
260 cdp_set_params_rssi_dbm_conversion(ol_txrx_soc_handle soc,
261 				   struct cdp_rssi_db2dbm_param_dp *params)
262 {
263 	if (!soc || !soc->ops) {
264 		dp_cdp_debug("Invalid Instance:");
265 		QDF_BUG(0);
266 		return QDF_STATUS_E_FAILURE;
267 	}
268 
269 	if (!soc->ops->mon_ops ||
270 	    !soc->ops->mon_ops->txrx_set_mon_pdev_params_rssi_dbm_conv)
271 		return QDF_STATUS_E_FAILURE;
272 
273 	return soc->ops->mon_ops->txrx_set_mon_pdev_params_rssi_dbm_conv
274 							    (soc, params);
275 }
276 #endif
277 
278 #ifdef WLAN_TELEMETRY_STATS_SUPPORT
279 /*
280  * cdp_update_pdev_mon_telemetry_airtime_stats() - update telemetry airtime
281  * stats in monitor pdev
282  *
283  *@soc: dp soc handle
284  *@pdev_id: pdev id
285  *
286  * This API is used to update telemetry airtime stats in monitor pdev
287  *
288  * Return: Success if stats are updated, else failure
289  */
290 static inline QDF_STATUS
291 cdp_update_pdev_mon_telemetry_airtime_stats(ol_txrx_soc_handle soc,
292 					    uint8_t pdev_id)
293 {
294 	if (!soc || !soc->ops) {
295 		dp_cdp_debug("Invalid Instance");
296 		return QDF_STATUS_E_FAILURE;
297 	}
298 
299 	if (!soc->ops->mon_ops ||
300 	    !soc->ops->mon_ops->txrx_update_pdev_mon_telemetry_airtime_stats)
301 		return QDF_STATUS_E_FAILURE;
302 
303 	return soc->ops->mon_ops->txrx_update_pdev_mon_telemetry_airtime_stats(
304 						soc, pdev_id);
305 }
306 #endif
307 #endif
308