staging: brcm80211: clarified fullmac io and event codes
[pandora-kernel.git] / drivers / staging / brcm80211 / brcmfmac / dhd.h
1 /*
2  * Copyright (c) 2010 Broadcom Corporation
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 /****************
18  * Common types *
19  */
20
21 #ifndef _BRCMF_H_
22 #define _BRCMF_H_
23
24 #define BRCMF_VERSION_STR               "4.218.248.5"
25
26 #define BRCMF_C_IOCTL_SMLEN     256     /* "small" ioctl buffer required */
27 #define BRCMF_C_IOCTL_MEDLEN    1536    /* "med" ioctl buffer required */
28 #define BRCMF_C_IOCTL_MAXLEN    8192
29
30 /*******************************************************************************
31  * IO codes that are interpreted by dongle firmware
32  ******************************************************************************/
33 #define BRCMF_C_UP                              2
34 #define BRCMF_C_SET_PROMISC                     10
35 #define BRCMF_C_GET_RATE                        12
36 #define BRCMF_C_GET_INFRA                       19
37 #define BRCMF_C_SET_INFRA                       20
38 #define BRCMF_C_GET_AUTH                        21
39 #define BRCMF_C_SET_AUTH                        22
40 #define BRCMF_C_GET_BSSID                       23
41 #define BRCMF_C_GET_SSID                        25
42 #define BRCMF_C_SET_SSID                        26
43 #define BRCMF_C_GET_CHANNEL                     29
44 #define BRCMF_C_GET_SRL                         31
45 #define BRCMF_C_GET_LRL                         33
46 #define BRCMF_C_GET_RADIO                       37
47 #define BRCMF_C_SET_RADIO                       38
48 #define BRCMF_C_GET_PHYTYPE                     39
49 #define BRCMF_C_SET_KEY                         45
50 #define BRCMF_C_SET_PASSIVE_SCAN                49
51 #define BRCMF_C_SCAN                            50
52 #define BRCMF_C_SCAN_RESULTS                    51
53 #define BRCMF_C_DISASSOC                        52
54 #define BRCMF_C_REASSOC                         53
55 #define BRCMF_C_SET_ROAM_TRIGGER                55
56 #define BRCMF_C_SET_ROAM_DELTA                  57
57 #define BRCMF_C_GET_DTIMPRD                     77
58 #define BRCMF_C_SET_COUNTRY                     84
59 #define BRCMF_C_GET_PM                          85
60 #define BRCMF_C_SET_PM                          86
61 #define BRCMF_C_GET_AP                          117
62 #define BRCMF_C_SET_AP                          118
63 #define BRCMF_C_GET_RSSI                        127
64 #define BRCMF_C_GET_WSEC                        133
65 #define BRCMF_C_SET_WSEC                        134
66 #define BRCMF_C_GET_PHY_NOISE                   135
67 #define BRCMF_C_GET_BSS_INFO                    136
68 #define BRCMF_C_SET_SCAN_CHANNEL_TIME           185
69 #define BRCMF_C_SET_SCAN_UNASSOC_TIME           187
70 #define BRCMF_C_SCB_DEAUTHENTICATE_FOR_REASON   201
71 #define BRCMF_C_GET_VALID_CHANNELS              217
72 #define BRCMF_C_GET_KEY_PRIMARY                 235
73 #define BRCMF_C_SET_KEY_PRIMARY                 236
74 #define BRCMF_C_SET_SCAN_PASSIVE_TIME           258
75 #define BRCMF_C_GET_VAR                         262
76 #define BRCMF_C_SET_VAR                         263
77
78 /* phy types (returned by WLC_GET_PHYTPE) */
79 #define WLC_PHY_TYPE_A          0
80 #define WLC_PHY_TYPE_B          1
81 #define WLC_PHY_TYPE_G          2
82 #define WLC_PHY_TYPE_N          4
83 #define WLC_PHY_TYPE_LP         5
84 #define WLC_PHY_TYPE_SSN        6
85 #define WLC_PHY_TYPE_HT         7
86 #define WLC_PHY_TYPE_LCN        8
87 #define WLC_PHY_TYPE_NULL       0xf
88
89 #define BRCMF_EVENTING_MASK_LEN 16
90
91 #define TOE_TX_CSUM_OL          0x00000001
92 #define TOE_RX_CSUM_OL          0x00000002
93
94 #define BRCMF_BSS_INFO_VERSION  108 /* current ver of brcmf_bss_info struct */
95
96 /* size of brcmf_scan_params not including variable length array */
97 #define BRCMF_SCAN_PARAMS_FIXED_SIZE 64
98
99 /* masks for channel and ssid count */
100 #define BRCMF_SCAN_PARAMS_COUNT_MASK 0x0000ffff
101 #define BRCMF_SCAN_PARAMS_NSSID_SHIFT 16
102
103 #define BRCMF_SCAN_ACTION_START      1
104 #define BRCMF_SCAN_ACTION_CONTINUE   2
105 #define WL_SCAN_ACTION_ABORT      3
106
107 #define BRCMF_ISCAN_REQ_VERSION 1
108
109 /* brcmf_iscan_results status values */
110 #define BRCMF_SCAN_RESULTS_SUCCESS      0
111 #define BRCMF_SCAN_RESULTS_PARTIAL      1
112 #define BRCMF_SCAN_RESULTS_PENDING      2
113 #define BRCMF_SCAN_RESULTS_ABORTED      3
114 #define BRCMF_SCAN_RESULTS_NO_MEM       4
115
116 /* Indicates this key is using soft encrypt */
117 #define WL_SOFT_KEY     (1 << 0)
118 /* primary (ie tx) key */
119 #define BRCMF_PRIMARY_KEY       (1 << 1)
120 /* Reserved for backward compat */
121 #define WL_KF_RES_4     (1 << 4)
122 /* Reserved for backward compat */
123 #define WL_KF_RES_5     (1 << 5)
124 /* Indicates a group key for a IBSS PEER */
125 #define WL_IBSS_PEER_GROUP_KEY  (1 << 6)
126
127 /* For supporting multiple interfaces */
128 #define BRCMF_MAX_IFS   16
129 #define BRCMF_DEL_IF    -0xe
130 #define BRCMF_BAD_IF    -0xf
131
132 #define DOT11_BSSTYPE_ANY                       2
133 #define DOT11_MAX_DEFAULT_KEYS  4
134
135 #define BRCMF_EVENT_MSG_LINK            0x01
136 #define BRCMF_EVENT_MSG_FLUSHTXQ        0x02
137 #define BRCMF_EVENT_MSG_GROUP           0x04
138
139 struct brcmf_event_msg {
140         __be16 version;
141         __be16 flags;
142         __be32 event_type;
143         __be32 status;
144         __be32 reason;
145         __be32 auth_type;
146         __be32 datalen;
147         u8 addr[ETH_ALEN];
148         char ifname[IFNAMSIZ];
149 } __packed;
150
151 struct brcm_ethhdr {
152         u16 subtype;
153         u16 length;
154         u8 version;
155         u8 oui[3];
156         u16 usr_subtype;
157 } __packed;
158
159 struct brcmf_event {
160         struct ethhdr eth;
161         struct brcm_ethhdr hdr;
162         struct brcmf_event_msg msg;
163 } __packed;
164
165 struct dngl_stats {
166         unsigned long rx_packets;       /* total packets received */
167         unsigned long tx_packets;       /* total packets transmitted */
168         unsigned long rx_bytes; /* total bytes received */
169         unsigned long tx_bytes; /* total bytes transmitted */
170         unsigned long rx_errors;        /* bad packets received */
171         unsigned long tx_errors;        /* packet transmit problems */
172         unsigned long rx_dropped;       /* packets dropped by dongle */
173         unsigned long tx_dropped;       /* packets dropped by dongle */
174         unsigned long multicast;        /* multicast packets received */
175 };
176
177 /* event codes sent by the dongle to this driver */
178 #define BRCMF_E_SET_SSID                        0
179 #define BRCMF_E_JOIN                            1
180 #define BRCMF_E_START                           2
181 #define BRCMF_E_AUTH                            3
182 #define BRCMF_E_AUTH_IND                        4
183 #define BRCMF_E_DEAUTH                          5
184 #define BRCMF_E_DEAUTH_IND                      6
185 #define BRCMF_E_ASSOC                           7
186 #define BRCMF_E_ASSOC_IND                       8
187 #define BRCMF_E_REASSOC                         9
188 #define BRCMF_E_REASSOC_IND                     10
189 #define BRCMF_E_DISASSOC                        11
190 #define BRCMF_E_DISASSOC_IND                    12
191 #define BRCMF_E_QUIET_START                     13
192 #define BRCMF_E_QUIET_END                       14
193 #define BRCMF_E_BEACON_RX                       15
194 #define BRCMF_E_LINK                            16
195 #define BRCMF_E_MIC_ERROR                       17
196 #define BRCMF_E_NDIS_LINK                       18
197 #define BRCMF_E_ROAM                            19
198 #define BRCMF_E_TXFAIL                          20
199 #define BRCMF_E_PMKID_CACHE                     21
200 #define BRCMF_E_RETROGRADE_TSF                  22
201 #define BRCMF_E_PRUNE                           23
202 #define BRCMF_E_AUTOAUTH                        24
203 #define BRCMF_E_EAPOL_MSG                       25
204 #define BRCMF_E_SCAN_COMPLETE                   26
205 #define BRCMF_E_ADDTS_IND                       27
206 #define BRCMF_E_DELTS_IND                       28
207 #define BRCMF_E_BCNSENT_IND                     29
208 #define BRCMF_E_BCNRX_MSG                       30
209 #define BRCMF_E_BCNLOST_MSG                     31
210 #define BRCMF_E_ROAM_PREP                       32
211 #define BRCMF_E_PFN_NET_FOUND                   33
212 #define BRCMF_E_PFN_NET_LOST                    34
213 #define BRCMF_E_RESET_COMPLETE                  35
214 #define BRCMF_E_JOIN_START                      36
215 #define BRCMF_E_ROAM_START                      37
216 #define BRCMF_E_ASSOC_START                     38
217 #define BRCMF_E_IBSS_ASSOC                      39
218 #define BRCMF_E_RADIO                           40
219 #define BRCMF_E_PSM_WATCHDOG                    41
220 #define BRCMF_E_PROBREQ_MSG                     44
221 #define BRCMF_E_SCAN_CONFIRM_IND                45
222 #define BRCMF_E_PSK_SUP                         46
223 #define BRCMF_E_COUNTRY_CODE_CHANGED            47
224 #define BRCMF_E_EXCEEDED_MEDIUM_TIME            48
225 #define BRCMF_E_ICV_ERROR                       49
226 #define BRCMF_E_UNICAST_DECODE_ERROR            50
227 #define BRCMF_E_MULTICAST_DECODE_ERROR          51
228 #define BRCMF_E_TRACE                           52
229 #define BRCMF_E_IF                              54
230 #define BRCMF_E_RSSI                            56
231 #define BRCMF_E_PFN_SCAN_COMPLETE               57
232 #define BRCMF_E_EXTLOG_MSG                      58
233 #define BRCMF_E_ACTION_FRAME                    59
234 #define BRCMF_E_ACTION_FRAME_COMPLETE           60
235 #define BRCMF_E_PRE_ASSOC_IND                   61
236 #define BRCMF_E_PRE_REASSOC_IND                 62
237 #define BRCMF_E_CHANNEL_ADOPTED                 63
238 #define BRCMF_E_AP_STARTED                      64
239 #define BRCMF_E_DFS_AP_STOP                     65
240 #define BRCMF_E_DFS_AP_RESUME                   66
241 #define BRCMF_E_RESERVED1                       67
242 #define BRCMF_E_RESERVED2                       68
243 #define BRCMF_E_ESCAN_RESULT                    69
244 #define BRCMF_E_ACTION_FRAME_OFF_CHAN_COMPLETE  70
245 #define BRCMF_E_DCS_REQUEST                     73
246
247 #define BRCMF_E_FIFO_CREDIT_MAP                 74
248
249 #define BRCMF_E_LAST                            75
250
251 #define BRCMF_E_STATUS_SUCCESS                  0
252 #define BRCMF_E_STATUS_FAIL                     1
253 #define BRCMF_E_STATUS_TIMEOUT                  2
254 #define BRCMF_E_STATUS_NO_NETWORKS              3
255 #define BRCMF_E_STATUS_ABORT                    4
256 #define BRCMF_E_STATUS_NO_ACK                   5
257 #define BRCMF_E_STATUS_UNSOLICITED              6
258 #define BRCMF_E_STATUS_ATTEMPT                  7
259 #define BRCMF_E_STATUS_PARTIAL                  8
260 #define BRCMF_E_STATUS_NEWSCAN                  9
261 #define BRCMF_E_STATUS_NEWASSOC                 10
262 #define BRCMF_E_STATUS_11HQUIET                 11
263 #define BRCMF_E_STATUS_SUPPRESS                 12
264 #define BRCMF_E_STATUS_NOCHANS                  13
265 #define BRCMF_E_STATUS_CS_ABORT                 15
266 #define BRCMF_E_STATUS_ERROR                    16
267
268 #define BRCMF_E_REASON_INITIAL_ASSOC            0
269 #define BRCMF_E_REASON_LOW_RSSI                 1
270 #define BRCMF_E_REASON_DEAUTH                   2
271 #define BRCMF_E_REASON_DISASSOC                 3
272 #define BRCMF_E_REASON_BCNS_LOST                4
273 #define BRCMF_E_REASON_MINTXRATE                9
274 #define BRCMF_E_REASON_TXFAIL                   10
275
276 #define BRCMF_E_REASON_FAST_ROAM_FAILED         5
277 #define BRCMF_E_REASON_DIRECTED_ROAM            6
278 #define BRCMF_E_REASON_TSPEC_REJECTED           7
279 #define BRCMF_E_REASON_BETTER_AP                8
280
281 #define BRCMF_E_PRUNE_ENCR_MISMATCH             1
282 #define BRCMF_E_PRUNE_BCAST_BSSID               2
283 #define BRCMF_E_PRUNE_MAC_DENY                  3
284 #define BRCMF_E_PRUNE_MAC_NA                    4
285 #define BRCMF_E_PRUNE_REG_PASSV                 5
286 #define BRCMF_E_PRUNE_SPCT_MGMT                 6
287 #define BRCMF_E_PRUNE_RADAR                     7
288 #define BRCMF_E_RSN_MISMATCH                    8
289 #define BRCMF_E_PRUNE_NO_COMMON_RATES           9
290 #define BRCMF_E_PRUNE_BASIC_RATES               10
291 #define BRCMF_E_PRUNE_CIPHER_NA                 12
292 #define BRCMF_E_PRUNE_KNOWN_STA                 13
293 #define BRCMF_E_PRUNE_WDS_PEER                  15
294 #define BRCMF_E_PRUNE_QBSS_LOAD                 16
295 #define BRCMF_E_PRUNE_HOME_AP                   17
296
297 #define BRCMF_E_SUP_OTHER                       0
298 #define BRCMF_E_SUP_DECRYPT_KEY_DATA            1
299 #define BRCMF_E_SUP_BAD_UCAST_WEP128            2
300 #define BRCMF_E_SUP_BAD_UCAST_WEP40             3
301 #define BRCMF_E_SUP_UNSUP_KEY_LEN               4
302 #define BRCMF_E_SUP_PW_KEY_CIPHER               5
303 #define BRCMF_E_SUP_MSG3_TOO_MANY_IE            6
304 #define BRCMF_E_SUP_MSG3_IE_MISMATCH            7
305 #define BRCMF_E_SUP_NO_INSTALL_FLAG             8
306 #define BRCMF_E_SUP_MSG3_NO_GTK                 9
307 #define BRCMF_E_SUP_GRP_KEY_CIPHER              10
308 #define BRCMF_E_SUP_GRP_MSG1_NO_GTK             11
309 #define BRCMF_E_SUP_GTK_DECRYPT_FAIL            12
310 #define BRCMF_E_SUP_SEND_FAIL                   13
311 #define BRCMF_E_SUP_DEAUTH                      14
312
313 #define BRCMF_E_IF_ADD                          1
314 #define BRCMF_E_IF_DEL                          2
315 #define BRCMF_E_IF_CHANGE                       3
316
317 #define BRCMF_E_IF_ROLE_STA                     0
318 #define BRCMF_E_IF_ROLE_AP                      1
319 #define BRCMF_E_IF_ROLE_WDS                     2
320
321 #define BRCMF_E_LINK_BCN_LOSS                   1
322 #define BRCMF_E_LINK_DISASSOC                   2
323 #define BRCMF_E_LINK_ASSOC_REC                  3
324 #define BRCMF_E_LINK_BSSCFG_DIS                 4
325
326 /* The level of bus communication with the dongle */
327 enum brcmf_bus_state {
328         BRCMF_BUS_DOWN,         /* Not ready for frame transfers */
329         BRCMF_BUS_LOAD,         /* Download access only (CPU reset) */
330         BRCMF_BUS_DATA          /* Ready for frame transfers */
331 };
332
333 /* Pattern matching filter. Specifies an offset within received packets to
334  * start matching, the pattern to match, the size of the pattern, and a bitmask
335  * that indicates which bits within the pattern should be matched.
336  */
337 struct brcmf_pkt_filter_pattern {
338         /*
339          * Offset within received packet to start pattern matching.
340          * Offset '0' is the first byte of the ethernet header.
341          */
342         u32 offset;
343         /* Size of the pattern.  Bitmask must be the same size.*/
344         u32 size_bytes;
345         /*
346          * Variable length mask and pattern data. mask starts at offset 0.
347          * Pattern immediately follows mask.
348          */
349         u8 mask_and_pattern[1];
350 };
351
352 /* IOVAR "pkt_filter_add" parameter. Used to install packet filters. */
353 struct brcmf_pkt_filter {
354         u32 id;         /* Unique filter id, specified by app. */
355         u32 type;               /* Filter type (WL_PKT_FILTER_TYPE_xxx). */
356         u32 negate_match;       /* Negate the result of filter matches */
357         union {                 /* Filter definitions */
358                 struct brcmf_pkt_filter_pattern pattern; /* Filter pattern */
359         } u;
360 };
361
362 /* IOVAR "pkt_filter_enable" parameter. */
363 struct brcmf_pkt_filter_enable {
364         u32 id;         /* Unique filter id */
365         u32 enable;             /* Enable/disable bool */
366 };
367
368 /* BSS info structure
369  * Applications MUST CHECK ie_offset field and length field to access IEs and
370  * next bss_info structure in a vector (in struct brcmf_scan_results)
371  */
372 struct brcmf_bss_info {
373         __le32 version;         /* version field */
374         __le32 length;          /* byte length of data in this record,
375                                  * starting at version and including IEs
376                                  */
377         u8 BSSID[ETH_ALEN];
378         __le16 beacon_period;   /* units are Kusec */
379         __le16 capability;      /* Capability information */
380         u8 SSID_len;
381         u8 SSID[32];
382         struct {
383                 __le32 count;   /* # rates in this set */
384                 u8 rates[16]; /* rates in 500kbps units w/hi bit set if basic */
385         } rateset;              /* supported rates */
386         __le16 chanspec;        /* chanspec for bss */
387         __le16 atim_window;     /* units are Kusec */
388         u8 dtim_period; /* DTIM period */
389         __le16 RSSI;            /* receive signal strength (in dBm) */
390         s8 phy_noise;           /* noise (in dBm) */
391
392         u8 n_cap;               /* BSS is 802.11N Capable */
393         /* 802.11N BSS Capabilities (based on HT_CAP_*): */
394         __le32 nbss_cap;
395         u8 ctl_ch;              /* 802.11N BSS control channel number */
396         __le32 reserved32[1];   /* Reserved for expansion of BSS properties */
397         u8 flags;               /* flags */
398         u8 reserved[3]; /* Reserved for expansion of BSS properties */
399         u8 basic_mcs[MCSSET_LEN];       /* 802.11N BSS required MCS set */
400
401         __le16 ie_offset;       /* offset at which IEs start, from beginning */
402         __le32 ie_length;       /* byte length of Information Elements */
403         __le16 SNR;             /* average SNR of during frame reception */
404         /* Add new fields here */
405         /* variable length Information Elements */
406 };
407
408 struct brcm_rateset_le {
409         /* # rates in this set */
410         __le32 count;
411         /* rates in 500kbps units w/hi bit set if basic */
412         u8 rates[WL_NUMRATES];
413 };
414
415 struct brcmf_ssid {
416         u32 SSID_len;
417         unsigned char SSID[32];
418 };
419
420 struct brcmf_ssid_le {
421         __le32 SSID_len;
422         unsigned char SSID[32];
423 };
424
425 struct brcmf_scan_params_le {
426         struct brcmf_ssid_le ssid_le;   /* default: {0, ""} */
427         u8 bssid[ETH_ALEN];     /* default: bcast */
428         s8 bss_type;            /* default: any,
429                                  * DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT
430                                  */
431         u8 scan_type;   /* flags, 0 use default */
432         __le32 nprobes;   /* -1 use default, number of probes per channel */
433         __le32 active_time;     /* -1 use default, dwell time per channel for
434                                  * active scanning
435                                  */
436         __le32 passive_time;    /* -1 use default, dwell time per channel
437                                  * for passive scanning
438                                  */
439         __le32 home_time;       /* -1 use default, dwell time for the
440                                  * home channel between channel scans
441                                  */
442         __le32 channel_num;     /* count of channels and ssids that follow
443                                  *
444                                  * low half is count of channels in
445                                  * channel_list, 0 means default (use all
446                                  * available channels)
447                                  *
448                                  * high half is entries in struct brcmf_ssid
449                                  * array that follows channel_list, aligned for
450                                  * s32 (4 bytes) meaning an odd channel count
451                                  * implies a 2-byte pad between end of
452                                  * channel_list and first ssid
453                                  *
454                                  * if ssid count is zero, single ssid in the
455                                  * fixed parameter portion is assumed, otherwise
456                                  * ssid in the fixed portion is ignored
457                                  */
458         __le16 channel_list[1]; /* list of chanspecs */
459 };
460
461 /* incremental scan struct */
462 struct brcmf_iscan_params_le {
463         __le32 version;
464         __le16 action;
465         __le16 scan_duration;
466         struct brcmf_scan_params_le params_le;
467 };
468
469 struct brcmf_scan_results {
470         u32 buflen;
471         u32 version;
472         u32 count;
473         struct brcmf_bss_info bss_info[1];
474 };
475
476 struct brcmf_scan_results_le {
477         __le32 buflen;
478         __le32 version;
479         __le32 count;
480         struct brcmf_bss_info bss_info[1];
481 };
482
483 /* used for association with a specific BSSID and chanspec list */
484 struct brcmf_assoc_params_le {
485         /* 00:00:00:00:00:00: broadcast scan */
486         u8 bssid[ETH_ALEN];
487         /* 0: all available channels, otherwise count of chanspecs in
488          * chanspec_list */
489         __le32 chanspec_num;
490         /* list of chanspecs */
491         __le16 chanspec_list[1];
492 };
493
494 /* used for join with or without a specific bssid and channel list */
495 struct brcmf_join_params {
496         struct brcmf_ssid_le ssid_le;
497         struct brcmf_assoc_params_le params_le;
498 };
499
500 /* size of brcmf_scan_results not including variable length array */
501 #define BRCMF_SCAN_RESULTS_FIXED_SIZE \
502         (sizeof(struct brcmf_scan_results) - sizeof(struct brcmf_bss_info))
503
504 /* incremental scan results struct */
505 struct brcmf_iscan_results {
506         union {
507                 u32 status;
508                 __le32 status_le;
509         };
510         union {
511                 struct brcmf_scan_results results;
512                 struct brcmf_scan_results_le results_le;
513         };
514 };
515
516 /* size of brcmf_iscan_results not including variable length array */
517 #define BRCMF_ISCAN_RESULTS_FIXED_SIZE \
518         (BRCMF_SCAN_RESULTS_FIXED_SIZE + \
519          offsetof(struct brcmf_iscan_results, results))
520
521 struct brcmf_wsec_key {
522         u32 index;              /* key index */
523         u32 len;                /* key length */
524         u8 data[WLAN_MAX_KEY_LEN];      /* key data */
525         u32 pad_1[18];
526         u32 algo;       /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
527         u32 flags;      /* misc flags */
528         u32 pad_2[3];
529         u32 iv_initialized;     /* has IV been initialized already? */
530         u32 pad_3;
531         /* Rx IV */
532         struct {
533                 u32 hi; /* upper 32 bits of IV */
534                 u16 lo; /* lower 16 bits of IV */
535         } rxiv;
536         u32 pad_4[2];
537         u8 ea[ETH_ALEN];        /* per station */
538 };
539
540 /*
541  * dongle requires same struct as above but with fields in little endian order
542  */
543 struct brcmf_wsec_key_le {
544         __le32 index;           /* key index */
545         __le32 len;             /* key length */
546         u8 data[WLAN_MAX_KEY_LEN];      /* key data */
547         __le32 pad_1[18];
548         __le32 algo;    /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
549         __le32 flags;   /* misc flags */
550         __le32 pad_2[3];
551         __le32 iv_initialized;  /* has IV been initialized already? */
552         __le32 pad_3;
553         /* Rx IV */
554         struct {
555                 __le32 hi;      /* upper 32 bits of IV */
556                 __le16 lo;      /* lower 16 bits of IV */
557         } rxiv;
558         __le32 pad_4[2];
559         u8 ea[ETH_ALEN];        /* per station */
560 };
561
562 /* Used to get specific STA parameters */
563 struct brcmf_scb_val_le {
564         __le32 val;
565         u8 ea[ETH_ALEN];
566 };
567
568 /* channel encoding */
569 struct brcmf_channel_info_le {
570         __le32 hw_channel;
571         __le32 target_channel;
572         __le32 scan_channel;
573 };
574
575 /* Linux network driver ioctl encoding */
576 struct brcmf_ioctl {
577         uint cmd;               /* common ioctl definition */
578         void *buf;              /* pointer to user buffer */
579         uint len;               /* length of user buffer */
580         u8 set;         /* get or set request (optional) */
581         uint used;              /* bytes read or written (optional) */
582         uint needed;            /* bytes needed (optional) */
583 };
584
585 /* Forward decls for struct brcmf_pub (see below) */
586 struct brcmf_bus;               /* device bus info */
587 struct brcmf_proto;     /* device communication protocol info */
588 struct brcmf_info;      /* device driver info */
589 struct brcmf_cfg80211_dev; /* cfg80211 device info */
590
591 /* Common structure for module and instance linkage */
592 struct brcmf_pub {
593         /* Linkage ponters */
594         struct brcmf_bus *bus;
595         struct brcmf_proto *prot;
596         struct brcmf_info *info;
597         struct brcmf_cfg80211_dev *config;
598
599         /* Internal brcmf items */
600         bool up;                /* Driver up/down (to OS) */
601         bool txoff;             /* Transmit flow-controlled */
602         bool dongle_reset;      /* true = DEVRESET put dongle into reset */
603         enum brcmf_bus_state busstate;
604         uint hdrlen;            /* Total BRCMF header length (proto + bus) */
605         uint maxctl;            /* Max size rxctl request from proto to bus */
606         uint rxsz;              /* Rx buffer size bus module should use */
607         u8 wme_dp;              /* wme discard priority */
608
609         /* Dongle media info */
610         bool iswl;              /* Dongle-resident driver is wl */
611         unsigned long drv_version;      /* Version of dongle-resident driver */
612         u8 mac[ETH_ALEN];               /* MAC address obtained from dongle */
613         struct dngl_stats dstats;       /* Stats for dongle-based data */
614
615         /* Additional stats for the bus level */
616
617         /* Data packets sent to dongle */
618         unsigned long tx_packets;
619         /* Multicast data packets sent to dongle */
620         unsigned long tx_multicast;
621         /* Errors in sending data to dongle */
622         unsigned long tx_errors;
623         /* Control packets sent to dongle */
624         unsigned long tx_ctlpkts;
625         /* Errors sending control frames to dongle */
626         unsigned long tx_ctlerrs;
627         /* Packets sent up the network interface */
628         unsigned long rx_packets;
629         /* Multicast packets sent up the network interface */
630         unsigned long rx_multicast;
631         /* Errors processing rx data packets */
632         unsigned long rx_errors;
633         /* Control frames processed from dongle */
634         unsigned long rx_ctlpkts;
635
636         /* Errors in processing rx control frames */
637         unsigned long rx_ctlerrs;
638         /* Packets dropped locally (no memory) */
639         unsigned long rx_dropped;
640         /* Packets flushed due to unscheduled sendup thread */
641         unsigned long rx_flushed;
642         /* Number of times dpc scheduled by watchdog timer */
643         unsigned long wd_dpc_sched;
644
645         /* Number of packets where header read-ahead was used. */
646         unsigned long rx_readahead_cnt;
647         /* Number of tx packets we had to realloc for headroom */
648         unsigned long tx_realloc;
649         /* Number of flow control pkts recvd */
650         unsigned long fc_packets;
651
652         /* Last error return */
653         int bcmerror;
654         uint tickcnt;
655
656         /* Last error from dongle */
657         int dongle_error;
658
659         /* Suspend disable flag  flag */
660         int suspend_disable_flag;       /* "1" to disable all extra powersaving
661                                          during suspend */
662         int in_suspend;         /* flag set to 1 when early suspend called */
663         int dtim_skip;          /* dtim skip , default 0 means wake each dtim */
664
665         /* Pkt filter defination */
666         char *pktfilter[100];
667         int pktfilter_count;
668
669         u8 country_code[BRCM_CNTRY_BUF_SZ];
670         char eventmask[BRCMF_EVENTING_MASK_LEN];
671
672 };
673
674 struct brcmf_if_event {
675         u8 ifidx;
676         u8 action;
677         u8 flags;
678         u8 bssidx;
679 };
680
681 struct bcmevent_name {
682         uint event;
683         const char *name;
684 };
685
686 /* Override to force tx queueing all the time */
687 extern uint brcmf_force_tx_queueing;
688
689 extern const struct bcmevent_name bcmevent_names[];
690 extern const int bcmevent_names_size;
691
692
693 static inline void MUTEX_LOCK_INIT(struct brcmf_pub *drvr)
694 {
695 }
696
697 static inline void MUTEX_LOCK(struct brcmf_pub *drvr)
698 {
699 }
700
701 static inline void MUTEX_UNLOCK(struct brcmf_pub *drvr)
702 {
703 }
704
705 static inline void MUTEX_LOCK_WL_SCAN_SET_INIT(void)
706 {
707 }
708
709 static inline void MUTEX_LOCK_WL_SCAN_SET(void)
710 {
711 }
712
713 static inline void MUTEX_UNLOCK_WL_SCAN_SET(void)
714 {
715 }
716
717 /* Indication from bus module regarding presence/insertion of dongle.
718  * Return struct brcmf_pub pointer, used as handle to OS module in later calls.
719  * Returned structure should have bus and prot pointers filled in.
720  * bus_hdrlen specifies required headroom for bus module header.
721  */
722 extern struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus,
723                                       uint bus_hdrlen);
724 extern int brcmf_net_attach(struct brcmf_pub *drvr, int idx);
725 extern int brcmf_netdev_wait_pend8021x(struct net_device *dev);
726
727 extern int brcmf_netdev_ioctl_priv(struct net_device *net,
728                                    struct brcmf_ioctl *ioc);
729
730 /* Indication from bus module regarding removal/absence of dongle */
731 extern void brcmf_detach(struct brcmf_pub *drvr);
732
733 /* Indication from bus module to change flow-control state */
734 extern void brcmf_txflowcontrol(struct brcmf_pub *drvr, int ifidx, bool on);
735
736 extern bool brcmf_c_prec_enq(struct brcmf_pub *drvr, struct pktq *q,
737                          struct sk_buff *pkt, int prec);
738
739 /* Receive frame for delivery to OS.  Callee disposes of rxp. */
740 extern void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx,
741                          struct sk_buff *rxp, int numpkt);
742
743 /* Return pointer to interface name */
744 extern char *brcmf_ifname(struct brcmf_pub *drvr, int idx);
745
746 /* Notify tx completion */
747 extern void brcmf_txcomplete(struct brcmf_pub *drvr, struct sk_buff *txp,
748                              bool success);
749
750 /* Query ioctl */
751 extern int brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx,
752                                        uint cmd, void *buf, uint len);
753
754 /* OS independent layer functions */
755 extern int brcmf_os_proto_block(struct brcmf_pub *drvr);
756 extern int brcmf_os_proto_unblock(struct brcmf_pub *drvr);
757 #ifdef BCMDBG
758 extern int brcmf_write_to_file(struct brcmf_pub *drvr, u8 *buf, int size);
759 #endif                          /* BCMDBG */
760
761 extern int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name);
762 extern int brcmf_c_host_event(struct brcmf_info *drvr_priv, int *idx,
763                               void *pktdata, struct brcmf_event_msg *,
764                               void **data_ptr);
765
766 extern void brcmf_c_init(void);
767
768 extern int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx,
769                         struct net_device *net, char *name, u8 *mac_addr,
770                         u32 flags, u8 bssidx);
771 extern void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx);
772
773 /* Send packet to dongle via data channel */
774 extern int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx,\
775                          struct sk_buff *pkt);
776
777 extern int brcmf_bus_devreset(struct brcmf_pub *drvr, u8 flag);
778 extern int brcmf_bus_start(struct brcmf_pub *drvr);
779
780 extern void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg);
781 extern void brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg,
782                                              int enable, int master_mode);
783
784 /* per-driver magic numbers */
785 #define BRCMF_IOCTL_MAGIC               0x00444944
786
787 /* bump this number if you change the ioctl interface */
788 #define BRCMF_IOCTL_VERSION     1
789 #define BRCMF_IOCTL_MAXLEN      8192    /* max length ioctl buffer required */
790
791 /* common ioctl definitions */
792 #define BRCMF_GET_VERSION                               1
793 #define BRCMF_GET_VAR                           2
794 #define BRCMF_SET_VAR                           3
795
796 /* message levels */
797 #define BRCMF_ERROR_VAL 0x0001
798 #define BRCMF_TRACE_VAL 0x0002
799 #define BRCMF_INFO_VAL  0x0004
800 #define BRCMF_DATA_VAL  0x0008
801 #define BRCMF_CTL_VAL   0x0010
802 #define BRCMF_TIMER_VAL 0x0020
803 #define BRCMF_HDRS_VAL  0x0040
804 #define BRCMF_BYTES_VAL 0x0080
805 #define BRCMF_INTR_VAL  0x0100
806 #define BRCMF_GLOM_VAL  0x0400
807 #define BRCMF_EVENT_VAL 0x0800
808 #define BRCMF_BTA_VAL   0x1000
809 #define BRCMF_ISCAN_VAL 0x2000
810
811 /* Enter idle immediately (no timeout) */
812 #define BRCMF_IDLE_IMMEDIATE    (-1)
813 #define BRCMF_IDLE_ACTIVE       0       /* Do not request any SD clock change
814                                  when idle */
815 #define BRCMF_IDLE_INTERVAL     1
816
817 #endif                          /* _BRCMF_H_ */