Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
at76c50x-usb.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002,2003 Oliver Kurth
3  * (c) 2003,2004 Joerg Albert <[email protected]>
4  * (c) 2007 Guido Guenther <[email protected]>
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 /* Board types */
26 enum board_type {
29  BOARD_503 = 3,
31  BOARD_505 = 5,
35 };
36 
37 #define CMD_STATUS_IDLE 0x00
38 #define CMD_STATUS_COMPLETE 0x01
39 #define CMD_STATUS_UNKNOWN 0x02
40 #define CMD_STATUS_INVALID_PARAMETER 0x03
41 #define CMD_STATUS_FUNCTION_NOT_SUPPORTED 0x04
42 #define CMD_STATUS_TIME_OUT 0x07
43 #define CMD_STATUS_IN_PROGRESS 0x08
44 #define CMD_STATUS_HOST_FAILURE 0xff
45 #define CMD_STATUS_SCAN_FAILED 0xf0
46 
47 /* answers to get op mode */
48 #define OPMODE_NONE 0x00
49 #define OPMODE_NORMAL_NIC_WITH_FLASH 0x01
50 #define OPMODE_HW_CONFIG_MODE 0x02
51 #define OPMODE_DFU_MODE_WITH_FLASH 0x03
52 #define OPMODE_NORMAL_NIC_WITHOUT_FLASH 0x04
53 
54 #define CMD_SET_MIB 0x01
55 #define CMD_GET_MIB 0x02
56 #define CMD_SCAN 0x03
57 #define CMD_JOIN 0x04
58 #define CMD_START_IBSS 0x05
59 #define CMD_RADIO_ON 0x06
60 #define CMD_RADIO_OFF 0x07
61 #define CMD_STARTUP 0x0B
62 
63 #define MIB_LOCAL 0x01
64 #define MIB_MAC_ADDR 0x02
65 #define MIB_MAC 0x03
66 #define MIB_MAC_MGMT 0x05
67 #define MIB_MAC_WEP 0x06
68 #define MIB_PHY 0x07
69 #define MIB_FW_VERSION 0x08
70 #define MIB_MDOMAIN 0x09
71 
72 #define ADHOC_MODE 1
73 #define INFRASTRUCTURE_MODE 2
74 
75 /* values for struct mib_local, field preamble_type */
76 #define PREAMBLE_TYPE_LONG 0
77 #define PREAMBLE_TYPE_SHORT 1
78 #define PREAMBLE_TYPE_AUTO 2
79 
80 /* values for tx_rate */
81 #define TX_RATE_1MBIT 0
82 #define TX_RATE_2MBIT 1
83 #define TX_RATE_5_5MBIT 2
84 #define TX_RATE_11MBIT 3
85 #define TX_RATE_AUTO 4
86 
87 /* power management modes */
88 #define AT76_PM_OFF 1
89 #define AT76_PM_ON 2
90 #define AT76_PM_SMART 3
91 
92 struct hwcfg_r505 {
95  u8 bb_cr[14];
96  u8 pidvid[4];
102 } __packed;
103 
104 struct hwcfg_rfmd {
107  u8 bb_cr[14];
108  u8 pidvid[4];
114 } __packed;
115 
120  u8 pidvid[4];
123 } __packed;
124 
125 union at76_hwcfg {
127  struct hwcfg_rfmd r3;
128  struct hwcfg_r505 r5;
129 };
130 
131 #define WEP_SMALL_KEY_LEN (40 / 8)
132 #define WEP_LARGE_KEY_LEN (104 / 8)
133 #define WEP_KEYS (4)
134 
146  u8 wep_default_key_id; /* 0..3 */
152 } __packed;
153 
154 struct at76_command {
158  u8 data[0];
159 } __packed;
160 
161 /* Length of Atmel-specific Rx header before 802.11 frame */
162 #define AT76_RX_HDRLEN offsetof(struct at76_rx_buffer, packet)
163 
174 } __packed;
175 
176 /* Length of Atmel-specific Tx header before 802.11 frame */
177 #define AT76_TX_HDRLEN offsetof(struct at76_tx_buffer, packet)
178 
185 } __packed;
186 
187 /* defines for scan_type below */
188 #define SCAN_TYPE_ACTIVE 0
189 #define SCAN_TYPE_PASSIVE 1
190 
193  u8 essid[32];
201 } __packed;
202 
205  u8 essid[32];
210 } __packed;
211 
214  u8 essid[32];
220 } __packed;
221 
227  union {
231  } data;
232 } __packed;
233 
234 struct mib_local {
244 } __packed;
245 
246 struct mib_mac_addr {
248  u8 res[2]; /* ??? */
251 } __packed;
252 
253 struct mib_mac {
262  u8 scan_type; /* active or passive */
264  __le16 probe_delay; /* delay before ProbeReq in active scan, RO */
270  u8 desired_bsstype; /* ad-hoc or infrastructure */
272 } __packed;
273 
274 struct mib_mac_mgmt {
278  __le16 station_id; /* assoc id */
288  /* rfmd and 505 */
295 } __packed;
296 
297 struct mib_mac_wep {
298  u8 privacy_invoked; /* 0 disable encr., 1 enable encr */
305  u8 encryption_level; /* 1 for 40bit, 2 for 104bit encryption */
306 } __packed;
307 
308 struct mib_phy {
310 
317 
323 } __packed;
324 
330 } __packed;
331 
332 struct mib_mdomain {
334  u8 channel_list[14]; /* 0 for invalid channels */
335 } __packed;
336 
338  __le32 crc; /* CRC32 of the whole image */
339  __le32 board_type; /* firmware compatibility code */
340  u8 build; /* firmware build number */
341  u8 patch; /* firmware patch level */
342  u8 minor; /* firmware minor version */
343  u8 major; /* firmware major version */
344  __le32 str_offset; /* offset of the copyright string */
345  __le32 int_fw_offset; /* internal firmware image offset */
346  __le32 int_fw_len; /* internal firmware image length */
347  __le32 ext_fw_offset; /* external firmware image offset */
348  __le32 ext_fw_len; /* external firmware image length */
349 } __packed;
350 
351 /* a description of a regulatory domain and the allowed channels */
352 struct reg_domain {
354  char const *name;
355  u32 channel_map; /* if bit N is set, channel (N+1) is allowed */
356 };
357 
358 /* Data for one loaded firmware file */
359 struct fwentry {
360  const char *const fwname;
361  const struct firmware *fw;
364  /* pointer to loaded firmware, no need to free */
365  u8 *extfw; /* external firmware, extfw_size bytes long */
366  u8 *intfw; /* internal firmware, intfw_size bytes long */
367  enum board_type board_type; /* board type */
369  int loaded; /* Loaded and parsed successfully */
370 };
371 
372 struct at76_priv {
373  struct usb_device *udev; /* USB device pointer */
374 
375  struct sk_buff *rx_skb; /* skbuff for receiving data */
376  struct sk_buff *tx_skb; /* skbuff for transmitting data */
377  void *bulk_out_buffer; /* buffer for sending data */
378 
379  struct urb *tx_urb; /* URB for sending data */
380  struct urb *rx_urb; /* URB for receiving data */
381 
382  unsigned int tx_pipe; /* bulk out pipe */
383  unsigned int rx_pipe; /* bulk in pipe */
384 
385  struct mutex mtx; /* locks this structure */
386 
387  /* work queues */
392 
394 
395  /* the WEP stuff */
396  int wep_enabled; /* 1 if WEP is enabled */
397  int wep_key_id; /* key id to be used */
399  u8 wep_keys_len[WEP_KEYS]; /* length of WEP keys */
400 
401  int channel;
402  int iw_mode;
406  int radio_on;
407  int promisc;
408 
409  int preamble_type; /* 0 - long, 1 - short, 2 - auto */
410  int auth_mode; /* authentication type: 0 open, 1 shared key */
411  int txrate; /* 0,1,2,3 = 1,2,5.5,11 Mbps, 4 is auto */
412  int frag_threshold; /* threshold for fragmentation of tx packets */
413  int rts_threshold; /* threshold for RTS mechanism */
415 
416  int scan_min_time; /* scan min channel time */
417  int scan_max_time; /* scan max channel time */
418  int scan_mode; /* SCAN_TYPE_ACTIVE, SCAN_TYPE_PASSIVE */
419  int scan_need_any; /* if set, need to scan for any ESSID */
420 
421  u16 assoc_id; /* current association ID, if associated */
422 
423  u8 pm_mode; /* power management mode */
424  u32 pm_period; /* power management period in microseconds */
425 
426  struct reg_domain const *domain; /* reg domain description */
427 
428  /* These fields contain HW config provided by the device (not all of
429  * these fields are used by all board types) */
432 
434 
437 
438  unsigned int device_unplugged:1;
439  unsigned int netdev_registered:1;
440  struct set_mib_buffer mib_buf; /* global buffer for set_mib calls */
441 
442  int beacon_period; /* period of mgmt beacons, Kus */
443 
444  struct ieee80211_hw *hw;
446 };
447 
448 #define AT76_SUPPORTED_FILTERS FIF_PROMISC_IN_BSS
449 
450 #define SCAN_POLL_INTERVAL (HZ / 4)
451 
452 #define CMD_COMPLETION_TIMEOUT (5 * HZ)
453 
454 #define DEF_RTS_THRESHOLD 1536
455 #define DEF_FRAG_THRESHOLD 1536
456 #define DEF_SHORT_RETRY_LIMIT 8
457 #define DEF_CHANNEL 10
458 #define DEF_SCAN_MIN_TIME 10
459 #define DEF_SCAN_MAX_TIME 120
460 
461 /* the max padding size for tx in bytes (see calc_padding) */
462 #define MAX_PADDING_SIZE 53
463 
464 #endif /* _AT76_USB_H */