1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 /* 3 * Copyright (C) 2012-2014, 2018-2020 Intel Corporation 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 */ 7 #ifndef __IWL_MVM_H__ 8 #define __IWL_MVM_H__ 9 10 #include <linux/list.h> 11 #include <linux/spinlock.h> 12 #include <linux/leds.h> 13 #include <linux/in6.h> 14 15 #ifdef CONFIG_THERMAL 16 #include <linux/thermal.h> 17 #endif 18 19 #include "iwl-op-mode.h" 20 #include "iwl-trans.h" 21 #include "fw/notif-wait.h" 22 #include "iwl-eeprom-parse.h" 23 #include "fw/file.h" 24 #include "iwl-config.h" 25 #include "sta.h" 26 #include "fw-api.h" 27 #include "constants.h" 28 #include "fw/runtime.h" 29 #include "fw/dbg.h" 30 #include "fw/acpi.h" 31 #include "iwl-nvm-parse.h" 32 33 #include <linux/average.h> 34 35 #define IWL_MVM_MAX_ADDRESSES 5 36 /* RSSI offset for WkP */ 37 #define IWL_RSSI_OFFSET 50 38 #define IWL_MVM_MISSED_BEACONS_THRESHOLD 8 39 #define IWL_MVM_MISSED_BEACONS_THRESHOLD_LONG 16 40 41 /* A TimeUnit is 1024 microsecond */ 42 #define MSEC_TO_TU(_msec) (_msec*1000/1024) 43 44 /* For GO, this value represents the number of TUs before CSA "beacon 45 * 0" TBTT when the CSA time-event needs to be scheduled to start. It 46 * must be big enough to ensure that we switch in time. 47 */ 48 #define IWL_MVM_CHANNEL_SWITCH_TIME_GO 40 49 50 /* For client, this value represents the number of TUs before CSA 51 * "beacon 1" TBTT, instead. This is because we don't know when the 52 * GO/AP will be in the new channel, so we switch early enough. 53 */ 54 #define IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT 10 55 56 /* 57 * This value (in TUs) is used to fine tune the CSA NoA end time which should 58 * be just before "beacon 0" TBTT. 59 */ 60 #define IWL_MVM_CHANNEL_SWITCH_MARGIN 4 61 62 /* 63 * Number of beacons to transmit on a new channel until we unblock tx to 64 * the stations, even if we didn't identify them on a new channel 65 */ 66 #define IWL_MVM_CS_UNBLOCK_TX_TIMEOUT 3 67 68 /* offchannel queue towards mac80211 */ 69 #define IWL_MVM_OFFCHANNEL_QUEUE 0 70 71 extern const struct ieee80211_ops iwl_mvm_hw_ops; 72 73 /** 74 * struct iwl_mvm_mod_params - module parameters for iwlmvm 75 * @init_dbg: if true, then the NIC won't be stopped if the INIT fw asserted. 76 * We will register to mac80211 to have testmode working. The NIC must not 77 * be up'ed after the INIT fw asserted. This is useful to be able to use 78 * proprietary tools over testmode to debug the INIT fw. 79 * @power_scheme: one of enum iwl_power_scheme 80 */ 81 struct iwl_mvm_mod_params { 82 bool init_dbg; 83 int power_scheme; 84 }; 85 extern struct iwl_mvm_mod_params iwlmvm_mod_params; 86 87 struct iwl_mvm_phy_ctxt { 88 u16 id; 89 u16 color; 90 u32 ref; 91 92 enum nl80211_chan_width width; 93 94 /* 95 * TODO: This should probably be removed. Currently here only for rate 96 * scaling algorithm 97 */ 98 struct ieee80211_channel *channel; 99 }; 100 101 struct iwl_mvm_time_event_data { 102 struct ieee80211_vif *vif; 103 struct list_head list; 104 unsigned long end_jiffies; 105 u32 duration; 106 bool running; 107 u32 uid; 108 109 /* 110 * The access to the 'id' field must be done when the 111 * mvm->time_event_lock is held, as it value is used to indicate 112 * if the te is in the time event list or not (when id == TE_MAX) 113 */ 114 u32 id; 115 }; 116 117 /* Power management */ 118 119 /** 120 * enum iwl_power_scheme 121 * @IWL_POWER_LEVEL_CAM - Continuously Active Mode 122 * @IWL_POWER_LEVEL_BPS - Balanced Power Save (default) 123 * @IWL_POWER_LEVEL_LP - Low Power 124 */ 125 enum iwl_power_scheme { 126 IWL_POWER_SCHEME_CAM = 1, 127 IWL_POWER_SCHEME_BPS, 128 IWL_POWER_SCHEME_LP 129 }; 130 131 #define IWL_CONN_MAX_LISTEN_INTERVAL 10 132 #define IWL_UAPSD_MAX_SP IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL 133 134 #ifdef CONFIG_IWLWIFI_DEBUGFS 135 enum iwl_dbgfs_pm_mask { 136 MVM_DEBUGFS_PM_KEEP_ALIVE = BIT(0), 137 MVM_DEBUGFS_PM_SKIP_OVER_DTIM = BIT(1), 138 MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS = BIT(2), 139 MVM_DEBUGFS_PM_RX_DATA_TIMEOUT = BIT(3), 140 MVM_DEBUGFS_PM_TX_DATA_TIMEOUT = BIT(4), 141 MVM_DEBUGFS_PM_LPRX_ENA = BIT(6), 142 MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD = BIT(7), 143 MVM_DEBUGFS_PM_SNOOZE_ENABLE = BIT(8), 144 MVM_DEBUGFS_PM_UAPSD_MISBEHAVING = BIT(9), 145 MVM_DEBUGFS_PM_USE_PS_POLL = BIT(10), 146 }; 147 148 struct iwl_dbgfs_pm { 149 u16 keep_alive_seconds; 150 u32 rx_data_timeout; 151 u32 tx_data_timeout; 152 bool skip_over_dtim; 153 u8 skip_dtim_periods; 154 bool lprx_ena; 155 u32 lprx_rssi_threshold; 156 bool snooze_ena; 157 bool uapsd_misbehaving; 158 bool use_ps_poll; 159 int mask; 160 }; 161 162 /* beacon filtering */ 163 164 enum iwl_dbgfs_bf_mask { 165 MVM_DEBUGFS_BF_ENERGY_DELTA = BIT(0), 166 MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA = BIT(1), 167 MVM_DEBUGFS_BF_ROAMING_STATE = BIT(2), 168 MVM_DEBUGFS_BF_TEMP_THRESHOLD = BIT(3), 169 MVM_DEBUGFS_BF_TEMP_FAST_FILTER = BIT(4), 170 MVM_DEBUGFS_BF_TEMP_SLOW_FILTER = BIT(5), 171 MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER = BIT(6), 172 MVM_DEBUGFS_BF_DEBUG_FLAG = BIT(7), 173 MVM_DEBUGFS_BF_ESCAPE_TIMER = BIT(8), 174 MVM_DEBUGFS_BA_ESCAPE_TIMER = BIT(9), 175 MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT = BIT(10), 176 }; 177 178 struct iwl_dbgfs_bf { 179 u32 bf_energy_delta; 180 u32 bf_roaming_energy_delta; 181 u32 bf_roaming_state; 182 u32 bf_temp_threshold; 183 u32 bf_temp_fast_filter; 184 u32 bf_temp_slow_filter; 185 u32 bf_enable_beacon_filter; 186 u32 bf_debug_flag; 187 u32 bf_escape_timer; 188 u32 ba_escape_timer; 189 u32 ba_enable_beacon_abort; 190 int mask; 191 }; 192 #endif 193 194 enum iwl_mvm_smps_type_request { 195 IWL_MVM_SMPS_REQ_BT_COEX, 196 IWL_MVM_SMPS_REQ_TT, 197 IWL_MVM_SMPS_REQ_PROT, 198 NUM_IWL_MVM_SMPS_REQ, 199 }; 200 201 enum iwl_bt_force_ant_mode { 202 BT_FORCE_ANT_DIS = 0, 203 BT_FORCE_ANT_AUTO, 204 BT_FORCE_ANT_BT, 205 BT_FORCE_ANT_WIFI, 206 207 BT_FORCE_ANT_MAX, 208 }; 209 210 /** 211 * struct iwl_mvm_low_latency_force - low latency force mode set by debugfs 212 * @LOW_LATENCY_FORCE_UNSET: unset force mode 213 * @LOW_LATENCY_FORCE_ON: for low latency on 214 * @LOW_LATENCY_FORCE_OFF: for low latency off 215 * @NUM_LOW_LATENCY_FORCE: max num of modes 216 */ 217 enum iwl_mvm_low_latency_force { 218 LOW_LATENCY_FORCE_UNSET, 219 LOW_LATENCY_FORCE_ON, 220 LOW_LATENCY_FORCE_OFF, 221 NUM_LOW_LATENCY_FORCE 222 }; 223 224 /** 225 * struct iwl_mvm_low_latency_cause - low latency set causes 226 * @LOW_LATENCY_TRAFFIC: indicates low latency traffic was detected 227 * @LOW_LATENCY_DEBUGFS: low latency mode set from debugfs 228 * @LOW_LATENCY_VCMD: low latency mode set from vendor command 229 * @LOW_LATENCY_VIF_TYPE: low latency mode set because of vif type (ap) 230 * @LOW_LATENCY_DEBUGFS_FORCE_ENABLE: indicate that force mode is enabled 231 * the actual set/unset is done with LOW_LATENCY_DEBUGFS_FORCE 232 * @LOW_LATENCY_DEBUGFS_FORCE: low latency force mode from debugfs 233 * set this with LOW_LATENCY_DEBUGFS_FORCE_ENABLE flag 234 * in low_latency. 235 */ 236 enum iwl_mvm_low_latency_cause { 237 LOW_LATENCY_TRAFFIC = BIT(0), 238 LOW_LATENCY_DEBUGFS = BIT(1), 239 LOW_LATENCY_VCMD = BIT(2), 240 LOW_LATENCY_VIF_TYPE = BIT(3), 241 LOW_LATENCY_DEBUGFS_FORCE_ENABLE = BIT(4), 242 LOW_LATENCY_DEBUGFS_FORCE = BIT(5), 243 }; 244 245 /** 246 * struct iwl_mvm_vif_bf_data - beacon filtering related data 247 * @bf_enabled: indicates if beacon filtering is enabled 248 * @ba_enabled: indicated if beacon abort is enabled 249 * @ave_beacon_signal: average beacon signal 250 * @last_cqm_event: rssi of the last cqm event 251 * @bt_coex_min_thold: minimum threshold for BT coex 252 * @bt_coex_max_thold: maximum threshold for BT coex 253 * @last_bt_coex_event: rssi of the last BT coex event 254 */ 255 struct iwl_mvm_vif_bf_data { 256 bool bf_enabled; 257 bool ba_enabled; 258 int ave_beacon_signal; 259 int last_cqm_event; 260 int bt_coex_min_thold; 261 int bt_coex_max_thold; 262 int last_bt_coex_event; 263 }; 264 265 /** 266 * struct iwl_probe_resp_data - data for NoA/CSA updates 267 * @rcu_head: used for freeing the data on update 268 * @notif: notification data 269 * @noa_len: length of NoA attribute, calculated from the notification 270 */ 271 struct iwl_probe_resp_data { 272 struct rcu_head rcu_head; 273 struct iwl_probe_resp_data_notif notif; 274 int noa_len; 275 }; 276 277 /** 278 * struct iwl_mvm_vif - data per Virtual Interface, it is a MAC context 279 * @id: between 0 and 3 280 * @color: to solve races upon MAC addition and removal 281 * @ap_sta_id: the sta_id of the AP - valid only if VIF type is STA 282 * @bssid: BSSID for this (client) interface 283 * @associated: indicates that we're currently associated, used only for 284 * managing the firmware state in iwl_mvm_bss_info_changed_station() 285 * @ap_assoc_sta_count: count of stations associated to us - valid only 286 * if VIF type is AP 287 * @uploaded: indicates the MAC context has been added to the device 288 * @ap_ibss_active: indicates that AP/IBSS is configured and that the interface 289 * should get quota etc. 290 * @pm_enabled - Indicate if MAC power management is allowed 291 * @monitor_active: indicates that monitor context is configured, and that the 292 * interface should get quota etc. 293 * @low_latency: bit flags for low latency 294 * see enum &iwl_mvm_low_latency_cause for causes. 295 * @low_latency_actual: boolean, indicates low latency is set, 296 * as a result from low_latency bit flags and takes force into account. 297 * @ps_disabled: indicates that this interface requires PS to be disabled 298 * @queue_params: QoS params for this MAC 299 * @bcast_sta: station used for broadcast packets. Used by the following 300 * vifs: P2P_DEVICE, GO and AP. 301 * @beacon_skb: the skb used to hold the AP/GO beacon template 302 * @smps_requests: the SMPS requests of different parts of the driver, 303 * combined on update to yield the overall request to mac80211. 304 * @beacon_stats: beacon statistics, containing the # of received beacons, 305 * # of received beacons accumulated over FW restart, and the current 306 * average signal of beacons retrieved from the firmware 307 * @csa_failed: CSA failed to schedule time event, report an error later 308 * @features: hw features active for this vif 309 * @probe_resp_data: data from FW notification to store NOA and CSA related 310 * data to be inserted into probe response. 311 */ 312 struct iwl_mvm_vif { 313 struct iwl_mvm *mvm; 314 u16 id; 315 u16 color; 316 u8 ap_sta_id; 317 318 u8 bssid[ETH_ALEN]; 319 bool associated; 320 u8 ap_assoc_sta_count; 321 322 u16 cab_queue; 323 324 bool uploaded; 325 bool ap_ibss_active; 326 bool pm_enabled; 327 bool monitor_active; 328 u8 low_latency: 6; 329 u8 low_latency_actual: 1; 330 bool ps_disabled; 331 struct iwl_mvm_vif_bf_data bf_data; 332 333 struct { 334 u32 num_beacons, accu_num_beacons; 335 u8 avg_signal; 336 } beacon_stats; 337 338 u32 ap_beacon_time; 339 340 enum iwl_tsf_id tsf_id; 341 342 /* 343 * QoS data from mac80211, need to store this here 344 * as mac80211 has a separate callback but we need 345 * to have the data for the MAC context 346 */ 347 struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS]; 348 struct iwl_mvm_time_event_data time_event_data; 349 struct iwl_mvm_time_event_data hs_time_event_data; 350 351 struct iwl_mvm_int_sta bcast_sta; 352 struct iwl_mvm_int_sta mcast_sta; 353 354 /* 355 * Assigned while mac80211 has the interface in a channel context, 356 * or, for P2P Device, while it exists. 357 */ 358 struct iwl_mvm_phy_ctxt *phy_ctxt; 359 360 #ifdef CONFIG_PM 361 /* WoWLAN GTK rekey data */ 362 struct { 363 u8 kck[NL80211_KCK_EXT_LEN]; 364 u8 kek[NL80211_KEK_EXT_LEN]; 365 size_t kek_len; 366 size_t kck_len; 367 u32 akm; 368 __le64 replay_ctr; 369 bool valid; 370 } rekey_data; 371 372 int tx_key_idx; 373 374 bool seqno_valid; 375 u16 seqno; 376 #endif 377 378 #if IS_ENABLED(CONFIG_IPV6) 379 /* IPv6 addresses for WoWLAN */ 380 struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX]; 381 unsigned long tentative_addrs[BITS_TO_LONGS(IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX)]; 382 int num_target_ipv6_addrs; 383 #endif 384 385 #ifdef CONFIG_IWLWIFI_DEBUGFS 386 struct dentry *dbgfs_dir; 387 struct dentry *dbgfs_slink; 388 struct iwl_dbgfs_pm dbgfs_pm; 389 struct iwl_dbgfs_bf dbgfs_bf; 390 struct iwl_mac_power_cmd mac_pwr_cmd; 391 int dbgfs_quota_min; 392 #endif 393 394 enum ieee80211_smps_mode smps_requests[NUM_IWL_MVM_SMPS_REQ]; 395 396 /* FW identified misbehaving AP */ 397 u8 uapsd_misbehaving_bssid[ETH_ALEN]; 398 399 struct delayed_work uapsd_nonagg_detected_wk; 400 401 /* Indicates that CSA countdown may be started */ 402 bool csa_countdown; 403 bool csa_failed; 404 u16 csa_target_freq; 405 u16 csa_count; 406 u16 csa_misbehave; 407 struct delayed_work csa_work; 408 409 /* Indicates that we are waiting for a beacon on a new channel */ 410 bool csa_bcn_pending; 411 412 /* TCP Checksum Offload */ 413 netdev_features_t features; 414 415 struct iwl_probe_resp_data __rcu *probe_resp_data; 416 417 /* we can only have 2 GTK + 2 IGTK active at a time */ 418 struct ieee80211_key_conf *ap_early_keys[4]; 419 420 /* 26-tone RU OFDMA transmissions should be blocked */ 421 bool he_ru_2mhz_block; 422 }; 423 424 static inline struct iwl_mvm_vif * 425 iwl_mvm_vif_from_mac80211(struct ieee80211_vif *vif) 426 { 427 if (!vif) 428 return NULL; 429 return (void *)vif->drv_priv; 430 } 431 432 extern const u8 tid_to_mac80211_ac[]; 433 434 #define IWL_MVM_SCAN_STOPPING_SHIFT 8 435 436 enum iwl_scan_status { 437 IWL_MVM_SCAN_REGULAR = BIT(0), 438 IWL_MVM_SCAN_SCHED = BIT(1), 439 IWL_MVM_SCAN_NETDETECT = BIT(2), 440 441 IWL_MVM_SCAN_STOPPING_REGULAR = BIT(8), 442 IWL_MVM_SCAN_STOPPING_SCHED = BIT(9), 443 IWL_MVM_SCAN_STOPPING_NETDETECT = BIT(10), 444 445 IWL_MVM_SCAN_REGULAR_MASK = IWL_MVM_SCAN_REGULAR | 446 IWL_MVM_SCAN_STOPPING_REGULAR, 447 IWL_MVM_SCAN_SCHED_MASK = IWL_MVM_SCAN_SCHED | 448 IWL_MVM_SCAN_STOPPING_SCHED, 449 IWL_MVM_SCAN_NETDETECT_MASK = IWL_MVM_SCAN_NETDETECT | 450 IWL_MVM_SCAN_STOPPING_NETDETECT, 451 452 IWL_MVM_SCAN_STOPPING_MASK = 0xff << IWL_MVM_SCAN_STOPPING_SHIFT, 453 IWL_MVM_SCAN_MASK = 0xff, 454 }; 455 456 enum iwl_mvm_scan_type { 457 IWL_SCAN_TYPE_NOT_SET, 458 IWL_SCAN_TYPE_UNASSOC, 459 IWL_SCAN_TYPE_WILD, 460 IWL_SCAN_TYPE_MILD, 461 IWL_SCAN_TYPE_FRAGMENTED, 462 IWL_SCAN_TYPE_FAST_BALANCE, 463 }; 464 465 enum iwl_mvm_sched_scan_pass_all_states { 466 SCHED_SCAN_PASS_ALL_DISABLED, 467 SCHED_SCAN_PASS_ALL_ENABLED, 468 SCHED_SCAN_PASS_ALL_FOUND, 469 }; 470 471 /** 472 * struct iwl_mvm_tt_mgnt - Thermal Throttling Management structure 473 * @ct_kill_exit: worker to exit thermal kill 474 * @dynamic_smps: Is thermal throttling enabled dynamic_smps? 475 * @tx_backoff: The current thremal throttling tx backoff in uSec. 476 * @min_backoff: The minimal tx backoff due to power restrictions 477 * @params: Parameters to configure the thermal throttling algorithm. 478 * @throttle: Is thermal throttling is active? 479 */ 480 struct iwl_mvm_tt_mgmt { 481 struct delayed_work ct_kill_exit; 482 bool dynamic_smps; 483 u32 tx_backoff; 484 u32 min_backoff; 485 struct iwl_tt_params params; 486 bool throttle; 487 }; 488 489 #ifdef CONFIG_THERMAL 490 /** 491 *struct iwl_mvm_thermal_device - thermal zone related data 492 * @temp_trips: temperature thresholds for report 493 * @fw_trips_index: keep indexes to original array - temp_trips 494 * @tzone: thermal zone device data 495 */ 496 struct iwl_mvm_thermal_device { 497 s16 temp_trips[IWL_MAX_DTS_TRIPS]; 498 u8 fw_trips_index[IWL_MAX_DTS_TRIPS]; 499 struct thermal_zone_device *tzone; 500 }; 501 502 /* 503 * struct iwl_mvm_cooling_device 504 * @cur_state: current state 505 * @cdev: struct thermal cooling device 506 */ 507 struct iwl_mvm_cooling_device { 508 u32 cur_state; 509 struct thermal_cooling_device *cdev; 510 }; 511 #endif 512 513 #define IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES 8 514 515 struct iwl_mvm_frame_stats { 516 u32 legacy_frames; 517 u32 ht_frames; 518 u32 vht_frames; 519 u32 bw_20_frames; 520 u32 bw_40_frames; 521 u32 bw_80_frames; 522 u32 bw_160_frames; 523 u32 sgi_frames; 524 u32 ngi_frames; 525 u32 siso_frames; 526 u32 mimo2_frames; 527 u32 agg_frames; 528 u32 ampdu_count; 529 u32 success_frames; 530 u32 fail_frames; 531 u32 last_rates[IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES]; 532 int last_frame_idx; 533 }; 534 535 #define IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE 0xff 536 #define IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -100 537 #define IWL_MVM_DEBUG_SET_TEMPERATURE_MAX 200 538 539 enum iwl_mvm_tdls_cs_state { 540 IWL_MVM_TDLS_SW_IDLE = 0, 541 IWL_MVM_TDLS_SW_REQ_SENT, 542 IWL_MVM_TDLS_SW_RESP_RCVD, 543 IWL_MVM_TDLS_SW_REQ_RCVD, 544 IWL_MVM_TDLS_SW_ACTIVE, 545 }; 546 547 enum iwl_mvm_traffic_load { 548 IWL_MVM_TRAFFIC_LOW, 549 IWL_MVM_TRAFFIC_MEDIUM, 550 IWL_MVM_TRAFFIC_HIGH, 551 }; 552 553 DECLARE_EWMA(rate, 16, 16) 554 555 struct iwl_mvm_tcm_mac { 556 struct { 557 u32 pkts[IEEE80211_NUM_ACS]; 558 u32 airtime; 559 } tx; 560 struct { 561 u32 pkts[IEEE80211_NUM_ACS]; 562 u32 airtime; 563 u32 last_ampdu_ref; 564 } rx; 565 struct { 566 /* track AP's transfer in client mode */ 567 u64 rx_bytes; 568 struct ewma_rate rate; 569 bool detected; 570 } uapsd_nonagg_detect; 571 bool opened_rx_ba_sessions; 572 }; 573 574 struct iwl_mvm_tcm { 575 struct delayed_work work; 576 spinlock_t lock; /* used when time elapsed */ 577 unsigned long ts; /* timestamp when period ends */ 578 unsigned long ll_ts; 579 unsigned long uapsd_nonagg_ts; 580 bool paused; 581 struct iwl_mvm_tcm_mac data[NUM_MAC_INDEX_DRIVER]; 582 struct { 583 u32 elapsed; /* milliseconds for this TCM period */ 584 u32 airtime[NUM_MAC_INDEX_DRIVER]; 585 enum iwl_mvm_traffic_load load[NUM_MAC_INDEX_DRIVER]; 586 enum iwl_mvm_traffic_load band_load[NUM_NL80211_BANDS]; 587 enum iwl_mvm_traffic_load global_load; 588 bool low_latency[NUM_MAC_INDEX_DRIVER]; 589 bool change[NUM_MAC_INDEX_DRIVER]; 590 bool global_change; 591 } result; 592 }; 593 594 /** 595 * struct iwl_mvm_reorder_buffer - per ra/tid/queue reorder buffer 596 * @head_sn: reorder window head sn 597 * @num_stored: number of mpdus stored in the buffer 598 * @buf_size: the reorder buffer size as set by the last addba request 599 * @queue: queue of this reorder buffer 600 * @last_amsdu: track last ASMDU SN for duplication detection 601 * @last_sub_index: track ASMDU sub frame index for duplication detection 602 * @reorder_timer: timer for frames are in the reorder buffer. For AMSDU 603 * it is the time of last received sub-frame 604 * @removed: prevent timer re-arming 605 * @valid: reordering is valid for this queue 606 * @lock: protect reorder buffer internal state 607 * @mvm: mvm pointer, needed for frame timer context 608 * @consec_oldsn_drops: consecutive drops due to old SN 609 * @consec_oldsn_ampdu_gp2: A-MPDU GP2 timestamp to track 610 * when to apply old SN consecutive drop workaround 611 * @consec_oldsn_prev_drop: track whether or not an MPDU 612 * that was single/part of the previous A-MPDU was 613 * dropped due to old SN 614 */ 615 struct iwl_mvm_reorder_buffer { 616 u16 head_sn; 617 u16 num_stored; 618 u16 buf_size; 619 int queue; 620 u16 last_amsdu; 621 u8 last_sub_index; 622 struct timer_list reorder_timer; 623 bool removed; 624 bool valid; 625 spinlock_t lock; 626 struct iwl_mvm *mvm; 627 unsigned int consec_oldsn_drops; 628 u32 consec_oldsn_ampdu_gp2; 629 unsigned int consec_oldsn_prev_drop:1; 630 } ____cacheline_aligned_in_smp; 631 632 /** 633 * struct _iwl_mvm_reorder_buf_entry - reorder buffer entry per-queue/per-seqno 634 * @frames: list of skbs stored 635 * @reorder_time: time the packet was stored in the reorder buffer 636 */ 637 struct _iwl_mvm_reorder_buf_entry { 638 struct sk_buff_head frames; 639 unsigned long reorder_time; 640 }; 641 642 /* make this indirection to get the aligned thing */ 643 struct iwl_mvm_reorder_buf_entry { 644 struct _iwl_mvm_reorder_buf_entry e; 645 } 646 #ifndef __CHECKER__ 647 /* sparse doesn't like this construct: "bad integer constant expression" */ 648 __aligned(roundup_pow_of_two(sizeof(struct _iwl_mvm_reorder_buf_entry))) 649 #endif 650 ; 651 652 /** 653 * struct iwl_mvm_baid_data - BA session data 654 * @sta_id: station id 655 * @tid: tid of the session 656 * @baid baid of the session 657 * @timeout: the timeout set in the addba request 658 * @entries_per_queue: # of buffers per queue, this actually gets 659 * aligned up to avoid cache line sharing between queues 660 * @last_rx: last rx jiffies, updated only if timeout passed from last update 661 * @session_timer: timer to check if BA session expired, runs at 2 * timeout 662 * @mvm: mvm pointer, needed for timer context 663 * @reorder_buf: reorder buffer, allocated per queue 664 * @reorder_buf_data: data 665 */ 666 struct iwl_mvm_baid_data { 667 struct rcu_head rcu_head; 668 u8 sta_id; 669 u8 tid; 670 u8 baid; 671 u16 timeout; 672 u16 entries_per_queue; 673 unsigned long last_rx; 674 struct timer_list session_timer; 675 struct iwl_mvm_baid_data __rcu **rcu_ptr; 676 struct iwl_mvm *mvm; 677 struct iwl_mvm_reorder_buffer reorder_buf[IWL_MAX_RX_HW_QUEUES]; 678 struct iwl_mvm_reorder_buf_entry entries[]; 679 }; 680 681 static inline struct iwl_mvm_baid_data * 682 iwl_mvm_baid_data_from_reorder_buf(struct iwl_mvm_reorder_buffer *buf) 683 { 684 return (void *)((u8 *)buf - 685 offsetof(struct iwl_mvm_baid_data, reorder_buf) - 686 sizeof(*buf) * buf->queue); 687 } 688 689 /* 690 * enum iwl_mvm_queue_status - queue status 691 * @IWL_MVM_QUEUE_FREE: the queue is not allocated nor reserved 692 * Basically, this means that this queue can be used for any purpose 693 * @IWL_MVM_QUEUE_RESERVED: queue is reserved but not yet in use 694 * This is the state of a queue that has been dedicated for some RATID 695 * (agg'd or not), but that hasn't yet gone through the actual enablement 696 * of iwl_mvm_enable_txq(), and therefore no traffic can go through it yet. 697 * Note that in this state there is no requirement to already know what TID 698 * should be used with this queue, it is just marked as a queue that will 699 * be used, and shouldn't be allocated to anyone else. 700 * @IWL_MVM_QUEUE_READY: queue is ready to be used 701 * This is the state of a queue that has been fully configured (including 702 * SCD pointers, etc), has a specific RA/TID assigned to it, and can be 703 * used to send traffic. 704 * @IWL_MVM_QUEUE_SHARED: queue is shared, or in a process of becoming shared 705 * This is a state in which a single queue serves more than one TID, all of 706 * which are not aggregated. Note that the queue is only associated to one 707 * RA. 708 */ 709 enum iwl_mvm_queue_status { 710 IWL_MVM_QUEUE_FREE, 711 IWL_MVM_QUEUE_RESERVED, 712 IWL_MVM_QUEUE_READY, 713 IWL_MVM_QUEUE_SHARED, 714 }; 715 716 #define IWL_MVM_DQA_QUEUE_TIMEOUT (5 * HZ) 717 #define IWL_MVM_INVALID_QUEUE 0xFFFF 718 719 #define IWL_MVM_NUM_CIPHERS 10 720 721 722 struct iwl_mvm_txq { 723 struct list_head list; 724 u16 txq_id; 725 atomic_t tx_request; 726 bool stopped; 727 }; 728 729 static inline struct iwl_mvm_txq * 730 iwl_mvm_txq_from_mac80211(struct ieee80211_txq *txq) 731 { 732 return (void *)txq->drv_priv; 733 } 734 735 static inline struct iwl_mvm_txq * 736 iwl_mvm_txq_from_tid(struct ieee80211_sta *sta, u8 tid) 737 { 738 if (tid == IWL_MAX_TID_COUNT) 739 tid = IEEE80211_NUM_TIDS; 740 741 return (void *)sta->txq[tid]->drv_priv; 742 } 743 744 /** 745 * struct iwl_mvm_tvqm_txq_info - maps TVQM hw queue to tid 746 * 747 * @sta_id: sta id 748 * @txq_tid: txq tid 749 */ 750 struct iwl_mvm_tvqm_txq_info { 751 u8 sta_id; 752 u8 txq_tid; 753 }; 754 755 struct iwl_mvm_dqa_txq_info { 756 u8 ra_sta_id; /* The RA this queue is mapped to, if exists */ 757 bool reserved; /* Is this the TXQ reserved for a STA */ 758 u8 mac80211_ac; /* The mac80211 AC this queue is mapped to */ 759 u8 txq_tid; /* The TID "owner" of this queue*/ 760 u16 tid_bitmap; /* Bitmap of the TIDs mapped to this queue */ 761 /* Timestamp for inactivation per TID of this queue */ 762 unsigned long last_frame_time[IWL_MAX_TID_COUNT + 1]; 763 enum iwl_mvm_queue_status status; 764 }; 765 766 struct iwl_mvm { 767 /* for logger access */ 768 struct device *dev; 769 770 struct iwl_trans *trans; 771 const struct iwl_fw *fw; 772 const struct iwl_cfg *cfg; 773 struct iwl_phy_db *phy_db; 774 struct ieee80211_hw *hw; 775 776 /* for protecting access to iwl_mvm */ 777 struct mutex mutex; 778 struct list_head async_handlers_list; 779 spinlock_t async_handlers_lock; 780 struct work_struct async_handlers_wk; 781 782 struct work_struct roc_done_wk; 783 784 unsigned long init_status; 785 786 unsigned long status; 787 788 u32 queue_sync_cookie; 789 unsigned long queue_sync_state; 790 /* 791 * for beacon filtering - 792 * currently only one interface can be supported 793 */ 794 struct iwl_mvm_vif *bf_allowed_vif; 795 796 bool hw_registered; 797 bool rfkill_safe_init_done; 798 799 u32 ampdu_ref; 800 bool ampdu_toggle; 801 802 struct iwl_notif_wait_data notif_wait; 803 804 union { 805 struct mvm_statistics_rx_v3 rx_stats_v3; 806 struct mvm_statistics_rx rx_stats; 807 }; 808 809 struct { 810 u64 rx_time; 811 u64 tx_time; 812 u64 on_time_rf; 813 u64 on_time_scan; 814 } radio_stats, accu_radio_stats; 815 816 struct list_head add_stream_txqs; 817 union { 818 struct iwl_mvm_dqa_txq_info queue_info[IWL_MAX_HW_QUEUES]; 819 struct iwl_mvm_tvqm_txq_info tvqm_info[IWL_MAX_TVQM_QUEUES]; 820 }; 821 struct work_struct add_stream_wk; /* To add streams to queues */ 822 823 const char *nvm_file_name; 824 struct iwl_nvm_data *nvm_data; 825 /* NVM sections */ 826 struct iwl_nvm_section nvm_sections[NVM_MAX_NUM_SECTIONS]; 827 828 struct iwl_fw_runtime fwrt; 829 830 /* EEPROM MAC addresses */ 831 struct mac_address addresses[IWL_MVM_MAX_ADDRESSES]; 832 833 /* data related to data path */ 834 struct iwl_rx_phy_info last_phy_info; 835 struct ieee80211_sta __rcu *fw_id_to_mac_id[IWL_MVM_STATION_COUNT_MAX]; 836 u8 rx_ba_sessions; 837 838 /* configured by mac80211 */ 839 u32 rts_threshold; 840 841 /* Scan status, cmd (pre-allocated) and auxiliary station */ 842 unsigned int scan_status; 843 void *scan_cmd; 844 struct iwl_mcast_filter_cmd *mcast_filter_cmd; 845 /* For CDB this is low band scan type, for non-CDB - type. */ 846 enum iwl_mvm_scan_type scan_type; 847 enum iwl_mvm_scan_type hb_scan_type; 848 849 enum iwl_mvm_sched_scan_pass_all_states sched_scan_pass_all; 850 struct delayed_work scan_timeout_dwork; 851 852 /* max number of simultaneous scans the FW supports */ 853 unsigned int max_scans; 854 855 /* UMAC scan tracking */ 856 u32 scan_uid_status[IWL_MVM_MAX_UMAC_SCANS]; 857 858 /* start time of last scan in TSF of the mac that requested the scan */ 859 u64 scan_start; 860 861 /* the vif that requested the current scan */ 862 struct iwl_mvm_vif *scan_vif; 863 864 /* rx chain antennas set through debugfs for the scan command */ 865 u8 scan_rx_ant; 866 867 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING 868 /* broadcast filters to configure for each associated station */ 869 const struct iwl_fw_bcast_filter *bcast_filters; 870 #ifdef CONFIG_IWLWIFI_DEBUGFS 871 struct { 872 bool override; 873 struct iwl_bcast_filter_cmd cmd; 874 } dbgfs_bcast_filtering; 875 #endif 876 #endif 877 878 /* Internal station */ 879 struct iwl_mvm_int_sta aux_sta; 880 struct iwl_mvm_int_sta snif_sta; 881 882 bool last_ebs_successful; 883 884 u8 scan_last_antenna_idx; /* to toggle TX between antennas */ 885 u8 mgmt_last_antenna_idx; 886 887 /* last smart fifo state that was successfully sent to firmware */ 888 enum iwl_sf_state sf_state; 889 890 #ifdef CONFIG_IWLWIFI_DEBUGFS 891 struct dentry *debugfs_dir; 892 u32 dbgfs_sram_offset, dbgfs_sram_len; 893 u32 dbgfs_prph_reg_addr; 894 bool disable_power_off; 895 bool disable_power_off_d3; 896 bool beacon_inject_active; 897 898 bool scan_iter_notif_enabled; 899 900 struct debugfs_blob_wrapper nvm_hw_blob; 901 struct debugfs_blob_wrapper nvm_sw_blob; 902 struct debugfs_blob_wrapper nvm_calib_blob; 903 struct debugfs_blob_wrapper nvm_prod_blob; 904 struct debugfs_blob_wrapper nvm_phy_sku_blob; 905 struct debugfs_blob_wrapper nvm_reg_blob; 906 907 struct iwl_mvm_frame_stats drv_rx_stats; 908 spinlock_t drv_stats_lock; 909 u16 dbgfs_rx_phyinfo; 910 #endif 911 912 struct iwl_mvm_phy_ctxt phy_ctxts[NUM_PHY_CTX]; 913 914 struct list_head time_event_list; 915 spinlock_t time_event_lock; 916 917 /* 918 * A bitmap indicating the index of the key in use. The firmware 919 * can hold 16 keys at most. Reflect this fact. 920 */ 921 unsigned long fw_key_table[BITS_TO_LONGS(STA_KEY_MAX_NUM)]; 922 u8 fw_key_deleted[STA_KEY_MAX_NUM]; 923 924 u8 vif_count; 925 struct ieee80211_vif __rcu *vif_id_to_mac[NUM_MAC_INDEX_DRIVER]; 926 927 /* -1 for always, 0 for never, >0 for that many times */ 928 s8 fw_restart; 929 u8 *error_recovery_buf; 930 931 #ifdef CONFIG_IWLWIFI_LEDS 932 struct led_classdev led; 933 #endif 934 935 struct ieee80211_vif *p2p_device_vif; 936 937 #ifdef CONFIG_PM 938 struct wiphy_wowlan_support wowlan; 939 int gtk_ivlen, gtk_icvlen, ptk_ivlen, ptk_icvlen; 940 941 /* sched scan settings for net detect */ 942 struct ieee80211_scan_ies nd_ies; 943 struct cfg80211_match_set *nd_match_sets; 944 int n_nd_match_sets; 945 struct ieee80211_channel **nd_channels; 946 int n_nd_channels; 947 bool net_detect; 948 u8 offload_tid; 949 #ifdef CONFIG_IWLWIFI_DEBUGFS 950 bool d3_wake_sysassert; 951 bool d3_test_active; 952 u32 d3_test_pme_ptr; 953 struct ieee80211_vif *keep_vif; 954 u32 last_netdetect_scans; /* no. of scans in the last net-detect wake */ 955 #endif 956 #endif 957 958 wait_queue_head_t rx_sync_waitq; 959 960 /* BT-Coex */ 961 struct iwl_bt_coex_profile_notif last_bt_notif; 962 struct iwl_bt_coex_ci_cmd last_bt_ci_cmd; 963 964 u8 bt_tx_prio; 965 enum iwl_bt_force_ant_mode bt_force_ant_mode; 966 967 /* Aux ROC */ 968 struct list_head aux_roc_te_list; 969 970 /* Thermal Throttling and CTkill */ 971 struct iwl_mvm_tt_mgmt thermal_throttle; 972 #ifdef CONFIG_THERMAL 973 struct iwl_mvm_thermal_device tz_device; 974 struct iwl_mvm_cooling_device cooling_dev; 975 #endif 976 977 s32 temperature; /* Celsius */ 978 /* 979 * Debug option to set the NIC temperature. This option makes the 980 * driver think this is the actual NIC temperature, and ignore the 981 * real temperature that is received from the fw 982 */ 983 bool temperature_test; /* Debug test temperature is enabled */ 984 985 unsigned long bt_coex_last_tcm_ts; 986 struct iwl_mvm_tcm tcm; 987 988 u8 uapsd_noagg_bssid_write_idx; 989 struct mac_address uapsd_noagg_bssids[IWL_MVM_UAPSD_NOAGG_BSSIDS_NUM] 990 __aligned(2); 991 992 struct iwl_time_quota_cmd last_quota_cmd; 993 994 #ifdef CONFIG_NL80211_TESTMODE 995 u32 noa_duration; 996 struct ieee80211_vif *noa_vif; 997 #endif 998 999 /* Tx queues */ 1000 u16 aux_queue; 1001 u16 snif_queue; 1002 u16 probe_queue; 1003 u16 p2p_dev_queue; 1004 1005 /* Indicate if device power save is allowed */ 1006 u8 ps_disabled; /* u8 instead of bool to ease debugfs_create_* usage */ 1007 /* Indicate if 32Khz external clock is valid */ 1008 u32 ext_clock_valid; 1009 1010 struct ieee80211_vif __rcu *csa_vif; 1011 struct ieee80211_vif __rcu *csa_tx_blocked_vif; 1012 u8 csa_tx_block_bcn_timeout; 1013 1014 /* system time of last beacon (for AP/GO interface) */ 1015 u32 ap_last_beacon_gp2; 1016 1017 /* indicates that we transmitted the last beacon */ 1018 bool ibss_manager; 1019 1020 bool lar_regdom_set; 1021 enum iwl_mcc_source mcc_src; 1022 1023 /* TDLS channel switch data */ 1024 struct { 1025 struct delayed_work dwork; 1026 enum iwl_mvm_tdls_cs_state state; 1027 1028 /* 1029 * Current cs sta - might be different from periodic cs peer 1030 * station. Value is meaningless when the cs-state is idle. 1031 */ 1032 u8 cur_sta_id; 1033 1034 /* TDLS periodic channel-switch peer */ 1035 struct { 1036 u8 sta_id; 1037 u8 op_class; 1038 bool initiator; /* are we the link initiator */ 1039 struct cfg80211_chan_def chandef; 1040 struct sk_buff *skb; /* ch sw template */ 1041 u32 ch_sw_tm_ie; 1042 1043 /* timestamp of last ch-sw request sent (GP2 time) */ 1044 u32 sent_timestamp; 1045 } peer; 1046 } tdls_cs; 1047 1048 1049 u32 ciphers[IWL_MVM_NUM_CIPHERS]; 1050 struct ieee80211_cipher_scheme cs[IWL_UCODE_MAX_CS]; 1051 1052 struct cfg80211_ftm_responder_stats ftm_resp_stats; 1053 struct { 1054 struct cfg80211_pmsr_request *req; 1055 struct wireless_dev *req_wdev; 1056 struct list_head loc_list; 1057 int responses[IWL_MVM_TOF_MAX_APS]; 1058 struct { 1059 struct list_head resp; 1060 } smooth; 1061 struct list_head pasn_list; 1062 } ftm_initiator; 1063 1064 struct list_head resp_pasn_list; 1065 1066 struct { 1067 u8 d0i3_resp; 1068 u8 range_resp; 1069 } cmd_ver; 1070 1071 struct ieee80211_vif *nan_vif; 1072 #define IWL_MAX_BAID 32 1073 struct iwl_mvm_baid_data __rcu *baid_map[IWL_MAX_BAID]; 1074 1075 /* 1076 * Drop beacons from other APs in AP mode when there are no connected 1077 * clients. 1078 */ 1079 bool drop_bcn_ap_mode; 1080 1081 struct delayed_work cs_tx_unblock_dwork; 1082 1083 /* does a monitor vif exist (only one can exist hence bool) */ 1084 bool monitor_on; 1085 1086 /* sniffer data to include in radiotap */ 1087 __le16 cur_aid; 1088 u8 cur_bssid[ETH_ALEN]; 1089 }; 1090 1091 /* Extract MVM priv from op_mode and _hw */ 1092 #define IWL_OP_MODE_GET_MVM(_iwl_op_mode) \ 1093 ((struct iwl_mvm *)(_iwl_op_mode)->op_mode_specific) 1094 1095 #define IWL_MAC80211_GET_MVM(_hw) \ 1096 IWL_OP_MODE_GET_MVM((struct iwl_op_mode *)((_hw)->priv)) 1097 1098 /** 1099 * enum iwl_mvm_status - MVM status bits 1100 * @IWL_MVM_STATUS_HW_RFKILL: HW RF-kill is asserted 1101 * @IWL_MVM_STATUS_HW_CTKILL: CT-kill is active 1102 * @IWL_MVM_STATUS_ROC_RUNNING: remain-on-channel is running 1103 * @IWL_MVM_STATUS_HW_RESTART_REQUESTED: HW restart was requested 1104 * @IWL_MVM_STATUS_IN_HW_RESTART: HW restart is active 1105 * @IWL_MVM_STATUS_ROC_AUX_RUNNING: AUX remain-on-channel is running 1106 * @IWL_MVM_STATUS_FIRMWARE_RUNNING: firmware is running 1107 * @IWL_MVM_STATUS_NEED_FLUSH_P2P: need to flush P2P bcast STA 1108 * @IWL_MVM_STATUS_IN_D3: in D3 (or at least about to go into it) 1109 */ 1110 enum iwl_mvm_status { 1111 IWL_MVM_STATUS_HW_RFKILL, 1112 IWL_MVM_STATUS_HW_CTKILL, 1113 IWL_MVM_STATUS_ROC_RUNNING, 1114 IWL_MVM_STATUS_HW_RESTART_REQUESTED, 1115 IWL_MVM_STATUS_IN_HW_RESTART, 1116 IWL_MVM_STATUS_ROC_AUX_RUNNING, 1117 IWL_MVM_STATUS_FIRMWARE_RUNNING, 1118 IWL_MVM_STATUS_NEED_FLUSH_P2P, 1119 IWL_MVM_STATUS_IN_D3, 1120 }; 1121 1122 /* Keep track of completed init configuration */ 1123 enum iwl_mvm_init_status { 1124 IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE = BIT(0), 1125 IWL_MVM_INIT_STATUS_LEDS_INIT_COMPLETE = BIT(1), 1126 }; 1127 1128 static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm) 1129 { 1130 return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status) || 1131 test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status); 1132 } 1133 1134 static inline bool iwl_mvm_is_radio_hw_killed(struct iwl_mvm *mvm) 1135 { 1136 return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status); 1137 } 1138 1139 static inline bool iwl_mvm_firmware_running(struct iwl_mvm *mvm) 1140 { 1141 return test_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status); 1142 } 1143 1144 /* Must be called with rcu_read_lock() held and it can only be 1145 * released when mvmsta is not needed anymore. 1146 */ 1147 static inline struct iwl_mvm_sta * 1148 iwl_mvm_sta_from_staid_rcu(struct iwl_mvm *mvm, u8 sta_id) 1149 { 1150 struct ieee80211_sta *sta; 1151 1152 if (sta_id >= mvm->fw->ucode_capa.num_stations) 1153 return NULL; 1154 1155 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); 1156 1157 /* This can happen if the station has been removed right now */ 1158 if (IS_ERR_OR_NULL(sta)) 1159 return NULL; 1160 1161 return iwl_mvm_sta_from_mac80211(sta); 1162 } 1163 1164 static inline struct iwl_mvm_sta * 1165 iwl_mvm_sta_from_staid_protected(struct iwl_mvm *mvm, u8 sta_id) 1166 { 1167 struct ieee80211_sta *sta; 1168 1169 if (sta_id >= mvm->fw->ucode_capa.num_stations) 1170 return NULL; 1171 1172 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id], 1173 lockdep_is_held(&mvm->mutex)); 1174 1175 /* This can happen if the station has been removed right now */ 1176 if (IS_ERR_OR_NULL(sta)) 1177 return NULL; 1178 1179 return iwl_mvm_sta_from_mac80211(sta); 1180 } 1181 1182 static inline struct ieee80211_vif * 1183 iwl_mvm_rcu_dereference_vif_id(struct iwl_mvm *mvm, u8 vif_id, bool rcu) 1184 { 1185 if (WARN_ON(vif_id >= ARRAY_SIZE(mvm->vif_id_to_mac))) 1186 return NULL; 1187 1188 if (rcu) 1189 return rcu_dereference(mvm->vif_id_to_mac[vif_id]); 1190 1191 return rcu_dereference_protected(mvm->vif_id_to_mac[vif_id], 1192 lockdep_is_held(&mvm->mutex)); 1193 } 1194 1195 static inline bool iwl_mvm_is_adaptive_dwell_supported(struct iwl_mvm *mvm) 1196 { 1197 return fw_has_api(&mvm->fw->ucode_capa, 1198 IWL_UCODE_TLV_API_ADAPTIVE_DWELL); 1199 } 1200 1201 static inline bool iwl_mvm_is_adaptive_dwell_v2_supported(struct iwl_mvm *mvm) 1202 { 1203 return fw_has_api(&mvm->fw->ucode_capa, 1204 IWL_UCODE_TLV_API_ADAPTIVE_DWELL_V2); 1205 } 1206 1207 static inline bool iwl_mvm_is_adwell_hb_ap_num_supported(struct iwl_mvm *mvm) 1208 { 1209 return fw_has_api(&mvm->fw->ucode_capa, 1210 IWL_UCODE_TLV_API_ADWELL_HB_DEF_N_AP); 1211 } 1212 1213 static inline bool iwl_mvm_is_oce_supported(struct iwl_mvm *mvm) 1214 { 1215 /* OCE should never be enabled for LMAC scan FWs */ 1216 return fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_OCE); 1217 } 1218 1219 static inline bool iwl_mvm_is_frag_ebs_supported(struct iwl_mvm *mvm) 1220 { 1221 return fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_FRAG_EBS); 1222 } 1223 1224 static inline bool iwl_mvm_is_short_beacon_notif_supported(struct iwl_mvm *mvm) 1225 { 1226 return fw_has_api(&mvm->fw->ucode_capa, 1227 IWL_UCODE_TLV_API_SHORT_BEACON_NOTIF); 1228 } 1229 1230 static inline bool iwl_mvm_is_dqa_data_queue(struct iwl_mvm *mvm, u8 queue) 1231 { 1232 return (queue >= IWL_MVM_DQA_MIN_DATA_QUEUE) && 1233 (queue <= IWL_MVM_DQA_MAX_DATA_QUEUE); 1234 } 1235 1236 static inline bool iwl_mvm_is_dqa_mgmt_queue(struct iwl_mvm *mvm, u8 queue) 1237 { 1238 return (queue >= IWL_MVM_DQA_MIN_MGMT_QUEUE) && 1239 (queue <= IWL_MVM_DQA_MAX_MGMT_QUEUE); 1240 } 1241 1242 static inline bool iwl_mvm_is_lar_supported(struct iwl_mvm *mvm) 1243 { 1244 bool nvm_lar = mvm->nvm_data->lar_enabled; 1245 bool tlv_lar = fw_has_capa(&mvm->fw->ucode_capa, 1246 IWL_UCODE_TLV_CAPA_LAR_SUPPORT); 1247 1248 /* 1249 * Enable LAR only if it is supported by the FW (TLV) && 1250 * enabled in the NVM 1251 */ 1252 if (mvm->cfg->nvm_type == IWL_NVM_EXT) 1253 return nvm_lar && tlv_lar; 1254 else 1255 return tlv_lar; 1256 } 1257 1258 static inline bool iwl_mvm_is_wifi_mcc_supported(struct iwl_mvm *mvm) 1259 { 1260 return fw_has_api(&mvm->fw->ucode_capa, 1261 IWL_UCODE_TLV_API_WIFI_MCC_UPDATE) || 1262 fw_has_capa(&mvm->fw->ucode_capa, 1263 IWL_UCODE_TLV_CAPA_LAR_MULTI_MCC); 1264 } 1265 1266 static inline bool iwl_mvm_bt_is_rrc_supported(struct iwl_mvm *mvm) 1267 { 1268 return fw_has_capa(&mvm->fw->ucode_capa, 1269 IWL_UCODE_TLV_CAPA_BT_COEX_RRC) && 1270 IWL_MVM_BT_COEX_RRC; 1271 } 1272 1273 static inline bool iwl_mvm_is_csum_supported(struct iwl_mvm *mvm) 1274 { 1275 return fw_has_capa(&mvm->fw->ucode_capa, 1276 IWL_UCODE_TLV_CAPA_CSUM_SUPPORT) && 1277 !IWL_MVM_HW_CSUM_DISABLE; 1278 } 1279 1280 static inline bool iwl_mvm_is_mplut_supported(struct iwl_mvm *mvm) 1281 { 1282 return fw_has_capa(&mvm->fw->ucode_capa, 1283 IWL_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT) && 1284 IWL_MVM_BT_COEX_MPLUT; 1285 } 1286 1287 static inline 1288 bool iwl_mvm_is_p2p_scm_uapsd_supported(struct iwl_mvm *mvm) 1289 { 1290 return fw_has_capa(&mvm->fw->ucode_capa, 1291 IWL_UCODE_TLV_CAPA_P2P_SCM_UAPSD) && 1292 !(iwlwifi_mod_params.uapsd_disable & 1293 IWL_DISABLE_UAPSD_P2P_CLIENT); 1294 } 1295 1296 static inline bool iwl_mvm_has_new_rx_api(struct iwl_mvm *mvm) 1297 { 1298 return fw_has_capa(&mvm->fw->ucode_capa, 1299 IWL_UCODE_TLV_CAPA_MULTI_QUEUE_RX_SUPPORT); 1300 } 1301 1302 static inline bool iwl_mvm_has_new_tx_api(struct iwl_mvm *mvm) 1303 { 1304 /* TODO - replace with TLV once defined */ 1305 return mvm->trans->trans_cfg->use_tfh; 1306 } 1307 1308 static inline bool iwl_mvm_has_unified_ucode(struct iwl_mvm *mvm) 1309 { 1310 /* TODO - better define this */ 1311 return mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_22000; 1312 } 1313 1314 static inline bool iwl_mvm_is_cdb_supported(struct iwl_mvm *mvm) 1315 { 1316 /* 1317 * TODO: 1318 * The issue of how to determine CDB APIs and usage is still not fully 1319 * defined. 1320 * There is a compilation for CDB and non-CDB FW, but there may 1321 * be also runtime check. 1322 * For now there is a TLV for checking compilation mode, but a 1323 * runtime check will also have to be here - once defined. 1324 */ 1325 return fw_has_capa(&mvm->fw->ucode_capa, 1326 IWL_UCODE_TLV_CAPA_CDB_SUPPORT); 1327 } 1328 1329 static inline bool iwl_mvm_cdb_scan_api(struct iwl_mvm *mvm) 1330 { 1331 /* 1332 * TODO: should this be the same as iwl_mvm_is_cdb_supported()? 1333 * but then there's a little bit of code in scan that won't make 1334 * any sense... 1335 */ 1336 return mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_22000; 1337 } 1338 1339 static inline bool iwl_mvm_is_scan_ext_chan_supported(struct iwl_mvm *mvm) 1340 { 1341 return fw_has_api(&mvm->fw->ucode_capa, 1342 IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER); 1343 } 1344 1345 1346 static inline bool iwl_mvm_is_reduced_config_scan_supported(struct iwl_mvm *mvm) 1347 { 1348 return fw_has_api(&mvm->fw->ucode_capa, 1349 IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG); 1350 } 1351 1352 static inline bool iwl_mvm_is_band_in_rx_supported(struct iwl_mvm *mvm) 1353 { 1354 return fw_has_api(&mvm->fw->ucode_capa, 1355 IWL_UCODE_TLV_API_BAND_IN_RX_DATA); 1356 } 1357 1358 static inline bool iwl_mvm_has_new_rx_stats_api(struct iwl_mvm *mvm) 1359 { 1360 return fw_has_api(&mvm->fw->ucode_capa, 1361 IWL_UCODE_TLV_API_NEW_RX_STATS); 1362 } 1363 1364 static inline bool iwl_mvm_has_quota_low_latency(struct iwl_mvm *mvm) 1365 { 1366 return fw_has_api(&mvm->fw->ucode_capa, 1367 IWL_UCODE_TLV_API_QUOTA_LOW_LATENCY); 1368 } 1369 1370 static inline bool iwl_mvm_has_tlc_offload(const struct iwl_mvm *mvm) 1371 { 1372 return fw_has_capa(&mvm->fw->ucode_capa, 1373 IWL_UCODE_TLV_CAPA_TLC_OFFLOAD); 1374 } 1375 1376 static inline struct agg_tx_status * 1377 iwl_mvm_get_agg_status(struct iwl_mvm *mvm, void *tx_resp) 1378 { 1379 if (iwl_mvm_has_new_tx_api(mvm)) 1380 return &((struct iwl_mvm_tx_resp *)tx_resp)->status; 1381 else 1382 return ((struct iwl_mvm_tx_resp_v3 *)tx_resp)->status; 1383 } 1384 1385 static inline bool iwl_mvm_is_tt_in_fw(struct iwl_mvm *mvm) 1386 { 1387 /* these two TLV are redundant since the responsibility to CT-kill by 1388 * FW happens only after we send at least one command of 1389 * temperature THs report. 1390 */ 1391 return fw_has_capa(&mvm->fw->ucode_capa, 1392 IWL_UCODE_TLV_CAPA_CT_KILL_BY_FW) && 1393 fw_has_capa(&mvm->fw->ucode_capa, 1394 IWL_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT); 1395 } 1396 1397 static inline bool iwl_mvm_is_ctdp_supported(struct iwl_mvm *mvm) 1398 { 1399 return fw_has_capa(&mvm->fw->ucode_capa, 1400 IWL_UCODE_TLV_CAPA_CTDP_SUPPORT); 1401 } 1402 1403 extern const u8 iwl_mvm_ac_to_tx_fifo[]; 1404 extern const u8 iwl_mvm_ac_to_gen2_tx_fifo[]; 1405 1406 static inline u8 iwl_mvm_mac_ac_to_tx_fifo(struct iwl_mvm *mvm, 1407 enum ieee80211_ac_numbers ac) 1408 { 1409 return iwl_mvm_has_new_tx_api(mvm) ? 1410 iwl_mvm_ac_to_gen2_tx_fifo[ac] : iwl_mvm_ac_to_tx_fifo[ac]; 1411 } 1412 1413 struct iwl_rate_info { 1414 u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */ 1415 u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */ 1416 u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */ 1417 u8 plcp_mimo3; /* uCode API: IWL_RATE_MIMO3_6M_PLCP, etc. */ 1418 u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */ 1419 }; 1420 1421 void __iwl_mvm_mac_stop(struct iwl_mvm *mvm); 1422 int __iwl_mvm_mac_start(struct iwl_mvm *mvm); 1423 1424 /****************** 1425 * MVM Methods 1426 ******************/ 1427 /* uCode */ 1428 int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm); 1429 1430 /* Utils */ 1431 int iwl_mvm_legacy_rate_to_mac80211_idx(u32 rate_n_flags, 1432 enum nl80211_band band); 1433 void iwl_mvm_hwrate_to_tx_rate(u32 rate_n_flags, 1434 enum nl80211_band band, 1435 struct ieee80211_tx_rate *r); 1436 u8 iwl_mvm_mac80211_idx_to_hwrate(int rate_idx); 1437 u8 iwl_mvm_mac80211_ac_to_ucode_ac(enum ieee80211_ac_numbers ac); 1438 void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm); 1439 u8 first_antenna(u8 mask); 1440 u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx); 1441 void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, u32 *gp2, u64 *boottime); 1442 u32 iwl_mvm_get_systime(struct iwl_mvm *mvm); 1443 1444 /* Tx / Host Commands */ 1445 int __must_check iwl_mvm_send_cmd(struct iwl_mvm *mvm, 1446 struct iwl_host_cmd *cmd); 1447 int __must_check iwl_mvm_send_cmd_pdu(struct iwl_mvm *mvm, u32 id, 1448 u32 flags, u16 len, const void *data); 1449 int __must_check iwl_mvm_send_cmd_status(struct iwl_mvm *mvm, 1450 struct iwl_host_cmd *cmd, 1451 u32 *status); 1452 int __must_check iwl_mvm_send_cmd_pdu_status(struct iwl_mvm *mvm, u32 id, 1453 u16 len, const void *data, 1454 u32 *status); 1455 int iwl_mvm_tx_skb_sta(struct iwl_mvm *mvm, struct sk_buff *skb, 1456 struct ieee80211_sta *sta); 1457 int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb); 1458 void iwl_mvm_set_tx_cmd(struct iwl_mvm *mvm, struct sk_buff *skb, 1459 struct iwl_tx_cmd *tx_cmd, 1460 struct ieee80211_tx_info *info, u8 sta_id); 1461 void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm, struct iwl_tx_cmd *tx_cmd, 1462 struct ieee80211_tx_info *info, 1463 struct ieee80211_sta *sta, __le16 fc); 1464 void iwl_mvm_mac_itxq_xmit(struct ieee80211_hw *hw, struct ieee80211_txq *txq); 1465 unsigned int iwl_mvm_max_amsdu_size(struct iwl_mvm *mvm, 1466 struct ieee80211_sta *sta, 1467 unsigned int tid); 1468 1469 #ifdef CONFIG_IWLWIFI_DEBUG 1470 const char *iwl_mvm_get_tx_fail_reason(u32 status); 1471 #else 1472 static inline const char *iwl_mvm_get_tx_fail_reason(u32 status) { return ""; } 1473 #endif 1474 int iwl_mvm_flush_tx_path(struct iwl_mvm *mvm, u32 tfd_msk, u32 flags); 1475 int iwl_mvm_flush_sta(struct iwl_mvm *mvm, void *sta, bool internal); 1476 int iwl_mvm_flush_sta_tids(struct iwl_mvm *mvm, u32 sta_id, 1477 u16 tids, u32 flags); 1478 1479 void iwl_mvm_async_handlers_purge(struct iwl_mvm *mvm); 1480 1481 static inline void iwl_mvm_set_tx_cmd_ccmp(struct ieee80211_tx_info *info, 1482 struct iwl_tx_cmd *tx_cmd) 1483 { 1484 struct ieee80211_key_conf *keyconf = info->control.hw_key; 1485 1486 tx_cmd->sec_ctl = TX_CMD_SEC_CCM; 1487 memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); 1488 } 1489 1490 static inline void iwl_mvm_wait_for_async_handlers(struct iwl_mvm *mvm) 1491 { 1492 flush_work(&mvm->async_handlers_wk); 1493 } 1494 1495 /* Statistics */ 1496 void iwl_mvm_handle_rx_statistics(struct iwl_mvm *mvm, 1497 struct iwl_rx_packet *pkt); 1498 void iwl_mvm_rx_statistics(struct iwl_mvm *mvm, 1499 struct iwl_rx_cmd_buffer *rxb); 1500 int iwl_mvm_request_statistics(struct iwl_mvm *mvm, bool clear); 1501 void iwl_mvm_accu_radio_stats(struct iwl_mvm *mvm); 1502 1503 /* NVM */ 1504 int iwl_nvm_init(struct iwl_mvm *mvm); 1505 int iwl_mvm_load_nvm_to_nic(struct iwl_mvm *mvm); 1506 1507 static inline u8 iwl_mvm_get_valid_tx_ant(struct iwl_mvm *mvm) 1508 { 1509 return mvm->nvm_data && mvm->nvm_data->valid_tx_ant ? 1510 mvm->fw->valid_tx_ant & mvm->nvm_data->valid_tx_ant : 1511 mvm->fw->valid_tx_ant; 1512 } 1513 1514 static inline u8 iwl_mvm_get_valid_rx_ant(struct iwl_mvm *mvm) 1515 { 1516 return mvm->nvm_data && mvm->nvm_data->valid_rx_ant ? 1517 mvm->fw->valid_rx_ant & mvm->nvm_data->valid_rx_ant : 1518 mvm->fw->valid_rx_ant; 1519 } 1520 1521 static inline void iwl_mvm_toggle_tx_ant(struct iwl_mvm *mvm, u8 *ant) 1522 { 1523 *ant = iwl_mvm_next_antenna(mvm, iwl_mvm_get_valid_tx_ant(mvm), *ant); 1524 } 1525 1526 static inline u32 iwl_mvm_get_phy_config(struct iwl_mvm *mvm) 1527 { 1528 u32 phy_config = ~(FW_PHY_CFG_TX_CHAIN | 1529 FW_PHY_CFG_RX_CHAIN); 1530 u32 valid_rx_ant = iwl_mvm_get_valid_rx_ant(mvm); 1531 u32 valid_tx_ant = iwl_mvm_get_valid_tx_ant(mvm); 1532 1533 phy_config |= valid_tx_ant << FW_PHY_CFG_TX_CHAIN_POS | 1534 valid_rx_ant << FW_PHY_CFG_RX_CHAIN_POS; 1535 1536 return mvm->fw->phy_config & phy_config; 1537 } 1538 1539 int iwl_mvm_up(struct iwl_mvm *mvm); 1540 int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm); 1541 1542 int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm); 1543 bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm *mvm, 1544 struct iwl_bcast_filter_cmd *cmd); 1545 1546 /* 1547 * FW notifications / CMD responses handlers 1548 * Convention: iwl_mvm_rx_<NAME OF THE CMD> 1549 */ 1550 void iwl_mvm_rx_rx_phy_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1551 void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi, 1552 struct iwl_rx_cmd_buffer *rxb); 1553 void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi, 1554 struct iwl_rx_cmd_buffer *rxb, int queue); 1555 void iwl_mvm_rx_monitor_no_data(struct iwl_mvm *mvm, struct napi_struct *napi, 1556 struct iwl_rx_cmd_buffer *rxb, int queue); 1557 void iwl_mvm_rx_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi, 1558 struct iwl_rx_cmd_buffer *rxb, int queue); 1559 void iwl_mvm_rx_bar_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi, 1560 struct iwl_rx_cmd_buffer *rxb, int queue); 1561 int iwl_mvm_notify_rx_queue(struct iwl_mvm *mvm, u32 rxq_mask, 1562 const struct iwl_mvm_internal_rxq_notif *notif, 1563 u32 notif_size, bool async); 1564 void iwl_mvm_rx_queue_notif(struct iwl_mvm *mvm, struct napi_struct *napi, 1565 struct iwl_rx_cmd_buffer *rxb, int queue); 1566 void iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1567 void iwl_mvm_mfu_assert_dump_notif(struct iwl_mvm *mvm, 1568 struct iwl_rx_cmd_buffer *rxb); 1569 void iwl_mvm_send_recovery_cmd(struct iwl_mvm *mvm, u32 flags); 1570 void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1571 void iwl_mvm_rx_ant_coupling_notif(struct iwl_mvm *mvm, 1572 struct iwl_rx_cmd_buffer *rxb); 1573 void iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1574 void iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm, 1575 struct iwl_rx_cmd_buffer *rxb); 1576 void iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm, 1577 struct iwl_rx_cmd_buffer *rxb); 1578 void iwl_mvm_rx_shared_mem_cfg_notif(struct iwl_mvm *mvm, 1579 struct iwl_rx_cmd_buffer *rxb); 1580 1581 /* MVM PHY */ 1582 int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt, 1583 struct cfg80211_chan_def *chandef, 1584 u8 chains_static, u8 chains_dynamic); 1585 int iwl_mvm_phy_ctxt_changed(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt, 1586 struct cfg80211_chan_def *chandef, 1587 u8 chains_static, u8 chains_dynamic); 1588 void iwl_mvm_phy_ctxt_ref(struct iwl_mvm *mvm, 1589 struct iwl_mvm_phy_ctxt *ctxt); 1590 void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm, 1591 struct iwl_mvm_phy_ctxt *ctxt); 1592 int iwl_mvm_phy_ctx_count(struct iwl_mvm *mvm); 1593 u8 iwl_mvm_get_channel_width(struct cfg80211_chan_def *chandef); 1594 u8 iwl_mvm_get_ctrl_pos(struct cfg80211_chan_def *chandef); 1595 1596 /* MAC (virtual interface) programming */ 1597 int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1598 int iwl_mvm_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1599 int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1600 bool force_assoc_off, const u8 *bssid_override); 1601 int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1602 int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm, 1603 struct ieee80211_vif *vif); 1604 int iwl_mvm_mac_ctxt_send_beacon(struct iwl_mvm *mvm, 1605 struct ieee80211_vif *vif, 1606 struct sk_buff *beacon); 1607 int iwl_mvm_mac_ctxt_send_beacon_cmd(struct iwl_mvm *mvm, 1608 struct sk_buff *beacon, 1609 void *data, int len); 1610 u8 iwl_mvm_mac_ctxt_get_lowest_rate(struct ieee80211_tx_info *info, 1611 struct ieee80211_vif *vif); 1612 void iwl_mvm_mac_ctxt_set_tim(struct iwl_mvm *mvm, 1613 __le32 *tim_index, __le32 *tim_size, 1614 u8 *beacon, u32 frame_size); 1615 void iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm, 1616 struct iwl_rx_cmd_buffer *rxb); 1617 void iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm, 1618 struct iwl_rx_cmd_buffer *rxb); 1619 void iwl_mvm_rx_stored_beacon_notif(struct iwl_mvm *mvm, 1620 struct iwl_rx_cmd_buffer *rxb); 1621 void iwl_mvm_mu_mimo_grp_notif(struct iwl_mvm *mvm, 1622 struct iwl_rx_cmd_buffer *rxb); 1623 void iwl_mvm_sta_pm_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1624 void iwl_mvm_window_status_notif(struct iwl_mvm *mvm, 1625 struct iwl_rx_cmd_buffer *rxb); 1626 void iwl_mvm_mac_ctxt_recalc_tsf_id(struct iwl_mvm *mvm, 1627 struct ieee80211_vif *vif); 1628 void iwl_mvm_probe_resp_data_notif(struct iwl_mvm *mvm, 1629 struct iwl_rx_cmd_buffer *rxb); 1630 void iwl_mvm_rx_missed_vap_notif(struct iwl_mvm *mvm, 1631 struct iwl_rx_cmd_buffer *rxb); 1632 void iwl_mvm_channel_switch_noa_notif(struct iwl_mvm *mvm, 1633 struct iwl_rx_cmd_buffer *rxb); 1634 /* Bindings */ 1635 int iwl_mvm_binding_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1636 int iwl_mvm_binding_remove_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1637 1638 /* Quota management */ 1639 static inline size_t iwl_mvm_quota_cmd_size(struct iwl_mvm *mvm) 1640 { 1641 return iwl_mvm_has_quota_low_latency(mvm) ? 1642 sizeof(struct iwl_time_quota_cmd) : 1643 sizeof(struct iwl_time_quota_cmd_v1); 1644 } 1645 1646 static inline struct iwl_time_quota_data 1647 *iwl_mvm_quota_cmd_get_quota(struct iwl_mvm *mvm, 1648 struct iwl_time_quota_cmd *cmd, 1649 int i) 1650 { 1651 struct iwl_time_quota_data_v1 *quotas; 1652 1653 if (iwl_mvm_has_quota_low_latency(mvm)) 1654 return &cmd->quotas[i]; 1655 1656 quotas = (struct iwl_time_quota_data_v1 *)cmd->quotas; 1657 return (struct iwl_time_quota_data *)"as[i]; 1658 } 1659 1660 int iwl_mvm_update_quotas(struct iwl_mvm *mvm, bool force_upload, 1661 struct ieee80211_vif *disabled_vif); 1662 1663 /* Scanning */ 1664 int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1665 struct cfg80211_scan_request *req, 1666 struct ieee80211_scan_ies *ies); 1667 int iwl_mvm_scan_size(struct iwl_mvm *mvm); 1668 int iwl_mvm_scan_stop(struct iwl_mvm *mvm, int type, bool notify); 1669 int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm); 1670 void iwl_mvm_report_scan_aborted(struct iwl_mvm *mvm); 1671 void iwl_mvm_scan_timeout_wk(struct work_struct *work); 1672 1673 /* Scheduled scan */ 1674 void iwl_mvm_rx_lmac_scan_complete_notif(struct iwl_mvm *mvm, 1675 struct iwl_rx_cmd_buffer *rxb); 1676 void iwl_mvm_rx_lmac_scan_iter_complete_notif(struct iwl_mvm *mvm, 1677 struct iwl_rx_cmd_buffer *rxb); 1678 int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm, 1679 struct ieee80211_vif *vif, 1680 struct cfg80211_sched_scan_request *req, 1681 struct ieee80211_scan_ies *ies, 1682 int type); 1683 void iwl_mvm_rx_scan_match_found(struct iwl_mvm *mvm, 1684 struct iwl_rx_cmd_buffer *rxb); 1685 1686 /* UMAC scan */ 1687 int iwl_mvm_config_scan(struct iwl_mvm *mvm); 1688 void iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm, 1689 struct iwl_rx_cmd_buffer *rxb); 1690 void iwl_mvm_rx_umac_scan_iter_complete_notif(struct iwl_mvm *mvm, 1691 struct iwl_rx_cmd_buffer *rxb); 1692 1693 /* MVM debugfs */ 1694 #ifdef CONFIG_IWLWIFI_DEBUGFS 1695 void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir); 1696 void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1697 void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1698 #else 1699 static inline void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, 1700 struct dentry *dbgfs_dir) 1701 { 1702 } 1703 static inline void 1704 iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif) 1705 { 1706 } 1707 static inline void 1708 iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif) 1709 { 1710 } 1711 #endif /* CONFIG_IWLWIFI_DEBUGFS */ 1712 1713 /* rate scaling */ 1714 int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq); 1715 void iwl_mvm_update_frame_stats(struct iwl_mvm *mvm, u32 rate, bool agg); 1716 int rs_pretty_print_rate(char *buf, int bufsz, const u32 rate); 1717 void rs_update_last_rssi(struct iwl_mvm *mvm, 1718 struct iwl_mvm_sta *mvmsta, 1719 struct ieee80211_rx_status *rx_status); 1720 1721 /* power management */ 1722 int iwl_mvm_power_update_device(struct iwl_mvm *mvm); 1723 int iwl_mvm_power_update_mac(struct iwl_mvm *mvm); 1724 int iwl_mvm_power_update_ps(struct iwl_mvm *mvm); 1725 int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1726 char *buf, int bufsz); 1727 1728 void iwl_mvm_power_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1729 void iwl_mvm_power_uapsd_misbehaving_ap_notif(struct iwl_mvm *mvm, 1730 struct iwl_rx_cmd_buffer *rxb); 1731 1732 #ifdef CONFIG_IWLWIFI_LEDS 1733 int iwl_mvm_leds_init(struct iwl_mvm *mvm); 1734 void iwl_mvm_leds_exit(struct iwl_mvm *mvm); 1735 void iwl_mvm_leds_sync(struct iwl_mvm *mvm); 1736 #else 1737 static inline int iwl_mvm_leds_init(struct iwl_mvm *mvm) 1738 { 1739 return 0; 1740 } 1741 static inline void iwl_mvm_leds_exit(struct iwl_mvm *mvm) 1742 { 1743 } 1744 static inline void iwl_mvm_leds_sync(struct iwl_mvm *mvm) 1745 { 1746 } 1747 #endif 1748 1749 /* D3 (WoWLAN, NetDetect) */ 1750 int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan); 1751 int iwl_mvm_resume(struct ieee80211_hw *hw); 1752 void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled); 1753 void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw, 1754 struct ieee80211_vif *vif, 1755 struct cfg80211_gtk_rekey_data *data); 1756 void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw, 1757 struct ieee80211_vif *vif, 1758 struct inet6_dev *idev); 1759 void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw, 1760 struct ieee80211_vif *vif, int idx); 1761 extern const struct file_operations iwl_dbgfs_d3_test_ops; 1762 struct iwl_wowlan_status *iwl_mvm_send_wowlan_get_status(struct iwl_mvm *mvm); 1763 #ifdef CONFIG_PM 1764 void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, 1765 struct ieee80211_vif *vif); 1766 #else 1767 static inline void 1768 iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif) 1769 { 1770 } 1771 #endif 1772 void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta, 1773 struct iwl_wowlan_config_cmd *cmd); 1774 int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm, 1775 struct ieee80211_vif *vif, 1776 bool disable_offloading, 1777 bool offload_ns, 1778 u32 cmd_flags); 1779 1780 /* BT Coex */ 1781 int iwl_mvm_send_bt_init_conf(struct iwl_mvm *mvm); 1782 void iwl_mvm_rx_bt_coex_notif(struct iwl_mvm *mvm, 1783 struct iwl_rx_cmd_buffer *rxb); 1784 void iwl_mvm_bt_rssi_event(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1785 enum ieee80211_rssi_event_data); 1786 void iwl_mvm_bt_coex_vif_change(struct iwl_mvm *mvm); 1787 u16 iwl_mvm_coex_agg_time_limit(struct iwl_mvm *mvm, 1788 struct ieee80211_sta *sta); 1789 bool iwl_mvm_bt_coex_is_mimo_allowed(struct iwl_mvm *mvm, 1790 struct ieee80211_sta *sta); 1791 bool iwl_mvm_bt_coex_is_ant_avail(struct iwl_mvm *mvm, u8 ant); 1792 bool iwl_mvm_bt_coex_is_shared_ant_avail(struct iwl_mvm *mvm); 1793 bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm *mvm, 1794 enum nl80211_band band); 1795 u8 iwl_mvm_bt_coex_get_single_ant_msk(struct iwl_mvm *mvm, u8 enabled_ants); 1796 u8 iwl_mvm_bt_coex_tx_prio(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr, 1797 struct ieee80211_tx_info *info, u8 ac); 1798 1799 /* beacon filtering */ 1800 #ifdef CONFIG_IWLWIFI_DEBUGFS 1801 void 1802 iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif, 1803 struct iwl_beacon_filter_cmd *cmd); 1804 #else 1805 static inline void 1806 iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif, 1807 struct iwl_beacon_filter_cmd *cmd) 1808 {} 1809 #endif 1810 int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm, 1811 struct ieee80211_vif *vif, 1812 u32 flags); 1813 int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm, 1814 struct ieee80211_vif *vif, 1815 u32 flags); 1816 /* SMPS */ 1817 void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1818 enum iwl_mvm_smps_type_request req_type, 1819 enum ieee80211_smps_mode smps_request); 1820 bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm); 1821 1822 /* Low latency */ 1823 int iwl_mvm_update_low_latency(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1824 bool low_latency, 1825 enum iwl_mvm_low_latency_cause cause); 1826 /* get SystemLowLatencyMode - only needed for beacon threshold? */ 1827 bool iwl_mvm_low_latency(struct iwl_mvm *mvm); 1828 bool iwl_mvm_low_latency_band(struct iwl_mvm *mvm, enum nl80211_band band); 1829 void iwl_mvm_send_low_latency_cmd(struct iwl_mvm *mvm, bool low_latency, 1830 u16 mac_id); 1831 1832 /* get VMACLowLatencyMode */ 1833 static inline bool iwl_mvm_vif_low_latency(struct iwl_mvm_vif *mvmvif) 1834 { 1835 /* 1836 * should this consider associated/active/... state? 1837 * 1838 * Normally low-latency should only be active on interfaces 1839 * that are active, but at least with debugfs it can also be 1840 * enabled on interfaces that aren't active. However, when 1841 * interface aren't active then they aren't added into the 1842 * binding, so this has no real impact. For now, just return 1843 * the current desired low-latency state. 1844 */ 1845 return mvmvif->low_latency_actual; 1846 } 1847 1848 static inline 1849 void iwl_mvm_vif_set_low_latency(struct iwl_mvm_vif *mvmvif, bool set, 1850 enum iwl_mvm_low_latency_cause cause) 1851 { 1852 u8 new_state; 1853 1854 if (set) 1855 mvmvif->low_latency |= cause; 1856 else 1857 mvmvif->low_latency &= ~cause; 1858 1859 /* 1860 * if LOW_LATENCY_DEBUGFS_FORCE_ENABLE is enabled no changes are 1861 * allowed to actual mode. 1862 */ 1863 if (mvmvif->low_latency & LOW_LATENCY_DEBUGFS_FORCE_ENABLE && 1864 cause != LOW_LATENCY_DEBUGFS_FORCE_ENABLE) 1865 return; 1866 1867 if (cause == LOW_LATENCY_DEBUGFS_FORCE_ENABLE && set) 1868 /* 1869 * We enter force state 1870 */ 1871 new_state = !!(mvmvif->low_latency & 1872 LOW_LATENCY_DEBUGFS_FORCE); 1873 else 1874 /* 1875 * Check if any other one set low latency 1876 */ 1877 new_state = !!(mvmvif->low_latency & 1878 ~(LOW_LATENCY_DEBUGFS_FORCE_ENABLE | 1879 LOW_LATENCY_DEBUGFS_FORCE)); 1880 1881 mvmvif->low_latency_actual = new_state; 1882 } 1883 1884 /* Return a bitmask with all the hw supported queues, except for the 1885 * command queue, which can't be flushed. 1886 */ 1887 static inline u32 iwl_mvm_flushable_queues(struct iwl_mvm *mvm) 1888 { 1889 return ((BIT(mvm->trans->trans_cfg->base_params->num_of_queues) - 1) & 1890 ~BIT(IWL_MVM_DQA_CMD_QUEUE)); 1891 } 1892 1893 void iwl_mvm_stop_device(struct iwl_mvm *mvm); 1894 1895 /* Re-configure the SCD for a queue that has already been configured */ 1896 int iwl_mvm_reconfig_scd(struct iwl_mvm *mvm, int queue, int fifo, int sta_id, 1897 int tid, int frame_limit, u16 ssn); 1898 1899 /* Thermal management and CT-kill */ 1900 void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff); 1901 void iwl_mvm_tt_temp_changed(struct iwl_mvm *mvm, u32 temp); 1902 void iwl_mvm_temp_notif(struct iwl_mvm *mvm, 1903 struct iwl_rx_cmd_buffer *rxb); 1904 void iwl_mvm_tt_handler(struct iwl_mvm *mvm); 1905 void iwl_mvm_thermal_initialize(struct iwl_mvm *mvm, u32 min_backoff); 1906 void iwl_mvm_thermal_exit(struct iwl_mvm *mvm); 1907 void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm *mvm, bool state); 1908 int iwl_mvm_get_temp(struct iwl_mvm *mvm, s32 *temp); 1909 void iwl_mvm_ct_kill_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1910 void iwl_mvm_enter_ctkill(struct iwl_mvm *mvm); 1911 int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm); 1912 int iwl_mvm_ctdp_command(struct iwl_mvm *mvm, u32 op, u32 budget); 1913 1914 /* Location Aware Regulatory */ 1915 struct iwl_mcc_update_resp * 1916 iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2, 1917 enum iwl_mcc_source src_id); 1918 int iwl_mvm_init_mcc(struct iwl_mvm *mvm); 1919 void iwl_mvm_rx_chub_update_mcc(struct iwl_mvm *mvm, 1920 struct iwl_rx_cmd_buffer *rxb); 1921 struct ieee80211_regdomain *iwl_mvm_get_regdomain(struct wiphy *wiphy, 1922 const char *alpha2, 1923 enum iwl_mcc_source src_id, 1924 bool *changed); 1925 struct ieee80211_regdomain *iwl_mvm_get_current_regdomain(struct iwl_mvm *mvm, 1926 bool *changed); 1927 int iwl_mvm_init_fw_regd(struct iwl_mvm *mvm); 1928 void iwl_mvm_update_changed_regdom(struct iwl_mvm *mvm); 1929 1930 /* smart fifo */ 1931 int iwl_mvm_sf_update(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1932 bool added_vif); 1933 1934 /* FTM responder */ 1935 int iwl_mvm_ftm_start_responder(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1936 void iwl_mvm_ftm_restart_responder(struct iwl_mvm *mvm, 1937 struct ieee80211_vif *vif); 1938 void iwl_mvm_ftm_responder_stats(struct iwl_mvm *mvm, 1939 struct iwl_rx_cmd_buffer *rxb); 1940 int iwl_mvm_ftm_resp_remove_pasn_sta(struct iwl_mvm *mvm, 1941 struct ieee80211_vif *vif, u8 *addr); 1942 int iwl_mvm_ftm_respoder_add_pasn_sta(struct iwl_mvm *mvm, 1943 struct ieee80211_vif *vif, 1944 u8 *addr, u32 cipher, u8 *tk, u32 tk_len, 1945 u8 *hltk, u32 hltk_len); 1946 void iwl_mvm_ftm_responder_clear(struct iwl_mvm *mvm, 1947 struct ieee80211_vif *vif); 1948 1949 /* FTM initiator */ 1950 void iwl_mvm_ftm_restart(struct iwl_mvm *mvm); 1951 void iwl_mvm_ftm_range_resp(struct iwl_mvm *mvm, 1952 struct iwl_rx_cmd_buffer *rxb); 1953 void iwl_mvm_ftm_lc_notif(struct iwl_mvm *mvm, 1954 struct iwl_rx_cmd_buffer *rxb); 1955 int iwl_mvm_ftm_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1956 struct cfg80211_pmsr_request *request); 1957 void iwl_mvm_ftm_abort(struct iwl_mvm *mvm, struct cfg80211_pmsr_request *req); 1958 void iwl_mvm_ftm_initiator_smooth_config(struct iwl_mvm *mvm); 1959 void iwl_mvm_ftm_initiator_smooth_stop(struct iwl_mvm *mvm); 1960 int iwl_mvm_ftm_add_pasn_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1961 u8 *addr, u32 cipher, u8 *tk, u32 tk_len, 1962 u8 *hltk, u32 hltk_len); 1963 void iwl_mvm_ftm_remove_pasn_sta(struct iwl_mvm *mvm, u8 *addr); 1964 1965 /* TDLS */ 1966 1967 /* 1968 * We use TID 4 (VI) as a FW-used-only TID when TDLS connections are present. 1969 * This TID is marked as used vs the AP and all connected TDLS peers. 1970 */ 1971 #define IWL_MVM_TDLS_FW_TID 4 1972 1973 int iwl_mvm_tdls_sta_count(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1974 void iwl_mvm_teardown_tdls_peers(struct iwl_mvm *mvm); 1975 void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1976 bool sta_added); 1977 void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw, 1978 struct ieee80211_vif *vif); 1979 int iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw, 1980 struct ieee80211_vif *vif, 1981 struct ieee80211_sta *sta, u8 oper_class, 1982 struct cfg80211_chan_def *chandef, 1983 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie); 1984 void iwl_mvm_tdls_recv_channel_switch(struct ieee80211_hw *hw, 1985 struct ieee80211_vif *vif, 1986 struct ieee80211_tdls_ch_sw_params *params); 1987 void iwl_mvm_tdls_cancel_channel_switch(struct ieee80211_hw *hw, 1988 struct ieee80211_vif *vif, 1989 struct ieee80211_sta *sta); 1990 void iwl_mvm_rx_tdls_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1991 void iwl_mvm_tdls_ch_switch_work(struct work_struct *work); 1992 1993 void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm, 1994 struct iwl_mvm_internal_rxq_notif *notif, 1995 u32 size); 1996 void iwl_mvm_reorder_timer_expired(struct timer_list *t); 1997 struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm); 1998 bool iwl_mvm_is_vif_assoc(struct iwl_mvm *mvm); 1999 2000 #define MVM_TCM_PERIOD_MSEC 500 2001 #define MVM_TCM_PERIOD (HZ * MVM_TCM_PERIOD_MSEC / 1000) 2002 #define MVM_LL_PERIOD (10 * HZ) 2003 void iwl_mvm_tcm_work(struct work_struct *work); 2004 void iwl_mvm_recalc_tcm(struct iwl_mvm *mvm); 2005 void iwl_mvm_pause_tcm(struct iwl_mvm *mvm, bool with_cancel); 2006 void iwl_mvm_resume_tcm(struct iwl_mvm *mvm); 2007 void iwl_mvm_tcm_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 2008 void iwl_mvm_tcm_rm_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 2009 u8 iwl_mvm_tcm_load_percentage(u32 airtime, u32 elapsed); 2010 2011 void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error); 2012 unsigned int iwl_mvm_get_wd_timeout(struct iwl_mvm *mvm, 2013 struct ieee80211_vif *vif, 2014 bool tdls, bool cmd_q); 2015 void iwl_mvm_connection_loss(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 2016 const char *errmsg); 2017 void iwl_mvm_event_frame_timeout_callback(struct iwl_mvm *mvm, 2018 struct ieee80211_vif *vif, 2019 const struct ieee80211_sta *sta, 2020 u16 tid); 2021 2022 int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b); 2023 int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm); 2024 int iwl_mvm_ppag_send_cmd(struct iwl_mvm *mvm); 2025 #ifdef CONFIG_IWLWIFI_DEBUGFS 2026 void iwl_mvm_sta_add_debugfs(struct ieee80211_hw *hw, 2027 struct ieee80211_vif *vif, 2028 struct ieee80211_sta *sta, 2029 struct dentry *dir); 2030 #endif 2031 2032 static inline u8 iwl_mvm_phy_band_from_nl80211(enum nl80211_band band) 2033 { 2034 switch (band) { 2035 case NL80211_BAND_2GHZ: 2036 return PHY_BAND_24; 2037 case NL80211_BAND_5GHZ: 2038 return PHY_BAND_5; 2039 case NL80211_BAND_6GHZ: 2040 return PHY_BAND_6; 2041 default: 2042 WARN_ONCE(1, "Unsupported band (%u)\n", band); 2043 return PHY_BAND_5; 2044 } 2045 } 2046 2047 /* Channel info utils */ 2048 static inline bool iwl_mvm_has_ultra_hb_channel(struct iwl_mvm *mvm) 2049 { 2050 return fw_has_capa(&mvm->fw->ucode_capa, 2051 IWL_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS); 2052 } 2053 2054 static inline void *iwl_mvm_chan_info_cmd_tail(struct iwl_mvm *mvm, 2055 struct iwl_fw_channel_info *ci) 2056 { 2057 return (u8 *)ci + (iwl_mvm_has_ultra_hb_channel(mvm) ? 2058 sizeof(struct iwl_fw_channel_info) : 2059 sizeof(struct iwl_fw_channel_info_v1)); 2060 } 2061 2062 static inline size_t iwl_mvm_chan_info_padding(struct iwl_mvm *mvm) 2063 { 2064 return iwl_mvm_has_ultra_hb_channel(mvm) ? 0 : 2065 sizeof(struct iwl_fw_channel_info) - 2066 sizeof(struct iwl_fw_channel_info_v1); 2067 } 2068 2069 static inline void iwl_mvm_set_chan_info(struct iwl_mvm *mvm, 2070 struct iwl_fw_channel_info *ci, 2071 u32 chan, u8 band, u8 width, 2072 u8 ctrl_pos) 2073 { 2074 if (iwl_mvm_has_ultra_hb_channel(mvm)) { 2075 ci->channel = cpu_to_le32(chan); 2076 ci->band = band; 2077 ci->width = width; 2078 ci->ctrl_pos = ctrl_pos; 2079 } else { 2080 struct iwl_fw_channel_info_v1 *ci_v1 = 2081 (struct iwl_fw_channel_info_v1 *)ci; 2082 2083 ci_v1->channel = chan; 2084 ci_v1->band = band; 2085 ci_v1->width = width; 2086 ci_v1->ctrl_pos = ctrl_pos; 2087 } 2088 } 2089 2090 static inline void 2091 iwl_mvm_set_chan_info_chandef(struct iwl_mvm *mvm, 2092 struct iwl_fw_channel_info *ci, 2093 struct cfg80211_chan_def *chandef) 2094 { 2095 enum nl80211_band band = chandef->chan->band; 2096 2097 iwl_mvm_set_chan_info(mvm, ci, chandef->chan->hw_value, 2098 iwl_mvm_phy_band_from_nl80211(band), 2099 iwl_mvm_get_channel_width(chandef), 2100 iwl_mvm_get_ctrl_pos(chandef)); 2101 } 2102 2103 static inline int iwl_umac_scan_get_max_profiles(const struct iwl_fw *fw) 2104 { 2105 u8 ver = iwl_fw_lookup_cmd_ver(fw, IWL_ALWAYS_LONG_GROUP, 2106 SCAN_OFFLOAD_UPDATE_PROFILES_CMD, 2107 IWL_FW_CMD_VER_UNKNOWN); 2108 return (ver == IWL_FW_CMD_VER_UNKNOWN || ver < 3) ? 2109 IWL_SCAN_MAX_PROFILES : IWL_SCAN_MAX_PROFILES_V2; 2110 } 2111 2112 static inline 2113 enum iwl_location_cipher iwl_mvm_cipher_to_location_cipher(u32 cipher) 2114 { 2115 switch (cipher) { 2116 case WLAN_CIPHER_SUITE_CCMP: 2117 return IWL_LOCATION_CIPHER_CCMP_128; 2118 case WLAN_CIPHER_SUITE_GCMP: 2119 return IWL_LOCATION_CIPHER_GCMP_128; 2120 case WLAN_CIPHER_SUITE_GCMP_256: 2121 return IWL_LOCATION_CIPHER_GCMP_256; 2122 default: 2123 return IWL_LOCATION_CIPHER_INVALID; 2124 } 2125 } 2126 #endif /* __IWL_MVM_H__ */ 2127