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