drivers/char/mem.c: avoid OOM lockup during large reads from /dev/zero
[safe/jmp/linux-2.6] / drivers / staging / at76_usb / at76_usb.h
1 /*
2  * Copyright (c) 2002,2003 Oliver Kurth
3  *           (c) 2003,2004 Joerg Albert <joerg.albert@gmx.de>
4  *           (c) 2007 Guido Guenther <agx@sigxcpu.org>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This driver was based on information from the Sourceforge driver
12  * released and maintained by Atmel:
13  *
14  *  http://sourceforge.net/projects/atmelwlandriver/
15  *
16  * Although the code was completely re-written,
17  * it would have been impossible without Atmel's decision to
18  * release an Open Source driver (unfortunately the firmware was
19  * kept binary only). Thanks for that decision to Atmel!
20  */
21
22 #ifndef _AT76_USB_H
23 #define _AT76_USB_H
24
25 /*
26  * ieee80211 definitions copied from net/ieee80211.h
27  */
28
29 #define WEP_KEY_LEN             13
30 #define WEP_KEYS                4
31
32 #define IEEE80211_DATA_LEN              2304
33 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
34    6.2.1.1.2.
35
36    The figure in section 7.1.2 suggests a body size of up to 2312
37    bytes is allowed, which is a bit confusing, I suspect this
38    represents the 2304 bytes of real data, plus a possible 8 bytes of
39    WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
40
41 #define IEEE80211_1ADDR_LEN 10
42 #define IEEE80211_2ADDR_LEN 16
43 #define IEEE80211_3ADDR_LEN 24
44 #define IEEE80211_4ADDR_LEN 30
45 #define IEEE80211_FCS_LEN    4
46 #define IEEE80211_HLEN                  (IEEE80211_4ADDR_LEN)
47 #define IEEE80211_FRAME_LEN             (IEEE80211_DATA_LEN + IEEE80211_HLEN)
48
49 #define MIN_FRAG_THRESHOLD     256U
50 #define MAX_FRAG_THRESHOLD     2346U
51
52 struct ieee80211_info_element {
53         u8 id;
54         u8 len;
55         u8 data[0];
56 } __attribute__ ((packed));
57
58 struct ieee80211_hdr_3addr {
59         __le16 frame_ctl;
60         __le16 duration_id;
61         u8 addr1[ETH_ALEN];
62         u8 addr2[ETH_ALEN];
63         u8 addr3[ETH_ALEN];
64         __le16 seq_ctl;
65         u8 payload[0];
66 } __attribute__ ((packed));
67
68 struct ieee80211_auth {
69         struct ieee80211_hdr_3addr header;
70         __le16 algorithm;
71         __le16 transaction;
72         __le16 status;
73         /* challenge */
74         struct ieee80211_info_element info_element[0];
75 } __attribute__ ((packed));
76
77 struct ieee80211_assoc_request {
78         struct ieee80211_hdr_3addr header;
79         __le16 capability;
80         __le16 listen_interval;
81         /* SSID, supported rates, RSN */
82         struct ieee80211_info_element info_element[0];
83 } __attribute__ ((packed));
84
85 struct ieee80211_probe_response {
86         struct ieee80211_hdr_3addr header;
87         __le32 time_stamp[2];
88         __le16 beacon_interval;
89         __le16 capability;
90         /* SSID, supported rates, FH params, DS params,
91          * CF params, IBSS params, TIM (if beacon), RSN */
92         struct ieee80211_info_element info_element[0];
93 } __attribute__ ((packed));
94
95 /* Alias beacon for probe_response */
96 #define ieee80211_beacon ieee80211_probe_response
97
98 struct ieee80211_assoc_response {
99         struct ieee80211_hdr_3addr header;
100         __le16 capability;
101         __le16 status;
102         __le16 aid;
103         /* supported rates */
104         struct ieee80211_info_element info_element[0];
105 } __attribute__ ((packed));
106
107 struct ieee80211_disassoc {
108         struct ieee80211_hdr_3addr header;
109         __le16 reason;
110 } __attribute__ ((packed));
111
112 /* Board types */
113 enum board_type {
114         BOARD_503_ISL3861 = 1,
115         BOARD_503_ISL3863 = 2,
116         BOARD_503 = 3,
117         BOARD_503_ACC = 4,
118         BOARD_505 = 5,
119         BOARD_505_2958 = 6,
120         BOARD_505A = 7,
121         BOARD_505AMX = 8
122 };
123
124 /* our private ioctl's */
125 /* preamble length (0 - long, 1 - short, 2 - auto) */
126 #define AT76_SET_SHORT_PREAMBLE         (SIOCIWFIRSTPRIV + 0)
127 #define AT76_GET_SHORT_PREAMBLE         (SIOCIWFIRSTPRIV + 1)
128 /* which debug channels are enabled */
129 #define AT76_SET_DEBUG                  (SIOCIWFIRSTPRIV + 2)
130 #define AT76_GET_DEBUG                  (SIOCIWFIRSTPRIV + 3)
131 /* power save mode (incl. the Atmel proprietary smart save mode) */
132 #define AT76_SET_POWERSAVE_MODE         (SIOCIWFIRSTPRIV + 4)
133 #define AT76_GET_POWERSAVE_MODE         (SIOCIWFIRSTPRIV + 5)
134 /* min and max channel times for scan */
135 #define AT76_SET_SCAN_TIMES             (SIOCIWFIRSTPRIV + 6)
136 #define AT76_GET_SCAN_TIMES             (SIOCIWFIRSTPRIV + 7)
137 /* scan mode (0 - active, 1 - passive) */
138 #define AT76_SET_SCAN_MODE              (SIOCIWFIRSTPRIV + 8)
139 #define AT76_GET_SCAN_MODE              (SIOCIWFIRSTPRIV + 9)
140
141 #define CMD_STATUS_IDLE                         0x00
142 #define CMD_STATUS_COMPLETE                     0x01
143 #define CMD_STATUS_UNKNOWN                      0x02
144 #define CMD_STATUS_INVALID_PARAMETER            0x03
145 #define CMD_STATUS_FUNCTION_NOT_SUPPORTED       0x04
146 #define CMD_STATUS_TIME_OUT                     0x07
147 #define CMD_STATUS_IN_PROGRESS                  0x08
148 #define CMD_STATUS_HOST_FAILURE                 0xff
149 #define CMD_STATUS_SCAN_FAILED                  0xf0
150
151 /* answers to get op mode */
152 #define OPMODE_NONE                             0x00
153 #define OPMODE_NORMAL_NIC_WITH_FLASH            0x01
154 #define OPMODE_HW_CONFIG_MODE                   0x02
155 #define OPMODE_DFU_MODE_WITH_FLASH              0x03
156 #define OPMODE_NORMAL_NIC_WITHOUT_FLASH         0x04
157
158 #define CMD_SET_MIB             0x01
159 #define CMD_GET_MIB             0x02
160 #define CMD_SCAN                0x03
161 #define CMD_JOIN                0x04
162 #define CMD_START_IBSS          0x05
163 #define CMD_RADIO_ON            0x06
164 #define CMD_RADIO_OFF           0x07
165 #define CMD_STARTUP             0x0B
166
167 #define MIB_LOCAL               0x01
168 #define MIB_MAC_ADDR            0x02
169 #define MIB_MAC                 0x03
170 #define MIB_MAC_MGMT            0x05
171 #define MIB_MAC_WEP             0x06
172 #define MIB_PHY                 0x07
173 #define MIB_FW_VERSION          0x08
174 #define MIB_MDOMAIN             0x09
175
176 #define ADHOC_MODE              1
177 #define INFRASTRUCTURE_MODE     2
178
179 /* values for struct mib_local, field preamble_type */
180 #define PREAMBLE_TYPE_LONG      0
181 #define PREAMBLE_TYPE_SHORT     1
182 #define PREAMBLE_TYPE_AUTO      2
183
184 /* values for tx_rate */
185 #define TX_RATE_1MBIT           0
186 #define TX_RATE_2MBIT           1
187 #define TX_RATE_5_5MBIT         2
188 #define TX_RATE_11MBIT          3
189 #define TX_RATE_AUTO            4
190
191 /* power management modes */
192 #define AT76_PM_OFF             1
193 #define AT76_PM_ON              2
194 #define AT76_PM_SMART           3
195
196 struct hwcfg_r505 {
197         u8 cr39_values[14];
198         u8 reserved1[14];
199         u8 bb_cr[14];
200         u8 pidvid[4];
201         u8 mac_addr[ETH_ALEN];
202         u8 regulatory_domain;
203         u8 reserved2[14];
204         u8 cr15_values[14];
205         u8 reserved3[3];
206 } __attribute__((packed));
207
208 struct hwcfg_rfmd {
209         u8 cr20_values[14];
210         u8 cr21_values[14];
211         u8 bb_cr[14];
212         u8 pidvid[4];
213         u8 mac_addr[ETH_ALEN];
214         u8 regulatory_domain;
215         u8 low_power_values[14];
216         u8 normal_power_values[14];
217         u8 reserved1[3];
218 } __attribute__((packed));
219
220 struct hwcfg_intersil {
221         u8 mac_addr[ETH_ALEN];
222         u8 cr31_values[14];
223         u8 cr58_values[14];
224         u8 pidvid[4];
225         u8 regulatory_domain;
226         u8 reserved[1];
227 } __attribute__((packed));
228
229 union at76_hwcfg {
230         struct hwcfg_intersil i;
231         struct hwcfg_rfmd r3;
232         struct hwcfg_r505 r5;
233 };
234
235 #define WEP_SMALL_KEY_LEN       (40 / 8)
236 #define WEP_LARGE_KEY_LEN       (104 / 8)
237
238 struct at76_card_config {
239         u8 exclude_unencrypted;
240         u8 promiscuous_mode;
241         u8 short_retry_limit;
242         u8 encryption_type;
243         __le16 rts_threshold;
244         __le16 fragmentation_threshold; /* 256..2346 */
245         u8 basic_rate_set[4];
246         u8 auto_rate_fallback;  /* 0,1 */
247         u8 channel;
248         u8 privacy_invoked;
249         u8 wep_default_key_id;  /* 0..3 */
250         u8 current_ssid[32];
251         u8 wep_default_key_value[4][WEP_KEY_LEN];
252         u8 ssid_len;
253         u8 short_preamble;
254         __le16 beacon_period;
255 } __attribute__((packed));
256
257 struct at76_command {
258         u8 cmd;
259         u8 reserved;
260         __le16 size;
261         u8 data[0];
262 } __attribute__((packed));
263
264 /* Length of Atmel-specific Rx header before 802.11 frame */
265 #define AT76_RX_HDRLEN offsetof(struct at76_rx_buffer, packet)
266
267 struct at76_rx_buffer {
268         __le16 wlength;
269         u8 rx_rate;
270         u8 newbss;
271         u8 fragmentation;
272         u8 rssi;
273         u8 link_quality;
274         u8 noise_level;
275         __le32 rx_time;
276         u8 packet[IEEE80211_FRAME_LEN + IEEE80211_FCS_LEN];
277 } __attribute__((packed));
278
279 /* Length of Atmel-specific Tx header before 802.11 frame */
280 #define AT76_TX_HDRLEN offsetof(struct at76_tx_buffer, packet)
281
282 struct at76_tx_buffer {
283         __le16 wlength;
284         u8 tx_rate;
285         u8 padding;
286         u8 reserved[4];
287         u8 packet[IEEE80211_FRAME_LEN + IEEE80211_FCS_LEN];
288 } __attribute__((packed));
289
290 /* defines for scan_type below */
291 #define SCAN_TYPE_ACTIVE        0
292 #define SCAN_TYPE_PASSIVE       1
293
294 struct at76_req_scan {
295         u8 bssid[ETH_ALEN];
296         u8 essid[32];
297         u8 scan_type;
298         u8 channel;
299         __le16 probe_delay;
300         __le16 min_channel_time;
301         __le16 max_channel_time;
302         u8 essid_size;
303         u8 international_scan;
304 } __attribute__((packed));
305
306 struct at76_req_ibss {
307         u8 bssid[ETH_ALEN];
308         u8 essid[32];
309         u8 bss_type;
310         u8 channel;
311         u8 essid_size;
312         u8 reserved[3];
313 } __attribute__((packed));
314
315 struct at76_req_join {
316         u8 bssid[ETH_ALEN];
317         u8 essid[32];
318         u8 bss_type;
319         u8 channel;
320         __le16 timeout;
321         u8 essid_size;
322         u8 reserved;
323 } __attribute__((packed));
324
325 struct set_mib_buffer {
326         u8 type;
327         u8 size;
328         u8 index;
329         u8 reserved;
330         union {
331                 u8 byte;
332                 __le16 word;
333                 u8 addr[ETH_ALEN];
334         } data;
335 } __attribute__((packed));
336
337 struct mib_local {
338         u16 reserved0;
339         u8 beacon_enable;
340         u8 txautorate_fallback;
341         u8 reserved1;
342         u8 ssid_size;
343         u8 promiscuous_mode;
344         u16 reserved2;
345         u8 preamble_type;
346         u16 reserved3;
347 } __attribute__((packed));
348
349 struct mib_mac_addr {
350         u8 mac_addr[ETH_ALEN];
351         u8 res[2];              /* ??? */
352         u8 group_addr[4][ETH_ALEN];
353         u8 group_addr_status[4];
354 } __attribute__((packed));
355
356 struct mib_mac {
357         __le32 max_tx_msdu_lifetime;
358         __le32 max_rx_lifetime;
359         __le16 frag_threshold;
360         __le16 rts_threshold;
361         __le16 cwmin;
362         __le16 cwmax;
363         u8 short_retry_time;
364         u8 long_retry_time;
365         u8 scan_type;           /* active or passive */
366         u8 scan_channel;
367         __le16 probe_delay;     /* delay before ProbeReq in active scan, RO */
368         __le16 min_channel_time;
369         __le16 max_channel_time;
370         __le16 listen_interval;
371         u8 desired_ssid[32];
372         u8 desired_bssid[ETH_ALEN];
373         u8 desired_bsstype;     /* ad-hoc or infrastructure */
374         u8 reserved2;
375 } __attribute__((packed));
376
377 struct mib_mac_mgmt {
378         __le16 beacon_period;
379         __le16 CFP_max_duration;
380         __le16 medium_occupancy_limit;
381         __le16 station_id;      /* assoc id */
382         __le16 ATIM_window;
383         u8 CFP_mode;
384         u8 privacy_option_implemented;
385         u8 DTIM_period;
386         u8 CFP_period;
387         u8 current_bssid[ETH_ALEN];
388         u8 current_essid[32];
389         u8 current_bss_type;
390         u8 power_mgmt_mode;
391         /* rfmd and 505 */
392         u8 ibss_change;
393         u8 res;
394         u8 multi_domain_capability_implemented;
395         u8 multi_domain_capability_enabled;
396         u8 country_string[3];
397         u8 reserved[3];
398 } __attribute__((packed));
399
400 struct mib_mac_wep {
401         u8 privacy_invoked;     /* 0 disable encr., 1 enable encr */
402         u8 wep_default_key_id;
403         u8 wep_key_mapping_len;
404         u8 exclude_unencrypted;
405         __le32 wep_icv_error_count;
406         __le32 wep_excluded_count;
407         u8 wep_default_keyvalue[WEP_KEYS][WEP_KEY_LEN];
408         u8 encryption_level;    /* 1 for 40bit, 2 for 104bit encryption */
409 } __attribute__((packed));
410
411 struct mib_phy {
412         __le32 ed_threshold;
413
414         __le16 slot_time;
415         __le16 sifs_time;
416         __le16 preamble_length;
417         __le16 plcp_header_length;
418         __le16 mpdu_max_length;
419         __le16 cca_mode_supported;
420
421         u8 operation_rate_set[4];
422         u8 channel_id;
423         u8 current_cca_mode;
424         u8 phy_type;
425         u8 current_reg_domain;
426 } __attribute__((packed));
427
428 struct mib_fw_version {
429         u8 major;
430         u8 minor;
431         u8 patch;
432         u8 build;
433 } __attribute__((packed));
434
435 struct mib_mdomain {
436         u8 tx_powerlevel[14];
437         u8 channel_list[14];    /* 0 for invalid channels */
438 } __attribute__((packed));
439
440 struct at76_fw_header {
441         __le32 crc;             /* CRC32 of the whole image */
442         __le32 board_type;      /* firmware compatibility code */
443         u8 build;               /* firmware build number */
444         u8 patch;               /* firmware patch level */
445         u8 minor;               /* firmware minor version */
446         u8 major;               /* firmware major version */
447         __le32 str_offset;      /* offset of the copyright string */
448         __le32 int_fw_offset;   /* internal firmware image offset */
449         __le32 int_fw_len;      /* internal firmware image length */
450         __le32 ext_fw_offset;   /* external firmware image offset */
451         __le32 ext_fw_len;      /* external firmware image length */
452 } __attribute__((packed));
453
454 enum mac_state {
455         MAC_INIT,
456         MAC_SCANNING,
457         MAC_AUTH,
458         MAC_ASSOC,
459         MAC_JOINING,
460         MAC_CONNECTED,
461         MAC_OWN_IBSS
462 };
463
464 /* a description of a regulatory domain and the allowed channels */
465 struct reg_domain {
466         u16 code;
467         char const *name;
468         u32 channel_map;        /* if bit N is set, channel (N+1) is allowed */
469 };
470
471 /* how long do we keep a (I)BSS in the bss_list in jiffies
472    this should be long enough for the user to retrieve the table
473    (by iwlist ?) after the device started, because all entries from
474    other channels than the one the device locks on get removed, too */
475 #define BSS_LIST_TIMEOUT        (120 * HZ)
476 /* struct to store BSS info found during scan */
477 #define BSS_LIST_MAX_RATE_LEN   32      /* 32 rates should be enough ... */
478
479 struct bss_info {
480         struct list_head list;
481
482         u8 bssid[ETH_ALEN];     /* bssid */
483         u8 ssid[IW_ESSID_MAX_SIZE];     /* essid */
484         u8 ssid_len;            /* length of ssid above */
485         u8 channel;
486         u16 capa;               /* BSS capabilities */
487         u16 beacon_interval;    /* beacon interval, Kus (1024 microseconds) */
488         u8 rates[BSS_LIST_MAX_RATE_LEN];        /* supported rates in units of
489                                                    500 kbps, ORed with 0x80 for
490                                                    basic rates */
491         u8 rates_len;
492
493         /* quality of received beacon */
494         u8 rssi;
495         u8 link_qual;
496         u8 noise_level;
497
498         unsigned long last_rx;  /* time (jiffies) of last beacon received */
499 };
500
501 /* a rx data buffer to collect rx fragments */
502 struct rx_data_buf {
503         u8 sender[ETH_ALEN];    /* sender address */
504         u16 seqnr;              /* sequence number */
505         u16 fragnr;             /* last fragment received */
506         unsigned long last_rx;  /* jiffies of last rx */
507         struct sk_buff *skb;    /* == NULL if entry is free */
508 };
509
510 #define NR_RX_DATA_BUF          8
511
512 /* Data for one loaded firmware file */
513 struct fwentry {
514         const char *const fwname;
515         const struct firmware *fw;
516         int extfw_size;
517         int intfw_size;
518         /* pointer to loaded firmware, no need to free */
519         u8 *extfw;              /* external firmware, extfw_size bytes long */
520         u8 *intfw;              /* internal firmware, intfw_size bytes long */
521         enum board_type board_type;     /* board type */
522         struct mib_fw_version fw_version;
523         int loaded;             /* Loaded and parsed successfully */
524 };
525
526 struct at76_priv {
527         struct usb_device *udev;        /* USB device pointer */
528         struct net_device *netdev;      /* net device pointer */
529         struct net_device_stats stats;  /* net device stats */
530         struct iw_statistics wstats;    /* wireless stats */
531
532         struct sk_buff *rx_skb; /* skbuff for receiving data */
533         void *bulk_out_buffer;  /* buffer for sending data */
534
535         struct urb *tx_urb;     /* URB for sending data */
536         struct urb *rx_urb;     /* URB for receiving data */
537
538         unsigned int tx_pipe;   /* bulk out pipe */
539         unsigned int rx_pipe;   /* bulk in pipe */
540
541         struct mutex mtx;       /* locks this structure */
542
543         /* work queues */
544         struct work_struct work_assoc_done;
545         struct work_struct work_join;
546         struct work_struct work_new_bss;
547         struct work_struct work_start_scan;
548         struct work_struct work_set_promisc;
549         struct work_struct work_submit_rx;
550         struct delayed_work dwork_restart;
551         struct delayed_work dwork_get_scan;
552         struct delayed_work dwork_beacon;
553         struct delayed_work dwork_auth;
554         struct delayed_work dwork_assoc;
555
556         struct tasklet_struct rx_tasklet;
557
558         /* the WEP stuff */
559         int wep_enabled;        /* 1 if WEP is enabled */
560         int wep_key_id;         /* key id to be used */
561         u8 wep_keys[WEP_KEYS][WEP_KEY_LEN];     /* the four WEP keys,
562                                                    5 or 13 bytes are used */
563         u8 wep_keys_len[WEP_KEYS];      /* the length of the above keys */
564
565         int channel;
566         int iw_mode;
567         u8 bssid[ETH_ALEN];
568         u8 essid[IW_ESSID_MAX_SIZE];
569         int essid_size;
570         int radio_on;
571         int promisc;
572
573         int preamble_type;      /* 0 - long, 1 - short, 2 - auto */
574         int auth_mode;          /* authentication type: 0 open, 1 shared key */
575         int txrate;             /* 0,1,2,3 = 1,2,5.5,11 Mbps, 4 is auto */
576         int frag_threshold;     /* threshold for fragmentation of tx packets */
577         int rts_threshold;      /* threshold for RTS mechanism */
578         int short_retry_limit;
579
580         int scan_min_time;      /* scan min channel time */
581         int scan_max_time;      /* scan max channel time */
582         int scan_mode;          /* SCAN_TYPE_ACTIVE, SCAN_TYPE_PASSIVE */
583         int scan_need_any;      /* if set, need to scan for any ESSID */
584
585         /* the list we got from scanning */
586         spinlock_t bss_list_spinlock;   /* protects bss_list operations */
587         struct list_head bss_list;      /* list of BSS we got beacons from */
588         struct timer_list bss_list_timer;       /* timer to purge old entries
589                                                    from bss_list */
590         struct bss_info *curr_bss;      /* current BSS */
591         u16 assoc_id;           /* current association ID, if associated */
592
593         u8 wanted_bssid[ETH_ALEN];
594         int wanted_bssid_valid; /* != 0 if wanted_bssid is to be used */
595
596         /* some data for infrastructure mode only */
597         spinlock_t mgmt_spinlock;       /* this spinlock protects access to
598                                            next_mgmt_bulk */
599
600         struct at76_tx_buffer *next_mgmt_bulk;  /* pending management msg to
601                                                    send via bulk out */
602         enum mac_state mac_state;
603         enum {
604                 SCAN_IDLE,
605                 SCAN_IN_PROGRESS,
606                 SCAN_COMPLETED
607         } scan_state;
608         time_t last_scan;
609
610         int retries;            /* remaining retries in case of timeout when
611                                  * sending AuthReq or AssocReq */
612         u8 pm_mode;             /* power management mode */
613         u32 pm_period;          /* power management period in microseconds */
614
615         struct reg_domain const *domain;        /* reg domain description */
616
617         /* iwspy support */
618         spinlock_t spy_spinlock;
619         struct iw_spy_data spy_data;
620
621         struct iw_public_data wireless_data;
622
623         /* These fields contain HW config provided by the device (not all of
624          * these fields are used by all board types) */
625         u8 mac_addr[ETH_ALEN];
626         u8 regulatory_domain;
627
628         struct at76_card_config card_config;
629
630         /* store rx fragments until complete */
631         struct rx_data_buf rx_data[NR_RX_DATA_BUF];
632
633         enum board_type board_type;
634         struct mib_fw_version fw_version;
635
636         unsigned int device_unplugged:1;
637         unsigned int netdev_registered:1;
638         struct set_mib_buffer mib_buf;  /* global buffer for set_mib calls */
639
640         /* beacon counting */
641         int beacon_period;      /* period of mgmt beacons, Kus */
642         int beacons_received;
643         unsigned long beacons_last_qual;        /* time we restarted counting
644                                                    beacons */
645 };
646
647 struct at76_rx_radiotap {
648         struct ieee80211_radiotap_header rt_hdr;
649         __le64 rt_tsft;
650         u8 rt_flags;
651         u8 rt_rate;
652         s8 rt_signal;
653         s8 rt_noise;
654 };
655
656 #define AT76_RX_RADIOTAP_PRESENT                  \
657         ((1 << IEEE80211_RADIOTAP_TSFT)         | \
658         (1 << IEEE80211_RADIOTAP_FLAGS)         | \
659         (1 << IEEE80211_RADIOTAP_RATE)          | \
660         (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL)  | \
661         (1 << IEEE80211_RADIOTAP_DB_ANTNOISE))
662
663 #define BEACON_MAX_DATA_LENGTH  1500
664
665 /* the maximum size of an AssocReq packet */
666 #define ASSOCREQ_MAX_SIZE \
667   (AT76_TX_HDRLEN + sizeof(struct ieee80211_assoc_request) + \
668    1 + 1 + IW_ESSID_MAX_SIZE + 1 + 1 + 4)
669
670 /* for shared secret auth, add the challenge text size */
671 #define AUTH_FRAME_SIZE (AT76_TX_HDRLEN + sizeof(struct ieee80211_auth))
672
673 /* Maximal number of AuthReq retries */
674 #define AUTH_RETRIES            3
675
676 /* Maximal number of AssocReq retries */
677 #define ASSOC_RETRIES           3
678
679 /* Beacon timeout in managed mode when we are connected */
680 #define BEACON_TIMEOUT          (10 * HZ)
681
682 /* Timeout for authentication response */
683 #define AUTH_TIMEOUT            (1 * HZ)
684
685 /* Timeout for association response */
686 #define ASSOC_TIMEOUT           (1 * HZ)
687
688 /* Polling interval when scan is running */
689 #define SCAN_POLL_INTERVAL      (HZ / 4)
690
691 /* Command completion timeout */
692 #define CMD_COMPLETION_TIMEOUT  (5 * HZ)
693
694 #define DEF_RTS_THRESHOLD       1536
695 #define DEF_FRAG_THRESHOLD      1536
696 #define DEF_SHORT_RETRY_LIMIT   8
697 #define DEF_CHANNEL             10
698 #define DEF_SCAN_MIN_TIME       10
699 #define DEF_SCAN_MAX_TIME       120
700
701 #define MAX_RTS_THRESHOLD       (MAX_FRAG_THRESHOLD + 1)
702
703 /* the max padding size for tx in bytes (see calc_padding) */
704 #define MAX_PADDING_SIZE        53
705
706 #endif                          /* _AT76_USB_H */