1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 /* 3 * Copyright (C) 2012-2014, 2018-2023 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 <linux/ptp_clock_kernel.h> 20 21 #include <linux/ktime.h> 22 23 #include "iwl-op-mode.h" 24 #include "iwl-trans.h" 25 #include "fw/notif-wait.h" 26 #include "iwl-eeprom-parse.h" 27 #include "fw/file.h" 28 #include "iwl-config.h" 29 #include "sta.h" 30 #include "fw-api.h" 31 #include "constants.h" 32 #include "fw/runtime.h" 33 #include "fw/dbg.h" 34 #include "fw/acpi.h" 35 #include "mei/iwl-mei.h" 36 #include "iwl-nvm-parse.h" 37 38 #include <linux/average.h> 39 40 #define IWL_MVM_MAX_ADDRESSES 5 41 /* RSSI offset for WkP */ 42 #define IWL_RSSI_OFFSET 50 43 #define IWL_MVM_MISSED_BEACONS_THRESHOLD 8 44 #define IWL_MVM_MISSED_BEACONS_THRESHOLD_LONG 16 45 46 /* A TimeUnit is 1024 microsecond */ 47 #define MSEC_TO_TU(_msec) (_msec*1000/1024) 48 49 /* For GO, this value represents the number of TUs before CSA "beacon 50 * 0" TBTT when the CSA time-event needs to be scheduled to start. It 51 * must be big enough to ensure that we switch in time. 52 */ 53 #define IWL_MVM_CHANNEL_SWITCH_TIME_GO 40 54 55 /* For client, this value represents the number of TUs before CSA 56 * "beacon 1" TBTT, instead. This is because we don't know when the 57 * GO/AP will be in the new channel, so we switch early enough. 58 */ 59 #define IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT 10 60 61 /* 62 * This value (in TUs) is used to fine tune the CSA NoA end time which should 63 * be just before "beacon 0" TBTT. 64 */ 65 #define IWL_MVM_CHANNEL_SWITCH_MARGIN 4 66 67 /* 68 * Number of beacons to transmit on a new channel until we unblock tx to 69 * the stations, even if we didn't identify them on a new channel 70 */ 71 #define IWL_MVM_CS_UNBLOCK_TX_TIMEOUT 3 72 73 /* offchannel queue towards mac80211 */ 74 #define IWL_MVM_OFFCHANNEL_QUEUE 0 75 76 /* invalid value for FW link id */ 77 #define IWL_MVM_FW_LINK_ID_INVALID 0xff 78 79 extern const struct ieee80211_ops iwl_mvm_hw_ops; 80 extern const struct ieee80211_ops iwl_mvm_mld_hw_ops; 81 82 /** 83 * struct iwl_mvm_mod_params - module parameters for iwlmvm 84 * @init_dbg: if true, then the NIC won't be stopped if the INIT fw asserted. 85 * We will register to mac80211 to have testmode working. The NIC must not 86 * be up'ed after the INIT fw asserted. This is useful to be able to use 87 * proprietary tools over testmode to debug the INIT fw. 88 * @power_scheme: one of enum iwl_power_scheme 89 */ 90 struct iwl_mvm_mod_params { 91 bool init_dbg; 92 int power_scheme; 93 }; 94 extern struct iwl_mvm_mod_params iwlmvm_mod_params; 95 96 struct iwl_mvm_phy_ctxt { 97 u16 id; 98 u16 color; 99 u32 ref; 100 101 enum nl80211_chan_width width; 102 103 struct ieee80211_channel *channel; 104 105 /* track for RLC config command */ 106 u32 center_freq1; 107 bool rlc_disabled; 108 }; 109 110 struct iwl_mvm_time_event_data { 111 struct ieee80211_vif *vif; 112 struct list_head list; 113 unsigned long end_jiffies; 114 u32 duration; 115 bool running; 116 u32 uid; 117 118 /* 119 * The access to the 'id' field must be done when the 120 * mvm->time_event_lock is held, as it value is used to indicate 121 * if the te is in the time event list or not (when id == TE_MAX) 122 */ 123 u32 id; 124 }; 125 126 /* Power management */ 127 128 /** 129 * enum iwl_power_scheme 130 * @IWL_POWER_SCHEME_CAM: Continuously Active Mode 131 * @IWL_POWER_SCHEME_BPS: Balanced Power Save (default) 132 * @IWL_POWER_SCHEME_LP: Low Power 133 */ 134 enum iwl_power_scheme { 135 IWL_POWER_SCHEME_CAM = 1, 136 IWL_POWER_SCHEME_BPS, 137 IWL_POWER_SCHEME_LP 138 }; 139 140 #define IWL_UAPSD_MAX_SP IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL 141 142 #ifdef CONFIG_IWLWIFI_DEBUGFS 143 enum iwl_dbgfs_pm_mask { 144 MVM_DEBUGFS_PM_KEEP_ALIVE = BIT(0), 145 MVM_DEBUGFS_PM_SKIP_OVER_DTIM = BIT(1), 146 MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS = BIT(2), 147 MVM_DEBUGFS_PM_RX_DATA_TIMEOUT = BIT(3), 148 MVM_DEBUGFS_PM_TX_DATA_TIMEOUT = BIT(4), 149 MVM_DEBUGFS_PM_LPRX_ENA = BIT(6), 150 MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD = BIT(7), 151 MVM_DEBUGFS_PM_SNOOZE_ENABLE = BIT(8), 152 MVM_DEBUGFS_PM_UAPSD_MISBEHAVING = BIT(9), 153 MVM_DEBUGFS_PM_USE_PS_POLL = BIT(10), 154 }; 155 156 struct iwl_dbgfs_pm { 157 u16 keep_alive_seconds; 158 u32 rx_data_timeout; 159 u32 tx_data_timeout; 160 bool skip_over_dtim; 161 u8 skip_dtim_periods; 162 bool lprx_ena; 163 u32 lprx_rssi_threshold; 164 bool snooze_ena; 165 bool uapsd_misbehaving; 166 bool use_ps_poll; 167 int mask; 168 }; 169 170 /* beacon filtering */ 171 172 enum iwl_dbgfs_bf_mask { 173 MVM_DEBUGFS_BF_ENERGY_DELTA = BIT(0), 174 MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA = BIT(1), 175 MVM_DEBUGFS_BF_ROAMING_STATE = BIT(2), 176 MVM_DEBUGFS_BF_TEMP_THRESHOLD = BIT(3), 177 MVM_DEBUGFS_BF_TEMP_FAST_FILTER = BIT(4), 178 MVM_DEBUGFS_BF_TEMP_SLOW_FILTER = BIT(5), 179 MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER = BIT(6), 180 MVM_DEBUGFS_BF_DEBUG_FLAG = BIT(7), 181 MVM_DEBUGFS_BF_ESCAPE_TIMER = BIT(8), 182 MVM_DEBUGFS_BA_ESCAPE_TIMER = BIT(9), 183 MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT = BIT(10), 184 }; 185 186 struct iwl_dbgfs_bf { 187 u32 bf_energy_delta; 188 u32 bf_roaming_energy_delta; 189 u32 bf_roaming_state; 190 u32 bf_temp_threshold; 191 u32 bf_temp_fast_filter; 192 u32 bf_temp_slow_filter; 193 u32 bf_enable_beacon_filter; 194 u32 bf_debug_flag; 195 u32 bf_escape_timer; 196 u32 ba_escape_timer; 197 u32 ba_enable_beacon_abort; 198 int mask; 199 }; 200 #endif 201 202 enum iwl_mvm_smps_type_request { 203 IWL_MVM_SMPS_REQ_BT_COEX, 204 IWL_MVM_SMPS_REQ_TT, 205 IWL_MVM_SMPS_REQ_PROT, 206 IWL_MVM_SMPS_REQ_FW, 207 NUM_IWL_MVM_SMPS_REQ, 208 }; 209 210 enum iwl_bt_force_ant_mode { 211 BT_FORCE_ANT_DIS = 0, 212 BT_FORCE_ANT_AUTO, 213 BT_FORCE_ANT_BT, 214 BT_FORCE_ANT_WIFI, 215 216 BT_FORCE_ANT_MAX, 217 }; 218 219 /** 220 * enum iwl_mvm_low_latency_force - low latency force mode set by debugfs 221 * @LOW_LATENCY_FORCE_UNSET: unset force mode 222 * @LOW_LATENCY_FORCE_ON: for low latency on 223 * @LOW_LATENCY_FORCE_OFF: for low latency off 224 * @NUM_LOW_LATENCY_FORCE: max num of modes 225 */ 226 enum iwl_mvm_low_latency_force { 227 LOW_LATENCY_FORCE_UNSET, 228 LOW_LATENCY_FORCE_ON, 229 LOW_LATENCY_FORCE_OFF, 230 NUM_LOW_LATENCY_FORCE 231 }; 232 233 /** 234 * enum iwl_mvm_low_latency_cause - low latency set causes 235 * @LOW_LATENCY_TRAFFIC: indicates low latency traffic was detected 236 * @LOW_LATENCY_DEBUGFS: low latency mode set from debugfs 237 * @LOW_LATENCY_VCMD: low latency mode set from vendor command 238 * @LOW_LATENCY_VIF_TYPE: low latency mode set because of vif type (ap) 239 * @LOW_LATENCY_DEBUGFS_FORCE_ENABLE: indicate that force mode is enabled 240 * the actual set/unset is done with LOW_LATENCY_DEBUGFS_FORCE 241 * @LOW_LATENCY_DEBUGFS_FORCE: low latency force mode from debugfs 242 * set this with LOW_LATENCY_DEBUGFS_FORCE_ENABLE flag 243 * in low_latency. 244 */ 245 enum iwl_mvm_low_latency_cause { 246 LOW_LATENCY_TRAFFIC = BIT(0), 247 LOW_LATENCY_DEBUGFS = BIT(1), 248 LOW_LATENCY_VCMD = BIT(2), 249 LOW_LATENCY_VIF_TYPE = BIT(3), 250 LOW_LATENCY_DEBUGFS_FORCE_ENABLE = BIT(4), 251 LOW_LATENCY_DEBUGFS_FORCE = BIT(5), 252 }; 253 254 /** 255 * struct iwl_mvm_vif_bf_data - beacon filtering related data 256 * @bf_enabled: indicates if beacon filtering is enabled 257 * @ba_enabled: indicated if beacon abort is enabled 258 * @ave_beacon_signal: average beacon signal 259 * @last_cqm_event: rssi of the last cqm event 260 * @bt_coex_min_thold: minimum threshold for BT coex 261 * @bt_coex_max_thold: maximum threshold for BT coex 262 * @last_bt_coex_event: rssi of the last BT coex event 263 */ 264 struct iwl_mvm_vif_bf_data { 265 bool bf_enabled; 266 bool ba_enabled; 267 int ave_beacon_signal; 268 int last_cqm_event; 269 int bt_coex_min_thold; 270 int bt_coex_max_thold; 271 int last_bt_coex_event; 272 }; 273 274 /** 275 * struct iwl_probe_resp_data - data for NoA/CSA updates 276 * @rcu_head: used for freeing the data on update 277 * @notif: notification data 278 * @noa_len: length of NoA attribute, calculated from the notification 279 */ 280 struct iwl_probe_resp_data { 281 struct rcu_head rcu_head; 282 struct iwl_probe_resp_data_notif notif; 283 int noa_len; 284 }; 285 286 /** 287 * struct iwl_mvm_vif_link_info - per link data in Virtual Interface 288 * @ap_sta_id: the sta_id of the AP - valid only if VIF type is STA 289 * @fw_link_id: the id of the link according to the FW API 290 * @bssid: BSSID for this (client) interface 291 * @bcast_sta: station used for broadcast packets. Used by the following 292 * vifs: P2P_DEVICE, GO and AP. 293 * @beacon_stats: beacon statistics, containing the # of received beacons, 294 * # of received beacons accumulated over FW restart, and the current 295 * average signal of beacons retrieved from the firmware 296 * @smps_requests: the SMPS requests of different parts of the driver, 297 * combined on update to yield the overall request to mac80211. 298 * @probe_resp_data: data from FW notification to store NOA and CSA related 299 * data to be inserted into probe response. 300 * @he_ru_2mhz_block: 26-tone RU OFDMA transmissions should be blocked 301 * @queue_params: QoS params for this MAC 302 * @mgmt_queue: queue number for unbufferable management frames 303 * @igtk: the current IGTK programmed into the firmware 304 * @active: indicates the link is active in FW (for sanity checking) 305 * @cab_queue: content-after-beacon (multicast) queue 306 * @listen_lmac: indicates this link is allocated to the listen LMAC 307 * @mcast_sta: multicast station 308 * @phy_ctxt: phy context allocated to this link, if any 309 */ 310 struct iwl_mvm_vif_link_info { 311 u8 bssid[ETH_ALEN]; 312 u8 ap_sta_id; 313 u8 fw_link_id; 314 315 struct iwl_mvm_int_sta bcast_sta; 316 struct iwl_mvm_int_sta mcast_sta; 317 318 struct { 319 u32 num_beacons, accu_num_beacons; 320 u8 avg_signal; 321 } beacon_stats; 322 323 enum ieee80211_smps_mode smps_requests[NUM_IWL_MVM_SMPS_REQ]; 324 struct iwl_probe_resp_data __rcu *probe_resp_data; 325 326 struct ieee80211_key_conf *igtk; 327 328 bool he_ru_2mhz_block; 329 bool active; 330 bool listen_lmac; 331 332 u16 cab_queue; 333 /* Assigned while mac80211 has the link in a channel context, 334 * or, for P2P Device, while it exists. 335 */ 336 struct iwl_mvm_phy_ctxt *phy_ctxt; 337 /* QoS data from mac80211, need to store this here 338 * as mac80211 has a separate callback but we need 339 * to have the data for the MAC context 340 */ 341 struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS]; 342 343 u16 mgmt_queue; 344 }; 345 346 /** 347 * struct iwl_mvm_vif - data per Virtual Interface, it is a MAC context 348 * @mvm: pointer back to the mvm struct 349 * @id: between 0 and 3 350 * @color: to solve races upon MAC addition and removal 351 * @associated: indicates that we're currently associated, used only for 352 * managing the firmware state in iwl_mvm_bss_info_changed_station() 353 * @ap_assoc_sta_count: count of stations associated to us - valid only 354 * if VIF type is AP 355 * @uploaded: indicates the MAC context has been added to the device 356 * @ap_ibss_active: indicates that AP/IBSS is configured and that the interface 357 * should get quota etc. 358 * @pm_enabled - indicate if MAC power management is allowed 359 * @monitor_active: indicates that monitor context is configured, and that the 360 * interface should get quota etc. 361 * @low_latency: bit flags for low latency 362 * see enum &iwl_mvm_low_latency_cause for causes. 363 * @low_latency_actual: boolean, indicates low latency is set, 364 * as a result from low_latency bit flags and takes force into account. 365 * @authorized: indicates the AP station was set to authorized 366 * @ps_disabled: indicates that this interface requires PS to be disabled 367 * @csa_countdown: indicates that CSA countdown may be started 368 * @csa_failed: CSA failed to schedule time event, report an error later 369 * @csa_bcn_pending: indicates that we are waiting for a beacon on a new channel 370 * @features: hw features active for this vif 371 * @ap_beacon_time: AP beacon time for synchronisation (on older FW) 372 * @bcn_prot: beacon protection data (keys; FIXME: needs to be per link) 373 * @bf_data: beacon filtering data 374 * @deflink: default link data for use in non-MLO 375 * @link: link data for each link in MLO 376 * @esr_active: indicates eSR mode is active 377 * @pm_enabled: indicates powersave is enabled 378 */ 379 struct iwl_mvm_vif { 380 struct iwl_mvm *mvm; 381 u16 id; 382 u16 color; 383 384 bool associated; 385 u8 ap_assoc_sta_count; 386 bool uploaded; 387 bool ap_ibss_active; 388 bool pm_enabled; 389 bool monitor_active; 390 bool esr_active; 391 392 u8 low_latency: 6; 393 u8 low_latency_actual: 1; 394 395 u8 authorized:1; 396 bool ps_disabled; 397 398 u32 ap_beacon_time; 399 struct iwl_mvm_vif_bf_data bf_data; 400 401 #ifdef CONFIG_PM 402 /* WoWLAN GTK rekey data */ 403 struct { 404 u8 kck[NL80211_KCK_EXT_LEN]; 405 u8 kek[NL80211_KEK_EXT_LEN]; 406 size_t kek_len; 407 size_t kck_len; 408 u32 akm; 409 __le64 replay_ctr; 410 bool valid; 411 } rekey_data; 412 413 int tx_key_idx; 414 415 bool seqno_valid; 416 u16 seqno; 417 #endif 418 419 #if IS_ENABLED(CONFIG_IPV6) 420 /* IPv6 addresses for WoWLAN */ 421 struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX]; 422 unsigned long tentative_addrs[BITS_TO_LONGS(IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX)]; 423 int num_target_ipv6_addrs; 424 #endif 425 426 #ifdef CONFIG_IWLWIFI_DEBUGFS 427 struct dentry *dbgfs_dir; 428 struct dentry *dbgfs_slink; 429 struct iwl_dbgfs_pm dbgfs_pm; 430 struct iwl_dbgfs_bf dbgfs_bf; 431 struct iwl_mac_power_cmd mac_pwr_cmd; 432 int dbgfs_quota_min; 433 #endif 434 435 /* FW identified misbehaving AP */ 436 u8 uapsd_misbehaving_ap_addr[ETH_ALEN] __aligned(2); 437 struct delayed_work uapsd_nonagg_detected_wk; 438 439 bool csa_countdown; 440 bool csa_failed; 441 bool csa_bcn_pending; 442 u16 csa_target_freq; 443 u16 csa_count; 444 u16 csa_misbehave; 445 struct delayed_work csa_work; 446 447 enum iwl_tsf_id tsf_id; 448 449 struct iwl_mvm_time_event_data time_event_data; 450 struct iwl_mvm_time_event_data hs_time_event_data; 451 452 /* TCP Checksum Offload */ 453 netdev_features_t features; 454 455 struct ieee80211_sta *ap_sta; 456 457 /* we can only have 2 GTK + 2 IGTK active at a time */ 458 struct ieee80211_key_conf *ap_early_keys[4]; 459 460 struct { 461 struct ieee80211_key_conf __rcu *keys[2]; 462 } bcn_prot; 463 464 struct iwl_mvm_vif_link_info deflink; 465 struct iwl_mvm_vif_link_info *link[IEEE80211_MLD_MAX_NUM_LINKS]; 466 }; 467 468 #define for_each_mvm_vif_valid_link(mvm_vif, link_id) \ 469 for (link_id = 0; \ 470 link_id < ARRAY_SIZE((mvm_vif)->link); \ 471 link_id++) \ 472 if ((mvm_vif)->link[link_id]) 473 474 static inline struct iwl_mvm_vif * 475 iwl_mvm_vif_from_mac80211(struct ieee80211_vif *vif) 476 { 477 return (void *)vif->drv_priv; 478 } 479 480 extern const u8 tid_to_mac80211_ac[]; 481 482 #define IWL_MVM_SCAN_STOPPING_SHIFT 8 483 484 enum iwl_scan_status { 485 IWL_MVM_SCAN_REGULAR = BIT(0), 486 IWL_MVM_SCAN_SCHED = BIT(1), 487 IWL_MVM_SCAN_NETDETECT = BIT(2), 488 489 IWL_MVM_SCAN_STOPPING_REGULAR = BIT(8), 490 IWL_MVM_SCAN_STOPPING_SCHED = BIT(9), 491 IWL_MVM_SCAN_STOPPING_NETDETECT = BIT(10), 492 493 IWL_MVM_SCAN_REGULAR_MASK = IWL_MVM_SCAN_REGULAR | 494 IWL_MVM_SCAN_STOPPING_REGULAR, 495 IWL_MVM_SCAN_SCHED_MASK = IWL_MVM_SCAN_SCHED | 496 IWL_MVM_SCAN_STOPPING_SCHED, 497 IWL_MVM_SCAN_NETDETECT_MASK = IWL_MVM_SCAN_NETDETECT | 498 IWL_MVM_SCAN_STOPPING_NETDETECT, 499 500 IWL_MVM_SCAN_STOPPING_MASK = 0xff << IWL_MVM_SCAN_STOPPING_SHIFT, 501 IWL_MVM_SCAN_MASK = 0xff, 502 }; 503 504 enum iwl_mvm_scan_type { 505 IWL_SCAN_TYPE_NOT_SET, 506 IWL_SCAN_TYPE_UNASSOC, 507 IWL_SCAN_TYPE_WILD, 508 IWL_SCAN_TYPE_MILD, 509 IWL_SCAN_TYPE_FRAGMENTED, 510 IWL_SCAN_TYPE_FAST_BALANCE, 511 }; 512 513 enum iwl_mvm_sched_scan_pass_all_states { 514 SCHED_SCAN_PASS_ALL_DISABLED, 515 SCHED_SCAN_PASS_ALL_ENABLED, 516 SCHED_SCAN_PASS_ALL_FOUND, 517 }; 518 519 /** 520 * struct iwl_mvm_tt_mgnt - Thermal Throttling Management structure 521 * @ct_kill_exit: worker to exit thermal kill 522 * @dynamic_smps: Is thermal throttling enabled dynamic_smps? 523 * @tx_backoff: The current thremal throttling tx backoff in uSec. 524 * @min_backoff: The minimal tx backoff due to power restrictions 525 * @params: Parameters to configure the thermal throttling algorithm. 526 * @throttle: Is thermal throttling is active? 527 */ 528 struct iwl_mvm_tt_mgmt { 529 struct delayed_work ct_kill_exit; 530 bool dynamic_smps; 531 u32 tx_backoff; 532 u32 min_backoff; 533 struct iwl_tt_params params; 534 bool throttle; 535 }; 536 537 #ifdef CONFIG_THERMAL 538 /** 539 *struct iwl_mvm_thermal_device - thermal zone related data 540 * @temp_trips: temperature thresholds for report 541 * @fw_trips_index: keep indexes to original array - temp_trips 542 * @tzone: thermal zone device data 543 */ 544 struct iwl_mvm_thermal_device { 545 struct thermal_trip trips[IWL_MAX_DTS_TRIPS]; 546 u8 fw_trips_index[IWL_MAX_DTS_TRIPS]; 547 struct thermal_zone_device *tzone; 548 }; 549 550 /* 551 * struct iwl_mvm_cooling_device 552 * @cur_state: current state 553 * @cdev: struct thermal cooling device 554 */ 555 struct iwl_mvm_cooling_device { 556 u32 cur_state; 557 struct thermal_cooling_device *cdev; 558 }; 559 #endif 560 561 #define IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES 8 562 563 struct iwl_mvm_frame_stats { 564 u32 legacy_frames; 565 u32 ht_frames; 566 u32 vht_frames; 567 u32 bw_20_frames; 568 u32 bw_40_frames; 569 u32 bw_80_frames; 570 u32 bw_160_frames; 571 u32 sgi_frames; 572 u32 ngi_frames; 573 u32 siso_frames; 574 u32 mimo2_frames; 575 u32 agg_frames; 576 u32 ampdu_count; 577 u32 success_frames; 578 u32 fail_frames; 579 u32 last_rates[IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES]; 580 int last_frame_idx; 581 }; 582 583 #define IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE 0xff 584 #define IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -100 585 #define IWL_MVM_DEBUG_SET_TEMPERATURE_MAX 200 586 587 enum iwl_mvm_tdls_cs_state { 588 IWL_MVM_TDLS_SW_IDLE = 0, 589 IWL_MVM_TDLS_SW_REQ_SENT, 590 IWL_MVM_TDLS_SW_RESP_RCVD, 591 IWL_MVM_TDLS_SW_REQ_RCVD, 592 IWL_MVM_TDLS_SW_ACTIVE, 593 }; 594 595 enum iwl_mvm_traffic_load { 596 IWL_MVM_TRAFFIC_LOW, 597 IWL_MVM_TRAFFIC_MEDIUM, 598 IWL_MVM_TRAFFIC_HIGH, 599 }; 600 601 DECLARE_EWMA(rate, 16, 16) 602 603 struct iwl_mvm_tcm_mac { 604 struct { 605 u32 pkts[IEEE80211_NUM_ACS]; 606 u32 airtime; 607 } tx; 608 struct { 609 u32 pkts[IEEE80211_NUM_ACS]; 610 u32 airtime; 611 u32 last_ampdu_ref; 612 } rx; 613 struct { 614 /* track AP's transfer in client mode */ 615 u64 rx_bytes; 616 struct ewma_rate rate; 617 bool detected; 618 } uapsd_nonagg_detect; 619 bool opened_rx_ba_sessions; 620 }; 621 622 struct iwl_mvm_tcm { 623 struct delayed_work work; 624 spinlock_t lock; /* used when time elapsed */ 625 unsigned long ts; /* timestamp when period ends */ 626 unsigned long ll_ts; 627 unsigned long uapsd_nonagg_ts; 628 bool paused; 629 struct iwl_mvm_tcm_mac data[NUM_MAC_INDEX_DRIVER]; 630 struct { 631 u32 elapsed; /* milliseconds for this TCM period */ 632 u32 airtime[NUM_MAC_INDEX_DRIVER]; 633 enum iwl_mvm_traffic_load load[NUM_MAC_INDEX_DRIVER]; 634 enum iwl_mvm_traffic_load band_load[NUM_NL80211_BANDS]; 635 enum iwl_mvm_traffic_load global_load; 636 bool low_latency[NUM_MAC_INDEX_DRIVER]; 637 bool change[NUM_MAC_INDEX_DRIVER]; 638 } result; 639 }; 640 641 /** 642 * struct iwl_mvm_reorder_buffer - per ra/tid/queue reorder buffer 643 * @head_sn: reorder window head sn 644 * @num_stored: number of mpdus stored in the buffer 645 * @buf_size: the reorder buffer size as set by the last addba request 646 * @queue: queue of this reorder buffer 647 * @last_amsdu: track last ASMDU SN for duplication detection 648 * @last_sub_index: track ASMDU sub frame index for duplication detection 649 * @reorder_timer: timer for frames are in the reorder buffer. For AMSDU 650 * it is the time of last received sub-frame 651 * @removed: prevent timer re-arming 652 * @valid: reordering is valid for this queue 653 * @lock: protect reorder buffer internal state 654 * @mvm: mvm pointer, needed for frame timer context 655 * @consec_oldsn_drops: consecutive drops due to old SN 656 * @consec_oldsn_ampdu_gp2: A-MPDU GP2 timestamp to track 657 * when to apply old SN consecutive drop workaround 658 * @consec_oldsn_prev_drop: track whether or not an MPDU 659 * that was single/part of the previous A-MPDU was 660 * dropped due to old SN 661 */ 662 struct iwl_mvm_reorder_buffer { 663 u16 head_sn; 664 u16 num_stored; 665 u16 buf_size; 666 int queue; 667 u16 last_amsdu; 668 u8 last_sub_index; 669 struct timer_list reorder_timer; 670 bool removed; 671 bool valid; 672 spinlock_t lock; 673 struct iwl_mvm *mvm; 674 unsigned int consec_oldsn_drops; 675 u32 consec_oldsn_ampdu_gp2; 676 unsigned int consec_oldsn_prev_drop:1; 677 } ____cacheline_aligned_in_smp; 678 679 /** 680 * struct _iwl_mvm_reorder_buf_entry - reorder buffer entry per-queue/per-seqno 681 * @frames: list of skbs stored 682 * @reorder_time: time the packet was stored in the reorder buffer 683 */ 684 struct _iwl_mvm_reorder_buf_entry { 685 struct sk_buff_head frames; 686 unsigned long reorder_time; 687 }; 688 689 /* make this indirection to get the aligned thing */ 690 struct iwl_mvm_reorder_buf_entry { 691 struct _iwl_mvm_reorder_buf_entry e; 692 } 693 #ifndef __CHECKER__ 694 /* sparse doesn't like this construct: "bad integer constant expression" */ 695 __aligned(roundup_pow_of_two(sizeof(struct _iwl_mvm_reorder_buf_entry))) 696 #endif 697 ; 698 699 /** 700 * struct iwl_mvm_baid_data - BA session data 701 * @sta_mask: current station mask for the BAID 702 * @tid: tid of the session 703 * @baid: baid of the session 704 * @timeout: the timeout set in the addba request 705 * @entries_per_queue: # of buffers per queue, this actually gets 706 * aligned up to avoid cache line sharing between queues 707 * @last_rx: last rx jiffies, updated only if timeout passed from last update 708 * @session_timer: timer to check if BA session expired, runs at 2 * timeout 709 * @rcu_ptr: BA data RCU protected access 710 * @rcu_head: RCU head for freeing this data 711 * @mvm: mvm pointer, needed for timer context 712 * @reorder_buf: reorder buffer, allocated per queue 713 * @entries: data 714 */ 715 struct iwl_mvm_baid_data { 716 struct rcu_head rcu_head; 717 u32 sta_mask; 718 u8 tid; 719 u8 baid; 720 u16 timeout; 721 u16 entries_per_queue; 722 unsigned long last_rx; 723 struct timer_list session_timer; 724 struct iwl_mvm_baid_data __rcu **rcu_ptr; 725 struct iwl_mvm *mvm; 726 struct iwl_mvm_reorder_buffer reorder_buf[IWL_MAX_RX_HW_QUEUES]; 727 struct iwl_mvm_reorder_buf_entry entries[]; 728 }; 729 730 static inline struct iwl_mvm_baid_data * 731 iwl_mvm_baid_data_from_reorder_buf(struct iwl_mvm_reorder_buffer *buf) 732 { 733 return (void *)((u8 *)buf - 734 offsetof(struct iwl_mvm_baid_data, reorder_buf) - 735 sizeof(*buf) * buf->queue); 736 } 737 738 /* 739 * enum iwl_mvm_queue_status - queue status 740 * @IWL_MVM_QUEUE_FREE: the queue is not allocated nor reserved 741 * Basically, this means that this queue can be used for any purpose 742 * @IWL_MVM_QUEUE_RESERVED: queue is reserved but not yet in use 743 * This is the state of a queue that has been dedicated for some RATID 744 * (agg'd or not), but that hasn't yet gone through the actual enablement 745 * of iwl_mvm_enable_txq(), and therefore no traffic can go through it yet. 746 * Note that in this state there is no requirement to already know what TID 747 * should be used with this queue, it is just marked as a queue that will 748 * be used, and shouldn't be allocated to anyone else. 749 * @IWL_MVM_QUEUE_READY: queue is ready to be used 750 * This is the state of a queue that has been fully configured (including 751 * SCD pointers, etc), has a specific RA/TID assigned to it, and can be 752 * used to send traffic. 753 * @IWL_MVM_QUEUE_SHARED: queue is shared, or in a process of becoming shared 754 * This is a state in which a single queue serves more than one TID, all of 755 * which are not aggregated. Note that the queue is only associated to one 756 * RA. 757 */ 758 enum iwl_mvm_queue_status { 759 IWL_MVM_QUEUE_FREE, 760 IWL_MVM_QUEUE_RESERVED, 761 IWL_MVM_QUEUE_READY, 762 IWL_MVM_QUEUE_SHARED, 763 }; 764 765 #define IWL_MVM_DQA_QUEUE_TIMEOUT (5 * HZ) 766 #define IWL_MVM_INVALID_QUEUE 0xFFFF 767 768 #define IWL_MVM_NUM_CIPHERS 10 769 770 771 struct iwl_mvm_txq { 772 struct list_head list; 773 u16 txq_id; 774 atomic_t tx_request; 775 #define IWL_MVM_TXQ_STATE_STOP_FULL 0 776 #define IWL_MVM_TXQ_STATE_STOP_REDIRECT 1 777 #define IWL_MVM_TXQ_STATE_READY 2 778 unsigned long state; 779 }; 780 781 static inline struct iwl_mvm_txq * 782 iwl_mvm_txq_from_mac80211(struct ieee80211_txq *txq) 783 { 784 return (void *)txq->drv_priv; 785 } 786 787 static inline struct iwl_mvm_txq * 788 iwl_mvm_txq_from_tid(struct ieee80211_sta *sta, u8 tid) 789 { 790 if (tid == IWL_MAX_TID_COUNT) 791 tid = IEEE80211_NUM_TIDS; 792 793 return (void *)sta->txq[tid]->drv_priv; 794 } 795 796 /** 797 * struct iwl_mvm_tvqm_txq_info - maps TVQM hw queue to tid 798 * 799 * @sta_id: sta id 800 * @txq_tid: txq tid 801 */ 802 struct iwl_mvm_tvqm_txq_info { 803 u8 sta_id; 804 u8 txq_tid; 805 }; 806 807 struct iwl_mvm_dqa_txq_info { 808 u8 ra_sta_id; /* The RA this queue is mapped to, if exists */ 809 bool reserved; /* Is this the TXQ reserved for a STA */ 810 u8 mac80211_ac; /* The mac80211 AC this queue is mapped to */ 811 u8 txq_tid; /* The TID "owner" of this queue*/ 812 u16 tid_bitmap; /* Bitmap of the TIDs mapped to this queue */ 813 /* Timestamp for inactivation per TID of this queue */ 814 unsigned long last_frame_time[IWL_MAX_TID_COUNT + 1]; 815 enum iwl_mvm_queue_status status; 816 }; 817 818 struct ptp_data { 819 struct ptp_clock *ptp_clock; 820 struct ptp_clock_info ptp_clock_info; 821 822 struct delayed_work dwork; 823 824 /* The last GP2 reading from the hw */ 825 u32 last_gp2; 826 827 /* number of wraparounds since scale_update_adj_time_ns */ 828 u32 wrap_counter; 829 830 /* GP2 time when the scale was last updated */ 831 u32 scale_update_gp2; 832 833 /* Adjusted time when the scale was last updated in nanoseconds */ 834 u64 scale_update_adj_time_ns; 835 836 /* clock frequency offset, scaled to 65536000000 */ 837 u64 scaled_freq; 838 839 /* Delta between hardware clock and ptp clock in nanoseconds */ 840 s64 delta; 841 }; 842 843 struct iwl_time_sync_data { 844 struct sk_buff_head frame_list; 845 u8 peer_addr[ETH_ALEN]; 846 bool active; 847 }; 848 849 struct iwl_mei_scan_filter { 850 bool is_mei_limited_scan; 851 struct sk_buff_head scan_res; 852 struct work_struct scan_work; 853 }; 854 855 struct iwl_mvm { 856 /* for logger access */ 857 struct device *dev; 858 859 struct iwl_trans *trans; 860 const struct iwl_fw *fw; 861 const struct iwl_cfg *cfg; 862 struct iwl_phy_db *phy_db; 863 struct ieee80211_hw *hw; 864 865 /* for protecting access to iwl_mvm */ 866 struct mutex mutex; 867 struct list_head async_handlers_list; 868 spinlock_t async_handlers_lock; 869 struct work_struct async_handlers_wk; 870 871 struct work_struct roc_done_wk; 872 873 unsigned long init_status; 874 875 unsigned long status; 876 877 u32 queue_sync_cookie; 878 unsigned long queue_sync_state; 879 /* 880 * for beacon filtering - 881 * currently only one interface can be supported 882 */ 883 struct iwl_mvm_vif *bf_allowed_vif; 884 885 bool hw_registered; 886 bool rfkill_safe_init_done; 887 888 u8 cca_40mhz_workaround; 889 890 u32 ampdu_ref; 891 bool ampdu_toggle; 892 893 struct iwl_notif_wait_data notif_wait; 894 895 union { 896 struct mvm_statistics_rx_v3 rx_stats_v3; 897 struct mvm_statistics_rx rx_stats; 898 }; 899 900 struct { 901 u64 rx_time; 902 u64 tx_time; 903 u64 on_time_rf; 904 u64 on_time_scan; 905 } radio_stats, accu_radio_stats; 906 907 struct list_head add_stream_txqs; 908 union { 909 struct iwl_mvm_dqa_txq_info queue_info[IWL_MAX_HW_QUEUES]; 910 struct iwl_mvm_tvqm_txq_info tvqm_info[IWL_MAX_TVQM_QUEUES]; 911 }; 912 struct work_struct add_stream_wk; /* To add streams to queues */ 913 spinlock_t add_stream_lock; 914 915 const char *nvm_file_name; 916 struct iwl_nvm_data *nvm_data; 917 struct iwl_mei_nvm *mei_nvm_data; 918 struct iwl_mvm_csme_conn_info __rcu *csme_conn_info; 919 bool mei_rfkill_blocked; 920 bool mei_registered; 921 struct work_struct sap_connected_wk; 922 923 /* 924 * NVM built based on the SAP data but that we can't free even after 925 * we get ownership because it contains the cfg80211's channel. 926 */ 927 struct iwl_nvm_data *temp_nvm_data; 928 929 /* NVM sections */ 930 struct iwl_nvm_section nvm_sections[NVM_MAX_NUM_SECTIONS]; 931 932 struct iwl_fw_runtime fwrt; 933 934 /* EEPROM MAC addresses */ 935 struct mac_address addresses[IWL_MVM_MAX_ADDRESSES]; 936 937 /* data related to data path */ 938 struct iwl_rx_phy_info last_phy_info; 939 struct ieee80211_sta __rcu *fw_id_to_mac_id[IWL_MVM_STATION_COUNT_MAX]; 940 struct ieee80211_link_sta __rcu *fw_id_to_link_sta[IWL_MVM_STATION_COUNT_MAX]; 941 unsigned long fw_link_ids_map; 942 u8 rx_ba_sessions; 943 944 /* configured by mac80211 */ 945 u32 rts_threshold; 946 947 /* Scan status, cmd (pre-allocated) and auxiliary station */ 948 unsigned int scan_status; 949 size_t scan_cmd_size; 950 void *scan_cmd; 951 struct iwl_mcast_filter_cmd *mcast_filter_cmd; 952 /* For CDB this is low band scan type, for non-CDB - type. */ 953 enum iwl_mvm_scan_type scan_type; 954 enum iwl_mvm_scan_type hb_scan_type; 955 956 enum iwl_mvm_sched_scan_pass_all_states sched_scan_pass_all; 957 struct delayed_work scan_timeout_dwork; 958 959 /* max number of simultaneous scans the FW supports */ 960 unsigned int max_scans; 961 962 /* UMAC scan tracking */ 963 u32 scan_uid_status[IWL_MVM_MAX_UMAC_SCANS]; 964 965 /* start time of last scan in TSF of the mac that requested the scan */ 966 u64 scan_start; 967 968 /* the vif that requested the current scan */ 969 struct iwl_mvm_vif *scan_vif; 970 971 /* rx chain antennas set through debugfs for the scan command */ 972 u8 scan_rx_ant; 973 974 /* Internal station */ 975 struct iwl_mvm_int_sta aux_sta; 976 struct iwl_mvm_int_sta snif_sta; 977 978 bool last_ebs_successful; 979 980 u8 scan_last_antenna_idx; /* to toggle TX between antennas */ 981 u8 mgmt_last_antenna_idx; 982 983 u8 set_tx_ant; 984 u8 set_rx_ant; 985 986 /* last smart fifo state that was successfully sent to firmware */ 987 enum iwl_sf_state sf_state; 988 989 /* 990 * Leave this pointer outside the ifdef below so that it can be 991 * assigned without ifdef in the source code. 992 */ 993 struct dentry *debugfs_dir; 994 #ifdef CONFIG_IWLWIFI_DEBUGFS 995 u32 dbgfs_sram_offset, dbgfs_sram_len; 996 u32 dbgfs_prph_reg_addr; 997 bool disable_power_off; 998 bool disable_power_off_d3; 999 bool beacon_inject_active; 1000 1001 bool scan_iter_notif_enabled; 1002 1003 struct debugfs_blob_wrapper nvm_hw_blob; 1004 struct debugfs_blob_wrapper nvm_sw_blob; 1005 struct debugfs_blob_wrapper nvm_calib_blob; 1006 struct debugfs_blob_wrapper nvm_prod_blob; 1007 struct debugfs_blob_wrapper nvm_phy_sku_blob; 1008 struct debugfs_blob_wrapper nvm_reg_blob; 1009 1010 struct iwl_mvm_frame_stats drv_rx_stats; 1011 spinlock_t drv_stats_lock; 1012 u16 dbgfs_rx_phyinfo; 1013 #endif 1014 1015 struct iwl_mvm_phy_ctxt phy_ctxts[NUM_PHY_CTX]; 1016 1017 struct list_head time_event_list; 1018 spinlock_t time_event_lock; 1019 1020 /* 1021 * A bitmap indicating the index of the key in use. The firmware 1022 * can hold 16 keys at most. Reflect this fact. 1023 */ 1024 unsigned long fw_key_table[BITS_TO_LONGS(STA_KEY_MAX_NUM)]; 1025 u8 fw_key_deleted[STA_KEY_MAX_NUM]; 1026 1027 struct ieee80211_vif __rcu *vif_id_to_mac[NUM_MAC_INDEX_DRIVER]; 1028 1029 struct ieee80211_bss_conf __rcu *link_id_to_link_conf[IWL_MVM_FW_MAX_LINK_ID + 1]; 1030 1031 /* -1 for always, 0 for never, >0 for that many times */ 1032 s8 fw_restart; 1033 u8 *error_recovery_buf; 1034 1035 #ifdef CONFIG_IWLWIFI_LEDS 1036 struct led_classdev led; 1037 #endif 1038 1039 struct ieee80211_vif *p2p_device_vif; 1040 1041 #ifdef CONFIG_PM 1042 struct wiphy_wowlan_support wowlan; 1043 int gtk_ivlen, gtk_icvlen, ptk_ivlen, ptk_icvlen; 1044 1045 /* sched scan settings for net detect */ 1046 struct ieee80211_scan_ies nd_ies; 1047 struct cfg80211_match_set *nd_match_sets; 1048 int n_nd_match_sets; 1049 struct ieee80211_channel **nd_channels; 1050 int n_nd_channels; 1051 bool net_detect; 1052 u8 offload_tid; 1053 #ifdef CONFIG_IWLWIFI_DEBUGFS 1054 bool d3_wake_sysassert; 1055 bool d3_test_active; 1056 u32 d3_test_pme_ptr; 1057 struct ieee80211_vif *keep_vif; 1058 u32 last_netdetect_scans; /* no. of scans in the last net-detect wake */ 1059 #endif 1060 #endif 1061 1062 wait_queue_head_t rx_sync_waitq; 1063 1064 /* BT-Coex */ 1065 struct iwl_bt_coex_profile_notif last_bt_notif; 1066 struct iwl_bt_coex_ci_cmd last_bt_ci_cmd; 1067 1068 u8 bt_tx_prio; 1069 enum iwl_bt_force_ant_mode bt_force_ant_mode; 1070 1071 /* Aux ROC */ 1072 struct list_head aux_roc_te_list; 1073 1074 /* Thermal Throttling and CTkill */ 1075 struct iwl_mvm_tt_mgmt thermal_throttle; 1076 #ifdef CONFIG_THERMAL 1077 struct iwl_mvm_thermal_device tz_device; 1078 struct iwl_mvm_cooling_device cooling_dev; 1079 #endif 1080 1081 s32 temperature; /* Celsius */ 1082 /* 1083 * Debug option to set the NIC temperature. This option makes the 1084 * driver think this is the actual NIC temperature, and ignore the 1085 * real temperature that is received from the fw 1086 */ 1087 bool temperature_test; /* Debug test temperature is enabled */ 1088 1089 bool fw_static_smps_request; 1090 1091 unsigned long bt_coex_last_tcm_ts; 1092 struct iwl_mvm_tcm tcm; 1093 1094 u8 uapsd_noagg_bssid_write_idx; 1095 struct mac_address uapsd_noagg_bssids[IWL_MVM_UAPSD_NOAGG_BSSIDS_NUM] 1096 __aligned(2); 1097 1098 struct iwl_time_quota_cmd last_quota_cmd; 1099 1100 #ifdef CONFIG_NL80211_TESTMODE 1101 u32 noa_duration; 1102 struct ieee80211_vif *noa_vif; 1103 #endif 1104 1105 /* Tx queues */ 1106 u16 aux_queue; 1107 u16 snif_queue; 1108 u16 probe_queue; 1109 u16 p2p_dev_queue; 1110 1111 /* Indicate if device power save is allowed */ 1112 u8 ps_disabled; /* u8 instead of bool to ease debugfs_create_* usage */ 1113 /* Indicate if 32Khz external clock is valid */ 1114 u32 ext_clock_valid; 1115 1116 /* This vif used by CSME to send / receive traffic */ 1117 struct ieee80211_vif *csme_vif; 1118 struct ieee80211_vif __rcu *csa_vif; 1119 struct ieee80211_vif __rcu *csa_tx_blocked_vif; 1120 u8 csa_tx_block_bcn_timeout; 1121 1122 /* system time of last beacon (for AP/GO interface) */ 1123 u32 ap_last_beacon_gp2; 1124 1125 /* indicates that we transmitted the last beacon */ 1126 bool ibss_manager; 1127 1128 bool lar_regdom_set; 1129 enum iwl_mcc_source mcc_src; 1130 1131 /* TDLS channel switch data */ 1132 struct { 1133 struct delayed_work dwork; 1134 enum iwl_mvm_tdls_cs_state state; 1135 1136 /* 1137 * Current cs sta - might be different from periodic cs peer 1138 * station. Value is meaningless when the cs-state is idle. 1139 */ 1140 u8 cur_sta_id; 1141 1142 /* TDLS periodic channel-switch peer */ 1143 struct { 1144 u8 sta_id; 1145 u8 op_class; 1146 bool initiator; /* are we the link initiator */ 1147 struct cfg80211_chan_def chandef; 1148 struct sk_buff *skb; /* ch sw template */ 1149 u32 ch_sw_tm_ie; 1150 1151 /* timestamp of last ch-sw request sent (GP2 time) */ 1152 u32 sent_timestamp; 1153 } peer; 1154 } tdls_cs; 1155 1156 1157 u32 ciphers[IWL_MVM_NUM_CIPHERS]; 1158 1159 struct cfg80211_ftm_responder_stats ftm_resp_stats; 1160 struct { 1161 struct cfg80211_pmsr_request *req; 1162 struct wireless_dev *req_wdev; 1163 struct list_head loc_list; 1164 int responses[IWL_MVM_TOF_MAX_APS]; 1165 struct { 1166 struct list_head resp; 1167 } smooth; 1168 struct list_head pasn_list; 1169 } ftm_initiator; 1170 1171 struct list_head resp_pasn_list; 1172 1173 struct ptp_data ptp_data; 1174 1175 struct { 1176 u8 range_resp; 1177 } cmd_ver; 1178 1179 struct ieee80211_vif *nan_vif; 1180 struct iwl_mvm_baid_data __rcu *baid_map[IWL_MAX_BAID]; 1181 1182 /* 1183 * Drop beacons from other APs in AP mode when there are no connected 1184 * clients. 1185 */ 1186 bool drop_bcn_ap_mode; 1187 1188 struct delayed_work cs_tx_unblock_dwork; 1189 1190 /* does a monitor vif exist (only one can exist hence bool) */ 1191 bool monitor_on; 1192 /* 1193 * primary channel position relative to he whole bandwidth, 1194 * in steps of 80 MHz 1195 */ 1196 u8 monitor_p80; 1197 1198 /* sniffer data to include in radiotap */ 1199 __le16 cur_aid; 1200 u8 cur_bssid[ETH_ALEN]; 1201 1202 #ifdef CONFIG_ACPI 1203 struct iwl_phy_specific_cfg phy_filters; 1204 #endif 1205 1206 unsigned long last_6ghz_passive_scan_jiffies; 1207 unsigned long last_reset_or_resume_time_jiffies; 1208 1209 bool sta_remove_requires_queue_remove; 1210 bool mld_api_is_used; 1211 1212 bool pldr_sync; 1213 1214 struct iwl_time_sync_data time_sync; 1215 1216 struct iwl_mei_scan_filter mei_scan_filter; 1217 }; 1218 1219 /* Extract MVM priv from op_mode and _hw */ 1220 #define IWL_OP_MODE_GET_MVM(_iwl_op_mode) \ 1221 ((struct iwl_mvm *)(_iwl_op_mode)->op_mode_specific) 1222 1223 #define IWL_MAC80211_GET_MVM(_hw) \ 1224 IWL_OP_MODE_GET_MVM((struct iwl_op_mode *)((_hw)->priv)) 1225 1226 /** 1227 * enum iwl_mvm_status - MVM status bits 1228 * @IWL_MVM_STATUS_HW_RFKILL: HW RF-kill is asserted 1229 * @IWL_MVM_STATUS_HW_CTKILL: CT-kill is active 1230 * @IWL_MVM_STATUS_ROC_RUNNING: remain-on-channel is running 1231 * @IWL_MVM_STATUS_HW_RESTART_REQUESTED: HW restart was requested 1232 * @IWL_MVM_STATUS_IN_HW_RESTART: HW restart is active 1233 * @IWL_MVM_STATUS_ROC_AUX_RUNNING: AUX remain-on-channel is running 1234 * @IWL_MVM_STATUS_FIRMWARE_RUNNING: firmware is running 1235 * @IWL_MVM_STATUS_NEED_FLUSH_P2P: need to flush P2P bcast STA 1236 * @IWL_MVM_STATUS_IN_D3: in D3 (or at least about to go into it) 1237 * @IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE: suppress one error log 1238 * if this is set, when intentionally triggered 1239 * @IWL_MVM_STATUS_STARTING: starting mac, 1240 * used to disable restart flow while in STARTING state 1241 */ 1242 enum iwl_mvm_status { 1243 IWL_MVM_STATUS_HW_RFKILL, 1244 IWL_MVM_STATUS_HW_CTKILL, 1245 IWL_MVM_STATUS_ROC_RUNNING, 1246 IWL_MVM_STATUS_HW_RESTART_REQUESTED, 1247 IWL_MVM_STATUS_IN_HW_RESTART, 1248 IWL_MVM_STATUS_ROC_AUX_RUNNING, 1249 IWL_MVM_STATUS_FIRMWARE_RUNNING, 1250 IWL_MVM_STATUS_NEED_FLUSH_P2P, 1251 IWL_MVM_STATUS_IN_D3, 1252 IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE, 1253 IWL_MVM_STATUS_STARTING, 1254 }; 1255 1256 struct iwl_mvm_csme_conn_info { 1257 struct rcu_head rcu_head; 1258 struct iwl_mei_conn_info conn_info; 1259 }; 1260 1261 /* Keep track of completed init configuration */ 1262 enum iwl_mvm_init_status { 1263 IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE = BIT(0), 1264 IWL_MVM_INIT_STATUS_LEDS_INIT_COMPLETE = BIT(1), 1265 }; 1266 1267 static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm) 1268 { 1269 return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status) || 1270 test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status); 1271 } 1272 1273 static inline bool iwl_mvm_is_radio_hw_killed(struct iwl_mvm *mvm) 1274 { 1275 return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status); 1276 } 1277 1278 static inline bool iwl_mvm_firmware_running(struct iwl_mvm *mvm) 1279 { 1280 return test_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status); 1281 } 1282 1283 /* Must be called with rcu_read_lock() held and it can only be 1284 * released when mvmsta is not needed anymore. 1285 */ 1286 static inline struct iwl_mvm_sta * 1287 iwl_mvm_sta_from_staid_rcu(struct iwl_mvm *mvm, u8 sta_id) 1288 { 1289 struct ieee80211_sta *sta; 1290 1291 if (sta_id >= mvm->fw->ucode_capa.num_stations) 1292 return NULL; 1293 1294 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); 1295 1296 /* This can happen if the station has been removed right now */ 1297 if (IS_ERR_OR_NULL(sta)) 1298 return NULL; 1299 1300 return iwl_mvm_sta_from_mac80211(sta); 1301 } 1302 1303 static inline struct iwl_mvm_sta * 1304 iwl_mvm_sta_from_staid_protected(struct iwl_mvm *mvm, u8 sta_id) 1305 { 1306 struct ieee80211_sta *sta; 1307 1308 if (sta_id >= mvm->fw->ucode_capa.num_stations) 1309 return NULL; 1310 1311 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id], 1312 lockdep_is_held(&mvm->mutex)); 1313 1314 /* This can happen if the station has been removed right now */ 1315 if (IS_ERR_OR_NULL(sta)) 1316 return NULL; 1317 1318 return iwl_mvm_sta_from_mac80211(sta); 1319 } 1320 1321 static inline struct ieee80211_vif * 1322 iwl_mvm_rcu_dereference_vif_id(struct iwl_mvm *mvm, u8 vif_id, bool rcu) 1323 { 1324 if (WARN_ON(vif_id >= ARRAY_SIZE(mvm->vif_id_to_mac))) 1325 return NULL; 1326 1327 if (rcu) 1328 return rcu_dereference(mvm->vif_id_to_mac[vif_id]); 1329 1330 return rcu_dereference_protected(mvm->vif_id_to_mac[vif_id], 1331 lockdep_is_held(&mvm->mutex)); 1332 } 1333 1334 static inline struct ieee80211_bss_conf * 1335 iwl_mvm_rcu_fw_link_id_to_link_conf(struct iwl_mvm *mvm, u8 link_id, bool rcu) 1336 { 1337 if (WARN_ON(link_id >= ARRAY_SIZE(mvm->link_id_to_link_conf))) 1338 return NULL; 1339 1340 if (rcu) 1341 return rcu_dereference(mvm->link_id_to_link_conf[link_id]); 1342 1343 return rcu_dereference_protected(mvm->link_id_to_link_conf[link_id], 1344 lockdep_is_held(&mvm->mutex)); 1345 } 1346 1347 static inline bool iwl_mvm_is_adaptive_dwell_supported(struct iwl_mvm *mvm) 1348 { 1349 return fw_has_api(&mvm->fw->ucode_capa, 1350 IWL_UCODE_TLV_API_ADAPTIVE_DWELL); 1351 } 1352 1353 static inline bool iwl_mvm_is_adaptive_dwell_v2_supported(struct iwl_mvm *mvm) 1354 { 1355 return fw_has_api(&mvm->fw->ucode_capa, 1356 IWL_UCODE_TLV_API_ADAPTIVE_DWELL_V2); 1357 } 1358 1359 static inline bool iwl_mvm_is_adwell_hb_ap_num_supported(struct iwl_mvm *mvm) 1360 { 1361 return fw_has_api(&mvm->fw->ucode_capa, 1362 IWL_UCODE_TLV_API_ADWELL_HB_DEF_N_AP); 1363 } 1364 1365 static inline bool iwl_mvm_is_oce_supported(struct iwl_mvm *mvm) 1366 { 1367 /* OCE should never be enabled for LMAC scan FWs */ 1368 return fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_OCE); 1369 } 1370 1371 static inline bool iwl_mvm_is_frag_ebs_supported(struct iwl_mvm *mvm) 1372 { 1373 return fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_FRAG_EBS); 1374 } 1375 1376 static inline bool iwl_mvm_is_short_beacon_notif_supported(struct iwl_mvm *mvm) 1377 { 1378 return fw_has_api(&mvm->fw->ucode_capa, 1379 IWL_UCODE_TLV_API_SHORT_BEACON_NOTIF); 1380 } 1381 1382 static inline bool iwl_mvm_is_dqa_data_queue(struct iwl_mvm *mvm, u8 queue) 1383 { 1384 return (queue >= IWL_MVM_DQA_MIN_DATA_QUEUE) && 1385 (queue <= IWL_MVM_DQA_MAX_DATA_QUEUE); 1386 } 1387 1388 static inline bool iwl_mvm_is_dqa_mgmt_queue(struct iwl_mvm *mvm, u8 queue) 1389 { 1390 return (queue >= IWL_MVM_DQA_MIN_MGMT_QUEUE) && 1391 (queue <= IWL_MVM_DQA_MAX_MGMT_QUEUE); 1392 } 1393 1394 static inline bool iwl_mvm_is_lar_supported(struct iwl_mvm *mvm) 1395 { 1396 bool nvm_lar = mvm->nvm_data->lar_enabled; 1397 bool tlv_lar = fw_has_capa(&mvm->fw->ucode_capa, 1398 IWL_UCODE_TLV_CAPA_LAR_SUPPORT); 1399 1400 /* 1401 * Enable LAR only if it is supported by the FW (TLV) && 1402 * enabled in the NVM 1403 */ 1404 if (mvm->cfg->nvm_type == IWL_NVM_EXT) 1405 return nvm_lar && tlv_lar; 1406 else 1407 return tlv_lar; 1408 } 1409 1410 static inline bool iwl_mvm_is_wifi_mcc_supported(struct iwl_mvm *mvm) 1411 { 1412 return fw_has_api(&mvm->fw->ucode_capa, 1413 IWL_UCODE_TLV_API_WIFI_MCC_UPDATE) || 1414 fw_has_capa(&mvm->fw->ucode_capa, 1415 IWL_UCODE_TLV_CAPA_LAR_MULTI_MCC); 1416 } 1417 1418 static inline bool iwl_mvm_bt_is_rrc_supported(struct iwl_mvm *mvm) 1419 { 1420 return fw_has_capa(&mvm->fw->ucode_capa, 1421 IWL_UCODE_TLV_CAPA_BT_COEX_RRC) && 1422 IWL_MVM_BT_COEX_RRC; 1423 } 1424 1425 static inline bool iwl_mvm_is_csum_supported(struct iwl_mvm *mvm) 1426 { 1427 return fw_has_capa(&mvm->fw->ucode_capa, 1428 IWL_UCODE_TLV_CAPA_CSUM_SUPPORT) && 1429 !IWL_MVM_HW_CSUM_DISABLE; 1430 } 1431 1432 static inline bool iwl_mvm_is_mplut_supported(struct iwl_mvm *mvm) 1433 { 1434 return fw_has_capa(&mvm->fw->ucode_capa, 1435 IWL_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT) && 1436 IWL_MVM_BT_COEX_MPLUT; 1437 } 1438 1439 static inline 1440 bool iwl_mvm_is_p2p_scm_uapsd_supported(struct iwl_mvm *mvm) 1441 { 1442 return fw_has_capa(&mvm->fw->ucode_capa, 1443 IWL_UCODE_TLV_CAPA_P2P_SCM_UAPSD) && 1444 !(iwlwifi_mod_params.uapsd_disable & 1445 IWL_DISABLE_UAPSD_P2P_CLIENT); 1446 } 1447 1448 static inline bool iwl_mvm_has_new_rx_api(struct iwl_mvm *mvm) 1449 { 1450 return fw_has_capa(&mvm->fw->ucode_capa, 1451 IWL_UCODE_TLV_CAPA_MULTI_QUEUE_RX_SUPPORT); 1452 } 1453 1454 static inline bool iwl_mvm_has_mld_api(const struct iwl_fw *fw) 1455 { 1456 return fw_has_capa(&fw->ucode_capa, 1457 IWL_UCODE_TLV_CAPA_MLD_API_SUPPORT); 1458 } 1459 1460 static inline bool iwl_mvm_has_new_station_api(const struct iwl_fw *fw) 1461 { 1462 return iwl_mvm_has_mld_api(fw) || 1463 iwl_fw_lookup_cmd_ver(fw, ADD_STA, 0) >= 12; 1464 } 1465 1466 static inline bool iwl_mvm_has_new_tx_api(struct iwl_mvm *mvm) 1467 { 1468 /* TODO - replace with TLV once defined */ 1469 return mvm->trans->trans_cfg->gen2; 1470 } 1471 1472 static inline bool iwl_mvm_has_unified_ucode(struct iwl_mvm *mvm) 1473 { 1474 /* TODO - better define this */ 1475 return mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_22000; 1476 } 1477 1478 static inline bool iwl_mvm_is_cdb_supported(struct iwl_mvm *mvm) 1479 { 1480 /* 1481 * TODO: 1482 * The issue of how to determine CDB APIs and usage is still not fully 1483 * defined. 1484 * There is a compilation for CDB and non-CDB FW, but there may 1485 * be also runtime check. 1486 * For now there is a TLV for checking compilation mode, but a 1487 * runtime check will also have to be here - once defined. 1488 */ 1489 return fw_has_capa(&mvm->fw->ucode_capa, 1490 IWL_UCODE_TLV_CAPA_CDB_SUPPORT); 1491 } 1492 1493 static inline bool iwl_mvm_cdb_scan_api(struct iwl_mvm *mvm) 1494 { 1495 /* 1496 * TODO: should this be the same as iwl_mvm_is_cdb_supported()? 1497 * but then there's a little bit of code in scan that won't make 1498 * any sense... 1499 */ 1500 return mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_22000; 1501 } 1502 1503 static inline bool iwl_mvm_is_scan_ext_chan_supported(struct iwl_mvm *mvm) 1504 { 1505 return fw_has_api(&mvm->fw->ucode_capa, 1506 IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER); 1507 } 1508 1509 1510 static inline bool iwl_mvm_is_reduced_config_scan_supported(struct iwl_mvm *mvm) 1511 { 1512 return fw_has_api(&mvm->fw->ucode_capa, 1513 IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG); 1514 } 1515 1516 static inline bool iwl_mvm_is_band_in_rx_supported(struct iwl_mvm *mvm) 1517 { 1518 return fw_has_api(&mvm->fw->ucode_capa, 1519 IWL_UCODE_TLV_API_BAND_IN_RX_DATA); 1520 } 1521 1522 static inline bool iwl_mvm_has_new_rx_stats_api(struct iwl_mvm *mvm) 1523 { 1524 return fw_has_api(&mvm->fw->ucode_capa, 1525 IWL_UCODE_TLV_API_NEW_RX_STATS); 1526 } 1527 1528 static inline bool iwl_mvm_has_quota_low_latency(struct iwl_mvm *mvm) 1529 { 1530 return fw_has_api(&mvm->fw->ucode_capa, 1531 IWL_UCODE_TLV_API_QUOTA_LOW_LATENCY); 1532 } 1533 1534 static inline bool iwl_mvm_has_tlc_offload(const struct iwl_mvm *mvm) 1535 { 1536 return fw_has_capa(&mvm->fw->ucode_capa, 1537 IWL_UCODE_TLV_CAPA_TLC_OFFLOAD); 1538 } 1539 1540 static inline struct agg_tx_status * 1541 iwl_mvm_get_agg_status(struct iwl_mvm *mvm, void *tx_resp) 1542 { 1543 if (iwl_mvm_has_new_tx_api(mvm)) 1544 return &((struct iwl_mvm_tx_resp *)tx_resp)->status; 1545 else 1546 return ((struct iwl_mvm_tx_resp_v3 *)tx_resp)->status; 1547 } 1548 1549 static inline bool iwl_mvm_is_tt_in_fw(struct iwl_mvm *mvm) 1550 { 1551 /* these two TLV are redundant since the responsibility to CT-kill by 1552 * FW happens only after we send at least one command of 1553 * temperature THs report. 1554 */ 1555 return fw_has_capa(&mvm->fw->ucode_capa, 1556 IWL_UCODE_TLV_CAPA_CT_KILL_BY_FW) && 1557 fw_has_capa(&mvm->fw->ucode_capa, 1558 IWL_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT); 1559 } 1560 1561 static inline bool iwl_mvm_is_ctdp_supported(struct iwl_mvm *mvm) 1562 { 1563 return fw_has_capa(&mvm->fw->ucode_capa, 1564 IWL_UCODE_TLV_CAPA_CTDP_SUPPORT); 1565 } 1566 1567 static inline bool iwl_mvm_is_esr_supported(struct iwl_trans *trans) 1568 { 1569 if ((CSR_HW_RFID_TYPE(trans->hw_rf_id) == IWL_CFG_RF_TYPE_FM) && 1570 !CSR_HW_RFID_IS_CDB(trans->hw_rf_id)) 1571 /* Step A doesn't support eSR */ 1572 return CSR_HW_RFID_STEP(trans->hw_rf_id); 1573 1574 return false; 1575 } 1576 1577 static inline int iwl_mvm_max_active_links(struct iwl_mvm *mvm, 1578 struct ieee80211_vif *vif) 1579 { 1580 struct iwl_trans *trans = mvm->fwrt.trans; 1581 1582 if (vif->type == NL80211_IFTYPE_AP) 1583 return mvm->fw->ucode_capa.num_beacons; 1584 1585 if (iwl_mvm_is_esr_supported(trans) || 1586 (CSR_HW_RFID_TYPE(trans->hw_rf_id) == IWL_CFG_RF_TYPE_FM && 1587 CSR_HW_RFID_IS_CDB(trans->hw_rf_id))) 1588 return IWL_MVM_FW_MAX_ACTIVE_LINKS_NUM; 1589 1590 return 1; 1591 } 1592 1593 extern const u8 iwl_mvm_ac_to_tx_fifo[]; 1594 extern const u8 iwl_mvm_ac_to_gen2_tx_fifo[]; 1595 1596 static inline u8 iwl_mvm_mac_ac_to_tx_fifo(struct iwl_mvm *mvm, 1597 enum ieee80211_ac_numbers ac) 1598 { 1599 return iwl_mvm_has_new_tx_api(mvm) ? 1600 iwl_mvm_ac_to_gen2_tx_fifo[ac] : iwl_mvm_ac_to_tx_fifo[ac]; 1601 } 1602 1603 struct iwl_rate_info { 1604 u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */ 1605 u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */ 1606 u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */ 1607 u8 plcp_mimo3; /* uCode API: IWL_RATE_MIMO3_6M_PLCP, etc. */ 1608 u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */ 1609 }; 1610 1611 void __iwl_mvm_mac_stop(struct iwl_mvm *mvm); 1612 int __iwl_mvm_mac_start(struct iwl_mvm *mvm); 1613 1614 /****************** 1615 * MVM Methods 1616 ******************/ 1617 /* uCode */ 1618 int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm); 1619 1620 /* Utils */ 1621 int iwl_mvm_legacy_hw_idx_to_mac80211_idx(u32 rate_n_flags, 1622 enum nl80211_band band); 1623 int iwl_mvm_legacy_rate_to_mac80211_idx(u32 rate_n_flags, 1624 enum nl80211_band band); 1625 void iwl_mvm_hwrate_to_tx_rate(u32 rate_n_flags, 1626 enum nl80211_band band, 1627 struct ieee80211_tx_rate *r); 1628 void iwl_mvm_hwrate_to_tx_rate_v1(u32 rate_n_flags, 1629 enum nl80211_band band, 1630 struct ieee80211_tx_rate *r); 1631 u8 iwl_mvm_mac80211_idx_to_hwrate(const struct iwl_fw *fw, int rate_idx); 1632 u8 iwl_mvm_mac80211_ac_to_ucode_ac(enum ieee80211_ac_numbers ac); 1633 bool iwl_mvm_is_nic_ack_enabled(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1634 1635 static inline void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm) 1636 { 1637 iwl_fwrt_dump_error_logs(&mvm->fwrt); 1638 } 1639 1640 u8 first_antenna(u8 mask); 1641 u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx); 1642 void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, int clock_type, u32 *gp2, 1643 u64 *boottime, ktime_t *realtime); 1644 u32 iwl_mvm_get_systime(struct iwl_mvm *mvm); 1645 1646 /* Tx / Host Commands */ 1647 int __must_check iwl_mvm_send_cmd(struct iwl_mvm *mvm, 1648 struct iwl_host_cmd *cmd); 1649 int __must_check iwl_mvm_send_cmd_pdu(struct iwl_mvm *mvm, u32 id, 1650 u32 flags, u16 len, const void *data); 1651 int __must_check iwl_mvm_send_cmd_status(struct iwl_mvm *mvm, 1652 struct iwl_host_cmd *cmd, 1653 u32 *status); 1654 int __must_check iwl_mvm_send_cmd_pdu_status(struct iwl_mvm *mvm, u32 id, 1655 u16 len, const void *data, 1656 u32 *status); 1657 int iwl_mvm_tx_skb_sta(struct iwl_mvm *mvm, struct sk_buff *skb, 1658 struct ieee80211_sta *sta); 1659 int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb); 1660 void iwl_mvm_set_tx_cmd(struct iwl_mvm *mvm, struct sk_buff *skb, 1661 struct iwl_tx_cmd *tx_cmd, 1662 struct ieee80211_tx_info *info, u8 sta_id); 1663 void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm, struct iwl_tx_cmd *tx_cmd, 1664 struct ieee80211_tx_info *info, 1665 struct ieee80211_sta *sta, __le16 fc); 1666 void iwl_mvm_mac_itxq_xmit(struct ieee80211_hw *hw, struct ieee80211_txq *txq); 1667 unsigned int iwl_mvm_max_amsdu_size(struct iwl_mvm *mvm, 1668 struct ieee80211_sta *sta, 1669 unsigned int tid); 1670 1671 #ifdef CONFIG_IWLWIFI_DEBUG 1672 const char *iwl_mvm_get_tx_fail_reason(u32 status); 1673 #else 1674 static inline const char *iwl_mvm_get_tx_fail_reason(u32 status) { return ""; } 1675 #endif 1676 int iwl_mvm_flush_tx_path(struct iwl_mvm *mvm, u32 tfd_msk); 1677 int iwl_mvm_flush_sta(struct iwl_mvm *mvm, void *sta, bool internal); 1678 int iwl_mvm_flush_sta_tids(struct iwl_mvm *mvm, u32 sta_id, u16 tids); 1679 1680 /* Utils to extract sta related data */ 1681 __le32 iwl_mvm_get_sta_htc_flags(struct ieee80211_sta *sta, 1682 struct ieee80211_link_sta *link_sta); 1683 u8 iwl_mvm_get_sta_uapsd_acs(struct ieee80211_sta *sta); 1684 u32 iwl_mvm_get_sta_ampdu_dens(struct ieee80211_link_sta *link_sta, 1685 struct ieee80211_bss_conf *link_conf, 1686 u32 *_agg_size); 1687 int iwl_mvm_set_sta_pkt_ext(struct iwl_mvm *mvm, 1688 struct ieee80211_link_sta *link_sta, 1689 struct iwl_he_pkt_ext_v2 *pkt_ext); 1690 1691 void iwl_mvm_async_handlers_purge(struct iwl_mvm *mvm); 1692 1693 static inline void iwl_mvm_set_tx_cmd_ccmp(struct ieee80211_tx_info *info, 1694 struct iwl_tx_cmd *tx_cmd) 1695 { 1696 struct ieee80211_key_conf *keyconf = info->control.hw_key; 1697 1698 tx_cmd->sec_ctl = TX_CMD_SEC_CCM; 1699 memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); 1700 } 1701 1702 static inline void iwl_mvm_wait_for_async_handlers(struct iwl_mvm *mvm) 1703 { 1704 flush_work(&mvm->async_handlers_wk); 1705 } 1706 1707 /* Statistics */ 1708 void iwl_mvm_handle_rx_statistics(struct iwl_mvm *mvm, 1709 struct iwl_rx_packet *pkt); 1710 void iwl_mvm_rx_statistics(struct iwl_mvm *mvm, 1711 struct iwl_rx_cmd_buffer *rxb); 1712 int iwl_mvm_request_statistics(struct iwl_mvm *mvm, bool clear); 1713 void iwl_mvm_accu_radio_stats(struct iwl_mvm *mvm); 1714 1715 /* NVM */ 1716 int iwl_nvm_init(struct iwl_mvm *mvm); 1717 int iwl_mvm_load_nvm_to_nic(struct iwl_mvm *mvm); 1718 1719 static inline u8 iwl_mvm_get_valid_tx_ant(struct iwl_mvm *mvm) 1720 { 1721 u8 tx_ant = mvm->fw->valid_tx_ant; 1722 1723 if (mvm->nvm_data && mvm->nvm_data->valid_tx_ant) 1724 tx_ant &= mvm->nvm_data->valid_tx_ant; 1725 1726 if (mvm->set_tx_ant) 1727 tx_ant &= mvm->set_tx_ant; 1728 1729 return tx_ant; 1730 } 1731 1732 static inline u8 iwl_mvm_get_valid_rx_ant(struct iwl_mvm *mvm) 1733 { 1734 u8 rx_ant = mvm->fw->valid_tx_ant; 1735 1736 if (mvm->nvm_data && mvm->nvm_data->valid_rx_ant) 1737 rx_ant &= mvm->nvm_data->valid_tx_ant; 1738 1739 if (mvm->set_rx_ant) 1740 rx_ant &= mvm->set_rx_ant; 1741 1742 return rx_ant; 1743 1744 } 1745 1746 static inline void iwl_mvm_toggle_tx_ant(struct iwl_mvm *mvm, u8 *ant) 1747 { 1748 *ant = iwl_mvm_next_antenna(mvm, iwl_mvm_get_valid_tx_ant(mvm), *ant); 1749 } 1750 1751 static inline u32 iwl_mvm_get_phy_config(struct iwl_mvm *mvm) 1752 { 1753 u32 phy_config = ~(FW_PHY_CFG_TX_CHAIN | 1754 FW_PHY_CFG_RX_CHAIN); 1755 u32 valid_rx_ant = iwl_mvm_get_valid_rx_ant(mvm); 1756 u32 valid_tx_ant = iwl_mvm_get_valid_tx_ant(mvm); 1757 1758 phy_config |= valid_tx_ant << FW_PHY_CFG_TX_CHAIN_POS | 1759 valid_rx_ant << FW_PHY_CFG_RX_CHAIN_POS; 1760 1761 return mvm->fw->phy_config & phy_config; 1762 } 1763 1764 int iwl_mvm_up(struct iwl_mvm *mvm); 1765 int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm); 1766 1767 int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm); 1768 1769 /* 1770 * FW notifications / CMD responses handlers 1771 * Convention: iwl_mvm_rx_<NAME OF THE CMD> 1772 */ 1773 void iwl_mvm_rx_mq(struct iwl_op_mode *op_mode, 1774 struct napi_struct *napi, 1775 struct iwl_rx_cmd_buffer *rxb); 1776 void iwl_mvm_rx_rx_phy_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1777 void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi, 1778 struct iwl_rx_cmd_buffer *rxb); 1779 void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi, 1780 struct iwl_rx_cmd_buffer *rxb, int queue); 1781 void iwl_mvm_rx_monitor_no_data(struct iwl_mvm *mvm, struct napi_struct *napi, 1782 struct iwl_rx_cmd_buffer *rxb, int queue); 1783 void iwl_mvm_rx_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi, 1784 struct iwl_rx_cmd_buffer *rxb, int queue); 1785 void iwl_mvm_rx_bar_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi, 1786 struct iwl_rx_cmd_buffer *rxb, int queue); 1787 void iwl_mvm_rx_queue_notif(struct iwl_mvm *mvm, struct napi_struct *napi, 1788 struct iwl_rx_cmd_buffer *rxb, int queue); 1789 void iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1790 void iwl_mvm_mfu_assert_dump_notif(struct iwl_mvm *mvm, 1791 struct iwl_rx_cmd_buffer *rxb); 1792 void iwl_mvm_send_recovery_cmd(struct iwl_mvm *mvm, u32 flags); 1793 void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1794 void iwl_mvm_rx_ant_coupling_notif(struct iwl_mvm *mvm, 1795 struct iwl_rx_cmd_buffer *rxb); 1796 void iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1797 void iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm, 1798 struct iwl_rx_cmd_buffer *rxb); 1799 void iwl_mvm_rx_shared_mem_cfg_notif(struct iwl_mvm *mvm, 1800 struct iwl_rx_cmd_buffer *rxb); 1801 1802 /* MVM PHY */ 1803 struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm); 1804 int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt, 1805 struct cfg80211_chan_def *chandef, 1806 u8 chains_static, u8 chains_dynamic); 1807 int iwl_mvm_phy_ctxt_changed(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt, 1808 struct cfg80211_chan_def *chandef, 1809 u8 chains_static, u8 chains_dynamic); 1810 void iwl_mvm_phy_ctxt_ref(struct iwl_mvm *mvm, 1811 struct iwl_mvm_phy_ctxt *ctxt); 1812 void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm, 1813 struct iwl_mvm_phy_ctxt *ctxt); 1814 int iwl_mvm_phy_ctx_count(struct iwl_mvm *mvm); 1815 u8 iwl_mvm_get_channel_width(struct cfg80211_chan_def *chandef); 1816 u8 iwl_mvm_get_ctrl_pos(struct cfg80211_chan_def *chandef); 1817 int iwl_mvm_phy_send_rlc(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt, 1818 u8 chains_static, u8 chains_dynamic); 1819 1820 /* MAC (virtual interface) programming */ 1821 1822 void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm, 1823 struct ieee80211_vif *vif); 1824 void iwl_mvm_set_fw_basic_rates(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1825 struct ieee80211_bss_conf *link_conf, 1826 __le32 *cck_rates, __le32 *ofdm_rates); 1827 void iwl_mvm_set_fw_protection_flags(struct iwl_mvm *mvm, 1828 struct ieee80211_vif *vif, 1829 struct ieee80211_bss_conf *link_conf, 1830 __le32 *protection_flags, u32 ht_flag, 1831 u32 tgg_flag); 1832 void iwl_mvm_set_fw_qos_params(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1833 struct ieee80211_bss_conf *link_conf, 1834 struct iwl_ac_qos *ac, __le32 *qos_flags); 1835 bool iwl_mvm_set_fw_mu_edca_params(struct iwl_mvm *mvm, 1836 const struct iwl_mvm_vif_link_info *link_info, 1837 struct iwl_he_backoff_conf *trig_based_txf); 1838 void iwl_mvm_set_fw_dtim_tbtt(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1839 struct ieee80211_bss_conf *link_conf, 1840 __le64 *dtim_tsf, __le32 *dtim_time, 1841 __le32 *assoc_beacon_arrive_time); 1842 __le32 iwl_mac_ctxt_p2p_dev_has_extended_disc(struct iwl_mvm *mvm, 1843 struct ieee80211_vif *vif); 1844 void iwl_mvm_mac_ctxt_cmd_ap_set_filter_flags(struct iwl_mvm *mvm, 1845 struct iwl_mvm_vif *mvmvif, 1846 __le32 *filter_flags, 1847 int accept_probe_req_flag, 1848 int accept_beacon_flag); 1849 int iwl_mvm_get_mac_type(struct ieee80211_vif *vif); 1850 __le32 iwl_mvm_mac_ctxt_cmd_p2p_sta_get_oppps_ctwin(struct iwl_mvm *mvm, 1851 struct ieee80211_vif *vif); 1852 u32 iwl_mvm_mac_ctxt_cmd_sta_get_twt_policy(struct iwl_mvm *mvm, 1853 struct ieee80211_vif *vif); 1854 int iwl_mvm_mld_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1855 int iwl_mvm_mld_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1856 bool force_assoc_off); 1857 int iwl_mvm_mld_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1858 int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1859 int iwl_mvm_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1860 int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1861 bool force_assoc_off, const u8 *bssid_override); 1862 int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1863 int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm, 1864 struct ieee80211_vif *vif, 1865 struct ieee80211_bss_conf *link_conf); 1866 int iwl_mvm_mac_ctxt_send_beacon_cmd(struct iwl_mvm *mvm, 1867 struct sk_buff *beacon, 1868 void *data, int len); 1869 u8 iwl_mvm_mac_ctxt_get_beacon_rate(struct iwl_mvm *mvm, 1870 struct ieee80211_tx_info *info, 1871 struct ieee80211_vif *vif); 1872 u8 iwl_mvm_mac_ctxt_get_lowest_rate(struct iwl_mvm *mvm, 1873 struct ieee80211_tx_info *info, 1874 struct ieee80211_vif *vif); 1875 u16 iwl_mvm_mac_ctxt_get_beacon_flags(const struct iwl_fw *fw, 1876 u8 rate_idx); 1877 void iwl_mvm_mac_ctxt_set_tim(struct iwl_mvm *mvm, 1878 __le32 *tim_index, __le32 *tim_size, 1879 u8 *beacon, u32 frame_size); 1880 void iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm, 1881 struct iwl_rx_cmd_buffer *rxb); 1882 void iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm, 1883 struct iwl_rx_cmd_buffer *rxb); 1884 void iwl_mvm_rx_stored_beacon_notif(struct iwl_mvm *mvm, 1885 struct iwl_rx_cmd_buffer *rxb); 1886 void iwl_mvm_mu_mimo_grp_notif(struct iwl_mvm *mvm, 1887 struct iwl_rx_cmd_buffer *rxb); 1888 void iwl_mvm_sta_pm_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1889 void iwl_mvm_window_status_notif(struct iwl_mvm *mvm, 1890 struct iwl_rx_cmd_buffer *rxb); 1891 void iwl_mvm_mac_ctxt_recalc_tsf_id(struct iwl_mvm *mvm, 1892 struct ieee80211_vif *vif); 1893 void iwl_mvm_probe_resp_data_notif(struct iwl_mvm *mvm, 1894 struct iwl_rx_cmd_buffer *rxb); 1895 void iwl_mvm_rx_missed_vap_notif(struct iwl_mvm *mvm, 1896 struct iwl_rx_cmd_buffer *rxb); 1897 void iwl_mvm_channel_switch_start_notif(struct iwl_mvm *mvm, 1898 struct iwl_rx_cmd_buffer *rxb); 1899 void iwl_mvm_channel_switch_error_notif(struct iwl_mvm *mvm, 1900 struct iwl_rx_cmd_buffer *rxb); 1901 /* Bindings */ 1902 int iwl_mvm_binding_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1903 int iwl_mvm_binding_remove_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1904 u32 iwl_mvm_get_lmac_id(struct iwl_mvm *mvm, enum nl80211_band band); 1905 1906 /* Links */ 1907 int iwl_mvm_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1908 struct ieee80211_bss_conf *link_conf); 1909 int iwl_mvm_link_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1910 struct ieee80211_bss_conf *link_conf, 1911 u32 changes, bool active); 1912 int iwl_mvm_remove_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1913 struct ieee80211_bss_conf *link_conf); 1914 int iwl_mvm_disable_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1915 struct ieee80211_bss_conf *link_conf); 1916 1917 /* AP and IBSS */ 1918 bool iwl_mvm_start_ap_ibss_common(struct ieee80211_hw *hw, 1919 struct ieee80211_vif *vif, int *ret); 1920 void iwl_mvm_stop_ap_ibss_common(struct iwl_mvm *mvm, 1921 struct ieee80211_vif *vif); 1922 1923 /* BSS Info */ 1924 /** 1925 * struct iwl_mvm_bss_info_changed_ops - callbacks for the bss_info_changed() 1926 * 1927 * Since the only difference between both MLD and 1928 * non-MLD versions of bss_info_changed() is these function calls, 1929 * each version will send its specific function calls to 1930 * %iwl_mvm_bss_info_changed_common(). 1931 * 1932 * @bss_info_changed_sta: pointer to the function that handles changes 1933 * in bss_info in sta mode 1934 * @bss_info_changed_ap_ibss: pointer to the function that handles changes 1935 * in bss_info in ap and ibss modes 1936 */ 1937 struct iwl_mvm_bss_info_changed_ops { 1938 void (*bss_info_changed_sta)(struct iwl_mvm *mvm, 1939 struct ieee80211_vif *vif, 1940 struct ieee80211_bss_conf *bss_conf, 1941 u64 changes); 1942 void (*bss_info_changed_ap_ibss)(struct iwl_mvm *mvm, 1943 struct ieee80211_vif *vif, 1944 struct ieee80211_bss_conf *bss_conf, 1945 u64 changes); 1946 }; 1947 1948 void 1949 iwl_mvm_bss_info_changed_common(struct ieee80211_hw *hw, 1950 struct ieee80211_vif *vif, 1951 struct ieee80211_bss_conf *bss_conf, 1952 const struct iwl_mvm_bss_info_changed_ops *callbacks, 1953 u64 changes); 1954 void 1955 iwl_mvm_bss_info_changed_station_common(struct iwl_mvm *mvm, 1956 struct ieee80211_vif *vif, 1957 struct ieee80211_bss_conf *link_conf, 1958 u64 changes); 1959 void iwl_mvm_bss_info_changed_station_assoc(struct iwl_mvm *mvm, 1960 struct ieee80211_vif *vif, 1961 u64 changes); 1962 1963 /* ROC */ 1964 /** 1965 * struct iwl_mvm_roc_ops - callbacks for the remain_on_channel() 1966 * 1967 * Since the only difference between both MLD and 1968 * non-MLD versions of remain_on_channel() is these function calls, 1969 * each version will send its specific function calls to 1970 * %iwl_mvm_roc_common(). 1971 * 1972 * @add_aux_sta_for_hs20: pointer to the function that adds an aux sta 1973 * for Hot Spot 2.0 1974 * @switch_phy_ctxt: pointer to the function that switches a vif from one 1975 * phy_ctx to another 1976 */ 1977 struct iwl_mvm_roc_ops { 1978 int (*add_aux_sta_for_hs20)(struct iwl_mvm *mvm, u32 lmac_id); 1979 int (*switch_phy_ctxt)(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1980 struct iwl_mvm_phy_ctxt *new_phy_ctxt); 1981 }; 1982 1983 int iwl_mvm_roc_common(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1984 struct ieee80211_channel *channel, int duration, 1985 enum ieee80211_roc_type type, 1986 const struct iwl_mvm_roc_ops *ops); 1987 int iwl_mvm_cancel_roc(struct ieee80211_hw *hw, 1988 struct ieee80211_vif *vif); 1989 /*Session Protection */ 1990 void iwl_mvm_protect_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1991 u32 duration_override); 1992 1993 /* Quota management */ 1994 static inline size_t iwl_mvm_quota_cmd_size(struct iwl_mvm *mvm) 1995 { 1996 return iwl_mvm_has_quota_low_latency(mvm) ? 1997 sizeof(struct iwl_time_quota_cmd) : 1998 sizeof(struct iwl_time_quota_cmd_v1); 1999 } 2000 2001 static inline struct iwl_time_quota_data 2002 *iwl_mvm_quota_cmd_get_quota(struct iwl_mvm *mvm, 2003 struct iwl_time_quota_cmd *cmd, 2004 int i) 2005 { 2006 struct iwl_time_quota_data_v1 *quotas; 2007 2008 if (iwl_mvm_has_quota_low_latency(mvm)) 2009 return &cmd->quotas[i]; 2010 2011 quotas = (struct iwl_time_quota_data_v1 *)cmd->quotas; 2012 return (struct iwl_time_quota_data *)"as[i]; 2013 } 2014 2015 int iwl_mvm_update_quotas(struct iwl_mvm *mvm, bool force_upload, 2016 struct ieee80211_vif *disabled_vif); 2017 2018 /* Scanning */ 2019 int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 2020 struct cfg80211_scan_request *req, 2021 struct ieee80211_scan_ies *ies); 2022 size_t iwl_mvm_scan_size(struct iwl_mvm *mvm); 2023 int iwl_mvm_scan_stop(struct iwl_mvm *mvm, int type, bool notify); 2024 int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm); 2025 void iwl_mvm_report_scan_aborted(struct iwl_mvm *mvm); 2026 void iwl_mvm_scan_timeout_wk(struct work_struct *work); 2027 2028 /* Scheduled scan */ 2029 void iwl_mvm_rx_lmac_scan_complete_notif(struct iwl_mvm *mvm, 2030 struct iwl_rx_cmd_buffer *rxb); 2031 void iwl_mvm_rx_lmac_scan_iter_complete_notif(struct iwl_mvm *mvm, 2032 struct iwl_rx_cmd_buffer *rxb); 2033 int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm, 2034 struct ieee80211_vif *vif, 2035 struct cfg80211_sched_scan_request *req, 2036 struct ieee80211_scan_ies *ies, 2037 int type); 2038 void iwl_mvm_rx_scan_match_found(struct iwl_mvm *mvm, 2039 struct iwl_rx_cmd_buffer *rxb); 2040 2041 /* UMAC scan */ 2042 int iwl_mvm_config_scan(struct iwl_mvm *mvm); 2043 void iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm, 2044 struct iwl_rx_cmd_buffer *rxb); 2045 void iwl_mvm_rx_umac_scan_iter_complete_notif(struct iwl_mvm *mvm, 2046 struct iwl_rx_cmd_buffer *rxb); 2047 2048 /* MVM debugfs */ 2049 #ifdef CONFIG_IWLWIFI_DEBUGFS 2050 void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm); 2051 void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 2052 void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 2053 #else 2054 static inline void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm) 2055 { 2056 } 2057 static inline void 2058 iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif) 2059 { 2060 } 2061 static inline void 2062 iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif) 2063 { 2064 } 2065 #endif /* CONFIG_IWLWIFI_DEBUGFS */ 2066 2067 /* rate scaling */ 2068 int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq); 2069 void iwl_mvm_update_frame_stats(struct iwl_mvm *mvm, u32 rate, bool agg); 2070 int rs_pretty_print_rate_v1(char *buf, int bufsz, const u32 rate); 2071 void rs_update_last_rssi(struct iwl_mvm *mvm, 2072 struct iwl_mvm_sta *mvmsta, 2073 struct ieee80211_rx_status *rx_status); 2074 2075 /* power management */ 2076 int iwl_mvm_power_update_device(struct iwl_mvm *mvm); 2077 int iwl_mvm_power_update_mac(struct iwl_mvm *mvm); 2078 int iwl_mvm_power_update_ps(struct iwl_mvm *mvm); 2079 int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 2080 char *buf, int bufsz); 2081 2082 void iwl_mvm_power_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 2083 void iwl_mvm_power_uapsd_misbehaving_ap_notif(struct iwl_mvm *mvm, 2084 struct iwl_rx_cmd_buffer *rxb); 2085 2086 #ifdef CONFIG_IWLWIFI_LEDS 2087 int iwl_mvm_leds_init(struct iwl_mvm *mvm); 2088 void iwl_mvm_leds_exit(struct iwl_mvm *mvm); 2089 void iwl_mvm_leds_sync(struct iwl_mvm *mvm); 2090 #else 2091 static inline int iwl_mvm_leds_init(struct iwl_mvm *mvm) 2092 { 2093 return 0; 2094 } 2095 static inline void iwl_mvm_leds_exit(struct iwl_mvm *mvm) 2096 { 2097 } 2098 static inline void iwl_mvm_leds_sync(struct iwl_mvm *mvm) 2099 { 2100 } 2101 #endif 2102 2103 /* D3 (WoWLAN, NetDetect) */ 2104 int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan); 2105 int iwl_mvm_resume(struct ieee80211_hw *hw); 2106 void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled); 2107 void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw, 2108 struct ieee80211_vif *vif, 2109 struct cfg80211_gtk_rekey_data *data); 2110 void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw, 2111 struct ieee80211_vif *vif, 2112 struct inet6_dev *idev); 2113 void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw, 2114 struct ieee80211_vif *vif, int idx); 2115 extern const struct file_operations iwl_dbgfs_d3_test_ops; 2116 #ifdef CONFIG_PM 2117 void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, 2118 struct ieee80211_vif *vif); 2119 #else 2120 static inline void 2121 iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif) 2122 { 2123 } 2124 #endif 2125 void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta, 2126 struct iwl_wowlan_config_cmd *cmd); 2127 int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm, 2128 struct ieee80211_vif *vif, 2129 bool disable_offloading, 2130 bool offload_ns, 2131 u32 cmd_flags); 2132 2133 /* BT Coex */ 2134 int iwl_mvm_send_bt_init_conf(struct iwl_mvm *mvm); 2135 void iwl_mvm_rx_bt_coex_notif(struct iwl_mvm *mvm, 2136 struct iwl_rx_cmd_buffer *rxb); 2137 void iwl_mvm_bt_rssi_event(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 2138 enum ieee80211_rssi_event_data); 2139 void iwl_mvm_bt_coex_vif_change(struct iwl_mvm *mvm); 2140 u16 iwl_mvm_coex_agg_time_limit(struct iwl_mvm *mvm, 2141 struct ieee80211_sta *sta); 2142 bool iwl_mvm_bt_coex_is_mimo_allowed(struct iwl_mvm *mvm, 2143 struct ieee80211_sta *sta); 2144 bool iwl_mvm_bt_coex_is_ant_avail(struct iwl_mvm *mvm, u8 ant); 2145 bool iwl_mvm_bt_coex_is_shared_ant_avail(struct iwl_mvm *mvm); 2146 bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm *mvm, 2147 enum nl80211_band band); 2148 u8 iwl_mvm_bt_coex_get_single_ant_msk(struct iwl_mvm *mvm, u8 enabled_ants); 2149 u8 iwl_mvm_bt_coex_tx_prio(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr, 2150 struct ieee80211_tx_info *info, u8 ac); 2151 2152 /* beacon filtering */ 2153 #ifdef CONFIG_IWLWIFI_DEBUGFS 2154 void 2155 iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif, 2156 struct iwl_beacon_filter_cmd *cmd); 2157 #else 2158 static inline void 2159 iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif, 2160 struct iwl_beacon_filter_cmd *cmd) 2161 {} 2162 #endif 2163 int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm, 2164 struct ieee80211_vif *vif, 2165 u32 flags); 2166 int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm, 2167 struct ieee80211_vif *vif, 2168 u32 flags); 2169 /* SMPS */ 2170 void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 2171 enum iwl_mvm_smps_type_request req_type, 2172 enum ieee80211_smps_mode smps_request, 2173 unsigned int link_id); 2174 void 2175 iwl_mvm_update_smps_on_active_links(struct iwl_mvm *mvm, 2176 struct ieee80211_vif *vif, 2177 enum iwl_mvm_smps_type_request req_type, 2178 enum ieee80211_smps_mode smps_request); 2179 bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm, 2180 struct iwl_mvm_phy_ctxt *ctxt); 2181 void iwl_mvm_update_link_smps(struct ieee80211_vif *vif, 2182 struct ieee80211_bss_conf *link_conf); 2183 2184 /* Low latency */ 2185 int iwl_mvm_update_low_latency(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 2186 bool low_latency, 2187 enum iwl_mvm_low_latency_cause cause); 2188 /* get SystemLowLatencyMode - only needed for beacon threshold? */ 2189 bool iwl_mvm_low_latency(struct iwl_mvm *mvm); 2190 bool iwl_mvm_low_latency_band(struct iwl_mvm *mvm, enum nl80211_band band); 2191 void iwl_mvm_send_low_latency_cmd(struct iwl_mvm *mvm, bool low_latency, 2192 u16 mac_id); 2193 2194 /* get VMACLowLatencyMode */ 2195 static inline bool iwl_mvm_vif_low_latency(struct iwl_mvm_vif *mvmvif) 2196 { 2197 /* 2198 * should this consider associated/active/... state? 2199 * 2200 * Normally low-latency should only be active on interfaces 2201 * that are active, but at least with debugfs it can also be 2202 * enabled on interfaces that aren't active. However, when 2203 * interface aren't active then they aren't added into the 2204 * binding, so this has no real impact. For now, just return 2205 * the current desired low-latency state. 2206 */ 2207 return mvmvif->low_latency_actual; 2208 } 2209 2210 static inline 2211 void iwl_mvm_vif_set_low_latency(struct iwl_mvm_vif *mvmvif, bool set, 2212 enum iwl_mvm_low_latency_cause cause) 2213 { 2214 u8 new_state; 2215 2216 if (set) 2217 mvmvif->low_latency |= cause; 2218 else 2219 mvmvif->low_latency &= ~cause; 2220 2221 /* 2222 * if LOW_LATENCY_DEBUGFS_FORCE_ENABLE is enabled no changes are 2223 * allowed to actual mode. 2224 */ 2225 if (mvmvif->low_latency & LOW_LATENCY_DEBUGFS_FORCE_ENABLE && 2226 cause != LOW_LATENCY_DEBUGFS_FORCE_ENABLE) 2227 return; 2228 2229 if (cause == LOW_LATENCY_DEBUGFS_FORCE_ENABLE && set) 2230 /* 2231 * We enter force state 2232 */ 2233 new_state = !!(mvmvif->low_latency & 2234 LOW_LATENCY_DEBUGFS_FORCE); 2235 else 2236 /* 2237 * Check if any other one set low latency 2238 */ 2239 new_state = !!(mvmvif->low_latency & 2240 ~(LOW_LATENCY_DEBUGFS_FORCE_ENABLE | 2241 LOW_LATENCY_DEBUGFS_FORCE)); 2242 2243 mvmvif->low_latency_actual = new_state; 2244 } 2245 2246 /* Return a bitmask with all the hw supported queues, except for the 2247 * command queue, which can't be flushed. 2248 */ 2249 static inline u32 iwl_mvm_flushable_queues(struct iwl_mvm *mvm) 2250 { 2251 return ((BIT(mvm->trans->trans_cfg->base_params->num_of_queues) - 1) & 2252 ~BIT(IWL_MVM_DQA_CMD_QUEUE)); 2253 } 2254 2255 void iwl_mvm_stop_device(struct iwl_mvm *mvm); 2256 2257 /* Thermal management and CT-kill */ 2258 void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff); 2259 void iwl_mvm_temp_notif(struct iwl_mvm *mvm, 2260 struct iwl_rx_cmd_buffer *rxb); 2261 void iwl_mvm_tt_handler(struct iwl_mvm *mvm); 2262 void iwl_mvm_thermal_initialize(struct iwl_mvm *mvm, u32 min_backoff); 2263 void iwl_mvm_thermal_exit(struct iwl_mvm *mvm); 2264 void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm *mvm, bool state); 2265 int iwl_mvm_get_temp(struct iwl_mvm *mvm, s32 *temp); 2266 void iwl_mvm_ct_kill_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 2267 void iwl_mvm_enter_ctkill(struct iwl_mvm *mvm); 2268 int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm); 2269 int iwl_mvm_ctdp_command(struct iwl_mvm *mvm, u32 op, u32 budget); 2270 2271 #if IS_ENABLED(CONFIG_IWLMEI) 2272 2273 /* vendor commands */ 2274 void iwl_mvm_vendor_cmds_register(struct iwl_mvm *mvm); 2275 2276 #else 2277 2278 static inline void iwl_mvm_vendor_cmds_register(struct iwl_mvm *mvm) {} 2279 2280 #endif 2281 2282 /* Location Aware Regulatory */ 2283 struct iwl_mcc_update_resp_v8 * 2284 iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2, 2285 enum iwl_mcc_source src_id); 2286 int iwl_mvm_init_mcc(struct iwl_mvm *mvm); 2287 void iwl_mvm_rx_chub_update_mcc(struct iwl_mvm *mvm, 2288 struct iwl_rx_cmd_buffer *rxb); 2289 struct ieee80211_regdomain *iwl_mvm_get_regdomain(struct wiphy *wiphy, 2290 const char *alpha2, 2291 enum iwl_mcc_source src_id, 2292 bool *changed); 2293 struct ieee80211_regdomain *iwl_mvm_get_current_regdomain(struct iwl_mvm *mvm, 2294 bool *changed); 2295 int iwl_mvm_init_fw_regd(struct iwl_mvm *mvm); 2296 void iwl_mvm_update_changed_regdom(struct iwl_mvm *mvm); 2297 2298 /* smart fifo */ 2299 int iwl_mvm_sf_update(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 2300 bool added_vif); 2301 2302 /* FTM responder */ 2303 int iwl_mvm_ftm_start_responder(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 2304 struct ieee80211_bss_conf *bss_conf); 2305 void iwl_mvm_ftm_restart_responder(struct iwl_mvm *mvm, 2306 struct ieee80211_vif *vif, 2307 struct ieee80211_bss_conf *bss_conf); 2308 void iwl_mvm_ftm_responder_stats(struct iwl_mvm *mvm, 2309 struct iwl_rx_cmd_buffer *rxb); 2310 int iwl_mvm_ftm_resp_remove_pasn_sta(struct iwl_mvm *mvm, 2311 struct ieee80211_vif *vif, u8 *addr); 2312 int iwl_mvm_ftm_respoder_add_pasn_sta(struct iwl_mvm *mvm, 2313 struct ieee80211_vif *vif, 2314 u8 *addr, u32 cipher, u8 *tk, u32 tk_len, 2315 u8 *hltk, u32 hltk_len); 2316 void iwl_mvm_ftm_responder_clear(struct iwl_mvm *mvm, 2317 struct ieee80211_vif *vif); 2318 2319 /* FTM initiator */ 2320 void iwl_mvm_ftm_restart(struct iwl_mvm *mvm); 2321 void iwl_mvm_ftm_range_resp(struct iwl_mvm *mvm, 2322 struct iwl_rx_cmd_buffer *rxb); 2323 void iwl_mvm_ftm_lc_notif(struct iwl_mvm *mvm, 2324 struct iwl_rx_cmd_buffer *rxb); 2325 int iwl_mvm_ftm_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 2326 struct cfg80211_pmsr_request *request); 2327 void iwl_mvm_ftm_abort(struct iwl_mvm *mvm, struct cfg80211_pmsr_request *req); 2328 void iwl_mvm_ftm_initiator_smooth_config(struct iwl_mvm *mvm); 2329 void iwl_mvm_ftm_initiator_smooth_stop(struct iwl_mvm *mvm); 2330 int iwl_mvm_ftm_add_pasn_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 2331 u8 *addr, u32 cipher, u8 *tk, u32 tk_len, 2332 u8 *hltk, u32 hltk_len); 2333 void iwl_mvm_ftm_remove_pasn_sta(struct iwl_mvm *mvm, u8 *addr); 2334 2335 /* TDLS */ 2336 2337 /* 2338 * We use TID 4 (VI) as a FW-used-only TID when TDLS connections are present. 2339 * This TID is marked as used vs the AP and all connected TDLS peers. 2340 */ 2341 #define IWL_MVM_TDLS_FW_TID 4 2342 2343 int iwl_mvm_tdls_sta_count(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 2344 void iwl_mvm_teardown_tdls_peers(struct iwl_mvm *mvm); 2345 void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 2346 bool sta_added); 2347 void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw, 2348 struct ieee80211_vif *vif); 2349 int iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw, 2350 struct ieee80211_vif *vif, 2351 struct ieee80211_sta *sta, u8 oper_class, 2352 struct cfg80211_chan_def *chandef, 2353 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie); 2354 void iwl_mvm_tdls_recv_channel_switch(struct ieee80211_hw *hw, 2355 struct ieee80211_vif *vif, 2356 struct ieee80211_tdls_ch_sw_params *params); 2357 void iwl_mvm_tdls_cancel_channel_switch(struct ieee80211_hw *hw, 2358 struct ieee80211_vif *vif, 2359 struct ieee80211_sta *sta); 2360 void iwl_mvm_rx_tdls_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 2361 void iwl_mvm_tdls_ch_switch_work(struct work_struct *work); 2362 2363 void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm, 2364 enum iwl_mvm_rxq_notif_type type, 2365 bool sync, 2366 const void *data, u32 size); 2367 void iwl_mvm_reorder_timer_expired(struct timer_list *t); 2368 struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm); 2369 struct ieee80211_vif *iwl_mvm_get_vif_by_macid(struct iwl_mvm *mvm, u32 macid); 2370 bool iwl_mvm_is_vif_assoc(struct iwl_mvm *mvm); 2371 2372 #define MVM_TCM_PERIOD_MSEC 500 2373 #define MVM_TCM_PERIOD (HZ * MVM_TCM_PERIOD_MSEC / 1000) 2374 #define MVM_LL_PERIOD (10 * HZ) 2375 void iwl_mvm_tcm_work(struct work_struct *work); 2376 void iwl_mvm_recalc_tcm(struct iwl_mvm *mvm); 2377 void iwl_mvm_pause_tcm(struct iwl_mvm *mvm, bool with_cancel); 2378 void iwl_mvm_resume_tcm(struct iwl_mvm *mvm); 2379 void iwl_mvm_tcm_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 2380 void iwl_mvm_tcm_rm_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 2381 u8 iwl_mvm_tcm_load_percentage(u32 airtime, u32 elapsed); 2382 2383 void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error); 2384 unsigned int iwl_mvm_get_wd_timeout(struct iwl_mvm *mvm, 2385 struct ieee80211_vif *vif, 2386 bool tdls, bool cmd_q); 2387 void iwl_mvm_connection_loss(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 2388 const char *errmsg); 2389 void iwl_mvm_event_frame_timeout_callback(struct iwl_mvm *mvm, 2390 struct ieee80211_vif *vif, 2391 const struct ieee80211_sta *sta, 2392 u16 tid); 2393 void iwl_mvm_mei_scan_filter_init(struct iwl_mei_scan_filter *mei_scan_filter); 2394 2395 void iwl_mvm_ptp_init(struct iwl_mvm *mvm); 2396 void iwl_mvm_ptp_remove(struct iwl_mvm *mvm); 2397 u64 iwl_mvm_ptp_get_adj_time(struct iwl_mvm *mvm, u64 base_time); 2398 int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b); 2399 int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm); 2400 int iwl_mvm_ppag_send_cmd(struct iwl_mvm *mvm); 2401 void iwl_mvm_get_acpi_tables(struct iwl_mvm *mvm); 2402 #ifdef CONFIG_IWLWIFI_DEBUGFS 2403 void iwl_mvm_link_sta_add_debugfs(struct ieee80211_hw *hw, 2404 struct ieee80211_vif *vif, 2405 struct ieee80211_link_sta *link_sta, 2406 struct dentry *dir); 2407 #endif 2408 2409 /* new MLD related APIs */ 2410 int iwl_mvm_sec_key_add(struct iwl_mvm *mvm, 2411 struct ieee80211_vif *vif, 2412 struct ieee80211_sta *sta, 2413 struct ieee80211_key_conf *keyconf); 2414 int iwl_mvm_sec_key_del(struct iwl_mvm *mvm, 2415 struct ieee80211_vif *vif, 2416 struct ieee80211_sta *sta, 2417 struct ieee80211_key_conf *keyconf); 2418 void iwl_mvm_sec_key_remove_ap(struct iwl_mvm *mvm, 2419 struct ieee80211_vif *vif, 2420 struct iwl_mvm_vif_link_info *link, 2421 unsigned int link_id); 2422 int iwl_mvm_mld_update_sta_keys(struct iwl_mvm *mvm, 2423 struct ieee80211_vif *vif, 2424 struct ieee80211_sta *sta, 2425 u32 old_sta_mask, 2426 u32 new_sta_mask); 2427 int iwl_mvm_mld_send_key(struct iwl_mvm *mvm, u32 sta_mask, u32 key_flags, 2428 struct ieee80211_key_conf *keyconf); 2429 u32 iwl_mvm_get_sec_flags(struct iwl_mvm *mvm, 2430 struct ieee80211_vif *vif, 2431 struct ieee80211_sta *sta, 2432 struct ieee80211_key_conf *keyconf); 2433 2434 bool iwl_rfi_supported(struct iwl_mvm *mvm); 2435 int iwl_rfi_send_config_cmd(struct iwl_mvm *mvm, 2436 struct iwl_rfi_lut_entry *rfi_table); 2437 struct iwl_rfi_freq_table_resp_cmd *iwl_rfi_get_freq_table(struct iwl_mvm *mvm); 2438 void iwl_rfi_deactivate_notif_handler(struct iwl_mvm *mvm, 2439 struct iwl_rx_cmd_buffer *rxb); 2440 2441 static inline u8 iwl_mvm_phy_band_from_nl80211(enum nl80211_band band) 2442 { 2443 switch (band) { 2444 case NL80211_BAND_2GHZ: 2445 return PHY_BAND_24; 2446 case NL80211_BAND_5GHZ: 2447 return PHY_BAND_5; 2448 case NL80211_BAND_6GHZ: 2449 return PHY_BAND_6; 2450 default: 2451 WARN_ONCE(1, "Unsupported band (%u)\n", band); 2452 return PHY_BAND_5; 2453 } 2454 } 2455 2456 /* Channel Switch */ 2457 void iwl_mvm_channel_switch_disconnect_wk(struct work_struct *wk); 2458 int iwl_mvm_post_channel_switch(struct ieee80211_hw *hw, 2459 struct ieee80211_vif *vif, 2460 struct ieee80211_bss_conf *link); 2461 2462 /* Channel Context */ 2463 /** 2464 * struct iwl_mvm_switch_vif_chanctx_ops - callbacks for switch_vif_chanctx() 2465 * 2466 * Since the only difference between both MLD and 2467 * non-MLD versions of switch_vif_chanctx() is these function calls, 2468 * each version will send its specific function calls to 2469 * %iwl_mvm_switch_vif_chanctx_common(). 2470 * 2471 * @__assign_vif_chanctx: pointer to the function that assigns a chanctx to 2472 * a given vif 2473 * @__unassign_vif_chanctx: pointer to the function that unassigns a chanctx to 2474 * a given vif 2475 */ 2476 struct iwl_mvm_switch_vif_chanctx_ops { 2477 int (*__assign_vif_chanctx)(struct iwl_mvm *mvm, 2478 struct ieee80211_vif *vif, 2479 struct ieee80211_bss_conf *link_conf, 2480 struct ieee80211_chanctx_conf *ctx, 2481 bool switching_chanctx); 2482 void (*__unassign_vif_chanctx)(struct iwl_mvm *mvm, 2483 struct ieee80211_vif *vif, 2484 struct ieee80211_bss_conf *link_conf, 2485 struct ieee80211_chanctx_conf *ctx, 2486 bool switching_chanctx); 2487 }; 2488 2489 int 2490 iwl_mvm_switch_vif_chanctx_common(struct ieee80211_hw *hw, 2491 struct ieee80211_vif_chanctx_switch *vifs, 2492 int n_vifs, 2493 enum ieee80211_chanctx_switch_mode mode, 2494 const struct iwl_mvm_switch_vif_chanctx_ops *ops); 2495 2496 /* Channel info utils */ 2497 static inline bool iwl_mvm_has_ultra_hb_channel(struct iwl_mvm *mvm) 2498 { 2499 return fw_has_capa(&mvm->fw->ucode_capa, 2500 IWL_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS); 2501 } 2502 2503 static inline void *iwl_mvm_chan_info_cmd_tail(struct iwl_mvm *mvm, 2504 struct iwl_fw_channel_info *ci) 2505 { 2506 return (u8 *)ci + (iwl_mvm_has_ultra_hb_channel(mvm) ? 2507 sizeof(struct iwl_fw_channel_info) : 2508 sizeof(struct iwl_fw_channel_info_v1)); 2509 } 2510 2511 static inline size_t iwl_mvm_chan_info_padding(struct iwl_mvm *mvm) 2512 { 2513 return iwl_mvm_has_ultra_hb_channel(mvm) ? 0 : 2514 sizeof(struct iwl_fw_channel_info) - 2515 sizeof(struct iwl_fw_channel_info_v1); 2516 } 2517 2518 static inline void iwl_mvm_set_chan_info(struct iwl_mvm *mvm, 2519 struct iwl_fw_channel_info *ci, 2520 u32 chan, u8 band, u8 width, 2521 u8 ctrl_pos) 2522 { 2523 if (iwl_mvm_has_ultra_hb_channel(mvm)) { 2524 ci->channel = cpu_to_le32(chan); 2525 ci->band = band; 2526 ci->width = width; 2527 ci->ctrl_pos = ctrl_pos; 2528 } else { 2529 struct iwl_fw_channel_info_v1 *ci_v1 = 2530 (struct iwl_fw_channel_info_v1 *)ci; 2531 2532 ci_v1->channel = chan; 2533 ci_v1->band = band; 2534 ci_v1->width = width; 2535 ci_v1->ctrl_pos = ctrl_pos; 2536 } 2537 } 2538 2539 static inline void 2540 iwl_mvm_set_chan_info_chandef(struct iwl_mvm *mvm, 2541 struct iwl_fw_channel_info *ci, 2542 struct cfg80211_chan_def *chandef) 2543 { 2544 enum nl80211_band band = chandef->chan->band; 2545 2546 iwl_mvm_set_chan_info(mvm, ci, chandef->chan->hw_value, 2547 iwl_mvm_phy_band_from_nl80211(band), 2548 iwl_mvm_get_channel_width(chandef), 2549 iwl_mvm_get_ctrl_pos(chandef)); 2550 } 2551 2552 static inline int iwl_umac_scan_get_max_profiles(const struct iwl_fw *fw) 2553 { 2554 u8 ver = iwl_fw_lookup_cmd_ver(fw, SCAN_OFFLOAD_UPDATE_PROFILES_CMD, 2555 IWL_FW_CMD_VER_UNKNOWN); 2556 return (ver == IWL_FW_CMD_VER_UNKNOWN || ver < 3) ? 2557 IWL_SCAN_MAX_PROFILES : IWL_SCAN_MAX_PROFILES_V2; 2558 } 2559 2560 static inline 2561 enum iwl_location_cipher iwl_mvm_cipher_to_location_cipher(u32 cipher) 2562 { 2563 switch (cipher) { 2564 case WLAN_CIPHER_SUITE_CCMP: 2565 return IWL_LOCATION_CIPHER_CCMP_128; 2566 case WLAN_CIPHER_SUITE_GCMP: 2567 return IWL_LOCATION_CIPHER_GCMP_128; 2568 case WLAN_CIPHER_SUITE_GCMP_256: 2569 return IWL_LOCATION_CIPHER_GCMP_256; 2570 default: 2571 return IWL_LOCATION_CIPHER_INVALID; 2572 } 2573 } 2574 2575 struct iwl_mvm_csme_conn_info *iwl_mvm_get_csme_conn_info(struct iwl_mvm *mvm); 2576 static inline int iwl_mvm_mei_get_ownership(struct iwl_mvm *mvm) 2577 { 2578 if (mvm->mei_registered) 2579 return iwl_mei_get_ownership(); 2580 return 0; 2581 } 2582 2583 static inline void iwl_mvm_mei_tx_copy_to_csme(struct iwl_mvm *mvm, 2584 struct sk_buff *skb, 2585 unsigned int ivlen) 2586 { 2587 if (mvm->mei_registered) 2588 iwl_mei_tx_copy_to_csme(skb, ivlen); 2589 } 2590 2591 static inline void iwl_mvm_mei_host_disassociated(struct iwl_mvm *mvm) 2592 { 2593 if (mvm->mei_registered) 2594 iwl_mei_host_disassociated(); 2595 } 2596 2597 static inline void iwl_mvm_mei_device_state(struct iwl_mvm *mvm, bool up) 2598 { 2599 if (mvm->mei_registered) 2600 iwl_mei_device_state(up); 2601 } 2602 2603 static inline void iwl_mvm_mei_set_sw_rfkill_state(struct iwl_mvm *mvm) 2604 { 2605 bool sw_rfkill = 2606 mvm->hw_registered ? rfkill_soft_blocked(mvm->hw->wiphy->rfkill) : false; 2607 2608 if (mvm->mei_registered) 2609 iwl_mei_set_rfkill_state(iwl_mvm_is_radio_killed(mvm), 2610 sw_rfkill); 2611 } 2612 2613 static inline bool iwl_mvm_mei_filter_scan(struct iwl_mvm *mvm, 2614 struct sk_buff *skb) 2615 { 2616 struct ieee80211_mgmt *mgmt = (void *)skb->data; 2617 2618 if (mvm->mei_scan_filter.is_mei_limited_scan && 2619 (ieee80211_is_probe_resp(mgmt->frame_control) || 2620 ieee80211_is_beacon(mgmt->frame_control))) { 2621 skb_queue_tail(&mvm->mei_scan_filter.scan_res, skb); 2622 schedule_work(&mvm->mei_scan_filter.scan_work); 2623 return true; 2624 } 2625 2626 return false; 2627 } 2628 2629 void iwl_mvm_send_roaming_forbidden_event(struct iwl_mvm *mvm, 2630 struct ieee80211_vif *vif, 2631 bool forbidden); 2632 bool iwl_mvm_is_vendor_in_approved_list(void); 2633 2634 /* Callbacks for ieee80211_ops */ 2635 void iwl_mvm_mac_tx(struct ieee80211_hw *hw, 2636 struct ieee80211_tx_control *control, struct sk_buff *skb); 2637 void iwl_mvm_mac_wake_tx_queue(struct ieee80211_hw *hw, 2638 struct ieee80211_txq *txq); 2639 2640 int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw, 2641 struct ieee80211_vif *vif, 2642 struct ieee80211_ampdu_params *params); 2643 int iwl_mvm_op_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant); 2644 int iwl_mvm_op_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant); 2645 int iwl_mvm_mac_start(struct ieee80211_hw *hw); 2646 void iwl_mvm_mac_reconfig_complete(struct ieee80211_hw *hw, 2647 enum ieee80211_reconfig_type reconfig_type); 2648 void iwl_mvm_mac_stop(struct ieee80211_hw *hw); 2649 static inline int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed) 2650 { 2651 return 0; 2652 } 2653 2654 u64 iwl_mvm_prepare_multicast(struct ieee80211_hw *hw, 2655 struct netdev_hw_addr_list *mc_list); 2656 2657 void iwl_mvm_configure_filter(struct ieee80211_hw *hw, 2658 unsigned int changed_flags, 2659 unsigned int *total_flags, u64 multicast); 2660 int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 2661 struct ieee80211_scan_request *hw_req); 2662 void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw, 2663 struct ieee80211_vif *vif); 2664 void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw *hw, 2665 struct ieee80211_vif *vif, 2666 struct ieee80211_sta *sta); 2667 void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 2668 enum sta_notify_cmd cmd, 2669 struct ieee80211_sta *sta); 2670 void 2671 iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw, 2672 struct ieee80211_sta *sta, u16 tids, 2673 int num_frames, 2674 enum ieee80211_frame_release_type reason, 2675 bool more_data); 2676 void 2677 iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw *hw, 2678 struct ieee80211_sta *sta, u16 tids, 2679 int num_frames, 2680 enum ieee80211_frame_release_type reason, 2681 bool more_data); 2682 int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, u32 value); 2683 void iwl_mvm_sta_rc_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 2684 struct ieee80211_sta *sta, u32 changed); 2685 void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw, 2686 struct ieee80211_vif *vif, 2687 struct ieee80211_prep_tx_info *info); 2688 void iwl_mvm_mac_mgd_complete_tx(struct ieee80211_hw *hw, 2689 struct ieee80211_vif *vif, 2690 struct ieee80211_prep_tx_info *info); 2691 void iwl_mvm_mac_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 2692 u32 queues, bool drop); 2693 void iwl_mvm_mac_flush_sta(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 2694 struct ieee80211_sta *sta); 2695 int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw, 2696 struct ieee80211_vif *vif, 2697 struct cfg80211_sched_scan_request *req, 2698 struct ieee80211_scan_ies *ies); 2699 int iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw *hw, 2700 struct ieee80211_vif *vif); 2701 int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 2702 struct ieee80211_vif *vif, struct ieee80211_sta *sta, 2703 struct ieee80211_key_conf *key); 2704 void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw, 2705 struct ieee80211_vif *vif, 2706 struct ieee80211_key_conf *keyconf, 2707 struct ieee80211_sta *sta, 2708 u32 iv32, u16 *phase1key); 2709 int iwl_mvm_add_chanctx(struct ieee80211_hw *hw, 2710 struct ieee80211_chanctx_conf *ctx); 2711 void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw, 2712 struct ieee80211_chanctx_conf *ctx); 2713 void iwl_mvm_change_chanctx(struct ieee80211_hw *hw, 2714 struct ieee80211_chanctx_conf *ctx, u32 changed); 2715 int iwl_mvm_tx_last_beacon(struct ieee80211_hw *hw); 2716 int iwl_mvm_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, 2717 bool set); 2718 void iwl_mvm_channel_switch(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 2719 struct ieee80211_channel_switch *chsw); 2720 int iwl_mvm_pre_channel_switch(struct ieee80211_hw *hw, 2721 struct ieee80211_vif *vif, 2722 struct ieee80211_channel_switch *chsw); 2723 void iwl_mvm_abort_channel_switch(struct ieee80211_hw *hw, 2724 struct ieee80211_vif *vif); 2725 void iwl_mvm_channel_switch_rx_beacon(struct ieee80211_hw *hw, 2726 struct ieee80211_vif *vif, 2727 struct ieee80211_channel_switch *chsw); 2728 void iwl_mvm_mac_event_callback(struct ieee80211_hw *hw, 2729 struct ieee80211_vif *vif, 2730 const struct ieee80211_event *event); 2731 void iwl_mvm_sync_rx_queues(struct ieee80211_hw *hw); 2732 int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw *hw, 2733 struct ieee80211_vif *vif, 2734 void *data, int len); 2735 int iwl_mvm_mac_get_survey(struct ieee80211_hw *hw, int idx, 2736 struct survey_info *survey); 2737 void iwl_mvm_mac_sta_statistics(struct ieee80211_hw *hw, 2738 struct ieee80211_vif *vif, 2739 struct ieee80211_sta *sta, 2740 struct station_info *sinfo); 2741 int 2742 iwl_mvm_mac_get_ftm_responder_stats(struct ieee80211_hw *hw, 2743 struct ieee80211_vif *vif, 2744 struct cfg80211_ftm_responder_stats *stats); 2745 int iwl_mvm_start_pmsr(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 2746 struct cfg80211_pmsr_request *request); 2747 void iwl_mvm_abort_pmsr(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 2748 struct cfg80211_pmsr_request *request); 2749 2750 bool iwl_mvm_have_links_same_channel(struct iwl_mvm_vif *vif1, 2751 struct iwl_mvm_vif *vif2); 2752 bool iwl_mvm_vif_is_active(struct iwl_mvm_vif *mvmvif); 2753 int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 2754 s16 tx_power); 2755 int iwl_mvm_set_hw_timestamp(struct ieee80211_hw *hw, 2756 struct ieee80211_vif *vif, 2757 struct cfg80211_set_hw_timestamp *hwts); 2758 int iwl_mvm_update_mu_groups(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 2759 bool iwl_mvm_enable_fils(struct iwl_mvm *mvm, 2760 struct ieee80211_chanctx_conf *ctx); 2761 #endif /* __IWL_MVM_H__ */ 2762