1 /*
2 * Copyright (c) 2012-2014, 2017-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 #ifndef _WDI_EVENT_API_H_
20 #define _WDI_EVENT_API_H_
21
22 #include "wdi_event.h"
23 #include <cdp_txrx_handle.h>
24 #include <cdp_txrx_cmn_struct.h>
25 struct ol_txrx_pdev_t;
26
27 #ifdef WDI_EVENT_ENABLE
28 /**
29 * @brief Subscribe to a specified WDI event.
30 * @details
31 * This function adds the provided wdi_event_subscribe object to a list of
32 * subscribers for the specified WDI event.
33 * When the event in question happens, each subscriber for the event will
34 * have their callback function invoked.
35 * The order in which callback functions from multiple subscribers are
36 * invoked is unspecified.
37 *
38 * @param soc_hdl - datapath soc handle
39 * @param pdev_id - physical device instance id
40 * @param event_cb_sub - the callback and context for the event subscriber
41 * @param event - which event's notifications are being subscribed to
42 * @return error code, or 0 for success
43 */
44 int wdi_event_sub(struct cdp_soc_t *soc, uint8_t pdev_id,
45 wdi_event_subscribe *event_cb_sub, uint32_t event);
46
47 /**
48 * @brief Unsubscribe from a specified WDI event.
49 * @details
50 * This function removes the provided event subscription object from the
51 * list of subscribers for its event.
52 * This function shall only be called if there was a successful prior call
53 * to event_sub() on the same wdi_event_subscribe object.
54 *
55 * @param soc_hdl - datapath soc handle
56 * @param pdev_id - physical device instance id
57 * @param event_cb_sub - the event subscription object
58 * @param event - which event is being unsubscribed
59 * @return error code, or 0 for success
60 */
61 int wdi_event_unsub(struct cdp_soc_t *soc, uint8_t pdev_id,
62 wdi_event_subscribe *event_cb_sub, uint32_t event);
63
64
65 void wdi_event_handler(enum WDI_EVENT event,
66 uint8_t pdev_id, void *data);
67 A_STATUS wdi_event_attach(struct ol_txrx_pdev_t *txrx_pdev);
68 A_STATUS wdi_event_detach(struct ol_txrx_pdev_t *txrx_pdev);
69
70 #else
71
wdi_event_handler(enum WDI_EVENT event,uint8_t pdev_id,void * data)72 static inline void wdi_event_handler(enum WDI_EVENT event,
73 uint8_t pdev_id, void *data)
74 {
75 }
76
wdi_event_attach(struct ol_txrx_pdev_t * txrx_pdev)77 static inline A_STATUS wdi_event_attach(struct ol_txrx_pdev_t *txrx_pdev)
78 {
79 return A_OK;
80 }
81
wdi_event_detach(struct ol_txrx_pdev_t * txrx_pdev)82 static inline A_STATUS wdi_event_detach(struct ol_txrx_pdev_t *txrx_pdev)
83 {
84 return A_OK;
85 }
86
wdi_event_sub(struct cdp_soc_t * soc,uint8_t pdev_id,wdi_event_subscribe * event_cb_sub,uint32_t event)87 static inline int wdi_event_sub(struct cdp_soc_t *soc, uint8_t pdev_id,
88 wdi_event_subscribe *event_cb_sub,
89 uint32_t event)
90 {
91 return 0;
92 }
93
wdi_event_unsub(struct cdp_soc_t * soc,uint8_t pdev_id,wdi_event_subscribe * event_cb_sub,uint32_t event)94 static inline int wdi_event_unsub(struct cdp_soc_t *soc, uint8_t pdev_id,
95 wdi_event_subscribe *event_cb_sub,
96 uint32_t event)
97 {
98 return 0;
99 }
100 #endif /* WDI_EVENT_ENABLE */
101
102 #endif /* _WDI_EVENT_API_H_ */
103