]> git.karo-electronics.de Git - mv-sheeva.git/blob - drivers/staging/brcm80211/brcmfmac/dhd.h
staging: brcm80211: remove unused definitions from dhd.h
[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 /* Forward decls */
25 struct dhd_bus;
26 struct dhd_prot;
27 struct dhd_info;
28
29 #define BRCMF_C_IOCTL_SMLEN     256     /* "small" ioctl buffer required */
30 #define BRCMF_C_IOCTL_MEDLEN    1536    /* "med" ioctl buffer required */
31 #define BRCMF_C_IOCTL_MAXLEN    8192
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 WL_PKT_FILTER_FIXED_LEN           offsetof(wl_pkt_filter_t, u)
90 #define WL_PKT_FILTER_PATTERN_FIXED_LEN   offsetof(wl_pkt_filter_pattern_t, mask_and_pattern)
91
92 #define WL_EVENTING_MASK_LEN    16
93
94 #define TOE_TX_CSUM_OL          0x00000001
95 #define TOE_RX_CSUM_OL          0x00000002
96
97 /* maximum channels returned by the get valid channels iovar */
98 #define WL_NUMCHANNELS          64
99
100 #define WL_BSS_INFO_VERSION     108     /* current ver of wl_bss_info struct */
101
102 /* size of wl_scan_params not including variable length array */
103 #define WL_SCAN_PARAMS_FIXED_SIZE 64
104
105 /* masks for channel and ssid count */
106 #define WL_SCAN_PARAMS_COUNT_MASK 0x0000ffff
107 #define WL_SCAN_PARAMS_NSSID_SHIFT 16
108
109 #define WL_SCAN_ACTION_START      1
110 #define WL_SCAN_ACTION_CONTINUE   2
111 #define WL_SCAN_ACTION_ABORT      3
112
113 #define ISCAN_REQ_VERSION 1
114
115 /* wl_iscan_results status values */
116 #define WL_SCAN_RESULTS_SUCCESS 0
117 #define WL_SCAN_RESULTS_PARTIAL 1
118 #define WL_SCAN_RESULTS_PENDING 2
119 #define WL_SCAN_RESULTS_ABORTED 3
120 #define WL_SCAN_RESULTS_NO_MEM  4
121
122 #define WL_SOFT_KEY     (1 << 0)        /* Indicates this key is using soft encrypt */
123 #define WL_PRIMARY_KEY  (1 << 1)        /* Indicates this key is the primary (ie tx) key */
124 #define WL_KF_RES_4     (1 << 4)        /* Reserved for backward compat */
125 #define WL_KF_RES_5     (1 << 5)        /* Reserved for backward compat */
126 #define WL_IBSS_PEER_GROUP_KEY  (1 << 6)        /* Indicates a group key for a IBSS PEER */
127
128 /* optionally set by a module_param_string() */
129 #define MOD_PARAM_PATHLEN       2048
130
131 /* For supporting multiple interfaces */
132 #define DHD_MAX_IFS     16
133 #define DHD_DEL_IF      -0xe
134 #define DHD_BAD_IF      -0xf
135
136 #define DOT11_BSSTYPE_ANY                       2
137 #define DOT11_MAX_DEFAULT_KEYS  4
138
139 #define BCM_MSG_IFNAME_MAX              16
140
141 #define WLC_EVENT_MSG_LINK              0x01
142 #define WLC_EVENT_MSG_FLUSHTXQ          0x02
143 #define WLC_EVENT_MSG_GROUP             0x04
144
145 typedef struct {
146         u16 version;
147         u16 flags;
148         u32 event_type;
149         u32 status;
150         u32 reason;
151         u32 auth_type;
152         u32 datalen;
153         u8 addr[ETH_ALEN];
154         char ifname[BCM_MSG_IFNAME_MAX];
155 } __attribute__((packed)) wl_event_msg_t;
156
157 typedef  struct bcmeth_hdr {
158         u16 subtype;
159         u16 length;
160         u8 version;
161         u8 oui[3];
162         u16 usr_subtype;
163 } __attribute__((packed)) bcmeth_hdr_t;
164
165 #ifdef BRCM_FULLMAC
166 typedef struct bcm_event {
167         struct ethhdr eth;
168         bcmeth_hdr_t            bcm_hdr;
169         wl_event_msg_t          event;
170 } __attribute__((packed)) bcm_event_t;
171 #endif
172 #define BCM_MSG_LEN     (sizeof(bcm_event_t) - sizeof(bcmeth_hdr_t) - \
173         sizeof(struct ether_header))
174
175 #define WLC_E_SET_SSID          0
176 #define WLC_E_JOIN              1
177 #define WLC_E_START             2
178 #define WLC_E_AUTH              3
179 #define WLC_E_AUTH_IND          4
180 #define WLC_E_DEAUTH            5
181 #define WLC_E_DEAUTH_IND        6
182 #define WLC_E_ASSOC             7
183 #define WLC_E_ASSOC_IND         8
184 #define WLC_E_REASSOC           9
185 #define WLC_E_REASSOC_IND       10
186 #define WLC_E_DISASSOC          11
187 #define WLC_E_DISASSOC_IND      12
188 #define WLC_E_QUIET_START       13
189 #define WLC_E_QUIET_END         14
190 #define WLC_E_BEACON_RX         15
191 #define WLC_E_LINK              16
192 #define WLC_E_MIC_ERROR         17
193 #define WLC_E_NDIS_LINK         18
194 #define WLC_E_ROAM              19
195 #define WLC_E_TXFAIL            20
196 #define WLC_E_PMKID_CACHE       21
197 #define WLC_E_RETROGRADE_TSF    22
198 #define WLC_E_PRUNE             23
199 #define WLC_E_AUTOAUTH          24
200 #define WLC_E_EAPOL_MSG         25
201 #define WLC_E_SCAN_COMPLETE     26
202 #define WLC_E_ADDTS_IND         27
203 #define WLC_E_DELTS_IND         28
204 #define WLC_E_BCNSENT_IND       29
205 #define WLC_E_BCNRX_MSG         30
206 #define WLC_E_BCNLOST_MSG       31
207 #define WLC_E_ROAM_PREP         32
208 #define WLC_E_PFN_NET_FOUND     33
209 #define WLC_E_PFN_NET_LOST      34
210 #define WLC_E_RESET_COMPLETE    35
211 #define WLC_E_JOIN_START        36
212 #define WLC_E_ROAM_START        37
213 #define WLC_E_ASSOC_START       38
214 #define WLC_E_IBSS_ASSOC        39
215 #define WLC_E_RADIO             40
216 #define WLC_E_PSM_WATCHDOG      41
217 #define WLC_E_PROBREQ_MSG       44
218 #define WLC_E_SCAN_CONFIRM_IND  45
219 #define WLC_E_PSK_SUP           46
220 #define WLC_E_COUNTRY_CODE_CHANGED 47
221 #define WLC_E_EXCEEDED_MEDIUM_TIME 48
222 #define WLC_E_ICV_ERROR         49
223 #define WLC_E_UNICAST_DECODE_ERROR 50
224 #define WLC_E_MULTICAST_DECODE_ERROR 51
225 #define WLC_E_TRACE             52
226 #define WLC_E_IF                54
227 #define WLC_E_RSSI              56
228 #define WLC_E_PFN_SCAN_COMPLETE 57
229 #define WLC_E_EXTLOG_MSG        58
230 #define WLC_E_ACTION_FRAME      59
231 #define WLC_E_ACTION_FRAME_COMPLETE 60
232 #define WLC_E_PRE_ASSOC_IND     61
233 #define WLC_E_PRE_REASSOC_IND   62
234 #define WLC_E_CHANNEL_ADOPTED   63
235 #define WLC_E_AP_STARTED        64
236 #define WLC_E_DFS_AP_STOP       65
237 #define WLC_E_DFS_AP_RESUME     66
238 #define WLC_E_RESERVED1         67
239 #define WLC_E_RESERVED2         68
240 #define WLC_E_ESCAN_RESULT      69
241 #define WLC_E_ACTION_FRAME_OFF_CHAN_COMPLETE    70
242 #define WLC_E_DCS_REQUEST 73
243
244 #define WLC_E_FIFO_CREDIT_MAP   74
245
246 #define WLC_E_LAST              75
247
248 #define WLC_E_STATUS_SUCCESS            0
249 #define WLC_E_STATUS_FAIL               1
250 #define WLC_E_STATUS_TIMEOUT            2
251 #define WLC_E_STATUS_NO_NETWORKS        3
252 #define WLC_E_STATUS_ABORT              4
253 #define WLC_E_STATUS_NO_ACK             5
254 #define WLC_E_STATUS_UNSOLICITED        6
255 #define WLC_E_STATUS_ATTEMPT            7
256 #define WLC_E_STATUS_PARTIAL            8
257 #define WLC_E_STATUS_NEWSCAN            9
258 #define WLC_E_STATUS_NEWASSOC           10
259 #define WLC_E_STATUS_11HQUIET           11
260 #define WLC_E_STATUS_SUPPRESS           12
261 #define WLC_E_STATUS_NOCHANS            13
262 #define WLC_E_STATUS_CS_ABORT           15
263 #define WLC_E_STATUS_ERROR              16
264
265 #define WLC_E_REASON_INITIAL_ASSOC      0
266 #define WLC_E_REASON_LOW_RSSI           1
267 #define WLC_E_REASON_DEAUTH             2
268 #define WLC_E_REASON_DISASSOC           3
269 #define WLC_E_REASON_BCNS_LOST          4
270 #define WLC_E_REASON_MINTXRATE          9
271 #define WLC_E_REASON_TXFAIL             10
272
273 #define WLC_E_REASON_FAST_ROAM_FAILED   5
274 #define WLC_E_REASON_DIRECTED_ROAM      6
275 #define WLC_E_REASON_TSPEC_REJECTED     7
276 #define WLC_E_REASON_BETTER_AP          8
277
278 #define WLC_E_PRUNE_ENCR_MISMATCH       1
279 #define WLC_E_PRUNE_BCAST_BSSID         2
280 #define WLC_E_PRUNE_MAC_DENY            3
281 #define WLC_E_PRUNE_MAC_NA              4
282 #define WLC_E_PRUNE_REG_PASSV           5
283 #define WLC_E_PRUNE_SPCT_MGMT           6
284 #define WLC_E_PRUNE_RADAR               7
285 #define WLC_E_RSN_MISMATCH              8
286 #define WLC_E_PRUNE_NO_COMMON_RATES     9
287 #define WLC_E_PRUNE_BASIC_RATES         10
288 #define WLC_E_PRUNE_CIPHER_NA           12
289 #define WLC_E_PRUNE_KNOWN_STA           13
290 #define WLC_E_PRUNE_WDS_PEER            15
291 #define WLC_E_PRUNE_QBSS_LOAD           16
292 #define WLC_E_PRUNE_HOME_AP             17
293
294 #define WLC_E_SUP_OTHER                 0
295 #define WLC_E_SUP_DECRYPT_KEY_DATA      1
296 #define WLC_E_SUP_BAD_UCAST_WEP128      2
297 #define WLC_E_SUP_BAD_UCAST_WEP40       3
298 #define WLC_E_SUP_UNSUP_KEY_LEN         4
299 #define WLC_E_SUP_PW_KEY_CIPHER         5
300 #define WLC_E_SUP_MSG3_TOO_MANY_IE      6
301 #define WLC_E_SUP_MSG3_IE_MISMATCH      7
302 #define WLC_E_SUP_NO_INSTALL_FLAG       8
303 #define WLC_E_SUP_MSG3_NO_GTK           9
304 #define WLC_E_SUP_GRP_KEY_CIPHER        10
305 #define WLC_E_SUP_GRP_MSG1_NO_GTK       11
306 #define WLC_E_SUP_GTK_DECRYPT_FAIL      12
307 #define WLC_E_SUP_SEND_FAIL             13
308 #define WLC_E_SUP_DEAUTH                14
309
310 #define WLC_E_IF_ADD            1
311 #define WLC_E_IF_DEL            2
312 #define WLC_E_IF_CHANGE         3
313
314 #define WLC_E_IF_ROLE_STA               0
315 #define WLC_E_IF_ROLE_AP                1
316 #define WLC_E_IF_ROLE_WDS               2
317
318 #define WLC_E_LINK_BCN_LOSS     1
319 #define WLC_E_LINK_DISASSOC     2
320 #define WLC_E_LINK_ASSOC_REC    3
321 #define WLC_E_LINK_BSSCFG_DIS   4
322
323 enum cust_gpio_modes {
324         WLAN_RESET_ON,
325         WLAN_RESET_OFF,
326         WLAN_POWER_ON,
327         WLAN_POWER_OFF
328 };
329
330 /* The level of bus communication with the dongle */
331 enum dhd_bus_state {
332         DHD_BUS_DOWN,           /* Not ready for frame transfers */
333         DHD_BUS_LOAD,           /* Download access only (CPU reset) */
334         DHD_BUS_DATA            /* Ready for frame transfers */
335 };
336
337 /* Pattern matching filter. Specifies an offset within received packets to
338  * start matching, the pattern to match, the size of the pattern, and a bitmask
339  * that indicates which bits within the pattern should be matched.
340  */
341 typedef struct wl_pkt_filter_pattern {
342         u32 offset;             /* Offset within received packet to start pattern matching.
343                                  * Offset '0' is the first byte of the ethernet header.
344                                  */
345         u32 size_bytes; /* Size of the pattern.  Bitmask must be the same size. */
346         u8 mask_and_pattern[1]; /* Variable length mask and pattern data.  mask starts
347                                          * at offset 0.  Pattern immediately follows mask.
348                                          */
349 } wl_pkt_filter_pattern_t;
350
351 /* IOVAR "pkt_filter_add" parameter. Used to install packet filters. */
352 typedef struct wl_pkt_filter {
353         u32 id;         /* Unique filter id, specified by app. */
354         u32 type;               /* Filter type (WL_PKT_FILTER_TYPE_xxx). */
355         u32 negate_match;       /* Negate the result of filter matches */
356         union {                 /* Filter definitions */
357                 wl_pkt_filter_pattern_t pattern;        /* Pattern matching filter */
358         } u;
359 } wl_pkt_filter_t;
360
361 /* IOVAR "pkt_filter_enable" parameter. */
362 typedef struct wl_pkt_filter_enable {
363         u32 id;         /* Unique filter id */
364         u32 enable;             /* Enable/disable bool */
365 } wl_pkt_filter_enable_t;
366
367 /* BSS info structure
368  * Applications MUST CHECK ie_offset field and length field to access IEs and
369  * next bss_info structure in a vector (in wl_scan_results_t)
370  */
371 typedef struct wl_bss_info {
372         u32 version;            /* version field */
373         u32 length;             /* byte length of data in this record,
374                                  * starting at version and including IEs
375                                  */
376         u8 BSSID[ETH_ALEN];
377         u16 beacon_period;      /* units are Kusec */
378         u16 capability; /* Capability information */
379         u8 SSID_len;
380         u8 SSID[32];
381         struct {
382                 uint count;     /* # rates in this set */
383                 u8 rates[16];   /* rates in 500kbps units w/hi bit set if basic */
384         } rateset;              /* supported rates */
385         chanspec_t chanspec;    /* chanspec for bss */
386         u16 atim_window;        /* units are Kusec */
387         u8 dtim_period; /* DTIM period */
388         s16 RSSI;               /* receive signal strength (in dBm) */
389         s8 phy_noise;           /* noise (in dBm) */
390
391         u8 n_cap;               /* BSS is 802.11N Capable */
392         u32 nbss_cap;   /* 802.11N BSS Capabilities (based on HT_CAP_*) */
393         u8 ctl_ch;              /* 802.11N BSS control channel number */
394         u32 reserved32[1];      /* Reserved for expansion of BSS properties */
395         u8 flags;               /* flags */
396         u8 reserved[3]; /* Reserved for expansion of BSS properties */
397         u8 basic_mcs[MCSSET_LEN];       /* 802.11N BSS required MCS set */
398
399         u16 ie_offset;  /* offset at which IEs start, from beginning */
400         u32 ie_length;  /* byte length of Information Elements */
401         s16 SNR;                /* average SNR of during frame reception */
402         /* Add new fields here */
403         /* variable length Information Elements */
404 } wl_bss_info_t;
405
406 typedef struct wlc_ssid {
407         u32 SSID_len;
408         unsigned char SSID[32];
409 } wlc_ssid_t;
410
411 typedef struct wl_scan_params {
412         wlc_ssid_t ssid;        /* default: {0, ""} */
413         u8 bssid[ETH_ALEN];     /* default: bcast */
414         s8 bss_type;            /* default: any,
415                                  * DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT
416                                  */
417         u8 scan_type;   /* flags, 0 use default */
418         s32 nprobes;            /* -1 use default, number of probes per channel */
419         s32 active_time;        /* -1 use default, dwell time per channel for
420                                  * active scanning
421                                  */
422         s32 passive_time;       /* -1 use default, dwell time per channel
423                                  * for passive scanning
424                                  */
425         s32 home_time;  /* -1 use default, dwell time for the home channel
426                                  * between channel scans
427                                  */
428         s32 channel_num;        /* count of channels and ssids that follow
429                                  *
430                                  * low half is count of channels in channel_list, 0
431                                  * means default (use all available channels)
432                                  *
433                                  * high half is entries in wlc_ssid_t array that
434                                  * follows channel_list, aligned for s32 (4 bytes)
435                                  * meaning an odd channel count implies a 2-byte pad
436                                  * between end of channel_list and first ssid
437                                  *
438                                  * if ssid count is zero, single ssid in the fixed
439                                  * parameter portion is assumed, otherwise ssid in
440                                  * the fixed portion is ignored
441                                  */
442         u16 channel_list[1];    /* list of chanspecs */
443 } wl_scan_params_t;
444
445 /* incremental scan struct */
446 typedef struct wl_iscan_params {
447         u32 version;
448         u16 action;
449         u16 scan_duration;
450         wl_scan_params_t params;
451 } wl_iscan_params_t;
452
453 /* 3 fields + size of wl_scan_params, not including variable length array */
454 #define WL_ISCAN_PARAMS_FIXED_SIZE (offsetof(wl_iscan_params_t, params) + sizeof(wlc_ssid_t))
455
456 typedef struct wl_scan_results {
457         u32 buflen;
458         u32 version;
459         u32 count;
460         wl_bss_info_t bss_info[1];
461 } wl_scan_results_t;
462
463 typedef struct wl_rateset_args {
464         u32 count;              /* # rates in this set */
465         u8 rates[WL_NUMRATES];  /* rates in 500kbps units w/hi bit set if basic */
466         u8 mcs[MCSSET_LEN];     /* supported mcs index bit map */
467 } wl_rateset_args_t;
468
469 /* u32 list */
470 typedef struct wl_u32_list {
471         /* in - # of elements, out - # of entries */
472         u32 count;
473         /* variable length u32 list */
474         u32 element[1];
475 } wl_u32_list_t;
476
477 /* used for association with a specific BSSID and chanspec list */
478 typedef struct wl_assoc_params {
479         u8 bssid[ETH_ALEN];     /* 00:00:00:00:00:00: broadcast scan */
480         s32 chanspec_num;       /* 0: all available channels,
481                                  * otherwise count of chanspecs in chanspec_list
482                                  */
483         chanspec_t chanspec_list[1];    /* list of chanspecs */
484 } wl_assoc_params_t;
485 #define WL_ASSOC_PARAMS_FIXED_SIZE      (sizeof(wl_assoc_params_t) - sizeof(chanspec_t))
486
487 /* used for reassociation/roam to a specific BSSID and channel */
488 typedef wl_assoc_params_t wl_reassoc_params_t;
489
490 /* used for join with or without a specific bssid and channel list */
491 typedef struct wl_join_params {
492         wlc_ssid_t ssid;
493         wl_assoc_params_t params;       /* optional field, but it must include the fixed portion
494                                          * of the wl_assoc_params_t struct when it does present.
495                                          */
496 } wl_join_params_t;
497
498 /* size of wl_scan_results not including variable length array */
499 #define WL_SCAN_RESULTS_FIXED_SIZE (sizeof(wl_scan_results_t) - sizeof(wl_bss_info_t))
500
501 /* incremental scan results struct */
502 typedef struct wl_iscan_results {
503         u32 status;
504         wl_scan_results_t results;
505 } wl_iscan_results_t;
506
507 /* size of wl_iscan_results not including variable length array */
508 #define WL_ISCAN_RESULTS_FIXED_SIZE \
509         (WL_SCAN_RESULTS_FIXED_SIZE + offsetof(wl_iscan_results_t, results))
510
511 typedef struct {
512         u32 duration;   /* millisecs spent sampling this channel */
513         u32 congest_ibss;       /* millisecs in our bss (presumably this traffic will */
514         /*  move if cur bss moves channels) */
515         u32 congest_obss;       /* traffic not in our bss */
516         u32 interference;       /* millisecs detecting a non 802.11 interferer. */
517         u32 timestamp;  /* second timestamp */
518 } cca_congest_t;
519
520 typedef struct {
521         chanspec_t chanspec;    /* Which channel? */
522         u8 num_secs;            /* How many secs worth of data */
523         cca_congest_t secs[1];  /* Data */
524 } cca_congest_channel_req_t;
525
526 typedef struct wl_country {
527         char country_abbrev[WLC_CNTRY_BUF_SZ];  /* nul-terminated country code used in
528                                                  * the Country IE
529                                                  */
530         s32 rev;                /* revision specifier for ccode
531                                  * on set, -1 indicates unspecified.
532                                  * on get, rev >= 0
533                                  */
534         char ccode[WLC_CNTRY_BUF_SZ];   /* nul-terminated built-in country code.
535                                          * variable length, but fixed size in
536                                          * struct allows simple allocation for
537                                          * expected country strings <= 3 chars.
538                                          */
539 } wl_country_t;
540
541 typedef struct wl_channels_in_country {
542         u32 buflen;
543         u32 band;
544         char country_abbrev[WLC_CNTRY_BUF_SZ];
545         u32 count;
546         u32 channel[1];
547 } wl_channels_in_country_t;
548
549 typedef struct wl_country_list {
550         u32 buflen;
551         u32 band_set;
552         u32 band;
553         u32 count;
554         char country_abbrev[1];
555 } wl_country_list_t;
556
557 typedef struct wl_rm_req_elt {
558         s8 type;
559         s8 flags;
560         chanspec_t chanspec;
561         u32 token;              /* token for this measurement */
562         u32 tsf_h;              /* TSF high 32-bits of Measurement start time */
563         u32 tsf_l;              /* TSF low 32-bits */
564         u32 dur;                /* TUs */
565 } wl_rm_req_elt_t;
566
567 typedef struct wl_rm_req {
568         u32 token;              /* overall measurement set token */
569         u32 count;              /* number of measurement requests */
570         void *cb;               /* completion callback function: may be NULL */
571         void *cb_arg;           /* arg to completion callback function */
572         wl_rm_req_elt_t req[1]; /* variable length block of requests */
573 } wl_rm_req_t;
574
575 typedef struct wl_rm_rep_elt {
576         s8 type;
577         s8 flags;
578         chanspec_t chanspec;
579         u32 token;              /* token for this measurement */
580         u32 tsf_h;              /* TSF high 32-bits of Measurement start time */
581         u32 tsf_l;              /* TSF low 32-bits */
582         u32 dur;                /* TUs */
583         u32 len;                /* byte length of data block */
584         u8 data[1];             /* variable length data block */
585 } wl_rm_rep_elt_t;
586
587 #define WL_RPI_REP_BIN_NUM 8
588 typedef struct wl_rm_rpi_rep {
589         u8 rpi[WL_RPI_REP_BIN_NUM];
590         s8 rpi_max[WL_RPI_REP_BIN_NUM];
591 } wl_rm_rpi_rep_t;
592
593 typedef struct wl_rm_rep {
594         u32 token;              /* overall measurement set token */
595         u32 len;                /* length of measurement report block */
596         wl_rm_rep_elt_t rep[1]; /* variable length block of reports */
597 } wl_rm_rep_t;
598
599 typedef struct wl_wsec_key {
600         u32 index;              /* key index */
601         u32 len;                /* key length */
602         u8 data[WLAN_MAX_KEY_LEN];      /* key data */
603         u32 pad_1[18];
604         u32 algo;               /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
605         u32 flags;              /* misc flags */
606         u32 pad_2[2];
607         int pad_3;
608         int iv_initialized;     /* has IV been initialized already? */
609         int pad_4;
610         /* Rx IV */
611         struct {
612                 u32 hi; /* upper 32 bits of IV */
613                 u16 lo; /* lower 16 bits of IV */
614         } rxiv;
615         u32 pad_5[2];
616         u8 ea[ETH_ALEN];        /* per station */
617 } wl_wsec_key_t;
618
619 /* Used to get specific STA parameters */
620 typedef struct {
621         u32 val;
622         u8 ea[ETH_ALEN];
623 } scb_val_t;
624
625 /* channel encoding */
626 typedef struct channel_info {
627         int hw_channel;
628         int target_channel;
629         int scan_channel;
630 } channel_info_t;
631
632 /* Linux network driver ioctl encoding */
633 typedef struct wl_ioctl {
634         uint cmd;               /* common ioctl definition */
635         void *buf;              /* pointer to user buffer */
636         uint len;               /* length of user buffer */
637         u8 set;         /* get or set request (optional) */
638         uint used;              /* bytes read or written (optional) */
639         uint needed;            /* bytes needed (optional) */
640 } wl_ioctl_t;
641
642 /* Common structure for module and instance linkage */
643 typedef struct dhd_pub {
644         /* Linkage ponters */
645         struct dhd_bus *bus;    /* Bus module handle */
646         struct dhd_prot *prot;  /* Protocol module handle */
647         struct dhd_info *info;  /* Info module handle */
648
649         /* Internal dhd items */
650         bool up;                /* Driver up/down (to OS) */
651         bool txoff;             /* Transmit flow-controlled */
652         bool dongle_reset;      /* true = DEVRESET put dongle into reset */
653         enum dhd_bus_state busstate;
654         uint hdrlen;            /* Total DHD header length (proto + bus) */
655         uint maxctl;            /* Max size rxctl request from proto to bus */
656         uint rxsz;              /* Rx buffer size bus module should use */
657         u8 wme_dp;              /* wme discard priority */
658
659         /* Dongle media info */
660         bool iswl;              /* Dongle-resident driver is wl */
661         unsigned long drv_version;      /* Version of dongle-resident driver */
662         u8 mac[ETH_ALEN];                       /* MAC address obtained from dongle */
663         dngl_stats_t dstats;            /* Stats for dongle-based data */
664
665         /* Additional stats for the bus level */
666         unsigned long tx_packets;       /* Data packets sent to dongle */
667         unsigned long tx_multicast;     /* Multicast data packets sent to dongle */
668         unsigned long tx_errors;        /* Errors in sending data to dongle */
669         unsigned long tx_ctlpkts;       /* Control packets sent to dongle */
670         unsigned long tx_ctlerrs;       /* Errors sending control frames to dongle */
671         unsigned long rx_packets;       /* Packets sent up the network interface */
672         unsigned long rx_multicast;     /* Multicast packets sent up the network
673                                          interface */
674         unsigned long rx_errors;        /* Errors processing rx data packets */
675         unsigned long rx_ctlpkts;       /* Control frames processed from dongle */
676         unsigned long rx_ctlerrs;       /* Errors in processing rx control frames */
677         unsigned long rx_dropped;       /* Packets dropped locally (no memory) */
678         unsigned long rx_flushed;       /* Packets flushed due to
679                                 unscheduled sendup thread */
680         unsigned long wd_dpc_sched;     /* Number of times dhd dpc scheduled by
681                                          watchdog timer */
682
683         unsigned long rx_readahead_cnt; /* Number of packets where header read-ahead
684                                          was used. */
685         unsigned long tx_realloc;       /* Number of tx packets we had to realloc for
686                                          headroom */
687         unsigned long fc_packets;       /* Number of flow control pkts recvd */
688
689         /* Last error return */
690         int bcmerror;
691         uint tickcnt;
692
693         /* Last error from dongle */
694         int dongle_error;
695
696         /* Suspend disable flag  flag */
697         int suspend_disable_flag;       /* "1" to disable all extra powersaving
698                                          during suspend */
699         int in_suspend;         /* flag set to 1 when early suspend called */
700 #ifdef PNO_SUPPORT
701         int pno_enable;         /* pno status : "1" is pno enable */
702 #endif                          /* PNO_SUPPORT */
703         int dtim_skip;          /* dtim skip , default 0 means wake each dtim */
704
705         /* Pkt filter defination */
706         char *pktfilter[100];
707         int pktfilter_count;
708
709         u8 country_code[WLC_CNTRY_BUF_SZ];
710         char eventmask[WL_EVENTING_MASK_LEN];
711
712 } dhd_pub_t;
713
714 typedef struct dhd_if_event {
715         u8 ifidx;
716         u8 action;
717         u8 flags;
718         u8 bssidx;
719 } dhd_if_event_t;
720
721 typedef struct {
722         u32 limit;              /* Expiration time (usec) */
723         u32 increment;  /* Current expiration increment (usec) */
724         u32 elapsed;            /* Current elapsed time (usec) */
725         u32 tick;               /* O/S tick time (usec) */
726 } dhd_timeout_t;
727
728 typedef struct {
729         uint event;
730         const char *name;
731 } bcmevent_name_t;
732
733 #if defined(CONFIG_PM_SLEEP)
734 extern atomic_t dhd_mmc_suspend;
735 #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
736 #define _DHD_PM_RESUME_WAIT(a, b) do { \
737                 int retry = 0; \
738                 while (atomic_read(&dhd_mmc_suspend) && retry++ != b) { \
739                         wait_event_timeout(a, false, HZ/100); \
740                 } \
741         }       while (0)
742 #define DHD_PM_RESUME_WAIT(a)   _DHD_PM_RESUME_WAIT(a, 30)
743 #define DHD_PM_RESUME_WAIT_FOREVER(a)   _DHD_PM_RESUME_WAIT(a, ~0)
744 #define DHD_PM_RESUME_RETURN_ERROR(a)   \
745         do { if (atomic_read(&dhd_mmc_suspend)) return a; } while (0)
746 #define DHD_PM_RESUME_RETURN    do { \
747         if (atomic_read(&dhd_mmc_suspend)) \
748                 return; \
749         } while (0)
750
751 #define DHD_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
752 #define SPINWAIT_SLEEP(a, exp, us) do { \
753                 uint countdown = (us) + 9999; \
754                 while ((exp) && (countdown >= 10000)) { \
755                         wait_event_timeout(a, false, HZ/100); \
756                         countdown -= 10000; \
757                 } \
758         } while (0)
759
760 #else
761
762 #define DHD_PM_RESUME_WAIT_INIT(a)
763 #define DHD_PM_RESUME_WAIT(a)
764 #define DHD_PM_RESUME_WAIT_FOREVER(a)
765 #define DHD_PM_RESUME_RETURN_ERROR(a)
766 #define DHD_PM_RESUME_RETURN
767
768 #define DHD_SPINWAIT_SLEEP_INIT(a)
769 #define SPINWAIT_SLEEP(a, exp, us)  do { \
770                 uint countdown = (us) + 9; \
771                 while ((exp) && (countdown >= 10)) { \
772                         udelay(10);  \
773                         countdown -= 10;  \
774                 } \
775         } while (0)
776
777 #endif  /* defined(CONFIG_PM_SLEEP) */
778
779 /*
780  * Insmod parameters for debug/test
781  */
782
783 /* Watchdog timer interval */
784 extern uint dhd_watchdog_ms;
785
786 #if defined(DHD_DEBUG)
787 /* Console output poll interval */
788 extern uint dhd_console_ms;
789 #endif                          /* defined(DHD_DEBUG) */
790
791 /* Use interrupts */
792 extern uint dhd_intr;
793
794 /* Use polling */
795 extern uint dhd_poll;
796
797 /* ARP offload agent mode */
798 extern uint dhd_arp_mode;
799
800 /* ARP offload enable */
801 extern uint dhd_arp_enable;
802
803 /* Pkt filte enable control */
804 extern uint dhd_pkt_filter_enable;
805
806 /*  Pkt filter init setup */
807 extern uint dhd_pkt_filter_init;
808
809 /* Pkt filter mode control */
810 extern uint dhd_master_mode;
811
812 /* Roaming mode control */
813 extern uint dhd_roam;
814
815 /* Roaming mode control */
816 extern uint dhd_radio_up;
817
818 /* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */
819 extern int dhd_idletime;
820 #define DHD_IDLETIME_TICKS 1
821
822 /* SDIO Drive Strength */
823 extern uint dhd_sdiod_drive_strength;
824
825 /* Override to force tx queueing all the time */
826 extern uint dhd_force_tx_queueing;
827
828 #ifdef SDTEST
829 /* Echo packet generator (SDIO), pkts/s */
830 extern uint dhd_pktgen;
831
832 /* Echo packet len (0 => sawtooth, max 1800) */
833 extern uint dhd_pktgen_len;
834 #define MAX_PKTGEN_LEN 1800
835 #endif
836
837 extern char brcmf_fw_path[MOD_PARAM_PATHLEN];
838 extern char brcmf_nv_path[MOD_PARAM_PATHLEN];
839
840 extern u32 g_assert_type;
841 extern const bcmevent_name_t bcmevent_names[];
842 extern const int bcmevent_names_size;
843
844
845 static inline void MUTEX_LOCK_INIT(dhd_pub_t *dhdp)
846 {
847 }
848
849 static inline void MUTEX_LOCK(dhd_pub_t *dhdp)
850 {
851 }
852
853 static inline void MUTEX_UNLOCK(dhd_pub_t *dhdp)
854 {
855 }
856
857 static inline void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t *dhdp)
858 {
859 }
860
861 static inline void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t *dhdp)
862 {
863 }
864
865 static inline void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t *dhdp)
866 {
867 }
868
869 static inline void MUTEX_LOCK_WL_SCAN_SET_INIT(void)
870 {
871 }
872
873 static inline void MUTEX_LOCK_WL_SCAN_SET(void)
874 {
875 }
876
877 static inline void MUTEX_UNLOCK_WL_SCAN_SET(void)
878 {
879 }
880
881 /*
882  * Exported from dhd OS modules (dhd_linux/dhd_ndis)
883  */
884
885 /* Indication from bus module regarding presence/insertion of dongle.
886  * Return dhd_pub_t pointer, used as handle to OS module in later calls.
887  * Returned structure should have bus and prot pointers filled in.
888  * bus_hdrlen specifies required headroom for bus module header.
889  */
890 extern dhd_pub_t *dhd_attach(struct dhd_bus *bus,
891                                 uint bus_hdrlen);
892 extern int dhd_net_attach(dhd_pub_t *dhdp, int idx);
893
894 /* Indication from bus module regarding removal/absence of dongle */
895 extern void dhd_detach(dhd_pub_t *dhdp);
896
897 /* Indication from bus module to change flow-control state */
898 extern void dhd_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool on);
899
900 extern bool brcmf_c_prec_enq(dhd_pub_t *dhdp, struct pktq *q,
901                          struct sk_buff *pkt, int prec);
902
903 /* Receive frame for delivery to OS.  Callee disposes of rxp. */
904 extern void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx,
905                          struct sk_buff *rxp, int numpkt);
906
907 /* Return pointer to interface name */
908 extern char *dhd_ifname(dhd_pub_t *dhdp, int idx);
909
910 /* Request scheduling of the bus dpc */
911 extern void dhd_sched_dpc(dhd_pub_t *dhdp);
912
913 /* Notify tx completion */
914 extern void dhd_txcomplete(dhd_pub_t *dhdp, struct sk_buff *txp, bool success);
915
916 /* Query ioctl */
917 extern int dhdcdc_query_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf,
918                               uint len);
919
920 /* OS independent layer functions */
921 extern int dhd_os_proto_block(dhd_pub_t *pub);
922 extern int dhd_os_proto_unblock(dhd_pub_t *pub);
923 extern int dhd_os_ioctl_resp_wait(dhd_pub_t *pub, uint *condition,
924                                   bool *pending);
925 extern int dhd_os_ioctl_resp_wake(dhd_pub_t *pub);
926 extern unsigned int dhd_os_get_ioctl_resp_timeout(void);
927 extern void dhd_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
928 extern void *dhd_os_open_image(char *filename);
929 extern int dhd_os_get_image_block(char *buf, int len, void *image);
930 extern void dhd_os_close_image(void *image);
931 extern void dhd_os_wd_timer(void *bus, uint wdtick);
932 extern void dhd_os_sdlock(dhd_pub_t *pub);
933 extern void dhd_os_sdunlock(dhd_pub_t *pub);
934 extern void dhd_os_sdlock_sndup_rxq(dhd_pub_t *pub);
935 extern void dhd_customer_gpio_wlan_ctrl(int onoff);
936 extern int dhd_custom_get_mac_address(unsigned char *buf);
937 extern void dhd_os_sdunlock_sndup_rxq(dhd_pub_t *pub);
938 extern void dhd_os_sdlock_eventq(dhd_pub_t *pub);
939 extern void dhd_os_sdunlock_eventq(dhd_pub_t *pub);
940 #ifdef DHD_DEBUG
941 extern int write_to_file(dhd_pub_t *dhd, u8 *buf, int size);
942 #endif                          /* DHD_DEBUG */
943 #if defined(OOB_INTR_ONLY)
944 extern int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr);
945 #endif                          /* defined(OOB_INTR_ONLY) */
946
947 int setScheduler(struct task_struct *p, int policy, struct sched_param *param);
948
949 extern void dhd_timeout_start(dhd_timeout_t *tmo, uint usec);
950 extern int dhd_timeout_expired(dhd_timeout_t *tmo);
951
952 extern int dhd_ifname2idx(struct dhd_info *dhd, char *name);
953 extern u8 *dhd_bssidx2bssid(dhd_pub_t *dhd, int idx);
954 extern int brcmf_c_host_event(struct dhd_info *dhd, int *idx, void *pktdata,
955                          wl_event_msg_t *, void **data_ptr);
956
957 extern void brcmf_c_init(void);
958
959 extern int dhd_add_if(struct dhd_info *dhd, int ifidx, void *handle,
960                       char *name, u8 *mac_addr, u32 flags, u8 bssidx);
961 extern void dhd_del_if(struct dhd_info *dhd, int ifidx);
962
963 extern void dhd_vif_add(struct dhd_info *dhd, int ifidx, char *name);
964 extern void dhd_vif_del(struct dhd_info *dhd, int ifidx);
965
966 extern void dhd_event(struct dhd_info *dhd, char *evpkt, int evlen, int ifidx);
967 extern void dhd_vif_sendup(struct dhd_info *dhd, int ifidx, unsigned char * cp,
968                            int len);
969
970 /* Send packet to dongle via data channel */
971 extern int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, struct sk_buff *pkt);
972
973 /* Send event to host */
974 extern void dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event,
975                              void *data);
976 extern int dhd_bus_devreset(dhd_pub_t *dhdp, u8 flag);
977 extern uint dhd_bus_status(dhd_pub_t *dhdp);
978 extern int dhd_bus_start(dhd_pub_t *dhdp);
979
980 extern void dhd_wait_for_event(dhd_pub_t *dhd, bool * lockvar);
981 extern void dhd_wait_event_wakeup(dhd_pub_t *dhd);
982
983 #ifdef PKT_FILTER_SUPPORT
984 extern void brcmf_c_pktfilter_offload_set(dhd_pub_t *dhd, char *arg);
985 extern void brcmf_c_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg,
986                                              int enable, int master_mode);
987 #endif
988
989 #ifdef BCMDBG
990 #define ASSERT(exp) \
991           do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0)
992 extern void osl_assert(char *exp, char *file, int line);
993 #else
994 #define ASSERT(exp)     do {} while (0)
995 #endif  /* defined(BCMDBG) */
996
997 /* Linux network driver ioctl encoding */
998 typedef struct dhd_ioctl {
999         uint cmd;               /* common ioctl definition */
1000         void *buf;              /* pointer to user buffer */
1001         uint len;               /* length of user buffer */
1002         bool set;               /* get or set request (optional) */
1003         uint used;              /* bytes read or written (optional) */
1004         uint needed;            /* bytes needed (optional) */
1005         uint driver;            /* to identify target driver */
1006 } dhd_ioctl_t;
1007
1008 /* per-driver magic numbers */
1009 #define DHD_IOCTL_MAGIC         0x00444944
1010
1011 /* bump this number if you change the ioctl interface */
1012 #define DHD_IOCTL_VERSION       1
1013
1014 #define DHD_IOCTL_MAXLEN        8192    /* max length ioctl buffer required */
1015 #define DHD_IOCTL_SMLEN 256     /* "small" length ioctl buffer required */
1016
1017 /* common ioctl definitions */
1018 #define DHD_GET_MAGIC                           0
1019 #define DHD_GET_VERSION                         1
1020 #define DHD_GET_VAR                             2
1021 #define DHD_SET_VAR                             3
1022
1023 /* message levels */
1024 #define DHD_ERROR_VAL   0x0001
1025 #define DHD_TRACE_VAL   0x0002
1026 #define DHD_INFO_VAL    0x0004
1027 #define DHD_DATA_VAL    0x0008
1028 #define DHD_CTL_VAL     0x0010
1029 #define DHD_TIMER_VAL   0x0020
1030 #define DHD_HDRS_VAL    0x0040
1031 #define DHD_BYTES_VAL   0x0080
1032 #define DHD_INTR_VAL    0x0100
1033 #define DHD_LOG_VAL     0x0200
1034 #define DHD_GLOM_VAL    0x0400
1035 #define DHD_EVENT_VAL   0x0800
1036 #define DHD_BTA_VAL     0x1000
1037 #define DHD_ISCAN_VAL 0x2000
1038
1039 #ifdef SDTEST
1040 /* For pktgen iovar */
1041 typedef struct dhd_pktgen {
1042         uint version;           /* To allow structure change tracking */
1043         uint freq;              /* Max ticks between tx/rx attempts */
1044         uint count;             /* Test packets to send/rcv each attempt */
1045         uint print;             /* Print counts every <print> attempts */
1046         uint total;             /* Total packets (or bursts) */
1047         uint minlen;            /* Minimum length of packets to send */
1048         uint maxlen;            /* Maximum length of packets to send */
1049         uint numsent;           /* Count of test packets sent */
1050         uint numrcvd;           /* Count of test packets received */
1051         uint numfail;           /* Count of test send failures */
1052         uint mode;              /* Test mode (type of test packets) */
1053         uint stop;              /* Stop after this many tx failures */
1054 } dhd_pktgen_t;
1055
1056 /* Version in case structure changes */
1057 #define DHD_PKTGEN_VERSION 2
1058
1059 /* Type of test packets to use */
1060 #define DHD_PKTGEN_ECHO         1       /* Send echo requests */
1061 #define DHD_PKTGEN_SEND         2       /* Send discard packets */
1062 #define DHD_PKTGEN_RXBURST      3       /* Request dongle send N packets */
1063 #define DHD_PKTGEN_RECV         4       /* Continuous rx from continuous
1064                                          tx dongle */
1065 #endif                          /* SDTEST */
1066
1067 /* Enter idle immediately (no timeout) */
1068 #define DHD_IDLE_IMMEDIATE      (-1)
1069
1070 /* Values for idleclock iovar: other values are the sd_divisor to use
1071          when idle */
1072 #define DHD_IDLE_ACTIVE 0       /* Do not request any SD clock change
1073                                  when idle */
1074 #define DHD_IDLE_STOP   (-1)    /* Request SD clock be stopped
1075                                  (and use SD1 mode) */
1076
1077 #endif                          /* _dhd_h_ */