1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef FWEH_H_
19#define FWEH_H_
20
21#include <asm/unaligned.h>
22#include <linux/skbuff.h>
23#include <linux/if_ether.h>
24#include <linux/if.h>
25
26
27struct brcmf_pub;
28struct brcmf_if;
29struct brcmf_cfg80211_info;
30struct brcmf_event;
31
32
33#define BRCMF_FWEH_EVENT_ENUM_DEFLIST \
34 BRCMF_ENUM_DEF(SET_SSID, 0) \
35 BRCMF_ENUM_DEF(JOIN, 1) \
36 BRCMF_ENUM_DEF(START, 2) \
37 BRCMF_ENUM_DEF(AUTH, 3) \
38 BRCMF_ENUM_DEF(AUTH_IND, 4) \
39 BRCMF_ENUM_DEF(DEAUTH, 5) \
40 BRCMF_ENUM_DEF(DEAUTH_IND, 6) \
41 BRCMF_ENUM_DEF(ASSOC, 7) \
42 BRCMF_ENUM_DEF(ASSOC_IND, 8) \
43 BRCMF_ENUM_DEF(REASSOC, 9) \
44 BRCMF_ENUM_DEF(REASSOC_IND, 10) \
45 BRCMF_ENUM_DEF(DISASSOC, 11) \
46 BRCMF_ENUM_DEF(DISASSOC_IND, 12) \
47 BRCMF_ENUM_DEF(QUIET_START, 13) \
48 BRCMF_ENUM_DEF(QUIET_END, 14) \
49 BRCMF_ENUM_DEF(BEACON_RX, 15) \
50 BRCMF_ENUM_DEF(LINK, 16) \
51 BRCMF_ENUM_DEF(MIC_ERROR, 17) \
52 BRCMF_ENUM_DEF(NDIS_LINK, 18) \
53 BRCMF_ENUM_DEF(ROAM, 19) \
54 BRCMF_ENUM_DEF(TXFAIL, 20) \
55 BRCMF_ENUM_DEF(PMKID_CACHE, 21) \
56 BRCMF_ENUM_DEF(RETROGRADE_TSF, 22) \
57 BRCMF_ENUM_DEF(PRUNE, 23) \
58 BRCMF_ENUM_DEF(AUTOAUTH, 24) \
59 BRCMF_ENUM_DEF(EAPOL_MSG, 25) \
60 BRCMF_ENUM_DEF(SCAN_COMPLETE, 26) \
61 BRCMF_ENUM_DEF(ADDTS_IND, 27) \
62 BRCMF_ENUM_DEF(DELTS_IND, 28) \
63 BRCMF_ENUM_DEF(BCNSENT_IND, 29) \
64 BRCMF_ENUM_DEF(BCNRX_MSG, 30) \
65 BRCMF_ENUM_DEF(BCNLOST_MSG, 31) \
66 BRCMF_ENUM_DEF(ROAM_PREP, 32) \
67 BRCMF_ENUM_DEF(PFN_NET_FOUND, 33) \
68 BRCMF_ENUM_DEF(PFN_NET_LOST, 34) \
69 BRCMF_ENUM_DEF(RESET_COMPLETE, 35) \
70 BRCMF_ENUM_DEF(JOIN_START, 36) \
71 BRCMF_ENUM_DEF(ROAM_START, 37) \
72 BRCMF_ENUM_DEF(ASSOC_START, 38) \
73 BRCMF_ENUM_DEF(IBSS_ASSOC, 39) \
74 BRCMF_ENUM_DEF(RADIO, 40) \
75 BRCMF_ENUM_DEF(PSM_WATCHDOG, 41) \
76 BRCMF_ENUM_DEF(PROBREQ_MSG, 44) \
77 BRCMF_ENUM_DEF(SCAN_CONFIRM_IND, 45) \
78 BRCMF_ENUM_DEF(PSK_SUP, 46) \
79 BRCMF_ENUM_DEF(COUNTRY_CODE_CHANGED, 47) \
80 BRCMF_ENUM_DEF(EXCEEDED_MEDIUM_TIME, 48) \
81 BRCMF_ENUM_DEF(ICV_ERROR, 49) \
82 BRCMF_ENUM_DEF(UNICAST_DECODE_ERROR, 50) \
83 BRCMF_ENUM_DEF(MULTICAST_DECODE_ERROR, 51) \
84 BRCMF_ENUM_DEF(TRACE, 52) \
85 BRCMF_ENUM_DEF(IF, 54) \
86 BRCMF_ENUM_DEF(P2P_DISC_LISTEN_COMPLETE, 55) \
87 BRCMF_ENUM_DEF(RSSI, 56) \
88 BRCMF_ENUM_DEF(PFN_SCAN_COMPLETE, 57) \
89 BRCMF_ENUM_DEF(EXTLOG_MSG, 58) \
90 BRCMF_ENUM_DEF(ACTION_FRAME, 59) \
91 BRCMF_ENUM_DEF(ACTION_FRAME_COMPLETE, 60) \
92 BRCMF_ENUM_DEF(PRE_ASSOC_IND, 61) \
93 BRCMF_ENUM_DEF(PRE_REASSOC_IND, 62) \
94 BRCMF_ENUM_DEF(CHANNEL_ADOPTED, 63) \
95 BRCMF_ENUM_DEF(AP_STARTED, 64) \
96 BRCMF_ENUM_DEF(DFS_AP_STOP, 65) \
97 BRCMF_ENUM_DEF(DFS_AP_RESUME, 66) \
98 BRCMF_ENUM_DEF(ESCAN_RESULT, 69) \
99 BRCMF_ENUM_DEF(ACTION_FRAME_OFF_CHAN_COMPLETE, 70) \
100 BRCMF_ENUM_DEF(PROBERESP_MSG, 71) \
101 BRCMF_ENUM_DEF(P2P_PROBEREQ_MSG, 72) \
102 BRCMF_ENUM_DEF(DCS_REQUEST, 73) \
103 BRCMF_ENUM_DEF(FIFO_CREDIT_MAP, 74) \
104 BRCMF_ENUM_DEF(ACTION_FRAME_RX, 75) \
105 BRCMF_ENUM_DEF(BCMC_CREDIT_SUPPORT, 127) \
106 BRCMF_ENUM_DEF(PSTA_PRIMARY_INTF_IND, 128)
107
108#define BRCMF_ENUM_DEF(id, val) \
109 BRCMF_E_##id = (val),
110
111
112enum brcmf_fweh_event_code {
113 BRCMF_FWEH_EVENT_ENUM_DEFLIST
114 BRCMF_E_LAST
115};
116#undef BRCMF_ENUM_DEF
117
118#define BRCMF_EVENTING_MASK_LEN DIV_ROUND_UP(BRCMF_E_LAST, 8)
119
120
121#define BRCMF_EVENT_MSG_LINK 0x01
122#define BRCMF_EVENT_MSG_FLUSHTXQ 0x02
123#define BRCMF_EVENT_MSG_GROUP 0x04
124
125
126#define BRCMF_E_STATUS_SUCCESS 0
127#define BRCMF_E_STATUS_FAIL 1
128#define BRCMF_E_STATUS_TIMEOUT 2
129#define BRCMF_E_STATUS_NO_NETWORKS 3
130#define BRCMF_E_STATUS_ABORT 4
131#define BRCMF_E_STATUS_NO_ACK 5
132#define BRCMF_E_STATUS_UNSOLICITED 6
133#define BRCMF_E_STATUS_ATTEMPT 7
134#define BRCMF_E_STATUS_PARTIAL 8
135#define BRCMF_E_STATUS_NEWSCAN 9
136#define BRCMF_E_STATUS_NEWASSOC 10
137#define BRCMF_E_STATUS_11HQUIET 11
138#define BRCMF_E_STATUS_SUPPRESS 12
139#define BRCMF_E_STATUS_NOCHANS 13
140#define BRCMF_E_STATUS_CS_ABORT 15
141#define BRCMF_E_STATUS_ERROR 16
142
143
144#define BRCMF_E_REASON_INITIAL_ASSOC 0
145#define BRCMF_E_REASON_LOW_RSSI 1
146#define BRCMF_E_REASON_DEAUTH 2
147#define BRCMF_E_REASON_DISASSOC 3
148#define BRCMF_E_REASON_BCNS_LOST 4
149#define BRCMF_E_REASON_MINTXRATE 9
150#define BRCMF_E_REASON_TXFAIL 10
151
152#define BRCMF_E_REASON_LINK_BSSCFG_DIS 4
153#define BRCMF_E_REASON_FAST_ROAM_FAILED 5
154#define BRCMF_E_REASON_DIRECTED_ROAM 6
155#define BRCMF_E_REASON_TSPEC_REJECTED 7
156#define BRCMF_E_REASON_BETTER_AP 8
157
158
159#define BRCMF_E_IF_ADD 1
160#define BRCMF_E_IF_DEL 2
161#define BRCMF_E_IF_CHANGE 3
162
163
164#define BRCMF_E_IF_FLAG_NOIF 1
165
166
167#define BRCMF_E_IF_ROLE_STA 0
168#define BRCMF_E_IF_ROLE_AP 1
169#define BRCMF_E_IF_ROLE_WDS 2
170
171
172
173
174#define BRCMF_EVENT_OUI_OFFSET 19
175#define BRCM_OUI "\x00\x10\x18"
176#define DOT11_OUI_LEN 3
177#define BCMILCP_BCM_SUBTYPE_EVENT 1
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195struct brcmf_event_msg {
196 u16 version;
197 u16 flags;
198 u32 event_code;
199 u32 status;
200 u32 reason;
201 s32 auth_type;
202 u32 datalen;
203 u8 addr[ETH_ALEN];
204 char ifname[IFNAMSIZ];
205 u8 ifidx;
206 u8 bsscfgidx;
207};
208
209struct brcmf_if_event {
210 u8 ifidx;
211 u8 action;
212 u8 flags;
213 u8 bssidx;
214 u8 role;
215};
216
217typedef int (*brcmf_fweh_handler_t)(struct brcmf_if *ifp,
218 const struct brcmf_event_msg *evtmsg,
219 void *data);
220
221
222
223
224
225
226
227
228
229struct brcmf_fweh_info {
230 struct work_struct event_work;
231 spinlock_t evt_q_lock;
232 struct list_head event_q;
233 int (*evt_handler[BRCMF_E_LAST])(struct brcmf_if *ifp,
234 const struct brcmf_event_msg *evtmsg,
235 void *data);
236};
237
238void brcmf_fweh_attach(struct brcmf_pub *drvr);
239void brcmf_fweh_detach(struct brcmf_pub *drvr);
240int brcmf_fweh_register(struct brcmf_pub *drvr, enum brcmf_fweh_event_code code,
241 int (*handler)(struct brcmf_if *ifp,
242 const struct brcmf_event_msg *evtmsg,
243 void *data));
244void brcmf_fweh_unregister(struct brcmf_pub *drvr,
245 enum brcmf_fweh_event_code code);
246int brcmf_fweh_activate_events(struct brcmf_if *ifp);
247void brcmf_fweh_process_event(struct brcmf_pub *drvr,
248 struct brcmf_event *event_packet);
249
250static inline void brcmf_fweh_process_skb(struct brcmf_pub *drvr,
251 struct sk_buff *skb)
252{
253 struct brcmf_event *event_packet;
254 u8 *data;
255 u16 usr_stype;
256
257
258 if (skb->protocol != cpu_to_be16(ETH_P_LINK_CTL))
259 return;
260
261
262 event_packet = (struct brcmf_event *)skb_mac_header(skb);
263 data = (u8 *)event_packet;
264 data += BRCMF_EVENT_OUI_OFFSET;
265 if (memcmp(BRCM_OUI, data, DOT11_OUI_LEN))
266 return;
267
268
269 data += DOT11_OUI_LEN;
270 usr_stype = get_unaligned_be16(data);
271 if (usr_stype != BCMILCP_BCM_SUBTYPE_EVENT)
272 return;
273
274 brcmf_fweh_process_event(drvr, event_packet);
275}
276
277#endif
278