linux/drivers/net/wireless/intel/iwlwifi/dvm/dev.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0-only */
   2/******************************************************************************
   3 *
   4 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
   5 *
   6 * Contact Information:
   7 *  Intel Linux Wireless <linuxwifi@intel.com>
   8 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
   9 *
  10 *****************************************************************************/
  11/*
  12 * Please use this file (dev.h) for driver implementation definitions.
  13 * Please use commands.h for uCode API definitions.
  14 */
  15
  16#ifndef __iwl_dev_h__
  17#define __iwl_dev_h__
  18
  19#include <linux/interrupt.h>
  20#include <linux/kernel.h>
  21#include <linux/wait.h>
  22#include <linux/leds.h>
  23#include <linux/slab.h>
  24#include <linux/mutex.h>
  25
  26#include "fw/img.h"
  27#include "iwl-eeprom-parse.h"
  28#include "iwl-csr.h"
  29#include "iwl-debug.h"
  30#include "iwl-agn-hw.h"
  31#include "iwl-op-mode.h"
  32#include "fw/notif-wait.h"
  33#include "iwl-trans.h"
  34
  35#include "led.h"
  36#include "power.h"
  37#include "rs.h"
  38#include "tt.h"
  39
  40/* CT-KILL constants */
  41#define CT_KILL_THRESHOLD_LEGACY   110 /* in Celsius */
  42#define CT_KILL_THRESHOLD          114 /* in Celsius */
  43#define CT_KILL_EXIT_THRESHOLD     95  /* in Celsius */
  44
  45/* Default noise level to report when noise measurement is not available.
  46 *   This may be because we're:
  47 *   1)  Not associated  no beacon statistics being sent to driver)
  48 *   2)  Scanning (noise measurement does not apply to associated channel)
  49 * Use default noise value of -127 ... this is below the range of measurable
  50 *   Rx dBm for all agn devices, so it can indicate "unmeasurable" to user.
  51 *   Also, -127 works better than 0 when averaging frames with/without
  52 *   noise info (e.g. averaging might be done in app); measured dBm values are
  53 *   always negative ... using a negative value as the default keeps all
  54 *   averages within an s8's (used in some apps) range of negative values. */
  55#define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
  56
  57/*
  58 * RTS threshold here is total size [2347] minus 4 FCS bytes
  59 * Per spec:
  60 *   a value of 0 means RTS on all data/management packets
  61 *   a value > max MSDU size means no RTS
  62 * else RTS for data/management frames where MPDU is larger
  63 *   than RTS value.
  64 */
  65#define DEFAULT_RTS_THRESHOLD     2347U
  66#define MIN_RTS_THRESHOLD         0U
  67#define MAX_RTS_THRESHOLD         2347U
  68#define MAX_MSDU_SIZE             2304U
  69#define MAX_MPDU_SIZE             2346U
  70#define DEFAULT_BEACON_INTERVAL   200U
  71#define DEFAULT_SHORT_RETRY_LIMIT 7U
  72#define DEFAULT_LONG_RETRY_LIMIT  4U
  73
  74#define IWL_NUM_SCAN_RATES         (2)
  75
  76
  77#define IEEE80211_DATA_LEN              2304
  78#define IEEE80211_4ADDR_LEN             30
  79#define IEEE80211_HLEN                  (IEEE80211_4ADDR_LEN)
  80#define IEEE80211_FRAME_LEN             (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  81
  82#define SUP_RATE_11A_MAX_NUM_CHANNELS  8
  83#define SUP_RATE_11B_MAX_NUM_CHANNELS  4
  84#define SUP_RATE_11G_MAX_NUM_CHANNELS  12
  85
  86#define IWL_SUPPORTED_RATES_IE_LEN         8
  87
  88#define IWL_INVALID_RATE     0xFF
  89#define IWL_INVALID_VALUE    -1
  90
  91union iwl_ht_rate_supp {
  92        u16 rates;
  93        struct {
  94                u8 siso_rate;
  95                u8 mimo_rate;
  96        };
  97};
  98
  99struct iwl_ht_config {
 100        bool single_chain_sufficient;
 101        enum ieee80211_smps_mode smps; /* current smps mode */
 102};
 103
 104/* QoS structures */
 105struct iwl_qos_info {
 106        int qos_active;
 107        struct iwl_qosparam_cmd def_qos_parm;
 108};
 109
 110/**
 111 * enum iwl_agg_state
 112 *
 113 * The state machine of the BA agreement establishment / tear down.
 114 * These states relate to a specific RA / TID.
 115 *
 116 * @IWL_AGG_OFF: aggregation is not used
 117 * @IWL_AGG_STARTING: aggregation are starting (between start and oper)
 118 * @IWL_AGG_ON: aggregation session is up
 119 * @IWL_EMPTYING_HW_QUEUE_ADDBA: establishing a BA session - waiting for the
 120 *      HW queue to be empty from packets for this RA /TID.
 121 * @IWL_EMPTYING_HW_QUEUE_DELBA: tearing down a BA session - waiting for the
 122 *      HW queue to be empty from packets for this RA /TID.
 123 */
 124enum iwl_agg_state {
 125        IWL_AGG_OFF = 0,
 126        IWL_AGG_STARTING,
 127        IWL_AGG_ON,
 128        IWL_EMPTYING_HW_QUEUE_ADDBA,
 129        IWL_EMPTYING_HW_QUEUE_DELBA,
 130};
 131
 132/**
 133 * struct iwl_ht_agg - aggregation state machine
 134
 135 * This structs holds the states for the BA agreement establishment and tear
 136 * down. It also holds the state during the BA session itself. This struct is
 137 * duplicated for each RA / TID.
 138
 139 * @rate_n_flags: Rate at which Tx was attempted. Holds the data between the
 140 *      Tx response (REPLY_TX), and the block ack notification
 141 *      (REPLY_COMPRESSED_BA).
 142 * @state: state of the BA agreement establishment / tear down.
 143 * @txq_id: Tx queue used by the BA session
 144 * @ssn: the first packet to be sent in AGG HW queue in Tx AGG start flow, or
 145 *      the first packet to be sent in legacy HW queue in Tx AGG stop flow.
 146 *      Basically when next_reclaimed reaches ssn, we can tell mac80211 that
 147 *      we are ready to finish the Tx AGG stop / start flow.
 148 * @wait_for_ba: Expect block-ack before next Tx reply
 149 */
 150struct iwl_ht_agg {
 151        u32 rate_n_flags;
 152        enum iwl_agg_state state;
 153        u16 txq_id;
 154        u16 ssn;
 155        bool wait_for_ba;
 156};
 157
 158/**
 159 * struct iwl_tid_data - one for each RA / TID
 160
 161 * This structs holds the states for each RA / TID.
 162
 163 * @seq_number: the next WiFi sequence number to use
 164 * @next_reclaimed: the WiFi sequence number of the next packet to be acked.
 165 *      This is basically (last acked packet++).
 166 * @agg: aggregation state machine
 167 */
 168struct iwl_tid_data {
 169        u16 seq_number;
 170        u16 next_reclaimed;
 171        struct iwl_ht_agg agg;
 172};
 173
 174/*
 175 * Structure should be accessed with sta_lock held. When station addition
 176 * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
 177 * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock
 178 * held.
 179 */
 180struct iwl_station_entry {
 181        struct iwl_addsta_cmd sta;
 182        u8 used, ctxid;
 183        struct iwl_link_quality_cmd *lq;
 184};
 185
 186/*
 187 * iwl_station_priv: Driver's private station information
 188 *
 189 * When mac80211 creates a station it reserves some space (hw->sta_data_size)
 190 * in the structure for use by driver. This structure is places in that
 191 * space.
 192 */
 193struct iwl_station_priv {
 194        struct iwl_rxon_context *ctx;
 195        struct iwl_lq_sta lq_sta;
 196        atomic_t pending_frames;
 197        bool client;
 198        bool asleep;
 199        u8 max_agg_bufsize;
 200        u8 sta_id;
 201};
 202
 203/**
 204 * struct iwl_vif_priv - driver's private per-interface information
 205 *
 206 * When mac80211 allocates a virtual interface, it can allocate
 207 * space for us to put data into.
 208 */
 209struct iwl_vif_priv {
 210        struct iwl_rxon_context *ctx;
 211        u8 ibss_bssid_sta_id;
 212};
 213
 214struct iwl_sensitivity_ranges {
 215        u16 min_nrg_cck;
 216
 217        u16 nrg_th_cck;
 218        u16 nrg_th_ofdm;
 219
 220        u16 auto_corr_min_ofdm;
 221        u16 auto_corr_min_ofdm_mrc;
 222        u16 auto_corr_min_ofdm_x1;
 223        u16 auto_corr_min_ofdm_mrc_x1;
 224
 225        u16 auto_corr_max_ofdm;
 226        u16 auto_corr_max_ofdm_mrc;
 227        u16 auto_corr_max_ofdm_x1;
 228        u16 auto_corr_max_ofdm_mrc_x1;
 229
 230        u16 auto_corr_max_cck;
 231        u16 auto_corr_max_cck_mrc;
 232        u16 auto_corr_min_cck;
 233        u16 auto_corr_min_cck_mrc;
 234
 235        u16 barker_corr_th_min;
 236        u16 barker_corr_th_min_mrc;
 237        u16 nrg_th_cca;
 238};
 239
 240
 241#define KELVIN_TO_CELSIUS(x) ((x)-273)
 242#define CELSIUS_TO_KELVIN(x) ((x)+273)
 243
 244
 245/******************************************************************************
 246 *
 247 * Functions implemented in core module which are forward declared here
 248 * for use by iwl-[4-5].c
 249 *
 250 * NOTE:  The implementation of these functions are not hardware specific
 251 * which is why they are in the core module files.
 252 *
 253 * Naming convention --
 254 * iwl_         <-- Is part of iwlwifi
 255 * iwlXXXX_     <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
 256 *
 257 ****************************************************************************/
 258void iwl_update_chain_flags(struct iwl_priv *priv);
 259extern const u8 iwl_bcast_addr[ETH_ALEN];
 260
 261#define IWL_OPERATION_MODE_AUTO     0
 262#define IWL_OPERATION_MODE_HT_ONLY  1
 263#define IWL_OPERATION_MODE_MIXED    2
 264#define IWL_OPERATION_MODE_20MHZ    3
 265
 266#define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
 267
 268/* Sensitivity and chain noise calibration */
 269#define INITIALIZATION_VALUE            0xFFFF
 270#define IWL_CAL_NUM_BEACONS             16
 271#define MAXIMUM_ALLOWED_PATHLOSS        15
 272
 273#define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
 274
 275#define MAX_FA_OFDM  50
 276#define MIN_FA_OFDM  5
 277#define MAX_FA_CCK   50
 278#define MIN_FA_CCK   5
 279
 280#define AUTO_CORR_STEP_OFDM       1
 281
 282#define AUTO_CORR_STEP_CCK     3
 283#define AUTO_CORR_MAX_TH_CCK   160
 284
 285#define NRG_DIFF               2
 286#define NRG_STEP_CCK           2
 287#define NRG_MARGIN             8
 288#define MAX_NUMBER_CCK_NO_FA 100
 289
 290#define AUTO_CORR_CCK_MIN_VAL_DEF    (125)
 291
 292#define CHAIN_A             0
 293#define CHAIN_B             1
 294#define CHAIN_C             2
 295#define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
 296#define ALL_BAND_FILTER                 0xFF00
 297#define IN_BAND_FILTER                  0xFF
 298#define MIN_AVERAGE_NOISE_MAX_VALUE     0xFFFFFFFF
 299
 300#define NRG_NUM_PREV_STAT_L     20
 301#define NUM_RX_CHAINS           3
 302
 303enum iwlagn_false_alarm_state {
 304        IWL_FA_TOO_MANY = 0,
 305        IWL_FA_TOO_FEW = 1,
 306        IWL_FA_GOOD_RANGE = 2,
 307};
 308
 309enum iwlagn_chain_noise_state {
 310        IWL_CHAIN_NOISE_ALIVE = 0,  /* must be 0 */
 311        IWL_CHAIN_NOISE_ACCUMULATE,
 312        IWL_CHAIN_NOISE_CALIBRATED,
 313        IWL_CHAIN_NOISE_DONE,
 314};
 315
 316/* Sensitivity calib data */
 317struct iwl_sensitivity_data {
 318        u32 auto_corr_ofdm;
 319        u32 auto_corr_ofdm_mrc;
 320        u32 auto_corr_ofdm_x1;
 321        u32 auto_corr_ofdm_mrc_x1;
 322        u32 auto_corr_cck;
 323        u32 auto_corr_cck_mrc;
 324
 325        u32 last_bad_plcp_cnt_ofdm;
 326        u32 last_fa_cnt_ofdm;
 327        u32 last_bad_plcp_cnt_cck;
 328        u32 last_fa_cnt_cck;
 329
 330        u32 nrg_curr_state;
 331        u32 nrg_prev_state;
 332        u32 nrg_value[10];
 333        u8  nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
 334        u32 nrg_silence_ref;
 335        u32 nrg_energy_idx;
 336        u32 nrg_silence_idx;
 337        u32 nrg_th_cck;
 338        s32 nrg_auto_corr_silence_diff;
 339        u32 num_in_cck_no_fa;
 340        u32 nrg_th_ofdm;
 341
 342        u16 barker_corr_th_min;
 343        u16 barker_corr_th_min_mrc;
 344        u16 nrg_th_cca;
 345};
 346
 347/* Chain noise (differential Rx gain) calib data */
 348struct iwl_chain_noise_data {
 349        u32 active_chains;
 350        u32 chain_noise_a;
 351        u32 chain_noise_b;
 352        u32 chain_noise_c;
 353        u32 chain_signal_a;
 354        u32 chain_signal_b;
 355        u32 chain_signal_c;
 356        u16 beacon_count;
 357        u8 disconn_array[NUM_RX_CHAINS];
 358        u8 delta_gain_code[NUM_RX_CHAINS];
 359        u8 radio_write;
 360        u8 state;
 361};
 362
 363enum {
 364        MEASUREMENT_READY = (1 << 0),
 365        MEASUREMENT_ACTIVE = (1 << 1),
 366};
 367
 368/* reply_tx_statistics (for _agn devices) */
 369struct reply_tx_error_statistics {
 370        u32 pp_delay;
 371        u32 pp_few_bytes;
 372        u32 pp_bt_prio;
 373        u32 pp_quiet_period;
 374        u32 pp_calc_ttak;
 375        u32 int_crossed_retry;
 376        u32 short_limit;
 377        u32 long_limit;
 378        u32 fifo_underrun;
 379        u32 drain_flow;
 380        u32 rfkill_flush;
 381        u32 life_expire;
 382        u32 dest_ps;
 383        u32 host_abort;
 384        u32 bt_retry;
 385        u32 sta_invalid;
 386        u32 frag_drop;
 387        u32 tid_disable;
 388        u32 fifo_flush;
 389        u32 insuff_cf_poll;
 390        u32 fail_hw_drop;
 391        u32 sta_color_mismatch;
 392        u32 unknown;
 393};
 394
 395/* reply_agg_tx_statistics (for _agn devices) */
 396struct reply_agg_tx_error_statistics {
 397        u32 underrun;
 398        u32 bt_prio;
 399        u32 few_bytes;
 400        u32 abort;
 401        u32 last_sent_ttl;
 402        u32 last_sent_try;
 403        u32 last_sent_bt_kill;
 404        u32 scd_query;
 405        u32 bad_crc32;
 406        u32 response;
 407        u32 dump_tx;
 408        u32 delay_tx;
 409        u32 unknown;
 410};
 411
 412/*
 413 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
 414 * to perform continuous uCode event logging operation if enabled
 415 */
 416#define UCODE_TRACE_PERIOD (10)
 417
 418/*
 419 * iwl_event_log: current uCode event log position
 420 *
 421 * @ucode_trace: enable/disable ucode continuous trace timer
 422 * @num_wraps: how many times the event buffer wraps
 423 * @next_entry:  the entry just before the next one that uCode would fill
 424 * @non_wraps_count: counter for no wrap detected when dump ucode events
 425 * @wraps_once_count: counter for wrap once detected when dump ucode events
 426 * @wraps_more_count: counter for wrap more than once detected
 427 *                    when dump ucode events
 428 */
 429struct iwl_event_log {
 430        bool ucode_trace;
 431        u32 num_wraps;
 432        u32 next_entry;
 433        int non_wraps_count;
 434        int wraps_once_count;
 435        int wraps_more_count;
 436};
 437
 438#define IWL_DELAY_NEXT_FORCE_RF_RESET  (HZ*3)
 439
 440/* BT Antenna Coupling Threshold (dB) */
 441#define IWL_BT_ANTENNA_COUPLING_THRESHOLD       (35)
 442
 443/* Firmware reload counter and Timestamp */
 444#define IWL_MIN_RELOAD_DURATION         1000 /* 1000 ms */
 445#define IWL_MAX_CONTINUE_RELOAD_CNT     4
 446
 447
 448struct iwl_rf_reset {
 449        int reset_request_count;
 450        int reset_success_count;
 451        int reset_reject_count;
 452        unsigned long last_reset_jiffies;
 453};
 454
 455enum iwl_rxon_context_id {
 456        IWL_RXON_CTX_BSS,
 457        IWL_RXON_CTX_PAN,
 458
 459        NUM_IWL_RXON_CTX
 460};
 461
 462/* extend beacon time format bit shifting  */
 463/*
 464 * for _agn devices
 465 * bits 31:22 - extended
 466 * bits 21:0  - interval
 467 */
 468#define IWLAGN_EXT_BEACON_TIME_POS      22
 469
 470struct iwl_rxon_context {
 471        struct ieee80211_vif *vif;
 472
 473        u8 mcast_queue;
 474        u8 ac_to_queue[IEEE80211_NUM_ACS];
 475        u8 ac_to_fifo[IEEE80211_NUM_ACS];
 476
 477        /*
 478         * We could use the vif to indicate active, but we
 479         * also need it to be active during disabling when
 480         * we already removed the vif for type setting.
 481         */
 482        bool always_active, is_active;
 483
 484        bool ht_need_multiple_chains;
 485
 486        enum iwl_rxon_context_id ctxid;
 487
 488        u32 interface_modes, exclusive_interface_modes;
 489        u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
 490
 491        /*
 492         * We declare this const so it can only be
 493         * changed via explicit cast within the
 494         * routines that actually update the physical
 495         * hardware.
 496         */
 497        const struct iwl_rxon_cmd active;
 498        struct iwl_rxon_cmd staging;
 499
 500        struct iwl_rxon_time_cmd timing;
 501
 502        struct iwl_qos_info qos_data;
 503
 504        u8 bcast_sta_id, ap_sta_id;
 505
 506        u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd;
 507        u8 qos_cmd;
 508        u8 wep_key_cmd;
 509
 510        struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
 511        u8 key_mapping_keys;
 512
 513        __le32 station_flags;
 514
 515        int beacon_int;
 516
 517        struct {
 518                bool non_gf_sta_present;
 519                u8 protection;
 520                bool enabled, is_40mhz;
 521                u8 extension_chan_offset;
 522        } ht;
 523};
 524
 525enum iwl_scan_type {
 526        IWL_SCAN_NORMAL,
 527        IWL_SCAN_RADIO_RESET,
 528};
 529
 530/**
 531 * struct iwl_hw_params
 532 *
 533 * Holds the module parameters
 534 *
 535 * @tx_chains_num: Number of TX chains
 536 * @rx_chains_num: Number of RX chains
 537 * @ct_kill_threshold: temperature threshold - in hw dependent unit
 538 * @ct_kill_exit_threshold: when to reeable the device - in hw dependent unit
 539 *      relevant for 1000, 6000 and up
 540 * @struct iwl_sensitivity_ranges: range of sensitivity values
 541 * @use_rts_for_aggregation: use rts/cts protection for HT traffic
 542 */
 543struct iwl_hw_params {
 544        u8  tx_chains_num;
 545        u8  rx_chains_num;
 546        bool use_rts_for_aggregation;
 547        u32 ct_kill_threshold;
 548        u32 ct_kill_exit_threshold;
 549
 550        const struct iwl_sensitivity_ranges *sens;
 551};
 552
 553/**
 554 * struct iwl_dvm_bt_params - DVM specific BT (coex) parameters
 555 * @advanced_bt_coexist: support advanced bt coexist
 556 * @bt_init_traffic_load: specify initial bt traffic load
 557 * @bt_prio_boost: default bt priority boost value
 558 * @agg_time_limit: maximum number of uSec in aggregation
 559 * @bt_sco_disable: uCode should not response to BT in SCO/ESCO mode
 560 */
 561struct iwl_dvm_bt_params {
 562        bool advanced_bt_coexist;
 563        u8 bt_init_traffic_load;
 564        u32 bt_prio_boost;
 565        u16 agg_time_limit;
 566        bool bt_sco_disable;
 567        bool bt_session_2;
 568};
 569
 570/**
 571 * struct iwl_dvm_cfg - DVM firmware specific device configuration
 572 * @set_hw_params: set hardware parameters
 573 * @set_channel_switch: send channel switch command
 574 * @nic_config: apply device specific configuration
 575 * @temperature: read temperature
 576 * @adv_thermal_throttle: support advance thermal throttle
 577 * @support_ct_kill_exit: support ct kill exit condition
 578 * @plcp_delta_threshold: plcp error rate threshold used to trigger
 579 *      radio tuning when there is a high receiving plcp error rate
 580 * @chain_noise_scale: default chain noise scale used for gain computation
 581 * @hd_v2: v2 of enhanced sensitivity value, used for 2000 series and up
 582 * @no_idle_support: do not support idle mode
 583 * @bt_params: pointer to BT parameters
 584 * @need_temp_offset_calib: need to perform temperature offset calibration
 585 * @no_xtal_calib: some devices do not need crystal calibration data,
 586 *      don't send it to those
 587 * @temp_offset_v2: support v2 of temperature offset calibration
 588 * @adv_pm: advanced power management
 589 */
 590struct iwl_dvm_cfg {
 591        void (*set_hw_params)(struct iwl_priv *priv);
 592        int (*set_channel_switch)(struct iwl_priv *priv,
 593                                  struct ieee80211_channel_switch *ch_switch);
 594        void (*nic_config)(struct iwl_priv *priv);
 595        void (*temperature)(struct iwl_priv *priv);
 596
 597        const struct iwl_dvm_bt_params *bt_params;
 598        s32 chain_noise_scale;
 599        u8 plcp_delta_threshold;
 600        bool adv_thermal_throttle;
 601        bool support_ct_kill_exit;
 602        bool hd_v2;
 603        bool no_idle_support;
 604        bool need_temp_offset_calib;
 605        bool no_xtal_calib;
 606        bool temp_offset_v2;
 607        bool adv_pm;
 608};
 609
 610struct iwl_wipan_noa_data {
 611        struct rcu_head rcu_head;
 612        u32 length;
 613        u8 data[];
 614};
 615
 616/* Calibration disabling bit mask */
 617enum {
 618        IWL_CALIB_ENABLE_ALL                    = 0,
 619
 620        IWL_SENSITIVITY_CALIB_DISABLED          = BIT(0),
 621        IWL_CHAIN_NOISE_CALIB_DISABLED          = BIT(1),
 622        IWL_TX_POWER_CALIB_DISABLED             = BIT(2),
 623
 624        IWL_CALIB_DISABLE_ALL                   = 0xFFFFFFFF,
 625};
 626
 627#define IWL_OP_MODE_GET_DVM(_iwl_op_mode) \
 628        ((struct iwl_priv *) ((_iwl_op_mode)->op_mode_specific))
 629
 630#define IWL_MAC80211_GET_DVM(_hw) \
 631        ((struct iwl_priv *) ((struct iwl_op_mode *) \
 632        (_hw)->priv)->op_mode_specific)
 633
 634struct iwl_priv {
 635
 636        struct iwl_trans *trans;
 637        struct device *dev;             /* for debug prints only */
 638        const struct iwl_cfg *cfg;
 639        const struct iwl_fw *fw;
 640        const struct iwl_dvm_cfg *lib;
 641        unsigned long status;
 642
 643        spinlock_t sta_lock;
 644        struct mutex mutex;
 645
 646        unsigned long transport_queue_stop;
 647        bool passive_no_rx;
 648#define IWL_INVALID_MAC80211_QUEUE      0xff
 649        u8 queue_to_mac80211[IWL_MAX_HW_QUEUES];
 650        atomic_t queue_stop_count[IWL_MAX_HW_QUEUES];
 651
 652        unsigned long agg_q_alloc[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)];
 653
 654        /* ieee device used by generic ieee processing code */
 655        struct ieee80211_hw *hw;
 656
 657        struct napi_struct *napi;
 658
 659        struct list_head calib_results;
 660
 661        struct workqueue_struct *workqueue;
 662
 663        struct iwl_hw_params hw_params;
 664
 665        enum nl80211_band band;
 666        u8 valid_contexts;
 667
 668        void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
 669                                       struct iwl_rx_cmd_buffer *rxb);
 670
 671        struct iwl_notif_wait_data notif_wait;
 672
 673        /* spectrum measurement report caching */
 674        struct iwl_spectrum_notification measure_report;
 675        u8 measurement_status;
 676
 677        /* ucode beacon time */
 678        u32 ucode_beacon_time;
 679        int missed_beacon_threshold;
 680
 681        /* track IBSS manager (last beacon) status */
 682        u32 ibss_manager;
 683
 684        /* jiffies when last recovery from statistics was performed */
 685        unsigned long rx_statistics_jiffies;
 686
 687        /*counters */
 688        u32 rx_handlers_stats[REPLY_MAX];
 689
 690        /* rf reset */
 691        struct iwl_rf_reset rf_reset;
 692
 693        /* firmware reload counter and timestamp */
 694        unsigned long reload_jiffies;
 695        int reload_count;
 696        bool ucode_loaded;
 697
 698        u8 plcp_delta_threshold;
 699
 700        /* thermal calibration */
 701        s32 temperature;        /* Celsius */
 702        s32 last_temperature;
 703
 704        struct iwl_wipan_noa_data __rcu *noa_data;
 705
 706        /* Scan related variables */
 707        unsigned long scan_start;
 708        unsigned long scan_start_tsf;
 709        void *scan_cmd;
 710        enum nl80211_band scan_band;
 711        struct cfg80211_scan_request *scan_request;
 712        struct ieee80211_vif *scan_vif;
 713        enum iwl_scan_type scan_type;
 714        u8 scan_tx_ant[NUM_NL80211_BANDS];
 715        u8 mgmt_tx_ant;
 716
 717        /* max number of station keys */
 718        u8 sta_key_max_num;
 719
 720        bool new_scan_threshold_behaviour;
 721
 722        bool wowlan;
 723
 724        /* EEPROM MAC addresses */
 725        struct mac_address addresses[2];
 726
 727        struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX];
 728
 729        __le16 switch_channel;
 730
 731        u8 start_calib;
 732        struct iwl_sensitivity_data sensitivity_data;
 733        struct iwl_chain_noise_data chain_noise_data;
 734        __le16 sensitivity_tbl[HD_TABLE_SIZE];
 735        __le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES];
 736
 737        struct iwl_ht_config current_ht_config;
 738
 739        /* Rate scaling data */
 740        u8 retry_rate;
 741
 742        int activity_timer_active;
 743
 744        struct iwl_power_mgr power_data;
 745        struct iwl_tt_mgmt thermal_throttle;
 746
 747        /* station table variables */
 748        int num_stations;
 749        struct iwl_station_entry stations[IWLAGN_STATION_COUNT];
 750        unsigned long ucode_key_table;
 751        struct iwl_tid_data tid_data[IWLAGN_STATION_COUNT][IWL_MAX_TID_COUNT];
 752        atomic_t num_aux_in_flight;
 753
 754        u8 mac80211_registered;
 755
 756        /* Indication if ieee80211_ops->open has been called */
 757        u8 is_open;
 758
 759        enum nl80211_iftype iw_mode;
 760
 761        /* Last Rx'd beacon timestamp */
 762        u64 timestamp;
 763
 764        struct {
 765                __le32 flag;
 766                struct statistics_general_common common;
 767                struct statistics_rx_non_phy rx_non_phy;
 768                struct statistics_rx_phy rx_ofdm;
 769                struct statistics_rx_ht_phy rx_ofdm_ht;
 770                struct statistics_rx_phy rx_cck;
 771                struct statistics_tx tx;
 772#ifdef CONFIG_IWLWIFI_DEBUGFS
 773                struct statistics_bt_activity bt_activity;
 774                __le32 num_bt_kills, accum_num_bt_kills;
 775#endif
 776                spinlock_t lock;
 777        } statistics;
 778#ifdef CONFIG_IWLWIFI_DEBUGFS
 779        struct {
 780                struct statistics_general_common common;
 781                struct statistics_rx_non_phy rx_non_phy;
 782                struct statistics_rx_phy rx_ofdm;
 783                struct statistics_rx_ht_phy rx_ofdm_ht;
 784                struct statistics_rx_phy rx_cck;
 785                struct statistics_tx tx;
 786                struct statistics_bt_activity bt_activity;
 787        } accum_stats, delta_stats, max_delta_stats;
 788#endif
 789
 790        /*
 791         * reporting the number of tids has AGG on. 0 means
 792         * no AGGREGATION
 793         */
 794        u8 agg_tids_count;
 795
 796        struct iwl_rx_phy_res last_phy_res;
 797        u32 ampdu_ref;
 798        bool last_phy_res_valid;
 799
 800        /*
 801         * chain noise reset and gain commands are the
 802         * two extra calibration commands follows the standard
 803         * phy calibration commands
 804         */
 805        u8 phy_calib_chain_noise_reset_cmd;
 806        u8 phy_calib_chain_noise_gain_cmd;
 807
 808        /* counts reply_tx error */
 809        struct reply_tx_error_statistics reply_tx_stats;
 810        struct reply_agg_tx_error_statistics reply_agg_tx_stats;
 811
 812        /* bt coex */
 813        u8 bt_enable_flag;
 814        u8 bt_status;
 815        u8 bt_traffic_load, last_bt_traffic_load;
 816        bool bt_ch_announce;
 817        bool bt_full_concurrent;
 818        bool bt_ant_couple_ok;
 819        __le32 kill_ack_mask;
 820        __le32 kill_cts_mask;
 821        __le16 bt_valid;
 822        bool reduced_txpower;
 823        u16 bt_on_thresh;
 824        u16 bt_duration;
 825        u16 dynamic_frag_thresh;
 826        u8 bt_ci_compliance;
 827        struct work_struct bt_traffic_change_work;
 828        bool bt_enable_pspoll;
 829        struct iwl_rxon_context *cur_rssi_ctx;
 830        bool bt_is_sco;
 831
 832        struct work_struct restart;
 833        struct work_struct scan_completed;
 834        struct work_struct abort_scan;
 835
 836        struct work_struct beacon_update;
 837        struct iwl_rxon_context *beacon_ctx;
 838        struct sk_buff *beacon_skb;
 839        void *beacon_cmd;
 840
 841        struct work_struct tt_work;
 842        struct work_struct ct_enter;
 843        struct work_struct ct_exit;
 844        struct work_struct start_internal_scan;
 845        struct work_struct tx_flush;
 846        struct work_struct bt_full_concurrency;
 847        struct work_struct bt_runtime_config;
 848
 849        struct delayed_work scan_check;
 850
 851        /* TX Power settings */
 852        s8 tx_power_user_lmt;
 853        s8 tx_power_next;
 854
 855#ifdef CONFIG_IWLWIFI_DEBUGFS
 856        /* debugfs */
 857        struct dentry *debugfs_dir;
 858        u32 dbgfs_sram_offset, dbgfs_sram_len;
 859        bool disable_ht40;
 860        void *wowlan_sram;
 861#endif /* CONFIG_IWLWIFI_DEBUGFS */
 862
 863        struct iwl_nvm_data *nvm_data;
 864        /* eeprom blob for debugfs */
 865        u8 *eeprom_blob;
 866        size_t eeprom_blob_size;
 867
 868        struct work_struct txpower_work;
 869        u32 calib_disabled;
 870        struct work_struct run_time_calib_work;
 871        struct timer_list statistics_periodic;
 872        struct timer_list ucode_trace;
 873
 874        struct iwl_event_log event_log;
 875
 876#ifdef CONFIG_IWLWIFI_LEDS
 877        struct led_classdev led;
 878        unsigned long blink_on, blink_off;
 879        bool led_registered;
 880#endif
 881
 882        /* WoWLAN GTK rekey data */
 883        u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
 884        __le64 replay_ctr;
 885        __le16 last_seq_ctl;
 886        bool have_rekey_data;
 887#ifdef CONFIG_PM_SLEEP
 888        struct wiphy_wowlan_support wowlan_support;
 889#endif
 890
 891        /* device_pointers: pointers to ucode event tables */
 892        struct {
 893                u32 error_event_table;
 894                u32 log_event_table;
 895        } device_pointers;
 896
 897        /* indicator of loaded ucode image */
 898        enum iwl_ucode_type cur_ucode;
 899}; /*iwl_priv */
 900
 901static inline struct iwl_rxon_context *
 902iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif)
 903{
 904        struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
 905
 906        return vif_priv->ctx;
 907}
 908
 909#define for_each_context(priv, ctx)                             \
 910        for (ctx = &priv->contexts[IWL_RXON_CTX_BSS];           \
 911             ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++)    \
 912                if (priv->valid_contexts & BIT(ctx->ctxid))
 913
 914static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
 915{
 916        return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
 917}
 918
 919static inline int iwl_is_associated(struct iwl_priv *priv,
 920                                    enum iwl_rxon_context_id ctxid)
 921{
 922        return iwl_is_associated_ctx(&priv->contexts[ctxid]);
 923}
 924
 925static inline int iwl_is_any_associated(struct iwl_priv *priv)
 926{
 927        struct iwl_rxon_context *ctx;
 928        for_each_context(priv, ctx)
 929                if (iwl_is_associated_ctx(ctx))
 930                        return true;
 931        return false;
 932}
 933
 934#endif                          /* __iwl_dev_h__ */
 935