xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_ctrl.h (revision dd4dc88b837a295134aa9869114a2efee0f4894b)
1 /*
2  * Copyright (c) 2016-2019 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 /**
471  * cdp_txrx_set_pdev_param() - set pdev parameter
472  * @soc: opaque soc handle
473  * @pdev: data path pdev handle
474  * @type: param type
475  * @val: value of pdev_tx_capture
476  *
477  * Return: status: 0 - Success, non-zero: Failure
478  */
479 static inline QDF_STATUS cdp_txrx_set_pdev_param(ol_txrx_soc_handle soc,
480 						 struct cdp_pdev *pdev,
481 						 enum cdp_pdev_param_type type,
482 						 uint8_t val)
483 {
484 	if (!soc || !soc->ops) {
485 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
486 				"%s: Invalid Instance:", __func__);
487 		QDF_BUG(0);
488 		return QDF_STATUS_SUCCESS;
489 	}
490 
491 	if (!soc->ops->ctrl_ops ||
492 	    !soc->ops->ctrl_ops->txrx_set_pdev_param)
493 		return QDF_STATUS_SUCCESS;
494 
495 	return soc->ops->ctrl_ops->txrx_set_pdev_param
496 			(pdev, type, val);
497 }
498 
499 /**
500  * cdp_enable_peer_based_pktlog()- Set flag in peer structure
501  *
502  * @soc: pointer to the soc
503  * @pdev: the data physical device object
504  * @enable: enable or disable peer based filter based pktlog
505  * @peer_macaddr: Mac address of peer which needs to be
506  * filtered
507  *
508  * This function will set flag in peer structure if peer based filtering
509  * is enabled for pktlog
510  *
511  * Return: int
512  */
513 static inline int
514 cdp_enable_peer_based_pktlog(ol_txrx_soc_handle soc,
515 			     struct cdp_pdev *pdev, char *peer_macaddr,
516 			     uint8_t enable)
517 {
518 	if (!soc || !soc->ops) {
519 		QDF_TRACE_ERROR(QDF_MODULE_ID_DP,
520 				"%s invalid instance", __func__);
521 		QDF_BUG(0);
522 		return 0;
523 	}
524 
525 	if (!soc->ops->ctrl_ops ||
526 	    !soc->ops->ctrl_ops->enable_peer_based_pktlog)
527 		return 0;
528 
529 	return soc->ops->ctrl_ops->enable_peer_based_pktlog
530 			(pdev, peer_macaddr, enable);
531 }
532 
533 /**
534  * cdp_calculate_delay_stats()- get rx delay stats
535  *
536  * @soc: pointer to the soc
537  * @vdev: vdev handle
538  * @nbuf: nbuf which is passed
539  *
540  * This function will calculate rx delay statistics.
541  */
542 static inline void
543 cdp_calculate_delay_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
544 			  qdf_nbuf_t nbuf)
545 {
546 	if (!soc || !soc->ops) {
547 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
548 			  "%s: Invalid Instance:", __func__);
549 		QDF_BUG(0);
550 		return;
551 	}
552 
553 	if (!soc->ops->ctrl_ops ||
554 	    !soc->ops->ctrl_ops->calculate_delay_stats) {
555 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
556 			  "%s: callback not registered:", __func__);
557 		return;
558 	}
559 
560 	return soc->ops->ctrl_ops->calculate_delay_stats(vdev, nbuf);
561 }
562 
563 /**
564  * @brief Subscribe to a specified WDI event.
565  * @details
566  *  This function adds the provided wdi_event_subscribe object to a list of
567  *  subscribers for the specified WDI event.
568  *  When the event in question happens, each subscriber for the event will
569  *  have their callback function invoked.
570  *  The order in which callback functions from multiple subscribers are
571  *  invoked is unspecified.
572  *
573  * @param soc - pointer to the soc
574  * @param pdev - the data physical device object
575  * @param event_cb_sub - the callback and context for the event subscriber
576  * @param event - which event's notifications are being subscribed to
577  * @return - int
578  */
579 static inline int
580 cdp_wdi_event_sub(ol_txrx_soc_handle soc,
581 		struct cdp_pdev *pdev, void *event_cb_sub, uint32_t event)
582 {
583 
584 	if (!soc || !soc->ops) {
585 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
586 			"%s invalid instance", __func__);
587 		QDF_BUG(0);
588 		return 0;
589 	}
590 
591 	if (!soc->ops->ctrl_ops ||
592 	    !soc->ops->ctrl_ops->txrx_wdi_event_sub)
593 		return 0;
594 
595 	return soc->ops->ctrl_ops->txrx_wdi_event_sub
596 			(pdev, event_cb_sub, event);
597 }
598 
599 /**
600  * @brief Unsubscribe from a specified WDI event.
601  * @details
602  *  This function removes the provided event subscription object from the
603  *  list of subscribers for its event.
604  *  This function shall only be called if there was a successful prior call
605  *  to event_sub() on the same wdi_event_subscribe object.
606  *
607  * @param soc - pointer to the soc
608  * @param pdev - the data physical device object
609  * @param event_cb_sub - the callback and context for the event subscriber
610  * @param event - which event's notifications are being subscribed to
611  * @return - int
612  */
613 static inline int
614 cdp_wdi_event_unsub(ol_txrx_soc_handle soc,
615 		struct cdp_pdev *pdev, void *event_cb_sub, uint32_t event)
616 {
617 
618 	if (!soc || !soc->ops) {
619 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
620 			"%s invalid instance", __func__);
621 		QDF_BUG(0);
622 		return 0;
623 	}
624 
625 	if (!soc->ops->ctrl_ops ||
626 	    !soc->ops->ctrl_ops->txrx_wdi_event_unsub)
627 		return 0;
628 
629 	return soc->ops->ctrl_ops->txrx_wdi_event_unsub
630 			(pdev, event_cb_sub, event);
631 }
632 
633 /**
634  * @brief Get security type from the from peer.
635  * @details
636  * This function gets the Security information from the peer handler.
637  * The security information is got from the rx descriptor and filled in
638  * to the peer handler.
639  *
640  * @param soc - pointer to the soc
641  * @param peer - peer handler
642  * @param sec_idx - mcast or ucast frame type.
643  * @return - int
644  */
645 static inline int
646 cdp_get_sec_type(ol_txrx_soc_handle soc, struct cdp_peer *peer, uint8_t sec_idx)
647 {
648 	if (!soc || !soc->ops) {
649 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
650 			"%s invalid instance", __func__);
651 		QDF_BUG(0);
652 		return A_ERROR;
653 	}
654 
655 	if (!soc->ops->ctrl_ops ||
656 	    !soc->ops->ctrl_ops->txrx_get_sec_type)
657 		return A_ERROR;
658 
659 	return soc->ops->ctrl_ops->txrx_get_sec_type
660 			(peer, sec_idx);
661 }
662 
663 /**
664   * cdp_set_mgmt_tx_power(): function to set tx power for mgmt frames
665   * @vdev_handle: vdev handle
666   * @subtype_index: subtype
667   * @tx_power: Tx power
668   * Return: None
669   */
670 static inline int cdp_set_mgmt_tx_power(ol_txrx_soc_handle soc,
671 	struct cdp_vdev *vdev, uint8_t subtype, uint8_t tx_power)
672 {
673 	if (!soc || !soc->ops) {
674 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
675 				"%s: Invalid Instance:", __func__);
676 		QDF_BUG(0);
677 		return 0;
678 	}
679 
680 	if (!soc->ops->ctrl_ops ||
681 	    !soc->ops->ctrl_ops->txrx_update_mgmt_txpow_vdev)
682 		return 0;
683 
684 	soc->ops->ctrl_ops->txrx_update_mgmt_txpow_vdev(vdev,
685 							subtype, tx_power);
686 	return 0;
687 }
688 
689 static inline void *
690 cdp_get_pldev(ol_txrx_soc_handle soc,
691 		struct cdp_pdev *pdev)
692 {
693 	if (!soc || !soc->ops) {
694 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
695 			"%s invalid instance", __func__);
696 		QDF_BUG(0);
697 		return NULL;
698 	}
699 
700 	if (!soc->ops->ctrl_ops || !soc->ops->ctrl_ops->txrx_get_pldev)
701 		return NULL;
702 
703 	return soc->ops->ctrl_ops->txrx_get_pldev(pdev);
704 }
705 
706 #ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
707 /**
708  * cdp_update_pdev_rx_protocol_tag() - wrapper function to set the protocol
709  *                                    tag in CDP layer from cfg layer
710  * @soc: SOC TXRX handle
711  * @pdev: CDP pdev pointer
712  * @protocol_mask: Bitmap for protocol for which tagging is enabled
713  * @protocol_type: Protocol type for which the tag should be update
714  * @tag: Actual tag value for the given prototype
715  * Return: Returns QDF_STATUS_SUCCESS/FAILURE
716  */
717 static inline QDF_STATUS
718 cdp_update_pdev_rx_protocol_tag(ol_txrx_soc_handle soc,
719 				struct cdp_pdev *pdev, uint32_t protocol_mask,
720 				uint16_t protocol_type, uint16_t tag)
721 {
722 	if (!soc || !soc->ops) {
723 		dp_err("Invalid SOC instance");
724 		QDF_BUG(0);
725 		return QDF_STATUS_E_FAILURE;
726 	}
727 
728 	if (!soc->ops->ctrl_ops ||
729 	    !soc->ops->ctrl_ops->txrx_update_pdev_rx_protocol_tag)
730 		return QDF_STATUS_E_FAILURE;
731 
732 	return soc->ops->ctrl_ops->txrx_update_pdev_rx_protocol_tag
733 			(pdev, protocol_mask, protocol_type, tag);
734 }
735 
736 #ifdef WLAN_SUPPORT_RX_TAG_STATISTICS
737 /**
738  * cdp_dump_pdev_rx_protocol_tag_stats() - wrapper function to dump the protocol
739 				tag statistics for given or all protocols
740  * @soc: SOC TXRX handle
741  * @pdev: CDP pdev pointer
742  * @protocol_type: Protocol type for which the tag should be update
743  * Return: Returns QDF_STATUS_SUCCESS/FAILURE
744  */
745 static inline QDF_STATUS
746 cdp_dump_pdev_rx_protocol_tag_stats(ol_txrx_soc_handle soc,
747 				    struct cdp_pdev *pdev,
748 				    uint16_t protocol_type)
749 {
750 	if (!soc || !soc->ops) {
751 		dp_err("Invalid SOC instance");
752 		QDF_BUG(0);
753 		return QDF_STATUS_E_FAILURE;
754 	}
755 
756 	if (!soc->ops->ctrl_ops ||
757 	    !soc->ops->ctrl_ops->txrx_dump_pdev_rx_protocol_tag_stats)
758 		return QDF_STATUS_E_FAILURE;
759 
760 	soc->ops->ctrl_ops->txrx_dump_pdev_rx_protocol_tag_stats(pdev,
761 						protocol_type);
762 	return QDF_STATUS_SUCCESS;
763 }
764 #endif /* WLAN_SUPPORT_RX_TAG_STATISTICS */
765 #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
766 
767 #ifdef ATH_SUPPORT_NAC_RSSI
768 /**
769   * cdp_vdev_config_for_nac_rssi(): To invoke dp callback for nac rssi config
770   * @soc: soc pointer
771   * @vdev: vdev pointer
772   * @nac_cmd: specfies nac_rss config action add, del, list
773   * @bssid: Neighbour bssid
774   * @client_macaddr: Non-Associated client MAC
775   * @chan_num: channel number to scan
776   *
777   * Return: QDF_STATUS
778   */
779 static inline QDF_STATUS cdp_vdev_config_for_nac_rssi(ol_txrx_soc_handle soc,
780 		struct cdp_vdev *vdev, enum cdp_nac_param_cmd nac_cmd,
781 		char *bssid, char *client_macaddr, uint8_t chan_num)
782 {
783 	if (!soc || !soc->ops) {
784 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
785 			"%s invalid instance", __func__);
786 		QDF_BUG(0);
787 		return QDF_STATUS_E_FAILURE;
788 	}
789 
790 	if (!soc->ops->ctrl_ops ||
791 			!soc->ops->ctrl_ops->txrx_vdev_config_for_nac_rssi)
792 		return QDF_STATUS_E_FAILURE;
793 
794 	return soc->ops->ctrl_ops->txrx_vdev_config_for_nac_rssi(vdev,
795 			nac_cmd, bssid, client_macaddr, chan_num);
796 }
797 
798 /*
799  * cdp_vdev_get_neighbour_rssi(): To invoke dp callback to get rssi value of nac
800  * @soc: soc pointer
801  * @vdev: vdev pointer
802  * @macaddr: Non-Associated client MAC
803  * @rssi: rssi
804  *
805  * Return: QDF_STATUS
806  */
807 static inline QDF_STATUS cdp_vdev_get_neighbour_rssi(ol_txrx_soc_handle soc,
808 						     struct cdp_vdev *vdev,
809 						     char *macaddr,
810 						     uint8_t *rssi)
811 {
812 	if (!soc || !soc->ops) {
813 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
814 			  "%s invalid instance", __func__);
815 		QDF_BUG(0);
816 		return QDF_STATUS_E_FAILURE;
817 	}
818 
819 	if (!soc->ops->ctrl_ops ||
820 	    !soc->ops->ctrl_ops->txrx_vdev_get_neighbour_rssi)
821 		return QDF_STATUS_E_FAILURE;
822 
823 	return soc->ops->ctrl_ops->txrx_vdev_get_neighbour_rssi(vdev, macaddr,
824 								rssi);
825 }
826 #endif
827 #endif
828