xref: /wlan-driver/qca-wifi-host-cmn/dp/inc/cdp_txrx_misc.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2016-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: cdp_txrx_misc.h
22  * Define the host data path miscellaneous API functions
23  * called by the host control SW and the OS interface module
24  */
25 #ifndef _CDP_TXRX_MISC_H_
26 #define _CDP_TXRX_MISC_H_
27 
28 #include "cdp_txrx_handle.h"
29 #include <cdp_txrx_cmn.h>
30 
31 /**
32  * cdp_tx_non_std() - Allow the control-path SW to send data frames
33  * @soc: data path soc handle
34  * @vdev_id: id of vdev
35  * @tx_spec: what non-standard handling to apply to the tx data frames
36  * @msdu_list: NULL-terminated list of tx MSDUs
37  *
38  * Generally, all tx data frames come from the OS shim into the txrx layer.
39  * However, there are rare cases such as TDLS messaging where the UMAC
40  * control-path SW creates tx data frames.
41  *  This UMAC SW can call this function to provide the tx data frames to
42  *  the txrx layer.
43  *  The UMAC SW can request a callback for these data frames after their
44  *  transmission completes, by using the ol_txrx_data_tx_cb_set function
45  *  to register a tx completion callback, and by specifying
46  *  ol_tx_spec_no_free as the tx_spec arg when giving the frames to
47  *  ol_tx_non_std.
48  *  The MSDUs need to have the appropriate L2 header type (802.3 vs. 802.11),
49  *  as specified by ol_cfg_frame_type().
50  *
51  *  Return: null - success, skb - failure
52  */
53 static inline qdf_nbuf_t
cdp_tx_non_std(ol_txrx_soc_handle soc,uint8_t vdev_id,enum ol_tx_spec tx_spec,qdf_nbuf_t msdu_list)54 cdp_tx_non_std(ol_txrx_soc_handle soc, uint8_t vdev_id,
55 	       enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list)
56 {
57 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
58 		dp_cdp_debug("invalid instance");
59 		return NULL;
60 	}
61 
62 	if (soc->ops->misc_ops->tx_non_std)
63 		return soc->ops->misc_ops->tx_non_std(soc, vdev_id, tx_spec,
64 						      msdu_list);
65 	return NULL;
66 }
67 
68 /**
69  * cdp_set_ibss_vdev_heart_beat_timer() - Update ibss vdev heart
70  * beat timer
71  * @soc: data path soc handle
72  * @vdev_id: id of vdev
73  * @timer_value_sec: new heart beat timer value
74  *
75  * Return: Old timer value set in vdev.
76  */
77 static inline uint16_t
cdp_set_ibss_vdev_heart_beat_timer(ol_txrx_soc_handle soc,uint8_t vdev_id,uint16_t timer_value_sec)78 cdp_set_ibss_vdev_heart_beat_timer(ol_txrx_soc_handle soc,
79 				   uint8_t vdev_id, uint16_t timer_value_sec)
80 {
81 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
82 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
83 			"%s invalid instance", __func__);
84 		return 0;
85 	}
86 
87 	if (soc->ops->misc_ops->set_ibss_vdev_heart_beat_timer)
88 		return soc->ops->misc_ops->set_ibss_vdev_heart_beat_timer(
89 			soc, vdev_id, timer_value_sec);
90 
91 	return 0;
92 }
93 
94 /**
95  * cdp_set_wisa_mode() - set wisa mode
96  * @soc: data path soc handle
97  * @vdev_id: vdev_id
98  * @enable: enable or disable
99  *
100  * Return: QDF_STATUS_SUCCESS mode enable success
101  */
102 static inline QDF_STATUS
cdp_set_wisa_mode(ol_txrx_soc_handle soc,uint8_t vdev_id,bool enable)103 cdp_set_wisa_mode(ol_txrx_soc_handle soc, uint8_t vdev_id, bool enable)
104 {
105 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
106 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
107 			"%s invalid instance", __func__);
108 		return QDF_STATUS_E_INVAL;
109 	}
110 
111 	if (soc->ops->misc_ops->set_wisa_mode)
112 		return soc->ops->misc_ops->set_wisa_mode(soc, vdev_id, enable);
113 	return QDF_STATUS_SUCCESS;
114 }
115 
116 /**
117  * cdp_data_stall_cb_register() - register data stall callback
118  * @soc: data path soc handle
119  * @pdev_id: id of data path pdev handle
120  * @cb: callback function
121  *
122  * Return: QDF_STATUS_SUCCESS register success
123  */
cdp_data_stall_cb_register(ol_txrx_soc_handle soc,uint8_t pdev_id,data_stall_detect_cb cb)124 static inline QDF_STATUS cdp_data_stall_cb_register(ol_txrx_soc_handle soc,
125 						    uint8_t pdev_id,
126 						    data_stall_detect_cb cb)
127 {
128 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
129 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
130 			"%s invalid instance", __func__);
131 		return QDF_STATUS_E_INVAL;
132 	}
133 
134 	if (soc->ops->misc_ops->txrx_data_stall_cb_register)
135 		return soc->ops->misc_ops->txrx_data_stall_cb_register(
136 							soc, pdev_id, cb);
137 	return QDF_STATUS_SUCCESS;
138 }
139 
140 /**
141  * cdp_data_stall_cb_deregister() - de-register data stall callback
142  * @soc: data path soc handle
143  * @pdev_id: id of data path pdev handle
144  * @cb: callback function
145  *
146  * Return: QDF_STATUS_SUCCESS de-register success
147  */
cdp_data_stall_cb_deregister(ol_txrx_soc_handle soc,uint8_t pdev_id,data_stall_detect_cb cb)148 static inline QDF_STATUS cdp_data_stall_cb_deregister(ol_txrx_soc_handle soc,
149 						      uint8_t pdev_id,
150 						      data_stall_detect_cb cb)
151 {
152 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
153 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
154 			"%s invalid instance", __func__);
155 		return QDF_STATUS_E_INVAL;
156 	}
157 
158 	if (soc->ops->misc_ops->txrx_data_stall_cb_deregister)
159 		return soc->ops->misc_ops->txrx_data_stall_cb_deregister(
160 							soc, pdev_id, cb);
161 	return QDF_STATUS_SUCCESS;
162 }
163 
164 /**
165  * cdp_post_data_stall_event() - post data stall event
166  * @soc: data path soc handle
167  * @indicator: Module triggering data stall
168  * @data_stall_type: data stall event type
169  * @pdev_id: pdev id
170  * @vdev_id_bitmap: vdev id bitmap
171  * @recovery_type: data stall recovery type
172  *
173  * Return: None
174  */
175 static inline void
cdp_post_data_stall_event(ol_txrx_soc_handle soc,enum data_stall_log_event_indicator indicator,enum data_stall_log_event_type data_stall_type,uint32_t pdev_id,uint32_t vdev_id_bitmap,enum data_stall_log_recovery_type recovery_type)176 cdp_post_data_stall_event(ol_txrx_soc_handle soc,
177 			  enum data_stall_log_event_indicator indicator,
178 			  enum data_stall_log_event_type data_stall_type,
179 			  uint32_t pdev_id, uint32_t vdev_id_bitmap,
180 			  enum data_stall_log_recovery_type recovery_type)
181 {
182 	if (!soc || !soc->ops) {
183 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
184 			"%s invalid instance", __func__);
185 		QDF_BUG(0);
186 		return;
187 	}
188 
189 	if (!soc->ops->misc_ops ||
190 	    !soc->ops->misc_ops->txrx_post_data_stall_event)
191 		return;
192 
193 	soc->ops->misc_ops->txrx_post_data_stall_event(
194 				soc, indicator, data_stall_type, pdev_id,
195 				vdev_id_bitmap, recovery_type);
196 }
197 
198 /**
199  * cdp_set_wmm_param() - set wmm parameter
200  * @soc: data path soc handle
201  * @pdev_id: id of data path pdev handle
202  * @wmm_param: wmm parameter
203  *
204  * Return: none
205  */
206 static inline void
cdp_set_wmm_param(ol_txrx_soc_handle soc,uint8_t pdev_id,struct ol_tx_wmm_param_t wmm_param)207 cdp_set_wmm_param(ol_txrx_soc_handle soc, uint8_t pdev_id,
208 		  struct ol_tx_wmm_param_t wmm_param)
209 {
210 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
211 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
212 			"%s invalid instance", __func__);
213 		return;
214 	}
215 
216 	if (soc->ops->misc_ops->set_wmm_param)
217 		return soc->ops->misc_ops->set_wmm_param(soc, pdev_id,
218 							 wmm_param);
219 
220 	return;
221 }
222 
223 /**
224  * cdp_runtime_suspend() - suspend
225  * @soc: data path soc handle
226  * @pdev_id: id of data path pdev handle
227  *
228  * Return: QDF_STATUS_SUCCESS suspend success
229  */
cdp_runtime_suspend(ol_txrx_soc_handle soc,uint8_t pdev_id)230 static inline QDF_STATUS cdp_runtime_suspend(ol_txrx_soc_handle soc,
231 					     uint8_t pdev_id)
232 {
233 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
234 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
235 			"%s invalid instance", __func__);
236 		return QDF_STATUS_E_INVAL;
237 	}
238 
239 	if (soc->ops->misc_ops->runtime_suspend)
240 		return soc->ops->misc_ops->runtime_suspend(soc, pdev_id);
241 
242 	return QDF_STATUS_SUCCESS;
243 }
244 
245 /**
246  * cdp_runtime_resume() - resume
247  * @soc: data path soc handle
248  * @pdev_id: id of data path pdev handle
249  *
250  * Return: QDF_STATUS_SUCCESS suspend success
251  */
cdp_runtime_resume(ol_txrx_soc_handle soc,uint8_t pdev_id)252 static inline QDF_STATUS cdp_runtime_resume(ol_txrx_soc_handle soc,
253 					    uint8_t pdev_id)
254 {
255 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
256 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
257 			"%s invalid instance", __func__);
258 		return QDF_STATUS_E_INVAL;
259 	}
260 
261 	if (soc->ops->misc_ops->runtime_resume)
262 		return soc->ops->misc_ops->runtime_resume(soc, pdev_id);
263 
264 	return QDF_STATUS_SUCCESS;
265 }
266 
267 /**
268  * cdp_hl_tdls_flag_reset() - tdls flag reset
269  * @soc: data path soc handle
270  * @vdev_id: id of vdev
271  * @flag: flag indicating to set/reset tdls
272  *
273  * Return: none
274  */
275 static inline void
cdp_hl_tdls_flag_reset(ol_txrx_soc_handle soc,uint8_t vdev_id,bool flag)276 cdp_hl_tdls_flag_reset(ol_txrx_soc_handle soc, uint8_t vdev_id, bool flag)
277 {
278 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
279 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
280 			"%s invalid instance", __func__);
281 		return;
282 	}
283 
284 	if (soc->ops->misc_ops->hl_tdls_flag_reset)
285 		return soc->ops->misc_ops->hl_tdls_flag_reset(soc, vdev_id,
286 							      flag);
287 
288 	return;
289 }
290 
291 /**
292  * cdp_get_opmode() - get vdev operation mode
293  * @soc: data path soc handle
294  * @vdev_id: id of vdev
295  *
296  * Return: virtual device operational mode
297  *      op_mode_ap,
298  *      op_mode_ibss,
299  *      op_mode_sta,
300  *      op_mode_monitor,
301  *      op_mode_ocb,
302  *	etc.
303  */
304 static inline int
cdp_get_opmode(ol_txrx_soc_handle soc,uint8_t vdev_id)305 cdp_get_opmode(ol_txrx_soc_handle soc, uint8_t vdev_id)
306 {
307 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
308 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
309 			"%s invalid instance", __func__);
310 		return 0;
311 	}
312 
313 	if (soc->ops->misc_ops->get_opmode)
314 		return soc->ops->misc_ops->get_opmode(soc, vdev_id);
315 
316 	return 0;
317 }
318 
319 /**
320  * cdp_get_vdev_id() - get vdev id
321  * @soc: data path soc handle
322  * @vdev: virtual interface instance
323  *
324  * get virtual interface id
325  *
326  * Return: interface id
327  *        0 unknown interface
328  */
329 static inline uint16_t
cdp_get_vdev_id(ol_txrx_soc_handle soc,struct cdp_vdev * vdev)330 cdp_get_vdev_id(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
331 {
332 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
333 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
334 			"%s invalid instance", __func__);
335 		return 0;
336 	}
337 
338 	if (soc->ops->misc_ops->get_vdev_id)
339 		return soc->ops->misc_ops->get_vdev_id(vdev);
340 	return 0;
341 }
342 
343 /**
344  * cdp_get_tx_ack_stats() - get tx ack count for vdev
345  * @soc: data path soc handle
346  * @vdev_id: vdev id
347  *
348  * Return: tx ack count
349  *          0 invalid count
350  */
351 static inline uint32_t
cdp_get_tx_ack_stats(ol_txrx_soc_handle soc,uint8_t vdev_id)352 cdp_get_tx_ack_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
353 {
354 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
355 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
356 			"%s invalid instance", __func__);
357 		return 0;
358 	}
359 
360 	if (soc->ops->misc_ops->get_tx_ack_stats)
361 		return soc->ops->misc_ops->get_tx_ack_stats(soc, vdev_id);
362 
363 	return 0;
364 }
365 
366 /**
367  * cdp_bad_peer_txctl_set_setting() - Set peer timer balance parameters
368  * @soc: data path soc handle
369  * @pdev_id: id of datapath pdev handle
370  * @enable: enable/disable peer balance state
371  * @period: balance timer period for peer
372  * @txq_limit: txp limit for peer
373  *
374  * Return: none
375  */
376 static inline void
cdp_bad_peer_txctl_set_setting(ol_txrx_soc_handle soc,uint8_t pdev_id,int enable,int period,int txq_limit)377 cdp_bad_peer_txctl_set_setting(ol_txrx_soc_handle soc, uint8_t pdev_id,
378 			       int enable, int period, int txq_limit)
379 {
380 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
381 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
382 			"%s invalid instance", __func__);
383 		return;
384 	}
385 
386 	if (soc->ops->misc_ops->bad_peer_txctl_set_setting)
387 		return soc->ops->misc_ops->bad_peer_txctl_set_setting(
388 					soc, pdev_id, enable, period,
389 					txq_limit);
390 	return;
391 }
392 
393 /**
394  * cdp_bad_peer_txctl_update_threshold() - TBD
395  * @soc: data path soc handle
396  * @pdev_id: id of data path pdev handle
397  * @level: index of the threshold configuration
398  * @tput_thresh: peer balance throughput threshold
399  * @tx_limit: peer balance tx limit threshold
400  *
401  * TBD
402  *
403  * Return: none
404  */
405 static inline void
cdp_bad_peer_txctl_update_threshold(ol_txrx_soc_handle soc,uint8_t pdev_id,int level,int tput_thresh,int tx_limit)406 cdp_bad_peer_txctl_update_threshold(ol_txrx_soc_handle soc,
407 				    uint8_t pdev_id, int level,
408 				    int tput_thresh, int tx_limit)
409 {
410 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
411 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
412 			"%s invalid instance", __func__);
413 		return;
414 	}
415 
416 	if (soc->ops->misc_ops->bad_peer_txctl_update_threshold)
417 		return soc->ops->misc_ops->bad_peer_txctl_update_threshold(
418 			soc, pdev_id, level, tput_thresh, tx_limit);
419 	return;
420 }
421 
422 /**
423  * cdp_mark_first_wakeup_packet() - set flag to indicate that
424  *    fw is compatible for marking first packet after wow wakeup
425  * @soc: data path soc handle
426  * @pdev_id: id of data path pdev handle
427  * @value: 1 for enabled/ 0 for disabled
428  *
429  * Return: None
430  */
cdp_mark_first_wakeup_packet(ol_txrx_soc_handle soc,uint8_t pdev_id,uint8_t value)431 static inline void cdp_mark_first_wakeup_packet(ol_txrx_soc_handle soc,
432 						uint8_t pdev_id, uint8_t value)
433 {
434 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
435 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
436 			"%s invalid instance", __func__);
437 		return;
438 	}
439 
440 	if (soc->ops->misc_ops->mark_first_wakeup_packet)
441 		return soc->ops->misc_ops->mark_first_wakeup_packet(
442 							soc, pdev_id, value);
443 	return;
444 }
445 
446 
447 /**
448  * cdp_update_mac_id() - update mac_id for vdev
449  * @psoc: data path soc handle
450  * @vdev_id: vdev id
451  * @mac_id: mac id
452  *
453  * Return: none
454  */
cdp_update_mac_id(void * psoc,uint8_t vdev_id,uint8_t mac_id)455 static inline void cdp_update_mac_id(void *psoc, uint8_t vdev_id,
456 				     uint8_t mac_id)
457 {
458 	ol_txrx_soc_handle soc = psoc;
459 
460 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
461 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
462 			"%s invalid instance", __func__);
463 		return;
464 	}
465 
466 	if (soc->ops->misc_ops->update_mac_id)
467 		return soc->ops->misc_ops->update_mac_id(soc, vdev_id, mac_id);
468 	return;
469 }
470 
471 /**
472  * cdp_flush_rx_frames() - flush cached rx frames
473  * @soc: data path soc handle
474  * @pdev_id: datapath pdev identifier
475  * @peer_mac: peer mac address
476  * @drop: set flag to drop frames
477  *
478  * Return: None
479  */
cdp_flush_rx_frames(ol_txrx_soc_handle soc,uint8_t pdev_id,uint8_t * peer_mac,bool drop)480 static inline void cdp_flush_rx_frames(ol_txrx_soc_handle soc, uint8_t pdev_id,
481 				       uint8_t *peer_mac, bool drop)
482 {
483 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
484 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
485 			"%s invalid instance", __func__);
486 		return;
487 	}
488 
489 	if (soc->ops->misc_ops->flush_rx_frames)
490 		return soc->ops->misc_ops->flush_rx_frames(soc, pdev_id,
491 							   peer_mac, drop);
492 	return;
493 }
494 
495 /**
496  * cdp_get_intra_bss_fwd_pkts_count() - to get the total tx and rx packets
497  *   that has been forwarded from txrx layer without going to upper layers.
498  * @soc: Datapath soc handle
499  * @vdev_id: vdev id
500  * @fwd_tx_packets: pointer to forwarded tx packets count parameter
501  * @fwd_rx_packets: pointer to forwarded rx packets count parameter
502  *
503  * Return: status -> A_OK - success, A_ERROR - failure
504  */
cdp_get_intra_bss_fwd_pkts_count(ol_txrx_soc_handle soc,uint8_t vdev_id,uint64_t * fwd_tx_packets,uint64_t * fwd_rx_packets)505 static inline A_STATUS cdp_get_intra_bss_fwd_pkts_count(
506 		ol_txrx_soc_handle soc, uint8_t vdev_id,
507 		uint64_t *fwd_tx_packets, uint64_t *fwd_rx_packets)
508 {
509 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
510 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
511 			"%s invalid instance", __func__);
512 		return 0;
513 	}
514 
515 	if (soc->ops->misc_ops->get_intra_bss_fwd_pkts_count)
516 		return soc->ops->misc_ops->get_intra_bss_fwd_pkts_count(
517 			soc, vdev_id, fwd_tx_packets, fwd_rx_packets);
518 
519 	return 0;
520 }
521 
522 /**
523  * cdp_pkt_log_init() - API to initialize packet log
524  * @soc: data path soc handle
525  * @pdev_id: id of data path pdev handle
526  * @scn: HIF context
527  *
528  * Return: void
529  */
cdp_pkt_log_init(ol_txrx_soc_handle soc,uint8_t pdev_id,void * scn)530 static inline void cdp_pkt_log_init(ol_txrx_soc_handle soc,
531 				    uint8_t pdev_id, void *scn)
532 {
533 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
534 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
535 			"%s invalid instance", __func__);
536 		return;
537 	}
538 
539 	if (soc->ops->misc_ops->pkt_log_init)
540 		return soc->ops->misc_ops->pkt_log_init(soc, pdev_id, scn);
541 
542 	return;
543 }
544 
545 /**
546  * cdp_pkt_log_con_service() - API to connect packet log service
547  * @soc: data path soc handle
548  * @pdev_id: id of data path pdev handle
549  * @scn: HIF context
550  *
551  * Return: void
552  */
cdp_pkt_log_con_service(ol_txrx_soc_handle soc,uint8_t pdev_id,void * scn)553 static inline void cdp_pkt_log_con_service(ol_txrx_soc_handle soc,
554 					   uint8_t pdev_id, void *scn)
555 {
556 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
557 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
558 			"%s invalid instance", __func__);
559 		return;
560 	}
561 
562 	if (soc->ops->misc_ops->pkt_log_con_service)
563 		return soc->ops->misc_ops->pkt_log_con_service(
564 						soc, pdev_id, scn);
565 
566 	return;
567 }
568 
569 /**
570  * cdp_pkt_log_exit() - API to cleanup packet log info
571  * @soc: data path soc handle
572  * @pdev_id: id of data path pdev handle
573  *
574  * Return: void
575  */
cdp_pkt_log_exit(ol_txrx_soc_handle soc,uint8_t pdev_id)576 static inline void cdp_pkt_log_exit(ol_txrx_soc_handle soc, uint8_t pdev_id)
577 {
578 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
579 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
580 			"%s invalid instance", __func__);
581 		return;
582 	}
583 
584 	if (soc->ops->misc_ops->pkt_log_exit)
585 		return soc->ops->misc_ops->pkt_log_exit(soc, pdev_id);
586 
587 	return;
588 }
589 
590 /**
591  * cdp_get_num_rx_contexts() - API to get the number of RX contexts
592  * @soc: soc handle
593  *
594  * Return: number of RX contexts
595  */
cdp_get_num_rx_contexts(ol_txrx_soc_handle soc)596 static inline int cdp_get_num_rx_contexts(ol_txrx_soc_handle soc)
597 {
598 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
599 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
600 			  "%s invalid instance", __func__);
601 		return 0;
602 	}
603 
604 	if (soc->ops->misc_ops->get_num_rx_contexts)
605 		return soc->ops->misc_ops->get_num_rx_contexts(soc);
606 
607 	return 0;
608 }
609 
610 /**
611  * cdp_register_packetdump_cb() - API to register packetdump callback
612  *
613  * Register TX/RX callback for data packets, during connection. And per packet
614  * stats will be passed to user-space by @tx_cb/@rx_cb.
615  *
616  * @soc: soc handle
617  * @pdev_id: id of data path pdev handle
618  * @tx_cb: tx packet callback
619  * @rx_cb: rx packet callback
620  *
621  * Return: void
622  */
cdp_register_packetdump_cb(ol_txrx_soc_handle soc,uint8_t pdev_id,ol_txrx_pktdump_cb tx_cb,ol_txrx_pktdump_cb rx_cb)623 static inline void cdp_register_packetdump_cb(ol_txrx_soc_handle soc,
624 					      uint8_t pdev_id,
625 					      ol_txrx_pktdump_cb tx_cb,
626 					      ol_txrx_pktdump_cb rx_cb)
627 {
628 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
629 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
630 			  "%s invalid instance", __func__);
631 		return;
632 	}
633 
634 	if (soc->ops->misc_ops->register_pktdump_cb)
635 		return soc->ops->misc_ops->register_pktdump_cb(
636 						soc, pdev_id, tx_cb, rx_cb);
637 }
638 
639 /**
640  * cdp_deregister_packetdump_cb() - API to unregister packetdump callback
641  *
642  * Deregister callback for TX/RX data packets.
643  *
644  * @soc: soc handle
645  * @pdev_id: id of data path pdev handle
646  *
647  * Return: void
648  */
cdp_deregister_packetdump_cb(ol_txrx_soc_handle soc,uint8_t pdev_id)649 static inline void cdp_deregister_packetdump_cb(ol_txrx_soc_handle soc,
650 						uint8_t pdev_id)
651 {
652 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
653 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
654 			  "%s invalid instance", __func__);
655 		return;
656 	}
657 
658 	if (soc->ops->misc_ops->unregister_pktdump_cb)
659 		return soc->ops->misc_ops->unregister_pktdump_cb(soc, pdev_id);
660 }
661 
662 typedef void (*rx_mic_error_callback)(struct cdp_ctrl_objmgr_psoc *psoc,
663 				uint8_t pdev_id,
664 				struct cdp_rx_mic_err_info *info);
665 
666 /**
667  * cdp_register_rx_mic_error_ind_handler() - API to register mic error
668  *                                           indication handler
669  *
670  * @soc: soc handle
671  * @rx_mic_cb: rx mic error indication callback
672  *
673  * Return: void
674  */
675 static inline void
cdp_register_rx_mic_error_ind_handler(ol_txrx_soc_handle soc,rx_mic_error_callback rx_mic_cb)676 cdp_register_rx_mic_error_ind_handler(ol_txrx_soc_handle soc,
677 				      rx_mic_error_callback rx_mic_cb)
678 {
679 	if (!soc || !soc->ol_ops) {
680 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
681 			  "%s invalid instance", __func__);
682 		return;
683 	}
684 
685 	soc->ol_ops->rx_mic_error = rx_mic_cb;
686 }
687 
688 typedef void (*rx_refill_thread_sched_cb)(ol_txrx_soc_handle soc);
689 
690 /**
691  * cdp_register_rx_refill_thread_sched_handler() - API to register RX refill
692  *                                                 thread schedule handler
693  * @soc: soc handle
694  * @rx_sched_cb: Rx refill thread scheduler callback function
695  *
696  * Return: void
697  */
698 static inline void
cdp_register_rx_refill_thread_sched_handler(ol_txrx_soc_handle soc,rx_refill_thread_sched_cb rx_sched_cb)699 cdp_register_rx_refill_thread_sched_handler(ol_txrx_soc_handle soc,
700 					    rx_refill_thread_sched_cb rx_sched_cb)
701 {
702 	if (!soc || !soc->ol_ops) {
703 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
704 			  "%s invalid instance", __func__);
705 		return;
706 	}
707 
708 	soc->ol_ops->dp_rx_sched_refill_thread = rx_sched_cb;
709 }
710 
711 /**
712  * cdp_pdev_reset_driver_del_ack() - reset driver TCP delayed ack flag
713  * @psoc: data path soc handle
714  * @pdev_id: pdev id
715  *
716  * Return: none
717  */
cdp_pdev_reset_driver_del_ack(void * psoc,uint8_t pdev_id)718 static inline void cdp_pdev_reset_driver_del_ack(void *psoc,
719 						 uint8_t pdev_id)
720 {
721 	ol_txrx_soc_handle soc = psoc;
722 
723 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
724 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
725 			  "%s invalid instance", __func__);
726 		return;
727 	}
728 
729 	if (soc->ops->misc_ops->pdev_reset_driver_del_ack)
730 		return soc->ops->misc_ops->pdev_reset_driver_del_ack(soc,
731 								     pdev_id);
732 }
733 
734 /**
735  * cdp_vdev_set_driver_del_ack_enable() - set driver delayed ack enabled flag
736  * @soc: data path soc handle
737  * @vdev_id: vdev id
738  * @rx_packets: number of rx packets
739  * @time_in_ms: time in ms
740  * @high_th: high threshold
741  * @low_th: low threshold
742  *
743  * Return: none
744  */
cdp_vdev_set_driver_del_ack_enable(ol_txrx_soc_handle soc,uint8_t vdev_id,unsigned long rx_packets,uint32_t time_in_ms,uint32_t high_th,uint32_t low_th)745 static inline void cdp_vdev_set_driver_del_ack_enable(ol_txrx_soc_handle soc,
746 						      uint8_t vdev_id,
747 						      unsigned long rx_packets,
748 						      uint32_t time_in_ms,
749 						      uint32_t high_th,
750 						      uint32_t low_th)
751 {
752 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
753 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
754 			  "%s invalid instance", __func__);
755 		return;
756 	}
757 
758 	if (soc->ops->misc_ops->vdev_set_driver_del_ack_enable)
759 		return soc->ops->misc_ops->vdev_set_driver_del_ack_enable(
760 			soc, vdev_id, rx_packets, time_in_ms, high_th, low_th);
761 }
762 
cdp_vdev_set_bundle_require_flag(ol_txrx_soc_handle soc,uint8_t vdev_id,unsigned long tx_bytes,uint32_t time_in_ms,uint32_t high_th,uint32_t low_th)763 static inline void cdp_vdev_set_bundle_require_flag(ol_txrx_soc_handle soc,
764 						    uint8_t vdev_id,
765 						    unsigned long tx_bytes,
766 						    uint32_t time_in_ms,
767 						    uint32_t high_th,
768 						    uint32_t low_th)
769 {
770 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
771 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
772 			  "%s invalid instance", __func__);
773 		return;
774 	}
775 
776 	if (soc->ops->misc_ops->vdev_set_bundle_require_flag)
777 		return soc->ops->misc_ops->vdev_set_bundle_require_flag(
778 			vdev_id, tx_bytes, time_in_ms, high_th, low_th);
779 }
780 
cdp_pdev_reset_bundle_require_flag(ol_txrx_soc_handle soc,uint8_t pdev_id)781 static inline void cdp_pdev_reset_bundle_require_flag(ol_txrx_soc_handle soc,
782 						      uint8_t pdev_id)
783 {
784 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
785 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
786 			  "%s invalid instance", __func__);
787 		return;
788 	}
789 
790 	if (soc->ops->misc_ops->pdev_reset_bundle_require_flag)
791 		return soc->ops->misc_ops->pdev_reset_bundle_require_flag(
792 								soc, pdev_id);
793 }
794 
795 /**
796  * cdp_txrx_ext_stats_request() - request dp tx and rx extended stats
797  * @soc: soc handle
798  * @pdev_id: pdev id
799  * @req: stats request structure to fill
800  *
801  * Return: QDF_STATUS
802  */
803 static inline QDF_STATUS
cdp_txrx_ext_stats_request(ol_txrx_soc_handle soc,uint8_t pdev_id,struct cdp_txrx_ext_stats * req)804 cdp_txrx_ext_stats_request(ol_txrx_soc_handle soc, uint8_t pdev_id,
805 			   struct cdp_txrx_ext_stats *req)
806 {
807 	if (!soc || !soc->ops || !soc->ops->misc_ops || !req) {
808 		dp_cdp_debug("Invalid Instance:");
809 		return QDF_STATUS_E_INVAL;
810 	}
811 
812 	if (soc->ops->misc_ops->txrx_ext_stats_request)
813 		return soc->ops->misc_ops->txrx_ext_stats_request(soc, pdev_id,
814 								  req);
815 
816 	return QDF_STATUS_SUCCESS;
817 }
818 
819 /**
820  * cdp_request_rx_hw_stats() - request rx hw stats
821  * @soc: soc handle
822  * @vdev_id: vdev id
823  *
824  * Return: QDF_STATUS
825  */
826 static inline QDF_STATUS
cdp_request_rx_hw_stats(ol_txrx_soc_handle soc,uint8_t vdev_id)827 cdp_request_rx_hw_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
828 {
829 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
830 		dp_cdp_debug("Invalid Instance:");
831 		return QDF_STATUS_E_INVAL;
832 	}
833 
834 	if (soc->ops->misc_ops->request_rx_hw_stats)
835 		return soc->ops->misc_ops->request_rx_hw_stats(soc, vdev_id);
836 
837 	return QDF_STATUS_SUCCESS;
838 }
839 
840 /**
841  * cdp_reset_rx_hw_ext_stats() - reset rx hw ext stats
842  * @soc: soc handle
843  *
844  * Return: none
845  */
846 static inline void
cdp_reset_rx_hw_ext_stats(ol_txrx_soc_handle soc)847 cdp_reset_rx_hw_ext_stats(ol_txrx_soc_handle soc)
848 {
849 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
850 		dp_cdp_debug("Invalid Instance");
851 		return;
852 	}
853 
854 	if (soc->ops->misc_ops->reset_rx_hw_ext_stats)
855 		soc->ops->misc_ops->reset_rx_hw_ext_stats(soc);
856 }
857 
858 /**
859  * cdp_vdev_inform_ll_conn() - Inform DP about the low latency connection
860  * @soc: soc handle
861  * @vdev_id: vdev id
862  * @action: Action to be performed (Add/Delete)
863  *
864  * Return: QDF_STATUS
865  */
866 static inline QDF_STATUS
cdp_vdev_inform_ll_conn(ol_txrx_soc_handle soc,uint8_t vdev_id,enum vdev_ll_conn_actions action)867 cdp_vdev_inform_ll_conn(ol_txrx_soc_handle soc, uint8_t vdev_id,
868 			enum vdev_ll_conn_actions action)
869 {
870 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
871 		dp_cdp_debug("Invalid Instance:");
872 		return QDF_STATUS_E_INVAL;
873 	}
874 
875 	if (soc->ops->misc_ops->vdev_inform_ll_conn)
876 		return soc->ops->misc_ops->vdev_inform_ll_conn(soc, vdev_id,
877 							       action);
878 
879 	return QDF_STATUS_SUCCESS;
880 }
881 
882 /**
883  * cdp_soc_set_swlm_enable() - Enable or disable software latency manager
884  * @soc: soc handle
885  * @value: value (enable/disable)
886  *
887  * Return: QDF_STATUS
888  */
889 static inline QDF_STATUS
cdp_soc_set_swlm_enable(ol_txrx_soc_handle soc,uint8_t value)890 cdp_soc_set_swlm_enable(ol_txrx_soc_handle soc, uint8_t value)
891 {
892 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
893 		dp_cdp_debug("Invalid Instance:");
894 		return QDF_STATUS_E_INVAL;
895 	}
896 
897 	if (soc->ops->misc_ops->set_swlm_enable)
898 		return soc->ops->misc_ops->set_swlm_enable(soc, value);
899 
900 	return QDF_STATUS_SUCCESS;
901 }
902 
903 /**
904  * cdp_soc_is_swlm_enabled() - Check if the software latency manager is
905  *			       enabled or not
906  * @soc: soc handle
907  *
908  * Return: 1 if enabled, 0 if disabled
909  */
910 static inline uint8_t
cdp_soc_is_swlm_enabled(ol_txrx_soc_handle soc)911 cdp_soc_is_swlm_enabled(ol_txrx_soc_handle soc)
912 {
913 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
914 		dp_cdp_debug("Invalid Instance:");
915 		return 0;
916 	}
917 
918 	if (soc->ops->misc_ops->is_swlm_enabled)
919 		return soc->ops->misc_ops->is_swlm_enabled(soc);
920 
921 	return 0;
922 }
923 
924 /**
925  * cdp_display_txrx_hw_info() - Dump the DP rings info
926  * @soc: soc handle
927  *
928  * Return: rings are empty
929  */
930 static inline bool
cdp_display_txrx_hw_info(ol_txrx_soc_handle soc)931 cdp_display_txrx_hw_info(ol_txrx_soc_handle soc)
932 {
933 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
934 		dp_cdp_debug("Invalid Instance:");
935 		return true;
936 	}
937 
938 	if (soc->ops->misc_ops->display_txrx_hw_info)
939 		return soc->ops->misc_ops->display_txrx_hw_info(soc);
940 
941 	return true;
942 }
943 
944 /**
945  * cdp_get_tx_rings_grp_bitmap() - Get tx rings grp bitmap
946  * @soc: soc handle
947  *
948  * Return: tx rings bitmap
949  */
950 static inline uint32_t
cdp_get_tx_rings_grp_bitmap(ol_txrx_soc_handle soc)951 cdp_get_tx_rings_grp_bitmap(ol_txrx_soc_handle soc)
952 {
953 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
954 		dp_cdp_debug("Invalid Instance:");
955 		return 0;
956 	}
957 
958 	if (soc->ops->misc_ops->get_tx_rings_grp_bitmap)
959 		return soc->ops->misc_ops->get_tx_rings_grp_bitmap(soc);
960 
961 	return 0;
962 }
963 
964 #ifdef WLAN_FEATURE_PEER_TXQ_FLUSH_CONF
965 /**
966  * cdp_set_peer_txq_flush_config() - Set the peer txq flush configuration
967  * @soc: Opaque handle to the DP soc object
968  * @vdev_id: VDEV identifier
969  * @mac: MAC address of the peer
970  * @ac: access category mask
971  * @tid: TID mask
972  * @policy: Flush policy
973  *
974  * Return: 0 on success, errno on failure
975  */
976 static inline int
cdp_set_peer_txq_flush_config(ol_txrx_soc_handle soc,uint8_t vdev_id,uint8_t * mac,uint8_t ac,uint32_t tid,enum cdp_peer_txq_flush_policy policy)977 cdp_set_peer_txq_flush_config(ol_txrx_soc_handle soc, uint8_t vdev_id,
978 			      uint8_t *mac, uint8_t ac, uint32_t tid,
979 			      enum cdp_peer_txq_flush_policy policy)
980 {
981 	if (!soc || !soc->ops || !soc->ops->misc_ops || !mac) {
982 		dp_cdp_debug("Invalid parameters");
983 		return 0;
984 	}
985 
986 	if (soc->ops->misc_ops->set_peer_txq_flush_config) {
987 		return soc->ops->misc_ops->set_peer_txq_flush_config(soc,
988 								     vdev_id,
989 								     mac, ac,
990 								     tid,
991 								     policy);
992 	}
993 
994 	return 0;
995 }
996 #endif /* WLAN_FEATURE_PEER_TXQ_FLUSH_CONF */
997 #ifdef FEATURE_RX_LINKSPEED_ROAM_TRIGGER
998 /**
999  * cdp_set_bus_vote_lvl_high() - have a vote on bus bandwidth lvl
1000  * @soc: datapath soc handle
1001  * @high: whether TPUT level is high or not
1002  *
1003  * Return: void
1004  */
1005 static inline void
cdp_set_bus_vote_lvl_high(ol_txrx_soc_handle soc,bool high)1006 cdp_set_bus_vote_lvl_high(ol_txrx_soc_handle soc, bool high)
1007 {
1008 	if (!soc || !soc->ops || !soc->ops->misc_ops ||
1009 	    !soc->ops->misc_ops->set_bus_vote_lvl_high) {
1010 		dp_cdp_debug("Invalid Instance:");
1011 		return;
1012 	}
1013 
1014 	soc->ops->misc_ops->set_bus_vote_lvl_high(soc, high);
1015 }
1016 
1017 /**
1018  * cdp_get_bus_lvl_high() - get high bus bandwidth lvl from dp
1019  * @soc: datapath soc handle
1020  *
1021  * Return: bool, whether TPUT level is high or not
1022  */
1023 static inline bool
cdp_get_bus_lvl_high(ol_txrx_soc_handle soc)1024 cdp_get_bus_lvl_high(ol_txrx_soc_handle soc)
1025 {
1026 	if (!soc || !soc->ops || !soc->ops->misc_ops ||
1027 	    !soc->ops->misc_ops->get_bus_vote_lvl_high) {
1028 		dp_cdp_debug("Invalid Instance:");
1029 		return false;
1030 	}
1031 
1032 	return soc->ops->misc_ops->get_bus_vote_lvl_high(soc);
1033 }
1034 #else
1035 static inline void
cdp_set_bus_vote_lvl_high(ol_txrx_soc_handle soc,bool high)1036 cdp_set_bus_vote_lvl_high(ol_txrx_soc_handle soc, bool high)
1037 {
1038 }
1039 
1040 static inline bool
cdp_get_bus_lvl_high(ol_txrx_soc_handle soc)1041 cdp_get_bus_lvl_high(ol_txrx_soc_handle soc)
1042 {
1043 	/*
1044 	 * default bus lvl is high to
1045 	 * make sure not affect tput
1046 	 */
1047 	return true;
1048 }
1049 #endif
1050 
1051 #ifdef DP_TX_PACKET_INSPECT_FOR_ILP
1052 /**
1053  * cdp_evaluate_update_tx_ilp_cfg() - Evaluate and update DP TX
1054  *                                    ILP configuration
1055  * @soc: DP SOC handle
1056  * @num_msdu_idx_map: Number of HTT msdu index to qtype map in array
1057  * @msdu_idx_map_arr: Pointer to HTT msdu index to qtype map array
1058  *
1059  * Return: Final updated TX ILP enable result, true - enabled, false - not
1060  */
1061 static inline bool
cdp_evaluate_update_tx_ilp_cfg(ol_txrx_soc_handle soc,uint8_t num_msdu_idx_map,uint8_t * msdu_idx_map_arr)1062 cdp_evaluate_update_tx_ilp_cfg(ol_txrx_soc_handle soc,
1063 			       uint8_t num_msdu_idx_map,
1064 			       uint8_t *msdu_idx_map_arr)
1065 {
1066 	if (!soc || !soc->ops || !soc->ops->misc_ops ||
1067 	    !soc->ops->misc_ops->evaluate_update_tx_ilp_cfg) {
1068 		dp_cdp_debug("Invalid Instance:");
1069 		return false;
1070 	}
1071 
1072 	return soc->ops->misc_ops->evaluate_update_tx_ilp_cfg(
1073 						soc, num_msdu_idx_map,
1074 						msdu_idx_map_arr);
1075 }
1076 #endif /* DP_TX_PACKET_INSPECT_FOR_ILP */
1077 #endif /* _CDP_TXRX_MISC_H_ */
1078