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