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