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