1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3 * Copyright (C) 2012-2014, 2018-2026 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 * @p2p_in_binding: indicates that this P2P-Device interface should be
387 * added to the binding, i.e. is running ROC right now
388 * @session_prot_connection_loss: the connection was lost due to session
389 * protection ending without receiving a beacon, so we need to now
390 * protect the deauth separately
391 * @ap_early_keys: The firmware cannot install keys before stations etc.,
392 * but higher layers work differently, so we store the keys here for
393 * later installation.
394 * @ap_sta: pointer to the AP STA data structure
395 * @csa_count: CSA counter (old CSA implementation w/o firmware)
396 * @csa_misbehave: CSA AP misbehaviour flag (old implementation)
397 * @csa_target_freq: CSA target channel frequency (old implementation)
398 * @csa_work: CSA work (old implementation)
399 * @dbgfs_bf: beamforming debugfs data
400 * @dbgfs_dir: debugfs directory for this vif
401 * @dbgfs_pm: power management debugfs data
402 * @dbgfs_quota_min: debugfs value for minimal quota
403 * @dbgfs_slink: debugfs symlink for this interface
404 * @ftm_unprotected: unprotected FTM debugfs override
405 * @hs_time_event_data: hotspot/AUX ROC time event data
406 * @mac_pwr_cmd: debugfs override for MAC power command
407 * @target_ipv6_addrs: IPv6 addresses on this interface for offload
408 * @num_target_ipv6_addrs: number of @target_ipv6_addrs
409 * @tentative_addrs: bitmap of tentative IPv6 addresses in @target_ipv6_addrs
410 * @rekey_data: rekeying data for WoWLAN GTK rekey offload
411 * @seqno: storage for seqno for older firmware D0/D3 transition
412 * @seqno_valid: indicates @seqno is valid
413 * @time_event_data: session protection time event data
414 * @tsf_id: the TSF resource ID assigned in firmware (for firmware needing that)
415 * @tx_key_idx: WEP transmit key index for D3
416 * @uapsd_misbehaving_ap_addr: MLD address/BSSID of U-APSD misbehaving AP, to
417 * not use U-APSD on reconnection
418 * @uapsd_nonagg_detected_wk: worker for handling detection of no aggregation
419 * in U-APSD
420 */
421 struct iwl_mvm_vif {
422 struct iwl_mvm *mvm;
423 u16 id;
424 u16 color;
425
426 bool associated;
427 u8 ap_assoc_sta_count;
428 bool uploaded;
429 bool ap_ibss_active;
430 bool pm_enabled;
431 bool monitor_active;
432 bool session_prot_connection_loss;
433
434 u8 low_latency: 6;
435 u8 low_latency_actual: 1;
436
437 u8 authorized:1;
438 bool ps_disabled;
439
440 u32 ap_beacon_time;
441 bool bf_enabled;
442 bool ba_enabled;
443
444 #ifdef CONFIG_PM_SLEEP
445 /* WoWLAN GTK rekey data */
446 struct {
447 u8 kck[NL80211_KCK_EXT_LEN];
448 u8 kek[NL80211_KEK_EXT_LEN];
449 size_t kek_len;
450 size_t kck_len;
451 u32 akm;
452 __le64 replay_ctr;
453 bool valid;
454 } rekey_data;
455
456 int tx_key_idx;
457
458 bool seqno_valid;
459 u16 seqno;
460 #endif
461
462 #if IS_ENABLED(CONFIG_IPV6)
463 /* IPv6 addresses for WoWLAN */
464 struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX];
465 unsigned long tentative_addrs[BITS_TO_LONGS(IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX)];
466 int num_target_ipv6_addrs;
467 #endif
468
469 #ifdef CONFIG_IWLWIFI_DEBUGFS
470 struct dentry *dbgfs_dir;
471 struct dentry *dbgfs_slink;
472 struct iwl_dbgfs_pm dbgfs_pm;
473 struct iwl_dbgfs_bf dbgfs_bf;
474 struct iwl_mac_power_cmd_v2 mac_pwr_cmd;
475 int dbgfs_quota_min;
476 bool ftm_unprotected;
477 #endif
478
479 /* FW identified misbehaving AP */
480 u8 uapsd_misbehaving_ap_addr[ETH_ALEN] __aligned(2);
481 struct delayed_work uapsd_nonagg_detected_wk;
482
483 bool csa_countdown;
484 bool csa_failed;
485 bool csa_bcn_pending;
486 bool csa_blocks_tx;
487 u16 csa_target_freq;
488 u16 csa_count;
489 u16 csa_misbehave;
490 struct delayed_work csa_work;
491
492 enum iwl_tsf_id tsf_id;
493
494 struct iwl_mvm_time_event_data time_event_data;
495 struct iwl_mvm_time_event_data hs_time_event_data;
496 enum iwl_roc_activity roc_activity;
497 bool p2p_in_binding;
498
499 /* TCP Checksum Offload */
500 netdev_features_t features;
501
502 struct ieee80211_sta *ap_sta;
503
504 /* we can only have 2 GTK + 2 IGTK active at a time */
505 struct ieee80211_key_conf *ap_early_keys[4];
506
507 struct {
508 struct ieee80211_key_conf __rcu *keys[2];
509 } bcn_prot;
510
511 u16 max_tx_op;
512
513 struct iwl_mvm_vif_link_info deflink;
514 struct iwl_mvm_vif_link_info *link[IEEE80211_MLD_MAX_NUM_LINKS];
515 };
516
517 #define for_each_mvm_vif_valid_link(mvm_vif, link_id) \
518 for (link_id = 0; \
519 link_id < ARRAY_SIZE((mvm_vif)->link); \
520 link_id++) \
521 if ((mvm_vif)->link[link_id])
522
523 static inline struct iwl_mvm_vif *
iwl_mvm_vif_from_mac80211(struct ieee80211_vif * vif)524 iwl_mvm_vif_from_mac80211(struct ieee80211_vif *vif)
525 {
526 return (void *)vif->drv_priv;
527 }
528
529 extern const u8 tid_to_mac80211_ac[];
530
531 #define IWL_MVM_SCAN_STOPPING_SHIFT 8
532
533 enum iwl_scan_status {
534 IWL_MVM_SCAN_REGULAR = BIT(0),
535 IWL_MVM_SCAN_SCHED = BIT(1),
536 IWL_MVM_SCAN_NETDETECT = BIT(2),
537
538 IWL_MVM_SCAN_STOPPING_REGULAR = BIT(8),
539 IWL_MVM_SCAN_STOPPING_SCHED = BIT(9),
540 IWL_MVM_SCAN_STOPPING_NETDETECT = BIT(10),
541 IWL_MVM_SCAN_STOPPING_INT_MLO = BIT(11),
542
543 IWL_MVM_SCAN_REGULAR_MASK = IWL_MVM_SCAN_REGULAR |
544 IWL_MVM_SCAN_STOPPING_REGULAR,
545 IWL_MVM_SCAN_SCHED_MASK = IWL_MVM_SCAN_SCHED |
546 IWL_MVM_SCAN_STOPPING_SCHED,
547 IWL_MVM_SCAN_NETDETECT_MASK = IWL_MVM_SCAN_NETDETECT |
548 IWL_MVM_SCAN_STOPPING_NETDETECT,
549
550 IWL_MVM_SCAN_STOPPING_MASK = 0xff << IWL_MVM_SCAN_STOPPING_SHIFT,
551 IWL_MVM_SCAN_MASK = 0xff,
552 };
553
554 enum iwl_mvm_scan_type {
555 IWL_SCAN_TYPE_NOT_SET,
556 IWL_SCAN_TYPE_UNASSOC,
557 IWL_SCAN_TYPE_WILD,
558 IWL_SCAN_TYPE_MILD,
559 IWL_SCAN_TYPE_FRAGMENTED,
560 IWL_SCAN_TYPE_FAST_BALANCE,
561 };
562
563 enum iwl_mvm_sched_scan_pass_all_states {
564 SCHED_SCAN_PASS_ALL_DISABLED,
565 SCHED_SCAN_PASS_ALL_ENABLED,
566 SCHED_SCAN_PASS_ALL_FOUND,
567 };
568
569 /**
570 * struct iwl_mvm_tt_mgmt - Thermal Throttling Management structure
571 * @ct_kill_exit: worker to exit thermal kill
572 * @dynamic_smps: Is thermal throttling enabled dynamic_smps?
573 * @tx_backoff: The current thremal throttling tx backoff in uSec.
574 * @min_backoff: The minimal tx backoff due to power restrictions
575 * @params: Parameters to configure the thermal throttling algorithm.
576 * @throttle: Is thermal throttling is active?
577 * @power_budget_mw: maximum cTDP power budget as defined for this system and
578 * device
579 */
580 struct iwl_mvm_tt_mgmt {
581 struct delayed_work ct_kill_exit;
582 bool dynamic_smps;
583 u32 tx_backoff;
584 u32 min_backoff;
585 struct iwl_tt_params params;
586 bool throttle;
587
588 u32 power_budget_mw;
589 };
590
591 #ifdef CONFIG_THERMAL
592 /**
593 * struct iwl_mvm_thermal_device - thermal zone related data
594 * @trips: temperature thresholds for report
595 * @tzone: thermal zone device data
596 */
597 struct iwl_mvm_thermal_device {
598 struct thermal_trip trips[IWL_MAX_DTS_TRIPS];
599 struct thermal_zone_device *tzone;
600 };
601
602 /*
603 * struct iwl_mvm_cooling_device
604 * @cur_state: current state
605 * @cdev: struct thermal cooling device
606 */
607 struct iwl_mvm_cooling_device {
608 u32 cur_state;
609 struct thermal_cooling_device *cdev;
610 };
611 #endif
612
613 #define IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES 8
614
615 struct iwl_mvm_frame_stats {
616 u32 legacy_frames;
617 u32 ht_frames;
618 u32 vht_frames;
619 u32 bw_20_frames;
620 u32 bw_40_frames;
621 u32 bw_80_frames;
622 u32 bw_160_frames;
623 u32 sgi_frames;
624 u32 ngi_frames;
625 u32 siso_frames;
626 u32 mimo2_frames;
627 u32 agg_frames;
628 u32 ampdu_count;
629 u32 success_frames;
630 u32 fail_frames;
631 u32 last_rates[IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES];
632 int last_frame_idx;
633 };
634
635 #define IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE 0xff
636 #define IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -100
637 #define IWL_MVM_DEBUG_SET_TEMPERATURE_MAX 200
638
639 enum iwl_mvm_tdls_cs_state {
640 IWL_MVM_TDLS_SW_IDLE = 0,
641 IWL_MVM_TDLS_SW_REQ_SENT,
642 IWL_MVM_TDLS_SW_RESP_RCVD,
643 IWL_MVM_TDLS_SW_REQ_RCVD,
644 IWL_MVM_TDLS_SW_ACTIVE,
645 };
646
647 enum iwl_mvm_traffic_load {
648 IWL_MVM_TRAFFIC_LOW,
649 IWL_MVM_TRAFFIC_MEDIUM,
650 IWL_MVM_TRAFFIC_HIGH,
651 };
652
653 DECLARE_EWMA(rate, 16, 16)
654
655 struct iwl_mvm_tcm_mac {
656 struct {
657 u32 pkts[IEEE80211_NUM_ACS];
658 u32 airtime;
659 } tx;
660 struct {
661 u32 pkts[IEEE80211_NUM_ACS];
662 u32 airtime;
663 u32 last_ampdu_ref;
664 } rx;
665 struct {
666 /* track AP's transfer in client mode */
667 u64 rx_bytes;
668 struct ewma_rate rate;
669 bool detected;
670 } uapsd_nonagg_detect;
671 bool opened_rx_ba_sessions;
672 };
673
674 struct iwl_mvm_tcm {
675 struct delayed_work work;
676 spinlock_t lock; /* used when time elapsed */
677 unsigned long ts; /* timestamp when period ends */
678 unsigned long ll_ts;
679 unsigned long uapsd_nonagg_ts;
680 bool paused;
681 struct iwl_mvm_tcm_mac data[NUM_MAC_INDEX_DRIVER];
682 struct {
683 u32 elapsed; /* milliseconds for this TCM period */
684 u32 airtime[NUM_MAC_INDEX_DRIVER];
685 enum iwl_mvm_traffic_load load[NUM_MAC_INDEX_DRIVER];
686 enum iwl_mvm_traffic_load band_load[NUM_NL80211_BANDS];
687 enum iwl_mvm_traffic_load global_load;
688 bool low_latency[NUM_MAC_INDEX_DRIVER];
689 bool change[NUM_MAC_INDEX_DRIVER];
690 } result;
691 };
692
693 /**
694 * struct iwl_mvm_reorder_buffer - per ra/tid/queue reorder buffer
695 * @head_sn: reorder window head sn
696 * @num_stored: number of mpdus stored in the buffer
697 * @queue: queue of this reorder buffer
698 * @valid: reordering is valid for this queue
699 * @lock: protect reorder buffer internal state
700 */
701 struct iwl_mvm_reorder_buffer {
702 u16 head_sn;
703 u16 num_stored;
704 int queue;
705 bool valid;
706 spinlock_t lock;
707 } ____cacheline_aligned_in_smp;
708
709 /**
710 * struct iwl_mvm_reorder_buf_entry - reorder buffer entry per-queue/per-seqno
711 * @frames: list of skbs stored
712 */
713 struct iwl_mvm_reorder_buf_entry {
714 struct sk_buff_head frames;
715 }
716 #ifndef __CHECKER__
717 /* sparse doesn't like this construct: "bad integer constant expression" */
718 __aligned(roundup_pow_of_two(sizeof(struct sk_buff_head)))
719 #endif
720 ;
721
722 /**
723 * struct iwl_mvm_baid_data - BA session data
724 * @sta_mask: current station mask for the BAID
725 * @tid: tid of the session
726 * @baid: baid of the session
727 * @timeout: the timeout set in the addba request
728 * @buf_size: the reorder buffer size as set by the last addba request
729 * @entries_per_queue: # of buffers per queue, this actually gets
730 * aligned up to avoid cache line sharing between queues
731 * @last_rx: last rx jiffies, updated only if timeout passed from last update
732 * @session_timer: timer to check if BA session expired, runs at 2 * timeout
733 * @rcu_ptr: BA data RCU protected access
734 * @rcu_head: RCU head for freeing this data
735 * @mvm: mvm pointer, needed for timer context
736 * @reorder_buf: reorder buffer, allocated per queue
737 * @entries: data
738 */
739 struct iwl_mvm_baid_data {
740 struct rcu_head rcu_head;
741 u32 sta_mask;
742 u8 tid;
743 u8 baid;
744 u16 timeout;
745 u16 buf_size;
746 u16 entries_per_queue;
747 unsigned long last_rx;
748 struct timer_list session_timer;
749 struct iwl_mvm_baid_data __rcu **rcu_ptr;
750 struct iwl_mvm *mvm;
751 struct iwl_mvm_reorder_buffer reorder_buf[IWL_MAX_RX_HW_QUEUES];
752 struct iwl_mvm_reorder_buf_entry entries[] ____cacheline_aligned_in_smp;
753 };
754
755 static inline struct iwl_mvm_baid_data *
iwl_mvm_baid_data_from_reorder_buf(struct iwl_mvm_reorder_buffer * buf)756 iwl_mvm_baid_data_from_reorder_buf(struct iwl_mvm_reorder_buffer *buf)
757 {
758 return (void *)((u8 *)buf -
759 offsetof(struct iwl_mvm_baid_data, reorder_buf) -
760 sizeof(*buf) * buf->queue);
761 }
762
763 /*
764 * enum iwl_mvm_queue_status - queue status
765 * @IWL_MVM_QUEUE_FREE: the queue is not allocated nor reserved
766 * Basically, this means that this queue can be used for any purpose
767 * @IWL_MVM_QUEUE_RESERVED: queue is reserved but not yet in use
768 * This is the state of a queue that has been dedicated for some RATID
769 * (agg'd or not), but that hasn't yet gone through the actual enablement
770 * of iwl_mvm_enable_txq(), and therefore no traffic can go through it yet.
771 * Note that in this state there is no requirement to already know what TID
772 * should be used with this queue, it is just marked as a queue that will
773 * be used, and shouldn't be allocated to anyone else.
774 * @IWL_MVM_QUEUE_READY: queue is ready to be used
775 * This is the state of a queue that has been fully configured (including
776 * SCD pointers, etc), has a specific RA/TID assigned to it, and can be
777 * used to send traffic.
778 * @IWL_MVM_QUEUE_SHARED: queue is shared, or in a process of becoming shared
779 * This is a state in which a single queue serves more than one TID, all of
780 * which are not aggregated. Note that the queue is only associated to one
781 * RA.
782 */
783 enum iwl_mvm_queue_status {
784 IWL_MVM_QUEUE_FREE,
785 IWL_MVM_QUEUE_RESERVED,
786 IWL_MVM_QUEUE_READY,
787 IWL_MVM_QUEUE_SHARED,
788 };
789
790 #define IWL_MVM_DQA_QUEUE_TIMEOUT (5 * HZ)
791 #define IWL_MVM_INVALID_QUEUE 0xFFFF
792
793 #define IWL_MVM_NUM_CIPHERS 10
794
795
796 struct iwl_mvm_txq {
797 struct list_head list;
798 u16 txq_id;
799 atomic_t tx_request;
800 #define IWL_MVM_TXQ_STATE_READY 0
801 #define IWL_MVM_TXQ_STATE_STOP_FULL 1
802 #define IWL_MVM_TXQ_STATE_STOP_REDIRECT 2
803 #define IWL_MVM_TXQ_STATE_STOP_AP_CSA 3
804 unsigned long state;
805 };
806
807 static inline struct iwl_mvm_txq *
iwl_mvm_txq_from_mac80211(struct ieee80211_txq * txq)808 iwl_mvm_txq_from_mac80211(struct ieee80211_txq *txq)
809 {
810 return (void *)txq->drv_priv;
811 }
812
813 static inline struct iwl_mvm_txq *
iwl_mvm_txq_from_tid(struct ieee80211_sta * sta,u8 tid)814 iwl_mvm_txq_from_tid(struct ieee80211_sta *sta, u8 tid)
815 {
816 if (tid == IWL_MAX_TID_COUNT)
817 tid = IEEE80211_NUM_TIDS;
818
819 return (void *)sta->txq[tid]->drv_priv;
820 }
821
822 /**
823 * struct iwl_mvm_tvqm_txq_info - maps TVQM hw queue to tid
824 *
825 * @sta_id: sta id
826 * @txq_tid: txq tid
827 */
828 struct iwl_mvm_tvqm_txq_info {
829 u8 sta_id;
830 u8 txq_tid;
831 };
832
833 struct iwl_mvm_dqa_txq_info {
834 u8 ra_sta_id; /* The RA this queue is mapped to, if exists */
835 bool reserved; /* Is this the TXQ reserved for a STA */
836 u8 mac80211_ac; /* The mac80211 AC this queue is mapped to */
837 u8 txq_tid; /* The TID "owner" of this queue*/
838 u16 tid_bitmap; /* Bitmap of the TIDs mapped to this queue */
839 /* Timestamp for inactivation per TID of this queue */
840 unsigned long last_frame_time[IWL_MAX_TID_COUNT + 1];
841 enum iwl_mvm_queue_status status;
842 };
843
844 struct ptp_data {
845 struct ptp_clock *ptp_clock;
846 struct ptp_clock_info ptp_clock_info;
847
848 struct delayed_work dwork;
849
850 /* The last GP2 reading from the hw */
851 u32 last_gp2;
852
853 /* number of wraparounds since scale_update_adj_time_ns */
854 u32 wrap_counter;
855
856 /* GP2 time when the scale was last updated */
857 u32 scale_update_gp2;
858
859 /* Adjusted time when the scale was last updated in nanoseconds */
860 u64 scale_update_adj_time_ns;
861
862 /* clock frequency offset, scaled to 65536000000 */
863 u64 scaled_freq;
864
865 /* Delta between hardware clock and ptp clock in nanoseconds */
866 s64 delta;
867 };
868
869 struct iwl_time_sync_data {
870 struct sk_buff_head frame_list;
871 u8 peer_addr[ETH_ALEN];
872 bool active;
873 };
874
875 struct iwl_mei_scan_filter {
876 bool is_mei_limited_scan;
877 struct sk_buff_head scan_res;
878 struct work_struct scan_work;
879 };
880
881 /**
882 * struct iwl_mvm_acs_survey_channel - per-channel survey information
883 *
884 * Stripped down version of &struct survey_info.
885 *
886 * @time: time in ms the radio was on the channel
887 * @time_busy: time in ms the channel was sensed busy
888 * @time_tx: time in ms spent transmitting data
889 * @time_rx: time in ms spent receiving data
890 * @noise: channel noise in dBm
891 */
892 struct iwl_mvm_acs_survey_channel {
893 u32 time;
894 u32 time_busy;
895 u32 time_tx;
896 u32 time_rx;
897 s8 noise;
898 };
899
900 struct iwl_mvm_acs_survey {
901 struct iwl_mvm_acs_survey_channel *bands[NUM_NL80211_BANDS];
902
903 /* Overall number of channels */
904 int n_channels;
905
906 /* Storage space for per-channel information follows */
907 struct iwl_mvm_acs_survey_channel channels[] __counted_by(n_channels);
908 };
909
910 struct iwl_mvm {
911 /* for logger access */
912 struct device *dev;
913
914 struct iwl_trans *trans;
915 const struct iwl_fw *fw;
916 const struct iwl_rf_cfg *cfg;
917 struct iwl_phy_db *phy_db;
918 struct ieee80211_hw *hw;
919
920 /* for protecting access to iwl_mvm */
921 struct mutex mutex;
922 struct list_head async_handlers_list;
923 spinlock_t async_handlers_lock;
924 struct work_struct async_handlers_wk;
925
926 /* For async rx handlers that require the wiphy lock */
927 struct wiphy_work async_handlers_wiphy_wk;
928
929 struct work_struct roc_done_wk;
930
931 unsigned long init_status;
932
933 unsigned long status;
934
935 u32 queue_sync_cookie;
936 unsigned long queue_sync_state;
937 /*
938 * for beacon filtering -
939 * currently only one interface can be supported
940 */
941 struct iwl_mvm_vif *bf_allowed_vif;
942
943 bool hw_registered;
944 bool rfkill_safe_init_done;
945
946 u8 cca_40mhz_workaround;
947
948 u8 fw_rates_ver;
949
950 u32 ampdu_ref;
951 bool ampdu_toggle;
952
953 struct iwl_notif_wait_data notif_wait;
954
955 union {
956 struct mvm_statistics_rx_v3 rx_stats_v3;
957 struct mvm_statistics_rx rx_stats;
958 };
959
960 struct {
961 u64 rx_time;
962 u64 tx_time;
963 u64 on_time_rf;
964 u64 on_time_scan;
965 } radio_stats, accu_radio_stats;
966
967 struct list_head add_stream_txqs;
968 union {
969 struct iwl_mvm_dqa_txq_info queue_info[IWL_MAX_HW_QUEUES];
970 struct iwl_mvm_tvqm_txq_info tvqm_info[IWL_MAX_TVQM_QUEUES];
971 };
972 struct work_struct add_stream_wk; /* To add streams to queues */
973 spinlock_t add_stream_lock;
974
975 const char *nvm_file_name;
976 struct iwl_nvm_data *nvm_data;
977 struct iwl_mei_nvm *mei_nvm_data;
978 struct iwl_mvm_csme_conn_info __rcu *csme_conn_info;
979 bool mei_rfkill_blocked;
980 bool mei_registered;
981 struct work_struct sap_connected_wk;
982
983 /*
984 * NVM built based on the SAP data but that we can't free even after
985 * we get ownership because it contains the cfg80211's channel.
986 */
987 struct iwl_nvm_data *temp_nvm_data;
988
989 /* NVM sections */
990 struct iwl_nvm_section nvm_sections[NVM_MAX_NUM_SECTIONS];
991
992 struct iwl_fw_runtime fwrt;
993
994 /* EEPROM MAC addresses */
995 struct mac_address addresses[IWL_MVM_MAX_ADDRESSES];
996
997 /* data related to data path */
998 struct iwl_rx_phy_info last_phy_info;
999 struct ieee80211_sta __rcu *fw_id_to_mac_id[IWL_STATION_COUNT_MAX];
1000 /* note: fw_id_to_link_sta must be protected by wiphy and mvm mutexes */
1001 struct ieee80211_link_sta __rcu *fw_id_to_link_sta[IWL_STATION_COUNT_MAX];
1002 u8 rx_ba_sessions;
1003
1004 /* configured by mac80211 */
1005 u32 rts_threshold;
1006
1007 /* Scan status, cmd (pre-allocated) and auxiliary station */
1008 unsigned int scan_status;
1009 size_t scan_cmd_size;
1010 void *scan_cmd;
1011 struct iwl_mcast_filter_cmd *mcast_filter_cmd;
1012 /* For CDB this is low band scan type, for non-CDB - type. */
1013 enum iwl_mvm_scan_type scan_type;
1014 enum iwl_mvm_scan_type hb_scan_type;
1015
1016 enum iwl_mvm_sched_scan_pass_all_states sched_scan_pass_all;
1017 struct delayed_work scan_timeout_dwork;
1018
1019 /* max number of simultaneous scans the FW supports */
1020 unsigned int max_scans;
1021
1022 /* UMAC scan tracking */
1023 u32 scan_uid_status[IWL_MAX_UMAC_SCANS];
1024
1025 /* start time of last scan in TSF of the mac that requested the scan */
1026 u64 scan_start;
1027
1028 /* the vif that requested the current scan */
1029 struct iwl_mvm_vif *scan_vif;
1030 u8 scan_link_id;
1031
1032 /* rx chain antennas set through debugfs for the scan command */
1033 u8 scan_rx_ant;
1034
1035 /* Internal station */
1036 struct iwl_mvm_int_sta aux_sta;
1037 struct iwl_mvm_int_sta snif_sta;
1038
1039 bool last_ebs_successful;
1040
1041 u8 scan_last_antenna_idx; /* to toggle TX between antennas */
1042 u8 mgmt_last_antenna_idx;
1043
1044 u8 set_tx_ant;
1045 u8 set_rx_ant;
1046
1047 /* last smart fifo state that was successfully sent to firmware */
1048 enum iwl_sf_state sf_state;
1049
1050 /*
1051 * Leave this pointer outside the ifdef below so that it can be
1052 * assigned without ifdef in the source code.
1053 */
1054 struct dentry *debugfs_dir;
1055 #ifdef CONFIG_IWLWIFI_DEBUGFS
1056 u32 dbgfs_sram_offset, dbgfs_sram_len;
1057 u32 dbgfs_prph_reg_addr;
1058 bool disable_power_off;
1059 bool disable_power_off_d3;
1060 bool beacon_inject_active;
1061
1062 bool scan_iter_notif_enabled;
1063
1064 struct debugfs_blob_wrapper nvm_hw_blob;
1065 struct debugfs_blob_wrapper nvm_sw_blob;
1066 struct debugfs_blob_wrapper nvm_calib_blob;
1067 struct debugfs_blob_wrapper nvm_prod_blob;
1068 struct debugfs_blob_wrapper nvm_phy_sku_blob;
1069 struct debugfs_blob_wrapper nvm_reg_blob;
1070
1071 struct iwl_mvm_frame_stats drv_rx_stats;
1072 spinlock_t drv_stats_lock;
1073 u16 dbgfs_rx_phyinfo;
1074 #endif
1075
1076 struct iwl_mvm_phy_ctxt phy_ctxts[NUM_PHY_CTX];
1077
1078 struct list_head time_event_list;
1079 spinlock_t time_event_lock;
1080
1081 /*
1082 * A bitmap indicating the index of the key in use. The firmware
1083 * can hold 16 keys at most. Reflect this fact.
1084 */
1085 unsigned long fw_key_table[BITS_TO_LONGS(STA_KEY_MAX_NUM)];
1086 u8 fw_key_deleted[STA_KEY_MAX_NUM];
1087
1088 struct ieee80211_vif __rcu *vif_id_to_mac[NUM_MAC_INDEX_DRIVER];
1089
1090 u8 *error_recovery_buf;
1091
1092 #ifdef CONFIG_IWLWIFI_LEDS
1093 struct led_classdev led;
1094 #endif
1095
1096 struct ieee80211_vif *p2p_device_vif;
1097
1098 #ifdef CONFIG_PM_SLEEP
1099 struct wiphy_wowlan_support wowlan;
1100 int gtk_ivlen, gtk_icvlen, ptk_ivlen, ptk_icvlen;
1101
1102 /* sched scan settings for net detect */
1103 struct ieee80211_scan_ies nd_ies;
1104 struct cfg80211_match_set *nd_match_sets;
1105 int n_nd_match_sets;
1106 struct ieee80211_channel **nd_channels;
1107 int n_nd_channels;
1108 bool net_detect;
1109 bool fast_resume;
1110 u8 offload_tid;
1111 #ifdef CONFIG_IWLWIFI_DEBUGFS
1112 bool d3_wake_sysassert;
1113 u32 last_netdetect_scans; /* no. of scans in the last net-detect wake */
1114 #endif
1115 #endif
1116
1117 wait_queue_head_t rx_sync_waitq;
1118
1119 struct iwl_bt_coex_prof_old_notif last_bt_notif;
1120 struct iwl_bt_coex_ci_cmd last_bt_ci_cmd;
1121
1122 u8 bt_tx_prio;
1123 enum iwl_bt_force_ant_mode bt_force_ant_mode;
1124
1125 /* Aux ROC */
1126 struct list_head aux_roc_te_list;
1127
1128 /* Thermal Throttling and CTkill */
1129 struct iwl_mvm_tt_mgmt thermal_throttle;
1130 #ifdef CONFIG_THERMAL
1131 struct iwl_mvm_thermal_device tz_device;
1132 struct iwl_mvm_cooling_device cooling_dev;
1133 #endif
1134
1135 s32 temperature; /* Celsius */
1136 /*
1137 * Debug option to set the NIC temperature. This option makes the
1138 * driver think this is the actual NIC temperature, and ignore the
1139 * real temperature that is received from the fw
1140 */
1141 bool temperature_test; /* Debug test temperature is enabled */
1142
1143 bool fw_static_smps_request;
1144
1145 unsigned long bt_coex_last_tcm_ts;
1146 struct iwl_mvm_tcm tcm;
1147
1148 u8 uapsd_noagg_bssid_write_idx;
1149 struct mac_address uapsd_noagg_bssids[IWL_MVM_UAPSD_NOAGG_BSSIDS_NUM]
1150 __aligned(2);
1151
1152 struct iwl_time_quota_cmd last_quota_cmd;
1153
1154 /* Tx queues */
1155 u16 aux_queue;
1156 u16 snif_queue;
1157 u16 probe_queue;
1158 u16 p2p_dev_queue;
1159
1160 /* Indicate if device power save is allowed */
1161 u8 ps_disabled; /* u8 instead of bool to ease debugfs_create_* usage */
1162 /* Indicate if 32Khz external clock is valid */
1163 u32 ext_clock_valid;
1164
1165 /* This vif used by CSME to send / receive traffic */
1166 struct ieee80211_vif *csme_vif;
1167 struct ieee80211_vif __rcu *csa_vif;
1168 struct ieee80211_vif __rcu *csa_tx_blocked_vif;
1169 u8 csa_tx_block_bcn_timeout;
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 u8 iwl_mvm_rate_idx_to_plcp(int idx);
1650 int iwl_mvm_legacy_hw_idx_to_mac80211_idx(u32 rate_n_flags,
1651 enum nl80211_band band);
1652 int iwl_mvm_legacy_rate_to_mac80211_idx(u32 rate_n_flags,
1653 enum nl80211_band band);
1654 void iwl_mvm_hwrate_to_tx_rate(u32 rate_n_flags,
1655 enum nl80211_band band,
1656 struct ieee80211_tx_rate *r);
1657 u8 iwl_mvm_rate_idx_to_fw_idx(const struct iwl_fw *fw, int rate_idx);
1658 u8 iwl_mvm_mac80211_ac_to_ucode_ac(enum ieee80211_ac_numbers ac);
1659 bool iwl_mvm_is_nic_ack_enabled(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1660 void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm);
1661
iwl_mvm_dump_nic_error_log(struct iwl_mvm * mvm)1662 static inline void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm)
1663 {
1664 iwl_fwrt_dump_error_logs(&mvm->fwrt);
1665 }
1666
1667 u8 first_antenna(u8 mask);
1668 u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx);
1669 void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, int clock_type, u32 *gp2,
1670 u64 *boottime, ktime_t *realtime);
1671 u32 iwl_mvm_get_systime(struct iwl_mvm *mvm);
1672
1673 /* Tx / Host Commands */
1674 int iwl_mvm_send_cmd(struct iwl_mvm *mvm,
1675 struct iwl_host_cmd *cmd);
1676 int _iwl_mvm_send_cmd_pdu(struct iwl_mvm *mvm, u32 id,
1677 u32 flags, u16 len, const void *data);
1678 #define iwl_mvm_send_cmd_pdu(mvm, id, flags, len, data) ({ \
1679 BUILD_BUG_ON(__builtin_constant_p(len) && \
1680 (u16)(len) > IWL_MAX_CMD_PAYLOAD_SIZE); \
1681 _iwl_mvm_send_cmd_pdu(mvm, id, flags, len, data); \
1682 })
1683 int iwl_mvm_send_cmd_status(struct iwl_mvm *mvm,
1684 struct iwl_host_cmd *cmd,
1685 u32 *status);
1686 int _iwl_mvm_send_cmd_pdu_status(struct iwl_mvm *mvm, u32 id,
1687 u16 len, const void *data,
1688 u32 *status);
1689 #define iwl_mvm_send_cmd_pdu_status(mvm, id, len, data, status) ({ \
1690 BUILD_BUG_ON(__builtin_constant_p(len) && \
1691 (u16)(len) > IWL_MAX_CMD_PAYLOAD_SIZE); \
1692 _iwl_mvm_send_cmd_pdu_status(mvm, id, len, data, status); \
1693 })
1694 int iwl_mvm_tx_skb_sta(struct iwl_mvm *mvm, struct sk_buff *skb,
1695 struct ieee80211_sta *sta);
1696 int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb);
1697 void iwl_mvm_set_tx_cmd(struct iwl_mvm *mvm, struct sk_buff *skb,
1698 struct iwl_tx_cmd_v6_params *tx_cmd_params,
1699 struct ieee80211_tx_info *info, u8 sta_id);
1700 void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm,
1701 struct iwl_tx_cmd_v6_params *tx_cmd_params,
1702 struct ieee80211_tx_info *info,
1703 struct ieee80211_sta *sta, __le16 fc);
1704 void iwl_mvm_mac_itxq_xmit(struct ieee80211_hw *hw, struct ieee80211_txq *txq);
1705 unsigned int iwl_mvm_max_amsdu_size(struct iwl_mvm *mvm,
1706 struct ieee80211_sta *sta,
1707 unsigned int tid);
1708
1709 #ifdef CONFIG_IWLWIFI_DEBUG
1710 const char *iwl_mvm_get_tx_fail_reason(u32 status);
1711 #else
iwl_mvm_get_tx_fail_reason(u32 status)1712 static inline const char *iwl_mvm_get_tx_fail_reason(u32 status) { return ""; }
1713 #endif
1714 int iwl_mvm_flush_tx_path(struct iwl_mvm *mvm, u32 tfd_msk);
1715 int iwl_mvm_flush_sta(struct iwl_mvm *mvm, u32 sta_id, u32 tfd_queue_mask);
1716 int iwl_mvm_flush_sta_tids(struct iwl_mvm *mvm, u32 sta_id, u16 tids);
1717
1718 /* Utils to extract sta related data */
1719 __le32 iwl_mvm_get_sta_htc_flags(struct ieee80211_sta *sta,
1720 struct ieee80211_link_sta *link_sta);
1721 u8 iwl_mvm_get_sta_uapsd_acs(struct ieee80211_sta *sta);
1722 u32 iwl_mvm_get_sta_ampdu_dens(struct ieee80211_link_sta *link_sta,
1723 struct ieee80211_bss_conf *link_conf,
1724 u32 *_agg_size);
1725 int iwl_mvm_set_sta_pkt_ext(struct iwl_mvm *mvm,
1726 struct ieee80211_link_sta *link_sta,
1727 struct iwl_he_pkt_ext_v2 *pkt_ext);
1728
1729 void iwl_mvm_async_handlers_purge(struct iwl_mvm *mvm);
1730
iwl_mvm_set_tx_cmd_ccmp(struct ieee80211_tx_info * info,struct iwl_tx_cmd_v6_params * tx_cmd_params)1731 static inline void iwl_mvm_set_tx_cmd_ccmp(struct ieee80211_tx_info *info,
1732 struct iwl_tx_cmd_v6_params *tx_cmd_params)
1733 {
1734 struct ieee80211_key_conf *keyconf = info->control.hw_key;
1735
1736 tx_cmd_params->sec_ctl = TX_CMD_SEC_CCM;
1737 memcpy(tx_cmd_params->key, keyconf->key, keyconf->keylen);
1738 }
1739
iwl_mvm_wait_for_async_handlers(struct iwl_mvm * mvm)1740 static inline void iwl_mvm_wait_for_async_handlers(struct iwl_mvm *mvm)
1741 {
1742 flush_work(&mvm->async_handlers_wk);
1743 }
1744
1745 /* Statistics */
1746 void iwl_mvm_handle_rx_system_oper_stats(struct iwl_mvm *mvm,
1747 struct iwl_rx_cmd_buffer *rxb);
1748 void iwl_mvm_handle_rx_system_oper_part1_stats(struct iwl_mvm *mvm,
1749 struct iwl_rx_cmd_buffer *rxb);
1750 static inline void
iwl_mvm_handle_rx_system_end_stats_notif(struct iwl_mvm * mvm,struct iwl_rx_cmd_buffer * rxb)1751 iwl_mvm_handle_rx_system_end_stats_notif(struct iwl_mvm *mvm,
1752 struct iwl_rx_cmd_buffer *rxb)
1753 {
1754 }
1755
1756 void iwl_mvm_handle_rx_statistics(struct iwl_mvm *mvm,
1757 struct iwl_rx_packet *pkt);
1758 void iwl_mvm_rx_statistics(struct iwl_mvm *mvm,
1759 struct iwl_rx_cmd_buffer *rxb);
1760 int iwl_mvm_request_statistics(struct iwl_mvm *mvm, bool clear);
1761 int iwl_mvm_request_periodic_system_statistics(struct iwl_mvm *mvm,
1762 bool enable);
1763 void iwl_mvm_accu_radio_stats(struct iwl_mvm *mvm);
1764
1765 /* NVM */
1766 int iwl_nvm_init(struct iwl_mvm *mvm);
1767 int iwl_mvm_load_nvm_to_nic(struct iwl_mvm *mvm);
1768
iwl_mvm_get_valid_tx_ant(struct iwl_mvm * mvm)1769 static inline u8 iwl_mvm_get_valid_tx_ant(struct iwl_mvm *mvm)
1770 {
1771 u8 tx_ant = mvm->fw->valid_tx_ant;
1772
1773 if (mvm->nvm_data && mvm->nvm_data->valid_tx_ant)
1774 tx_ant &= mvm->nvm_data->valid_tx_ant;
1775
1776 if (mvm->set_tx_ant)
1777 tx_ant &= mvm->set_tx_ant;
1778
1779 return tx_ant;
1780 }
1781
iwl_mvm_get_valid_rx_ant(struct iwl_mvm * mvm)1782 static inline u8 iwl_mvm_get_valid_rx_ant(struct iwl_mvm *mvm)
1783 {
1784 u8 rx_ant = mvm->fw->valid_rx_ant;
1785
1786 if (mvm->nvm_data && mvm->nvm_data->valid_rx_ant)
1787 rx_ant &= mvm->nvm_data->valid_rx_ant;
1788
1789 if (mvm->set_rx_ant)
1790 rx_ant &= mvm->set_rx_ant;
1791
1792 return rx_ant;
1793
1794 }
1795
iwl_mvm_toggle_tx_ant(struct iwl_mvm * mvm,u8 * ant)1796 static inline void iwl_mvm_toggle_tx_ant(struct iwl_mvm *mvm, u8 *ant)
1797 {
1798 *ant = iwl_mvm_next_antenna(mvm, iwl_mvm_get_valid_tx_ant(mvm), *ant);
1799 }
1800
iwl_mvm_get_phy_config(struct iwl_mvm * mvm)1801 static inline u32 iwl_mvm_get_phy_config(struct iwl_mvm *mvm)
1802 {
1803 u32 phy_config = ~(FW_PHY_CFG_TX_CHAIN |
1804 FW_PHY_CFG_RX_CHAIN);
1805 u32 valid_rx_ant = iwl_mvm_get_valid_rx_ant(mvm);
1806 u32 valid_tx_ant = iwl_mvm_get_valid_tx_ant(mvm);
1807
1808 phy_config |= valid_tx_ant << FW_PHY_CFG_TX_CHAIN_POS |
1809 valid_rx_ant << FW_PHY_CFG_RX_CHAIN_POS;
1810
1811 return mvm->fw->phy_config & phy_config;
1812 }
1813
1814 int iwl_mvm_up(struct iwl_mvm *mvm);
1815 int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm);
1816
1817 int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm);
1818
1819 void iwl_mvm_mac_init_mvmvif(struct iwl_mvm *mvm, struct iwl_mvm_vif *mvmvif);
1820
1821 /*
1822 * FW notifications / CMD responses handlers
1823 * Convention: iwl_mvm_rx_<NAME OF THE CMD>
1824 */
1825 void iwl_mvm_rx_mq(struct iwl_op_mode *op_mode,
1826 struct napi_struct *napi,
1827 struct iwl_rx_cmd_buffer *rxb);
1828 void iwl_mvm_rx_rx_phy_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1829 void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi,
1830 struct iwl_rx_cmd_buffer *rxb);
1831 void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
1832 struct iwl_rx_cmd_buffer *rxb, int queue);
1833 void iwl_mvm_rx_monitor_no_data(struct iwl_mvm *mvm, struct napi_struct *napi,
1834 struct iwl_rx_cmd_buffer *rxb, int queue);
1835 void iwl_mvm_rx_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi,
1836 struct iwl_rx_cmd_buffer *rxb, int queue);
1837 void iwl_mvm_rx_bar_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi,
1838 struct iwl_rx_cmd_buffer *rxb, int queue);
1839 void iwl_mvm_rx_queue_notif(struct iwl_mvm *mvm, struct napi_struct *napi,
1840 struct iwl_rx_cmd_buffer *rxb, int queue);
1841 void iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1842 void iwl_mvm_mfu_assert_dump_notif(struct iwl_mvm *mvm,
1843 struct iwl_rx_cmd_buffer *rxb);
1844 void iwl_mvm_send_recovery_cmd(struct iwl_mvm *mvm, u32 flags);
1845 void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1846 void iwl_mvm_rx_ant_coupling_notif(struct iwl_mvm *mvm,
1847 struct iwl_rx_cmd_buffer *rxb);
1848 void iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1849 void iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm,
1850 struct iwl_rx_cmd_buffer *rxb);
1851 void iwl_mvm_rx_shared_mem_cfg_notif(struct iwl_mvm *mvm,
1852 struct iwl_rx_cmd_buffer *rxb);
1853
1854 /* MVM PHY */
1855 struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm);
1856 int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
1857 const struct cfg80211_chan_def *chandef,
1858 const struct cfg80211_chan_def *ap,
1859 u8 chains_static, u8 chains_dynamic);
1860 int iwl_mvm_phy_ctxt_changed(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
1861 const struct cfg80211_chan_def *chandef,
1862 const struct cfg80211_chan_def *ap,
1863 u8 chains_static, u8 chains_dynamic);
1864 void iwl_mvm_phy_ctxt_ref(struct iwl_mvm *mvm,
1865 struct iwl_mvm_phy_ctxt *ctxt);
1866 void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm,
1867 struct iwl_mvm_phy_ctxt *ctxt);
1868 int iwl_mvm_phy_ctx_count(struct iwl_mvm *mvm);
1869 u8 iwl_mvm_get_channel_width(const struct cfg80211_chan_def *chandef);
1870 u8 iwl_mvm_get_ctrl_pos(const struct cfg80211_chan_def *chandef);
1871 int iwl_mvm_phy_send_rlc(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
1872 u8 chains_static, u8 chains_dynamic);
1873
1874 /* MAC (virtual interface) programming */
1875
1876 void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm,
1877 struct ieee80211_vif *vif);
1878 void iwl_mvm_set_fw_basic_rates(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1879 struct iwl_mvm_vif_link_info *link_info,
1880 __le32 *cck_rates, __le32 *ofdm_rates);
1881 void iwl_mvm_set_fw_protection_flags(struct iwl_mvm *mvm,
1882 struct ieee80211_vif *vif,
1883 struct ieee80211_bss_conf *link_conf,
1884 __le32 *protection_flags, u32 ht_flag,
1885 u32 tgg_flag);
1886 void iwl_mvm_set_fw_qos_params(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1887 struct ieee80211_bss_conf *link_conf,
1888 struct iwl_ac_qos *ac, __le32 *qos_flags);
1889 bool iwl_mvm_set_fw_mu_edca_params(struct iwl_mvm *mvm,
1890 const struct iwl_mvm_vif_link_info *link_info,
1891 struct iwl_he_backoff_conf *trig_based_txf);
1892 void iwl_mvm_set_fw_dtim_tbtt(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1893 struct ieee80211_bss_conf *link_conf,
1894 __le64 *dtim_tsf, __le32 *dtim_time,
1895 __le32 *assoc_beacon_arrive_time);
1896 __le32 iwl_mac_ctxt_p2p_dev_has_extended_disc(struct iwl_mvm *mvm,
1897 struct ieee80211_vif *vif);
1898 void iwl_mvm_mac_ctxt_cmd_ap_set_filter_flags(struct iwl_mvm *mvm,
1899 struct iwl_mvm_vif *mvmvif,
1900 __le32 *filter_flags,
1901 int accept_probe_req_flag,
1902 int accept_beacon_flag);
1903 int iwl_mvm_get_mac_type(struct ieee80211_vif *vif);
1904 __le32 iwl_mvm_mac_ctxt_cmd_p2p_sta_get_oppps_ctwin(struct iwl_mvm *mvm,
1905 struct ieee80211_vif *vif);
1906 u32 iwl_mvm_mac_ctxt_cmd_sta_get_twt_policy(struct iwl_mvm *mvm,
1907 struct ieee80211_vif *vif);
1908 int iwl_mvm_mld_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1909 int iwl_mvm_mld_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1910 bool force_assoc_off);
1911 int iwl_mvm_mld_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1912 int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1913 int iwl_mvm_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1914 int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1915 bool force_assoc_off, const u8 *bssid_override);
1916 int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1917 int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
1918 struct ieee80211_vif *vif,
1919 struct ieee80211_bss_conf *link_conf);
1920 int iwl_mvm_mac_ctxt_send_beacon_cmd(struct iwl_mvm *mvm,
1921 struct sk_buff *beacon,
1922 void *data, int len);
1923 u8 iwl_mvm_mac_ctxt_get_beacon_rate(struct iwl_mvm *mvm,
1924 struct ieee80211_tx_info *info,
1925 struct ieee80211_vif *vif);
1926 u8 iwl_mvm_mac_ctxt_get_lowest_rate(struct iwl_mvm *mvm,
1927 struct ieee80211_tx_info *info,
1928 struct ieee80211_vif *vif);
1929 u16 iwl_mvm_mac_ctxt_get_beacon_flags(const struct iwl_fw *fw,
1930 u8 rate_idx);
1931 void iwl_mvm_mac_ctxt_set_tim(struct iwl_mvm *mvm,
1932 __le32 *tim_index, __le32 *tim_size,
1933 u8 *beacon, u32 frame_size);
1934 void iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
1935 struct iwl_rx_cmd_buffer *rxb);
1936 void iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm,
1937 struct iwl_rx_cmd_buffer *rxb);
1938 void iwl_mvm_rx_missed_beacons_notif_legacy(struct iwl_mvm *mvm,
1939 struct iwl_rx_cmd_buffer *rxb);
1940 void iwl_mvm_rx_stored_beacon_notif(struct iwl_mvm *mvm,
1941 struct iwl_rx_cmd_buffer *rxb);
1942 void iwl_mvm_mu_mimo_grp_notif(struct iwl_mvm *mvm,
1943 struct iwl_rx_cmd_buffer *rxb);
1944 void iwl_mvm_sta_pm_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1945 void iwl_mvm_window_status_notif(struct iwl_mvm *mvm,
1946 struct iwl_rx_cmd_buffer *rxb);
1947 void iwl_mvm_mac_ctxt_recalc_tsf_id(struct iwl_mvm *mvm,
1948 struct ieee80211_vif *vif);
1949 void iwl_mvm_probe_resp_data_notif(struct iwl_mvm *mvm,
1950 struct iwl_rx_cmd_buffer *rxb);
1951 void iwl_mvm_channel_switch_start_notif(struct iwl_mvm *mvm,
1952 struct iwl_rx_cmd_buffer *rxb);
1953 void iwl_mvm_channel_switch_error_notif(struct iwl_mvm *mvm,
1954 struct iwl_rx_cmd_buffer *rxb);
1955 void iwl_mvm_rx_beacon_filter_notif(struct iwl_mvm *mvm,
1956 struct iwl_rx_cmd_buffer *rxb);
1957
1958 /* Bindings */
1959 int iwl_mvm_binding_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1960 int iwl_mvm_binding_remove_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1961 u32 iwl_mvm_get_lmac_id(struct iwl_mvm *mvm, enum nl80211_band band);
1962
1963 /* Links */
1964 void iwl_mvm_init_link(struct iwl_mvm_vif_link_info *link);
1965 void iwl_mvm_set_link_fw_id(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1966 struct ieee80211_bss_conf *link_conf);
1967 int iwl_mvm_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1968 struct ieee80211_bss_conf *link_conf);
1969 int iwl_mvm_link_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1970 struct ieee80211_bss_conf *link_conf,
1971 u32 changes, bool active);
1972 int iwl_mvm_remove_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1973 struct ieee80211_bss_conf *link_conf);
1974 int iwl_mvm_disable_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1975 struct ieee80211_bss_conf *link_conf);
1976
1977 #if IS_ENABLED(CONFIG_IWLWIFI_KUNIT_TESTS)
1978 extern const struct iwl_hcmd_arr iwl_mvm_groups[];
1979 extern const unsigned int iwl_mvm_groups_size;
1980 #endif
1981
1982 /* AP and IBSS */
1983 bool iwl_mvm_start_ap_ibss_common(struct ieee80211_hw *hw,
1984 struct ieee80211_vif *vif, int *ret);
1985 void iwl_mvm_stop_ap_ibss_common(struct iwl_mvm *mvm,
1986 struct ieee80211_vif *vif);
1987
1988 /* BSS Info */
1989 void iwl_mvm_bss_info_changed_station_common(struct iwl_mvm *mvm,
1990 struct ieee80211_vif *vif,
1991 struct ieee80211_bss_conf *link_conf,
1992 u64 changes);
1993 void iwl_mvm_bss_info_changed_station_assoc(struct iwl_mvm *mvm,
1994 struct ieee80211_vif *vif,
1995 u64 changes);
1996
1997 /* ROC */
1998 /**
1999 * struct iwl_mvm_roc_ops - callbacks for the remain_on_channel()
2000 *
2001 * Since the only difference between both MLD and
2002 * non-MLD versions of remain_on_channel() is these function calls,
2003 * each version will send its specific function calls to
2004 * %iwl_mvm_roc_common().
2005 *
2006 * @add_aux_sta_for_hs20: pointer to the function that adds an aux sta
2007 * for Hot Spot 2.0
2008 * @link: For a P2P Device interface, pointer to a function that links the
2009 * MAC/Link to the PHY context
2010 */
2011 struct iwl_mvm_roc_ops {
2012 int (*add_aux_sta_for_hs20)(struct iwl_mvm *mvm, u32 lmac_id);
2013 int (*link)(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2014 };
2015
2016 int iwl_mvm_roc_common(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2017 struct ieee80211_channel *channel, int duration,
2018 enum ieee80211_roc_type type,
2019 const struct iwl_mvm_roc_ops *ops);
2020 int iwl_mvm_cancel_roc(struct ieee80211_hw *hw,
2021 struct ieee80211_vif *vif);
2022 /*Session Protection */
2023 void iwl_mvm_protect_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2024 u32 duration_override);
2025
2026 /* Quota management */
iwl_mvm_quota_cmd_size(struct iwl_mvm * mvm)2027 static inline size_t iwl_mvm_quota_cmd_size(struct iwl_mvm *mvm)
2028 {
2029 return iwl_mvm_has_quota_low_latency(mvm) ?
2030 sizeof(struct iwl_time_quota_cmd) :
2031 sizeof(struct iwl_time_quota_cmd_v1);
2032 }
2033
2034 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)2035 *iwl_mvm_quota_cmd_get_quota(struct iwl_mvm *mvm,
2036 struct iwl_time_quota_cmd *cmd,
2037 int i)
2038 {
2039 struct iwl_time_quota_data_v1 *quotas;
2040
2041 if (iwl_mvm_has_quota_low_latency(mvm))
2042 return &cmd->quotas[i];
2043
2044 quotas = (struct iwl_time_quota_data_v1 *)cmd->quotas;
2045 return (struct iwl_time_quota_data *)"as[i];
2046 }
2047
2048 int iwl_mvm_update_quotas(struct iwl_mvm *mvm, bool force_upload,
2049 struct ieee80211_vif *disabled_vif);
2050
2051 /* Scanning */
2052 int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2053 struct cfg80211_scan_request *req,
2054 struct ieee80211_scan_ies *ies);
2055 size_t iwl_mvm_scan_size(struct iwl_mvm *mvm);
2056 int iwl_mvm_scan_stop(struct iwl_mvm *mvm, int type, bool notify);
2057
2058 int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm);
2059 void iwl_mvm_report_scan_aborted(struct iwl_mvm *mvm);
2060 void iwl_mvm_scan_timeout_wk(struct work_struct *work);
2061 void iwl_mvm_rx_channel_survey_notif(struct iwl_mvm *mvm,
2062 struct iwl_rx_cmd_buffer *rxb);
2063
2064 /* Scheduled scan */
2065 void iwl_mvm_rx_lmac_scan_complete_notif(struct iwl_mvm *mvm,
2066 struct iwl_rx_cmd_buffer *rxb);
2067 void iwl_mvm_rx_lmac_scan_iter_complete_notif(struct iwl_mvm *mvm,
2068 struct iwl_rx_cmd_buffer *rxb);
2069 int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
2070 struct ieee80211_vif *vif,
2071 struct cfg80211_sched_scan_request *req,
2072 struct ieee80211_scan_ies *ies,
2073 int type);
2074 void iwl_mvm_rx_scan_match_found(struct iwl_mvm *mvm,
2075 struct iwl_rx_cmd_buffer *rxb);
2076
2077 /* UMAC scan */
2078 int iwl_mvm_config_scan(struct iwl_mvm *mvm);
2079 void iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm,
2080 struct iwl_rx_cmd_buffer *rxb);
2081 void iwl_mvm_rx_umac_scan_iter_complete_notif(struct iwl_mvm *mvm,
2082 struct iwl_rx_cmd_buffer *rxb);
2083
2084 /* MVM debugfs */
2085 #ifdef CONFIG_IWLWIFI_DEBUGFS
2086 void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm);
2087 void iwl_mvm_vif_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
2088 void iwl_mvm_vif_dbgfs_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2089 void iwl_mvm_vif_dbgfs_rm_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2090 #else
iwl_mvm_dbgfs_register(struct iwl_mvm * mvm)2091 static inline void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm)
2092 {
2093 }
2094 static inline void
iwl_mvm_vif_dbgfs_add_link(struct iwl_mvm * mvm,struct ieee80211_vif * vif)2095 iwl_mvm_vif_dbgfs_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2096 {
2097 }
2098 static inline void
iwl_mvm_vif_dbgfs_rm_link(struct iwl_mvm * mvm,struct ieee80211_vif * vif)2099 iwl_mvm_vif_dbgfs_rm_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2100 {
2101 }
2102 #endif /* CONFIG_IWLWIFI_DEBUGFS */
2103
2104 /* rate scaling */
2105 int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq);
2106 void iwl_mvm_update_frame_stats(struct iwl_mvm *mvm, u32 rate, bool agg);
2107 int rs_pretty_print_rate_v1(char *buf, int bufsz, const u32 rate);
2108 void rs_update_last_rssi(struct iwl_mvm *mvm,
2109 struct iwl_mvm_sta *mvmsta,
2110 struct ieee80211_rx_status *rx_status);
2111
2112 /* power management */
2113 int iwl_mvm_power_update_device(struct iwl_mvm *mvm);
2114 int iwl_mvm_power_update_mac(struct iwl_mvm *mvm);
2115 int iwl_mvm_power_update_ps(struct iwl_mvm *mvm);
2116 int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2117 char *buf, int bufsz);
2118
2119 void iwl_mvm_power_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2120 void iwl_mvm_power_uapsd_misbehaving_ap_notif(struct iwl_mvm *mvm,
2121 struct iwl_rx_cmd_buffer *rxb);
2122
2123 #ifdef CONFIG_IWLWIFI_LEDS
2124 int iwl_mvm_leds_init(struct iwl_mvm *mvm);
2125 void iwl_mvm_leds_exit(struct iwl_mvm *mvm);
2126 void iwl_mvm_leds_sync(struct iwl_mvm *mvm);
2127 #else
iwl_mvm_leds_init(struct iwl_mvm * mvm)2128 static inline int iwl_mvm_leds_init(struct iwl_mvm *mvm)
2129 {
2130 return 0;
2131 }
iwl_mvm_leds_exit(struct iwl_mvm * mvm)2132 static inline void iwl_mvm_leds_exit(struct iwl_mvm *mvm)
2133 {
2134 }
iwl_mvm_leds_sync(struct iwl_mvm * mvm)2135 static inline void iwl_mvm_leds_sync(struct iwl_mvm *mvm)
2136 {
2137 }
2138 #endif
2139
2140 /* D3 (WoWLAN, NetDetect) */
2141 int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
2142 int iwl_mvm_resume(struct ieee80211_hw *hw);
2143 void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled);
2144 void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw,
2145 struct ieee80211_vif *vif,
2146 struct cfg80211_gtk_rekey_data *data);
2147 void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw,
2148 struct ieee80211_vif *vif,
2149 struct inet6_dev *idev);
2150 void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw,
2151 struct ieee80211_vif *vif, int idx);
2152 extern const struct file_operations iwl_dbgfs_d3_test_ops;
2153 #ifdef CONFIG_PM_SLEEP
2154 void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm,
2155 struct ieee80211_vif *vif);
2156 void iwl_mvm_fast_suspend(struct iwl_mvm *mvm);
2157 int iwl_mvm_fast_resume(struct iwl_mvm *mvm);
2158 #else
2159 static inline void
iwl_mvm_set_last_nonqos_seq(struct iwl_mvm * mvm,struct ieee80211_vif * vif)2160 iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2161 {
2162 }
2163
iwl_mvm_fast_suspend(struct iwl_mvm * mvm)2164 static inline void iwl_mvm_fast_suspend(struct iwl_mvm *mvm)
2165 {
2166 }
2167
iwl_mvm_fast_resume(struct iwl_mvm * mvm)2168 static inline int iwl_mvm_fast_resume(struct iwl_mvm *mvm)
2169 {
2170 return 0;
2171 }
2172 #endif
2173 void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta,
2174 struct iwl_wowlan_config_cmd_v6 *cmd);
2175 int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
2176 struct ieee80211_vif *vif,
2177 bool disable_offloading,
2178 bool offload_ns,
2179 u32 cmd_flags,
2180 u8 sta_id);
2181
2182 /* BT Coex */
2183 int iwl_mvm_send_bt_init_conf(struct iwl_mvm *mvm);
2184 void iwl_mvm_rx_bt_coex_old_notif(struct iwl_mvm *mvm,
2185 struct iwl_rx_cmd_buffer *rxb);
2186 void iwl_mvm_bt_rssi_event(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2187 enum ieee80211_rssi_event_data);
2188 void iwl_mvm_bt_coex_vif_change(struct iwl_mvm *mvm);
2189 u16 iwl_mvm_coex_agg_time_limit(struct iwl_mvm *mvm,
2190 struct ieee80211_sta *sta);
2191 bool iwl_mvm_bt_coex_is_mimo_allowed(struct iwl_mvm *mvm,
2192 struct ieee80211_sta *sta);
2193 bool iwl_mvm_bt_coex_is_ant_avail(struct iwl_mvm *mvm, u8 ant);
2194 bool iwl_mvm_bt_coex_is_shared_ant_avail(struct iwl_mvm *mvm);
2195 bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm *mvm,
2196 enum nl80211_band band);
2197 u8 iwl_mvm_bt_coex_get_single_ant_msk(struct iwl_mvm *mvm, u8 enabled_ants);
2198 u8 iwl_mvm_bt_coex_tx_prio(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
2199 struct ieee80211_tx_info *info, u8 ac);
2200
2201 /* beacon filtering */
2202 #ifdef CONFIG_IWLWIFI_DEBUGFS
2203 void
2204 iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
2205 struct iwl_beacon_filter_cmd *cmd);
2206 #else
2207 static inline void
iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif * vif,struct iwl_beacon_filter_cmd * cmd)2208 iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
2209 struct iwl_beacon_filter_cmd *cmd)
2210 {}
2211 #endif
2212 int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm,
2213 struct ieee80211_vif *vif);
2214 int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm,
2215 struct ieee80211_vif *vif);
2216 /* SMPS */
2217 void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2218 enum iwl_mvm_smps_type_request req_type,
2219 enum ieee80211_smps_mode smps_request,
2220 unsigned int link_id);
2221 void
2222 iwl_mvm_update_smps_on_active_links(struct iwl_mvm *mvm,
2223 struct ieee80211_vif *vif,
2224 enum iwl_mvm_smps_type_request req_type,
2225 enum ieee80211_smps_mode smps_request);
2226 bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm,
2227 struct iwl_mvm_phy_ctxt *ctxt);
2228 void iwl_mvm_update_link_smps(struct ieee80211_vif *vif,
2229 struct ieee80211_bss_conf *link_conf);
2230
2231 /* Low latency */
2232 int iwl_mvm_update_low_latency(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2233 bool low_latency,
2234 enum iwl_mvm_low_latency_cause cause);
2235 /* get SystemLowLatencyMode - only needed for beacon threshold? */
2236 bool iwl_mvm_low_latency(struct iwl_mvm *mvm);
2237 bool iwl_mvm_low_latency_band(struct iwl_mvm *mvm, enum nl80211_band band);
2238 void iwl_mvm_send_low_latency_cmd(struct iwl_mvm *mvm, bool low_latency,
2239 u16 mac_id);
2240
2241 /* get VMACLowLatencyMode */
iwl_mvm_vif_low_latency(struct iwl_mvm_vif * mvmvif)2242 static inline bool iwl_mvm_vif_low_latency(struct iwl_mvm_vif *mvmvif)
2243 {
2244 /*
2245 * should this consider associated/active/... state?
2246 *
2247 * Normally low-latency should only be active on interfaces
2248 * that are active, but at least with debugfs it can also be
2249 * enabled on interfaces that aren't active. However, when
2250 * interface aren't active then they aren't added into the
2251 * binding, so this has no real impact. For now, just return
2252 * the current desired low-latency state.
2253 */
2254 return mvmvif->low_latency_actual;
2255 }
2256
2257 static inline
iwl_mvm_vif_set_low_latency(struct iwl_mvm_vif * mvmvif,bool set,enum iwl_mvm_low_latency_cause cause)2258 void iwl_mvm_vif_set_low_latency(struct iwl_mvm_vif *mvmvif, bool set,
2259 enum iwl_mvm_low_latency_cause cause)
2260 {
2261 u8 new_state;
2262
2263 if (set)
2264 mvmvif->low_latency |= cause;
2265 else
2266 mvmvif->low_latency &= ~cause;
2267
2268 /*
2269 * if LOW_LATENCY_DEBUGFS_FORCE_ENABLE is enabled no changes are
2270 * allowed to actual mode.
2271 */
2272 if (mvmvif->low_latency & LOW_LATENCY_DEBUGFS_FORCE_ENABLE &&
2273 cause != LOW_LATENCY_DEBUGFS_FORCE_ENABLE)
2274 return;
2275
2276 if (cause == LOW_LATENCY_DEBUGFS_FORCE_ENABLE && set)
2277 /*
2278 * We enter force state
2279 */
2280 new_state = !!(mvmvif->low_latency &
2281 LOW_LATENCY_DEBUGFS_FORCE);
2282 else
2283 /*
2284 * Check if any other one set low latency
2285 */
2286 new_state = !!(mvmvif->low_latency &
2287 ~(LOW_LATENCY_DEBUGFS_FORCE_ENABLE |
2288 LOW_LATENCY_DEBUGFS_FORCE));
2289
2290 mvmvif->low_latency_actual = new_state;
2291 }
2292
2293 /* Return a bitmask with all the hw supported queues, except for the
2294 * command queue, which can't be flushed.
2295 */
iwl_mvm_flushable_queues(struct iwl_mvm * mvm)2296 static inline u32 iwl_mvm_flushable_queues(struct iwl_mvm *mvm)
2297 {
2298 return ((BIT(mvm->trans->mac_cfg->base->num_of_queues) - 1) &
2299 ~BIT(IWL_MVM_DQA_CMD_QUEUE));
2300 }
2301
2302 void iwl_mvm_stop_device(struct iwl_mvm *mvm);
2303
2304 /* Thermal management and CT-kill */
2305 void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff);
2306 void iwl_mvm_temp_notif(struct iwl_mvm *mvm,
2307 struct iwl_rx_cmd_buffer *rxb);
2308 void iwl_mvm_tt_handler(struct iwl_mvm *mvm);
2309 void iwl_mvm_thermal_initialize(struct iwl_mvm *mvm, u32 min_backoff);
2310 void iwl_mvm_thermal_exit(struct iwl_mvm *mvm);
2311 void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm *mvm, bool state);
2312 int iwl_mvm_get_temp(struct iwl_mvm *mvm, s32 *temp);
2313 void iwl_mvm_ct_kill_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
2314 void iwl_mvm_enter_ctkill(struct iwl_mvm *mvm);
2315 int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm);
2316 int iwl_mvm_ctdp_command(struct iwl_mvm *mvm, u32 op, u32 budget);
2317
2318 #if IS_ENABLED(CONFIG_IWLMEI)
2319
2320 /* vendor commands */
2321 void iwl_mvm_vendor_cmds_register(struct iwl_mvm *mvm);
2322
2323 #else
2324
iwl_mvm_vendor_cmds_register(struct iwl_mvm * mvm)2325 static inline void iwl_mvm_vendor_cmds_register(struct iwl_mvm *mvm) {}
2326
2327 #endif
2328
2329 /* Location Aware Regulatory */
2330 struct iwl_mcc_update_resp_v8 *
2331 iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2,
2332 enum iwl_mcc_source src_id);
2333 int iwl_mvm_init_mcc(struct iwl_mvm *mvm);
2334 void iwl_mvm_rx_chub_update_mcc(struct iwl_mvm *mvm,
2335 struct iwl_rx_cmd_buffer *rxb);
2336 struct ieee80211_regdomain *iwl_mvm_get_regdomain(struct wiphy *wiphy,
2337 const char *alpha2,
2338 enum iwl_mcc_source src_id,
2339 bool *changed);
2340 struct ieee80211_regdomain *iwl_mvm_get_current_regdomain(struct iwl_mvm *mvm,
2341 bool *changed);
2342 int iwl_mvm_init_fw_regd(struct iwl_mvm *mvm, bool force_regd_sync);
2343 void iwl_mvm_update_changed_regdom(struct iwl_mvm *mvm);
2344
2345 /* smart fifo */
2346 int iwl_mvm_sf_update(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2347 bool added_vif);
2348
2349 /* FTM responder */
2350 int iwl_mvm_ftm_start_responder(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2351 struct ieee80211_bss_conf *bss_conf);
2352 void iwl_mvm_ftm_restart_responder(struct iwl_mvm *mvm,
2353 struct ieee80211_vif *vif,
2354 struct ieee80211_bss_conf *bss_conf);
2355 void iwl_mvm_ftm_responder_stats(struct iwl_mvm *mvm,
2356 struct iwl_rx_cmd_buffer *rxb);
2357 void iwl_mvm_ftm_responder_clear(struct iwl_mvm *mvm,
2358 struct ieee80211_vif *vif);
2359
2360 /* FTM initiator */
2361 void iwl_mvm_ftm_restart(struct iwl_mvm *mvm);
2362 void iwl_mvm_ftm_range_resp(struct iwl_mvm *mvm,
2363 struct iwl_rx_cmd_buffer *rxb);
2364 void iwl_mvm_ftm_lc_notif(struct iwl_mvm *mvm,
2365 struct iwl_rx_cmd_buffer *rxb);
2366 int iwl_mvm_ftm_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2367 struct cfg80211_pmsr_request *request);
2368 void iwl_mvm_ftm_abort(struct iwl_mvm *mvm, struct cfg80211_pmsr_request *req);
2369 void iwl_mvm_ftm_initiator_smooth_config(struct iwl_mvm *mvm);
2370 void iwl_mvm_ftm_initiator_smooth_stop(struct iwl_mvm *mvm);
2371
2372 /* TDLS */
2373
2374 /*
2375 * We use TID 4 (VI) as a FW-used-only TID when TDLS connections are present.
2376 * This TID is marked as used vs the AP and all connected TDLS peers.
2377 */
2378 #define IWL_MVM_TDLS_FW_TID 4
2379
2380 int iwl_mvm_tdls_sta_count(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2381 void iwl_mvm_teardown_tdls_peers(struct iwl_mvm *mvm);
2382 void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2383 bool sta_added);
2384 void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,
2385 struct ieee80211_vif *vif,
2386 unsigned int link_id);
2387 int iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw,
2388 struct ieee80211_vif *vif,
2389 struct ieee80211_sta *sta, u8 oper_class,
2390 struct cfg80211_chan_def *chandef,
2391 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie);
2392 void iwl_mvm_tdls_recv_channel_switch(struct ieee80211_hw *hw,
2393 struct ieee80211_vif *vif,
2394 struct ieee80211_tdls_ch_sw_params *params);
2395 void iwl_mvm_tdls_cancel_channel_switch(struct ieee80211_hw *hw,
2396 struct ieee80211_vif *vif,
2397 struct ieee80211_sta *sta);
2398 void iwl_mvm_rx_tdls_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
2399 void iwl_mvm_tdls_ch_switch_work(struct work_struct *work);
2400
2401 void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm,
2402 enum iwl_mvm_rxq_notif_type type,
2403 bool sync,
2404 const void *data, u32 size);
2405 struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm);
2406 bool iwl_mvm_is_vif_assoc(struct iwl_mvm *mvm);
2407
2408 #define MVM_TCM_PERIOD_MSEC 500
2409 #define MVM_TCM_PERIOD (HZ * MVM_TCM_PERIOD_MSEC / 1000)
2410 #define MVM_LL_PERIOD (10 * HZ)
2411 void iwl_mvm_tcm_work(struct work_struct *work);
2412 void iwl_mvm_pause_tcm(struct iwl_mvm *mvm, bool with_cancel);
2413 void iwl_mvm_resume_tcm(struct iwl_mvm *mvm);
2414 void iwl_mvm_tcm_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2415 void iwl_mvm_tcm_rm_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2416 u8 iwl_mvm_tcm_load_percentage(u32 airtime, u32 elapsed);
2417
2418 unsigned int iwl_mvm_get_wd_timeout(struct iwl_mvm *mvm,
2419 struct ieee80211_vif *vif);
2420 void iwl_mvm_connection_loss(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2421 const char *errmsg);
2422 void iwl_mvm_event_frame_timeout_callback(struct iwl_mvm *mvm,
2423 struct ieee80211_vif *vif,
2424 const struct ieee80211_sta *sta,
2425 u16 tid);
2426 void iwl_mvm_mei_scan_filter_init(struct iwl_mei_scan_filter *mei_scan_filter);
2427
2428 void iwl_mvm_ptp_init(struct iwl_mvm *mvm);
2429 void iwl_mvm_ptp_remove(struct iwl_mvm *mvm);
2430 u64 iwl_mvm_ptp_get_adj_time(struct iwl_mvm *mvm, u64 base_time);
2431 int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b);
2432 int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm);
2433 int iwl_mvm_ppag_send_cmd(struct iwl_mvm *mvm);
2434 void iwl_mvm_get_bios_tables(struct iwl_mvm *mvm);
2435 #ifdef CONFIG_IWLWIFI_DEBUGFS
2436 void iwl_mvm_link_sta_add_debugfs(struct ieee80211_hw *hw,
2437 struct ieee80211_vif *vif,
2438 struct ieee80211_link_sta *link_sta,
2439 struct dentry *dir);
2440 void iwl_mvm_link_add_debugfs(struct ieee80211_hw *hw,
2441 struct ieee80211_vif *vif,
2442 struct ieee80211_bss_conf *link_conf,
2443 struct dentry *dir);
2444 #endif
2445
2446 /* new MLD related APIs */
2447 int iwl_mvm_sec_key_add(struct iwl_mvm *mvm,
2448 struct ieee80211_vif *vif,
2449 struct ieee80211_sta *sta,
2450 struct ieee80211_key_conf *keyconf);
2451 int iwl_mvm_sec_key_del(struct iwl_mvm *mvm,
2452 struct ieee80211_vif *vif,
2453 struct ieee80211_sta *sta,
2454 struct ieee80211_key_conf *keyconf);
2455 int iwl_mvm_sec_key_del_pasn(struct iwl_mvm *mvm,
2456 struct ieee80211_vif *vif,
2457 u32 sta_mask,
2458 struct ieee80211_key_conf *keyconf);
2459 void iwl_mvm_sec_key_remove_ap(struct iwl_mvm *mvm,
2460 struct ieee80211_vif *vif,
2461 struct iwl_mvm_vif_link_info *link,
2462 unsigned int link_id);
2463 int iwl_mvm_mld_send_key(struct iwl_mvm *mvm, u32 sta_mask, u32 key_flags,
2464 struct ieee80211_key_conf *keyconf);
2465 u32 iwl_mvm_get_sec_flags(struct iwl_mvm *mvm,
2466 struct ieee80211_vif *vif,
2467 struct ieee80211_sta *sta,
2468 struct ieee80211_key_conf *keyconf);
2469
2470 bool iwl_rfi_supported(struct iwl_mvm *mvm);
2471 int iwl_rfi_send_config_cmd(struct iwl_mvm *mvm,
2472 struct iwl_rfi_lut_entry *rfi_table);
2473 struct iwl_rfi_freq_table_resp_cmd *iwl_rfi_get_freq_table(struct iwl_mvm *mvm);
2474 void iwl_rfi_deactivate_notif_handler(struct iwl_mvm *mvm,
2475 struct iwl_rx_cmd_buffer *rxb);
2476
iwl_mvm_phy_band_from_nl80211(enum nl80211_band band)2477 static inline u8 iwl_mvm_phy_band_from_nl80211(enum nl80211_band band)
2478 {
2479 switch (band) {
2480 case NL80211_BAND_2GHZ:
2481 return PHY_BAND_24;
2482 case NL80211_BAND_5GHZ:
2483 return PHY_BAND_5;
2484 case NL80211_BAND_6GHZ:
2485 return PHY_BAND_6;
2486 default:
2487 WARN_ONCE(1, "Unsupported band (%u)\n", band);
2488 return PHY_BAND_5;
2489 }
2490 }
2491
iwl_mvm_nl80211_band_from_phy(u8 phy_band)2492 static inline u8 iwl_mvm_nl80211_band_from_phy(u8 phy_band)
2493 {
2494 switch (phy_band) {
2495 case PHY_BAND_24:
2496 return NL80211_BAND_2GHZ;
2497 case PHY_BAND_5:
2498 return NL80211_BAND_5GHZ;
2499 case PHY_BAND_6:
2500 return NL80211_BAND_6GHZ;
2501 default:
2502 WARN_ONCE(1, "Unsupported phy band (%u)\n", phy_band);
2503 return NL80211_BAND_5GHZ;
2504 }
2505 }
2506
2507 /* Channel Switch */
2508 void iwl_mvm_channel_switch_disconnect_wk(struct work_struct *wk);
2509 int iwl_mvm_post_channel_switch(struct ieee80211_hw *hw,
2510 struct ieee80211_vif *vif,
2511 struct ieee80211_bss_conf *link);
2512
2513 /* Channel Context */
2514 /**
2515 * struct iwl_mvm_switch_vif_chanctx_ops - callbacks for switch_vif_chanctx()
2516 *
2517 * Since the only difference between both MLD and
2518 * non-MLD versions of switch_vif_chanctx() is these function calls,
2519 * each version will send its specific function calls to
2520 * %iwl_mvm_switch_vif_chanctx_common().
2521 *
2522 * @__assign_vif_chanctx: pointer to the function that assigns a chanctx to
2523 * a given vif
2524 * @__unassign_vif_chanctx: pointer to the function that unassigns a chanctx to
2525 * a given vif
2526 */
2527 struct iwl_mvm_switch_vif_chanctx_ops {
2528 int (*__assign_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 void (*__unassign_vif_chanctx)(struct iwl_mvm *mvm,
2534 struct ieee80211_vif *vif,
2535 struct ieee80211_bss_conf *link_conf,
2536 struct ieee80211_chanctx_conf *ctx,
2537 bool switching_chanctx);
2538 };
2539
2540 int
2541 iwl_mvm_switch_vif_chanctx_common(struct ieee80211_hw *hw,
2542 struct ieee80211_vif_chanctx_switch *vifs,
2543 int n_vifs,
2544 enum ieee80211_chanctx_switch_mode mode,
2545 const struct iwl_mvm_switch_vif_chanctx_ops *ops);
2546
2547 /* Channel info utils */
iwl_mvm_has_ultra_hb_channel(struct iwl_mvm * mvm)2548 static inline bool iwl_mvm_has_ultra_hb_channel(struct iwl_mvm *mvm)
2549 {
2550 return fw_has_capa(&mvm->fw->ucode_capa,
2551 IWL_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS);
2552 }
2553
iwl_mvm_chan_info_cmd_tail(struct iwl_mvm * mvm,struct iwl_fw_channel_info * ci)2554 static inline void *iwl_mvm_chan_info_cmd_tail(struct iwl_mvm *mvm,
2555 struct iwl_fw_channel_info *ci)
2556 {
2557 return (u8 *)ci + (iwl_mvm_has_ultra_hb_channel(mvm) ?
2558 sizeof(struct iwl_fw_channel_info) :
2559 sizeof(struct iwl_fw_channel_info_v1));
2560 }
2561
iwl_mvm_chan_info_padding(struct iwl_mvm * mvm)2562 static inline size_t iwl_mvm_chan_info_padding(struct iwl_mvm *mvm)
2563 {
2564 return iwl_mvm_has_ultra_hb_channel(mvm) ? 0 :
2565 sizeof(struct iwl_fw_channel_info) -
2566 sizeof(struct iwl_fw_channel_info_v1);
2567 }
2568
iwl_mvm_set_chan_info(struct iwl_mvm * mvm,struct iwl_fw_channel_info * ci,u32 chan,u8 band,u8 width,u8 ctrl_pos)2569 static inline void iwl_mvm_set_chan_info(struct iwl_mvm *mvm,
2570 struct iwl_fw_channel_info *ci,
2571 u32 chan, u8 band, u8 width,
2572 u8 ctrl_pos)
2573 {
2574 if (iwl_mvm_has_ultra_hb_channel(mvm)) {
2575 ci->channel = cpu_to_le32(chan);
2576 ci->band = band;
2577 ci->width = width;
2578 ci->ctrl_pos = ctrl_pos;
2579 } else {
2580 struct iwl_fw_channel_info_v1 *ci_v1 =
2581 (struct iwl_fw_channel_info_v1 *)ci;
2582
2583 ci_v1->channel = chan;
2584 ci_v1->band = band;
2585 ci_v1->width = width;
2586 ci_v1->ctrl_pos = ctrl_pos;
2587 }
2588 }
2589
2590 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)2591 iwl_mvm_set_chan_info_chandef(struct iwl_mvm *mvm,
2592 struct iwl_fw_channel_info *ci,
2593 const struct cfg80211_chan_def *chandef)
2594 {
2595 enum nl80211_band band = chandef->chan->band;
2596
2597 iwl_mvm_set_chan_info(mvm, ci, chandef->chan->hw_value,
2598 iwl_mvm_phy_band_from_nl80211(band),
2599 iwl_mvm_get_channel_width(chandef),
2600 iwl_mvm_get_ctrl_pos(chandef));
2601 }
2602
iwl_umac_scan_get_max_profiles(const struct iwl_fw * fw)2603 static inline int iwl_umac_scan_get_max_profiles(const struct iwl_fw *fw)
2604 {
2605 u8 ver = iwl_fw_lookup_cmd_ver(fw, SCAN_OFFLOAD_UPDATE_PROFILES_CMD,
2606 IWL_FW_CMD_VER_UNKNOWN);
2607 return (ver == IWL_FW_CMD_VER_UNKNOWN || ver < 3) ?
2608 IWL_SCAN_MAX_PROFILES : IWL_SCAN_MAX_PROFILES_V2;
2609 }
2610
2611 static inline
iwl_mvm_cipher_to_location_cipher(u32 cipher)2612 enum iwl_location_cipher iwl_mvm_cipher_to_location_cipher(u32 cipher)
2613 {
2614 switch (cipher) {
2615 case WLAN_CIPHER_SUITE_CCMP:
2616 return IWL_LOCATION_CIPHER_CCMP_128;
2617 case WLAN_CIPHER_SUITE_GCMP:
2618 return IWL_LOCATION_CIPHER_GCMP_128;
2619 case WLAN_CIPHER_SUITE_GCMP_256:
2620 return IWL_LOCATION_CIPHER_GCMP_256;
2621 default:
2622 return IWL_LOCATION_CIPHER_INVALID;
2623 }
2624 }
2625
2626 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)2627 static inline int iwl_mvm_mei_get_ownership(struct iwl_mvm *mvm)
2628 {
2629 if (mvm->mei_registered)
2630 return iwl_mei_get_ownership();
2631 return 0;
2632 }
2633
iwl_mvm_mei_tx_copy_to_csme(struct iwl_mvm * mvm,struct sk_buff * skb,unsigned int ivlen)2634 static inline void iwl_mvm_mei_tx_copy_to_csme(struct iwl_mvm *mvm,
2635 struct sk_buff *skb,
2636 unsigned int ivlen)
2637 {
2638 if (mvm->mei_registered)
2639 iwl_mei_tx_copy_to_csme(skb, ivlen);
2640 }
2641
iwl_mvm_mei_host_disassociated(struct iwl_mvm * mvm)2642 static inline void iwl_mvm_mei_host_disassociated(struct iwl_mvm *mvm)
2643 {
2644 if (mvm->mei_registered)
2645 iwl_mei_host_disassociated();
2646 }
2647
iwl_mvm_mei_device_state(struct iwl_mvm * mvm,bool up)2648 static inline void iwl_mvm_mei_device_state(struct iwl_mvm *mvm, bool up)
2649 {
2650 if (mvm->mei_registered)
2651 iwl_mei_device_state(up);
2652 }
2653
iwl_mvm_mei_set_sw_rfkill_state(struct iwl_mvm * mvm)2654 static inline void iwl_mvm_mei_set_sw_rfkill_state(struct iwl_mvm *mvm)
2655 {
2656 bool sw_rfkill =
2657 mvm->hw_registered ? rfkill_soft_blocked(mvm->hw->wiphy->rfkill) : false;
2658
2659 if (mvm->mei_registered)
2660 iwl_mei_set_rfkill_state(iwl_mvm_is_radio_killed(mvm),
2661 sw_rfkill);
2662 }
2663
iwl_mvm_has_p2p_over_aux(struct iwl_mvm * mvm)2664 static inline bool iwl_mvm_has_p2p_over_aux(struct iwl_mvm *mvm)
2665 {
2666 u32 cmd_id = WIDE_ID(MAC_CONF_GROUP, ROC_CMD);
2667
2668 return iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id, 0) >= 4;
2669 }
2670
iwl_mvm_mei_filter_scan(struct iwl_mvm * mvm,struct sk_buff * skb)2671 static inline bool iwl_mvm_mei_filter_scan(struct iwl_mvm *mvm,
2672 struct sk_buff *skb)
2673 {
2674 struct ieee80211_mgmt *mgmt = (void *)skb->data;
2675
2676 if (mvm->mei_scan_filter.is_mei_limited_scan &&
2677 (ieee80211_is_probe_resp(mgmt->frame_control) ||
2678 ieee80211_is_beacon(mgmt->frame_control))) {
2679 skb_queue_tail(&mvm->mei_scan_filter.scan_res, skb);
2680 schedule_work(&mvm->mei_scan_filter.scan_work);
2681 return true;
2682 }
2683
2684 return false;
2685 }
2686
2687 void iwl_mvm_send_roaming_forbidden_event(struct iwl_mvm *mvm,
2688 struct ieee80211_vif *vif,
2689 bool forbidden);
2690
2691 /* Callbacks for ieee80211_ops */
2692 void iwl_mvm_mac_tx(struct ieee80211_hw *hw,
2693 struct ieee80211_tx_control *control, struct sk_buff *skb);
2694 void iwl_mvm_mac_wake_tx_queue(struct ieee80211_hw *hw,
2695 struct ieee80211_txq *txq);
2696
2697 int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw,
2698 struct ieee80211_vif *vif,
2699 struct ieee80211_ampdu_params *params);
2700 int iwl_mvm_op_get_antenna(struct ieee80211_hw *hw, int radio_idx, u32 *tx_ant,
2701 u32 *rx_ant);
2702 int iwl_mvm_op_set_antenna(struct ieee80211_hw *hw, int radio_idx, u32 tx_ant,
2703 u32 rx_ant);
2704 int iwl_mvm_mac_start(struct ieee80211_hw *hw);
2705 void iwl_mvm_mac_reconfig_complete(struct ieee80211_hw *hw,
2706 enum ieee80211_reconfig_type reconfig_type);
2707 void iwl_mvm_mac_stop(struct ieee80211_hw *hw, bool suspend);
iwl_mvm_mac_config(struct ieee80211_hw * hw,int radio_idx,u32 changed)2708 static inline int iwl_mvm_mac_config(struct ieee80211_hw *hw, int radio_idx,
2709 u32 changed)
2710 {
2711 return 0;
2712 }
2713
2714 u64 iwl_mvm_prepare_multicast(struct ieee80211_hw *hw,
2715 struct netdev_hw_addr_list *mc_list);
2716
2717 void iwl_mvm_configure_filter(struct ieee80211_hw *hw,
2718 unsigned int changed_flags,
2719 unsigned int *total_flags, u64 multicast);
2720 int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2721 struct ieee80211_scan_request *hw_req);
2722 void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw,
2723 struct ieee80211_vif *vif);
2724 void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw *hw,
2725 struct ieee80211_vif *vif,
2726 struct ieee80211_sta *sta);
2727 void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2728 enum sta_notify_cmd cmd,
2729 struct ieee80211_sta *sta);
2730 void
2731 iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw,
2732 struct ieee80211_sta *sta, u16 tids,
2733 int num_frames,
2734 enum ieee80211_frame_release_type reason,
2735 bool more_data);
2736 void
2737 iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw *hw,
2738 struct ieee80211_sta *sta, u16 tids,
2739 int num_frames,
2740 enum ieee80211_frame_release_type reason,
2741 bool more_data);
2742 int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, int radio_idx,
2743 u32 value);
2744 void iwl_mvm_sta_rc_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2745 struct ieee80211_link_sta *link_sta, u32 changed);
2746 void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw,
2747 struct ieee80211_vif *vif,
2748 struct ieee80211_prep_tx_info *info);
2749 void iwl_mvm_mac_mgd_complete_tx(struct ieee80211_hw *hw,
2750 struct ieee80211_vif *vif,
2751 struct ieee80211_prep_tx_info *info);
2752 void iwl_mvm_mac_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2753 u32 queues, bool drop);
2754 void iwl_mvm_mac_flush_sta(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2755 struct ieee80211_sta *sta);
2756 int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw,
2757 struct ieee80211_vif *vif,
2758 struct cfg80211_sched_scan_request *req,
2759 struct ieee80211_scan_ies *ies);
2760 int iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw *hw,
2761 struct ieee80211_vif *vif);
2762 int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2763 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
2764 struct ieee80211_key_conf *key);
2765 void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw,
2766 struct ieee80211_vif *vif,
2767 struct ieee80211_key_conf *keyconf,
2768 struct ieee80211_sta *sta,
2769 u32 iv32, u16 *phase1key);
2770 int iwl_mvm_add_chanctx(struct ieee80211_hw *hw,
2771 struct ieee80211_chanctx_conf *ctx);
2772 void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw,
2773 struct ieee80211_chanctx_conf *ctx);
2774 void iwl_mvm_change_chanctx(struct ieee80211_hw *hw,
2775 struct ieee80211_chanctx_conf *ctx, u32 changed);
2776 int iwl_mvm_tx_last_beacon(struct ieee80211_hw *hw);
2777 void iwl_mvm_channel_switch(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2778 struct ieee80211_channel_switch *chsw);
2779 int iwl_mvm_mac_pre_channel_switch(struct ieee80211_hw *hw,
2780 struct ieee80211_vif *vif,
2781 struct ieee80211_channel_switch *chsw);
2782
2783 void iwl_mvm_abort_channel_switch(struct ieee80211_hw *hw,
2784 struct ieee80211_vif *vif,
2785 struct ieee80211_bss_conf *link_conf);
2786 void iwl_mvm_channel_switch_rx_beacon(struct ieee80211_hw *hw,
2787 struct ieee80211_vif *vif,
2788 struct ieee80211_channel_switch *chsw);
2789 void iwl_mvm_mac_event_callback(struct ieee80211_hw *hw,
2790 struct ieee80211_vif *vif,
2791 const struct ieee80211_event *event);
2792 void iwl_mvm_sync_rx_queues(struct ieee80211_hw *hw);
2793 int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw *hw,
2794 struct ieee80211_vif *vif,
2795 void *data, int len);
2796 int iwl_mvm_mac_get_survey(struct ieee80211_hw *hw, int idx,
2797 struct survey_info *survey);
2798 void iwl_mvm_mac_sta_statistics(struct ieee80211_hw *hw,
2799 struct ieee80211_vif *vif,
2800 struct ieee80211_sta *sta,
2801 struct station_info *sinfo);
2802 int
2803 iwl_mvm_mac_get_ftm_responder_stats(struct ieee80211_hw *hw,
2804 struct ieee80211_vif *vif,
2805 struct cfg80211_ftm_responder_stats *stats);
2806 int iwl_mvm_start_pmsr(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2807 struct cfg80211_pmsr_request *request);
2808 void iwl_mvm_abort_pmsr(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2809 struct cfg80211_pmsr_request *request);
2810
2811 bool iwl_mvm_have_links_same_channel(struct iwl_mvm_vif *vif1,
2812 struct iwl_mvm_vif *vif2);
2813 bool iwl_mvm_vif_is_active(struct iwl_mvm_vif *mvmvif);
2814 int iwl_mvm_set_tx_power(struct iwl_mvm *mvm,
2815 struct ieee80211_bss_conf *bss_conf,
2816 s16 tx_power);
2817 int iwl_mvm_set_hw_timestamp(struct ieee80211_hw *hw,
2818 struct ieee80211_vif *vif,
2819 struct cfg80211_set_hw_timestamp *hwts);
2820 int iwl_mvm_update_mu_groups(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2821 bool iwl_mvm_enable_fils(struct iwl_mvm *mvm,
2822 struct ieee80211_vif *vif,
2823 struct ieee80211_chanctx_conf *ctx);
2824
2825 struct cfg80211_chan_def *
2826 iwl_mvm_chanctx_def(struct iwl_mvm *mvm, struct ieee80211_chanctx_conf *ctx);
2827
2828 void iwl_mvm_roc_duration_and_delay(struct ieee80211_vif *vif,
2829 u32 duration_ms,
2830 u32 *duration_tu,
2831 u32 *delay);
2832 int iwl_mvm_roc_add_cmd(struct iwl_mvm *mvm,
2833 struct ieee80211_channel *channel,
2834 struct ieee80211_vif *vif,
2835 int duration, enum iwl_roc_activity activity);
2836
2837 void
2838 iwl_mvm_send_ap_tx_power_constraint_cmd(struct iwl_mvm *mvm,
2839 struct ieee80211_vif *vif,
2840 struct ieee80211_bss_conf *bss_conf,
2841 bool is_ap);
2842
2843 void iwl_mvm_smps_workaround(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2844 bool update);
2845
2846 /* rate_n_flags conversion */
2847 u32 iwl_mvm_v3_rate_from_fw(__le32 rate, u8 rate_ver);
2848 __le32 iwl_mvm_v3_rate_to_fw(u32 rate, u8 rate_ver);
2849
2850 #endif /* __IWL_MVM_H__ */
2851