0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef _AT76_USB_H
0019 #define _AT76_USB_H
0020
0021
0022 enum board_type {
0023 BOARD_503_ISL3861 = 1,
0024 BOARD_503_ISL3863 = 2,
0025 BOARD_503 = 3,
0026 BOARD_503_ACC = 4,
0027 BOARD_505 = 5,
0028 BOARD_505_2958 = 6,
0029 BOARD_505A = 7,
0030 BOARD_505AMX = 8
0031 };
0032
0033 #define CMD_STATUS_IDLE 0x00
0034 #define CMD_STATUS_COMPLETE 0x01
0035 #define CMD_STATUS_UNKNOWN 0x02
0036 #define CMD_STATUS_INVALID_PARAMETER 0x03
0037 #define CMD_STATUS_FUNCTION_NOT_SUPPORTED 0x04
0038 #define CMD_STATUS_TIME_OUT 0x07
0039 #define CMD_STATUS_IN_PROGRESS 0x08
0040 #define CMD_STATUS_HOST_FAILURE 0xff
0041 #define CMD_STATUS_SCAN_FAILED 0xf0
0042
0043
0044 #define OPMODE_NONE 0x00
0045 #define OPMODE_NORMAL_NIC_WITH_FLASH 0x01
0046 #define OPMODE_HW_CONFIG_MODE 0x02
0047 #define OPMODE_DFU_MODE_WITH_FLASH 0x03
0048 #define OPMODE_NORMAL_NIC_WITHOUT_FLASH 0x04
0049
0050 #define CMD_SET_MIB 0x01
0051 #define CMD_GET_MIB 0x02
0052 #define CMD_SCAN 0x03
0053 #define CMD_JOIN 0x04
0054 #define CMD_START_IBSS 0x05
0055 #define CMD_RADIO_ON 0x06
0056 #define CMD_RADIO_OFF 0x07
0057 #define CMD_STARTUP 0x0B
0058
0059 #define MIB_LOCAL 0x01
0060 #define MIB_MAC_ADDR 0x02
0061 #define MIB_MAC 0x03
0062 #define MIB_MAC_MGMT 0x05
0063 #define MIB_MAC_WEP 0x06
0064 #define MIB_PHY 0x07
0065 #define MIB_FW_VERSION 0x08
0066 #define MIB_MDOMAIN 0x09
0067
0068 #define ADHOC_MODE 1
0069 #define INFRASTRUCTURE_MODE 2
0070
0071
0072 #define PREAMBLE_TYPE_LONG 0
0073 #define PREAMBLE_TYPE_SHORT 1
0074 #define PREAMBLE_TYPE_AUTO 2
0075
0076
0077 #define TX_RATE_1MBIT 0
0078 #define TX_RATE_2MBIT 1
0079 #define TX_RATE_5_5MBIT 2
0080 #define TX_RATE_11MBIT 3
0081 #define TX_RATE_AUTO 4
0082
0083
0084 #define AT76_PM_OFF 1
0085 #define AT76_PM_ON 2
0086 #define AT76_PM_SMART 3
0087
0088 struct hwcfg_r505 {
0089 u8 cr39_values[14];
0090 u8 reserved1[14];
0091 u8 bb_cr[14];
0092 u8 pidvid[4];
0093 u8 mac_addr[ETH_ALEN];
0094 u8 regulatory_domain;
0095 u8 reserved2[14];
0096 u8 cr15_values[14];
0097 u8 reserved3[3];
0098 } __packed;
0099
0100 struct hwcfg_rfmd {
0101 u8 cr20_values[14];
0102 u8 cr21_values[14];
0103 u8 bb_cr[14];
0104 u8 pidvid[4];
0105 u8 mac_addr[ETH_ALEN];
0106 u8 regulatory_domain;
0107 u8 low_power_values[14];
0108 u8 normal_power_values[14];
0109 u8 reserved1[3];
0110 } __packed;
0111
0112 struct hwcfg_intersil {
0113 u8 mac_addr[ETH_ALEN];
0114 u8 cr31_values[14];
0115 u8 cr58_values[14];
0116 u8 pidvid[4];
0117 u8 regulatory_domain;
0118 u8 reserved[1];
0119 } __packed;
0120
0121 union at76_hwcfg {
0122 struct hwcfg_intersil i;
0123 struct hwcfg_rfmd r3;
0124 struct hwcfg_r505 r5;
0125 };
0126
0127 #define WEP_SMALL_KEY_LEN (40 / 8)
0128 #define WEP_LARGE_KEY_LEN (104 / 8)
0129 #define WEP_KEYS (4)
0130
0131 struct at76_card_config {
0132 u8 exclude_unencrypted;
0133 u8 promiscuous_mode;
0134 u8 short_retry_limit;
0135 u8 encryption_type;
0136 __le16 rts_threshold;
0137 __le16 fragmentation_threshold;
0138 u8 basic_rate_set[4];
0139 u8 auto_rate_fallback;
0140 u8 channel;
0141 u8 privacy_invoked;
0142 u8 wep_default_key_id;
0143 u8 current_ssid[32];
0144 u8 wep_default_key_value[4][WEP_LARGE_KEY_LEN];
0145 u8 ssid_len;
0146 u8 short_preamble;
0147 __le16 beacon_period;
0148 } __packed;
0149
0150 struct at76_command {
0151 u8 cmd;
0152 u8 reserved;
0153 __le16 size;
0154 u8 data[];
0155 } __packed;
0156
0157
0158 #define AT76_RX_HDRLEN offsetof(struct at76_rx_buffer, packet)
0159
0160 struct at76_rx_buffer {
0161 __le16 wlength;
0162 u8 rx_rate;
0163 u8 newbss;
0164 u8 fragmentation;
0165 u8 rssi;
0166 u8 link_quality;
0167 u8 noise_level;
0168 __le32 rx_time;
0169 u8 packet[IEEE80211_MAX_FRAG_THRESHOLD];
0170 } __packed;
0171
0172
0173 #define AT76_TX_HDRLEN offsetof(struct at76_tx_buffer, packet)
0174
0175 struct at76_tx_buffer {
0176 __le16 wlength;
0177 u8 tx_rate;
0178 u8 padding;
0179 u8 reserved[4];
0180 u8 packet[IEEE80211_MAX_FRAG_THRESHOLD];
0181 } __packed;
0182
0183
0184 #define SCAN_TYPE_ACTIVE 0
0185 #define SCAN_TYPE_PASSIVE 1
0186
0187 struct at76_req_scan {
0188 u8 bssid[ETH_ALEN];
0189 u8 essid[32];
0190 u8 scan_type;
0191 u8 channel;
0192 __le16 probe_delay;
0193 __le16 min_channel_time;
0194 __le16 max_channel_time;
0195 u8 essid_size;
0196 u8 international_scan;
0197 } __packed;
0198
0199 struct at76_req_ibss {
0200 u8 bssid[ETH_ALEN];
0201 u8 essid[32];
0202 u8 bss_type;
0203 u8 channel;
0204 u8 essid_size;
0205 u8 reserved[3];
0206 } __packed;
0207
0208 struct at76_req_join {
0209 u8 bssid[ETH_ALEN];
0210 u8 essid[32];
0211 u8 bss_type;
0212 u8 channel;
0213 __le16 timeout;
0214 u8 essid_size;
0215 u8 reserved;
0216 } __packed;
0217
0218 struct mib_local {
0219 u16 reserved0;
0220 u8 beacon_enable;
0221 u8 txautorate_fallback;
0222 u8 reserved1;
0223 u8 ssid_size;
0224 u8 promiscuous_mode;
0225 u16 reserved2;
0226 u8 preamble_type;
0227 u16 reserved3;
0228 } __packed;
0229
0230 struct mib_mac_addr {
0231 u8 mac_addr[ETH_ALEN];
0232 u8 res[2];
0233 u8 group_addr[4][ETH_ALEN];
0234 u8 group_addr_status[4];
0235 } __packed;
0236
0237 struct mib_mac {
0238 __le32 max_tx_msdu_lifetime;
0239 __le32 max_rx_lifetime;
0240 __le16 frag_threshold;
0241 __le16 rts_threshold;
0242 __le16 cwmin;
0243 __le16 cwmax;
0244 u8 short_retry_time;
0245 u8 long_retry_time;
0246 u8 scan_type;
0247 u8 scan_channel;
0248 __le16 probe_delay;
0249 __le16 min_channel_time;
0250 __le16 max_channel_time;
0251 __le16 listen_interval;
0252 u8 desired_ssid[32];
0253 u8 desired_bssid[ETH_ALEN];
0254 u8 desired_bsstype;
0255 u8 reserved2;
0256 } __packed;
0257
0258 struct mib_mac_mgmt {
0259 __le16 beacon_period;
0260 __le16 CFP_max_duration;
0261 __le16 medium_occupancy_limit;
0262 __le16 station_id;
0263 __le16 ATIM_window;
0264 u8 CFP_mode;
0265 u8 privacy_option_implemented;
0266 u8 DTIM_period;
0267 u8 CFP_period;
0268 u8 current_bssid[ETH_ALEN];
0269 u8 current_essid[32];
0270 u8 current_bss_type;
0271 u8 power_mgmt_mode;
0272
0273 u8 ibss_change;
0274 u8 res;
0275 u8 multi_domain_capability_implemented;
0276 u8 multi_domain_capability_enabled;
0277 u8 country_string[IEEE80211_COUNTRY_STRING_LEN];
0278 u8 reserved[3];
0279 } __packed;
0280
0281 struct mib_mac_wep {
0282 u8 privacy_invoked;
0283 u8 wep_default_key_id;
0284 u8 wep_key_mapping_len;
0285 u8 exclude_unencrypted;
0286 __le32 wep_icv_error_count;
0287 __le32 wep_excluded_count;
0288 u8 wep_default_keyvalue[WEP_KEYS][WEP_LARGE_KEY_LEN];
0289 u8 encryption_level;
0290 } __packed;
0291
0292 struct mib_phy {
0293 __le32 ed_threshold;
0294
0295 __le16 slot_time;
0296 __le16 sifs_time;
0297 __le16 preamble_length;
0298 __le16 plcp_header_length;
0299 __le16 mpdu_max_length;
0300 __le16 cca_mode_supported;
0301
0302 u8 operation_rate_set[4];
0303 u8 channel_id;
0304 u8 current_cca_mode;
0305 u8 phy_type;
0306 u8 current_reg_domain;
0307 } __packed;
0308
0309 struct mib_fw_version {
0310 u8 major;
0311 u8 minor;
0312 u8 patch;
0313 u8 build;
0314 } __packed;
0315
0316 struct mib_mdomain {
0317 u8 tx_powerlevel[14];
0318 u8 channel_list[14];
0319 } __packed;
0320
0321 struct set_mib_buffer {
0322 u8 type;
0323 u8 size;
0324 u8 index;
0325 u8 reserved;
0326 union {
0327 u8 byte;
0328 __le16 word;
0329 u8 addr[ETH_ALEN];
0330 struct mib_mac_wep wep_mib;
0331 } data;
0332 } __packed;
0333
0334 struct at76_fw_header {
0335 __le32 crc;
0336 __le32 board_type;
0337 u8 build;
0338 u8 patch;
0339 u8 minor;
0340 u8 major;
0341 __le32 str_offset;
0342 __le32 int_fw_offset;
0343 __le32 int_fw_len;
0344 __le32 ext_fw_offset;
0345 __le32 ext_fw_len;
0346 } __packed;
0347
0348
0349 struct reg_domain {
0350 u16 code;
0351 char const *name;
0352 u32 channel_map;
0353 };
0354
0355
0356 struct fwentry {
0357 const char *const fwname;
0358 const struct firmware *fw;
0359 int extfw_size;
0360 int intfw_size;
0361
0362 u8 *extfw;
0363 u8 *intfw;
0364 enum board_type board_type;
0365 struct mib_fw_version fw_version;
0366 int loaded;
0367 };
0368
0369 struct at76_priv {
0370 struct usb_device *udev;
0371
0372 struct sk_buff *rx_skb;
0373 struct sk_buff *tx_skb;
0374 void *bulk_out_buffer;
0375
0376 struct urb *tx_urb;
0377 struct urb *rx_urb;
0378
0379 unsigned int tx_pipe;
0380 unsigned int rx_pipe;
0381
0382 struct mutex mtx;
0383
0384
0385 struct work_struct work_set_promisc;
0386 struct work_struct work_submit_rx;
0387 struct work_struct work_join_bssid;
0388 struct delayed_work dwork_hw_scan;
0389
0390 struct tasklet_struct rx_tasklet;
0391
0392
0393 int wep_enabled;
0394 int wep_key_id;
0395 u8 wep_keys[WEP_KEYS][WEP_LARGE_KEY_LEN];
0396 u8 wep_keys_len[WEP_KEYS];
0397
0398 int channel;
0399 int iw_mode;
0400 u8 bssid[ETH_ALEN];
0401 u8 essid[IW_ESSID_MAX_SIZE];
0402 int essid_size;
0403 int radio_on;
0404 int promisc;
0405
0406 int preamble_type;
0407 int auth_mode;
0408 int txrate;
0409 int frag_threshold;
0410 int rts_threshold;
0411 int short_retry_limit;
0412
0413 int scan_min_time;
0414 int scan_max_time;
0415 int scan_mode;
0416 int scan_need_any;
0417 bool scanning;
0418
0419 u16 assoc_id;
0420
0421 u8 pm_mode;
0422 u32 pm_period;
0423
0424 struct reg_domain const *domain;
0425
0426
0427
0428 u8 mac_addr[ETH_ALEN];
0429 u8 regulatory_domain;
0430
0431 struct at76_card_config card_config;
0432
0433 enum board_type board_type;
0434 struct mib_fw_version fw_version;
0435
0436 unsigned int device_unplugged:1;
0437 unsigned int netdev_registered:1;
0438 struct set_mib_buffer mib_buf;
0439
0440 int beacon_period;
0441
0442 struct ieee80211_hw *hw;
0443 int mac80211_registered;
0444 };
0445
0446 #define AT76_SUPPORTED_FILTERS 0
0447
0448 #define SCAN_POLL_INTERVAL (HZ / 4)
0449
0450 #define CMD_COMPLETION_TIMEOUT (5 * HZ)
0451
0452 #define DEF_RTS_THRESHOLD 1536
0453 #define DEF_FRAG_THRESHOLD 1536
0454 #define DEF_SHORT_RETRY_LIMIT 8
0455 #define DEF_CHANNEL 10
0456 #define DEF_SCAN_MIN_TIME 10
0457 #define DEF_SCAN_MAX_TIME 120
0458
0459
0460 #define MAX_PADDING_SIZE 53
0461
0462 #endif