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