linux/drivers/net/wireless/atmel/at76c50x-usb.h
<<
>>
Prefs
   1/*
   2 * Copyright (c) 2002,2003 Oliver Kurth
   3 *           (c) 2003,2004 Joerg Albert <joerg.albert@gmx.de>
   4 *           (c) 2007 Guido Guenther <agx@sigxcpu.org>
   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 */
  26enum board_type {
  27        BOARD_503_ISL3861 = 1,
  28        BOARD_503_ISL3863 = 2,
  29        BOARD_503 = 3,
  30        BOARD_503_ACC = 4,
  31        BOARD_505 = 5,
  32        BOARD_505_2958 = 6,
  33        BOARD_505A = 7,
  34        BOARD_505AMX = 8
  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
  92struct hwcfg_r505 {
  93        u8 cr39_values[14];
  94        u8 reserved1[14];
  95        u8 bb_cr[14];
  96        u8 pidvid[4];
  97        u8 mac_addr[ETH_ALEN];
  98        u8 regulatory_domain;
  99        u8 reserved2[14];
 100        u8 cr15_values[14];
 101        u8 reserved3[3];
 102} __packed;
 103
 104struct hwcfg_rfmd {
 105        u8 cr20_values[14];
 106        u8 cr21_values[14];
 107        u8 bb_cr[14];
 108        u8 pidvid[4];
 109        u8 mac_addr[ETH_ALEN];
 110        u8 regulatory_domain;
 111        u8 low_power_values[14];
 112        u8 normal_power_values[14];
 113        u8 reserved1[3];
 114} __packed;
 115
 116struct hwcfg_intersil {
 117        u8 mac_addr[ETH_ALEN];
 118        u8 cr31_values[14];
 119        u8 cr58_values[14];
 120        u8 pidvid[4];
 121        u8 regulatory_domain;
 122        u8 reserved[1];
 123} __packed;
 124
 125union at76_hwcfg {
 126        struct hwcfg_intersil i;
 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
 135struct at76_card_config {
 136        u8 exclude_unencrypted;
 137        u8 promiscuous_mode;
 138        u8 short_retry_limit;
 139        u8 encryption_type;
 140        __le16 rts_threshold;
 141        __le16 fragmentation_threshold; /* 256..2346 */
 142        u8 basic_rate_set[4];
 143        u8 auto_rate_fallback;  /* 0,1 */
 144        u8 channel;
 145        u8 privacy_invoked;
 146        u8 wep_default_key_id;  /* 0..3 */
 147        u8 current_ssid[32];
 148        u8 wep_default_key_value[4][WEP_LARGE_KEY_LEN];
 149        u8 ssid_len;
 150        u8 short_preamble;
 151        __le16 beacon_period;
 152} __packed;
 153
 154struct at76_command {
 155        u8 cmd;
 156        u8 reserved;
 157        __le16 size;
 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
 164struct at76_rx_buffer {
 165        __le16 wlength;
 166        u8 rx_rate;
 167        u8 newbss;
 168        u8 fragmentation;
 169        u8 rssi;
 170        u8 link_quality;
 171        u8 noise_level;
 172        __le32 rx_time;
 173        u8 packet[IEEE80211_MAX_FRAG_THRESHOLD];
 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
 179struct at76_tx_buffer {
 180        __le16 wlength;
 181        u8 tx_rate;
 182        u8 padding;
 183        u8 reserved[4];
 184        u8 packet[IEEE80211_MAX_FRAG_THRESHOLD];
 185} __packed;
 186
 187/* defines for scan_type below */
 188#define SCAN_TYPE_ACTIVE        0
 189#define SCAN_TYPE_PASSIVE       1
 190
 191struct at76_req_scan {
 192        u8 bssid[ETH_ALEN];
 193        u8 essid[32];
 194        u8 scan_type;
 195        u8 channel;
 196        __le16 probe_delay;
 197        __le16 min_channel_time;
 198        __le16 max_channel_time;
 199        u8 essid_size;
 200        u8 international_scan;
 201} __packed;
 202
 203struct at76_req_ibss {
 204        u8 bssid[ETH_ALEN];
 205        u8 essid[32];
 206        u8 bss_type;
 207        u8 channel;
 208        u8 essid_size;
 209        u8 reserved[3];
 210} __packed;
 211
 212struct at76_req_join {
 213        u8 bssid[ETH_ALEN];
 214        u8 essid[32];
 215        u8 bss_type;
 216        u8 channel;
 217        __le16 timeout;
 218        u8 essid_size;
 219        u8 reserved;
 220} __packed;
 221
 222struct mib_local {
 223        u16 reserved0;
 224        u8 beacon_enable;
 225        u8 txautorate_fallback;
 226        u8 reserved1;
 227        u8 ssid_size;
 228        u8 promiscuous_mode;
 229        u16 reserved2;
 230        u8 preamble_type;
 231        u16 reserved3;
 232} __packed;
 233
 234struct mib_mac_addr {
 235        u8 mac_addr[ETH_ALEN];
 236        u8 res[2];              /* ??? */
 237        u8 group_addr[4][ETH_ALEN];
 238        u8 group_addr_status[4];
 239} __packed;
 240
 241struct mib_mac {
 242        __le32 max_tx_msdu_lifetime;
 243        __le32 max_rx_lifetime;
 244        __le16 frag_threshold;
 245        __le16 rts_threshold;
 246        __le16 cwmin;
 247        __le16 cwmax;
 248        u8 short_retry_time;
 249        u8 long_retry_time;
 250        u8 scan_type;           /* active or passive */
 251        u8 scan_channel;
 252        __le16 probe_delay;     /* delay before ProbeReq in active scan, RO */
 253        __le16 min_channel_time;
 254        __le16 max_channel_time;
 255        __le16 listen_interval;
 256        u8 desired_ssid[32];
 257        u8 desired_bssid[ETH_ALEN];
 258        u8 desired_bsstype;     /* ad-hoc or infrastructure */
 259        u8 reserved2;
 260} __packed;
 261
 262struct mib_mac_mgmt {
 263        __le16 beacon_period;
 264        __le16 CFP_max_duration;
 265        __le16 medium_occupancy_limit;
 266        __le16 station_id;      /* assoc id */
 267        __le16 ATIM_window;
 268        u8 CFP_mode;
 269        u8 privacy_option_implemented;
 270        u8 DTIM_period;
 271        u8 CFP_period;
 272        u8 current_bssid[ETH_ALEN];
 273        u8 current_essid[32];
 274        u8 current_bss_type;
 275        u8 power_mgmt_mode;
 276        /* rfmd and 505 */
 277        u8 ibss_change;
 278        u8 res;
 279        u8 multi_domain_capability_implemented;
 280        u8 multi_domain_capability_enabled;
 281        u8 country_string[IEEE80211_COUNTRY_STRING_LEN];
 282        u8 reserved[3];
 283} __packed;
 284
 285struct mib_mac_wep {
 286        u8 privacy_invoked;     /* 0 disable encr., 1 enable encr */
 287        u8 wep_default_key_id;
 288        u8 wep_key_mapping_len;
 289        u8 exclude_unencrypted;
 290        __le32 wep_icv_error_count;
 291        __le32 wep_excluded_count;
 292        u8 wep_default_keyvalue[WEP_KEYS][WEP_LARGE_KEY_LEN];
 293        u8 encryption_level;    /* 1 for 40bit, 2 for 104bit encryption */
 294} __packed;
 295
 296struct mib_phy {
 297        __le32 ed_threshold;
 298
 299        __le16 slot_time;
 300        __le16 sifs_time;
 301        __le16 preamble_length;
 302        __le16 plcp_header_length;
 303        __le16 mpdu_max_length;
 304        __le16 cca_mode_supported;
 305
 306        u8 operation_rate_set[4];
 307        u8 channel_id;
 308        u8 current_cca_mode;
 309        u8 phy_type;
 310        u8 current_reg_domain;
 311} __packed;
 312
 313struct mib_fw_version {
 314        u8 major;
 315        u8 minor;
 316        u8 patch;
 317        u8 build;
 318} __packed;
 319
 320struct mib_mdomain {
 321        u8 tx_powerlevel[14];
 322        u8 channel_list[14];    /* 0 for invalid channels */
 323} __packed;
 324
 325struct set_mib_buffer {
 326        u8 type;
 327        u8 size;
 328        u8 index;
 329        u8 reserved;
 330        union {
 331                u8 byte;
 332                __le16 word;
 333                u8 addr[ETH_ALEN];
 334                struct mib_mac_wep wep_mib;
 335        } data;
 336} __packed;
 337
 338struct at76_fw_header {
 339        __le32 crc;             /* CRC32 of the whole image */
 340        __le32 board_type;      /* firmware compatibility code */
 341        u8 build;               /* firmware build number */
 342        u8 patch;               /* firmware patch level */
 343        u8 minor;               /* firmware minor version */
 344        u8 major;               /* firmware major version */
 345        __le32 str_offset;      /* offset of the copyright string */
 346        __le32 int_fw_offset;   /* internal firmware image offset */
 347        __le32 int_fw_len;      /* internal firmware image length */
 348        __le32 ext_fw_offset;   /* external firmware image offset */
 349        __le32 ext_fw_len;      /* external firmware image length */
 350} __packed;
 351
 352/* a description of a regulatory domain and the allowed channels */
 353struct reg_domain {
 354        u16 code;
 355        char const *name;
 356        u32 channel_map;        /* if bit N is set, channel (N+1) is allowed */
 357};
 358
 359/* Data for one loaded firmware file */
 360struct fwentry {
 361        const char *const fwname;
 362        const struct firmware *fw;
 363        int extfw_size;
 364        int intfw_size;
 365        /* pointer to loaded firmware, no need to free */
 366        u8 *extfw;              /* external firmware, extfw_size bytes long */
 367        u8 *intfw;              /* internal firmware, intfw_size bytes long */
 368        enum board_type board_type;     /* board type */
 369        struct mib_fw_version fw_version;
 370        int loaded;             /* Loaded and parsed successfully */
 371};
 372
 373struct at76_priv {
 374        struct usb_device *udev;        /* USB device pointer */
 375
 376        struct sk_buff *rx_skb; /* skbuff for receiving data */
 377        struct sk_buff *tx_skb; /* skbuff for transmitting data */
 378        void *bulk_out_buffer;  /* buffer for sending data */
 379
 380        struct urb *tx_urb;     /* URB for sending data */
 381        struct urb *rx_urb;     /* URB for receiving data */
 382
 383        unsigned int tx_pipe;   /* bulk out pipe */
 384        unsigned int rx_pipe;   /* bulk in pipe */
 385
 386        struct mutex mtx;       /* locks this structure */
 387
 388        /* work queues */
 389        struct work_struct work_set_promisc;
 390        struct work_struct work_submit_rx;
 391        struct work_struct work_join_bssid;
 392        struct delayed_work dwork_hw_scan;
 393
 394        struct tasklet_struct rx_tasklet;
 395
 396        /* the WEP stuff */
 397        int wep_enabled;        /* 1 if WEP is enabled */
 398        int wep_key_id;         /* key id to be used */
 399        u8 wep_keys[WEP_KEYS][WEP_LARGE_KEY_LEN];       /* WEP keys */
 400        u8 wep_keys_len[WEP_KEYS];      /* length of WEP keys */
 401
 402        int channel;
 403        int iw_mode;
 404        u8 bssid[ETH_ALEN];
 405        u8 essid[IW_ESSID_MAX_SIZE];
 406        int essid_size;
 407        int radio_on;
 408        int promisc;
 409
 410        int preamble_type;      /* 0 - long, 1 - short, 2 - auto */
 411        int auth_mode;          /* authentication type: 0 open, 1 shared key */
 412        int txrate;             /* 0,1,2,3 = 1,2,5.5,11 Mbps, 4 is auto */
 413        int frag_threshold;     /* threshold for fragmentation of tx packets */
 414        int rts_threshold;      /* threshold for RTS mechanism */
 415        int short_retry_limit;
 416
 417        int scan_min_time;      /* scan min channel time */
 418        int scan_max_time;      /* scan max channel time */
 419        int scan_mode;          /* SCAN_TYPE_ACTIVE, SCAN_TYPE_PASSIVE */
 420        int scan_need_any;      /* if set, need to scan for any ESSID */
 421        bool scanning;          /* if set, the scan is running */
 422
 423        u16 assoc_id;           /* current association ID, if associated */
 424
 425        u8 pm_mode;             /* power management mode */
 426        u32 pm_period;          /* power management period in microseconds */
 427
 428        struct reg_domain const *domain;        /* reg domain description */
 429
 430        /* These fields contain HW config provided by the device (not all of
 431         * these fields are used by all board types) */
 432        u8 mac_addr[ETH_ALEN];
 433        u8 regulatory_domain;
 434
 435        struct at76_card_config card_config;
 436
 437        enum board_type board_type;
 438        struct mib_fw_version fw_version;
 439
 440        unsigned int device_unplugged:1;
 441        unsigned int netdev_registered:1;
 442        struct set_mib_buffer mib_buf;  /* global buffer for set_mib calls */
 443
 444        int beacon_period;      /* period of mgmt beacons, Kus */
 445
 446        struct ieee80211_hw *hw;
 447        int mac80211_registered;
 448};
 449
 450#define AT76_SUPPORTED_FILTERS 0
 451
 452#define SCAN_POLL_INTERVAL      (HZ / 4)
 453
 454#define CMD_COMPLETION_TIMEOUT  (5 * HZ)
 455
 456#define DEF_RTS_THRESHOLD       1536
 457#define DEF_FRAG_THRESHOLD      1536
 458#define DEF_SHORT_RETRY_LIMIT   8
 459#define DEF_CHANNEL             10
 460#define DEF_SCAN_MIN_TIME       10
 461#define DEF_SCAN_MAX_TIME       120
 462
 463/* the max padding size for tx in bytes (see calc_padding) */
 464#define MAX_PADDING_SIZE        53
 465
 466#endif                          /* _AT76_USB_H */
 467