staging: brcm80211: emptied include/802.11.h
[deliverable/linux.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 #include <linux/sched.h>
25 #include <linux/init.h>
26 #include <linux/kernel.h>
27 #include <linux/slab.h>
28 #include <linux/skbuff.h>
29 #include <linux/netdevice.h>
30 #include <linux/etherdevice.h>
31 #include <linux/random.h>
32 #include <linux/spinlock.h>
33 #include <linux/ethtool.h>
34 #include <linux/suspend.h>
35 #include <asm/uaccess.h>
36 #include <asm/unaligned.h>
37 #include "bcmdefs.h"
38 /* The kernel threading is sdio-specific */
39 #include "bcmwifi.h"
40 #include "proto/802.11.h"
41 #include "proto/bcmeth.h"
42 #include "proto/bcmevent.h"
43
44 /* Forward decls */
45 struct dhd_bus;
46 struct dhd_prot;
47 struct dhd_info;
48
49 #define WLC_UP 2
50 #define WLC_SET_PROMISC 10
51 #define WLC_GET_RATE 12
52 #define WLC_GET_INFRA 19
53 #define WLC_SET_INFRA 20
54 #define WLC_GET_AUTH 21
55 #define WLC_SET_AUTH 22
56 #define WLC_GET_BSSID 23
57 #define WLC_GET_SSID 25
58 #define WLC_SET_SSID 26
59 #define WLC_GET_CHANNEL 29
60 #define WLC_GET_SRL 31
61 #define WLC_GET_LRL 33
62 #define WLC_GET_RADIO 37
63 #define WLC_SET_RADIO 38
64 #define WLC_GET_PHYTYPE 39
65 #define WLC_SET_KEY 45
66 #define WLC_SET_PASSIVE_SCAN 49
67 #define WLC_SCAN 50
68 #define WLC_SCAN_RESULTS 51
69 #define WLC_DISASSOC 52
70 #define WLC_REASSOC 53
71 #define WLC_SET_ROAM_TRIGGER 55
72 #define WLC_SET_ROAM_DELTA 57
73 #define WLC_GET_DTIMPRD 77
74 #define WLC_SET_COUNTRY 84
75 #define WLC_GET_PM 85
76 #define WLC_SET_PM 86
77 #define WLC_GET_AP 117
78 #define WLC_SET_AP 118
79 #define WLC_GET_RSSI 127
80 #define WLC_GET_WSEC 133
81 #define WLC_SET_WSEC 134
82 #define WLC_GET_PHY_NOISE 135
83 #define WLC_GET_BSS_INFO 136
84 #define WLC_SET_SCAN_CHANNEL_TIME 185
85 #define WLC_SET_SCAN_UNASSOC_TIME 187
86 #define WLC_SCB_DEAUTHENTICATE_FOR_REASON 201
87 #define WLC_GET_VALID_CHANNELS 217
88 #define WLC_GET_KEY_PRIMARY 235
89 #define WLC_SET_KEY_PRIMARY 236
90 #define WLC_SET_SCAN_PASSIVE_TIME 258
91 #define WLC_GET_VAR 262 /* get value of named variable */
92 #define WLC_SET_VAR 263 /* set named variable to value */
93
94 /* phy types (returned by WLC_GET_PHYTPE) */
95 #define WLC_PHY_TYPE_A 0
96 #define WLC_PHY_TYPE_B 1
97 #define WLC_PHY_TYPE_G 2
98 #define WLC_PHY_TYPE_N 4
99 #define WLC_PHY_TYPE_LP 5
100 #define WLC_PHY_TYPE_SSN 6
101 #define WLC_PHY_TYPE_HT 7
102 #define WLC_PHY_TYPE_LCN 8
103 #define WLC_PHY_TYPE_NULL 0xf
104
105 #define WL_PKT_FILTER_FIXED_LEN offsetof(wl_pkt_filter_t, u)
106 #define WL_PKT_FILTER_PATTERN_FIXED_LEN offsetof(wl_pkt_filter_pattern_t, mask_and_pattern)
107
108 #define WL_EVENTING_MASK_LEN 16
109
110 #define TOE_TX_CSUM_OL 0x00000001
111 #define TOE_RX_CSUM_OL 0x00000002
112
113 /* maximum channels returned by the get valid channels iovar */
114 #define WL_NUMCHANNELS 64
115
116 #define WL_BSS_INFO_VERSION 108 /* current ver of wl_bss_info struct */
117
118 /* size of wl_scan_params not including variable length array */
119 #define WL_SCAN_PARAMS_FIXED_SIZE 64
120
121 /* masks for channel and ssid count */
122 #define WL_SCAN_PARAMS_COUNT_MASK 0x0000ffff
123 #define WL_SCAN_PARAMS_NSSID_SHIFT 16
124
125 #define WL_SCAN_ACTION_START 1
126 #define WL_SCAN_ACTION_CONTINUE 2
127 #define WL_SCAN_ACTION_ABORT 3
128
129 #define ISCAN_REQ_VERSION 1
130
131 /* wl_iscan_results status values */
132 #define WL_SCAN_RESULTS_SUCCESS 0
133 #define WL_SCAN_RESULTS_PARTIAL 1
134 #define WL_SCAN_RESULTS_PENDING 2
135 #define WL_SCAN_RESULTS_ABORTED 3
136 #define WL_SCAN_RESULTS_NO_MEM 4
137
138 #define MAX_CCA_CHANNELS 38 /* Max number of 20 Mhz wide channels */
139 #define MAX_CCA_SECS 60 /* CCA keeps this many seconds history */
140
141 #define IBSS_MED 15 /* Mediom in-bss congestion percentage */
142 #define IBSS_HI 25 /* Hi in-bss congestion percentage */
143 #define OBSS_MED 12
144 #define OBSS_HI 25
145 #define INTERFER_MED 5
146 #define INTERFER_HI 10
147
148 #define CCA_FLAG_2G_ONLY 0x01 /* Return a channel from 2.4 Ghz band */
149 #define CCA_FLAG_5G_ONLY 0x02 /* Return a channel from 2.4 Ghz band */
150 #define CCA_FLAG_IGNORE_DURATION 0x04 /* Ignore dwell time for each channel */
151 #define CCA_FLAGS_PREFER_1_6_11 0x10
152 #define CCA_FLAG_IGNORE_INTERFER 0x20 /* do not exlude channel based on interfer level */
153
154 #define CCA_ERRNO_BAND 1 /* After filtering for band pref, no choices left */
155 #define CCA_ERRNO_DURATION 2 /* After filtering for duration, no choices left */
156 #define CCA_ERRNO_PREF_CHAN 3 /* After filtering for chan pref, no choices left */
157 #define CCA_ERRNO_INTERFER 4 /* After filtering for interference, no choices left */
158 #define CCA_ERRNO_TOO_FEW 5 /* Only 1 channel was input */
159
160 #define WL_NUM_RPI_BINS 8
161 #define WL_RM_TYPE_BASIC 1
162 #define WL_RM_TYPE_CCA 2
163 #define WL_RM_TYPE_RPI 3
164
165 #define WL_RM_FLAG_PARALLEL (1<<0)
166
167 #define WL_RM_FLAG_LATE (1<<1)
168 #define WL_RM_FLAG_INCAPABLE (1<<2)
169 #define WL_RM_FLAG_REFUSED (1<<3)
170
171 #define WL_SOFT_KEY (1 << 0) /* Indicates this key is using soft encrypt */
172 #define WL_PRIMARY_KEY (1 << 1) /* Indicates this key is the primary (ie tx) key */
173 #define WL_KF_RES_4 (1 << 4) /* Reserved for backward compat */
174 #define WL_KF_RES_5 (1 << 5) /* Reserved for backward compat */
175 #define WL_IBSS_PEER_GROUP_KEY (1 << 6) /* Indicates a group key for a IBSS PEER */
176
177 #define WLC_IOCTL_SMLEN 256 /* "small" length ioctl buffer required */
178 #define WLC_IOCTL_MEDLEN 1536 /* "med" length ioctl buffer required */
179 #define WLC_IOCTL_MAXLEN 8192
180
181 #define DHD_IF_VIF 0x01 /* Virtual IF (Hidden from user) */
182
183 /* optionally set by a module_param_string() */
184 #define MOD_PARAM_PATHLEN 2048
185
186 /* For supporting multiple interfaces */
187 #define DHD_MAX_IFS 16
188 #define DHD_DEL_IF -0xe
189 #define DHD_BAD_IF -0xf
190
191 #define DOT11_BSSTYPE_ANY 2
192 #define DOT11_MAX_DEFAULT_KEYS 4
193
194 enum cust_gpio_modes {
195 WLAN_RESET_ON,
196 WLAN_RESET_OFF,
197 WLAN_POWER_ON,
198 WLAN_POWER_OFF
199 };
200
201 /* The level of bus communication with the dongle */
202 enum dhd_bus_state {
203 DHD_BUS_DOWN, /* Not ready for frame transfers */
204 DHD_BUS_LOAD, /* Download access only (CPU reset) */
205 DHD_BUS_DATA /* Ready for frame transfers */
206 };
207
208 /* Pattern matching filter. Specifies an offset within received packets to
209 * start matching, the pattern to match, the size of the pattern, and a bitmask
210 * that indicates which bits within the pattern should be matched.
211 */
212 typedef struct wl_pkt_filter_pattern {
213 u32 offset; /* Offset within received packet to start pattern matching.
214 * Offset '0' is the first byte of the ethernet header.
215 */
216 u32 size_bytes; /* Size of the pattern. Bitmask must be the same size. */
217 u8 mask_and_pattern[1]; /* Variable length mask and pattern data. mask starts
218 * at offset 0. Pattern immediately follows mask.
219 */
220 } wl_pkt_filter_pattern_t;
221
222 /* IOVAR "pkt_filter_add" parameter. Used to install packet filters. */
223 typedef struct wl_pkt_filter {
224 u32 id; /* Unique filter id, specified by app. */
225 u32 type; /* Filter type (WL_PKT_FILTER_TYPE_xxx). */
226 u32 negate_match; /* Negate the result of filter matches */
227 union { /* Filter definitions */
228 wl_pkt_filter_pattern_t pattern; /* Pattern matching filter */
229 } u;
230 } wl_pkt_filter_t;
231
232 /* IOVAR "pkt_filter_enable" parameter. */
233 typedef struct wl_pkt_filter_enable {
234 u32 id; /* Unique filter id */
235 u32 enable; /* Enable/disable bool */
236 } wl_pkt_filter_enable_t;
237
238 /* BSS info structure
239 * Applications MUST CHECK ie_offset field and length field to access IEs and
240 * next bss_info structure in a vector (in wl_scan_results_t)
241 */
242 typedef struct wl_bss_info {
243 u32 version; /* version field */
244 u32 length; /* byte length of data in this record,
245 * starting at version and including IEs
246 */
247 u8 BSSID[ETH_ALEN];
248 u16 beacon_period; /* units are Kusec */
249 u16 capability; /* Capability information */
250 u8 SSID_len;
251 u8 SSID[32];
252 struct {
253 uint count; /* # rates in this set */
254 u8 rates[16]; /* rates in 500kbps units w/hi bit set if basic */
255 } rateset; /* supported rates */
256 chanspec_t chanspec; /* chanspec for bss */
257 u16 atim_window; /* units are Kusec */
258 u8 dtim_period; /* DTIM period */
259 s16 RSSI; /* receive signal strength (in dBm) */
260 s8 phy_noise; /* noise (in dBm) */
261
262 u8 n_cap; /* BSS is 802.11N Capable */
263 u32 nbss_cap; /* 802.11N BSS Capabilities (based on HT_CAP_*) */
264 u8 ctl_ch; /* 802.11N BSS control channel number */
265 u32 reserved32[1]; /* Reserved for expansion of BSS properties */
266 u8 flags; /* flags */
267 u8 reserved[3]; /* Reserved for expansion of BSS properties */
268 u8 basic_mcs[MCSSET_LEN]; /* 802.11N BSS required MCS set */
269
270 u16 ie_offset; /* offset at which IEs start, from beginning */
271 u32 ie_length; /* byte length of Information Elements */
272 s16 SNR; /* average SNR of during frame reception */
273 /* Add new fields here */
274 /* variable length Information Elements */
275 } wl_bss_info_t;
276
277 typedef struct wlc_ssid {
278 u32 SSID_len;
279 unsigned char SSID[32];
280 } wlc_ssid_t;
281
282 typedef struct wl_scan_params {
283 wlc_ssid_t ssid; /* default: {0, ""} */
284 u8 bssid[ETH_ALEN]; /* default: bcast */
285 s8 bss_type; /* default: any,
286 * DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT
287 */
288 u8 scan_type; /* flags, 0 use default */
289 s32 nprobes; /* -1 use default, number of probes per channel */
290 s32 active_time; /* -1 use default, dwell time per channel for
291 * active scanning
292 */
293 s32 passive_time; /* -1 use default, dwell time per channel
294 * for passive scanning
295 */
296 s32 home_time; /* -1 use default, dwell time for the home channel
297 * between channel scans
298 */
299 s32 channel_num; /* count of channels and ssids that follow
300 *
301 * low half is count of channels in channel_list, 0
302 * means default (use all available channels)
303 *
304 * high half is entries in wlc_ssid_t array that
305 * follows channel_list, aligned for s32 (4 bytes)
306 * meaning an odd channel count implies a 2-byte pad
307 * between end of channel_list and first ssid
308 *
309 * if ssid count is zero, single ssid in the fixed
310 * parameter portion is assumed, otherwise ssid in
311 * the fixed portion is ignored
312 */
313 u16 channel_list[1]; /* list of chanspecs */
314 } wl_scan_params_t;
315
316 /* incremental scan struct */
317 typedef struct wl_iscan_params {
318 u32 version;
319 u16 action;
320 u16 scan_duration;
321 wl_scan_params_t params;
322 } wl_iscan_params_t;
323
324 /* 3 fields + size of wl_scan_params, not including variable length array */
325 #define WL_ISCAN_PARAMS_FIXED_SIZE (offsetof(wl_iscan_params_t, params) + sizeof(wlc_ssid_t))
326
327 typedef struct wl_scan_results {
328 u32 buflen;
329 u32 version;
330 u32 count;
331 wl_bss_info_t bss_info[1];
332 } wl_scan_results_t;
333
334 typedef struct wl_rateset_args {
335 u32 count; /* # rates in this set */
336 u8 rates[WL_NUMRATES]; /* rates in 500kbps units w/hi bit set if basic */
337 u8 mcs[MCSSET_LEN]; /* supported mcs index bit map */
338 } wl_rateset_args_t;
339
340 /* u32 list */
341 typedef struct wl_u32_list {
342 /* in - # of elements, out - # of entries */
343 u32 count;
344 /* variable length u32 list */
345 u32 element[1];
346 } wl_u32_list_t;
347
348 /* used for association with a specific BSSID and chanspec list */
349 typedef struct wl_assoc_params {
350 u8 bssid[ETH_ALEN]; /* 00:00:00:00:00:00: broadcast scan */
351 s32 chanspec_num; /* 0: all available channels,
352 * otherwise count of chanspecs in chanspec_list
353 */
354 chanspec_t chanspec_list[1]; /* list of chanspecs */
355 } wl_assoc_params_t;
356 #define WL_ASSOC_PARAMS_FIXED_SIZE (sizeof(wl_assoc_params_t) - sizeof(chanspec_t))
357
358 /* used for reassociation/roam to a specific BSSID and channel */
359 typedef wl_assoc_params_t wl_reassoc_params_t;
360 #define WL_REASSOC_PARAMS_FIXED_SIZE WL_ASSOC_PARAMS_FIXED_SIZE
361
362 /* used for join with or without a specific bssid and channel list */
363 typedef struct wl_join_params {
364 wlc_ssid_t ssid;
365 wl_assoc_params_t params; /* optional field, but it must include the fixed portion
366 * of the wl_assoc_params_t struct when it does present.
367 */
368 } wl_join_params_t;
369 #define WL_JOIN_PARAMS_FIXED_SIZE (sizeof(wl_join_params_t) - sizeof(chanspec_t))
370
371 /* size of wl_scan_results not including variable length array */
372 #define WL_SCAN_RESULTS_FIXED_SIZE (sizeof(wl_scan_results_t) - sizeof(wl_bss_info_t))
373
374 /* incremental scan results struct */
375 typedef struct wl_iscan_results {
376 u32 status;
377 wl_scan_results_t results;
378 } wl_iscan_results_t;
379
380 /* size of wl_iscan_results not including variable length array */
381 #define WL_ISCAN_RESULTS_FIXED_SIZE \
382 (WL_SCAN_RESULTS_FIXED_SIZE + offsetof(wl_iscan_results_t, results))
383
384 typedef struct {
385 u32 duration; /* millisecs spent sampling this channel */
386 u32 congest_ibss; /* millisecs in our bss (presumably this traffic will */
387 /* move if cur bss moves channels) */
388 u32 congest_obss; /* traffic not in our bss */
389 u32 interference; /* millisecs detecting a non 802.11 interferer. */
390 u32 timestamp; /* second timestamp */
391 } cca_congest_t;
392
393 typedef struct {
394 chanspec_t chanspec; /* Which channel? */
395 u8 num_secs; /* How many secs worth of data */
396 cca_congest_t secs[1]; /* Data */
397 } cca_congest_channel_req_t;
398
399 typedef struct wl_country {
400 char country_abbrev[WLC_CNTRY_BUF_SZ]; /* nul-terminated country code used in
401 * the Country IE
402 */
403 s32 rev; /* revision specifier for ccode
404 * on set, -1 indicates unspecified.
405 * on get, rev >= 0
406 */
407 char ccode[WLC_CNTRY_BUF_SZ]; /* nul-terminated built-in country code.
408 * variable length, but fixed size in
409 * struct allows simple allocation for
410 * expected country strings <= 3 chars.
411 */
412 } wl_country_t;
413
414 typedef struct wl_channels_in_country {
415 u32 buflen;
416 u32 band;
417 char country_abbrev[WLC_CNTRY_BUF_SZ];
418 u32 count;
419 u32 channel[1];
420 } wl_channels_in_country_t;
421
422 typedef struct wl_country_list {
423 u32 buflen;
424 u32 band_set;
425 u32 band;
426 u32 count;
427 char country_abbrev[1];
428 } wl_country_list_t;
429
430 typedef struct wl_rm_req_elt {
431 s8 type;
432 s8 flags;
433 chanspec_t chanspec;
434 u32 token; /* token for this measurement */
435 u32 tsf_h; /* TSF high 32-bits of Measurement start time */
436 u32 tsf_l; /* TSF low 32-bits */
437 u32 dur; /* TUs */
438 } wl_rm_req_elt_t;
439
440 typedef struct wl_rm_req {
441 u32 token; /* overall measurement set token */
442 u32 count; /* number of measurement requests */
443 void *cb; /* completion callback function: may be NULL */
444 void *cb_arg; /* arg to completion callback function */
445 wl_rm_req_elt_t req[1]; /* variable length block of requests */
446 } wl_rm_req_t;
447 #define WL_RM_REQ_FIXED_LEN offsetof(wl_rm_req_t, req)
448
449 typedef struct wl_rm_rep_elt {
450 s8 type;
451 s8 flags;
452 chanspec_t chanspec;
453 u32 token; /* token for this measurement */
454 u32 tsf_h; /* TSF high 32-bits of Measurement start time */
455 u32 tsf_l; /* TSF low 32-bits */
456 u32 dur; /* TUs */
457 u32 len; /* byte length of data block */
458 u8 data[1]; /* variable length data block */
459 } wl_rm_rep_elt_t;
460 #define WL_RM_REP_ELT_FIXED_LEN 24 /* length excluding data block */
461
462 #define WL_RPI_REP_BIN_NUM 8
463 typedef struct wl_rm_rpi_rep {
464 u8 rpi[WL_RPI_REP_BIN_NUM];
465 s8 rpi_max[WL_RPI_REP_BIN_NUM];
466 } wl_rm_rpi_rep_t;
467
468 typedef struct wl_rm_rep {
469 u32 token; /* overall measurement set token */
470 u32 len; /* length of measurement report block */
471 wl_rm_rep_elt_t rep[1]; /* variable length block of reports */
472 } wl_rm_rep_t;
473 #define WL_RM_REP_FIXED_LEN 8
474
475 typedef struct wl_wsec_key {
476 u32 index; /* key index */
477 u32 len; /* key length */
478 u8 data[WLAN_MAX_KEY_LEN]; /* key data */
479 u32 pad_1[18];
480 u32 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
481 u32 flags; /* misc flags */
482 u32 pad_2[2];
483 int pad_3;
484 int iv_initialized; /* has IV been initialized already? */
485 int pad_4;
486 /* Rx IV */
487 struct {
488 u32 hi; /* upper 32 bits of IV */
489 u16 lo; /* lower 16 bits of IV */
490 } rxiv;
491 u32 pad_5[2];
492 u8 ea[ETH_ALEN]; /* per station */
493 } wl_wsec_key_t;
494
495 /* Used to get specific STA parameters */
496 typedef struct {
497 u32 val;
498 u8 ea[ETH_ALEN];
499 } scb_val_t;
500
501 /* channel encoding */
502 typedef struct channel_info {
503 int hw_channel;
504 int target_channel;
505 int scan_channel;
506 } channel_info_t;
507
508 /* Linux network driver ioctl encoding */
509 typedef struct wl_ioctl {
510 uint cmd; /* common ioctl definition */
511 void *buf; /* pointer to user buffer */
512 uint len; /* length of user buffer */
513 u8 set; /* get or set request (optional) */
514 uint used; /* bytes read or written (optional) */
515 uint needed; /* bytes needed (optional) */
516 } wl_ioctl_t;
517
518 /* Common structure for module and instance linkage */
519 typedef struct dhd_pub {
520 /* Linkage ponters */
521 struct dhd_bus *bus; /* Bus module handle */
522 struct dhd_prot *prot; /* Protocol module handle */
523 struct dhd_info *info; /* Info module handle */
524
525 /* Internal dhd items */
526 bool up; /* Driver up/down (to OS) */
527 bool txoff; /* Transmit flow-controlled */
528 bool dongle_reset; /* true = DEVRESET put dongle into reset */
529 enum dhd_bus_state busstate;
530 uint hdrlen; /* Total DHD header length (proto + bus) */
531 uint maxctl; /* Max size rxctl request from proto to bus */
532 uint rxsz; /* Rx buffer size bus module should use */
533 u8 wme_dp; /* wme discard priority */
534
535 /* Dongle media info */
536 bool iswl; /* Dongle-resident driver is wl */
537 unsigned long drv_version; /* Version of dongle-resident driver */
538 u8 mac[ETH_ALEN]; /* MAC address obtained from dongle */
539 dngl_stats_t dstats; /* Stats for dongle-based data */
540
541 /* Additional stats for the bus level */
542 unsigned long tx_packets; /* Data packets sent to dongle */
543 unsigned long tx_multicast; /* Multicast data packets sent to dongle */
544 unsigned long tx_errors; /* Errors in sending data to dongle */
545 unsigned long tx_ctlpkts; /* Control packets sent to dongle */
546 unsigned long tx_ctlerrs; /* Errors sending control frames to dongle */
547 unsigned long rx_packets; /* Packets sent up the network interface */
548 unsigned long rx_multicast; /* Multicast packets sent up the network
549 interface */
550 unsigned long rx_errors; /* Errors processing rx data packets */
551 unsigned long rx_ctlpkts; /* Control frames processed from dongle */
552 unsigned long rx_ctlerrs; /* Errors in processing rx control frames */
553 unsigned long rx_dropped; /* Packets dropped locally (no memory) */
554 unsigned long rx_flushed; /* Packets flushed due to
555 unscheduled sendup thread */
556 unsigned long wd_dpc_sched; /* Number of times dhd dpc scheduled by
557 watchdog timer */
558
559 unsigned long rx_readahead_cnt; /* Number of packets where header read-ahead
560 was used. */
561 unsigned long tx_realloc; /* Number of tx packets we had to realloc for
562 headroom */
563 unsigned long fc_packets; /* Number of flow control pkts recvd */
564
565 /* Last error return */
566 int bcmerror;
567 uint tickcnt;
568
569 /* Last error from dongle */
570 int dongle_error;
571
572 /* Suspend disable flag flag */
573 int suspend_disable_flag; /* "1" to disable all extra powersaving
574 during suspend */
575 int in_suspend; /* flag set to 1 when early suspend called */
576 #ifdef PNO_SUPPORT
577 int pno_enable; /* pno status : "1" is pno enable */
578 #endif /* PNO_SUPPORT */
579 int dtim_skip; /* dtim skip , default 0 means wake each dtim */
580
581 /* Pkt filter defination */
582 char *pktfilter[100];
583 int pktfilter_count;
584
585 u8 country_code[WLC_CNTRY_BUF_SZ];
586 char eventmask[WL_EVENTING_MASK_LEN];
587
588 } dhd_pub_t;
589
590 typedef struct dhd_if_event {
591 u8 ifidx;
592 u8 action;
593 u8 flags;
594 u8 bssidx;
595 } dhd_if_event_t;
596
597 typedef struct {
598 u32 limit; /* Expiration time (usec) */
599 u32 increment; /* Current expiration increment (usec) */
600 u32 elapsed; /* Current elapsed time (usec) */
601 u32 tick; /* O/S tick time (usec) */
602 } dhd_timeout_t;
603
604 #if defined(CONFIG_PM_SLEEP)
605 extern atomic_t dhd_mmc_suspend;
606 #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
607 #define _DHD_PM_RESUME_WAIT(a, b) do { \
608 int retry = 0; \
609 while (atomic_read(&dhd_mmc_suspend) && retry++ != b) { \
610 wait_event_timeout(a, false, HZ/100); \
611 } \
612 } while (0)
613 #define DHD_PM_RESUME_WAIT(a) _DHD_PM_RESUME_WAIT(a, 30)
614 #define DHD_PM_RESUME_WAIT_FOREVER(a) _DHD_PM_RESUME_WAIT(a, ~0)
615 #define DHD_PM_RESUME_RETURN_ERROR(a) \
616 do { if (atomic_read(&dhd_mmc_suspend)) return a; } while (0)
617 #define DHD_PM_RESUME_RETURN do { \
618 if (atomic_read(&dhd_mmc_suspend)) \
619 return; \
620 } while (0)
621
622 #define DHD_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
623 #define SPINWAIT_SLEEP(a, exp, us) do { \
624 uint countdown = (us) + 9999; \
625 while ((exp) && (countdown >= 10000)) { \
626 wait_event_timeout(a, false, HZ/100); \
627 countdown -= 10000; \
628 } \
629 } while (0)
630
631 #else
632
633 #define DHD_PM_RESUME_WAIT_INIT(a)
634 #define DHD_PM_RESUME_WAIT(a)
635 #define DHD_PM_RESUME_WAIT_FOREVER(a)
636 #define DHD_PM_RESUME_RETURN_ERROR(a)
637 #define DHD_PM_RESUME_RETURN
638
639 #define DHD_SPINWAIT_SLEEP_INIT(a)
640 #define SPINWAIT_SLEEP(a, exp, us) do { \
641 uint countdown = (us) + 9; \
642 while ((exp) && (countdown >= 10)) { \
643 udelay(10); \
644 countdown -= 10; \
645 } \
646 } while (0)
647
648 #endif /* defined(CONFIG_PM_SLEEP) */
649
650 /*
651 * Insmod parameters for debug/test
652 */
653
654 /* Watchdog timer interval */
655 extern uint dhd_watchdog_ms;
656
657 #if defined(DHD_DEBUG)
658 /* Console output poll interval */
659 extern uint dhd_console_ms;
660 #endif /* defined(DHD_DEBUG) */
661
662 /* Use interrupts */
663 extern uint dhd_intr;
664
665 /* Use polling */
666 extern uint dhd_poll;
667
668 /* ARP offload agent mode */
669 extern uint dhd_arp_mode;
670
671 /* ARP offload enable */
672 extern uint dhd_arp_enable;
673
674 /* Pkt filte enable control */
675 extern uint dhd_pkt_filter_enable;
676
677 /* Pkt filter init setup */
678 extern uint dhd_pkt_filter_init;
679
680 /* Pkt filter mode control */
681 extern uint dhd_master_mode;
682
683 /* Roaming mode control */
684 extern uint dhd_roam;
685
686 /* Roaming mode control */
687 extern uint dhd_radio_up;
688
689 /* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */
690 extern int dhd_idletime;
691 #define DHD_IDLETIME_TICKS 1
692
693 /* SDIO Drive Strength */
694 extern uint dhd_sdiod_drive_strength;
695
696 /* Override to force tx queueing all the time */
697 extern uint dhd_force_tx_queueing;
698
699 #ifdef SDTEST
700 /* Echo packet generator (SDIO), pkts/s */
701 extern uint dhd_pktgen;
702
703 /* Echo packet len (0 => sawtooth, max 1800) */
704 extern uint dhd_pktgen_len;
705 #define MAX_PKTGEN_LEN 1800
706 #endif
707
708 extern char fw_path[MOD_PARAM_PATHLEN];
709 extern char nv_path[MOD_PARAM_PATHLEN];
710
711 extern u32 g_assert_type;
712
713 static inline void MUTEX_LOCK_INIT(dhd_pub_t *dhdp)
714 {
715 }
716
717 static inline void MUTEX_LOCK(dhd_pub_t *dhdp)
718 {
719 }
720
721 static inline void MUTEX_UNLOCK(dhd_pub_t *dhdp)
722 {
723 }
724
725 static inline void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t *dhdp)
726 {
727 }
728
729 static inline void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t *dhdp)
730 {
731 }
732
733 static inline void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t *dhdp)
734 {
735 }
736
737 static inline void MUTEX_LOCK_WL_SCAN_SET_INIT(void)
738 {
739 }
740
741 static inline void MUTEX_LOCK_WL_SCAN_SET(void)
742 {
743 }
744
745 static inline void MUTEX_UNLOCK_WL_SCAN_SET(void)
746 {
747 }
748
749 /*
750 * Exported from dhd OS modules (dhd_linux/dhd_ndis)
751 */
752
753 /* Indication from bus module regarding presence/insertion of dongle.
754 * Return dhd_pub_t pointer, used as handle to OS module in later calls.
755 * Returned structure should have bus and prot pointers filled in.
756 * bus_hdrlen specifies required headroom for bus module header.
757 */
758 extern dhd_pub_t *dhd_attach(struct dhd_bus *bus,
759 uint bus_hdrlen);
760 extern int dhd_net_attach(dhd_pub_t *dhdp, int idx);
761
762 /* Indication from bus module regarding removal/absence of dongle */
763 extern void dhd_detach(dhd_pub_t *dhdp);
764
765 /* Indication from bus module to change flow-control state */
766 extern void dhd_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool on);
767
768 extern bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q,
769 struct sk_buff *pkt, int prec);
770
771 /* Receive frame for delivery to OS. Callee disposes of rxp. */
772 extern void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx,
773 struct sk_buff *rxp, int numpkt);
774
775 /* Return pointer to interface name */
776 extern char *dhd_ifname(dhd_pub_t *dhdp, int idx);
777
778 /* Request scheduling of the bus dpc */
779 extern void dhd_sched_dpc(dhd_pub_t *dhdp);
780
781 /* Notify tx completion */
782 extern void dhd_txcomplete(dhd_pub_t *dhdp, struct sk_buff *txp, bool success);
783
784 /* Query ioctl */
785 extern int dhdcdc_query_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf,
786 uint len);
787
788 /* OS independent layer functions */
789 extern int dhd_os_proto_block(dhd_pub_t *pub);
790 extern int dhd_os_proto_unblock(dhd_pub_t *pub);
791 extern int dhd_os_ioctl_resp_wait(dhd_pub_t *pub, uint *condition,
792 bool *pending);
793 extern int dhd_os_ioctl_resp_wake(dhd_pub_t *pub);
794 extern unsigned int dhd_os_get_ioctl_resp_timeout(void);
795 extern void dhd_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
796 extern void *dhd_os_open_image(char *filename);
797 extern int dhd_os_get_image_block(char *buf, int len, void *image);
798 extern void dhd_os_close_image(void *image);
799 extern void dhd_os_wd_timer(void *bus, uint wdtick);
800 extern void dhd_os_sdlock(dhd_pub_t *pub);
801 extern void dhd_os_sdunlock(dhd_pub_t *pub);
802 extern void dhd_os_sdlock_txq(dhd_pub_t *pub);
803 extern void dhd_os_sdunlock_txq(dhd_pub_t *pub);
804 extern void dhd_os_sdlock_rxq(dhd_pub_t *pub);
805 extern void dhd_os_sdunlock_rxq(dhd_pub_t *pub);
806 extern void dhd_os_sdlock_sndup_rxq(dhd_pub_t *pub);
807 extern void dhd_customer_gpio_wlan_ctrl(int onoff);
808 extern int dhd_custom_get_mac_address(unsigned char *buf);
809 extern void dhd_os_sdunlock_sndup_rxq(dhd_pub_t *pub);
810 extern void dhd_os_sdlock_eventq(dhd_pub_t *pub);
811 extern void dhd_os_sdunlock_eventq(dhd_pub_t *pub);
812 #ifdef DHD_DEBUG
813 extern int write_to_file(dhd_pub_t *dhd, u8 *buf, int size);
814 #endif /* DHD_DEBUG */
815 #if defined(OOB_INTR_ONLY)
816 extern int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr);
817 #endif /* defined(OOB_INTR_ONLY) */
818 extern void dhd_os_sdtxlock(dhd_pub_t *pub);
819 extern void dhd_os_sdtxunlock(dhd_pub_t *pub);
820
821 int setScheduler(struct task_struct *p, int policy, struct sched_param *param);
822
823 extern void dhd_timeout_start(dhd_timeout_t *tmo, uint usec);
824 extern int dhd_timeout_expired(dhd_timeout_t *tmo);
825
826 extern int dhd_ifname2idx(struct dhd_info *dhd, char *name);
827 extern u8 *dhd_bssidx2bssid(dhd_pub_t *dhd, int idx);
828 extern int wl_host_event(struct dhd_info *dhd, int *idx, void *pktdata,
829 wl_event_msg_t *, void **data_ptr);
830
831 extern void dhd_common_init(void);
832
833 extern int dhd_add_if(struct dhd_info *dhd, int ifidx, void *handle,
834 char *name, u8 *mac_addr, u32 flags, u8 bssidx);
835 extern void dhd_del_if(struct dhd_info *dhd, int ifidx);
836
837 extern void dhd_vif_add(struct dhd_info *dhd, int ifidx, char *name);
838 extern void dhd_vif_del(struct dhd_info *dhd, int ifidx);
839
840 extern void dhd_event(struct dhd_info *dhd, char *evpkt, int evlen, int ifidx);
841 extern void dhd_vif_sendup(struct dhd_info *dhd, int ifidx, unsigned char * cp,
842 int len);
843
844 /* Send packet to dongle via data channel */
845 extern int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, struct sk_buff *pkt);
846
847 /* Send event to host */
848 extern void dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event,
849 void *data);
850 extern int dhd_bus_devreset(dhd_pub_t *dhdp, u8 flag);
851 extern uint dhd_bus_status(dhd_pub_t *dhdp);
852 extern int dhd_bus_start(dhd_pub_t *dhdp);
853
854 extern void dhd_wait_for_event(dhd_pub_t *dhd, bool * lockvar);
855 extern void dhd_wait_event_wakeup(dhd_pub_t *dhd);
856
857 #ifdef BCMDBG
858 #define ASSERT(exp) \
859 do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0)
860 extern void osl_assert(char *exp, char *file, int line);
861 #else
862 #define ASSERT(exp) do {} while (0)
863 #endif /* defined(BCMDBG) */
864
865 /* Linux network driver ioctl encoding */
866 typedef struct dhd_ioctl {
867 uint cmd; /* common ioctl definition */
868 void *buf; /* pointer to user buffer */
869 uint len; /* length of user buffer */
870 bool set; /* get or set request (optional) */
871 uint used; /* bytes read or written (optional) */
872 uint needed; /* bytes needed (optional) */
873 uint driver; /* to identify target driver */
874 } dhd_ioctl_t;
875
876 /* per-driver magic numbers */
877 #define DHD_IOCTL_MAGIC 0x00444944
878
879 /* bump this number if you change the ioctl interface */
880 #define DHD_IOCTL_VERSION 1
881
882 #define DHD_IOCTL_MAXLEN 8192 /* max length ioctl buffer required */
883 #define DHD_IOCTL_SMLEN 256 /* "small" length ioctl buffer required */
884
885 /* common ioctl definitions */
886 #define DHD_GET_MAGIC 0
887 #define DHD_GET_VERSION 1
888 #define DHD_GET_VAR 2
889 #define DHD_SET_VAR 3
890
891 /* message levels */
892 #define DHD_ERROR_VAL 0x0001
893 #define DHD_TRACE_VAL 0x0002
894 #define DHD_INFO_VAL 0x0004
895 #define DHD_DATA_VAL 0x0008
896 #define DHD_CTL_VAL 0x0010
897 #define DHD_TIMER_VAL 0x0020
898 #define DHD_HDRS_VAL 0x0040
899 #define DHD_BYTES_VAL 0x0080
900 #define DHD_INTR_VAL 0x0100
901 #define DHD_LOG_VAL 0x0200
902 #define DHD_GLOM_VAL 0x0400
903 #define DHD_EVENT_VAL 0x0800
904 #define DHD_BTA_VAL 0x1000
905 #define DHD_ISCAN_VAL 0x2000
906
907 #ifdef SDTEST
908 /* For pktgen iovar */
909 typedef struct dhd_pktgen {
910 uint version; /* To allow structure change tracking */
911 uint freq; /* Max ticks between tx/rx attempts */
912 uint count; /* Test packets to send/rcv each attempt */
913 uint print; /* Print counts every <print> attempts */
914 uint total; /* Total packets (or bursts) */
915 uint minlen; /* Minimum length of packets to send */
916 uint maxlen; /* Maximum length of packets to send */
917 uint numsent; /* Count of test packets sent */
918 uint numrcvd; /* Count of test packets received */
919 uint numfail; /* Count of test send failures */
920 uint mode; /* Test mode (type of test packets) */
921 uint stop; /* Stop after this many tx failures */
922 } dhd_pktgen_t;
923
924 /* Version in case structure changes */
925 #define DHD_PKTGEN_VERSION 2
926
927 /* Type of test packets to use */
928 #define DHD_PKTGEN_ECHO 1 /* Send echo requests */
929 #define DHD_PKTGEN_SEND 2 /* Send discard packets */
930 #define DHD_PKTGEN_RXBURST 3 /* Request dongle send N packets */
931 #define DHD_PKTGEN_RECV 4 /* Continuous rx from continuous
932 tx dongle */
933 #endif /* SDTEST */
934
935 /* Enter idle immediately (no timeout) */
936 #define DHD_IDLE_IMMEDIATE (-1)
937
938 /* Values for idleclock iovar: other values are the sd_divisor to use
939 when idle */
940 #define DHD_IDLE_ACTIVE 0 /* Do not request any SD clock change
941 when idle */
942 #define DHD_IDLE_STOP (-1) /* Request SD clock be stopped
943 (and use SD1 mode) */
944
945 #endif /* _dhd_h_ */
This page took 0.049282 seconds and 6 git commands to generate.