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