1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (c) 2002,2003 Oliver Kurth
4 * (c) 2003,2004 Joerg Albert <joerg.albert@gmx.de>
5 * (c) 2007 Guido Guenther <agx@sigxcpu.org>
7 * This driver was based on information from the Sourceforge driver
8 * released and maintained by Atmel:
10 * http://sourceforge.net/projects/atmelwlandriver/
12 * Although the code was completely re-written,
13 * it would have been impossible without Atmel's decision to
14 * release an Open Source driver (unfortunately the firmware was
15 * kept binary only). Thanks for that decision to Atmel!
23 BOARD_503_ISL3861
= 1,
24 BOARD_503_ISL3863
= 2,
33 #define CMD_STATUS_IDLE 0x00
34 #define CMD_STATUS_COMPLETE 0x01
35 #define CMD_STATUS_UNKNOWN 0x02
36 #define CMD_STATUS_INVALID_PARAMETER 0x03
37 #define CMD_STATUS_FUNCTION_NOT_SUPPORTED 0x04
38 #define CMD_STATUS_TIME_OUT 0x07
39 #define CMD_STATUS_IN_PROGRESS 0x08
40 #define CMD_STATUS_HOST_FAILURE 0xff
41 #define CMD_STATUS_SCAN_FAILED 0xf0
43 /* answers to get op mode */
44 #define OPMODE_NONE 0x00
45 #define OPMODE_NORMAL_NIC_WITH_FLASH 0x01
46 #define OPMODE_HW_CONFIG_MODE 0x02
47 #define OPMODE_DFU_MODE_WITH_FLASH 0x03
48 #define OPMODE_NORMAL_NIC_WITHOUT_FLASH 0x04
50 #define CMD_SET_MIB 0x01
51 #define CMD_GET_MIB 0x02
54 #define CMD_START_IBSS 0x05
55 #define CMD_RADIO_ON 0x06
56 #define CMD_RADIO_OFF 0x07
57 #define CMD_STARTUP 0x0B
59 #define MIB_LOCAL 0x01
60 #define MIB_MAC_ADDR 0x02
62 #define MIB_MAC_MGMT 0x05
63 #define MIB_MAC_WEP 0x06
65 #define MIB_FW_VERSION 0x08
66 #define MIB_MDOMAIN 0x09
69 #define INFRASTRUCTURE_MODE 2
71 /* values for struct mib_local, field preamble_type */
72 #define PREAMBLE_TYPE_LONG 0
73 #define PREAMBLE_TYPE_SHORT 1
74 #define PREAMBLE_TYPE_AUTO 2
76 /* values for tx_rate */
77 #define TX_RATE_1MBIT 0
78 #define TX_RATE_2MBIT 1
79 #define TX_RATE_5_5MBIT 2
80 #define TX_RATE_11MBIT 3
81 #define TX_RATE_AUTO 4
83 /* power management modes */
86 #define AT76_PM_SMART 3
93 u8 mac_addr
[ETH_ALEN
];
105 u8 mac_addr
[ETH_ALEN
];
106 u8 regulatory_domain
;
107 u8 low_power_values
[14];
108 u8 normal_power_values
[14];
112 struct hwcfg_intersil
{
113 u8 mac_addr
[ETH_ALEN
];
117 u8 regulatory_domain
;
122 struct hwcfg_intersil i
;
123 struct hwcfg_rfmd r3
;
124 struct hwcfg_r505 r5
;
127 #define WEP_SMALL_KEY_LEN (40 / 8)
128 #define WEP_LARGE_KEY_LEN (104 / 8)
131 struct at76_card_config
{
132 u8 exclude_unencrypted
;
134 u8 short_retry_limit
;
136 __le16 rts_threshold
;
137 __le16 fragmentation_threshold
; /* 256..2346 */
138 u8 basic_rate_set
[4];
139 u8 auto_rate_fallback
; /* 0,1 */
142 u8 wep_default_key_id
; /* 0..3 */
144 u8 wep_default_key_value
[4][WEP_LARGE_KEY_LEN
];
147 __le16 beacon_period
;
150 struct at76_command
{
157 /* Length of Atmel-specific Rx header before 802.11 frame */
158 #define AT76_RX_HDRLEN offsetof(struct at76_rx_buffer, packet)
160 struct at76_rx_buffer
{
169 u8 packet
[IEEE80211_MAX_FRAG_THRESHOLD
];
172 /* Length of Atmel-specific Tx header before 802.11 frame */
173 #define AT76_TX_HDRLEN offsetof(struct at76_tx_buffer, packet)
175 struct at76_tx_buffer
{
180 u8 packet
[IEEE80211_MAX_FRAG_THRESHOLD
];
183 /* defines for scan_type below */
184 #define SCAN_TYPE_ACTIVE 0
185 #define SCAN_TYPE_PASSIVE 1
187 struct at76_req_scan
{
193 __le16 min_channel_time
;
194 __le16 max_channel_time
;
196 u8 international_scan
;
199 struct at76_req_ibss
{
208 struct at76_req_join
{
221 u8 txautorate_fallback
;
230 struct mib_mac_addr
{
231 u8 mac_addr
[ETH_ALEN
];
233 u8 group_addr
[4][ETH_ALEN
];
234 u8 group_addr_status
[4];
238 __le32 max_tx_msdu_lifetime
;
239 __le32 max_rx_lifetime
;
240 __le16 frag_threshold
;
241 __le16 rts_threshold
;
246 u8 scan_type
; /* active or passive */
248 __le16 probe_delay
; /* delay before ProbeReq in active scan, RO */
249 __le16 min_channel_time
;
250 __le16 max_channel_time
;
251 __le16 listen_interval
;
253 u8 desired_bssid
[ETH_ALEN
];
254 u8 desired_bsstype
; /* ad-hoc or infrastructure */
258 struct mib_mac_mgmt
{
259 __le16 beacon_period
;
260 __le16 CFP_max_duration
;
261 __le16 medium_occupancy_limit
;
262 __le16 station_id
; /* assoc id */
265 u8 privacy_option_implemented
;
268 u8 current_bssid
[ETH_ALEN
];
269 u8 current_essid
[32];
275 u8 multi_domain_capability_implemented
;
276 u8 multi_domain_capability_enabled
;
277 u8 country_string
[IEEE80211_COUNTRY_STRING_LEN
];
282 u8 privacy_invoked
; /* 0 disable encr., 1 enable encr */
283 u8 wep_default_key_id
;
284 u8 wep_key_mapping_len
;
285 u8 exclude_unencrypted
;
286 __le32 wep_icv_error_count
;
287 __le32 wep_excluded_count
;
288 u8 wep_default_keyvalue
[WEP_KEYS
][WEP_LARGE_KEY_LEN
];
289 u8 encryption_level
; /* 1 for 40bit, 2 for 104bit encryption */
297 __le16 preamble_length
;
298 __le16 plcp_header_length
;
299 __le16 mpdu_max_length
;
300 __le16 cca_mode_supported
;
302 u8 operation_rate_set
[4];
306 u8 current_reg_domain
;
309 struct mib_fw_version
{
317 u8 tx_powerlevel
[14];
318 u8 channel_list
[14]; /* 0 for invalid channels */
321 struct set_mib_buffer
{
330 struct mib_mac_wep wep_mib
;
334 struct at76_fw_header
{
335 __le32 crc
; /* CRC32 of the whole image */
336 __le32 board_type
; /* firmware compatibility code */
337 u8 build
; /* firmware build number */
338 u8 patch
; /* firmware patch level */
339 u8 minor
; /* firmware minor version */
340 u8 major
; /* firmware major version */
341 __le32 str_offset
; /* offset of the copyright string */
342 __le32 int_fw_offset
; /* internal firmware image offset */
343 __le32 int_fw_len
; /* internal firmware image length */
344 __le32 ext_fw_offset
; /* external firmware image offset */
345 __le32 ext_fw_len
; /* external firmware image length */
348 /* a description of a regulatory domain and the allowed channels */
352 u32 channel_map
; /* if bit N is set, channel (N+1) is allowed */
355 /* Data for one loaded firmware file */
357 const char *const fwname
;
358 const struct firmware
*fw
;
361 /* pointer to loaded firmware, no need to free */
362 u8
*extfw
; /* external firmware, extfw_size bytes long */
363 u8
*intfw
; /* internal firmware, intfw_size bytes long */
364 enum board_type board_type
; /* board type */
365 struct mib_fw_version fw_version
;
366 int loaded
; /* Loaded and parsed successfully */
370 struct usb_device
*udev
; /* USB device pointer */
372 struct sk_buff
*rx_skb
; /* skbuff for receiving data */
373 struct sk_buff
*tx_skb
; /* skbuff for transmitting data */
374 void *bulk_out_buffer
; /* buffer for sending data */
376 struct urb
*tx_urb
; /* URB for sending data */
377 struct urb
*rx_urb
; /* URB for receiving data */
379 unsigned int tx_pipe
; /* bulk out pipe */
380 unsigned int rx_pipe
; /* bulk in pipe */
382 struct mutex mtx
; /* locks this structure */
385 struct work_struct work_set_promisc
;
386 struct work_struct work_submit_rx
;
387 struct work_struct work_join_bssid
;
388 struct delayed_work dwork_hw_scan
;
390 struct tasklet_struct rx_tasklet
;
393 int wep_enabled
; /* 1 if WEP is enabled */
394 int wep_key_id
; /* key id to be used */
395 u8 wep_keys
[WEP_KEYS
][WEP_LARGE_KEY_LEN
]; /* WEP keys */
396 u8 wep_keys_len
[WEP_KEYS
]; /* length of WEP keys */
401 u8 essid
[IW_ESSID_MAX_SIZE
];
406 int preamble_type
; /* 0 - long, 1 - short, 2 - auto */
407 int auth_mode
; /* authentication type: 0 open, 1 shared key */
408 int txrate
; /* 0,1,2,3 = 1,2,5.5,11 Mbps, 4 is auto */
409 int frag_threshold
; /* threshold for fragmentation of tx packets */
410 int rts_threshold
; /* threshold for RTS mechanism */
411 int short_retry_limit
;
413 int scan_min_time
; /* scan min channel time */
414 int scan_max_time
; /* scan max channel time */
415 int scan_mode
; /* SCAN_TYPE_ACTIVE, SCAN_TYPE_PASSIVE */
416 int scan_need_any
; /* if set, need to scan for any ESSID */
417 bool scanning
; /* if set, the scan is running */
419 u16 assoc_id
; /* current association ID, if associated */
421 u8 pm_mode
; /* power management mode */
422 u32 pm_period
; /* power management period in microseconds */
424 struct reg_domain
const *domain
; /* reg domain description */
426 /* These fields contain HW config provided by the device (not all of
427 * these fields are used by all board types) */
428 u8 mac_addr
[ETH_ALEN
];
429 u8 regulatory_domain
;
431 struct at76_card_config card_config
;
433 enum board_type board_type
;
434 struct mib_fw_version fw_version
;
436 unsigned int device_unplugged
:1;
437 unsigned int netdev_registered
:1;
438 struct set_mib_buffer mib_buf
; /* global buffer for set_mib calls */
440 int beacon_period
; /* period of mgmt beacons, Kus */
442 struct ieee80211_hw
*hw
;
443 int mac80211_registered
;
446 #define AT76_SUPPORTED_FILTERS 0
448 #define SCAN_POLL_INTERVAL (HZ / 4)
450 #define CMD_COMPLETION_TIMEOUT (5 * HZ)
452 #define DEF_RTS_THRESHOLD 1536
453 #define DEF_FRAG_THRESHOLD 1536
454 #define DEF_SHORT_RETRY_LIMIT 8
455 #define DEF_CHANNEL 10
456 #define DEF_SCAN_MIN_TIME 10
457 #define DEF_SCAN_MAX_TIME 120
459 /* the max padding size for tx in bytes (see calc_padding) */
460 #define MAX_PADDING_SIZE 53
462 #endif /* _AT76_USB_H */