Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1 | /** |
| 2 | * This header file contains global constant/enum definitions, |
| 3 | * global variable declaration. |
| 4 | */ |
| 5 | #ifndef _WLAN_DEFS_H_ |
| 6 | #define _WLAN_DEFS_H_ |
| 7 | |
| 8 | #include <linux/spinlock.h> |
| 9 | |
| 10 | extern unsigned int libertas_debug; |
| 11 | |
Dan Williams | 3a8b9a4 | 2007-05-10 23:05:55 -0400 | [diff] [blame^] | 12 | #ifdef CONFIG_LIBERTAS_DEBUG |
| 13 | #define DEBUG |
| 14 | #define PROC_DEBUG |
| 15 | #endif |
| 16 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 17 | #define DRV_NAME "usb8xxx" |
| 18 | |
| 19 | #define lbs_pr_info(format, args...) \ |
| 20 | printk(KERN_INFO DRV_NAME": " format, ## args) |
| 21 | #define lbs_pr_err(format, args...) \ |
| 22 | printk(KERN_ERR DRV_NAME": " format, ## args) |
| 23 | #define lbs_pr_alert(format, args...) \ |
| 24 | printk(KERN_ALERT DRV_NAME": " format, ## args) |
| 25 | |
| 26 | #ifdef DEBUG |
| 27 | #define lbs_pr_debug(level, format, args...) \ |
| 28 | do { if (libertas_debug >= level) \ |
| 29 | printk(KERN_INFO DRV_NAME": " format, ##args); } while (0) |
| 30 | #define lbs_dev_dbg(level, device, format, args...) \ |
| 31 | lbs_pr_debug(level, "%s: " format, \ |
| 32 | (device)->bus_id , ## args) |
| 33 | |
| 34 | static inline void lbs_dbg_hex(char *prompt, u8 * buf, int len) |
| 35 | { |
| 36 | int i = 0; |
| 37 | |
| 38 | if (!libertas_debug) |
| 39 | return; |
| 40 | |
| 41 | printk(KERN_DEBUG "%s: ", prompt); |
| 42 | for (i = 1; i <= len; i++) { |
| 43 | printk(KERN_DEBUG "%02x ", (u8) * buf); |
| 44 | buf++; |
| 45 | } |
| 46 | printk("\n"); |
| 47 | } |
| 48 | #else |
| 49 | #define lbs_pr_debug(level, format, args...) do {} while (0) |
| 50 | #define lbs_dev_dbg(level, device, format, args...) do {} while (0) |
| 51 | #define lbs_dbg_hex(x,y,z) do {} while (0) |
| 52 | #endif |
| 53 | |
| 54 | #define ENTER() lbs_pr_debug(1, "Enter: %s, %s:%i\n", \ |
| 55 | __FUNCTION__, __FILE__, __LINE__) |
| 56 | #define LEAVE() lbs_pr_debug(1, "Leave: %s, %s:%i\n", \ |
| 57 | __FUNCTION__, __FILE__, __LINE__) |
| 58 | |
| 59 | /** Buffer Constants */ |
| 60 | |
| 61 | /* The size of SQ memory PPA, DPA are 8 DWORDs, that keep the physical |
| 62 | * addresses of TxPD buffers. Station has only 8 TxPD available, Whereas |
| 63 | * driver has more local TxPDs. Each TxPD on the host memory is associated |
| 64 | * with a Tx control node. The driver maintains 8 RxPD descriptors for |
| 65 | * station firmware to store Rx packet information. |
| 66 | * |
| 67 | * Current version of MAC has a 32x6 multicast address buffer. |
| 68 | * |
| 69 | * 802.11b can have up to 14 channels, the driver keeps the |
| 70 | * BSSID(MAC address) of each APs or Ad hoc stations it has sensed. |
| 71 | */ |
| 72 | |
| 73 | #define MRVDRV_MAX_MULTICAST_LIST_SIZE 32 |
| 74 | #define MRVDRV_NUM_OF_CMD_BUFFER 10 |
| 75 | #define MRVDRV_SIZE_OF_CMD_BUFFER (2 * 1024) |
| 76 | #define MRVDRV_MAX_CHANNEL_SIZE 14 |
| 77 | #define MRVDRV_MAX_BSSID_LIST 64 |
| 78 | #define MRVDRV_ASSOCIATION_TIME_OUT 255 |
| 79 | #define MRVDRV_SNAP_HEADER_LEN 8 |
| 80 | |
| 81 | #define WLAN_UPLD_SIZE 2312 |
| 82 | #define DEV_NAME_LEN 32 |
| 83 | |
| 84 | /** Misc constants */ |
| 85 | /* This section defines 802.11 specific contants */ |
| 86 | |
| 87 | #define MRVDRV_MAX_BSS_DESCRIPTS 16 |
| 88 | #define MRVDRV_MAX_REGION_CODE 6 |
| 89 | |
| 90 | #define MRVDRV_IGNORE_MULTIPLE_DTIM 0xfffe |
| 91 | #define MRVDRV_MIN_MULTIPLE_DTIM 1 |
| 92 | #define MRVDRV_MAX_MULTIPLE_DTIM 5 |
| 93 | #define MRVDRV_DEFAULT_MULTIPLE_DTIM 1 |
| 94 | |
| 95 | #define MRVDRV_DEFAULT_LISTEN_INTERVAL 10 |
| 96 | |
| 97 | #define MRVDRV_CHANNELS_PER_SCAN 4 |
| 98 | #define MRVDRV_MAX_CHANNELS_PER_SCAN 14 |
| 99 | |
| 100 | #define MRVDRV_DEBUG_RX_PATH 0x00000001 |
| 101 | #define MRVDRV_DEBUG_TX_PATH 0x00000002 |
| 102 | |
| 103 | #define MRVDRV_MIN_BEACON_INTERVAL 20 |
| 104 | #define MRVDRV_MAX_BEACON_INTERVAL 1000 |
| 105 | #define MRVDRV_BEACON_INTERVAL 100 |
| 106 | |
| 107 | /** TxPD status */ |
| 108 | |
| 109 | /* Station firmware use TxPD status field to report final Tx transmit |
| 110 | * result, Bit masks are used to present combined situations. |
| 111 | */ |
| 112 | |
| 113 | #define MRVDRV_TxPD_POWER_MGMT_NULL_PACKET 0x01 |
| 114 | #define MRVDRV_TxPD_POWER_MGMT_LAST_PACKET 0x08 |
| 115 | |
| 116 | /** Tx mesh flag */ |
| 117 | /* Currently we are using normal WDS flag as mesh flag. |
| 118 | * TODO: change to proper mesh flag when MAC understands it. |
| 119 | */ |
| 120 | #define TxPD_CONTROL_WDS_FRAME (1<<17) |
| 121 | #define TxPD_MESH_FRAME TxPD_CONTROL_WDS_FRAME |
| 122 | |
| 123 | /** RxPD status */ |
| 124 | |
| 125 | #define MRVDRV_RXPD_STATUS_OK 0x0001 |
| 126 | |
| 127 | /** RxPD status - Received packet types */ |
| 128 | /** Rx mesh flag */ |
| 129 | /* Currently we are using normal WDS flag as mesh flag. |
| 130 | * TODO: change to proper mesh flag when MAC understands it. |
| 131 | */ |
| 132 | #define RxPD_CONTROL_WDS_FRAME (0x40) |
| 133 | #define RxPD_MESH_FRAME RxPD_CONTROL_WDS_FRAME |
| 134 | |
| 135 | /** RSSI-related defines */ |
| 136 | /* RSSI constants are used to implement 802.11 RSSI threshold |
| 137 | * indication. if the Rx packet signal got too weak for 5 consecutive |
| 138 | * times, miniport driver (driver) will report this event to wrapper |
| 139 | */ |
| 140 | |
| 141 | #define MRVDRV_NF_DEFAULT_SCAN_VALUE (-96) |
| 142 | |
| 143 | /** RTS/FRAG related defines */ |
| 144 | #define MRVDRV_RTS_MIN_VALUE 0 |
| 145 | #define MRVDRV_RTS_MAX_VALUE 2347 |
| 146 | #define MRVDRV_FRAG_MIN_VALUE 256 |
| 147 | #define MRVDRV_FRAG_MAX_VALUE 2346 |
| 148 | |
| 149 | /* This is for firmware specific length */ |
| 150 | #define EXTRA_LEN 36 |
| 151 | |
| 152 | #define MRVDRV_ETH_TX_PACKET_BUFFER_SIZE \ |
| 153 | (ETH_FRAME_LEN + sizeof(struct txpd) + EXTRA_LEN) |
| 154 | |
| 155 | #define MRVDRV_ETH_RX_PACKET_BUFFER_SIZE \ |
| 156 | (ETH_FRAME_LEN + sizeof(struct rxpd) \ |
| 157 | + MRVDRV_SNAP_HEADER_LEN + EXTRA_LEN) |
| 158 | |
| 159 | #define CMD_F_HOSTCMD (1 << 0) |
| 160 | #define FW_CAPINFO_WPA (1 << 0) |
| 161 | |
| 162 | /** WPA key LENGTH*/ |
| 163 | #define MRVL_MAX_KEY_WPA_KEY_LENGTH 32 |
| 164 | |
| 165 | #define KEY_LEN_WPA_AES 16 |
| 166 | #define KEY_LEN_WPA_TKIP 32 |
| 167 | #define KEY_LEN_WEP_104 13 |
| 168 | #define KEY_LEN_WEP_40 5 |
| 169 | |
| 170 | #define RF_ANTENNA_1 0x1 |
| 171 | #define RF_ANTENNA_2 0x2 |
| 172 | #define RF_ANTENNA_AUTO 0xFFFF |
| 173 | |
| 174 | #define BAND_B (0x01) |
| 175 | #define BAND_G (0x02) |
| 176 | #define ALL_802_11_BANDS (BAND_B | BAND_G) |
| 177 | |
| 178 | /** MACRO DEFINITIONS */ |
| 179 | #define CAL_NF(NF) ((s32)(-(s32)(NF))) |
| 180 | #define CAL_RSSI(SNR, NF) ((s32)((s32)(SNR) + CAL_NF(NF))) |
| 181 | #define SCAN_RSSI(RSSI) (0x100 - ((u8)(RSSI))) |
| 182 | |
| 183 | #define DEFAULT_BCN_AVG_FACTOR 8 |
| 184 | #define DEFAULT_DATA_AVG_FACTOR 8 |
| 185 | #define AVG_SCALE 100 |
| 186 | #define CAL_AVG_SNR_NF(AVG, SNRNF, N) \ |
| 187 | (((AVG) == 0) ? ((u16)(SNRNF) * AVG_SCALE) : \ |
| 188 | ((((int)(AVG) * (N -1)) + ((u16)(SNRNF) * \ |
| 189 | AVG_SCALE)) / N)) |
| 190 | |
| 191 | #define B_SUPPORTED_RATES 8 |
| 192 | #define G_SUPPORTED_RATES 14 |
| 193 | |
| 194 | #define WLAN_SUPPORTED_RATES 14 |
| 195 | |
| 196 | #define MAX_LEDS 8 |
| 197 | |
| 198 | #define IS_MESH_FRAME(x) (x->cb[6]) |
| 199 | #define SET_MESH_FRAME(x) (x->cb[6]=1) |
| 200 | #define UNSET_MESH_FRAME(x) (x->cb[6]=0) |
| 201 | |
| 202 | /** Global Variable Declaration */ |
| 203 | typedef struct _wlan_private wlan_private; |
| 204 | typedef struct _wlan_adapter wlan_adapter; |
| 205 | extern const char libertas_driver_version[]; |
| 206 | extern u16 libertas_region_code_to_index[MRVDRV_MAX_REGION_CODE]; |
| 207 | |
| 208 | extern u8 libertas_wlan_data_rates[WLAN_SUPPORTED_RATES]; |
| 209 | |
| 210 | extern u8 libertas_supported_rates[G_SUPPORTED_RATES]; |
| 211 | |
| 212 | extern u8 libertas_adhoc_rates_g[G_SUPPORTED_RATES]; |
| 213 | |
| 214 | extern u8 libertas_adhoc_rates_b[4]; |
| 215 | |
| 216 | /** ENUM definition*/ |
| 217 | /** SNRNF_TYPE */ |
| 218 | enum SNRNF_TYPE { |
| 219 | TYPE_BEACON = 0, |
| 220 | TYPE_RXPD, |
| 221 | MAX_TYPE_B |
| 222 | }; |
| 223 | |
| 224 | /** SNRNF_DATA*/ |
| 225 | enum SNRNF_DATA { |
| 226 | TYPE_NOAVG = 0, |
| 227 | TYPE_AVG, |
| 228 | MAX_TYPE_AVG |
| 229 | }; |
| 230 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 231 | /** WLAN_802_11_POWER_MODE */ |
| 232 | enum WLAN_802_11_POWER_MODE { |
| 233 | wlan802_11powermodecam, |
| 234 | wlan802_11powermodemax_psp, |
| 235 | wlan802_11Powermodefast_psp, |
| 236 | /*not a real mode, defined as an upper bound */ |
| 237 | wlan802_11powemodemax |
| 238 | }; |
| 239 | |
| 240 | /** PS_STATE */ |
| 241 | enum PS_STATE { |
| 242 | PS_STATE_FULL_POWER, |
| 243 | PS_STATE_AWAKE, |
| 244 | PS_STATE_PRE_SLEEP, |
| 245 | PS_STATE_SLEEP |
| 246 | }; |
| 247 | |
| 248 | /** DNLD_STATE */ |
| 249 | enum DNLD_STATE { |
| 250 | DNLD_RES_RECEIVED, |
| 251 | DNLD_DATA_SENT, |
| 252 | DNLD_CMD_SENT |
| 253 | }; |
| 254 | |
| 255 | /** WLAN_MEDIA_STATE */ |
| 256 | enum WLAN_MEDIA_STATE { |
| 257 | libertas_connected, |
| 258 | libertas_disconnected |
| 259 | }; |
| 260 | |
| 261 | /** WLAN_802_11_PRIVACY_FILTER */ |
| 262 | enum WLAN_802_11_PRIVACY_FILTER { |
| 263 | wlan802_11privfilteracceptall, |
| 264 | wlan802_11privfilter8021xWEP |
| 265 | }; |
| 266 | |
| 267 | /** mv_ms_type */ |
| 268 | enum mv_ms_type { |
| 269 | MVMS_DAT = 0, |
| 270 | MVMS_CMD = 1, |
| 271 | MVMS_TXDONE = 2, |
| 272 | MVMS_EVENT |
| 273 | }; |
| 274 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 275 | /** SNMP_MIB_INDEX_e */ |
| 276 | enum SNMP_MIB_INDEX_e { |
| 277 | desired_bsstype_i = 0, |
| 278 | op_rateset_i, |
| 279 | bcnperiod_i, |
| 280 | dtimperiod_i, |
| 281 | assocrsp_timeout_i, |
| 282 | rtsthresh_i, |
| 283 | short_retrylim_i, |
| 284 | long_retrylim_i, |
| 285 | fragthresh_i, |
| 286 | dot11d_i, |
| 287 | dot11h_i, |
| 288 | manufid_i, |
| 289 | prodID_i, |
| 290 | manuf_oui_i, |
| 291 | manuf_name_i, |
| 292 | manuf_prodname_i, |
| 293 | manuf_prodver_i, |
| 294 | }; |
| 295 | |
| 296 | /** KEY_TYPE_ID */ |
| 297 | enum KEY_TYPE_ID { |
| 298 | KEY_TYPE_ID_WEP = 0, |
| 299 | KEY_TYPE_ID_TKIP, |
| 300 | KEY_TYPE_ID_AES |
| 301 | }; |
| 302 | |
| 303 | /** KEY_INFO_WPA (applies to both TKIP and AES/CCMP) */ |
| 304 | enum KEY_INFO_WPA { |
| 305 | KEY_INFO_WPA_MCAST = 0x01, |
| 306 | KEY_INFO_WPA_UNICAST = 0x02, |
| 307 | KEY_INFO_WPA_ENABLED = 0x04 |
| 308 | }; |
| 309 | |
| 310 | /** SNMP_MIB_VALUE_e */ |
| 311 | enum SNMP_MIB_VALUE_e { |
| 312 | SNMP_MIB_VALUE_INFRA = 1, |
| 313 | SNMP_MIB_VALUE_ADHOC |
| 314 | }; |
| 315 | |
| 316 | /* Default values for fwt commands. */ |
| 317 | #define FWT_DEFAULT_METRIC 0 |
| 318 | #define FWT_DEFAULT_DIR 1 |
| 319 | #define FWT_DEFAULT_SSN 0xffffffff |
| 320 | #define FWT_DEFAULT_DSN 0 |
| 321 | #define FWT_DEFAULT_HOPCOUNT 0 |
| 322 | #define FWT_DEFAULT_TTL 0 |
| 323 | #define FWT_DEFAULT_EXPIRATION 0 |
| 324 | #define FWT_DEFAULT_SLEEPMODE 0 |
| 325 | #define FWT_DEFAULT_SNR 0 |
| 326 | |
| 327 | #endif /* _WLAN_DEFS_H_ */ |