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