1 /*
2  * Copyright 2022, Cypress Semiconductor Corporation (an Infineon company)
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /** @file
19  *  Header for Event detection
20  *
21  *  Provides constants and prototypes for functions that allow both
22  *  whd and user applications to receive event callbacks.
23  */
24 
25 #include "whd.h"
26 
27 #ifndef INCLUDED_WHD_EVENTS_INT_H
28 #define INCLUDED_WHD_EVENTS_INT_H
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34 
35 /******************************************************
36 * @cond       Typedefs
37 ******************************************************/
38 
39 /**
40  * Enumerated list of event types
41  */
42 typedef enum
43 {
44     WLC_E_NONE = 0x7FFFFFFE,
45     WLC_E_SET_SSID = 0 /** indicates status of set SSID */,
46     WLC_E_JOIN = 1,     /** differentiates join IBSS from found (WLC_E_START) IBSS */
47     WLC_E_START = 2,     /** STA founded an IBSS or AP started a BSS */
48     WLC_E_AUTH = 3,     /** 802.11 AUTH request */
49     WLC_E_AUTH_IND = 4,     /** 802.11 AUTH indication */
50     WLC_E_DEAUTH = 5,     /** 802.11 DEAUTH request */
51     WLC_E_DEAUTH_IND = 6,     /** 802.11 DEAUTH indication */
52     WLC_E_ASSOC = 7,     /** 802.11 ASSOC request */
53     WLC_E_ASSOC_IND = 8,     /** 802.11 ASSOC indication */
54     WLC_E_REASSOC = 9,     /** 802.11 REASSOC request */
55     WLC_E_REASSOC_IND = 10,     /** 802.11 REASSOC indication */
56     WLC_E_DISASSOC = 11,     /** 802.11 DISASSOC request */
57     WLC_E_DISASSOC_IND = 12,     /** 802.11 DISASSOC indication */
58     WLC_E_QUIET_START = 13,     /** 802.11h Quiet period started */
59     WLC_E_QUIET_END = 14,     /** 802.11h Quiet period ended */
60     WLC_E_BEACON_RX = 15,     /** BEACONS received/lost indication */
61     WLC_E_LINK = 16,     /** generic link indication */
62     WLC_E_MIC_ERROR = 17,     /** TKIP MIC error occurred */
63     WLC_E_NDIS_LINK = 18,     /** NDIS style link indication */
64     WLC_E_ROAM = 19,     /** roam attempt occurred: indicate status & reason */
65     WLC_E_TXFAIL = 20,     /** change in dot11FailedCount (txfail) */
66     WLC_E_PMKID_CACHE = 21,     /** WPA2 pmkid cache indication */
67     WLC_E_RETROGRADE_TSF = 22,     /** current AP's TSF value went backward */
68     WLC_E_PRUNE = 23,     /** AP was pruned from join list for reason */
69     WLC_E_AUTOAUTH = 24,     /** report AutoAuth table entry match for join attempt */
70     WLC_E_EAPOL_MSG = 25,     /** Event encapsulating an EAPOL message */
71     WLC_E_SCAN_COMPLETE = 26,     /** Scan results are ready or scan was aborted */
72     WLC_E_ADDTS_IND = 27,     /** indicate to host addts fail/success */
73     WLC_E_DELTS_IND = 28,     /** indicate to host delts fail/success */
74     WLC_E_BCNSENT_IND = 29,     /** indicate to host of beacon transmit */
75     WLC_E_BCNRX_MSG = 30,     /** Send the received beacon up to the host */
76     WLC_E_BCNLOST_MSG = 31,     /** indicate to host loss of beacon */
77     WLC_E_ROAM_PREP = 32,     /** before attempting to roam */
78     WLC_E_PFN_NET_FOUND = 33,     /** PFN network found event */
79     WLC_E_PFN_NET_LOST = 34,     /** PFN network lost event */
80     WLC_E_RESET_COMPLETE = 35, WLC_E_JOIN_START = 36, WLC_E_ROAM_START = 37, WLC_E_ASSOC_START = 38,
81     WLC_E_IBSS_ASSOC = 39, WLC_E_RADIO = 40, WLC_E_PSM_WATCHDOG = 41,                                                                                                      /** PSM microcode watchdog fired */
82     WLC_E_CCX_ASSOC_START = 42,     /** CCX association start */
83     WLC_E_CCX_ASSOC_ABORT = 43,     /** CCX association abort */
84     WLC_E_PROBREQ_MSG = 44,     /** probe request received */
85     WLC_E_SCAN_CONFIRM_IND = 45, WLC_E_PSK_SUP = 46,     /** WPA Handshake */
86     WLC_E_COUNTRY_CODE_CHANGED = 47, WLC_E_EXCEEDED_MEDIUM_TIME = 48,     /** WMMAC excedded medium time */
87     WLC_E_ICV_ERROR = 49,     /** WEP ICV error occurred */
88     WLC_E_UNICAST_DECODE_ERROR = 50,     /** Unsupported unicast encrypted frame */
89     WLC_E_MULTICAST_DECODE_ERROR = 51,     /** Unsupported multicast encrypted frame */
90     WLC_E_TRACE = 52, WLC_E_BTA_HCI_EVENT = 53,     /** BT-AMP HCI event */
91     WLC_E_IF = 54,     /** I/F change (for wlan host notification) */
92     WLC_E_P2P_DISC_LISTEN_COMPLETE = 55,     /** P2P Discovery listen state expires */
93     WLC_E_RSSI = 56,     /** indicate RSSI change based on configured levels */
94     WLC_E_PFN_BEST_BATCHING = 57,     /** PFN best network batching event */
95     WLC_E_EXTLOG_MSG = 58, WLC_E_ACTION_FRAME = 59,     /** Action frame reception */
96     WLC_E_ACTION_FRAME_COMPLETE = 60,     /** Action frame Tx complete */
97     WLC_E_PRE_ASSOC_IND = 61,     /** assoc request received */
98     WLC_E_PRE_REASSOC_IND = 62,     /** re-assoc request received */
99     WLC_E_CHANNEL_ADOPTED = 63,     /** channel adopted (xxx: obsoleted) */
100     WLC_E_AP_STARTED = 64,     /** AP started */
101     WLC_E_DFS_AP_STOP = 65,     /** AP stopped due to DFS */
102     WLC_E_DFS_AP_RESUME = 66,     /** AP resumed due to DFS */
103     WLC_E_WAI_STA_EVENT = 67,     /** WAI stations event */
104     WLC_E_WAI_MSG = 68,     /** event encapsulating an WAI message */
105     WLC_E_ESCAN_RESULT = 69,     /** escan result event */
106     WLC_E_ACTION_FRAME_OFF_CHAN_COMPLETE = 70,     /** action frame off channel complete *//* NOTE - This used to be WLC_E_WAKE_EVENT */
107     WLC_E_PROBRESP_MSG = 71,     /** probe response received */
108     WLC_E_P2P_PROBREQ_MSG = 72,     /** P2P Probe request received */
109     WLC_E_DCS_REQUEST = 73, WLC_E_FIFO_CREDIT_MAP = 74,     /** credits for D11 FIFOs. [AC0,AC1,AC2,AC3,BC_MC,ATIM] */
110     WLC_E_ACTION_FRAME_RX = 75,     /** Received action frame event WITH wl_event_rx_frame_data_t header */
111     WLC_E_WAKE_EVENT = 76,     /** Wake Event timer fired, used for wake WLAN test mode */
112     WLC_E_RM_COMPLETE = 77,     /** Radio measurement complete */
113     WLC_E_HTSFSYNC = 78,     /** Synchronize TSF with the host */
114     WLC_E_OVERLAY_REQ = 79,     /** request an overlay IOCTL/iovar from the host */
115     WLC_E_CSA_COMPLETE_IND = 80, WLC_E_EXCESS_PM_WAKE_EVENT = 81,     /** excess PM Wake Event to inform host  */
116     WLC_E_PFN_SCAN_NONE = 82,     /** no PFN networks around */
117     WLC_E_PFN_SCAN_ALLGONE = 83,     /** last found PFN network gets lost */
118     WLC_E_GTK_PLUMBED = 84, WLC_E_ASSOC_IND_NDIS = 85,     /** 802.11 ASSOC indication for NDIS only */
119     WLC_E_REASSOC_IND_NDIS = 86,     /** 802.11 REASSOC indication for NDIS only */
120     WLC_E_ASSOC_REQ_IE = 87, WLC_E_ASSOC_RESP_IE = 88, WLC_E_ASSOC_RECREATED = 89,     /** association recreated on resume */
121     WLC_E_ACTION_FRAME_RX_NDIS = 90,     /** rx action frame event for NDIS only */
122     WLC_E_AUTH_REQ = 91,     /** authentication request received */
123     WLC_E_TDLS_PEER_EVENT = 92,     /** discovered peer, connected/disconnected peer */
124     WLC_E_MESH_DHCP_SUCCESS = 92,     /** DHCP handshake successful for a mesh interface */
125     WLC_E_SPEEDY_RECREATE_FAIL = 93,     /** fast assoc recreation failed */
126     WLC_E_NATIVE = 94,     /** port-specific event and payload (e.g. NDIS) */
127     WLC_E_PKTDELAY_IND = 95,     /** event for tx pkt delay suddently jump */
128     WLC_E_AWDL_AW = 96,     /** AWDL AW period starts */
129     WLC_E_AWDL_ROLE = 97,     /** AWDL Master/Slave/NE master role event */
130     WLC_E_AWDL_EVENT = 98,     /** Generic AWDL event */
131     WLC_E_NIC_AF_TXS = 99,     /** NIC AF txstatus */
132     WLC_E_NAN = 100,     /** NAN event */
133     WLC_E_BEACON_FRAME_RX = 101, WLC_E_SERVICE_FOUND = 102,     /** desired service found */
134     WLC_E_GAS_FRAGMENT_RX = 103,     /** GAS fragment received */
135     WLC_E_GAS_COMPLETE = 104,     /** GAS sessions all complete */
136     WLC_E_P2PO_ADD_DEVICE = 105,     /** New device found by p2p offload */
137     WLC_E_P2PO_DEL_DEVICE = 106,     /** device has been removed by p2p offload */
138     WLC_E_WNM_STA_SLEEP = 107,     /** WNM event to notify STA enter sleep mode */
139     WLC_E_TXFAIL_THRESH = 108,     /** Indication of MAC tx failures (exhaustion of 802.11 retries) exceeding threshold(s) */
140     WLC_E_PROXD = 109,     /** Proximity Detection event */
141     WLC_E_IBSS_COALESCE = 110,     /** IBSS Coalescing */
142     WLC_E_MESH_PAIRED = 110,     /** Mesh peer found and paired */
143     WLC_E_AWDL_RX_PRB_RESP = 111,     /** AWDL RX Probe response */
144     WLC_E_AWDL_RX_ACT_FRAME = 112,     /** AWDL RX Action Frames */
145     WLC_E_AWDL_WOWL_NULLPKT = 113,     /** AWDL Wowl nulls */
146     WLC_E_AWDL_PHYCAL_STATUS = 114,     /** AWDL Phycal status */
147     WLC_E_AWDL_OOB_AF_STATUS = 115,     /** AWDL OOB AF status */
148     WLC_E_AWDL_SCAN_STATUS = 116,     /** Interleaved Scan status */
149     WLC_E_AWDL_AW_START = 117,     /** AWDL AW Start */
150     WLC_E_AWDL_AW_END = 118,     /** AWDL AW End */
151     WLC_E_AWDL_AW_EXT = 119,     /** AWDL AW Extensions */
152     WLC_E_AWDL_PEER_CACHE_CONTROL = 120, WLC_E_CSA_START_IND = 121, WLC_E_CSA_DONE_IND = 122,
153     WLC_E_CSA_FAILURE_IND = 123, WLC_E_CCA_CHAN_QUAL = 124,                                                                                               /** CCA based channel quality report */
154     WLC_E_BSSID = 125,     /** to report change in BSSID while roaming */
155     WLC_E_TX_STAT_ERROR = 126,     /** tx error indication */
156     WLC_E_BCMC_CREDIT_SUPPORT = 127,     /** credit check for BCMC supported */
157     WLC_E_PSTA_PRIMARY_INTF_IND = 128,     /** psta primary interface indication */
158     WLC_E_BT_WIFI_HANDOVER_REQ = 130,     /* Handover Request Initiated */
159     WLC_E_SPW_TXINHIBIT = 131,     /* Southpaw TxInhibit notification */
160     WLC_E_FBT_AUTH_REQ_IND = 132,     /* FBT Authentication Request Indication */
161     WLC_E_RSSI_LQM = 133,     /* Enhancement addition for WLC_E_RSSI */
162     WLC_E_PFN_GSCAN_FULL_RESULT = 134,     /* Full probe/beacon (IEs etc) results */
163     WLC_E_PFN_SWC = 135,     /* Significant change in rssi of bssids being tracked */
164     WLC_E_AUTHORIZED = 136,     /* a STA been authroized for traffic */
165     WLC_E_PROBREQ_MSG_RX = 137,     /* probe req with wl_event_rx_frame_data_t header */
166     WLC_E_PFN_SCAN_COMPLETE = 138,     /* PFN completed scan of network list */
167     WLC_E_RMC_EVENT = 139,     /* RMC Event */
168     WLC_E_DPSTA_INTF_IND = 140,      /* DPSTA interface indication */
169     WLC_E_RRM = 141,                 /* RRM Event */
170     WLC_E_ULP = 146,                 /* ULP entry event */
171     WLC_E_TKO = 151,                 /* TCP Keep Alive Offload Event */
172     WLC_E_EXT_AUTH_REQ = 187,        /* authentication request received */
173     WLC_E_EXT_AUTH_FRAME_RX = 188,   /* authentication request received */
174     WLC_E_MGMT_FRAME_TXSTATUS = 189, /* mgmt frame Tx complete */
175     WLC_E_LAST = 190,                /* highest val + 1 for range checking */
176 } whd_event_num_t;
177 
178 /**
179  * Enumerated list of error types
180  */
181 typedef enum
182 {
183     WLC_ERR_NONE = 0x00,
184     WLC_ERR_BUS  = 0x01,     /** indicates BUS got wrong */
185     WLC_ERR_FW   = 0x02,     /** FW halt or crash */
186 }  whd_error_num_t;
187 
188 #define WLC_SUP_STATUS_OFFSET      (256)
189 #define WLC_DOT11_SC_STATUS_OFFSET (512)
190 /**
191  * Enumerated list of event status codes
192  * @note : WLC_SUP values overlap other values, so it is necessary
193  *         to check the event type
194  */
195 typedef enum
196 {
197     WLC_E_STATUS_SUCCESS = 0,     /** operation was successful */
198     WLC_E_STATUS_FAIL = 1,     /** operation failed */
199     WLC_E_STATUS_TIMEOUT = 2,     /** operation timed out */
200     WLC_E_STATUS_NO_NETWORKS = 3,     /** failed due to no matching network found */
201     WLC_E_STATUS_ABORT = 4,     /** operation was aborted */
202     WLC_E_STATUS_NO_ACK = 5,     /** protocol failure: packet not ack'd */
203     WLC_E_STATUS_UNSOLICITED = 6,     /** AUTH or ASSOC packet was unsolicited */
204     WLC_E_STATUS_ATTEMPT = 7,     /** attempt to assoc to an auto auth configuration */
205     WLC_E_STATUS_PARTIAL = 8,     /** scan results are incomplete */
206     WLC_E_STATUS_NEWSCAN = 9,     /** scan aborted by another scan */
207     WLC_E_STATUS_NEWASSOC = 10,     /** scan aborted due to assoc in progress */
208     WLC_E_STATUS_11HQUIET = 11,     /** 802.11h quiet period started */
209     WLC_E_STATUS_SUPPRESS = 12,     /** user disabled scanning (WLC_SET_SCANSUPPRESS) */
210     WLC_E_STATUS_NOCHANS = 13,     /** no allowable channels to scan */
211     WLC_E_STATUS_CCXFASTRM = 14,     /** scan aborted due to CCX fast roam */
212     WLC_E_STATUS_CS_ABORT = 15,     /** abort channel select */
213 
214     /* for WLC_SUP messages */
215     WLC_SUP_DISCONNECTED = 0 + WLC_SUP_STATUS_OFFSET, WLC_SUP_CONNECTING = 1 + WLC_SUP_STATUS_OFFSET,
216     WLC_SUP_IDREQUIRED = 2 + WLC_SUP_STATUS_OFFSET, WLC_SUP_AUTHENTICATING = 3 + WLC_SUP_STATUS_OFFSET,
217     WLC_SUP_AUTHENTICATED = 4 + WLC_SUP_STATUS_OFFSET, WLC_SUP_KEYXCHANGE = 5 + WLC_SUP_STATUS_OFFSET,
218     WLC_SUP_KEYED = 6 + WLC_SUP_STATUS_OFFSET, WLC_SUP_TIMEOUT = 7 + WLC_SUP_STATUS_OFFSET,
219     WLC_SUP_LAST_BASIC_STATE = 8 + WLC_SUP_STATUS_OFFSET,
220     /* Extended supplicant authentication states */
221     WLC_SUP_KEYXCHANGE_WAIT_M1 = WLC_SUP_AUTHENTICATED,     /** Waiting   to receive handshake msg M1 */
222     WLC_SUP_KEYXCHANGE_PREP_M2 = WLC_SUP_KEYXCHANGE,     /** Preparing to send    handshake msg M2 */
223     WLC_SUP_KEYXCHANGE_WAIT_M3 = WLC_SUP_LAST_BASIC_STATE,     /** Waiting   to receive handshake msg M3 */
224     WLC_SUP_KEYXCHANGE_PREP_M4 = 9 + WLC_SUP_STATUS_OFFSET,     /** Preparing to send    handshake msg M4 */
225     WLC_SUP_KEYXCHANGE_WAIT_G1 = 10 + WLC_SUP_STATUS_OFFSET,     /** Waiting   to receive handshake msg G1 */
226     WLC_SUP_KEYXCHANGE_PREP_G2 = 11 + WLC_SUP_STATUS_OFFSET,     /** Preparing to send    handshake msg G2 */
227 
228     WLC_DOT11_SC_SUCCESS = 0 + WLC_DOT11_SC_STATUS_OFFSET,     /* Successful */
229     WLC_DOT11_SC_FAILURE = 1 + WLC_DOT11_SC_STATUS_OFFSET,     /* Unspecified failure */
230     WLC_DOT11_SC_CAP_MISMATCH = 10 + WLC_DOT11_SC_STATUS_OFFSET,     /* Cannot support all requested capabilities in the Capability Information field */
231     WLC_DOT11_SC_REASSOC_FAIL = 11 + WLC_DOT11_SC_STATUS_OFFSET,     /* Reassociation denied due to inability to confirm that association exists */
232     WLC_DOT11_SC_ASSOC_FAIL = 12 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied due to reason outside the scope of this standard */
233     WLC_DOT11_SC_AUTH_MISMATCH = 13 + WLC_DOT11_SC_STATUS_OFFSET,     /* Responding station does not support the specified authentication algorithm */
234     WLC_DOT11_SC_AUTH_SEQ = 14 + WLC_DOT11_SC_STATUS_OFFSET,     /* Received an Authentication frame with authentication transaction sequence number out of expected sequence */
235     WLC_DOT11_SC_AUTH_CHALLENGE_FAIL = 15 + WLC_DOT11_SC_STATUS_OFFSET,     /* Authentication rejected because of challenge failure */
236     WLC_DOT11_SC_AUTH_TIMEOUT = 16 + WLC_DOT11_SC_STATUS_OFFSET,     /* Authentication rejected due to timeout waiting for next frame in sequence */
237     WLC_DOT11_SC_ASSOC_BUSY_FAIL = 17 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied because AP is unable to handle additional associated stations */
238     WLC_DOT11_SC_ASSOC_RATE_MISMATCH = 18 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied due to requesting station not supporting all of the data rates in the BSSBasicRateSet parameter */
239     WLC_DOT11_SC_ASSOC_SHORT_REQUIRED = 19 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied due to requesting station not supporting the Short Preamble option */
240     WLC_DOT11_SC_ASSOC_PBCC_REQUIRED = 20 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied due to requesting  station not supporting the PBCC Modulation option */
241     WLC_DOT11_SC_ASSOC_AGILITY_REQUIRED = 21 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied due to requesting station not supporting the Channel Agility option */
242     WLC_DOT11_SC_ASSOC_SPECTRUM_REQUIRED = 22 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied because Spectrum Management capability is required. */
243     WLC_DOT11_SC_ASSOC_BAD_POWER_CAP = 23 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied because the info in the Power Cap element is unacceptable. */
244     WLC_DOT11_SC_ASSOC_BAD_SUP_CHANNELS = 24 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied because the info in the Supported Channel element is unacceptable */
245     WLC_DOT11_SC_ASSOC_SHORTSLOT_REQUIRED = 25 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied due to requesting station not supporting the Short Slot Time option */
246     WLC_DOT11_SC_ASSOC_ERPBCC_REQUIRED = 26 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied due to requesting station not supporting the ER-PBCC Modulation option */
247     WLC_DOT11_SC_ASSOC_DSSOFDM_REQUIRED = 27 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied due to requesting station not supporting the DSS-OFDM option */
248     WLC_DOT11_SC_DECLINED = 37 + WLC_DOT11_SC_STATUS_OFFSET,     /* request declined */
249     WLC_DOT11_SC_INVALID_PARAMS = 38 + WLC_DOT11_SC_STATUS_OFFSET,     /* One or more params have invalid values */
250     WLC_DOT11_SC_INVALID_AKMP = 43 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied due to invalid AKMP */
251     WLC_DOT11_SC_INVALID_MDID = 54 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied due to invalid MDID */
252     WLC_DOT11_SC_INVALID_FTIE = 55 + WLC_DOT11_SC_STATUS_OFFSET,     /* Association denied due to invalid FTIE */
253 
254     WLC_E_STATUS_FORCE_32_BIT = 0x7FFFFFFE     /** Force enum to be stored in 32 bit variable */
255 } whd_event_status_t;
256 
257 #define WLC_E_PRUNE_REASON_OFFSET    (256)
258 #define WLC_E_SUP_REASON_OFFSET      (512)
259 #define WLC_E_DOT11_RC_REASON_OFFSET (768)
260 
261 /**
262  * Enumerated list of event reason codes
263  * @note : Several values overlap other values, so it is necessary
264  *         to check the event type
265  */
266 typedef enum
267 {
268     /* roam reason codes */
269     WLC_E_REASON_INITIAL_ASSOC = 0,     /** initial assoc */
270     WLC_E_REASON_LOW_RSSI = 1,     /** roamed due to low RSSI */
271     WLC_E_REASON_DEAUTH = 2,     /** roamed due to DEAUTH indication */
272     WLC_E_REASON_DISASSOC = 3,     /** roamed due to DISASSOC indication */
273     WLC_E_REASON_BCNS_LOST = 4,     /** roamed due to lost beacons */
274     WLC_E_REASON_FAST_ROAM_FAILED = 5,     /** roamed due to fast roam failure */
275     WLC_E_REASON_DIRECTED_ROAM = 6,     /** roamed due to request by AP */
276     WLC_E_REASON_TSPEC_REJECTED = 7,     /** roamed due to TSPEC rejection */
277     WLC_E_REASON_BETTER_AP = 8,     /** roamed due to finding better AP */
278 
279     /* NAN sub-events comes as a reason code with event as WLC_E_NAN */
280     WLC_E_NAN_EVENT_STATUS_CHG = 9,     /* generated on any change in nan_mac status */
281     WLC_E_NAN_EVENT_MERGE = 10,     /* Merged to a NAN cluster */
282     WLC_E_NAN_EVENT_STOP = 11,     /* NAN stopped */
283     WLC_E_NAN_EVENT_P2P = 12,     /* NAN P2P EVENT */
284 
285     /* XXX: Dont use below four events: They will be cleanup, use WL_NAN_EVENT_POST_DISC */
286     WLC_E_NAN_EVENT_WINDOW_BEGIN_P2P = 13,     /* Event for begin of P2P further availability window */
287     WLC_E_NAN_EVENT_WINDOW_BEGIN_MESH = 14, WLC_E_NAN_EVENT_WINDOW_BEGIN_IBSS = 15,
288     WLC_E_NAN_EVENT_WINDOW_BEGIN_RANGING = 16, WLC_E_NAN_EVENT_POST_DISC = 17,                                                                                     /* Event for post discovery data */
289     WLC_E_NAN_EVENT_DATA_IF_ADD = 18,     /* Event for Data IF add */
290     WLC_E_NAN_EVENT_DATA_PEER_ADD = 19,     /* Event for peer add */
291 
292     /* nan 2.0 */
293     WLC_E_NAN_EVENT_DATA_IND = 20,     /* Data Indication to Host */
294     WLC_E_NAN_EVENT_DATA_CONF = 21,     /* Data Response to Host */
295     WLC_E_NAN_EVENT_SDF_RX = 22,     /* entire service discovery frame */
296     WLC_E_NAN_EVENT_DATA_END = 23, WLC_E_NAN_EVENT_BCN_RX = 24,     /* received beacon payload */
297 
298     /* prune reason codes */
299     WLC_E_PRUNE_ENCR_MISMATCH = 1 + WLC_E_PRUNE_REASON_OFFSET,     /** encryption mismatch */
300     WLC_E_PRUNE_BCAST_BSSID = 2 + WLC_E_PRUNE_REASON_OFFSET,     /** AP uses a broadcast BSSID */
301     WLC_E_PRUNE_MAC_DENY = 3 + WLC_E_PRUNE_REASON_OFFSET,     /** STA's MAC addr is in AP's MAC deny list */
302     WLC_E_PRUNE_MAC_NA = 4 + WLC_E_PRUNE_REASON_OFFSET,     /** STA's MAC addr is not in AP's MAC allow list */
303     WLC_E_PRUNE_REG_PASSV = 5 + WLC_E_PRUNE_REASON_OFFSET,     /** AP not allowed due to regulatory restriction */
304     WLC_E_PRUNE_SPCT_MGMT = 6 + WLC_E_PRUNE_REASON_OFFSET,     /** AP does not support STA locale spectrum mgmt */
305     WLC_E_PRUNE_RADAR = 7 + WLC_E_PRUNE_REASON_OFFSET,     /** AP is on a radar channel of STA locale */
306     WLC_E_RSN_MISMATCH = 8 + WLC_E_PRUNE_REASON_OFFSET,     /** STA does not support AP's RSN */
307     WLC_E_PRUNE_NO_COMMON_RATES = 9 + WLC_E_PRUNE_REASON_OFFSET,     /** No rates in common with AP */
308     WLC_E_PRUNE_BASIC_RATES = 10 + WLC_E_PRUNE_REASON_OFFSET,     /** STA does not support all basic rates of BSS */
309     WLC_E_PRUNE_CCXFAST_PREVAP = 11 + WLC_E_PRUNE_REASON_OFFSET,     /** CCX FAST ROAM: prune previous AP */
310     WLC_E_PRUNE_CIPHER_NA = 12 + WLC_E_PRUNE_REASON_OFFSET,     /** BSS's cipher not supported */
311     WLC_E_PRUNE_KNOWN_STA = 13 + WLC_E_PRUNE_REASON_OFFSET,     /** AP is already known to us as a STA */
312     WLC_E_PRUNE_CCXFAST_DROAM = 14 + WLC_E_PRUNE_REASON_OFFSET,     /** CCX FAST ROAM: prune unqualified AP */
313     WLC_E_PRUNE_WDS_PEER = 15 + WLC_E_PRUNE_REASON_OFFSET,     /** AP is already known to us as a WDS peer */
314     WLC_E_PRUNE_QBSS_LOAD = 16 + WLC_E_PRUNE_REASON_OFFSET,     /** QBSS LOAD - AAC is too low */
315     WLC_E_PRUNE_HOME_AP = 17 + WLC_E_PRUNE_REASON_OFFSET,     /** prune home AP */
316     WLC_E_PRUNE_AP_BLOCKED = 18 + WLC_E_PRUNE_REASON_OFFSET,     /** prune blocked AP */
317     WLC_E_PRUNE_NO_DIAG_SUPPORT = 19 + WLC_E_PRUNE_REASON_OFFSET,     /** prune due to diagnostic mode not supported */
318 
319     /* WPA failure reason codes carried in the WLC_E_PSK_SUP event */
320     WLC_E_SUP_OTHER = 0 + WLC_E_SUP_REASON_OFFSET,     /** Other reason */
321     WLC_E_SUP_DECRYPT_KEY_DATA = 1 + WLC_E_SUP_REASON_OFFSET,     /** Decryption of key data failed */
322     WLC_E_SUP_BAD_UCAST_WEP128 = 2 + WLC_E_SUP_REASON_OFFSET,     /** Illegal use of ucast WEP128 */
323     WLC_E_SUP_BAD_UCAST_WEP40 = 3 + WLC_E_SUP_REASON_OFFSET,     /** Illegal use of ucast WEP40 */
324     WLC_E_SUP_UNSUP_KEY_LEN = 4 + WLC_E_SUP_REASON_OFFSET,     /** Unsupported key length */
325     WLC_E_SUP_PW_KEY_CIPHER = 5 + WLC_E_SUP_REASON_OFFSET,     /** Unicast cipher mismatch in pairwise key */
326     WLC_E_SUP_MSG3_TOO_MANY_IE = 6 + WLC_E_SUP_REASON_OFFSET,     /** WPA IE contains > 1 RSN IE in key msg 3 */
327     WLC_E_SUP_MSG3_IE_MISMATCH = 7 + WLC_E_SUP_REASON_OFFSET,     /** WPA IE mismatch in key message 3 */
328     WLC_E_SUP_NO_INSTALL_FLAG = 8 + WLC_E_SUP_REASON_OFFSET,     /** INSTALL flag unset in 4-way msg */
329     WLC_E_SUP_MSG3_NO_GTK = 9 + WLC_E_SUP_REASON_OFFSET,     /** encapsulated GTK missing from msg 3 */
330     WLC_E_SUP_GRP_KEY_CIPHER = 10 + WLC_E_SUP_REASON_OFFSET,     /** Multicast cipher mismatch in group key */
331     WLC_E_SUP_GRP_MSG1_NO_GTK = 11 + WLC_E_SUP_REASON_OFFSET,     /** encapsulated GTK missing from group msg 1 */
332     WLC_E_SUP_GTK_DECRYPT_FAIL = 12 + WLC_E_SUP_REASON_OFFSET,     /** GTK decrypt failure */
333     WLC_E_SUP_SEND_FAIL = 13 + WLC_E_SUP_REASON_OFFSET,     /** message send failure */
334     WLC_E_SUP_DEAUTH = 14 + WLC_E_SUP_REASON_OFFSET,     /** received FC_DEAUTH */
335     WLC_E_SUP_WPA_PSK_TMO = 15 + WLC_E_SUP_REASON_OFFSET,     /** WPA PSK 4-way handshake timeout */
336 
337     DOT11_RC_RESERVED = 0 + WLC_E_DOT11_RC_REASON_OFFSET,     /* d11 RC reserved */
338     DOT11_RC_UNSPECIFIED = 1 + WLC_E_DOT11_RC_REASON_OFFSET,     /* Unspecified reason */
339     DOT11_RC_AUTH_INVAL = 2 + WLC_E_DOT11_RC_REASON_OFFSET,     /* Previous authentication no longer valid */
340     DOT11_RC_DEAUTH_LEAVING = 3 + WLC_E_DOT11_RC_REASON_OFFSET,     /* Deauthenticated because sending station is leaving (or has left) IBSS or ESS */
341     DOT11_RC_INACTIVITY = 4 + WLC_E_DOT11_RC_REASON_OFFSET,     /* Disassociated due to inactivity */
342     DOT11_RC_BUSY = 5 + WLC_E_DOT11_RC_REASON_OFFSET,     /* Disassociated because AP is unable to handle all currently associated stations */
343     DOT11_RC_INVAL_CLASS_2 = 6 + WLC_E_DOT11_RC_REASON_OFFSET,     /* Class 2 frame received from nonauthenticated station */
344     DOT11_RC_INVAL_CLASS_3 = 7 + WLC_E_DOT11_RC_REASON_OFFSET,     /* Class 3 frame received from nonassociated station */
345     DOT11_RC_DISASSOC_LEAVING = 8 + WLC_E_DOT11_RC_REASON_OFFSET,     /* Disassociated because sending station is leaving (or has left) BSS */
346     DOT11_RC_NOT_AUTH = 9 + WLC_E_DOT11_RC_REASON_OFFSET,     /* Station requesting (re)association is not * authenticated with responding station */
347     DOT11_RC_BAD_PC = 10 + WLC_E_DOT11_RC_REASON_OFFSET,     /* Unacceptable power capability element */
348     DOT11_RC_BAD_CHANNELS = 11 + WLC_E_DOT11_RC_REASON_OFFSET,     /* Unacceptable supported channels element */
349     /* 12 is unused */
350     /* XXX 13-23 are WPA/802.11i reason codes defined in proto/wpa.h */
351     /* 32-39 are QSTA specific reasons added in 11e */
352     DOT11_RC_UNSPECIFIED_QOS = 32 + WLC_E_DOT11_RC_REASON_OFFSET,     /* unspecified QoS-related reason */
353     DOT11_RC_INSUFFCIENT_BW = 33 + WLC_E_DOT11_RC_REASON_OFFSET,     /* QAP lacks sufficient bandwidth */
354     DOT11_RC_EXCESSIVE_FRAMES = 34 + WLC_E_DOT11_RC_REASON_OFFSET,     /* excessive number of frames need ack */
355     DOT11_RC_TX_OUTSIDE_TXOP = 35 + WLC_E_DOT11_RC_REASON_OFFSET,     /* transmitting outside the limits of txop */
356     DOT11_RC_LEAVING_QBSS = 36 + WLC_E_DOT11_RC_REASON_OFFSET,     /* QSTA is leaving the QBSS (or restting) */
357     DOT11_RC_BAD_MECHANISM = 37 + WLC_E_DOT11_RC_REASON_OFFSET,     /* does not want to use the mechanism */
358     DOT11_RC_SETUP_NEEDED = 38 + WLC_E_DOT11_RC_REASON_OFFSET,     /* mechanism needs a setup */
359     DOT11_RC_TIMEOUT = 39 + WLC_E_DOT11_RC_REASON_OFFSET,     /* timeout */
360     DOT11_RC_MAX = 23 + WLC_E_DOT11_RC_REASON_OFFSET,     /* Reason codes > 23 are reserved */
361 
362     WLC_E_REASON_FORCE_32_BIT = 0x7FFFFFFE     /** Force enum to be stored in 32 bit variable */
363 } whd_event_reason_t;
364 
365 typedef enum
366 {
367     WLC_E_NAN_EVENT_START = 1,     /* NAN cluster started */
368     WLC_E_NAN_EVENT_JOIN = 2,     /* Joined to a NAN cluster */
369     WLC_E_NAN_EVENT_ROLE = 3,     /* Role or State changed */
370     WLC_E_NAN_EVENT_SCAN_COMPLETE = 4, WLC_E_NAN_EVENT_DISCOVERY_RESULT = 5, WLC_E_NAN_EVENT_REPLIED = 6,
371     WLC_E_NAN_EVENT_TERMINATED = 7,                                                                                                           /* the instance ID will be present in the ev data */
372     WLC_E_NAN_EVENT_RECEIVE = 8
373 
374 } whd_nan_events_t;
375 
376 /* Reason codes for LINK */
377 #define WLC_E_LINK_BCN_LOSS     1 /** Link down because of beacon loss */
378 #define WLC_E_LINK_DISASSOC     2 /** Link down because of disassoc */
379 #define WLC_E_LINK_ASSOC_REC    3 /** Link down because assoc recreate failed */
380 #define WLC_E_LINK_BSSCFG_DIS   4 /** Link down due to bsscfg down */
381 
382 /**
383  * Event handler prototype definition
384  *
385  * @param[out] whd_event_header_t : whd event header
386  * @param[out] uint8_t*           : event data
387  * @param[out] handler_user_data  : semaphore data
388  */
389 typedef void *(*whd_event_handler_t)(whd_interface_t ifp, const whd_event_header_t *event_header,
390                                      const uint8_t *event_data, void *handler_user_data);
391 /** @endcond */
392 
393 /**
394  * Error handler prototype definition
395  *
396  * @param[out] uint8_t           : error_type
397  * @param[out] uint8_t*           : event data
398  * @param[out] handler_user_data  : semaphore data
399  */
400 typedef void *(*whd_error_handler_t)(whd_driver_t whd_driver, const uint8_t *error_type,
401                                      const uint8_t *event_data, void *handler_user_data);
402 /** @endcond */
403 extern whd_result_t whd_management_set_event_handler_locally(whd_interface_t ifp,
404                                                              const whd_event_num_t *event_nums,
405                                                              whd_event_handler_t handler_func,
406                                                              void *handler_user_data, uint16_t *event_index);
407 
408 extern whd_result_t whd_management_set_event_handler(whd_interface_t ifp, const whd_event_num_t *event_nums,
409                                                      whd_event_handler_t handler_func,
410                                                      void *handler_user_data, uint16_t *event_index);
411 
412 extern uint32_t whd_wifi_set_event_handler(whd_interface_t ifp, const uint32_t *event_type,
413                                            whd_event_handler_t handler_func,
414                                            void *handler_user_data, uint16_t *event_index);
415 
416 extern uint32_t whd_wifi_deregister_event_handler(whd_interface_t ifp, uint16_t event_index);
417 
418 extern whd_result_t whd_set_error_handler_locally(whd_driver_t whd_driver, const uint8_t *error_nums,
419                                                   whd_error_handler_t handler_func,
420                                                   void *handler_user_data, uint16_t *error_index);
421 
422 extern whd_result_t whd_wifi_set_error_handler(whd_interface_t ifp, const uint8_t *error_type,
423                                                whd_error_handler_t handler_func,
424                                                void *handler_user_data, uint16_t *error_index);
425 
426 extern uint32_t whd_wifi_deregister_error_handler(whd_interface_t ifp, uint16_t error_index);
427 
428 /** @cond */
429 
430 //extern void* whd_rrm_report_handler( const whd_event_header_t* event_header, const uint8_t* event_data, void* handler_user_data );
431 
432 extern void *whd_nan_scan_handler(const whd_event_header_t *event_header, const uint8_t *event_data,
433                                   void *handler_user_data);
434 
435 #define WHD_MSG_IFNAME_MAX 16
436 
437 /* Maximum number of events registered at a time */
438 #define WHD_MAX_EVENT_SUBSCRIPTION 33
439 
440 #define WHD_EVENT_NOT_REGISTERED 0xFF
441 /* Enum to index and find the entry of paricular event registered */
442 typedef enum
443 {
444     WHD_SCAN_EVENT_ENTRY       = 0,
445     WHD_JOIN_EVENT_ENTRY,
446     WHD_AP_EVENT_ENTRY,
447     WHD_P2P_EVENT_ENTRY,
448     WHD_AUTH_EVENT_ENTRY,
449     WHD_EVENT_ENTRY_MAX
450 } whd_event_entry_t;
451 
452 #pragma pack(1)
453 typedef struct whd_event_eth_hdr
454 {
455     uint16_t subtype;      /** Vendor specific..32769 */
456     uint16_t length;
457     uint8_t version;       /** Version is 0 */
458     uint8_t oui[3];        /**  OUI */
459     uint16_t usr_subtype;  /** user specific Data */
460 } whd_event_eth_hdr_t;
461 
462 typedef struct whd_event_ether_header
463 {
464     whd_mac_t destination_address;
465     whd_mac_t source_address;
466     uint16_t ethertype;
467 } whd_event_ether_header_t;
468 
469 struct whd_event_msg
470 {
471     uint16_t version;
472     uint16_t flags;                 /* see flags below */
473     uint32_t event_type;            /* Message (see below) */
474     uint32_t status;                /* Status code (see below) */
475     uint32_t reason;                /* Reason code (if applicable) */
476     uint32_t auth_type;             /* WLC_E_AUTH */
477     uint32_t datalen;               /* data buf */
478     whd_mac_t addr;                 /* Station address (if applicable) */
479     char ifname[WHD_MSG_IFNAME_MAX];               /* name of the packet incoming interface */
480     uint8_t ifidx;                                 /* destination OS i/f index */
481     uint8_t bsscfgidx;                             /* source bsscfg index */
482 };
483 
484 /* used by driver msgs */
485 typedef struct whd_event
486 {
487     whd_event_ether_header_t eth;
488     whd_event_eth_hdr_t eth_evt_hdr;
489     whd_event_header_t whd_event;
490     /* data portion follows */
491 } whd_event_t;
492 
493 #pragma pack()
494 
495 /** @endcond */
496 
497 /** @} */
498 
499 #ifdef __cplusplus
500 } /* extern "C" */
501 #endif
502 #endif /* ifndef INCLUDED_WHD_EVENTS_H */
503