diff options
Diffstat (limited to 'drivers/staging/at76_usb/at76_usb.h')
-rw-r--r-- | drivers/staging/at76_usb/at76_usb.h | 227 |
1 files changed, 169 insertions, 58 deletions
diff --git a/drivers/staging/at76_usb/at76_usb.h b/drivers/staging/at76_usb/at76_usb.h index 8bb352f16d4..b20be9da1fa 100644 --- a/drivers/staging/at76_usb/at76_usb.h +++ b/drivers/staging/at76_usb/at76_usb.h | |||
@@ -34,6 +34,23 @@ enum board_type { | |||
34 | BOARD_505AMX = 8 | 34 | BOARD_505AMX = 8 |
35 | }; | 35 | }; |
36 | 36 | ||
37 | /* our private ioctl's */ | ||
38 | /* preamble length (0 - long, 1 - short, 2 - auto) */ | ||
39 | #define AT76_SET_SHORT_PREAMBLE (SIOCIWFIRSTPRIV + 0) | ||
40 | #define AT76_GET_SHORT_PREAMBLE (SIOCIWFIRSTPRIV + 1) | ||
41 | /* which debug channels are enabled */ | ||
42 | #define AT76_SET_DEBUG (SIOCIWFIRSTPRIV + 2) | ||
43 | #define AT76_GET_DEBUG (SIOCIWFIRSTPRIV + 3) | ||
44 | /* power save mode (incl. the Atmel proprietary smart save mode) */ | ||
45 | #define AT76_SET_POWERSAVE_MODE (SIOCIWFIRSTPRIV + 4) | ||
46 | #define AT76_GET_POWERSAVE_MODE (SIOCIWFIRSTPRIV + 5) | ||
47 | /* min and max channel times for scan */ | ||
48 | #define AT76_SET_SCAN_TIMES (SIOCIWFIRSTPRIV + 6) | ||
49 | #define AT76_GET_SCAN_TIMES (SIOCIWFIRSTPRIV + 7) | ||
50 | /* scan mode (0 - active, 1 - passive) */ | ||
51 | #define AT76_SET_SCAN_MODE (SIOCIWFIRSTPRIV + 8) | ||
52 | #define AT76_GET_SCAN_MODE (SIOCIWFIRSTPRIV + 9) | ||
53 | |||
37 | #define CMD_STATUS_IDLE 0x00 | 54 | #define CMD_STATUS_IDLE 0x00 |
38 | #define CMD_STATUS_COMPLETE 0x01 | 55 | #define CMD_STATUS_COMPLETE 0x01 |
39 | #define CMD_STATUS_UNKNOWN 0x02 | 56 | #define CMD_STATUS_UNKNOWN 0x02 |
@@ -65,7 +82,6 @@ enum board_type { | |||
65 | #define MIB_MAC 0x03 | 82 | #define MIB_MAC 0x03 |
66 | #define MIB_MAC_MGMT 0x05 | 83 | #define MIB_MAC_MGMT 0x05 |
67 | #define MIB_MAC_WEP 0x06 | 84 | #define MIB_MAC_WEP 0x06 |
68 | #define MIB_MAC_ENCRYPTION 0x06 | ||
69 | #define MIB_PHY 0x07 | 85 | #define MIB_PHY 0x07 |
70 | #define MIB_FW_VERSION 0x08 | 86 | #define MIB_FW_VERSION 0x08 |
71 | #define MIB_MDOMAIN 0x09 | 87 | #define MIB_MDOMAIN 0x09 |
@@ -90,26 +106,6 @@ enum board_type { | |||
90 | #define AT76_PM_ON 2 | 106 | #define AT76_PM_ON 2 |
91 | #define AT76_PM_SMART 3 | 107 | #define AT76_PM_SMART 3 |
92 | 108 | ||
93 | /* cipher values for encryption keys */ | ||
94 | #define CIPHER_NONE 0 /* this value is only guessed */ | ||
95 | #define CIPHER_WEP64 1 | ||
96 | #define CIPHER_TKIP 2 | ||
97 | #define CIPHER_CCMP 3 | ||
98 | #define CIPHER_CCX 4 /* for consistency sake only */ | ||
99 | #define CIPHER_WEP128 5 | ||
100 | |||
101 | /* bit flags key types for encryption keys */ | ||
102 | #define KEY_PAIRWISE 2 | ||
103 | #define KEY_TX 4 | ||
104 | |||
105 | #define CIPHER_KEYS (4) | ||
106 | #define CIPHER_KEY_LEN (40) | ||
107 | |||
108 | struct key_config { | ||
109 | u8 cipher; | ||
110 | u8 keylen; | ||
111 | }; | ||
112 | |||
113 | struct hwcfg_r505 { | 109 | struct hwcfg_r505 { |
114 | u8 cr39_values[14]; | 110 | u8 cr39_values[14]; |
115 | u8 reserved1[14]; | 111 | u8 reserved1[14]; |
@@ -151,9 +147,6 @@ union at76_hwcfg { | |||
151 | 147 | ||
152 | #define WEP_SMALL_KEY_LEN (40 / 8) | 148 | #define WEP_SMALL_KEY_LEN (40 / 8) |
153 | #define WEP_LARGE_KEY_LEN (104 / 8) | 149 | #define WEP_LARGE_KEY_LEN (104 / 8) |
154 | #define WEP_KEYS (4) | ||
155 | |||
156 | |||
157 | 150 | ||
158 | struct at76_card_config { | 151 | struct at76_card_config { |
159 | u8 exclude_unencrypted; | 152 | u8 exclude_unencrypted; |
@@ -168,7 +161,7 @@ struct at76_card_config { | |||
168 | u8 privacy_invoked; | 161 | u8 privacy_invoked; |
169 | u8 wep_default_key_id; /* 0..3 */ | 162 | u8 wep_default_key_id; /* 0..3 */ |
170 | u8 current_ssid[32]; | 163 | u8 current_ssid[32]; |
171 | u8 wep_default_key_value[4][WEP_LARGE_KEY_LEN]; | 164 | u8 wep_default_key_value[4][WEP_KEY_LEN]; |
172 | u8 ssid_len; | 165 | u8 ssid_len; |
173 | u8 short_preamble; | 166 | u8 short_preamble; |
174 | __le16 beacon_period; | 167 | __le16 beacon_period; |
@@ -193,7 +186,7 @@ struct at76_rx_buffer { | |||
193 | u8 link_quality; | 186 | u8 link_quality; |
194 | u8 noise_level; | 187 | u8 noise_level; |
195 | __le32 rx_time; | 188 | __le32 rx_time; |
196 | u8 packet[IEEE80211_MAX_FRAG_THRESHOLD]; | 189 | u8 packet[IEEE80211_FRAME_LEN + IEEE80211_FCS_LEN]; |
197 | } __attribute__((packed)); | 190 | } __attribute__((packed)); |
198 | 191 | ||
199 | /* Length of Atmel-specific Tx header before 802.11 frame */ | 192 | /* Length of Atmel-specific Tx header before 802.11 frame */ |
@@ -203,11 +196,8 @@ struct at76_tx_buffer { | |||
203 | __le16 wlength; | 196 | __le16 wlength; |
204 | u8 tx_rate; | 197 | u8 tx_rate; |
205 | u8 padding; | 198 | u8 padding; |
206 | u8 key_id; | 199 | u8 reserved[4]; |
207 | u8 cipher_type; | 200 | u8 packet[IEEE80211_FRAME_LEN + IEEE80211_FCS_LEN]; |
208 | u8 cipher_length; | ||
209 | u8 reserved; | ||
210 | u8 packet[IEEE80211_MAX_FRAG_THRESHOLD]; | ||
211 | } __attribute__((packed)); | 201 | } __attribute__((packed)); |
212 | 202 | ||
213 | /* defines for scan_type below */ | 203 | /* defines for scan_type below */ |
@@ -254,7 +244,6 @@ struct set_mib_buffer { | |||
254 | u8 byte; | 244 | u8 byte; |
255 | __le16 word; | 245 | __le16 word; |
256 | u8 addr[ETH_ALEN]; | 246 | u8 addr[ETH_ALEN]; |
257 | u8 data[256]; /* we need more space for mib_mac_encryption */ | ||
258 | } data; | 247 | } data; |
259 | } __attribute__((packed)); | 248 | } __attribute__((packed)); |
260 | 249 | ||
@@ -328,24 +317,10 @@ struct mib_mac_wep { | |||
328 | u8 exclude_unencrypted; | 317 | u8 exclude_unencrypted; |
329 | __le32 wep_icv_error_count; | 318 | __le32 wep_icv_error_count; |
330 | __le32 wep_excluded_count; | 319 | __le32 wep_excluded_count; |
331 | u8 wep_default_keyvalue[WEP_KEYS][WEP_LARGE_KEY_LEN]; | 320 | u8 wep_default_keyvalue[WEP_KEYS][WEP_KEY_LEN]; |
332 | u8 encryption_level; /* 1 for 40bit, 2 for 104bit encryption */ | 321 | u8 encryption_level; /* 1 for 40bit, 2 for 104bit encryption */ |
333 | } __attribute__((packed)); | 322 | } __attribute__((packed)); |
334 | 323 | ||
335 | struct mib_mac_encryption { | ||
336 | u8 cipher_default_keyvalue[CIPHER_KEYS][CIPHER_KEY_LEN]; | ||
337 | u8 tkip_bssid[6]; | ||
338 | u8 privacy_invoked; | ||
339 | u8 cipher_default_key_id; | ||
340 | u8 cipher_default_group_key_id; | ||
341 | u8 exclude_unencrypted; | ||
342 | u8 wep_encryption_type; | ||
343 | u8 ckip_key_permutation; /* bool */ | ||
344 | __le32 wep_icv_error_count; | ||
345 | __le32 wep_excluded_count; | ||
346 | u8 key_rsc[CIPHER_KEYS][8]; | ||
347 | } __attribute__((packed)); | ||
348 | |||
349 | struct mib_phy { | 324 | struct mib_phy { |
350 | __le32 ed_threshold; | 325 | __le32 ed_threshold; |
351 | 326 | ||
@@ -389,6 +364,16 @@ struct at76_fw_header { | |||
389 | __le32 ext_fw_len; /* external firmware image length */ | 364 | __le32 ext_fw_len; /* external firmware image length */ |
390 | } __attribute__((packed)); | 365 | } __attribute__((packed)); |
391 | 366 | ||
367 | enum mac_state { | ||
368 | MAC_INIT, | ||
369 | MAC_SCANNING, | ||
370 | MAC_AUTH, | ||
371 | MAC_ASSOC, | ||
372 | MAC_JOINING, | ||
373 | MAC_CONNECTED, | ||
374 | MAC_OWN_IBSS | ||
375 | }; | ||
376 | |||
392 | /* a description of a regulatory domain and the allowed channels */ | 377 | /* a description of a regulatory domain and the allowed channels */ |
393 | struct reg_domain { | 378 | struct reg_domain { |
394 | u16 code; | 379 | u16 code; |
@@ -396,6 +381,47 @@ struct reg_domain { | |||
396 | u32 channel_map; /* if bit N is set, channel (N+1) is allowed */ | 381 | u32 channel_map; /* if bit N is set, channel (N+1) is allowed */ |
397 | }; | 382 | }; |
398 | 383 | ||
384 | /* how long do we keep a (I)BSS in the bss_list in jiffies | ||
385 | this should be long enough for the user to retrieve the table | ||
386 | (by iwlist ?) after the device started, because all entries from | ||
387 | other channels than the one the device locks on get removed, too */ | ||
388 | #define BSS_LIST_TIMEOUT (120 * HZ) | ||
389 | /* struct to store BSS info found during scan */ | ||
390 | #define BSS_LIST_MAX_RATE_LEN 32 /* 32 rates should be enough ... */ | ||
391 | |||
392 | struct bss_info { | ||
393 | struct list_head list; | ||
394 | |||
395 | u8 bssid[ETH_ALEN]; /* bssid */ | ||
396 | u8 ssid[IW_ESSID_MAX_SIZE]; /* essid */ | ||
397 | u8 ssid_len; /* length of ssid above */ | ||
398 | u8 channel; | ||
399 | u16 capa; /* BSS capabilities */ | ||
400 | u16 beacon_interval; /* beacon interval, Kus (1024 microseconds) */ | ||
401 | u8 rates[BSS_LIST_MAX_RATE_LEN]; /* supported rates in units of | ||
402 | 500 kbps, ORed with 0x80 for | ||
403 | basic rates */ | ||
404 | u8 rates_len; | ||
405 | |||
406 | /* quality of received beacon */ | ||
407 | u8 rssi; | ||
408 | u8 link_qual; | ||
409 | u8 noise_level; | ||
410 | |||
411 | unsigned long last_rx; /* time (jiffies) of last beacon received */ | ||
412 | }; | ||
413 | |||
414 | /* a rx data buffer to collect rx fragments */ | ||
415 | struct rx_data_buf { | ||
416 | u8 sender[ETH_ALEN]; /* sender address */ | ||
417 | u16 seqnr; /* sequence number */ | ||
418 | u16 fragnr; /* last fragment received */ | ||
419 | unsigned long last_rx; /* jiffies of last rx */ | ||
420 | struct sk_buff *skb; /* == NULL if entry is free */ | ||
421 | }; | ||
422 | |||
423 | #define NR_RX_DATA_BUF 8 | ||
424 | |||
399 | /* Data for one loaded firmware file */ | 425 | /* Data for one loaded firmware file */ |
400 | struct fwentry { | 426 | struct fwentry { |
401 | const char *const fwname; | 427 | const char *const fwname; |
@@ -412,9 +438,11 @@ struct fwentry { | |||
412 | 438 | ||
413 | struct at76_priv { | 439 | struct at76_priv { |
414 | struct usb_device *udev; /* USB device pointer */ | 440 | struct usb_device *udev; /* USB device pointer */ |
441 | struct net_device *netdev; /* net device pointer */ | ||
442 | struct net_device_stats stats; /* net device stats */ | ||
443 | struct iw_statistics wstats; /* wireless stats */ | ||
415 | 444 | ||
416 | struct sk_buff *rx_skb; /* skbuff for receiving data */ | 445 | struct sk_buff *rx_skb; /* skbuff for receiving data */ |
417 | struct sk_buff *tx_skb; /* skbuff for transmitting data */ | ||
418 | void *bulk_out_buffer; /* buffer for sending data */ | 446 | void *bulk_out_buffer; /* buffer for sending data */ |
419 | 447 | ||
420 | struct urb *tx_urb; /* URB for sending data */ | 448 | struct urb *tx_urb; /* URB for sending data */ |
@@ -426,17 +454,26 @@ struct at76_priv { | |||
426 | struct mutex mtx; /* locks this structure */ | 454 | struct mutex mtx; /* locks this structure */ |
427 | 455 | ||
428 | /* work queues */ | 456 | /* work queues */ |
457 | struct work_struct work_assoc_done; | ||
458 | struct work_struct work_join; | ||
459 | struct work_struct work_new_bss; | ||
460 | struct work_struct work_start_scan; | ||
429 | struct work_struct work_set_promisc; | 461 | struct work_struct work_set_promisc; |
430 | struct work_struct work_submit_rx; | 462 | struct work_struct work_submit_rx; |
431 | struct delayed_work dwork_hw_scan; | 463 | struct delayed_work dwork_restart; |
464 | struct delayed_work dwork_get_scan; | ||
465 | struct delayed_work dwork_beacon; | ||
466 | struct delayed_work dwork_auth; | ||
467 | struct delayed_work dwork_assoc; | ||
432 | 468 | ||
433 | struct tasklet_struct rx_tasklet; | 469 | struct tasklet_struct rx_tasklet; |
434 | 470 | ||
435 | /* the WEP stuff */ | 471 | /* the WEP stuff */ |
436 | int wep_enabled; /* 1 if WEP is enabled */ | 472 | int wep_enabled; /* 1 if WEP is enabled */ |
437 | int wep_key_id; /* key id to be used */ | 473 | int wep_key_id; /* key id to be used */ |
438 | u8 wep_keys[WEP_KEYS][WEP_LARGE_KEY_LEN]; /* WEP keys */ | 474 | u8 wep_keys[WEP_KEYS][WEP_KEY_LEN]; /* the four WEP keys, |
439 | u8 wep_keys_len[WEP_KEYS]; /* length of WEP keys */ | 475 | 5 or 13 bytes are used */ |
476 | u8 wep_keys_len[WEP_KEYS]; /* the length of the above keys */ | ||
440 | 477 | ||
441 | int channel; | 478 | int channel; |
442 | int iw_mode; | 479 | int iw_mode; |
@@ -458,13 +495,44 @@ struct at76_priv { | |||
458 | int scan_mode; /* SCAN_TYPE_ACTIVE, SCAN_TYPE_PASSIVE */ | 495 | int scan_mode; /* SCAN_TYPE_ACTIVE, SCAN_TYPE_PASSIVE */ |
459 | int scan_need_any; /* if set, need to scan for any ESSID */ | 496 | int scan_need_any; /* if set, need to scan for any ESSID */ |
460 | 497 | ||
498 | /* the list we got from scanning */ | ||
499 | spinlock_t bss_list_spinlock; /* protects bss_list operations */ | ||
500 | struct list_head bss_list; /* list of BSS we got beacons from */ | ||
501 | struct timer_list bss_list_timer; /* timer to purge old entries | ||
502 | from bss_list */ | ||
503 | struct bss_info *curr_bss; /* current BSS */ | ||
461 | u16 assoc_id; /* current association ID, if associated */ | 504 | u16 assoc_id; /* current association ID, if associated */ |
462 | 505 | ||
506 | u8 wanted_bssid[ETH_ALEN]; | ||
507 | int wanted_bssid_valid; /* != 0 if wanted_bssid is to be used */ | ||
508 | |||
509 | /* some data for infrastructure mode only */ | ||
510 | spinlock_t mgmt_spinlock; /* this spinlock protects access to | ||
511 | next_mgmt_bulk */ | ||
512 | |||
513 | struct at76_tx_buffer *next_mgmt_bulk; /* pending management msg to | ||
514 | send via bulk out */ | ||
515 | enum mac_state mac_state; | ||
516 | enum { | ||
517 | SCAN_IDLE, | ||
518 | SCAN_IN_PROGRESS, | ||
519 | SCAN_COMPLETED | ||
520 | } scan_state; | ||
521 | time_t last_scan; | ||
522 | |||
523 | int retries; /* remaining retries in case of timeout when | ||
524 | * sending AuthReq or AssocReq */ | ||
463 | u8 pm_mode; /* power management mode */ | 525 | u8 pm_mode; /* power management mode */ |
464 | u32 pm_period; /* power management period in microseconds */ | 526 | u32 pm_period; /* power management period in microseconds */ |
465 | 527 | ||
466 | struct reg_domain const *domain; /* reg domain description */ | 528 | struct reg_domain const *domain; /* reg domain description */ |
467 | 529 | ||
530 | /* iwspy support */ | ||
531 | spinlock_t spy_spinlock; | ||
532 | struct iw_spy_data spy_data; | ||
533 | |||
534 | struct iw_public_data wireless_data; | ||
535 | |||
468 | /* These fields contain HW config provided by the device (not all of | 536 | /* These fields contain HW config provided by the device (not all of |
469 | * these fields are used by all board types) */ | 537 | * these fields are used by all board types) */ |
470 | u8 mac_addr[ETH_ALEN]; | 538 | u8 mac_addr[ETH_ALEN]; |
@@ -472,6 +540,9 @@ struct at76_priv { | |||
472 | 540 | ||
473 | struct at76_card_config card_config; | 541 | struct at76_card_config card_config; |
474 | 542 | ||
543 | /* store rx fragments until complete */ | ||
544 | struct rx_data_buf rx_data[NR_RX_DATA_BUF]; | ||
545 | |||
475 | enum board_type board_type; | 546 | enum board_type board_type; |
476 | struct mib_fw_version fw_version; | 547 | struct mib_fw_version fw_version; |
477 | 548 | ||
@@ -479,20 +550,58 @@ struct at76_priv { | |||
479 | unsigned int netdev_registered:1; | 550 | unsigned int netdev_registered:1; |
480 | struct set_mib_buffer mib_buf; /* global buffer for set_mib calls */ | 551 | struct set_mib_buffer mib_buf; /* global buffer for set_mib calls */ |
481 | 552 | ||
553 | /* beacon counting */ | ||
482 | int beacon_period; /* period of mgmt beacons, Kus */ | 554 | int beacon_period; /* period of mgmt beacons, Kus */ |
555 | int beacons_received; | ||
556 | unsigned long beacons_last_qual; /* time we restarted counting | ||
557 | beacons */ | ||
558 | }; | ||
483 | 559 | ||
484 | struct ieee80211_hw *hw; | 560 | struct at76_rx_radiotap { |
485 | int mac80211_registered; | 561 | struct ieee80211_radiotap_header rt_hdr; |
486 | 562 | __le64 rt_tsft; | |
487 | struct key_config keys[4]; /* installed key types */ | 563 | u8 rt_flags; |
488 | u8 default_pairwise_key; | 564 | u8 rt_rate; |
489 | u8 default_group_key; | 565 | s8 rt_signal; |
566 | s8 rt_noise; | ||
490 | }; | 567 | }; |
491 | 568 | ||
492 | #define AT76_SUPPORTED_FILTERS FIF_PROMISC_IN_BSS | 569 | #define AT76_RX_RADIOTAP_PRESENT \ |
570 | ((1 << IEEE80211_RADIOTAP_TSFT) | \ | ||
571 | (1 << IEEE80211_RADIOTAP_FLAGS) | \ | ||
572 | (1 << IEEE80211_RADIOTAP_RATE) | \ | ||
573 | (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) | \ | ||
574 | (1 << IEEE80211_RADIOTAP_DB_ANTNOISE)) | ||
575 | |||
576 | #define BEACON_MAX_DATA_LENGTH 1500 | ||
577 | |||
578 | /* the maximum size of an AssocReq packet */ | ||
579 | #define ASSOCREQ_MAX_SIZE \ | ||
580 | (AT76_TX_HDRLEN + sizeof(struct ieee80211_assoc_request) + \ | ||
581 | 1 + 1 + IW_ESSID_MAX_SIZE + 1 + 1 + 4) | ||
582 | |||
583 | /* for shared secret auth, add the challenge text size */ | ||
584 | #define AUTH_FRAME_SIZE (AT76_TX_HDRLEN + sizeof(struct ieee80211_auth)) | ||
585 | |||
586 | /* Maximal number of AuthReq retries */ | ||
587 | #define AUTH_RETRIES 3 | ||
493 | 588 | ||
589 | /* Maximal number of AssocReq retries */ | ||
590 | #define ASSOC_RETRIES 3 | ||
591 | |||
592 | /* Beacon timeout in managed mode when we are connected */ | ||
593 | #define BEACON_TIMEOUT (10 * HZ) | ||
594 | |||
595 | /* Timeout for authentication response */ | ||
596 | #define AUTH_TIMEOUT (1 * HZ) | ||
597 | |||
598 | /* Timeout for association response */ | ||
599 | #define ASSOC_TIMEOUT (1 * HZ) | ||
600 | |||
601 | /* Polling interval when scan is running */ | ||
494 | #define SCAN_POLL_INTERVAL (HZ / 4) | 602 | #define SCAN_POLL_INTERVAL (HZ / 4) |
495 | 603 | ||
604 | /* Command completion timeout */ | ||
496 | #define CMD_COMPLETION_TIMEOUT (5 * HZ) | 605 | #define CMD_COMPLETION_TIMEOUT (5 * HZ) |
497 | 606 | ||
498 | #define DEF_RTS_THRESHOLD 1536 | 607 | #define DEF_RTS_THRESHOLD 1536 |
@@ -502,6 +611,8 @@ struct at76_priv { | |||
502 | #define DEF_SCAN_MIN_TIME 10 | 611 | #define DEF_SCAN_MIN_TIME 10 |
503 | #define DEF_SCAN_MAX_TIME 120 | 612 | #define DEF_SCAN_MAX_TIME 120 |
504 | 613 | ||
614 | #define MAX_RTS_THRESHOLD (MAX_FRAG_THRESHOLD + 1) | ||
615 | |||
505 | /* the max padding size for tx in bytes (see calc_padding) */ | 616 | /* the max padding size for tx in bytes (see calc_padding) */ |
506 | #define MAX_PADDING_SIZE 53 | 617 | #define MAX_PADDING_SIZE 53 |
507 | 618 | ||