xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_ctrl.h (revision 8967ce71a84a76351f8ebf239925d47f7c692f7e)
1 /*
2  * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * @file cdp_txrx_ctrl.h
21  * @brief Define the host data path control API functions
22  * called by the host control SW and the OS interface module
23  */
24 
25 #ifndef _CDP_TXRX_CTRL_H_
26 #define _CDP_TXRX_CTRL_H_
27 #include "cdp_txrx_handle.h"
28 #include "cdp_txrx_cmn_struct.h"
29 #include "cdp_txrx_cmn.h"
30 #include "cdp_txrx_ops.h"
31 
32 static inline int cdp_is_target_ar900b
33 	(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
34 {
35 	if (!soc || !soc->ops) {
36 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
37 				"%s: Invalid Instance:", __func__);
38 		QDF_BUG(0);
39 		return 0;
40 	}
41 
42 	if (!soc->ops->ctrl_ops ||
43 	    !soc->ops->ctrl_ops->txrx_is_target_ar900b)
44 		return 0;
45 
46 	return soc->ops->ctrl_ops->txrx_is_target_ar900b(vdev);
47 }
48 
49 
50 /* WIN */
51 static inline int
52 cdp_mempools_attach(ol_txrx_soc_handle soc, void *ctrl_pdev)
53 {
54 	if (!soc || !soc->ops) {
55 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
56 				"%s: Invalid Instance:", __func__);
57 		QDF_BUG(0);
58 		return 0;
59 	}
60 
61 	if (!soc->ops->ctrl_ops ||
62 	    !soc->ops->ctrl_ops->txrx_mempools_attach)
63 		return 0;
64 
65 	return soc->ops->ctrl_ops->txrx_mempools_attach(ctrl_pdev);
66 }
67 
68 /**
69  * @brief set filter neighbour peers
70  * @details
71  *  This defines interface function to set neighbour peer filtering.
72  *
73  * @param soc - the pointer to soc object
74  * @param pdev - the pointer physical device object
75  * @param val - the enable/disable value
76  * @return - int
77  */
78 static inline int
79 cdp_set_filter_neighbour_peers(ol_txrx_soc_handle soc,
80 	struct cdp_pdev *pdev, u_int32_t val)
81 {
82 	if (!soc || !soc->ops) {
83 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
84 				"%s: Invalid Instance:", __func__);
85 		QDF_BUG(0);
86 		return 0;
87 	}
88 
89 	if (!soc->ops->ctrl_ops ||
90 	    !soc->ops->ctrl_ops->txrx_set_filter_neighbour_peers)
91 		return 0;
92 
93 	return soc->ops->ctrl_ops->txrx_set_filter_neighbour_peers
94 			(pdev, val);
95 }
96 
97 /**
98  * @brief update the neighbour peer addresses
99  * @details
100  *  This defines interface function to update neighbour peers addresses
101  *  which needs to be filtered
102  *
103  * @param soc - the pointer to soc object
104  * @param vdev - the pointer to vdev
105  * @param cmd - add/del entry into peer table
106  * @param macaddr - the address of neighbour peer
107  * @return - int
108  */
109 static inline int
110 cdp_update_filter_neighbour_peers(ol_txrx_soc_handle soc,
111 	struct cdp_vdev *vdev, uint32_t cmd, uint8_t *macaddr)
112 {
113 	if (!soc || !soc->ops) {
114 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
115 				"%s: Invalid Instance:", __func__);
116 		QDF_BUG(0);
117 		return 0;
118 	}
119 
120 	if (!soc->ops->ctrl_ops ||
121 	    !soc->ops->ctrl_ops->txrx_update_filter_neighbour_peers)
122 		return 0;
123 
124 	return soc->ops->ctrl_ops->txrx_update_filter_neighbour_peers
125 			(vdev, cmd, macaddr);
126 }
127 
128 /**
129  * @brief set the safemode of the device
130  * @details
131  *  This flag is used to bypass the encrypt and decrypt processes when send and
132  *  receive packets. It works like open AUTH mode, HW will treate all packets
133  *  as non-encrypt frames because no key installed. For rx fragmented frames,
134  *  it bypasses all the rx defragmentaion.
135  *
136  * @param vdev - the data virtual device object
137  * @param val - the safemode state
138  * @return - void
139  */
140 static inline void
141 cdp_set_safemode(ol_txrx_soc_handle soc,
142 	struct cdp_vdev *vdev, u_int32_t val)
143 {
144 	if (!soc || !soc->ops) {
145 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
146 				"%s: Invalid Instance:", __func__);
147 		QDF_BUG(0);
148 		return;
149 	}
150 
151 	if (!soc->ops->ctrl_ops ||
152 	    !soc->ops->ctrl_ops->txrx_set_safemode)
153 		return;
154 
155 	soc->ops->ctrl_ops->txrx_set_safemode(vdev, val);
156 }
157 /**
158  * @brief configure the drop unencrypted frame flag
159  * @details
160  *  Rx related. When set this flag, all the unencrypted frames
161  *  received over a secure connection will be discarded
162  *
163  * @param vdev - the data virtual device object
164  * @param val - flag
165  * @return - void
166  */
167 static inline void
168 cdp_set_drop_unenc(ol_txrx_soc_handle soc,
169 	struct cdp_vdev *vdev, u_int32_t val)
170 {
171 	if (!soc || !soc->ops) {
172 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
173 				"%s: Invalid Instance:", __func__);
174 		QDF_BUG(0);
175 		return;
176 	}
177 
178 	if (!soc->ops->ctrl_ops ||
179 	    !soc->ops->ctrl_ops->txrx_set_drop_unenc)
180 		return;
181 
182 	soc->ops->ctrl_ops->txrx_set_drop_unenc(vdev, val);
183 }
184 
185 
186 /**
187  * @brief set the Tx encapsulation type of the VDEV
188  * @details
189  *  This will be used to populate the HTT desc packet type field during Tx
190  *
191  * @param vdev - the data virtual device object
192  * @param val - the Tx encap type (htt_cmn_pkt_type)
193  * @return - void
194  */
195 static inline void
196 cdp_set_tx_encap_type(ol_txrx_soc_handle soc,
197 	struct cdp_vdev *vdev, enum htt_cmn_pkt_type val)
198 {
199 	if (!soc || !soc->ops) {
200 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
201 				"%s: Invalid Instance:", __func__);
202 		QDF_BUG(0);
203 		return;
204 	}
205 
206 	if (!soc->ops->ctrl_ops ||
207 	    !soc->ops->ctrl_ops->txrx_set_tx_encap_type)
208 		return;
209 
210 	soc->ops->ctrl_ops->txrx_set_tx_encap_type(vdev, val);
211 }
212 
213 /**
214  * @brief set the Rx decapsulation type of the VDEV
215  * @details
216  *  This will be used to configure into firmware and hardware which format to
217  *  decap all Rx packets into, for all peers under the VDEV.
218  *
219  * @param vdev - the data virtual device object
220  * @param val - the Rx decap mode (htt_cmn_pkt_type)
221  * @return - void
222  */
223 static inline void
224 cdp_set_vdev_rx_decap_type(ol_txrx_soc_handle soc,
225 	struct cdp_vdev *vdev, enum htt_cmn_pkt_type val)
226 {
227 	if (!soc || !soc->ops) {
228 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
229 				"%s: Invalid Instance:", __func__);
230 		QDF_BUG(0);
231 		return;
232 	}
233 
234 	if (!soc->ops->ctrl_ops ||
235 	    !soc->ops->ctrl_ops->txrx_set_vdev_rx_decap_type)
236 		return;
237 
238 	soc->ops->ctrl_ops->txrx_set_vdev_rx_decap_type
239 			(vdev, val);
240 }
241 
242 /**
243  * @brief get the Rx decapsulation type of the VDEV
244  *
245  * @param vdev - the data virtual device object
246  * @return - the Rx decap type (htt_cmn_pkt_type)
247  */
248 static inline enum htt_cmn_pkt_type
249 cdp_get_vdev_rx_decap_type(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
250 {
251 	if (!soc || !soc->ops) {
252 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
253 				"%s: Invalid Instance:", __func__);
254 		QDF_BUG(0);
255 		return 0;
256 	}
257 
258 	if (!soc->ops->ctrl_ops ||
259 	    !soc->ops->ctrl_ops->txrx_get_vdev_rx_decap_type)
260 		return 0;
261 
262 	return soc->ops->ctrl_ops->txrx_get_vdev_rx_decap_type(vdev);
263 }
264 
265 /**
266  * @brief set the Reo Destination ring for the pdev
267  * @details
268  *  This will be used to configure the Reo Destination ring for this pdev.
269  *
270  * @param soc - pointer to the soc
271  * @param pdev - the data physical device object
272  * @param val - the Reo destination ring index (1 to 4)
273  * @return - void
274  */
275 static inline void
276 cdp_set_pdev_reo_dest(ol_txrx_soc_handle soc,
277 	struct cdp_pdev *pdev, enum cdp_host_reo_dest_ring val)
278 {
279 	if (!soc || !soc->ops) {
280 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
281 				"%s: Invalid Instance:", __func__);
282 		QDF_BUG(0);
283 		return;
284 	}
285 
286 	if (!soc->ops->ctrl_ops ||
287 	    !soc->ops->ctrl_ops->txrx_set_pdev_reo_dest)
288 		return;
289 
290 	soc->ops->ctrl_ops->txrx_set_pdev_reo_dest
291 			(pdev, val);
292 }
293 
294 /**
295  * @brief get the Reo Destination ring for the pdev
296  *
297  * @param soc - pointer to the soc
298  * @param pdev - the data physical device object
299  * @return - the Reo destination ring index (1 to 4), 0 if not supported.
300  */
301 static inline enum cdp_host_reo_dest_ring
302 cdp_get_pdev_reo_dest(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
303 {
304 	if (!soc || !soc->ops) {
305 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
306 				"%s: Invalid Instance:", __func__);
307 		QDF_BUG(0);
308 		return cdp_host_reo_dest_ring_unknown;
309 	}
310 
311 	if (!soc->ops->ctrl_ops ||
312 	    !soc->ops->ctrl_ops->txrx_get_pdev_reo_dest)
313 		return cdp_host_reo_dest_ring_unknown;
314 
315 	return soc->ops->ctrl_ops->txrx_get_pdev_reo_dest(pdev);
316 }
317 
318 /* Is this similar to ol_txrx_peer_state_update() in MCL */
319 /**
320  * @brief Update the authorize peer object at association time
321  * @details
322  *  For the host-based implementation of rate-control, it
323  *  updates the peer/node-related parameters within rate-control
324  *  context of the peer at association.
325  *
326  * @param peer - pointer to the node's object
327  * @authorize - either to authorize or unauthorize peer
328  *
329  * @return none
330  */
331 static inline void
332 cdp_peer_authorize(ol_txrx_soc_handle soc,
333 	struct cdp_peer *peer, u_int32_t authorize)
334 {
335 	if (!soc || !soc->ops) {
336 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
337 				"%s: Invalid Instance:", __func__);
338 		QDF_BUG(0);
339 		return;
340 	}
341 
342 	if (!soc->ops->ctrl_ops ||
343 	    !soc->ops->ctrl_ops->txrx_peer_authorize)
344 		return;
345 
346 	soc->ops->ctrl_ops->txrx_peer_authorize
347 			(peer, authorize);
348 }
349 
350 /* Should be ol_txrx_ctrl_api.h */
351 static inline void cdp_set_mesh_mode
352 (ol_txrx_soc_handle soc, struct cdp_vdev *vdev, u_int32_t val)
353 {
354 	if (!soc || !soc->ops) {
355 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
356 				"%s: Invalid Instance:", __func__);
357 		QDF_BUG(0);
358 		return;
359 	}
360 
361 	if (!soc->ops->ctrl_ops ||
362 	    !soc->ops->ctrl_ops->txrx_set_mesh_mode)
363 		return;
364 
365 	soc->ops->ctrl_ops->txrx_set_mesh_mode(vdev, val);
366 }
367 
368 /**
369  * @brief set mesh rx filter
370  * @details based on the bits enabled in the filter packets has to be dropped.
371  *
372  * @param soc - pointer to the soc
373  * @param vdev - the data virtual device object
374  * @param val - value to be set
375  * @return - void
376  */
377 static inline
378 void cdp_set_mesh_rx_filter(ol_txrx_soc_handle soc,
379 				struct cdp_vdev *vdev, uint32_t val)
380 {
381 	if (!soc || !soc->ops) {
382 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
383 				"%s: Invalid Instance:", __func__);
384 		QDF_BUG(0);
385 		return;
386 	}
387 
388 	if (!soc->ops->ctrl_ops ||
389 	    !soc->ops->ctrl_ops->txrx_set_mesh_rx_filter)
390 		return;
391 
392 	soc->ops->ctrl_ops->txrx_set_mesh_rx_filter(vdev, val);
393 }
394 
395 static inline void cdp_tx_flush_buffers
396 (ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
397 {
398 	if (!soc || !soc->ops) {
399 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
400 				"%s: Invalid Instance:", __func__);
401 		QDF_BUG(0);
402 		return;
403 	}
404 
405 	if (!soc->ops->ctrl_ops ||
406 	    !soc->ops->ctrl_ops->tx_flush_buffers)
407 		return;
408 
409 	soc->ops->ctrl_ops->tx_flush_buffers(vdev);
410 }
411 
412 static inline uint32_t cdp_txrx_get_vdev_param(ol_txrx_soc_handle soc,
413 					       struct cdp_vdev *vdev,
414 					       enum cdp_vdev_param_type type)
415 {
416 	if (!soc || !soc->ops) {
417 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
418 			  "%s: Invalid Instance:", __func__);
419 		QDF_BUG(0);
420 		return -1;
421 	}
422 
423 	if (!soc->ops->ctrl_ops ||
424 	    !soc->ops->ctrl_ops->txrx_get_vdev_param) {
425 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
426 			  "%s: callback not registered:", __func__);
427 		return -1;
428 	}
429 
430 	return soc->ops->ctrl_ops->txrx_get_vdev_param(vdev, type);
431 }
432 
433 static inline void cdp_txrx_set_vdev_param(ol_txrx_soc_handle soc,
434 		struct cdp_vdev *vdev, enum cdp_vdev_param_type type,
435 		uint32_t val)
436 {
437 	if (!soc || !soc->ops) {
438 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
439 				"%s: Invalid Instance:", __func__);
440 		QDF_BUG(0);
441 		return;
442 	}
443 
444 	if (!soc->ops->ctrl_ops ||
445 	    !soc->ops->ctrl_ops->txrx_set_vdev_param)
446 		return;
447 
448 	soc->ops->ctrl_ops->txrx_set_vdev_param(vdev, type, val);
449 }
450 
451 static inline void
452 cdp_peer_set_nawds(ol_txrx_soc_handle soc,
453 		struct cdp_peer *peer, uint8_t value)
454 {
455 	if (!soc || !soc->ops) {
456 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
457 				"%s: Invalid Instance:", __func__);
458 		QDF_BUG(0);
459 		return;
460 	}
461 
462 	if (!soc->ops->ctrl_ops ||
463 	    !soc->ops->ctrl_ops->txrx_peer_set_nawds)
464 		return;
465 
466 	soc->ops->ctrl_ops->txrx_peer_set_nawds
467 			(peer, value);
468 }
469 
470 #ifdef QCA_MULTIPASS_SUPPORT
471 static inline void
472 cdp_peer_set_vlan_id(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
473 		     uint8_t *peer_mac, uint8_t vlan_id)
474 {
475 	if (!soc || !soc->ops) {
476 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
477 			  "%s: Invalid Instance:", __func__);
478 		QDF_BUG(0);
479 		return;
480 	}
481 
482 	if (!soc->ops->ctrl_ops ||
483 	    !soc->ops->ctrl_ops->txrx_peer_set_vlan_id)
484 		return;
485 
486 	soc->ops->ctrl_ops->txrx_peer_set_vlan_id(soc, vdev, peer_mac, vlan_id);
487 }
488 #endif
489 
490 /**
491  * cdp_txrx_set_pdev_param() - set pdev parameter
492  * @soc: opaque soc handle
493  * @pdev: data path pdev handle
494  * @type: param type
495  * @val: value of pdev_tx_capture
496  *
497  * Return: status: 0 - Success, non-zero: Failure
498  */
499 static inline QDF_STATUS cdp_txrx_set_pdev_param(ol_txrx_soc_handle soc,
500 						 struct cdp_pdev *pdev,
501 						 enum cdp_pdev_param_type type,
502 						 uint32_t val)
503 {
504 	if (!soc || !soc->ops) {
505 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
506 				"%s: Invalid Instance:", __func__);
507 		QDF_BUG(0);
508 		return QDF_STATUS_SUCCESS;
509 	}
510 
511 	if (!soc->ops->ctrl_ops ||
512 	    !soc->ops->ctrl_ops->txrx_set_pdev_param)
513 		return QDF_STATUS_SUCCESS;
514 
515 	return soc->ops->ctrl_ops->txrx_set_pdev_param
516 			(pdev, type, val);
517 }
518 
519 /**
520  * cdp_enable_peer_based_pktlog()- Set flag in peer structure
521  *
522  * @soc: pointer to the soc
523  * @pdev: the data physical device object
524  * @enable: enable or disable peer based filter based pktlog
525  * @peer_macaddr: Mac address of peer which needs to be
526  * filtered
527  *
528  * This function will set flag in peer structure if peer based filtering
529  * is enabled for pktlog
530  *
531  * Return: int
532  */
533 static inline int
534 cdp_enable_peer_based_pktlog(ol_txrx_soc_handle soc,
535 			     struct cdp_pdev *pdev, char *peer_macaddr,
536 			     uint8_t enable)
537 {
538 	if (!soc || !soc->ops) {
539 		QDF_TRACE_ERROR(QDF_MODULE_ID_DP,
540 				"%s invalid instance", __func__);
541 		QDF_BUG(0);
542 		return 0;
543 	}
544 
545 	if (!soc->ops->ctrl_ops ||
546 	    !soc->ops->ctrl_ops->enable_peer_based_pktlog)
547 		return 0;
548 
549 	return soc->ops->ctrl_ops->enable_peer_based_pktlog
550 			(pdev, peer_macaddr, enable);
551 }
552 
553 /**
554  * cdp_calculate_delay_stats()- get rx delay stats
555  *
556  * @soc: pointer to the soc
557  * @vdev: vdev handle
558  * @nbuf: nbuf which is passed
559  *
560  * This function will calculate rx delay statistics.
561  */
562 static inline void
563 cdp_calculate_delay_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
564 			  qdf_nbuf_t nbuf)
565 {
566 	if (!soc || !soc->ops) {
567 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
568 			  "%s: Invalid Instance:", __func__);
569 		QDF_BUG(0);
570 		return;
571 	}
572 
573 	if (!soc->ops->ctrl_ops ||
574 	    !soc->ops->ctrl_ops->calculate_delay_stats) {
575 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
576 			  "%s: callback not registered:", __func__);
577 		return;
578 	}
579 
580 	return soc->ops->ctrl_ops->calculate_delay_stats(vdev, nbuf);
581 }
582 
583 /**
584  * @brief Subscribe to a specified WDI event.
585  * @details
586  *  This function adds the provided wdi_event_subscribe object to a list of
587  *  subscribers for the specified WDI event.
588  *  When the event in question happens, each subscriber for the event will
589  *  have their callback function invoked.
590  *  The order in which callback functions from multiple subscribers are
591  *  invoked is unspecified.
592  *
593  * @param soc - pointer to the soc
594  * @param pdev - the data physical device object
595  * @param event_cb_sub - the callback and context for the event subscriber
596  * @param event - which event's notifications are being subscribed to
597  * @return - int
598  */
599 static inline int
600 cdp_wdi_event_sub(ol_txrx_soc_handle soc,
601 		struct cdp_pdev *pdev, void *event_cb_sub, uint32_t event)
602 {
603 
604 	if (!soc || !soc->ops) {
605 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
606 			"%s invalid instance", __func__);
607 		QDF_BUG(0);
608 		return 0;
609 	}
610 
611 	if (!soc->ops->ctrl_ops ||
612 	    !soc->ops->ctrl_ops->txrx_wdi_event_sub)
613 		return 0;
614 
615 	return soc->ops->ctrl_ops->txrx_wdi_event_sub
616 			(pdev, event_cb_sub, event);
617 }
618 
619 /**
620  * @brief Unsubscribe from a specified WDI event.
621  * @details
622  *  This function removes the provided event subscription object from the
623  *  list of subscribers for its event.
624  *  This function shall only be called if there was a successful prior call
625  *  to event_sub() on the same wdi_event_subscribe object.
626  *
627  * @param soc - pointer to the soc
628  * @param pdev - the data physical device object
629  * @param event_cb_sub - the callback and context for the event subscriber
630  * @param event - which event's notifications are being subscribed to
631  * @return - int
632  */
633 static inline int
634 cdp_wdi_event_unsub(ol_txrx_soc_handle soc,
635 		struct cdp_pdev *pdev, void *event_cb_sub, uint32_t event)
636 {
637 
638 	if (!soc || !soc->ops) {
639 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
640 			"%s invalid instance", __func__);
641 		QDF_BUG(0);
642 		return 0;
643 	}
644 
645 	if (!soc->ops->ctrl_ops ||
646 	    !soc->ops->ctrl_ops->txrx_wdi_event_unsub)
647 		return 0;
648 
649 	return soc->ops->ctrl_ops->txrx_wdi_event_unsub
650 			(pdev, event_cb_sub, event);
651 }
652 
653 /**
654  * @brief Get security type from the from peer.
655  * @details
656  * This function gets the Security information from the peer handler.
657  * The security information is got from the rx descriptor and filled in
658  * to the peer handler.
659  *
660  * @param soc - pointer to the soc
661  * @param peer - peer handler
662  * @param sec_idx - mcast or ucast frame type.
663  * @return - int
664  */
665 static inline int
666 cdp_get_sec_type(ol_txrx_soc_handle soc, struct cdp_peer *peer, uint8_t sec_idx)
667 {
668 	if (!soc || !soc->ops) {
669 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
670 			"%s invalid instance", __func__);
671 		QDF_BUG(0);
672 		return A_ERROR;
673 	}
674 
675 	if (!soc->ops->ctrl_ops ||
676 	    !soc->ops->ctrl_ops->txrx_get_sec_type)
677 		return A_ERROR;
678 
679 	return soc->ops->ctrl_ops->txrx_get_sec_type
680 			(peer, sec_idx);
681 }
682 
683 /**
684   * cdp_set_mgmt_tx_power(): function to set tx power for mgmt frames
685   * @vdev_handle: vdev handle
686   * @subtype_index: subtype
687   * @tx_power: Tx power
688   * Return: None
689   */
690 static inline int cdp_set_mgmt_tx_power(ol_txrx_soc_handle soc,
691 	struct cdp_vdev *vdev, uint8_t subtype, uint8_t tx_power)
692 {
693 	if (!soc || !soc->ops) {
694 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
695 				"%s: Invalid Instance:", __func__);
696 		QDF_BUG(0);
697 		return 0;
698 	}
699 
700 	if (!soc->ops->ctrl_ops ||
701 	    !soc->ops->ctrl_ops->txrx_update_mgmt_txpow_vdev)
702 		return 0;
703 
704 	soc->ops->ctrl_ops->txrx_update_mgmt_txpow_vdev(vdev,
705 							subtype, tx_power);
706 	return 0;
707 }
708 
709 static inline void *
710 cdp_get_pldev(ol_txrx_soc_handle soc,
711 		struct cdp_pdev *pdev)
712 {
713 	if (!soc || !soc->ops) {
714 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
715 			"%s invalid instance", __func__);
716 		QDF_BUG(0);
717 		return NULL;
718 	}
719 
720 	if (!soc->ops->ctrl_ops || !soc->ops->ctrl_ops->txrx_get_pldev)
721 		return NULL;
722 
723 	return soc->ops->ctrl_ops->txrx_get_pldev(pdev);
724 }
725 
726 #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
727 /**
728  * cdp_cfr_filter() - Configure Host RX monitor status ring for CFR
729  * @soc: SOC TXRX handle
730  * @pdev_id: ID of the physical device object
731  * @enable: Enable or disable CFR
732  * @filter_val: Flag to select filter for monitor mode
733  */
734 static inline void
735 cdp_cfr_filter(ol_txrx_soc_handle soc,
736 	       uint8_t pdev_id,
737 	       bool enable,
738 	       struct cdp_monitor_filter *filter_val)
739 {
740 	if (!soc || !soc->ops) {
741 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
742 			  "%s invalid instance", __func__);
743 		QDF_BUG(0);
744 		return;
745 	}
746 
747 	if (!soc->ops->cfr_ops || !soc->ops->cfr_ops->txrx_cfr_filter)
748 		return;
749 
750 	soc->ops->cfr_ops->txrx_cfr_filter(soc, pdev_id, enable, filter_val);
751 }
752 #endif
753 
754 #if defined(WLAN_TX_PKT_CAPTURE_ENH) || defined(WLAN_RX_PKT_CAPTURE_ENH)
755 /**
756  * cdp_update_peer_pkt_capture_params() - Sets Rx & Tx Capture params for a peer
757  * @soc: SOC TXRX handle
758  * @pdev: CDP pdev pointer
759  * @is_rx_pkt_cap_enable: enable/disable rx pkt capture for this peer
760  * @is_tx_pkt_cap_enable: enable/disable tx pkt capture for this peer
761  * @peer_mac: MAC address of peer for which pkt_cap is to be enabled/disabled
762  *
763  * Return: Success when matching peer is found & flags are set, error otherwise
764  */
765 static inline QDF_STATUS
766 cdp_update_peer_pkt_capture_params(ol_txrx_soc_handle soc,
767 				   struct cdp_pdev *pdev,
768 				   bool is_rx_pkt_cap_enable,
769 				   bool is_tx_pkt_cap_enable,
770 				   uint8_t *peer_mac)
771 {
772 	if (!soc || !soc->ops) {
773 		dp_err("Invalid SOC instance");
774 		QDF_BUG(0);
775 		return QDF_STATUS_E_FAILURE;
776 	}
777 
778 	if (!soc->ops->ctrl_ops ||
779 	    !soc->ops->ctrl_ops->txrx_update_peer_pkt_capture_params)
780 		return QDF_STATUS_E_FAILURE;
781 
782 	return soc->ops->ctrl_ops->txrx_update_peer_pkt_capture_params
783 			(pdev, is_rx_pkt_cap_enable, is_tx_pkt_cap_enable,
784 			 peer_mac);
785 }
786 #endif /* WLAN_TX_PKT_CAPTURE_ENH || WLAN_RX_PKT_CAPTURE_ENH */
787 
788 #ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
789 /**
790  * cdp_update_pdev_rx_protocol_tag() - wrapper function to set the protocol
791  *                                    tag in CDP layer from cfg layer
792  * @soc: SOC TXRX handle
793  * @pdev: CDP pdev pointer
794  * @protocol_mask: Bitmap for protocol for which tagging is enabled
795  * @protocol_type: Protocol type for which the tag should be update
796  * @tag: Actual tag value for the given prototype
797  * Return: Returns QDF_STATUS_SUCCESS/FAILURE
798  */
799 static inline QDF_STATUS
800 cdp_update_pdev_rx_protocol_tag(ol_txrx_soc_handle soc,
801 				struct cdp_pdev *pdev, uint32_t protocol_mask,
802 				uint16_t protocol_type, uint16_t tag)
803 {
804 	if (!soc || !soc->ops) {
805 		dp_err("Invalid SOC instance");
806 		QDF_BUG(0);
807 		return QDF_STATUS_E_FAILURE;
808 	}
809 
810 	if (!soc->ops->ctrl_ops ||
811 	    !soc->ops->ctrl_ops->txrx_update_pdev_rx_protocol_tag)
812 		return QDF_STATUS_E_FAILURE;
813 
814 	return soc->ops->ctrl_ops->txrx_update_pdev_rx_protocol_tag
815 			(pdev, protocol_mask, protocol_type, tag);
816 }
817 
818 #ifdef WLAN_SUPPORT_RX_TAG_STATISTICS
819 /**
820  * cdp_dump_pdev_rx_protocol_tag_stats() - wrapper function to dump the protocol
821 				tag statistics for given or all protocols
822  * @soc: SOC TXRX handle
823  * @pdev: CDP pdev pointer
824  * @protocol_type: Protocol type for which the tag should be update
825  * Return: Returns QDF_STATUS_SUCCESS/FAILURE
826  */
827 static inline QDF_STATUS
828 cdp_dump_pdev_rx_protocol_tag_stats(ol_txrx_soc_handle soc,
829 				    struct cdp_pdev *pdev,
830 				    uint16_t protocol_type)
831 {
832 	if (!soc || !soc->ops) {
833 		dp_err("Invalid SOC instance");
834 		QDF_BUG(0);
835 		return QDF_STATUS_E_FAILURE;
836 	}
837 
838 	if (!soc->ops->ctrl_ops ||
839 	    !soc->ops->ctrl_ops->txrx_dump_pdev_rx_protocol_tag_stats)
840 		return QDF_STATUS_E_FAILURE;
841 
842 	soc->ops->ctrl_ops->txrx_dump_pdev_rx_protocol_tag_stats(pdev,
843 						protocol_type);
844 	return QDF_STATUS_SUCCESS;
845 }
846 #endif /* WLAN_SUPPORT_RX_TAG_STATISTICS */
847 #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
848 
849 #ifdef ATH_SUPPORT_NAC_RSSI
850 /**
851   * cdp_vdev_config_for_nac_rssi(): To invoke dp callback for nac rssi config
852   * @soc: soc pointer
853   * @vdev: vdev pointer
854   * @nac_cmd: specfies nac_rss config action add, del, list
855   * @bssid: Neighbour bssid
856   * @client_macaddr: Non-Associated client MAC
857   * @chan_num: channel number to scan
858   *
859   * Return: QDF_STATUS
860   */
861 static inline QDF_STATUS cdp_vdev_config_for_nac_rssi(ol_txrx_soc_handle soc,
862 		struct cdp_vdev *vdev, enum cdp_nac_param_cmd nac_cmd,
863 		char *bssid, char *client_macaddr, uint8_t chan_num)
864 {
865 	if (!soc || !soc->ops) {
866 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
867 			"%s invalid instance", __func__);
868 		QDF_BUG(0);
869 		return QDF_STATUS_E_FAILURE;
870 	}
871 
872 	if (!soc->ops->ctrl_ops ||
873 			!soc->ops->ctrl_ops->txrx_vdev_config_for_nac_rssi)
874 		return QDF_STATUS_E_FAILURE;
875 
876 	return soc->ops->ctrl_ops->txrx_vdev_config_for_nac_rssi(vdev,
877 			nac_cmd, bssid, client_macaddr, chan_num);
878 }
879 
880 /*
881  * cdp_vdev_get_neighbour_rssi(): To invoke dp callback to get rssi value of nac
882  * @soc: soc pointer
883  * @vdev: vdev pointer
884  * @macaddr: Non-Associated client MAC
885  * @rssi: rssi
886  *
887  * Return: QDF_STATUS
888  */
889 static inline QDF_STATUS cdp_vdev_get_neighbour_rssi(ol_txrx_soc_handle soc,
890 						     struct cdp_vdev *vdev,
891 						     char *macaddr,
892 						     uint8_t *rssi)
893 {
894 	if (!soc || !soc->ops) {
895 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
896 			  "%s invalid instance", __func__);
897 		QDF_BUG(0);
898 		return QDF_STATUS_E_FAILURE;
899 	}
900 
901 	if (!soc->ops->ctrl_ops ||
902 	    !soc->ops->ctrl_ops->txrx_vdev_get_neighbour_rssi)
903 		return QDF_STATUS_E_FAILURE;
904 
905 	return soc->ops->ctrl_ops->txrx_vdev_get_neighbour_rssi(vdev, macaddr,
906 								rssi);
907 }
908 #endif
909 
910 #ifdef WLAN_SUPPORT_RX_FLOW_TAG
911 /**
912  * cdp_set_rx_flow_tag() - wrapper function to set the flow
913  *                         tag in CDP layer from cfg layer
914  * @soc: SOC TXRX handle
915  * @pdev: CDP pdev pointer
916  * @flow_info: Flow 5-tuple, along with tag, if any, that needs to added/deleted
917  *
918  * Return: Success when add/del operation is successful, error otherwise
919  */
920 static inline QDF_STATUS
921 cdp_set_rx_flow_tag(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
922 		    struct cdp_rx_flow_info *flow_info)
923 {
924 	if (!soc || !soc->ops) {
925 		dp_err("Invalid SOC instance");
926 		QDF_BUG(0);
927 		return QDF_STATUS_E_FAILURE;
928 	}
929 
930 	if (!soc->ops->ctrl_ops ||
931 	    !soc->ops->ctrl_ops->txrx_set_rx_flow_tag)
932 		return QDF_STATUS_E_FAILURE;
933 
934 	return soc->ops->ctrl_ops->txrx_set_rx_flow_tag(pdev, flow_info);
935 }
936 
937 /**
938  * cdp_dump_rx_flow_tag_stats() - wrapper function to dump the flow
939  *                                tag statistics for given flow
940  * @soc: SOC TXRX handle
941  * @pdev: CDP pdev pointer
942  * @flow_info: Flow tuple for which we want to print the statistics
943  *
944  * Return: Success when flow is found and stats are printed, error otherwise
945  */
946 static inline QDF_STATUS
947 cdp_dump_rx_flow_tag_stats(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
948 			   struct cdp_rx_flow_info *flow_info)
949 {
950 	if (!soc || !soc->ops) {
951 		dp_err("Invalid SOC instance");
952 		QDF_BUG(0);
953 		return QDF_STATUS_E_FAILURE;
954 	}
955 
956 	if (!soc->ops->ctrl_ops ||
957 	    !soc->ops->ctrl_ops->txrx_dump_rx_flow_tag_stats)
958 		return QDF_STATUS_E_FAILURE;
959 
960 	return soc->ops->ctrl_ops->txrx_dump_rx_flow_tag_stats(pdev, flow_info);
961 }
962 #endif /* WLAN_SUPPORT_RX_FLOW_TAG */
963 #endif /* _CDP_TXRX_CTRL_H_ */
964