xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_misc.h (revision d0c05845839e5f2ba5a8dcebe0cd3e4cd4e8dfcf)
1 /*
2  * Copyright (c) 2016-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  * @file cdp_txrx_misc.h
22  * @brief 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
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
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
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  */
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  */
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
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
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  */
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  */
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
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  *
303  * return interface id
304  *        0 unknown interface
305  */
306 static inline int
307 cdp_get_opmode(ol_txrx_soc_handle soc, uint8_t vdev_id)
308 {
309 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
310 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
311 			"%s invalid instance", __func__);
312 		return 0;
313 	}
314 
315 	if (soc->ops->misc_ops->get_opmode)
316 		return soc->ops->misc_ops->get_opmode(soc, vdev_id);
317 
318 	return 0;
319 }
320 
321 /**
322  * cdp_get_vdev_id() - get vdev id
323  * @soc - data path soc handle
324  * @vdev - virtual interface instance
325  *
326  * get virtual interface id
327  *
328  * return interface id
329  *        0 unknown interface
330  */
331 static inline uint16_t
332 cdp_get_vdev_id(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
333 {
334 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
335 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
336 			"%s invalid instance", __func__);
337 		return 0;
338 	}
339 
340 	if (soc->ops->misc_ops->get_vdev_id)
341 		return soc->ops->misc_ops->get_vdev_id(vdev);
342 	return 0;
343 }
344 
345 /**
346  * cdp_get_tx_ack_stats() - get tx ack count for vdev
347  * @soc - data path soc handle
348  * @vdev_id - vdev id
349  *
350  * return tx ack count
351  *          0 invalid count
352  */
353 static inline uint32_t
354 cdp_get_tx_ack_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
355 {
356 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
357 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
358 			"%s invalid instance", __func__);
359 		return 0;
360 	}
361 
362 	if (soc->ops->misc_ops->get_tx_ack_stats)
363 		return soc->ops->misc_ops->get_tx_ack_stats(soc, vdev_id);
364 
365 	return 0;
366 }
367 
368 /**
369  * cdp_bad_peer_txctl_set_setting() - Set peer timer balance parameters
370  * @soc: data path soc handle
371  * @pdev_id: id of datapath pdev handle
372  * @enable: enable/disable peer balance state
373  * @period: balance timer period for peer
374  * @txq_limit: txp limit for peer
375  *
376  * Return: none
377  */
378 static inline void
379 cdp_bad_peer_txctl_set_setting(ol_txrx_soc_handle soc, uint8_t pdev_id,
380 			       int enable, int period, int txq_limit)
381 {
382 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
383 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
384 			"%s invalid instance", __func__);
385 		return;
386 	}
387 
388 	if (soc->ops->misc_ops->bad_peer_txctl_set_setting)
389 		return soc->ops->misc_ops->bad_peer_txctl_set_setting(
390 					soc, pdev_id, enable, period,
391 					txq_limit);
392 	return;
393 }
394 
395 /**
396  * cdp_bad_peer_txctl_update_threshold() - TBD
397  * @soc: data path soc handle
398  * @pdev_id: id of data path pdev handle
399  * @level: index of the threshold configuration
400  * @tput_thresh: peer balance throughput threshold
401  * @tx_limit: peer balance tx limit threshold
402  *
403  * TBD
404  *
405  * Return: none
406  */
407 static inline void
408 cdp_bad_peer_txctl_update_threshold(ol_txrx_soc_handle soc,
409 				    uint8_t pdev_id, int level,
410 				    int tput_thresh, int tx_limit)
411 {
412 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
413 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
414 			"%s invalid instance", __func__);
415 		return;
416 	}
417 
418 	if (soc->ops->misc_ops->bad_peer_txctl_update_threshold)
419 		return soc->ops->misc_ops->bad_peer_txctl_update_threshold(
420 			soc, pdev_id, level, tput_thresh, tx_limit);
421 	return;
422 }
423 
424 /**
425  * cdp_mark_first_wakeup_packet() - set flag to indicate that
426  *    fw is compatible for marking first packet after wow wakeup
427  * @soc: data path soc handle
428  * @pdev_id: id of data path pdev handle
429  * @value: 1 for enabled/ 0 for disabled
430  *
431  * Return: None
432  */
433 static inline void cdp_mark_first_wakeup_packet(ol_txrx_soc_handle soc,
434 						uint8_t pdev_id, uint8_t value)
435 {
436 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
437 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
438 			"%s invalid instance", __func__);
439 		return;
440 	}
441 
442 	if (soc->ops->misc_ops->mark_first_wakeup_packet)
443 		return soc->ops->misc_ops->mark_first_wakeup_packet(
444 							soc, pdev_id, value);
445 	return;
446 }
447 
448 
449 /**
450  * cds_update_mac_id() - update mac_id for vdev
451  * @psoc: data path soc handle
452  * @vdev_id: vdev id
453  * @mac_id: mac id
454  *
455  * Return: none
456  */
457 static inline void cdp_update_mac_id(void *psoc, uint8_t vdev_id,
458 				     uint8_t mac_id)
459 {
460 	ol_txrx_soc_handle soc = psoc;
461 
462 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
463 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
464 			"%s invalid instance", __func__);
465 		return;
466 	}
467 
468 	if (soc->ops->misc_ops->update_mac_id)
469 		return soc->ops->misc_ops->update_mac_id(soc, vdev_id, mac_id);
470 	return;
471 }
472 
473 /**
474  * cdp_flush_rx_frames() - flush cached rx frames
475  * @soc: data path soc handle
476  * @pdev_id: datapath pdev identifier
477  * @peer_mac: peer mac address
478  * @drop: set flag to drop frames
479  *
480  * Return: None
481  */
482 static inline void cdp_flush_rx_frames(ol_txrx_soc_handle soc, uint8_t pdev_id,
483 				       uint8_t *peer_mac, bool drop)
484 {
485 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
486 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
487 			"%s invalid instance", __func__);
488 		return;
489 	}
490 
491 	if (soc->ops->misc_ops->flush_rx_frames)
492 		return soc->ops->misc_ops->flush_rx_frames(soc, pdev_id,
493 							   peer_mac, drop);
494 	return;
495 }
496 
497 /*
498  * cdp_get_intra_bss_fwd_pkts_count() - to get the total tx and rx packets
499  *   that has been forwarded from txrx layer without going to upper layers.
500  * @soc: Datapath soc handle
501  * @vdev_id: vdev id
502  * @fwd_tx_packets: pointer to forwarded tx packets count parameter
503  * @fwd_rx_packets: pointer to forwarded rx packets count parameter
504  *
505  * Return: status -> A_OK - success, A_ERROR - failure
506  */
507 static inline A_STATUS cdp_get_intra_bss_fwd_pkts_count(
508 		ol_txrx_soc_handle soc, uint8_t vdev_id,
509 		uint64_t *fwd_tx_packets, uint64_t *fwd_rx_packets)
510 {
511 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
512 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
513 			"%s invalid instance", __func__);
514 		return 0;
515 	}
516 
517 	if (soc->ops->misc_ops->get_intra_bss_fwd_pkts_count)
518 		return soc->ops->misc_ops->get_intra_bss_fwd_pkts_count(
519 			soc, vdev_id, fwd_tx_packets, fwd_rx_packets);
520 
521 	return 0;
522 }
523 
524 /**
525  * cdp_pkt_log_init() - API to initialize packet log
526  * @soc: data path soc handle
527  * @pdev_id: id of data path pdev handle
528  * @scn: HIF context
529  *
530  * Return: void
531  */
532 static inline void cdp_pkt_log_init(ol_txrx_soc_handle soc,
533 				    uint8_t pdev_id, void *scn)
534 {
535 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
536 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
537 			"%s invalid instance", __func__);
538 		return;
539 	}
540 
541 	if (soc->ops->misc_ops->pkt_log_init)
542 		return soc->ops->misc_ops->pkt_log_init(soc, pdev_id, scn);
543 
544 	return;
545 }
546 
547 /**
548  * cdp_pkt_log_con_service() - API to connect packet log service
549  * @soc: data path soc handle
550  * @pdev_id: id of data path pdev handle
551  * @scn: HIF context
552  *
553  * Return: void
554  */
555 static inline void cdp_pkt_log_con_service(ol_txrx_soc_handle soc,
556 					   uint8_t pdev_id, void *scn)
557 {
558 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
559 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
560 			"%s invalid instance", __func__);
561 		return;
562 	}
563 
564 	if (soc->ops->misc_ops->pkt_log_con_service)
565 		return soc->ops->misc_ops->pkt_log_con_service(
566 						soc, pdev_id, scn);
567 
568 	return;
569 }
570 
571 /**
572  * cdp_pkt_log_exit() - API to cleanup packet log info
573  * @soc: data path soc handle
574  * @pdev_id: id of data path pdev handle
575  *
576  * Return: void
577  */
578 static inline void cdp_pkt_log_exit(ol_txrx_soc_handle soc, uint8_t pdev_id)
579 {
580 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
581 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
582 			"%s invalid instance", __func__);
583 		return;
584 	}
585 
586 	if (soc->ops->misc_ops->pkt_log_exit)
587 		return soc->ops->misc_ops->pkt_log_exit(soc, pdev_id);
588 
589 	return;
590 }
591 
592 /**
593  * cdp_get_num_rx_contexts() - API to get the number of RX contexts
594  * @soc: soc handle
595  *
596  * Return: number of RX contexts
597  */
598 static inline int cdp_get_num_rx_contexts(ol_txrx_soc_handle soc)
599 {
600 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
601 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
602 			  "%s invalid instance", __func__);
603 		return 0;
604 	}
605 
606 	if (soc->ops->misc_ops->get_num_rx_contexts)
607 		return soc->ops->misc_ops->get_num_rx_contexts(soc);
608 
609 	return 0;
610 }
611 
612 /**
613  * cdp_register_packetdump_cb() - API to register packetdump callback
614  *
615  * Register TX/RX callback for data packets, during connection. And per packet
616  * stats will be passed to user-space by @tx_cb/@rx_cb.
617  *
618  * @soc: soc handle
619  * @pdev_id: id of data path pdev handle
620  * @tx_cb: tx packet callback
621  * @rx_cb: rx packet callback
622  *
623  * Return: void
624  */
625 static inline void cdp_register_packetdump_cb(ol_txrx_soc_handle soc,
626 					      uint8_t pdev_id,
627 					      ol_txrx_pktdump_cb tx_cb,
628 					      ol_txrx_pktdump_cb rx_cb)
629 {
630 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
631 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
632 			  "%s invalid instance", __func__);
633 		return;
634 	}
635 
636 	if (soc->ops->misc_ops->register_pktdump_cb)
637 		return soc->ops->misc_ops->register_pktdump_cb(
638 						soc, pdev_id, tx_cb, rx_cb);
639 }
640 
641 /**
642  * cdp_deregister_packetdump_cb() - API to unregister packetdump callback
643  *
644  * Deregister callback for TX/RX data packets.
645  *
646  * @soc: soc handle
647  * @pdev_id: id of data path pdev handle
648  *
649  * Return: void
650  */
651 static inline void cdp_deregister_packetdump_cb(ol_txrx_soc_handle soc,
652 						uint8_t pdev_id)
653 {
654 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
655 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
656 			  "%s invalid instance", __func__);
657 		return;
658 	}
659 
660 	if (soc->ops->misc_ops->unregister_pktdump_cb)
661 		return soc->ops->misc_ops->unregister_pktdump_cb(soc, pdev_id);
662 }
663 
664 typedef void (*rx_mic_error_callback)(struct cdp_ctrl_objmgr_psoc *psoc,
665 				uint8_t pdev_id,
666 				struct cdp_rx_mic_err_info *info);
667 
668 /**
669  * cdp_register_rx_mic_error_ind_handler() - API to register mic error
670  *                                           indication handler
671  *
672  * @soc: soc handle
673  * @rx_mic_cb: rx mic error indication callback
674  *
675  * Return: void
676  */
677 static inline void
678 cdp_register_rx_mic_error_ind_handler(ol_txrx_soc_handle soc,
679 				      rx_mic_error_callback rx_mic_cb)
680 {
681 	if (!soc || !soc->ol_ops) {
682 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
683 			  "%s invalid instance", __func__);
684 		return;
685 	}
686 
687 	soc->ol_ops->rx_mic_error = rx_mic_cb;
688 }
689 
690 typedef void (*rx_refill_thread_sched_cb)(ol_txrx_soc_handle soc);
691 
692 /**
693  * cdp_register_rx_refill_thread_sched_handler() - API to register RX refill
694  *                                                 thread schedule handler
695  *
696  * @soc: soc handle
697  *
698  * Return: void
699  */
700 static inline void
701 cdp_register_rx_refill_thread_sched_handler(ol_txrx_soc_handle soc,
702 					    rx_refill_thread_sched_cb rx_sched_cb)
703 {
704 	if (!soc || !soc->ol_ops) {
705 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
706 			  "%s invalid instance", __func__);
707 		return;
708 	}
709 
710 	soc->ol_ops->dp_rx_sched_refill_thread = rx_sched_cb;
711 }
712 
713 /**
714  * cdp_pdev_reset_driver_del_ack() - reset driver TCP delayed ack flag
715  * @soc: data path soc handle
716  * @pdev_id: pdev id
717  *
718  * Return: none
719  */
720 static inline void cdp_pdev_reset_driver_del_ack(void *psoc,
721 						 uint8_t pdev_id)
722 {
723 	ol_txrx_soc_handle soc = psoc;
724 
725 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
726 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
727 			  "%s invalid instance", __func__);
728 		return;
729 	}
730 
731 	if (soc->ops->misc_ops->pdev_reset_driver_del_ack)
732 		return soc->ops->misc_ops->pdev_reset_driver_del_ack(soc,
733 								     pdev_id);
734 }
735 
736 /*
737  * cdp_vdev_set_driver_del_ack_enable() - set driver delayed ack enabled flag
738  * @soc: data path soc handle
739  * @vdev_id: vdev id
740  * @rx_packets: number of rx packets
741  * @time_in_ms: time in ms
742  * @high_th: high threshold
743  * @low_th: low threshold
744  *
745  * Return: none
746  */
747 static inline void cdp_vdev_set_driver_del_ack_enable(ol_txrx_soc_handle soc,
748 						      uint8_t vdev_id,
749 						      unsigned long rx_packets,
750 						      uint32_t time_in_ms,
751 						      uint32_t high_th,
752 						      uint32_t low_th)
753 {
754 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
755 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
756 			  "%s invalid instance", __func__);
757 		return;
758 	}
759 
760 	if (soc->ops->misc_ops->vdev_set_driver_del_ack_enable)
761 		return soc->ops->misc_ops->vdev_set_driver_del_ack_enable(
762 			soc, vdev_id, rx_packets, time_in_ms, high_th, low_th);
763 }
764 
765 static inline void cdp_vdev_set_bundle_require_flag(ol_txrx_soc_handle soc,
766 						    uint8_t vdev_id,
767 						    unsigned long tx_bytes,
768 						    uint32_t time_in_ms,
769 						    uint32_t high_th,
770 						    uint32_t low_th)
771 {
772 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
773 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
774 			  "%s invalid instance", __func__);
775 		return;
776 	}
777 
778 	if (soc->ops->misc_ops->vdev_set_bundle_require_flag)
779 		return soc->ops->misc_ops->vdev_set_bundle_require_flag(
780 			vdev_id, tx_bytes, time_in_ms, high_th, low_th);
781 }
782 
783 static inline void cdp_pdev_reset_bundle_require_flag(ol_txrx_soc_handle soc,
784 						      uint8_t pdev_id)
785 {
786 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
787 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
788 			  "%s invalid instance", __func__);
789 		return;
790 	}
791 
792 	if (soc->ops->misc_ops->pdev_reset_bundle_require_flag)
793 		return soc->ops->misc_ops->pdev_reset_bundle_require_flag(
794 								soc, pdev_id);
795 }
796 
797 /**
798  * cdp_txrx_ext_stats_request(): request dp tx and rx extended stats
799  * @soc: soc handle
800  * @pdev_id: pdev id
801  * @req: stats request structure to fill
802  *
803  * return: status
804  */
805 static inline QDF_STATUS
806 cdp_txrx_ext_stats_request(ol_txrx_soc_handle soc, uint8_t pdev_id,
807 			   struct cdp_txrx_ext_stats *req)
808 {
809 	if (!soc || !soc->ops || !soc->ops->misc_ops || !req) {
810 		dp_cdp_debug("Invalid Instance:");
811 		return QDF_STATUS_E_INVAL;
812 	}
813 
814 	if (soc->ops->misc_ops->txrx_ext_stats_request)
815 		return soc->ops->misc_ops->txrx_ext_stats_request(soc, pdev_id,
816 								  req);
817 
818 	return QDF_STATUS_SUCCESS;
819 }
820 
821 /**
822  * cdp_request_rx_hw_stats(): request rx hw stats
823  * @soc: soc handle
824  * @vdev_id: vdev id
825  *
826  * return: none
827  */
828 static inline QDF_STATUS
829 cdp_request_rx_hw_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
830 {
831 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
832 		dp_cdp_debug("Invalid Instance:");
833 		return QDF_STATUS_E_INVAL;
834 	}
835 
836 	if (soc->ops->misc_ops->request_rx_hw_stats)
837 		return soc->ops->misc_ops->request_rx_hw_stats(soc, vdev_id);
838 
839 	return QDF_STATUS_SUCCESS;
840 }
841 
842 /**
843  * cdp_reset_rx_hw_ext_stats(): reset rx hw ext stats
844  * @soc: soc handle
845  *
846  * Return: none
847  */
848 static inline void
849 cdp_reset_rx_hw_ext_stats(ol_txrx_soc_handle soc)
850 {
851 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
852 		dp_cdp_debug("Invalid Instance");
853 		return;
854 	}
855 
856 	if (soc->ops->misc_ops->reset_rx_hw_ext_stats)
857 		soc->ops->misc_ops->reset_rx_hw_ext_stats(soc);
858 }
859 
860 /**
861  * cdp_vdev_inform_ll_conn() - Inform DP about the low latency connection
862  * @soc: soc handle
863  * @vdev_id: vdev id
864  * @action: Action to be performed (Add/Delete)
865  *
866  * Returns: QDF_STATUS
867  */
868 static inline QDF_STATUS
869 cdp_vdev_inform_ll_conn(ol_txrx_soc_handle soc, uint8_t vdev_id,
870 			enum vdev_ll_conn_actions action)
871 {
872 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
873 		dp_cdp_debug("Invalid Instance:");
874 		return QDF_STATUS_E_INVAL;
875 	}
876 
877 	if (soc->ops->misc_ops->vdev_inform_ll_conn)
878 		return soc->ops->misc_ops->vdev_inform_ll_conn(soc, vdev_id,
879 							       action);
880 
881 	return QDF_STATUS_SUCCESS;
882 }
883 
884 /**
885  * cdp_soc_set_swlm_enable() - Enable or disable software latency manager
886  * @soc: soc handle
887  * @value: value (enable/disable)
888  *
889  * Returns: QDF_STATUS
890  */
891 static inline QDF_STATUS
892 cdp_soc_set_swlm_enable(ol_txrx_soc_handle soc, uint8_t value)
893 {
894 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
895 		dp_cdp_debug("Invalid Instance:");
896 		return QDF_STATUS_E_INVAL;
897 	}
898 
899 	if (soc->ops->misc_ops->set_swlm_enable)
900 		return soc->ops->misc_ops->set_swlm_enable(soc, value);
901 
902 	return QDF_STATUS_SUCCESS;
903 }
904 
905 /**
906  * cdp_soc_is_swlm_enabled() - Check if the software latency manager is
907  *			       enabled or not
908  * @soc: soc handle
909  *
910  * Returns: 1 if enabled, 0 if disabled
911  */
912 static inline uint8_t
913 cdp_soc_is_swlm_enabled(ol_txrx_soc_handle soc)
914 {
915 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
916 		dp_cdp_debug("Invalid Instance:");
917 		return 0;
918 	}
919 
920 	if (soc->ops->misc_ops->is_swlm_enabled)
921 		return soc->ops->misc_ops->is_swlm_enabled(soc);
922 
923 	return 0;
924 }
925 
926 /**
927  * cdp_display_txrx_hw_info() - Dump the DP rings info
928  * @soc: soc handle
929  *
930  * Return: none
931  */
932 static inline void
933 cdp_display_txrx_hw_info(ol_txrx_soc_handle soc)
934 {
935 	if (!soc || !soc->ops || !soc->ops->misc_ops) {
936 		dp_cdp_debug("Invalid Instance:");
937 		return;
938 	}
939 
940 	if (soc->ops->misc_ops->display_txrx_hw_info)
941 		return soc->ops->misc_ops->display_txrx_hw_info(soc);
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
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
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() - 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
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_vote_lvl() - get 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
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
1036 cdp_set_bus_vote_lvl_high(ol_txrx_soc_handle soc, bool high)
1037 {
1038 }
1039 
1040 static inline bool
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 #endif /* _CDP_TXRX_MISC_H_ */
1051