xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_ctrl.h (revision 3149adf58a329e17232a4c0e58d460d025edd55a)
1 /*
2  * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
3  *
4  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5  *
6  *
7  * Permission to use, copy, modify, and/or distribute this software for
8  * any purpose with or without fee is hereby granted, provided that the
9  * above copyright notice and this permission notice appear in all
10  * copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19  * PERFORMANCE OF THIS SOFTWARE.
20  */
21 
22 /*
23  * This file was originally distributed by Qualcomm Atheros, Inc.
24  * under proprietary terms before Copyright ownership was assigned
25  * to the Linux Foundation.
26  */
27 /**
28  * @file cdp_txrx_ctrl.h
29  * @brief Define the host data path control API functions
30  * called by the host control SW and the OS interface module
31  */
32 
33 #ifndef _CDP_TXRX_CTRL_H_
34 #define _CDP_TXRX_CTRL_H_
35 #include "cdp_txrx_handle.h"
36 #include "cdp_txrx_cmn_struct.h"
37 #include "cdp_txrx_ops.h"
38 
39 static inline int cdp_is_target_ar900b
40 	(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
41 {
42 	if (!soc || !soc->ops) {
43 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
44 				"%s: Invalid Instance:", __func__);
45 		QDF_BUG(0);
46 		return 0;
47 	}
48 
49 	if (!soc->ops->ctrl_ops ||
50 	    !soc->ops->ctrl_ops->txrx_is_target_ar900b)
51 		return 0;
52 
53 	return soc->ops->ctrl_ops->txrx_is_target_ar900b(vdev);
54 }
55 
56 
57 /* WIN */
58 static inline int
59 cdp_mempools_attach(ol_txrx_soc_handle soc, void *ctrl_pdev)
60 {
61 	if (!soc || !soc->ops) {
62 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
63 				"%s: Invalid Instance:", __func__);
64 		QDF_BUG(0);
65 		return 0;
66 	}
67 
68 	if (!soc->ops->ctrl_ops ||
69 	    !soc->ops->ctrl_ops->txrx_mempools_attach)
70 		return 0;
71 
72 	return soc->ops->ctrl_ops->txrx_mempools_attach(ctrl_pdev);
73 }
74 
75 /**
76  * @brief set filter neighbour peers
77  * @details
78  *  This defines interface function to set neighbour peer filtering.
79  *
80  * @param soc - the pointer to soc object
81  * @param pdev - the pointer physical device object
82  * @param val - the enable/disable value
83  * @return - int
84  */
85 static inline int
86 cdp_set_filter_neighbour_peers(ol_txrx_soc_handle soc,
87 	struct cdp_pdev *pdev, u_int32_t val)
88 {
89 	if (!soc || !soc->ops) {
90 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
91 				"%s: Invalid Instance:", __func__);
92 		QDF_BUG(0);
93 		return 0;
94 	}
95 
96 	if (!soc->ops->ctrl_ops ||
97 	    !soc->ops->ctrl_ops->txrx_set_filter_neighbour_peers)
98 		return 0;
99 
100 	return soc->ops->ctrl_ops->txrx_set_filter_neighbour_peers
101 			(pdev, val);
102 }
103 
104 /**
105  * @brief update the neighbour peer addresses
106  * @details
107  *  This defines interface function to update neighbour peers addresses
108  *  which needs to be filtered
109  *
110  * @param soc - the pointer to soc object
111  * @param pdev - the pointer to physical device object
112  * @param cmd - add/del entry into peer table
113  * @param macaddr - the address of neighbour peer
114  * @return - int
115  */
116 static inline int
117 cdp_update_filter_neighbour_peers(ol_txrx_soc_handle soc,
118 	struct cdp_pdev *pdev, uint32_t cmd, uint8_t *macaddr)
119 {
120 	if (!soc || !soc->ops) {
121 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
122 				"%s: Invalid Instance:", __func__);
123 		QDF_BUG(0);
124 		return 0;
125 	}
126 
127 	if (!soc->ops->ctrl_ops ||
128 	    !soc->ops->ctrl_ops->txrx_update_filter_neighbour_peers)
129 		return 0;
130 
131 	return soc->ops->ctrl_ops->txrx_update_filter_neighbour_peers
132 			(pdev, cmd, macaddr);
133 }
134 
135 /**
136  * @brief set the safemode of the device
137  * @details
138  *  This flag is used to bypass the encrypt and decrypt processes when send and
139  *  receive packets. It works like open AUTH mode, HW will treate all packets
140  *  as non-encrypt frames because no key installed. For rx fragmented frames,
141  *  it bypasses all the rx defragmentaion.
142  *
143  * @param vdev - the data virtual device object
144  * @param val - the safemode state
145  * @return - void
146  */
147 static inline void
148 cdp_set_safemode(ol_txrx_soc_handle soc,
149 	struct cdp_vdev *vdev, u_int32_t val)
150 {
151 	if (!soc || !soc->ops) {
152 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
153 				"%s: Invalid Instance:", __func__);
154 		QDF_BUG(0);
155 		return;
156 	}
157 
158 	if (!soc->ops->ctrl_ops ||
159 	    !soc->ops->ctrl_ops->txrx_set_safemode)
160 		return;
161 
162 	soc->ops->ctrl_ops->txrx_set_safemode(vdev, val);
163 }
164 /**
165  * @brief configure the drop unencrypted frame flag
166  * @details
167  *  Rx related. When set this flag, all the unencrypted frames
168  *  received over a secure connection will be discarded
169  *
170  * @param vdev - the data virtual device object
171  * @param val - flag
172  * @return - void
173  */
174 static inline void
175 cdp_set_drop_unenc(ol_txrx_soc_handle soc,
176 	struct cdp_vdev *vdev, u_int32_t val)
177 {
178 	if (!soc || !soc->ops) {
179 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
180 				"%s: Invalid Instance:", __func__);
181 		QDF_BUG(0);
182 		return;
183 	}
184 
185 	if (!soc->ops->ctrl_ops ||
186 	    !soc->ops->ctrl_ops->txrx_set_drop_unenc)
187 		return;
188 
189 	soc->ops->ctrl_ops->txrx_set_drop_unenc(vdev, val);
190 }
191 
192 
193 /**
194  * @brief set the Tx encapsulation type of the VDEV
195  * @details
196  *  This will be used to populate the HTT desc packet type field during Tx
197  *
198  * @param vdev - the data virtual device object
199  * @param val - the Tx encap type (htt_cmn_pkt_type)
200  * @return - void
201  */
202 static inline void
203 cdp_set_tx_encap_type(ol_txrx_soc_handle soc,
204 	struct cdp_vdev *vdev, enum htt_cmn_pkt_type val)
205 {
206 	if (!soc || !soc->ops) {
207 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
208 				"%s: Invalid Instance:", __func__);
209 		QDF_BUG(0);
210 		return;
211 	}
212 
213 	if (!soc->ops->ctrl_ops ||
214 	    !soc->ops->ctrl_ops->txrx_set_tx_encap_type)
215 		return;
216 
217 	soc->ops->ctrl_ops->txrx_set_tx_encap_type(vdev, val);
218 }
219 
220 /**
221  * @brief set the Rx decapsulation type of the VDEV
222  * @details
223  *  This will be used to configure into firmware and hardware which format to
224  *  decap all Rx packets into, for all peers under the VDEV.
225  *
226  * @param vdev - the data virtual device object
227  * @param val - the Rx decap mode (htt_cmn_pkt_type)
228  * @return - void
229  */
230 static inline void
231 cdp_set_vdev_rx_decap_type(ol_txrx_soc_handle soc,
232 	struct cdp_vdev *vdev, enum htt_cmn_pkt_type val)
233 {
234 	if (!soc || !soc->ops) {
235 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
236 				"%s: Invalid Instance:", __func__);
237 		QDF_BUG(0);
238 		return;
239 	}
240 
241 	if (!soc->ops->ctrl_ops ||
242 	    !soc->ops->ctrl_ops->txrx_set_vdev_rx_decap_type)
243 		return;
244 
245 	soc->ops->ctrl_ops->txrx_set_vdev_rx_decap_type
246 			(vdev, val);
247 }
248 
249 /**
250  * @brief get the Rx decapsulation type of the VDEV
251  *
252  * @param vdev - the data virtual device object
253  * @return - the Rx decap type (htt_cmn_pkt_type)
254  */
255 static inline enum htt_cmn_pkt_type
256 cdp_get_vdev_rx_decap_type(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
257 {
258 	if (!soc || !soc->ops) {
259 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
260 				"%s: Invalid Instance:", __func__);
261 		QDF_BUG(0);
262 		return 0;
263 	}
264 
265 	if (!soc->ops->ctrl_ops ||
266 	    !soc->ops->ctrl_ops->txrx_get_vdev_rx_decap_type)
267 		return 0;
268 
269 	return soc->ops->ctrl_ops->txrx_get_vdev_rx_decap_type(vdev);
270 }
271 
272 /**
273  * @brief set the Reo Destination ring for the pdev
274  * @details
275  *  This will be used to configure the Reo Destination ring for this pdev.
276  *
277  * @param soc - pointer to the soc
278  * @param pdev - the data physical device object
279  * @param val - the Reo destination ring index (1 to 4)
280  * @return - void
281  */
282 static inline void
283 cdp_set_pdev_reo_dest(ol_txrx_soc_handle soc,
284 	struct cdp_pdev *pdev, enum cdp_host_reo_dest_ring val)
285 {
286 	if (!soc || !soc->ops) {
287 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
288 				"%s: Invalid Instance:", __func__);
289 		QDF_BUG(0);
290 		return;
291 	}
292 
293 	if (!soc->ops->ctrl_ops ||
294 	    !soc->ops->ctrl_ops->txrx_set_pdev_reo_dest)
295 		return;
296 
297 	soc->ops->ctrl_ops->txrx_set_pdev_reo_dest
298 			(pdev, val);
299 }
300 
301 /**
302  * @brief get the Reo Destination ring for the pdev
303  *
304  * @param soc - pointer to the soc
305  * @param pdev - the data physical device object
306  * @return - the Reo destination ring index (1 to 4), 0 if not supported.
307  */
308 static inline enum cdp_host_reo_dest_ring
309 cdp_get_pdev_reo_dest(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
310 {
311 	if (!soc || !soc->ops) {
312 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
313 				"%s: Invalid Instance:", __func__);
314 		QDF_BUG(0);
315 		return cdp_host_reo_dest_ring_unknown;
316 	}
317 
318 	if (!soc->ops->ctrl_ops ||
319 	    !soc->ops->ctrl_ops->txrx_get_pdev_reo_dest)
320 		return cdp_host_reo_dest_ring_unknown;
321 
322 	return soc->ops->ctrl_ops->txrx_get_pdev_reo_dest(pdev);
323 }
324 
325 /* Is this similar to ol_txrx_peer_state_update() in MCL */
326 /**
327  * @brief Update the authorize peer object at association time
328  * @details
329  *  For the host-based implementation of rate-control, it
330  *  updates the peer/node-related parameters within rate-control
331  *  context of the peer at association.
332  *
333  * @param peer - pointer to the node's object
334  * @authorize - either to authorize or unauthorize peer
335  *
336  * @return none
337  */
338 static inline void
339 cdp_peer_authorize(ol_txrx_soc_handle soc,
340 	struct cdp_peer *peer, u_int32_t authorize)
341 {
342 	if (!soc || !soc->ops) {
343 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
344 				"%s: Invalid Instance:", __func__);
345 		QDF_BUG(0);
346 		return;
347 	}
348 
349 	if (!soc->ops->ctrl_ops ||
350 	    !soc->ops->ctrl_ops->txrx_peer_authorize)
351 		return;
352 
353 	soc->ops->ctrl_ops->txrx_peer_authorize
354 			(peer, authorize);
355 }
356 
357 static inline bool
358 cdp_set_inact_params(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
359 			u_int16_t inact_check_interval,
360 			u_int16_t inact_normal,
361 			u_int16_t inact_overload)
362 {
363 	if (!soc || !pdev || !soc->ops) {
364 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
365 				"%s: Invalid Instance:", __func__);
366 		QDF_BUG(0);
367 		return false;
368 	}
369 
370 	if (!soc->ops->ctrl_ops ||
371 	    !soc->ops->ctrl_ops->txrx_set_inact_params)
372 		return false;
373 
374 	return soc->ops->ctrl_ops->txrx_set_inact_params
375 			(pdev, inact_check_interval, inact_normal,
376 			inact_overload);
377 }
378 
379 static inline bool
380 cdp_start_inact_timer(ol_txrx_soc_handle soc,
381 	struct cdp_pdev *pdev,
382 	bool enable)
383 {
384 	if (!soc || !pdev || !soc->ops) {
385 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
386 				"%s: Invalid Instance:", __func__);
387 		QDF_BUG(0);
388 		return false;
389 	}
390 
391 	if (!soc->ops->ctrl_ops ||
392 	    !soc->ops->ctrl_ops->txrx_start_inact_timer)
393 		return false;
394 
395 	return soc->ops->ctrl_ops->txrx_start_inact_timer
396 			(pdev, enable);
397 }
398 
399 /**
400  * @brief Set the overload status of the radio
401  * @details
402  *   Set the overload status of the radio, updating the inactivity
403  *   threshold and inactivity count for each node.
404  *
405  * @param pdev - the data physical device object
406  * @param overload - whether the radio is overloaded or not
407  */
408 static inline void
409 cdp_set_overload(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
410 	bool overload)
411 {
412 	if (!soc || !pdev || !soc->ops) {
413 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
414 				"%s: Invalid Instance:", __func__);
415 		QDF_BUG(0);
416 		return;
417 	}
418 
419 	if (!soc->ops->ctrl_ops ||
420 	    !soc->ops->ctrl_ops->txrx_set_overload)
421 		return;
422 
423 	soc->ops->ctrl_ops->txrx_set_overload(pdev, overload);
424 }
425 
426 /**
427  * @brief Check the inactivity status of the peer/node
428  *
429  * @param peer - pointer to the node's object
430  * @return true if the node is inactive; otherwise return false
431  */
432 static inline bool
433 cdp_peer_is_inact(ol_txrx_soc_handle soc, void *peer)
434 {
435 	if (!soc || !peer || !soc->ops) {
436 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
437 				"%s: Invalid Instance:", __func__);
438 		QDF_BUG(0);
439 		return false;
440 	}
441 
442 	if (!soc->ops->ctrl_ops ||
443 	    !soc->ops->ctrl_ops->txrx_peer_is_inact)
444 		return false;
445 
446 	return soc->ops->ctrl_ops->txrx_peer_is_inact(peer);
447 }
448 
449 /**
450  * @brief Mark inactivity status of the peer/node
451  * @details
452  *   If it becomes active, reset inactivity count to reload value;
453  *   if the inactivity status changed, notify umac band steering.
454  *
455  * @param peer - pointer to the node's object
456  * @param inactive - whether the node is inactive or not
457  */
458 static inline void
459 cdp_mark_peer_inact(ol_txrx_soc_handle soc,
460 	void *peer,
461 	bool inactive)
462 {
463 	if (!soc || !soc->ops) {
464 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
465 				"%s: Invalid Instance:", __func__);
466 		QDF_BUG(0);
467 		return;
468 	}
469 
470 	if (!soc->ops->ctrl_ops ||
471 	    !soc->ops->ctrl_ops->txrx_mark_peer_inact)
472 		return;
473 
474 	soc->ops->ctrl_ops->txrx_mark_peer_inact
475 			(peer, inactive);
476 }
477 
478 
479 /* Should be ol_txrx_ctrl_api.h */
480 static inline void cdp_set_mesh_mode
481 (ol_txrx_soc_handle soc, struct cdp_vdev *vdev, u_int32_t val)
482 {
483 	if (!soc || !soc->ops) {
484 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
485 				"%s: Invalid Instance:", __func__);
486 		QDF_BUG(0);
487 		return;
488 	}
489 
490 	if (!soc->ops->ctrl_ops ||
491 	    !soc->ops->ctrl_ops->txrx_set_mesh_mode)
492 		return;
493 
494 	soc->ops->ctrl_ops->txrx_set_mesh_mode(vdev, val);
495 }
496 
497 /**
498  * @brief set mesh rx filter
499  * @details based on the bits enabled in the filter packets has to be dropped.
500  *
501  * @param soc - pointer to the soc
502  * @param vdev - the data virtual device object
503  * @param val - value to be set
504  * @return - void
505  */
506 static inline
507 void cdp_set_mesh_rx_filter(ol_txrx_soc_handle soc,
508 				struct cdp_vdev *vdev, uint32_t val)
509 {
510 	if (!soc || !soc->ops) {
511 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
512 				"%s: Invalid Instance:", __func__);
513 		QDF_BUG(0);
514 		return;
515 	}
516 
517 	if (!soc->ops->ctrl_ops ||
518 	    !soc->ops->ctrl_ops->txrx_set_mesh_rx_filter)
519 		return;
520 
521 	soc->ops->ctrl_ops->txrx_set_mesh_rx_filter(vdev, val);
522 }
523 
524 static inline void cdp_tx_flush_buffers
525 (ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
526 {
527 	if (!soc || !soc->ops) {
528 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
529 				"%s: Invalid Instance:", __func__);
530 		QDF_BUG(0);
531 		return;
532 	}
533 
534 	if (!soc->ops->ctrl_ops ||
535 	    !soc->ops->ctrl_ops->tx_flush_buffers)
536 		return;
537 
538 	soc->ops->ctrl_ops->tx_flush_buffers(vdev);
539 }
540 
541 static inline void cdp_txrx_set_vdev_param(ol_txrx_soc_handle soc,
542 		struct cdp_vdev *vdev, enum cdp_vdev_param_type type,
543 		uint32_t val)
544 {
545 	if (!soc || !soc->ops) {
546 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
547 				"%s: Invalid Instance:", __func__);
548 		QDF_BUG(0);
549 		return;
550 	}
551 
552 	if (!soc->ops->ctrl_ops ||
553 	    !soc->ops->ctrl_ops->txrx_set_vdev_param)
554 		return;
555 
556 	soc->ops->ctrl_ops->txrx_set_vdev_param(vdev, type, val);
557 }
558 
559 static inline void
560 cdp_peer_set_nawds(ol_txrx_soc_handle soc,
561 		struct cdp_peer *peer, uint8_t value)
562 {
563 	if (!soc || !soc->ops) {
564 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
565 				"%s: Invalid Instance:", __func__);
566 		QDF_BUG(0);
567 		return;
568 	}
569 
570 	if (!soc->ops->ctrl_ops ||
571 	    !soc->ops->ctrl_ops->txrx_peer_set_nawds)
572 		return;
573 
574 	soc->ops->ctrl_ops->txrx_peer_set_nawds
575 			(peer, value);
576 }
577 
578 static inline void cdp_txrx_set_pdev_param(ol_txrx_soc_handle soc,
579 		struct cdp_pdev *pdev, enum cdp_pdev_param_type type,
580 		uint8_t val)
581 {
582 	if (!soc || !soc->ops) {
583 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
584 				"%s: Invalid Instance:", __func__);
585 		QDF_BUG(0);
586 		return;
587 	}
588 
589 	if (!soc->ops->ctrl_ops ||
590 	    !soc->ops->ctrl_ops->txrx_set_pdev_param)
591 		return;
592 
593 	soc->ops->ctrl_ops->txrx_set_pdev_param
594 			(pdev, type, val);
595 }
596 
597 /**
598  * @brief Subscribe to a specified WDI event.
599  * @details
600  *  This function adds the provided wdi_event_subscribe object to a list of
601  *  subscribers for the specified WDI event.
602  *  When the event in question happens, each subscriber for the event will
603  *  have their callback function invoked.
604  *  The order in which callback functions from multiple subscribers are
605  *  invoked is unspecified.
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_sub(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_sub)
627 		return 0;
628 
629 	return soc->ops->ctrl_ops->txrx_wdi_event_sub
630 			(pdev, event_cb_sub, event);
631 }
632 
633 /**
634  * @brief Unsubscribe from a specified WDI event.
635  * @details
636  *  This function removes the provided event subscription object from the
637  *  list of subscribers for its event.
638  *  This function shall only be called if there was a successful prior call
639  *  to event_sub() on the same wdi_event_subscribe object.
640  *
641  * @param soc - pointer to the soc
642  * @param pdev - the data physical device object
643  * @param event_cb_sub - the callback and context for the event subscriber
644  * @param event - which event's notifications are being subscribed to
645  * @return - int
646  */
647 static inline int
648 cdp_wdi_event_unsub(ol_txrx_soc_handle soc,
649 		struct cdp_pdev *pdev, void *event_cb_sub, uint32_t event)
650 {
651 
652 	if (!soc || !soc->ops) {
653 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
654 			"%s invalid instance", __func__);
655 		QDF_BUG(0);
656 		return 0;
657 	}
658 
659 	if (!soc->ops->ctrl_ops ||
660 	    !soc->ops->ctrl_ops->txrx_wdi_event_unsub)
661 		return 0;
662 
663 	return soc->ops->ctrl_ops->txrx_wdi_event_unsub
664 			(pdev, event_cb_sub, event);
665 }
666 
667 /**
668  * @brief Get security type from the from peer.
669  * @details
670  * This function gets the Security information from the peer handler.
671  * The security information is got from the rx descriptor and filled in
672  * to the peer handler.
673  *
674  * @param soc - pointer to the soc
675  * @param peer - peer handler
676  * @param sec_idx - mcast or ucast frame type.
677  * @return - int
678  */
679 static inline int
680 cdp_get_sec_type(ol_txrx_soc_handle soc, struct cdp_peer *peer, uint8_t sec_idx)
681 {
682 	if (!soc || !soc->ops) {
683 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
684 			"%s invalid instance", __func__);
685 		QDF_BUG(0);
686 		return A_ERROR;
687 	}
688 
689 	if (!soc->ops->ctrl_ops ||
690 	    !soc->ops->ctrl_ops->txrx_get_sec_type)
691 		return A_ERROR;
692 
693 	return soc->ops->ctrl_ops->txrx_get_sec_type
694 			(peer, sec_idx);
695 }
696 
697 /**
698   * cdp_set_mgmt_tx_power(): function to set tx power for mgmt frames
699   * @vdev_handle: vdev handle
700   * @subtype_index: subtype
701   * @tx_power: Tx power
702   * Return: None
703   */
704 static inline int cdp_set_mgmt_tx_power(ol_txrx_soc_handle soc,
705 	struct cdp_vdev *vdev, uint8_t subtype, uint8_t tx_power)
706 {
707 	if (!soc || !soc->ops) {
708 		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
709 				"%s: Invalid Instance:", __func__);
710 		QDF_BUG(0);
711 		return 0;
712 	}
713 
714 	if (!soc->ops->ctrl_ops ||
715 	    !soc->ops->ctrl_ops->txrx_update_mgmt_txpow_vdev)
716 		return 0;
717 
718 	soc->ops->ctrl_ops->txrx_update_mgmt_txpow_vdev(vdev,
719 							subtype, tx_power);
720 	return 0;
721 }
722 
723 static inline void *
724 cdp_get_pldev(ol_txrx_soc_handle soc,
725 		struct cdp_pdev *pdev)
726 {
727 	if (!soc || !soc->ops) {
728 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
729 			"%s invalid instance", __func__);
730 		QDF_BUG(0);
731 		return NULL;
732 	}
733 
734 	if (!soc->ops->ctrl_ops || !soc->ops->ctrl_ops->txrx_get_pldev)
735 		return NULL;
736 
737 	return soc->ops->ctrl_ops->txrx_get_pldev(pdev);
738 }
739 
740 #ifdef ATH_SUPPORT_NAC_RSSI
741 /**
742   * cdp_vdev_config_for_nac_rssi(): To invoke dp callback for nac rssi config
743   * @soc: soc pointer
744   * @vdev: vdev pointer
745   * @nac_cmd: specfies nac_rss config action add, del, list
746   * @bssid: Neighbour bssid
747   * @client_macaddr: Non-Associated client MAC
748   * @chan_num: channel number to scan
749   *
750   * Return: QDF_STATUS
751   */
752 static inline QDF_STATUS cdp_vdev_config_for_nac_rssi(ol_txrx_soc_handle soc,
753 		struct cdp_vdev *vdev, enum cdp_nac_param_cmd nac_cmd,
754 		char *bssid, char *client_macaddr, uint8_t chan_num)
755 {
756 	if (!soc || !soc->ops) {
757 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
758 			"%s invalid instance", __func__);
759 		QDF_BUG(0);
760 		return QDF_STATUS_E_FAILURE;
761 	}
762 
763 	if (!soc->ops->ctrl_ops ||
764 			!soc->ops->ctrl_ops->txrx_vdev_config_for_nac_rssi)
765 		return QDF_STATUS_E_FAILURE;
766 
767 	return soc->ops->ctrl_ops->txrx_vdev_config_for_nac_rssi(vdev,
768 			nac_cmd, bssid, client_macaddr, chan_num);
769 }
770 #endif
771 #endif
772