]> git.karo-electronics.de Git - mv-sheeva.git/blob - drivers/staging/brcm80211/brcmfmac/dhd.h
staging: brcm80211: move debug console related code to dhd_sdio.c
[mv-sheeva.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 _dhd_h_
22 #define _dhd_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 #define BRCMF_C_UP                              2
31 #define BRCMF_C_SET_PROMISC                     10
32 #define BRCMF_C_GET_RATE                        12
33 #define BRCMF_C_GET_INFRA                       19
34 #define BRCMF_C_SET_INFRA                       20
35 #define BRCMF_C_GET_AUTH                        21
36 #define BRCMF_C_SET_AUTH                        22
37 #define BRCMF_C_GET_BSSID                       23
38 #define BRCMF_C_GET_SSID                        25
39 #define BRCMF_C_SET_SSID                        26
40 #define BRCMF_C_GET_CHANNEL                     29
41 #define BRCMF_C_GET_SRL                         31
42 #define BRCMF_C_GET_LRL                         33
43 #define BRCMF_C_GET_RADIO                       37
44 #define BRCMF_C_SET_RADIO                       38
45 #define BRCMF_C_GET_PHYTYPE                     39
46 #define BRCMF_C_SET_KEY                         45
47 #define BRCMF_C_SET_PASSIVE_SCAN                49
48 #define BRCMF_C_SCAN                            50
49 #define BRCMF_C_SCAN_RESULTS                    51
50 #define BRCMF_C_DISASSOC                        52
51 #define BRCMF_C_REASSOC                         53
52 #define BRCMF_C_SET_ROAM_TRIGGER                55
53 #define BRCMF_C_SET_ROAM_DELTA                  57
54 #define BRCMF_C_GET_DTIMPRD                     77
55 #define BRCMF_C_SET_COUNTRY                     84
56 #define BRCMF_C_GET_PM                          85
57 #define BRCMF_C_SET_PM                          86
58 #define BRCMF_C_GET_AP                          117
59 #define BRCMF_C_SET_AP                          118
60 #define BRCMF_C_GET_RSSI                        127
61 #define BRCMF_C_GET_WSEC                        133
62 #define BRCMF_C_SET_WSEC                        134
63 #define BRCMF_C_GET_PHY_NOISE                   135
64 #define BRCMF_C_GET_BSS_INFO                    136
65 #define BRCMF_C_SET_SCAN_CHANNEL_TIME           185
66 #define BRCMF_C_SET_SCAN_UNASSOC_TIME           187
67 #define BRCMF_C_SCB_DEAUTHENTICATE_FOR_REASON   201
68 #define BRCMF_C_GET_VALID_CHANNELS              217
69 #define BRCMF_C_GET_KEY_PRIMARY                 235
70 #define BRCMF_C_SET_KEY_PRIMARY                 236
71 #define BRCMF_C_SET_SCAN_PASSIVE_TIME           258
72 #define BRCMF_C_GET_VAR                         262
73 #define BRCMF_C_SET_VAR                         263
74
75 /* phy types (returned by WLC_GET_PHYTPE) */
76 #define WLC_PHY_TYPE_A          0
77 #define WLC_PHY_TYPE_B          1
78 #define WLC_PHY_TYPE_G          2
79 #define WLC_PHY_TYPE_N          4
80 #define WLC_PHY_TYPE_LP         5
81 #define WLC_PHY_TYPE_SSN        6
82 #define WLC_PHY_TYPE_HT         7
83 #define WLC_PHY_TYPE_LCN        8
84 #define WLC_PHY_TYPE_NULL       0xf
85
86 #define WL_PKT_FILTER_FIXED_LEN           offsetof(wl_pkt_filter_t, u)
87 #define WL_PKT_FILTER_PATTERN_FIXED_LEN   offsetof(wl_pkt_filter_pattern_t, mask_and_pattern)
88
89 #define WL_EVENTING_MASK_LEN    16
90
91 #define TOE_TX_CSUM_OL          0x00000001
92 #define TOE_RX_CSUM_OL          0x00000002
93
94 /* maximum channels returned by the get valid channels iovar */
95 #define WL_NUMCHANNELS          64
96
97 #define WL_BSS_INFO_VERSION     108     /* current ver of wl_bss_info struct */
98
99 /* size of wl_scan_params not including variable length array */
100 #define WL_SCAN_PARAMS_FIXED_SIZE 64
101
102 /* masks for channel and ssid count */
103 #define WL_SCAN_PARAMS_COUNT_MASK 0x0000ffff
104 #define WL_SCAN_PARAMS_NSSID_SHIFT 16
105
106 #define WL_SCAN_ACTION_START      1
107 #define WL_SCAN_ACTION_CONTINUE   2
108 #define WL_SCAN_ACTION_ABORT      3
109
110 #define ISCAN_REQ_VERSION 1
111
112 /* wl_iscan_results status values */
113 #define WL_SCAN_RESULTS_SUCCESS 0
114 #define WL_SCAN_RESULTS_PARTIAL 1
115 #define WL_SCAN_RESULTS_PENDING 2
116 #define WL_SCAN_RESULTS_ABORTED 3
117 #define WL_SCAN_RESULTS_NO_MEM  4
118
119 #define WL_SOFT_KEY     (1 << 0)        /* Indicates this key is using soft encrypt */
120 #define WL_PRIMARY_KEY  (1 << 1)        /* Indicates this key is the primary (ie tx) key */
121 #define WL_KF_RES_4     (1 << 4)        /* Reserved for backward compat */
122 #define WL_KF_RES_5     (1 << 5)        /* Reserved for backward compat */
123 #define WL_IBSS_PEER_GROUP_KEY  (1 << 6)        /* Indicates a group key for a IBSS PEER */
124
125 /* optionally set by a module_param_string() */
126 #define MOD_PARAM_PATHLEN       2048
127
128 /* For supporting multiple interfaces */
129 #define DHD_MAX_IFS     16
130 #define DHD_DEL_IF      -0xe
131 #define DHD_BAD_IF      -0xf
132
133 #define DOT11_BSSTYPE_ANY                       2
134 #define DOT11_MAX_DEFAULT_KEYS  4
135
136 #define BRCMF_EVENT_MSG_LINK            0x01
137 #define BRCMF_EVENT_MSG_FLUSHTXQ        0x02
138 #define BRCMF_EVENT_MSG_GROUP           0x04
139
140 typedef struct brcmf_event_msg {
141         u16 version;
142         u16 flags;
143         u32 event_type;
144         u32 status;
145         u32 reason;
146         u32 auth_type;
147         u32 datalen;
148         u8 addr[ETH_ALEN];
149         char ifname[IFNAMSIZ];
150 } __packed brcmf_event_msg_t;
151
152 struct brcm_ethhdr {
153         u16 subtype;
154         u16 length;
155         u8 version;
156         u8 oui[3];
157         u16 usr_subtype;
158 } __packed;
159
160 typedef struct brcmf_event {
161         struct ethhdr eth;
162         struct brcm_ethhdr hdr;
163         struct brcmf_event_msg msg;
164 } __packed brcmf_event_t;
165
166 #define BRCMF_E_SET_SSID                        0
167 #define BRCMF_E_JOIN                            1
168 #define BRCMF_E_START                           2
169 #define BRCMF_E_AUTH                            3
170 #define BRCMF_E_AUTH_IND                        4
171 #define BRCMF_E_DEAUTH                          5
172 #define BRCMF_E_DEAUTH_IND                      6
173 #define BRCMF_E_ASSOC                           7
174 #define BRCMF_E_ASSOC_IND                       8
175 #define BRCMF_E_REASSOC                         9
176 #define BRCMF_E_REASSOC_IND                     10
177 #define BRCMF_E_DISASSOC                        11
178 #define BRCMF_E_DISASSOC_IND                    12
179 #define BRCMF_E_QUIET_START                     13
180 #define BRCMF_E_QUIET_END                       14
181 #define BRCMF_E_BEACON_RX                       15
182 #define BRCMF_E_LINK                            16
183 #define BRCMF_E_MIC_ERROR                       17
184 #define BRCMF_E_NDIS_LINK                       18
185 #define BRCMF_E_ROAM                            19
186 #define BRCMF_E_TXFAIL                          20
187 #define BRCMF_E_PMKID_CACHE                     21
188 #define BRCMF_E_RETROGRADE_TSF                  22
189 #define BRCMF_E_PRUNE                           23
190 #define BRCMF_E_AUTOAUTH                        24
191 #define BRCMF_E_EAPOL_MSG                       25
192 #define BRCMF_E_SCAN_COMPLETE                   26
193 #define BRCMF_E_ADDTS_IND                       27
194 #define BRCMF_E_DELTS_IND                       28
195 #define BRCMF_E_BCNSENT_IND                     29
196 #define BRCMF_E_BCNRX_MSG                       30
197 #define BRCMF_E_BCNLOST_MSG                     31
198 #define BRCMF_E_ROAM_PREP                       32
199 #define BRCMF_E_PFN_NET_FOUND                   33
200 #define BRCMF_E_PFN_NET_LOST                    34
201 #define BRCMF_E_RESET_COMPLETE                  35
202 #define BRCMF_E_JOIN_START                      36
203 #define BRCMF_E_ROAM_START                      37
204 #define BRCMF_E_ASSOC_START                     38
205 #define BRCMF_E_IBSS_ASSOC                      39
206 #define BRCMF_E_RADIO                           40
207 #define BRCMF_E_PSM_WATCHDOG                    41
208 #define BRCMF_E_PROBREQ_MSG                     44
209 #define BRCMF_E_SCAN_CONFIRM_IND                45
210 #define BRCMF_E_PSK_SUP                         46
211 #define BRCMF_E_COUNTRY_CODE_CHANGED            47
212 #define BRCMF_E_EXCEEDED_MEDIUM_TIME            48
213 #define BRCMF_E_ICV_ERROR                       49
214 #define BRCMF_E_UNICAST_DECODE_ERROR            50
215 #define BRCMF_E_MULTICAST_DECODE_ERROR          51
216 #define BRCMF_E_TRACE                           52
217 #define BRCMF_E_IF                              54
218 #define BRCMF_E_RSSI                            56
219 #define BRCMF_E_PFN_SCAN_COMPLETE               57
220 #define BRCMF_E_EXTLOG_MSG                      58
221 #define BRCMF_E_ACTION_FRAME                    59
222 #define BRCMF_E_ACTION_FRAME_COMPLETE           60
223 #define BRCMF_E_PRE_ASSOC_IND                   61
224 #define BRCMF_E_PRE_REASSOC_IND                 62
225 #define BRCMF_E_CHANNEL_ADOPTED                 63
226 #define BRCMF_E_AP_STARTED                      64
227 #define BRCMF_E_DFS_AP_STOP                     65
228 #define BRCMF_E_DFS_AP_RESUME                   66
229 #define BRCMF_E_RESERVED1                       67
230 #define BRCMF_E_RESERVED2                       68
231 #define BRCMF_E_ESCAN_RESULT                    69
232 #define BRCMF_E_ACTION_FRAME_OFF_CHAN_COMPLETE  70
233 #define BRCMF_E_DCS_REQUEST                     73
234
235 #define BRCMF_E_FIFO_CREDIT_MAP                 74
236
237 #define BRCMF_E_LAST                            75
238
239 #define BRCMF_E_STATUS_SUCCESS                  0
240 #define BRCMF_E_STATUS_FAIL                     1
241 #define BRCMF_E_STATUS_TIMEOUT                  2
242 #define BRCMF_E_STATUS_NO_NETWORKS              3
243 #define BRCMF_E_STATUS_ABORT                    4
244 #define BRCMF_E_STATUS_NO_ACK                   5
245 #define BRCMF_E_STATUS_UNSOLICITED              6
246 #define BRCMF_E_STATUS_ATTEMPT                  7
247 #define BRCMF_E_STATUS_PARTIAL                  8
248 #define BRCMF_E_STATUS_NEWSCAN                  9
249 #define BRCMF_E_STATUS_NEWASSOC                 10
250 #define BRCMF_E_STATUS_11HQUIET                 11
251 #define BRCMF_E_STATUS_SUPPRESS                 12
252 #define BRCMF_E_STATUS_NOCHANS                  13
253 #define BRCMF_E_STATUS_CS_ABORT                 15
254 #define BRCMF_E_STATUS_ERROR                    16
255
256 #define BRCMF_E_REASON_INITIAL_ASSOC            0
257 #define BRCMF_E_REASON_LOW_RSSI                 1
258 #define BRCMF_E_REASON_DEAUTH                   2
259 #define BRCMF_E_REASON_DISASSOC                 3
260 #define BRCMF_E_REASON_BCNS_LOST                4
261 #define BRCMF_E_REASON_MINTXRATE                9
262 #define BRCMF_E_REASON_TXFAIL                   10
263
264 #define BRCMF_E_REASON_FAST_ROAM_FAILED         5
265 #define BRCMF_E_REASON_DIRECTED_ROAM            6
266 #define BRCMF_E_REASON_TSPEC_REJECTED           7
267 #define BRCMF_E_REASON_BETTER_AP                8
268
269 #define BRCMF_E_PRUNE_ENCR_MISMATCH             1
270 #define BRCMF_E_PRUNE_BCAST_BSSID               2
271 #define BRCMF_E_PRUNE_MAC_DENY                  3
272 #define BRCMF_E_PRUNE_MAC_NA                    4
273 #define BRCMF_E_PRUNE_REG_PASSV                 5
274 #define BRCMF_E_PRUNE_SPCT_MGMT                 6
275 #define BRCMF_E_PRUNE_RADAR                     7
276 #define BRCMF_E_RSN_MISMATCH                    8
277 #define BRCMF_E_PRUNE_NO_COMMON_RATES           9
278 #define BRCMF_E_PRUNE_BASIC_RATES               10
279 #define BRCMF_E_PRUNE_CIPHER_NA                 12
280 #define BRCMF_E_PRUNE_KNOWN_STA                 13
281 #define BRCMF_E_PRUNE_WDS_PEER                  15
282 #define BRCMF_E_PRUNE_QBSS_LOAD                 16
283 #define BRCMF_E_PRUNE_HOME_AP                   17
284
285 #define BRCMF_E_SUP_OTHER                       0
286 #define BRCMF_E_SUP_DECRYPT_KEY_DATA            1
287 #define BRCMF_E_SUP_BAD_UCAST_WEP128            2
288 #define BRCMF_E_SUP_BAD_UCAST_WEP40             3
289 #define BRCMF_E_SUP_UNSUP_KEY_LEN               4
290 #define BRCMF_E_SUP_PW_KEY_CIPHER               5
291 #define BRCMF_E_SUP_MSG3_TOO_MANY_IE            6
292 #define BRCMF_E_SUP_MSG3_IE_MISMATCH            7
293 #define BRCMF_E_SUP_NO_INSTALL_FLAG             8
294 #define BRCMF_E_SUP_MSG3_NO_GTK                 9
295 #define BRCMF_E_SUP_GRP_KEY_CIPHER              10
296 #define BRCMF_E_SUP_GRP_MSG1_NO_GTK             11
297 #define BRCMF_E_SUP_GTK_DECRYPT_FAIL            12
298 #define BRCMF_E_SUP_SEND_FAIL                   13
299 #define BRCMF_E_SUP_DEAUTH                      14
300
301 #define BRCMF_E_IF_ADD                          1
302 #define BRCMF_E_IF_DEL                          2
303 #define BRCMF_E_IF_CHANGE                       3
304
305 #define BRCMF_E_IF_ROLE_STA                     0
306 #define BRCMF_E_IF_ROLE_AP                      1
307 #define BRCMF_E_IF_ROLE_WDS                     2
308
309 #define BRCMF_E_LINK_BCN_LOSS                   1
310 #define BRCMF_E_LINK_DISASSOC                   2
311 #define BRCMF_E_LINK_ASSOC_REC                  3
312 #define BRCMF_E_LINK_BSSCFG_DIS                 4
313
314 enum cust_gpio_modes {
315         WLAN_RESET_ON,
316         WLAN_RESET_OFF,
317         WLAN_POWER_ON,
318         WLAN_POWER_OFF
319 };
320
321 /* The level of bus communication with the dongle */
322 enum dhd_bus_state {
323         DHD_BUS_DOWN,           /* Not ready for frame transfers */
324         DHD_BUS_LOAD,           /* Download access only (CPU reset) */
325         DHD_BUS_DATA            /* Ready for frame transfers */
326 };
327
328 /* Pattern matching filter. Specifies an offset within received packets to
329  * start matching, the pattern to match, the size of the pattern, and a bitmask
330  * that indicates which bits within the pattern should be matched.
331  */
332 typedef struct wl_pkt_filter_pattern {
333         u32 offset;             /* Offset within received packet to start pattern matching.
334                                  * Offset '0' is the first byte of the ethernet header.
335                                  */
336         u32 size_bytes; /* Size of the pattern.  Bitmask must be the same size. */
337         u8 mask_and_pattern[1]; /* Variable length mask and pattern data.  mask starts
338                                          * at offset 0.  Pattern immediately follows mask.
339                                          */
340 } wl_pkt_filter_pattern_t;
341
342 /* IOVAR "pkt_filter_add" parameter. Used to install packet filters. */
343 typedef struct wl_pkt_filter {
344         u32 id;         /* Unique filter id, specified by app. */
345         u32 type;               /* Filter type (WL_PKT_FILTER_TYPE_xxx). */
346         u32 negate_match;       /* Negate the result of filter matches */
347         union {                 /* Filter definitions */
348                 wl_pkt_filter_pattern_t pattern;        /* Pattern matching filter */
349         } u;
350 } wl_pkt_filter_t;
351
352 /* IOVAR "pkt_filter_enable" parameter. */
353 typedef struct wl_pkt_filter_enable {
354         u32 id;         /* Unique filter id */
355         u32 enable;             /* Enable/disable bool */
356 } wl_pkt_filter_enable_t;
357
358 /* BSS info structure
359  * Applications MUST CHECK ie_offset field and length field to access IEs and
360  * next bss_info structure in a vector (in wl_scan_results_t)
361  */
362 typedef struct wl_bss_info {
363         u32 version;            /* version field */
364         u32 length;             /* byte length of data in this record,
365                                  * starting at version and including IEs
366                                  */
367         u8 BSSID[ETH_ALEN];
368         u16 beacon_period;      /* units are Kusec */
369         u16 capability; /* Capability information */
370         u8 SSID_len;
371         u8 SSID[32];
372         struct {
373                 uint count;     /* # rates in this set */
374                 u8 rates[16];   /* rates in 500kbps units w/hi bit set if basic */
375         } rateset;              /* supported rates */
376         chanspec_t chanspec;    /* chanspec for bss */
377         u16 atim_window;        /* units are Kusec */
378         u8 dtim_period; /* DTIM period */
379         s16 RSSI;               /* receive signal strength (in dBm) */
380         s8 phy_noise;           /* noise (in dBm) */
381
382         u8 n_cap;               /* BSS is 802.11N Capable */
383         u32 nbss_cap;   /* 802.11N BSS Capabilities (based on HT_CAP_*) */
384         u8 ctl_ch;              /* 802.11N BSS control channel number */
385         u32 reserved32[1];      /* Reserved for expansion of BSS properties */
386         u8 flags;               /* flags */
387         u8 reserved[3]; /* Reserved for expansion of BSS properties */
388         u8 basic_mcs[MCSSET_LEN];       /* 802.11N BSS required MCS set */
389
390         u16 ie_offset;  /* offset at which IEs start, from beginning */
391         u32 ie_length;  /* byte length of Information Elements */
392         s16 SNR;                /* average SNR of during frame reception */
393         /* Add new fields here */
394         /* variable length Information Elements */
395 } wl_bss_info_t;
396
397 typedef struct wlc_ssid {
398         u32 SSID_len;
399         unsigned char SSID[32];
400 } wlc_ssid_t;
401
402 typedef struct wl_scan_params {
403         wlc_ssid_t ssid;        /* default: {0, ""} */
404         u8 bssid[ETH_ALEN];     /* default: bcast */
405         s8 bss_type;            /* default: any,
406                                  * DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT
407                                  */
408         u8 scan_type;   /* flags, 0 use default */
409         s32 nprobes;            /* -1 use default, number of probes per channel */
410         s32 active_time;        /* -1 use default, dwell time per channel for
411                                  * active scanning
412                                  */
413         s32 passive_time;       /* -1 use default, dwell time per channel
414                                  * for passive scanning
415                                  */
416         s32 home_time;  /* -1 use default, dwell time for the home channel
417                                  * between channel scans
418                                  */
419         s32 channel_num;        /* count of channels and ssids that follow
420                                  *
421                                  * low half is count of channels in channel_list, 0
422                                  * means default (use all available channels)
423                                  *
424                                  * high half is entries in wlc_ssid_t array that
425                                  * follows channel_list, aligned for s32 (4 bytes)
426                                  * meaning an odd channel count implies a 2-byte pad
427                                  * between end of channel_list and first ssid
428                                  *
429                                  * if ssid count is zero, single ssid in the fixed
430                                  * parameter portion is assumed, otherwise ssid in
431                                  * the fixed portion is ignored
432                                  */
433         u16 channel_list[1];    /* list of chanspecs */
434 } wl_scan_params_t;
435
436 /* incremental scan struct */
437 typedef struct wl_iscan_params {
438         u32 version;
439         u16 action;
440         u16 scan_duration;
441         wl_scan_params_t params;
442 } wl_iscan_params_t;
443
444 /* 3 fields + size of wl_scan_params, not including variable length array */
445 #define WL_ISCAN_PARAMS_FIXED_SIZE (offsetof(wl_iscan_params_t, params) + sizeof(wlc_ssid_t))
446
447 typedef struct wl_scan_results {
448         u32 buflen;
449         u32 version;
450         u32 count;
451         wl_bss_info_t bss_info[1];
452 } wl_scan_results_t;
453
454 typedef struct wl_rateset_args {
455         u32 count;              /* # rates in this set */
456         u8 rates[WL_NUMRATES];  /* rates in 500kbps units w/hi bit set if basic */
457         u8 mcs[MCSSET_LEN];     /* supported mcs index bit map */
458 } wl_rateset_args_t;
459
460 /* u32 list */
461 typedef struct wl_u32_list {
462         /* in - # of elements, out - # of entries */
463         u32 count;
464         /* variable length u32 list */
465         u32 element[1];
466 } wl_u32_list_t;
467
468 /* used for association with a specific BSSID and chanspec list */
469 typedef struct wl_assoc_params {
470         u8 bssid[ETH_ALEN];     /* 00:00:00:00:00:00: broadcast scan */
471         s32 chanspec_num;       /* 0: all available channels,
472                                  * otherwise count of chanspecs in chanspec_list
473                                  */
474         chanspec_t chanspec_list[1];    /* list of chanspecs */
475 } wl_assoc_params_t;
476 #define WL_ASSOC_PARAMS_FIXED_SIZE      (sizeof(wl_assoc_params_t) - sizeof(chanspec_t))
477
478 /* used for reassociation/roam to a specific BSSID and channel */
479 typedef wl_assoc_params_t wl_reassoc_params_t;
480
481 /* used for join with or without a specific bssid and channel list */
482 typedef struct wl_join_params {
483         wlc_ssid_t ssid;
484         wl_assoc_params_t params;       /* optional field, but it must include the fixed portion
485                                          * of the wl_assoc_params_t struct when it does present.
486                                          */
487 } wl_join_params_t;
488
489 /* size of wl_scan_results not including variable length array */
490 #define WL_SCAN_RESULTS_FIXED_SIZE (sizeof(wl_scan_results_t) - sizeof(wl_bss_info_t))
491
492 /* incremental scan results struct */
493 typedef struct wl_iscan_results {
494         u32 status;
495         wl_scan_results_t results;
496 } wl_iscan_results_t;
497
498 /* size of wl_iscan_results not including variable length array */
499 #define WL_ISCAN_RESULTS_FIXED_SIZE \
500         (WL_SCAN_RESULTS_FIXED_SIZE + offsetof(wl_iscan_results_t, results))
501
502 typedef struct {
503         u32 duration;   /* millisecs spent sampling this channel */
504         u32 congest_ibss;       /* millisecs in our bss (presumably this traffic will */
505         /*  move if cur bss moves channels) */
506         u32 congest_obss;       /* traffic not in our bss */
507         u32 interference;       /* millisecs detecting a non 802.11 interferer. */
508         u32 timestamp;  /* second timestamp */
509 } cca_congest_t;
510
511 typedef struct {
512         chanspec_t chanspec;    /* Which channel? */
513         u8 num_secs;            /* How many secs worth of data */
514         cca_congest_t secs[1];  /* Data */
515 } cca_congest_channel_req_t;
516
517 typedef struct wl_country {
518         char country_abbrev[WLC_CNTRY_BUF_SZ];  /* nul-terminated country code used in
519                                                  * the Country IE
520                                                  */
521         s32 rev;                /* revision specifier for ccode
522                                  * on set, -1 indicates unspecified.
523                                  * on get, rev >= 0
524                                  */
525         char ccode[WLC_CNTRY_BUF_SZ];   /* nul-terminated built-in country code.
526                                          * variable length, but fixed size in
527                                          * struct allows simple allocation for
528                                          * expected country strings <= 3 chars.
529                                          */
530 } wl_country_t;
531
532 typedef struct wl_channels_in_country {
533         u32 buflen;
534         u32 band;
535         char country_abbrev[WLC_CNTRY_BUF_SZ];
536         u32 count;
537         u32 channel[1];
538 } wl_channels_in_country_t;
539
540 typedef struct wl_country_list {
541         u32 buflen;
542         u32 band_set;
543         u32 band;
544         u32 count;
545         char country_abbrev[1];
546 } wl_country_list_t;
547
548 typedef struct wl_rm_req_elt {
549         s8 type;
550         s8 flags;
551         chanspec_t chanspec;
552         u32 token;              /* token for this measurement */
553         u32 tsf_h;              /* TSF high 32-bits of Measurement start time */
554         u32 tsf_l;              /* TSF low 32-bits */
555         u32 dur;                /* TUs */
556 } wl_rm_req_elt_t;
557
558 typedef struct wl_rm_req {
559         u32 token;              /* overall measurement set token */
560         u32 count;              /* number of measurement requests */
561         void *cb;               /* completion callback function: may be NULL */
562         void *cb_arg;           /* arg to completion callback function */
563         wl_rm_req_elt_t req[1]; /* variable length block of requests */
564 } wl_rm_req_t;
565
566 typedef struct wl_rm_rep_elt {
567         s8 type;
568         s8 flags;
569         chanspec_t chanspec;
570         u32 token;              /* token for this measurement */
571         u32 tsf_h;              /* TSF high 32-bits of Measurement start time */
572         u32 tsf_l;              /* TSF low 32-bits */
573         u32 dur;                /* TUs */
574         u32 len;                /* byte length of data block */
575         u8 data[1];             /* variable length data block */
576 } wl_rm_rep_elt_t;
577
578 #define WL_RPI_REP_BIN_NUM 8
579 typedef struct wl_rm_rpi_rep {
580         u8 rpi[WL_RPI_REP_BIN_NUM];
581         s8 rpi_max[WL_RPI_REP_BIN_NUM];
582 } wl_rm_rpi_rep_t;
583
584 typedef struct wl_rm_rep {
585         u32 token;              /* overall measurement set token */
586         u32 len;                /* length of measurement report block */
587         wl_rm_rep_elt_t rep[1]; /* variable length block of reports */
588 } wl_rm_rep_t;
589
590 typedef struct wl_wsec_key {
591         u32 index;              /* key index */
592         u32 len;                /* key length */
593         u8 data[WLAN_MAX_KEY_LEN];      /* key data */
594         u32 pad_1[18];
595         u32 algo;               /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
596         u32 flags;              /* misc flags */
597         u32 pad_2[2];
598         int pad_3;
599         int iv_initialized;     /* has IV been initialized already? */
600         int pad_4;
601         /* Rx IV */
602         struct {
603                 u32 hi; /* upper 32 bits of IV */
604                 u16 lo; /* lower 16 bits of IV */
605         } rxiv;
606         u32 pad_5[2];
607         u8 ea[ETH_ALEN];        /* per station */
608 } wl_wsec_key_t;
609
610 /* Used to get specific STA parameters */
611 typedef struct {
612         u32 val;
613         u8 ea[ETH_ALEN];
614 } scb_val_t;
615
616 /* channel encoding */
617 typedef struct channel_info {
618         int hw_channel;
619         int target_channel;
620         int scan_channel;
621 } channel_info_t;
622
623 /* Linux network driver ioctl encoding */
624 typedef struct wl_ioctl {
625         uint cmd;               /* common ioctl definition */
626         void *buf;              /* pointer to user buffer */
627         uint len;               /* length of user buffer */
628         u8 set;         /* get or set request (optional) */
629         uint used;              /* bytes read or written (optional) */
630         uint needed;            /* bytes needed (optional) */
631 } wl_ioctl_t;
632
633 /* Forward decls for struct dhd_pub (see below) */
634 struct dhd_bus;         /* device bus info */
635 struct brcmf_proto;     /* device communication protocol info */
636 struct dhd_info;        /* device driver info */
637
638 /* Common structure for module and instance linkage */
639 typedef struct dhd_pub {
640         /* Linkage ponters */
641         struct dhd_bus *bus;
642         struct brcmf_proto *prot;
643         struct dhd_info *info;
644
645         /* Internal dhd items */
646         bool up;                /* Driver up/down (to OS) */
647         bool txoff;             /* Transmit flow-controlled */
648         bool dongle_reset;      /* true = DEVRESET put dongle into reset */
649         enum dhd_bus_state busstate;
650         uint hdrlen;            /* Total DHD header length (proto + bus) */
651         uint maxctl;            /* Max size rxctl request from proto to bus */
652         uint rxsz;              /* Rx buffer size bus module should use */
653         u8 wme_dp;              /* wme discard priority */
654
655         /* Dongle media info */
656         bool iswl;              /* Dongle-resident driver is wl */
657         unsigned long drv_version;      /* Version of dongle-resident driver */
658         u8 mac[ETH_ALEN];                       /* MAC address obtained from dongle */
659         dngl_stats_t dstats;            /* Stats for dongle-based data */
660
661         /* Additional stats for the bus level */
662         unsigned long tx_packets;       /* Data packets sent to dongle */
663         unsigned long tx_multicast;     /* Multicast data packets sent to dongle */
664         unsigned long tx_errors;        /* Errors in sending data to dongle */
665         unsigned long tx_ctlpkts;       /* Control packets sent to dongle */
666         unsigned long tx_ctlerrs;       /* Errors sending control frames to dongle */
667         unsigned long rx_packets;       /* Packets sent up the network interface */
668         unsigned long rx_multicast;     /* Multicast packets sent up the network
669                                          interface */
670         unsigned long rx_errors;        /* Errors processing rx data packets */
671         unsigned long rx_ctlpkts;       /* Control frames processed from dongle */
672         unsigned long rx_ctlerrs;       /* Errors in processing rx control frames */
673         unsigned long rx_dropped;       /* Packets dropped locally (no memory) */
674         unsigned long rx_flushed;       /* Packets flushed due to
675                                 unscheduled sendup thread */
676         unsigned long wd_dpc_sched;     /* Number of times dhd dpc scheduled by
677                                          watchdog timer */
678
679         unsigned long rx_readahead_cnt; /* Number of packets where header read-ahead
680                                          was used. */
681         unsigned long tx_realloc;       /* Number of tx packets we had to realloc for
682                                          headroom */
683         unsigned long fc_packets;       /* Number of flow control pkts recvd */
684
685         /* Last error return */
686         int bcmerror;
687         uint tickcnt;
688
689         /* Last error from dongle */
690         int dongle_error;
691
692         /* Suspend disable flag  flag */
693         int suspend_disable_flag;       /* "1" to disable all extra powersaving
694                                          during suspend */
695         int in_suspend;         /* flag set to 1 when early suspend called */
696         int dtim_skip;          /* dtim skip , default 0 means wake each dtim */
697
698         /* Pkt filter defination */
699         char *pktfilter[100];
700         int pktfilter_count;
701
702         u8 country_code[WLC_CNTRY_BUF_SZ];
703         char eventmask[WL_EVENTING_MASK_LEN];
704
705 } dhd_pub_t;
706
707 typedef struct dhd_if_event {
708         u8 ifidx;
709         u8 action;
710         u8 flags;
711         u8 bssidx;
712 } dhd_if_event_t;
713
714 typedef struct {
715         u32 limit;              /* Expiration time (usec) */
716         u32 increment;  /* Current expiration increment (usec) */
717         u32 elapsed;            /* Current elapsed time (usec) */
718         u32 tick;               /* O/S tick time (usec) */
719 } dhd_timeout_t;
720
721 typedef struct {
722         uint event;
723         const char *name;
724 } bcmevent_name_t;
725
726 #if defined(CONFIG_PM_SLEEP)
727 extern atomic_t brcmf_mmc_suspend;
728 #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
729 #define _DHD_PM_RESUME_WAIT(a, b) do { \
730                 int retry = 0; \
731                 while (atomic_read(&brcmf_mmc_suspend) && retry++ != b) { \
732                         wait_event_timeout(a, false, HZ/100); \
733                 } \
734         }       while (0)
735 #define DHD_PM_RESUME_WAIT(a)   _DHD_PM_RESUME_WAIT(a, 30)
736 #define DHD_PM_RESUME_WAIT_FOREVER(a)   _DHD_PM_RESUME_WAIT(a, ~0)
737 #define DHD_PM_RESUME_RETURN_ERROR(a)   \
738         do { if (atomic_read(&brcmf_mmc_suspend)) return a; } while (0)
739 #define DHD_PM_RESUME_RETURN    do { \
740         if (atomic_read(&brcmf_mmc_suspend)) \
741                 return; \
742         } while (0)
743
744 #define DHD_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
745 #define SPINWAIT_SLEEP(a, exp, us) do { \
746                 uint countdown = (us) + 9999; \
747                 while ((exp) && (countdown >= 10000)) { \
748                         wait_event_timeout(a, false, HZ/100); \
749                         countdown -= 10000; \
750                 } \
751         } while (0)
752
753 #else
754
755 #define DHD_PM_RESUME_WAIT_INIT(a)
756 #define DHD_PM_RESUME_WAIT(a)
757 #define DHD_PM_RESUME_WAIT_FOREVER(a)
758 #define DHD_PM_RESUME_RETURN_ERROR(a)
759 #define DHD_PM_RESUME_RETURN
760
761 #define DHD_SPINWAIT_SLEEP_INIT(a)
762 #define SPINWAIT_SLEEP(a, exp, us)  do { \
763                 uint countdown = (us) + 9; \
764                 while ((exp) && (countdown >= 10)) { \
765                         udelay(10);  \
766                         countdown -= 10;  \
767                 } \
768         } while (0)
769
770 #endif  /* defined(CONFIG_PM_SLEEP) */
771
772 /*
773  * Insmod parameters for debug/test
774  */
775
776 /* Use interrupts */
777 extern uint brcmf_intr;
778
779 /* Use polling */
780 extern uint brcmf_poll;
781
782 /* ARP offload agent mode */
783 extern uint brcmf_arp_mode;
784
785 /* ARP offload enable */
786 extern uint brcmf_arp_enable;
787
788 /* Pkt filte enable control */
789 extern uint brcmf_pkt_filter_enable;
790
791 /*  Pkt filter init setup */
792 extern uint brcmf_pkt_filter_init;
793
794 /* Pkt filter mode control */
795 extern uint brcmf_master_mode;
796
797 /* Roaming mode control */
798 extern uint brcmf_roam;
799
800 /* Roaming mode control */
801 extern uint brcmf_radio_up;
802
803 /* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */
804 extern int brcmf_idletime;
805 #define BRCMF_IDLETIME_TICKS 1
806
807 /* SDIO Drive Strength */
808 extern uint brcmf_sdiod_drive_strength;
809
810 /* Override to force tx queueing all the time */
811 extern uint brcmf_force_tx_queueing;
812
813 /* thread priority for watchdog and dpc */
814 extern int brcmf_watchdog_prio;
815 extern int brcmf_dpc_prio;
816
817 #ifdef SDTEST
818 /* Echo packet generator (SDIO), pkts/s */
819 extern uint brcmf_pktgen;
820
821 /* Echo packet len (0 => sawtooth, max 1800) */
822 extern uint brcmf_pktgen_len;
823 #define BRCMF_MAX_PKTGEN_LEN 1800
824 #endif
825
826 extern char brcmf_fw_path[MOD_PARAM_PATHLEN];
827 extern char brcmf_nv_path[MOD_PARAM_PATHLEN];
828
829 extern u32 g_assert_type;
830 extern const bcmevent_name_t bcmevent_names[];
831 extern const int bcmevent_names_size;
832
833
834 static inline void MUTEX_LOCK_INIT(dhd_pub_t *dhdp)
835 {
836 }
837
838 static inline void MUTEX_LOCK(dhd_pub_t *dhdp)
839 {
840 }
841
842 static inline void MUTEX_UNLOCK(dhd_pub_t *dhdp)
843 {
844 }
845
846 static inline void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t *dhdp)
847 {
848 }
849
850 static inline void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t *dhdp)
851 {
852 }
853
854 static inline void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t *dhdp)
855 {
856 }
857
858 static inline void MUTEX_LOCK_WL_SCAN_SET_INIT(void)
859 {
860 }
861
862 static inline void MUTEX_LOCK_WL_SCAN_SET(void)
863 {
864 }
865
866 static inline void MUTEX_UNLOCK_WL_SCAN_SET(void)
867 {
868 }
869
870 /*
871  * Exported from dhd OS modules (dhd_linux/dhd_ndis)
872  */
873
874 /* Indication from bus module regarding presence/insertion of dongle.
875  * Return dhd_pub_t pointer, used as handle to OS module in later calls.
876  * Returned structure should have bus and prot pointers filled in.
877  * bus_hdrlen specifies required headroom for bus module header.
878  */
879 extern dhd_pub_t *brcmf_attach(struct dhd_bus *bus,
880                                 uint bus_hdrlen);
881 extern int brcmf_net_attach(dhd_pub_t *dhdp, int idx);
882 extern int brcmf_netdev_wait_pend8021x(struct net_device *dev);
883
884 /* Indication from bus module regarding removal/absence of dongle */
885 extern void brcmf_detach(dhd_pub_t *dhdp);
886
887 /* Indication from bus module to change flow-control state */
888 extern void brcmf_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool on);
889
890 extern bool brcmf_c_prec_enq(dhd_pub_t *dhdp, struct pktq *q,
891                          struct sk_buff *pkt, int prec);
892
893 /* Receive frame for delivery to OS.  Callee disposes of rxp. */
894 extern void brcmf_rx_frame(dhd_pub_t *dhdp, int ifidx,
895                          struct sk_buff *rxp, int numpkt);
896
897 /* Return pointer to interface name */
898 extern char *brcmf_ifname(dhd_pub_t *dhdp, int idx);
899
900 /* Request scheduling of the bus dpc */
901 extern void brcmf_sched_dpc(dhd_pub_t *dhdp);
902
903 /* Notify tx completion */
904 extern void brcmf_txcomplete(dhd_pub_t *dhdp, struct sk_buff *txp,
905                              bool success);
906
907 /* Query ioctl */
908 extern int brcmf_proto_cdc_query_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd,
909                                        void *buf, uint len);
910
911 /* OS independent layer functions */
912 extern int brcmf_os_proto_block(dhd_pub_t *pub);
913 extern int brcmf_os_proto_unblock(dhd_pub_t *pub);
914 extern int brcmf_os_ioctl_resp_wait(dhd_pub_t *pub, uint *condition,
915                                   bool *pending);
916 extern int brcmf_os_ioctl_resp_wake(dhd_pub_t *pub);
917 extern unsigned int brcmf_os_get_ioctl_resp_timeout(void);
918 extern void brcmf_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
919 extern void *brcmf_os_open_image(char *filename);
920 extern int brcmf_os_get_image_block(char *buf, int len, void *image);
921 extern void brcmf_os_close_image(void *image);
922 extern void brcmf_os_sdlock(dhd_pub_t *pub);
923 extern void brcmf_os_sdunlock(dhd_pub_t *pub);
924 extern void brcmf_os_sdlock_sndup_rxq(dhd_pub_t *pub);
925 extern void brcmf_customer_gpio_wlan_ctrl(int onoff);
926 extern int brcmf_custom_get_mac_address(unsigned char *buf);
927 extern void brcmf_os_sdunlock_sndup_rxq(dhd_pub_t *pub);
928 extern void brcmf_os_sdlock_eventq(dhd_pub_t *pub);
929 extern void brcmf_os_sdunlock_eventq(dhd_pub_t *pub);
930 #ifdef BCMDBG
931 extern int brcmf_write_to_file(dhd_pub_t *dhd, u8 *buf, int size);
932 #endif                          /* BCMDBG */
933
934 extern void brcmf_timeout_start(dhd_timeout_t *tmo, uint usec);
935 extern int brcmf_timeout_expired(dhd_timeout_t *tmo);
936
937 extern int brcmf_ifname2idx(struct dhd_info *dhd, char *name);
938 extern int brcmf_c_host_event(struct dhd_info *dhd, int *idx, void *pktdata,
939                          brcmf_event_msg_t *, void **data_ptr);
940
941 extern void brcmf_c_init(void);
942
943 extern int brcmf_add_if(struct dhd_info *dhd, int ifidx, void *handle,
944                       char *name, u8 *mac_addr, u32 flags, u8 bssidx);
945 extern void brcmf_del_if(struct dhd_info *dhd, int ifidx);
946
947 extern void brcmf_vif_add(struct dhd_info *dhd, int ifidx, char *name);
948 extern void brcmf_vif_del(struct dhd_info *dhd, int ifidx);
949
950 extern void brcmf_event(struct dhd_info *dhd, char *evpkt, int evlen,
951                         int ifidx);
952 extern void brcmf_vif_sendup(struct dhd_info *dhd, int ifidx,
953                              unsigned char *cp, int len);
954
955 /* Send packet to dongle via data channel */
956 extern int brcmf_sendpkt(dhd_pub_t *dhdp, int ifidx, struct sk_buff *pkt);
957
958 extern int brcmf_bus_devreset(dhd_pub_t *dhdp, u8 flag);
959 extern int brcmf_bus_start(dhd_pub_t *dhdp);
960
961 extern void brcmf_c_pktfilter_offload_set(dhd_pub_t *dhd, char *arg);
962 extern void brcmf_c_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg,
963                                              int enable, int master_mode);
964
965 #ifdef BCMDBG
966 #define ASSERT(exp) \
967           do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0)
968 extern void osl_assert(char *exp, char *file, int line);
969 #else
970 #define ASSERT(exp)     do {} while (0)
971 #endif  /* defined(BCMDBG) */
972
973 /* Linux network driver ioctl encoding */
974 typedef struct dhd_ioctl {
975         uint cmd;               /* common ioctl definition */
976         void *buf;              /* pointer to user buffer */
977         uint len;               /* length of user buffer */
978         bool set;               /* get or set request (optional) */
979         uint used;              /* bytes read or written (optional) */
980         uint needed;            /* bytes needed (optional) */
981         uint driver;            /* to identify target driver */
982 } dhd_ioctl_t;
983
984 /* per-driver magic numbers */
985 #define DHD_IOCTL_MAGIC         0x00444944
986
987 /* bump this number if you change the ioctl interface */
988 #define DHD_IOCTL_VERSION       1
989
990 #define DHD_IOCTL_MAXLEN        8192    /* max length ioctl buffer required */
991 #define DHD_IOCTL_SMLEN 256     /* "small" length ioctl buffer required */
992
993 /* common ioctl definitions */
994 #define DHD_GET_MAGIC                           0
995 #define DHD_GET_VERSION                         1
996 #define DHD_GET_VAR                             2
997 #define DHD_SET_VAR                             3
998
999 /* message levels */
1000 #define DHD_ERROR_VAL   0x0001
1001 #define DHD_TRACE_VAL   0x0002
1002 #define DHD_INFO_VAL    0x0004
1003 #define DHD_DATA_VAL    0x0008
1004 #define DHD_CTL_VAL     0x0010
1005 #define DHD_TIMER_VAL   0x0020
1006 #define DHD_HDRS_VAL    0x0040
1007 #define DHD_BYTES_VAL   0x0080
1008 #define DHD_INTR_VAL    0x0100
1009 #define DHD_LOG_VAL     0x0200
1010 #define DHD_GLOM_VAL    0x0400
1011 #define DHD_EVENT_VAL   0x0800
1012 #define DHD_BTA_VAL     0x1000
1013 #define DHD_ISCAN_VAL 0x2000
1014
1015 #ifdef SDTEST
1016 /* For pktgen iovar */
1017 typedef struct brcmf_pktgen {
1018         uint version;           /* To allow structure change tracking */
1019         uint freq;              /* Max ticks between tx/rx attempts */
1020         uint count;             /* Test packets to send/rcv each attempt */
1021         uint print;             /* Print counts every <print> attempts */
1022         uint total;             /* Total packets (or bursts) */
1023         uint minlen;            /* Minimum length of packets to send */
1024         uint maxlen;            /* Maximum length of packets to send */
1025         uint numsent;           /* Count of test packets sent */
1026         uint numrcvd;           /* Count of test packets received */
1027         uint numfail;           /* Count of test send failures */
1028         uint mode;              /* Test mode (type of test packets) */
1029         uint stop;              /* Stop after this many tx failures */
1030 } brcmf_pktgen_t;
1031
1032 /* Version in case structure changes */
1033 #define DHD_PKTGEN_VERSION 2
1034
1035 /* Type of test packets to use */
1036 #define DHD_PKTGEN_ECHO         1       /* Send echo requests */
1037 #define DHD_PKTGEN_SEND         2       /* Send discard packets */
1038 #define DHD_PKTGEN_RXBURST      3       /* Request dongle send N packets */
1039 #define DHD_PKTGEN_RECV         4       /* Continuous rx from continuous
1040                                          tx dongle */
1041 #endif                          /* SDTEST */
1042
1043 /* Enter idle immediately (no timeout) */
1044 #define DHD_IDLE_IMMEDIATE      (-1)
1045
1046 /* Values for idleclock iovar: other values are the sd_divisor to use
1047          when idle */
1048 #define DHD_IDLE_ACTIVE 0       /* Do not request any SD clock change
1049                                  when idle */
1050 #define DHD_IDLE_STOP   (-1)    /* Request SD clock be stopped
1051                                  (and use SD1 mode) */
1052
1053 #endif                          /* _dhd_h_ */