iwl-dev.h revision ab36eab24e7847d6d92872c55b46554c8ac4c4b3
1/****************************************************************************** 2 * 3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 * You should have received a copy of the GNU General Public License along with 15 * this program; if not, write to the Free Software Foundation, Inc., 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA 17 * 18 * The full GNU General Public License is included in this distribution in the 19 * file called LICENSE. 20 * 21 * Contact Information: 22 * Intel Linux Wireless <ilw@linux.intel.com> 23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 24 * 25 *****************************************************************************/ 26/* 27 * Please use this file (iwl-dev.h) for driver implementation definitions. 28 * Please use iwl-commands.h for uCode API definitions. 29 */ 30 31#ifndef __iwl_dev_h__ 32#define __iwl_dev_h__ 33 34#include <linux/interrupt.h> 35#include <linux/kernel.h> 36#include <linux/wait.h> 37#include <linux/leds.h> 38#include <linux/slab.h> 39#include <net/ieee80211_radiotap.h> 40 41#include "iwl-eeprom.h" 42#include "iwl-csr.h" 43#include "iwl-prph.h" 44#include "iwl-debug.h" 45#include "iwl-agn-hw.h" 46#include "iwl-led.h" 47#include "iwl-power.h" 48#include "iwl-agn-rs.h" 49#include "iwl-agn-tt.h" 50#include "iwl-bus.h" 51#include "iwl-trans.h" 52#include "iwl-shared.h" 53 54struct iwl_tx_queue; 55 56/* CT-KILL constants */ 57#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ 58#define CT_KILL_THRESHOLD 114 /* in Celsius */ 59#define CT_KILL_EXIT_THRESHOLD 95 /* in Celsius */ 60 61/* Default noise level to report when noise measurement is not available. 62 * This may be because we're: 63 * 1) Not associated no beacon statistics being sent to driver) 64 * 2) Scanning (noise measurement does not apply to associated channel) 65 * Use default noise value of -127 ... this is below the range of measurable 66 * Rx dBm for all agn devices, so it can indicate "unmeasurable" to user. 67 * Also, -127 works better than 0 when averaging frames with/without 68 * noise info (e.g. averaging might be done in app); measured dBm values are 69 * always negative ... using a negative value as the default keeps all 70 * averages within an s8's (used in some apps) range of negative values. */ 71#define IWL_NOISE_MEAS_NOT_AVAILABLE (-127) 72 73/* 74 * RTS threshold here is total size [2347] minus 4 FCS bytes 75 * Per spec: 76 * a value of 0 means RTS on all data/management packets 77 * a value > max MSDU size means no RTS 78 * else RTS for data/management frames where MPDU is larger 79 * than RTS value. 80 */ 81#define DEFAULT_RTS_THRESHOLD 2347U 82#define MIN_RTS_THRESHOLD 0U 83#define MAX_RTS_THRESHOLD 2347U 84#define MAX_MSDU_SIZE 2304U 85#define MAX_MPDU_SIZE 2346U 86#define DEFAULT_BEACON_INTERVAL 200U 87#define DEFAULT_SHORT_RETRY_LIMIT 7U 88#define DEFAULT_LONG_RETRY_LIMIT 4U 89 90#define IWL_NUM_SCAN_RATES (2) 91 92/* 93 * One for each channel, holds all channel setup data 94 * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant 95 * with one another! 96 */ 97struct iwl_channel_info { 98 struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */ 99 struct iwl_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for 100 * HT40 channel */ 101 102 u8 channel; /* channel number */ 103 u8 flags; /* flags copied from EEPROM */ 104 s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ 105 s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */ 106 s8 min_power; /* always 0 */ 107 s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */ 108 109 u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */ 110 u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */ 111 enum ieee80211_band band; 112 113 /* HT40 channel info */ 114 s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ 115 u8 ht40_flags; /* flags copied from EEPROM */ 116 u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */ 117}; 118 119/* 120 * Minimum number of queues. MAX_NUM is defined in hw specific files. 121 * Set the minimum to accommodate 122 * - 4 standard TX queues 123 * - the command queue 124 * - 4 PAN TX queues 125 * - the PAN multicast queue, and 126 * - the AUX (TX during scan dwell) queue. 127 */ 128#define IWL_MIN_NUM_QUEUES 11 129 130/* 131 * Command queue depends on iPAN support. 132 */ 133#define IWL_DEFAULT_CMD_QUEUE_NUM 4 134#define IWL_IPAN_CMD_QUEUE_NUM 9 135 136#define IEEE80211_DATA_LEN 2304 137#define IEEE80211_4ADDR_LEN 30 138#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) 139#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) 140 141#define SUP_RATE_11A_MAX_NUM_CHANNELS 8 142#define SUP_RATE_11B_MAX_NUM_CHANNELS 4 143#define SUP_RATE_11G_MAX_NUM_CHANNELS 12 144 145#define IWL_SUPPORTED_RATES_IE_LEN 8 146 147#define IWL_INVALID_RATE 0xFF 148#define IWL_INVALID_VALUE -1 149 150union iwl_ht_rate_supp { 151 u16 rates; 152 struct { 153 u8 siso_rate; 154 u8 mimo_rate; 155 }; 156}; 157 158#define CFG_HT_RX_AMPDU_FACTOR_8K (0x0) 159#define CFG_HT_RX_AMPDU_FACTOR_16K (0x1) 160#define CFG_HT_RX_AMPDU_FACTOR_32K (0x2) 161#define CFG_HT_RX_AMPDU_FACTOR_64K (0x3) 162#define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K 163#define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K 164#define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K 165 166/* 167 * Maximal MPDU density for TX aggregation 168 * 4 - 2us density 169 * 5 - 4us density 170 * 6 - 8us density 171 * 7 - 16us density 172 */ 173#define CFG_HT_MPDU_DENSITY_2USEC (0x4) 174#define CFG_HT_MPDU_DENSITY_4USEC (0x5) 175#define CFG_HT_MPDU_DENSITY_8USEC (0x6) 176#define CFG_HT_MPDU_DENSITY_16USEC (0x7) 177#define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC 178#define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC 179#define CFG_HT_MPDU_DENSITY_MIN (0x1) 180 181struct iwl_ht_config { 182 bool single_chain_sufficient; 183 enum ieee80211_smps_mode smps; /* current smps mode */ 184}; 185 186/* QoS structures */ 187struct iwl_qos_info { 188 int qos_active; 189 struct iwl_qosparam_cmd def_qos_parm; 190}; 191 192/* 193 * Structure should be accessed with sta_lock held. When station addition 194 * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only 195 * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock 196 * held. 197 */ 198struct iwl_station_entry { 199 struct iwl_addsta_cmd sta; 200 u8 used, ctxid; 201 struct iwl_link_quality_cmd *lq; 202}; 203 204/* 205 * iwl_station_priv: Driver's private station information 206 * 207 * When mac80211 creates a station it reserves some space (hw->sta_data_size) 208 * in the structure for use by driver. This structure is places in that 209 * space. 210 */ 211struct iwl_station_priv { 212 struct iwl_rxon_context *ctx; 213 struct iwl_lq_sta lq_sta; 214 atomic_t pending_frames; 215 bool client; 216 bool asleep; 217 u8 max_agg_bufsize; 218 u8 sta_id; 219}; 220 221/** 222 * struct iwl_vif_priv - driver's private per-interface information 223 * 224 * When mac80211 allocates a virtual interface, it can allocate 225 * space for us to put data into. 226 */ 227struct iwl_vif_priv { 228 struct iwl_rxon_context *ctx; 229 u8 ibss_bssid_sta_id; 230}; 231 232/* v1/v2 uCode file layout */ 233struct iwl_ucode_header { 234 __le32 ver; /* major/minor/API/serial */ 235 union { 236 struct { 237 __le32 inst_size; /* bytes of runtime code */ 238 __le32 data_size; /* bytes of runtime data */ 239 __le32 init_size; /* bytes of init code */ 240 __le32 init_data_size; /* bytes of init data */ 241 __le32 boot_size; /* bytes of bootstrap code */ 242 u8 data[0]; /* in same order as sizes */ 243 } v1; 244 struct { 245 __le32 build; /* build number */ 246 __le32 inst_size; /* bytes of runtime code */ 247 __le32 data_size; /* bytes of runtime data */ 248 __le32 init_size; /* bytes of init code */ 249 __le32 init_data_size; /* bytes of init data */ 250 __le32 boot_size; /* bytes of bootstrap code */ 251 u8 data[0]; /* in same order as sizes */ 252 } v2; 253 } u; 254}; 255 256/* 257 * new TLV uCode file layout 258 * 259 * The new TLV file format contains TLVs, that each specify 260 * some piece of data. To facilitate "groups", for example 261 * different instruction image with different capabilities, 262 * bundled with the same init image, an alternative mechanism 263 * is provided: 264 * When the alternative field is 0, that means that the item 265 * is always valid. When it is non-zero, then it is only 266 * valid in conjunction with items of the same alternative, 267 * in which case the driver (user) selects one alternative 268 * to use. 269 */ 270 271enum iwl_ucode_tlv_type { 272 IWL_UCODE_TLV_INVALID = 0, /* unused */ 273 IWL_UCODE_TLV_INST = 1, 274 IWL_UCODE_TLV_DATA = 2, 275 IWL_UCODE_TLV_INIT = 3, 276 IWL_UCODE_TLV_INIT_DATA = 4, 277 IWL_UCODE_TLV_BOOT = 5, 278 IWL_UCODE_TLV_PROBE_MAX_LEN = 6, /* a u32 value */ 279 IWL_UCODE_TLV_PAN = 7, 280 IWL_UCODE_TLV_RUNT_EVTLOG_PTR = 8, 281 IWL_UCODE_TLV_RUNT_EVTLOG_SIZE = 9, 282 IWL_UCODE_TLV_RUNT_ERRLOG_PTR = 10, 283 IWL_UCODE_TLV_INIT_EVTLOG_PTR = 11, 284 IWL_UCODE_TLV_INIT_EVTLOG_SIZE = 12, 285 IWL_UCODE_TLV_INIT_ERRLOG_PTR = 13, 286 IWL_UCODE_TLV_ENHANCE_SENS_TBL = 14, 287 IWL_UCODE_TLV_PHY_CALIBRATION_SIZE = 15, 288 IWL_UCODE_TLV_WOWLAN_INST = 16, 289 IWL_UCODE_TLV_WOWLAN_DATA = 17, 290 IWL_UCODE_TLV_FLAGS = 18, 291}; 292 293/** 294 * enum iwl_ucode_tlv_flag - ucode API flags 295 * @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously 296 * was a separate TLV but moved here to save space. 297 * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID, 298 * treats good CRC threshold as a boolean 299 * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w). 300 * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P. 301 */ 302enum iwl_ucode_tlv_flag { 303 IWL_UCODE_TLV_FLAGS_PAN = BIT(0), 304 IWL_UCODE_TLV_FLAGS_NEWSCAN = BIT(1), 305 IWL_UCODE_TLV_FLAGS_MFP = BIT(2), 306 IWL_UCODE_TLV_FLAGS_P2P = BIT(3), 307}; 308 309struct iwl_ucode_tlv { 310 __le16 type; /* see above */ 311 __le16 alternative; /* see comment */ 312 __le32 length; /* not including type/length fields */ 313 u8 data[0]; 314} __packed; 315 316#define IWL_TLV_UCODE_MAGIC 0x0a4c5749 317 318struct iwl_tlv_ucode_header { 319 /* 320 * The TLV style ucode header is distinguished from 321 * the v1/v2 style header by first four bytes being 322 * zero, as such is an invalid combination of 323 * major/minor/API/serial versions. 324 */ 325 __le32 zero; 326 __le32 magic; 327 u8 human_readable[64]; 328 __le32 ver; /* major/minor/API/serial */ 329 __le32 build; 330 __le64 alternatives; /* bitmask of valid alternatives */ 331 /* 332 * The data contained herein has a TLV layout, 333 * see above for the TLV header and types. 334 * Note that each TLV is padded to a length 335 * that is a multiple of 4 for alignment. 336 */ 337 u8 data[0]; 338}; 339 340struct iwl_sensitivity_ranges { 341 u16 min_nrg_cck; 342 u16 max_nrg_cck; 343 344 u16 nrg_th_cck; 345 u16 nrg_th_ofdm; 346 347 u16 auto_corr_min_ofdm; 348 u16 auto_corr_min_ofdm_mrc; 349 u16 auto_corr_min_ofdm_x1; 350 u16 auto_corr_min_ofdm_mrc_x1; 351 352 u16 auto_corr_max_ofdm; 353 u16 auto_corr_max_ofdm_mrc; 354 u16 auto_corr_max_ofdm_x1; 355 u16 auto_corr_max_ofdm_mrc_x1; 356 357 u16 auto_corr_max_cck; 358 u16 auto_corr_max_cck_mrc; 359 u16 auto_corr_min_cck; 360 u16 auto_corr_min_cck_mrc; 361 362 u16 barker_corr_th_min; 363 u16 barker_corr_th_min_mrc; 364 u16 nrg_th_cca; 365}; 366 367 368#define KELVIN_TO_CELSIUS(x) ((x)-273) 369#define CELSIUS_TO_KELVIN(x) ((x)+273) 370 371 372/****************************************************************************** 373 * 374 * Functions implemented in core module which are forward declared here 375 * for use by iwl-[4-5].c 376 * 377 * NOTE: The implementation of these functions are not hardware specific 378 * which is why they are in the core module files. 379 * 380 * Naming convention -- 381 * iwl_ <-- Is part of iwlwifi 382 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) 383 * 384 ****************************************************************************/ 385extern void iwl_update_chain_flags(struct iwl_priv *priv); 386extern const u8 iwl_bcast_addr[ETH_ALEN]; 387 388#define IWL_OPERATION_MODE_AUTO 0 389#define IWL_OPERATION_MODE_HT_ONLY 1 390#define IWL_OPERATION_MODE_MIXED 2 391#define IWL_OPERATION_MODE_20MHZ 3 392 393#define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000 394 395/* Sensitivity and chain noise calibration */ 396#define INITIALIZATION_VALUE 0xFFFF 397#define IWL_CAL_NUM_BEACONS 16 398#define MAXIMUM_ALLOWED_PATHLOSS 15 399 400#define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3 401 402#define MAX_FA_OFDM 50 403#define MIN_FA_OFDM 5 404#define MAX_FA_CCK 50 405#define MIN_FA_CCK 5 406 407#define AUTO_CORR_STEP_OFDM 1 408 409#define AUTO_CORR_STEP_CCK 3 410#define AUTO_CORR_MAX_TH_CCK 160 411 412#define NRG_DIFF 2 413#define NRG_STEP_CCK 2 414#define NRG_MARGIN 8 415#define MAX_NUMBER_CCK_NO_FA 100 416 417#define AUTO_CORR_CCK_MIN_VAL_DEF (125) 418 419#define CHAIN_A 0 420#define CHAIN_B 1 421#define CHAIN_C 2 422#define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4 423#define ALL_BAND_FILTER 0xFF00 424#define IN_BAND_FILTER 0xFF 425#define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF 426 427#define NRG_NUM_PREV_STAT_L 20 428#define NUM_RX_CHAINS 3 429 430enum iwlagn_false_alarm_state { 431 IWL_FA_TOO_MANY = 0, 432 IWL_FA_TOO_FEW = 1, 433 IWL_FA_GOOD_RANGE = 2, 434}; 435 436enum iwlagn_chain_noise_state { 437 IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ 438 IWL_CHAIN_NOISE_ACCUMULATE, 439 IWL_CHAIN_NOISE_CALIBRATED, 440 IWL_CHAIN_NOISE_DONE, 441}; 442 443 444/* Opaque calibration results */ 445struct iwl_calib_result { 446 struct list_head list; 447 size_t cmd_len; 448 struct iwl_calib_hdr hdr; 449 /* data follows */ 450}; 451 452/* Sensitivity calib data */ 453struct iwl_sensitivity_data { 454 u32 auto_corr_ofdm; 455 u32 auto_corr_ofdm_mrc; 456 u32 auto_corr_ofdm_x1; 457 u32 auto_corr_ofdm_mrc_x1; 458 u32 auto_corr_cck; 459 u32 auto_corr_cck_mrc; 460 461 u32 last_bad_plcp_cnt_ofdm; 462 u32 last_fa_cnt_ofdm; 463 u32 last_bad_plcp_cnt_cck; 464 u32 last_fa_cnt_cck; 465 466 u32 nrg_curr_state; 467 u32 nrg_prev_state; 468 u32 nrg_value[10]; 469 u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L]; 470 u32 nrg_silence_ref; 471 u32 nrg_energy_idx; 472 u32 nrg_silence_idx; 473 u32 nrg_th_cck; 474 s32 nrg_auto_corr_silence_diff; 475 u32 num_in_cck_no_fa; 476 u32 nrg_th_ofdm; 477 478 u16 barker_corr_th_min; 479 u16 barker_corr_th_min_mrc; 480 u16 nrg_th_cca; 481}; 482 483/* Chain noise (differential Rx gain) calib data */ 484struct iwl_chain_noise_data { 485 u32 active_chains; 486 u32 chain_noise_a; 487 u32 chain_noise_b; 488 u32 chain_noise_c; 489 u32 chain_signal_a; 490 u32 chain_signal_b; 491 u32 chain_signal_c; 492 u16 beacon_count; 493 u8 disconn_array[NUM_RX_CHAINS]; 494 u8 delta_gain_code[NUM_RX_CHAINS]; 495 u8 radio_write; 496 u8 state; 497}; 498 499#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ 500#define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ 501 502enum { 503 MEASUREMENT_READY = (1 << 0), 504 MEASUREMENT_ACTIVE = (1 << 1), 505}; 506 507enum iwl_nvm_type { 508 NVM_DEVICE_TYPE_EEPROM = 0, 509 NVM_DEVICE_TYPE_OTP, 510}; 511 512/* 513 * Two types of OTP memory access modes 514 * IWL_OTP_ACCESS_ABSOLUTE - absolute address mode, 515 * based on physical memory addressing 516 * IWL_OTP_ACCESS_RELATIVE - relative address mode, 517 * based on logical memory addressing 518 */ 519enum iwl_access_mode { 520 IWL_OTP_ACCESS_ABSOLUTE, 521 IWL_OTP_ACCESS_RELATIVE, 522}; 523 524/** 525 * enum iwl_pa_type - Power Amplifier type 526 * @IWL_PA_SYSTEM: based on uCode configuration 527 * @IWL_PA_INTERNAL: use Internal only 528 */ 529enum iwl_pa_type { 530 IWL_PA_SYSTEM = 0, 531 IWL_PA_INTERNAL = 1, 532}; 533 534/* reply_tx_statistics (for _agn devices) */ 535struct reply_tx_error_statistics { 536 u32 pp_delay; 537 u32 pp_few_bytes; 538 u32 pp_bt_prio; 539 u32 pp_quiet_period; 540 u32 pp_calc_ttak; 541 u32 int_crossed_retry; 542 u32 short_limit; 543 u32 long_limit; 544 u32 fifo_underrun; 545 u32 drain_flow; 546 u32 rfkill_flush; 547 u32 life_expire; 548 u32 dest_ps; 549 u32 host_abort; 550 u32 bt_retry; 551 u32 sta_invalid; 552 u32 frag_drop; 553 u32 tid_disable; 554 u32 fifo_flush; 555 u32 insuff_cf_poll; 556 u32 fail_hw_drop; 557 u32 sta_color_mismatch; 558 u32 unknown; 559}; 560 561/* reply_agg_tx_statistics (for _agn devices) */ 562struct reply_agg_tx_error_statistics { 563 u32 underrun; 564 u32 bt_prio; 565 u32 few_bytes; 566 u32 abort; 567 u32 last_sent_ttl; 568 u32 last_sent_try; 569 u32 last_sent_bt_kill; 570 u32 scd_query; 571 u32 bad_crc32; 572 u32 response; 573 u32 dump_tx; 574 u32 delay_tx; 575 u32 unknown; 576}; 577 578/* management statistics */ 579enum iwl_mgmt_stats { 580 MANAGEMENT_ASSOC_REQ = 0, 581 MANAGEMENT_ASSOC_RESP, 582 MANAGEMENT_REASSOC_REQ, 583 MANAGEMENT_REASSOC_RESP, 584 MANAGEMENT_PROBE_REQ, 585 MANAGEMENT_PROBE_RESP, 586 MANAGEMENT_BEACON, 587 MANAGEMENT_ATIM, 588 MANAGEMENT_DISASSOC, 589 MANAGEMENT_AUTH, 590 MANAGEMENT_DEAUTH, 591 MANAGEMENT_ACTION, 592 MANAGEMENT_MAX, 593}; 594/* control statistics */ 595enum iwl_ctrl_stats { 596 CONTROL_BACK_REQ = 0, 597 CONTROL_BACK, 598 CONTROL_PSPOLL, 599 CONTROL_RTS, 600 CONTROL_CTS, 601 CONTROL_ACK, 602 CONTROL_CFEND, 603 CONTROL_CFENDACK, 604 CONTROL_MAX, 605}; 606 607struct traffic_stats { 608#ifdef CONFIG_IWLWIFI_DEBUGFS 609 u32 mgmt[MANAGEMENT_MAX]; 610 u32 ctrl[CONTROL_MAX]; 611 u32 data_cnt; 612 u64 data_bytes; 613#endif 614}; 615 616/* 617 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds 618 * to perform continuous uCode event logging operation if enabled 619 */ 620#define UCODE_TRACE_PERIOD (100) 621 622/* 623 * iwl_event_log: current uCode event log position 624 * 625 * @ucode_trace: enable/disable ucode continuous trace timer 626 * @num_wraps: how many times the event buffer wraps 627 * @next_entry: the entry just before the next one that uCode would fill 628 * @non_wraps_count: counter for no wrap detected when dump ucode events 629 * @wraps_once_count: counter for wrap once detected when dump ucode events 630 * @wraps_more_count: counter for wrap more than once detected 631 * when dump ucode events 632 */ 633struct iwl_event_log { 634 bool ucode_trace; 635 u32 num_wraps; 636 u32 next_entry; 637 int non_wraps_count; 638 int wraps_once_count; 639 int wraps_more_count; 640}; 641 642/* 643 * This is the threshold value of plcp error rate per 100mSecs. It is 644 * used to set and check for the validity of plcp_delta. 645 */ 646#define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (1) 647#define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50) 648#define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF (100) 649#define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF (200) 650#define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255) 651#define IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE (0) 652 653#define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3) 654#define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5) 655 656/* TX queue watchdog timeouts in mSecs */ 657#define IWL_DEF_WD_TIMEOUT (2000) 658#define IWL_LONG_WD_TIMEOUT (10000) 659#define IWL_MAX_WD_TIMEOUT (120000) 660 661/* BT Antenna Coupling Threshold (dB) */ 662#define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35) 663 664/* Firmware reload counter and Timestamp */ 665#define IWL_MIN_RELOAD_DURATION 1000 /* 1000 ms */ 666#define IWL_MAX_CONTINUE_RELOAD_CNT 4 667 668 669enum iwl_reset { 670 IWL_RF_RESET = 0, 671 IWL_FW_RESET, 672 IWL_MAX_FORCE_RESET, 673}; 674 675struct iwl_force_reset { 676 int reset_request_count; 677 int reset_success_count; 678 int reset_reject_count; 679 unsigned long reset_duration; 680 unsigned long last_force_reset_jiffies; 681}; 682 683/* extend beacon time format bit shifting */ 684/* 685 * for _agn devices 686 * bits 31:22 - extended 687 * bits 21:0 - interval 688 */ 689#define IWLAGN_EXT_BEACON_TIME_POS 22 690 691struct iwl_rxon_context { 692 struct ieee80211_vif *vif; 693 694 /* 695 * We could use the vif to indicate active, but we 696 * also need it to be active during disabling when 697 * we already removed the vif for type setting. 698 */ 699 bool always_active, is_active; 700 701 bool ht_need_multiple_chains; 702 703 enum iwl_rxon_context_id ctxid; 704 705 u32 interface_modes, exclusive_interface_modes; 706 u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype; 707 708 /* 709 * We declare this const so it can only be 710 * changed via explicit cast within the 711 * routines that actually update the physical 712 * hardware. 713 */ 714 const struct iwl_rxon_cmd active; 715 struct iwl_rxon_cmd staging; 716 717 struct iwl_rxon_time_cmd timing; 718 719 struct iwl_qos_info qos_data; 720 721 u8 bcast_sta_id, ap_sta_id; 722 723 u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd; 724 u8 qos_cmd; 725 u8 wep_key_cmd; 726 727 struct iwl_wep_key wep_keys[WEP_KEYS_MAX]; 728 u8 key_mapping_keys; 729 730 __le32 station_flags; 731 732 int beacon_int; 733 734 struct { 735 bool non_gf_sta_present; 736 u8 protection; 737 bool enabled, is_40mhz; 738 u8 extension_chan_offset; 739 } ht; 740 741 u8 bssid[ETH_ALEN]; 742 bool preauth_bssid; 743 744 bool last_tx_rejected; 745}; 746 747enum iwl_scan_type { 748 IWL_SCAN_NORMAL, 749 IWL_SCAN_RADIO_RESET, 750 IWL_SCAN_ROC, 751}; 752 753#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE 754struct iwl_testmode_trace { 755 u32 buff_size; 756 u32 total_size; 757 u32 num_chunks; 758 u8 *cpu_addr; 759 u8 *trace_addr; 760 dma_addr_t dma_addr; 761 bool trace_enabled; 762}; 763struct iwl_testmode_sram { 764 u32 buff_size; 765 u32 num_chunks; 766 u8 *buff_addr; 767 bool sram_readed; 768}; 769#endif 770 771struct iwl_wipan_noa_data { 772 struct rcu_head rcu_head; 773 u32 length; 774 u8 data[]; 775}; 776 777struct iwl_priv { 778 779 /*data shared among all the driver's layers */ 780 struct iwl_shared _shrd; 781 struct iwl_shared *shrd; 782 783 /* ieee device used by generic ieee processing code */ 784 struct ieee80211_hw *hw; 785 struct ieee80211_channel *ieee_channels; 786 struct ieee80211_rate *ieee_rates; 787 struct kmem_cache *tx_cmd_pool; 788 struct iwl_cfg *cfg; 789 790 enum ieee80211_band band; 791 792 void (*pre_rx_handler)(struct iwl_priv *priv, 793 struct iwl_rx_mem_buffer *rxb); 794 int (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv, 795 struct iwl_rx_mem_buffer *rxb, 796 struct iwl_device_cmd *cmd); 797 798 struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; 799 800 /* spectrum measurement report caching */ 801 struct iwl_spectrum_notification measure_report; 802 u8 measurement_status; 803 804 /* ucode beacon time */ 805 u32 ucode_beacon_time; 806 int missed_beacon_threshold; 807 808 /* track IBSS manager (last beacon) status */ 809 u32 ibss_manager; 810 811 /* jiffies when last recovery from statistics was performed */ 812 unsigned long rx_statistics_jiffies; 813 814 /*counters */ 815 u32 rx_handlers_stats[REPLY_MAX]; 816 817 /* force reset */ 818 struct iwl_force_reset force_reset[IWL_MAX_FORCE_RESET]; 819 820 /* firmware reload counter and timestamp */ 821 unsigned long reload_jiffies; 822 int reload_count; 823 824 /* we allocate array of iwl_channel_info for NIC's valid channels. 825 * Access via channel # using indirect index array */ 826 struct iwl_channel_info *channel_info; /* channel info array */ 827 u8 channel_count; /* # of channels */ 828 829 /* thermal calibration */ 830 s32 temperature; /* Celsius */ 831 s32 last_temperature; 832 833 /* init calibration results */ 834 struct list_head calib_results; 835 836 struct iwl_wipan_noa_data __rcu *noa_data; 837 838 /* Scan related variables */ 839 unsigned long scan_start; 840 unsigned long scan_start_tsf; 841 void *scan_cmd; 842 enum ieee80211_band scan_band; 843 struct cfg80211_scan_request *scan_request; 844 struct ieee80211_vif *scan_vif; 845 enum iwl_scan_type scan_type; 846 u8 scan_tx_ant[IEEE80211_NUM_BANDS]; 847 u8 mgmt_tx_ant; 848 849 /* max number of station keys */ 850 u8 sta_key_max_num; 851 852 bool new_scan_threshold_behaviour; 853 854 /* EEPROM MAC addresses */ 855 struct mac_address addresses[2]; 856 857 /* uCode images, save to reload in case of failure */ 858 int fw_index; /* firmware we're trying to load */ 859 u32 ucode_ver; /* version of ucode, copy of 860 iwl_ucode.ver */ 861 862 char firmware_name[25]; 863 864 struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX]; 865 866 __le16 switch_channel; 867 868 struct { 869 u32 error_event_table; 870 u32 log_event_table; 871 } device_pointers; 872 873 u16 active_rate; 874 875 u8 start_calib; 876 struct iwl_sensitivity_data sensitivity_data; 877 struct iwl_chain_noise_data chain_noise_data; 878 bool enhance_sensitivity_table; 879 __le16 sensitivity_tbl[HD_TABLE_SIZE]; 880 __le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES]; 881 882 struct iwl_ht_config current_ht_config; 883 884 /* Rate scaling data */ 885 u8 retry_rate; 886 887 int activity_timer_active; 888 889 /* counts mgmt, ctl, and data packets */ 890 struct traffic_stats tx_stats; 891 struct traffic_stats rx_stats; 892 893 struct iwl_power_mgr power_data; 894 struct iwl_tt_mgmt thermal_throttle; 895 896 /* station table variables */ 897 int num_stations; 898 struct iwl_station_entry stations[IWLAGN_STATION_COUNT]; 899 unsigned long ucode_key_table; 900 901 u8 mac80211_registered; 902 903 /* Indication if ieee80211_ops->open has been called */ 904 u8 is_open; 905 906 enum nl80211_iftype iw_mode; 907 908 /* Last Rx'd beacon timestamp */ 909 u64 timestamp; 910 911 struct { 912 __le32 flag; 913 struct statistics_general_common common; 914 struct statistics_rx_non_phy rx_non_phy; 915 struct statistics_rx_phy rx_ofdm; 916 struct statistics_rx_ht_phy rx_ofdm_ht; 917 struct statistics_rx_phy rx_cck; 918 struct statistics_tx tx; 919#ifdef CONFIG_IWLWIFI_DEBUGFS 920 struct statistics_bt_activity bt_activity; 921 __le32 num_bt_kills, accum_num_bt_kills; 922#endif 923 } statistics; 924#ifdef CONFIG_IWLWIFI_DEBUGFS 925 struct { 926 struct statistics_general_common common; 927 struct statistics_rx_non_phy rx_non_phy; 928 struct statistics_rx_phy rx_ofdm; 929 struct statistics_rx_ht_phy rx_ofdm_ht; 930 struct statistics_rx_phy rx_cck; 931 struct statistics_tx tx; 932 struct statistics_bt_activity bt_activity; 933 } accum_stats, delta_stats, max_delta_stats; 934#endif 935 936 /* 937 * reporting the number of tids has AGG on. 0 means 938 * no AGGREGATION 939 */ 940 u8 agg_tids_count; 941 942 struct iwl_rx_phy_res last_phy_res; 943 bool last_phy_res_valid; 944 945 struct completion firmware_loading_complete; 946 947 u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; 948 u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; 949 950 /* 951 * chain noise reset and gain commands are the 952 * two extra calibration commands follows the standard 953 * phy calibration commands 954 */ 955 u8 phy_calib_chain_noise_reset_cmd; 956 u8 phy_calib_chain_noise_gain_cmd; 957 958 /* counts reply_tx error */ 959 struct reply_tx_error_statistics reply_tx_stats; 960 struct reply_agg_tx_error_statistics reply_agg_tx_stats; 961 962 /* remain-on-channel offload support */ 963 struct ieee80211_channel *hw_roc_channel; 964 struct delayed_work hw_roc_disable_work; 965 enum nl80211_channel_type hw_roc_chantype; 966 int hw_roc_duration; 967 bool hw_roc_setup, hw_roc_start_notified; 968 969 /* bt coex */ 970 u8 bt_enable_flag; 971 u8 bt_status; 972 u8 bt_traffic_load, last_bt_traffic_load; 973 bool bt_ch_announce; 974 bool bt_full_concurrent; 975 bool bt_ant_couple_ok; 976 __le32 kill_ack_mask; 977 __le32 kill_cts_mask; 978 __le16 bt_valid; 979 u16 bt_on_thresh; 980 u16 bt_duration; 981 u16 dynamic_frag_thresh; 982 u8 bt_ci_compliance; 983 struct work_struct bt_traffic_change_work; 984 bool bt_enable_pspoll; 985 struct iwl_rxon_context *cur_rssi_ctx; 986 bool bt_is_sco; 987 988 struct work_struct restart; 989 struct work_struct scan_completed; 990 struct work_struct abort_scan; 991 992 struct work_struct beacon_update; 993 struct iwl_rxon_context *beacon_ctx; 994 struct sk_buff *beacon_skb; 995 void *beacon_cmd; 996 997 struct work_struct tt_work; 998 struct work_struct ct_enter; 999 struct work_struct ct_exit; 1000 struct work_struct start_internal_scan; 1001 struct work_struct tx_flush; 1002 struct work_struct bt_full_concurrency; 1003 struct work_struct bt_runtime_config; 1004 1005 struct delayed_work scan_check; 1006 1007 /* TX Power */ 1008 s8 tx_power_user_lmt; 1009 s8 tx_power_device_lmt; 1010 s8 tx_power_lmt_in_half_dbm; /* max tx power in half-dBm format */ 1011 s8 tx_power_next; 1012 1013#ifdef CONFIG_IWLWIFI_DEBUGFS 1014 /* debugfs */ 1015 u16 tx_traffic_idx; 1016 u16 rx_traffic_idx; 1017 u8 *tx_traffic; 1018 u8 *rx_traffic; 1019 struct dentry *debugfs_dir; 1020 u32 dbgfs_sram_offset, dbgfs_sram_len; 1021 bool disable_ht40; 1022 void *wowlan_sram; 1023#endif /* CONFIG_IWLWIFI_DEBUGFS */ 1024 1025 struct work_struct txpower_work; 1026 u32 disable_sens_cal; 1027 u32 disable_chain_noise_cal; 1028 struct work_struct run_time_calib_work; 1029 struct timer_list statistics_periodic; 1030 struct timer_list ucode_trace; 1031 struct timer_list watchdog; 1032 1033 struct iwl_event_log event_log; 1034 1035 struct led_classdev led; 1036 unsigned long blink_on, blink_off; 1037 bool led_registered; 1038#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE 1039 struct iwl_testmode_trace testmode_trace; 1040 struct iwl_testmode_sram testmode_sram; 1041 u32 tm_fixed_rate; 1042#endif 1043 1044 /* WoWLAN GTK rekey data */ 1045 u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN]; 1046 __le64 replay_ctr; 1047 __le16 last_seq_ctl; 1048 bool have_rekey_data; 1049}; /*iwl_priv */ 1050 1051extern struct iwl_mod_params iwlagn_mod_params; 1052 1053static inline struct iwl_rxon_context * 1054iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif) 1055{ 1056 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 1057 1058 return vif_priv->ctx; 1059} 1060 1061#define for_each_context(priv, ctx) \ 1062 for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \ 1063 ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \ 1064 if (priv->shrd->valid_contexts & BIT(ctx->ctxid)) 1065 1066static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx) 1067{ 1068 return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; 1069} 1070 1071static inline int iwl_is_associated(struct iwl_priv *priv, 1072 enum iwl_rxon_context_id ctxid) 1073{ 1074 return iwl_is_associated_ctx(&priv->contexts[ctxid]); 1075} 1076 1077static inline int iwl_is_any_associated(struct iwl_priv *priv) 1078{ 1079 struct iwl_rxon_context *ctx; 1080 for_each_context(priv, ctx) 1081 if (iwl_is_associated_ctx(ctx)) 1082 return true; 1083 return false; 1084} 1085 1086static inline int is_channel_valid(const struct iwl_channel_info *ch_info) 1087{ 1088 if (ch_info == NULL) 1089 return 0; 1090 return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0; 1091} 1092 1093static inline int is_channel_radar(const struct iwl_channel_info *ch_info) 1094{ 1095 return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0; 1096} 1097 1098static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info) 1099{ 1100 return ch_info->band == IEEE80211_BAND_5GHZ; 1101} 1102 1103static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info) 1104{ 1105 return ch_info->band == IEEE80211_BAND_2GHZ; 1106} 1107 1108static inline int is_channel_passive(const struct iwl_channel_info *ch) 1109{ 1110 return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0; 1111} 1112 1113static inline int is_channel_ibss(const struct iwl_channel_info *ch) 1114{ 1115 return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0; 1116} 1117 1118#endif /* __iwl_dev_h__ */ 1119