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