1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #ifndef _AT76_USB_H
19 #define _AT76_USB_H
20
21
22 enum board_type {
23 BOARD_503_ISL3861 = 1,
24 BOARD_503_ISL3863 = 2,
25 BOARD_503 = 3,
26 BOARD_503_ACC = 4,
27 BOARD_505 = 5,
28 BOARD_505_2958 = 6,
29 BOARD_505A = 7,
30 BOARD_505AMX = 8
31 };
32
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
42
43
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
49
50 #define CMD_SET_MIB 0x01
51 #define CMD_GET_MIB 0x02
52 #define CMD_SCAN 0x03
53 #define CMD_JOIN 0x04
54 #define CMD_START_IBSS 0x05
55 #define CMD_RADIO_ON 0x06
56 #define CMD_RADIO_OFF 0x07
57 #define CMD_STARTUP 0x0B
58
59 #define MIB_LOCAL 0x01
60 #define MIB_MAC_ADDR 0x02
61 #define MIB_MAC 0x03
62 #define MIB_MAC_MGMT 0x05
63 #define MIB_MAC_WEP 0x06
64 #define MIB_PHY 0x07
65 #define MIB_FW_VERSION 0x08
66 #define MIB_MDOMAIN 0x09
67
68 #define ADHOC_MODE 1
69 #define INFRASTRUCTURE_MODE 2
70
71
72 #define PREAMBLE_TYPE_LONG 0
73 #define PREAMBLE_TYPE_SHORT 1
74 #define PREAMBLE_TYPE_AUTO 2
75
76
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
82
83
84 #define AT76_PM_OFF 1
85 #define AT76_PM_ON 2
86 #define AT76_PM_SMART 3
87
88 struct hwcfg_r505 {
89 u8 cr39_values[14];
90 u8 reserved1[14];
91 u8 bb_cr[14];
92 u8 pidvid[4];
93 u8 mac_addr[ETH_ALEN];
94 u8 regulatory_domain;
95 u8 reserved2[14];
96 u8 cr15_values[14];
97 u8 reserved3[3];
98 } __packed;
99
100 struct hwcfg_rfmd {
101 u8 cr20_values[14];
102 u8 cr21_values[14];
103 u8 bb_cr[14];
104 u8 pidvid[4];
105 u8 mac_addr[ETH_ALEN];
106 u8 regulatory_domain;
107 u8 low_power_values[14];
108 u8 normal_power_values[14];
109 u8 reserved1[3];
110 } __packed;
111
112 struct hwcfg_intersil {
113 u8 mac_addr[ETH_ALEN];
114 u8 cr31_values[14];
115 u8 cr58_values[14];
116 u8 pidvid[4];
117 u8 regulatory_domain;
118 u8 reserved[1];
119 } __packed;
120
121 union at76_hwcfg {
122 struct hwcfg_intersil i;
123 struct hwcfg_rfmd r3;
124 struct hwcfg_r505 r5;
125 };
126
127 #define WEP_SMALL_KEY_LEN (40 / 8)
128 #define WEP_LARGE_KEY_LEN (104 / 8)
129 #define WEP_KEYS (4)
130
131 struct at76_card_config {
132 u8 exclude_unencrypted;
133 u8 promiscuous_mode;
134 u8 short_retry_limit;
135 u8 encryption_type;
136 __le16 rts_threshold;
137 __le16 fragmentation_threshold;
138 u8 basic_rate_set[4];
139 u8 auto_rate_fallback;
140 u8 channel;
141 u8 privacy_invoked;
142 u8 wep_default_key_id;
143 u8 current_ssid[32];
144 u8 wep_default_key_value[4][WEP_LARGE_KEY_LEN];
145 u8 ssid_len;
146 u8 short_preamble;
147 __le16 beacon_period;
148 } __packed;
149
150 struct at76_command {
151 u8 cmd;
152 u8 reserved;
153 __le16 size;
154 u8 data[0];
155 } __packed;
156
157
158 #define AT76_RX_HDRLEN offsetof(struct at76_rx_buffer, packet)
159
160 struct at76_rx_buffer {
161 __le16 wlength;
162 u8 rx_rate;
163 u8 newbss;
164 u8 fragmentation;
165 u8 rssi;
166 u8 link_quality;
167 u8 noise_level;
168 __le32 rx_time;
169 u8 packet[IEEE80211_MAX_FRAG_THRESHOLD];
170 } __packed;
171
172
173 #define AT76_TX_HDRLEN offsetof(struct at76_tx_buffer, packet)
174
175 struct at76_tx_buffer {
176 __le16 wlength;
177 u8 tx_rate;
178 u8 padding;
179 u8 reserved[4];
180 u8 packet[IEEE80211_MAX_FRAG_THRESHOLD];
181 } __packed;
182
183
184 #define SCAN_TYPE_ACTIVE 0
185 #define SCAN_TYPE_PASSIVE 1
186
187 struct at76_req_scan {
188 u8 bssid[ETH_ALEN];
189 u8 essid[32];
190 u8 scan_type;
191 u8 channel;
192 __le16 probe_delay;
193 __le16 min_channel_time;
194 __le16 max_channel_time;
195 u8 essid_size;
196 u8 international_scan;
197 } __packed;
198
199 struct at76_req_ibss {
200 u8 bssid[ETH_ALEN];
201 u8 essid[32];
202 u8 bss_type;
203 u8 channel;
204 u8 essid_size;
205 u8 reserved[3];
206 } __packed;
207
208 struct at76_req_join {
209 u8 bssid[ETH_ALEN];
210 u8 essid[32];
211 u8 bss_type;
212 u8 channel;
213 __le16 timeout;
214 u8 essid_size;
215 u8 reserved;
216 } __packed;
217
218 struct mib_local {
219 u16 reserved0;
220 u8 beacon_enable;
221 u8 txautorate_fallback;
222 u8 reserved1;
223 u8 ssid_size;
224 u8 promiscuous_mode;
225 u16 reserved2;
226 u8 preamble_type;
227 u16 reserved3;
228 } __packed;
229
230 struct mib_mac_addr {
231 u8 mac_addr[ETH_ALEN];
232 u8 res[2];
233 u8 group_addr[4][ETH_ALEN];
234 u8 group_addr_status[4];
235 } __packed;
236
237 struct mib_mac {
238 __le32 max_tx_msdu_lifetime;
239 __le32 max_rx_lifetime;
240 __le16 frag_threshold;
241 __le16 rts_threshold;
242 __le16 cwmin;
243 __le16 cwmax;
244 u8 short_retry_time;
245 u8 long_retry_time;
246 u8 scan_type;
247 u8 scan_channel;
248 __le16 probe_delay;
249 __le16 min_channel_time;
250 __le16 max_channel_time;
251 __le16 listen_interval;
252 u8 desired_ssid[32];
253 u8 desired_bssid[ETH_ALEN];
254 u8 desired_bsstype;
255 u8 reserved2;
256 } __packed;
257
258 struct mib_mac_mgmt {
259 __le16 beacon_period;
260 __le16 CFP_max_duration;
261 __le16 medium_occupancy_limit;
262 __le16 station_id;
263 __le16 ATIM_window;
264 u8 CFP_mode;
265 u8 privacy_option_implemented;
266 u8 DTIM_period;
267 u8 CFP_period;
268 u8 current_bssid[ETH_ALEN];
269 u8 current_essid[32];
270 u8 current_bss_type;
271 u8 power_mgmt_mode;
272
273 u8 ibss_change;
274 u8 res;
275 u8 multi_domain_capability_implemented;
276 u8 multi_domain_capability_enabled;
277 u8 country_string[IEEE80211_COUNTRY_STRING_LEN];
278 u8 reserved[3];
279 } __packed;
280
281 struct mib_mac_wep {
282 u8 privacy_invoked;
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;
290 } __packed;
291
292 struct mib_phy {
293 __le32 ed_threshold;
294
295 __le16 slot_time;
296 __le16 sifs_time;
297 __le16 preamble_length;
298 __le16 plcp_header_length;
299 __le16 mpdu_max_length;
300 __le16 cca_mode_supported;
301
302 u8 operation_rate_set[4];
303 u8 channel_id;
304 u8 current_cca_mode;
305 u8 phy_type;
306 u8 current_reg_domain;
307 } __packed;
308
309 struct mib_fw_version {
310 u8 major;
311 u8 minor;
312 u8 patch;
313 u8 build;
314 } __packed;
315
316 struct mib_mdomain {
317 u8 tx_powerlevel[14];
318 u8 channel_list[14];
319 } __packed;
320
321 struct set_mib_buffer {
322 u8 type;
323 u8 size;
324 u8 index;
325 u8 reserved;
326 union {
327 u8 byte;
328 __le16 word;
329 u8 addr[ETH_ALEN];
330 struct mib_mac_wep wep_mib;
331 } data;
332 } __packed;
333
334 struct at76_fw_header {
335 __le32 crc;
336 __le32 board_type;
337 u8 build;
338 u8 patch;
339 u8 minor;
340 u8 major;
341 __le32 str_offset;
342 __le32 int_fw_offset;
343 __le32 int_fw_len;
344 __le32 ext_fw_offset;
345 __le32 ext_fw_len;
346 } __packed;
347
348
349 struct reg_domain {
350 u16 code;
351 char const *name;
352 u32 channel_map;
353 };
354
355
356 struct fwentry {
357 const char *const fwname;
358 const struct firmware *fw;
359 int extfw_size;
360 int intfw_size;
361
362 u8 *extfw;
363 u8 *intfw;
364 enum board_type board_type;
365 struct mib_fw_version fw_version;
366 int loaded;
367 };
368
369 struct at76_priv {
370 struct usb_device *udev;
371
372 struct sk_buff *rx_skb;
373 struct sk_buff *tx_skb;
374 void *bulk_out_buffer;
375
376 struct urb *tx_urb;
377 struct urb *rx_urb;
378
379 unsigned int tx_pipe;
380 unsigned int rx_pipe;
381
382 struct mutex mtx;
383
384
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;
389
390 struct tasklet_struct rx_tasklet;
391
392
393 int wep_enabled;
394 int wep_key_id;
395 u8 wep_keys[WEP_KEYS][WEP_LARGE_KEY_LEN];
396 u8 wep_keys_len[WEP_KEYS];
397
398 int channel;
399 int iw_mode;
400 u8 bssid[ETH_ALEN];
401 u8 essid[IW_ESSID_MAX_SIZE];
402 int essid_size;
403 int radio_on;
404 int promisc;
405
406 int preamble_type;
407 int auth_mode;
408 int txrate;
409 int frag_threshold;
410 int rts_threshold;
411 int short_retry_limit;
412
413 int scan_min_time;
414 int scan_max_time;
415 int scan_mode;
416 int scan_need_any;
417 bool scanning;
418
419 u16 assoc_id;
420
421 u8 pm_mode;
422 u32 pm_period;
423
424 struct reg_domain const *domain;
425
426
427
428 u8 mac_addr[ETH_ALEN];
429 u8 regulatory_domain;
430
431 struct at76_card_config card_config;
432
433 enum board_type board_type;
434 struct mib_fw_version fw_version;
435
436 unsigned int device_unplugged:1;
437 unsigned int netdev_registered:1;
438 struct set_mib_buffer mib_buf;
439
440 int beacon_period;
441
442 struct ieee80211_hw *hw;
443 int mac80211_registered;
444 };
445
446 #define AT76_SUPPORTED_FILTERS 0
447
448 #define SCAN_POLL_INTERVAL (HZ / 4)
449
450 #define CMD_COMPLETION_TIMEOUT (5 * HZ)
451
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
458
459
460 #define MAX_PADDING_SIZE 53
461
462 #endif