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