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