1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3 * Copyright (C) 2012-2014, 2018-2022 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 #ifdef CONFIG_IWLWIFI_LEDS
13 #include <linux/leds.h>
14 #endif
15 #include <linux/in6.h>
16
17 #ifdef CONFIG_THERMAL
18 #include <linux/thermal.h>
19 #endif
20
21 #include <linux/ktime.h>
22
23 #include "iwl-op-mode.h"
24 #include "iwl-trans.h"
25 #include "fw/notif-wait.h"
26 #include "iwl-eeprom-parse.h"
27 #include "fw/file.h"
28 #include "iwl-config.h"
29 #include "sta.h"
30 #include "fw-api.h"
31 #include "constants.h"
32 #include "fw/runtime.h"
33 #include "fw/dbg.h"
34 #include "fw/acpi.h"
35 #include "mei/iwl-mei.h"
36 #include "iwl-nvm-parse.h"
37
38 #include <linux/average.h>
39 #if defined(__FreeBSD__)
40 #include <net/if_inet6.h>
41 #endif
42
43 #define IWL_MVM_MAX_ADDRESSES 5
44 /* RSSI offset for WkP */
45 #define IWL_RSSI_OFFSET 50
46 #define IWL_MVM_MISSED_BEACONS_THRESHOLD 8
47 #define IWL_MVM_MISSED_BEACONS_THRESHOLD_LONG 16
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 extern const struct ieee80211_ops iwl_mvm_hw_ops;
80
81 /**
82 * struct iwl_mvm_mod_params - module parameters for iwlmvm
83 * @init_dbg: if true, then the NIC won't be stopped if the INIT fw asserted.
84 * We will register to mac80211 to have testmode working. The NIC must not
85 * be up'ed after the INIT fw asserted. This is useful to be able to use
86 * proprietary tools over testmode to debug the INIT fw.
87 * @power_scheme: one of enum iwl_power_scheme
88 */
89 struct iwl_mvm_mod_params {
90 bool init_dbg;
91 int power_scheme;
92 };
93 extern struct iwl_mvm_mod_params iwlmvm_mod_params;
94
95 struct iwl_mvm_phy_ctxt {
96 u16 id;
97 u16 color;
98 u32 ref;
99
100 enum nl80211_chan_width width;
101
102 struct ieee80211_channel *channel;
103
104 /* track for RLC config command */
105 u32 center_freq1;
106 };
107
108 struct iwl_mvm_time_event_data {
109 struct ieee80211_vif *vif;
110 struct list_head list;
111 unsigned long end_jiffies;
112 u32 duration;
113 bool running;
114 u32 uid;
115
116 /*
117 * The access to the 'id' field must be done when the
118 * mvm->time_event_lock is held, as it value is used to indicate
119 * if the te is in the time event list or not (when id == TE_MAX)
120 */
121 u32 id;
122 };
123
124 /* Power management */
125
126 /**
127 * enum iwl_power_scheme
128 * @IWL_POWER_LEVEL_CAM - Continuously Active Mode
129 * @IWL_POWER_LEVEL_BPS - Balanced Power Save (default)
130 * @IWL_POWER_LEVEL_LP - Low Power
131 */
132 enum iwl_power_scheme {
133 IWL_POWER_SCHEME_CAM = 1,
134 IWL_POWER_SCHEME_BPS,
135 IWL_POWER_SCHEME_LP
136 };
137
138 #define IWL_CONN_MAX_LISTEN_INTERVAL 10
139 #define IWL_UAPSD_MAX_SP IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
140
141 #ifdef CONFIG_IWLWIFI_DEBUGFS
142 enum iwl_dbgfs_pm_mask {
143 MVM_DEBUGFS_PM_KEEP_ALIVE = BIT(0),
144 MVM_DEBUGFS_PM_SKIP_OVER_DTIM = BIT(1),
145 MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS = BIT(2),
146 MVM_DEBUGFS_PM_RX_DATA_TIMEOUT = BIT(3),
147 MVM_DEBUGFS_PM_TX_DATA_TIMEOUT = BIT(4),
148 MVM_DEBUGFS_PM_LPRX_ENA = BIT(6),
149 MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD = BIT(7),
150 MVM_DEBUGFS_PM_SNOOZE_ENABLE = BIT(8),
151 MVM_DEBUGFS_PM_UAPSD_MISBEHAVING = BIT(9),
152 MVM_DEBUGFS_PM_USE_PS_POLL = BIT(10),
153 };
154
155 struct iwl_dbgfs_pm {
156 u16 keep_alive_seconds;
157 u32 rx_data_timeout;
158 u32 tx_data_timeout;
159 bool skip_over_dtim;
160 u8 skip_dtim_periods;
161 bool lprx_ena;
162 u32 lprx_rssi_threshold;
163 bool snooze_ena;
164 bool uapsd_misbehaving;
165 bool use_ps_poll;
166 int mask;
167 };
168
169 /* beacon filtering */
170
171 enum iwl_dbgfs_bf_mask {
172 MVM_DEBUGFS_BF_ENERGY_DELTA = BIT(0),
173 MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA = BIT(1),
174 MVM_DEBUGFS_BF_ROAMING_STATE = BIT(2),
175 MVM_DEBUGFS_BF_TEMP_THRESHOLD = BIT(3),
176 MVM_DEBUGFS_BF_TEMP_FAST_FILTER = BIT(4),
177 MVM_DEBUGFS_BF_TEMP_SLOW_FILTER = BIT(5),
178 MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER = BIT(6),
179 MVM_DEBUGFS_BF_DEBUG_FLAG = BIT(7),
180 MVM_DEBUGFS_BF_ESCAPE_TIMER = BIT(8),
181 MVM_DEBUGFS_BA_ESCAPE_TIMER = BIT(9),
182 MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT = BIT(10),
183 };
184
185 struct iwl_dbgfs_bf {
186 u32 bf_energy_delta;
187 u32 bf_roaming_energy_delta;
188 u32 bf_roaming_state;
189 u32 bf_temp_threshold;
190 u32 bf_temp_fast_filter;
191 u32 bf_temp_slow_filter;
192 u32 bf_enable_beacon_filter;
193 u32 bf_debug_flag;
194 u32 bf_escape_timer;
195 u32 ba_escape_timer;
196 u32 ba_enable_beacon_abort;
197 int mask;
198 };
199 #endif
200
201 enum iwl_mvm_smps_type_request {
202 IWL_MVM_SMPS_REQ_BT_COEX,
203 IWL_MVM_SMPS_REQ_TT,
204 IWL_MVM_SMPS_REQ_PROT,
205 IWL_MVM_SMPS_REQ_FW,
206 NUM_IWL_MVM_SMPS_REQ,
207 };
208
209 enum iwl_bt_force_ant_mode {
210 BT_FORCE_ANT_DIS = 0,
211 BT_FORCE_ANT_AUTO,
212 BT_FORCE_ANT_BT,
213 BT_FORCE_ANT_WIFI,
214
215 BT_FORCE_ANT_MAX,
216 };
217
218 /**
219 * struct iwl_mvm_low_latency_force - low latency force mode set by debugfs
220 * @LOW_LATENCY_FORCE_UNSET: unset force mode
221 * @LOW_LATENCY_FORCE_ON: for low latency on
222 * @LOW_LATENCY_FORCE_OFF: for low latency off
223 * @NUM_LOW_LATENCY_FORCE: max num of modes
224 */
225 enum iwl_mvm_low_latency_force {
226 LOW_LATENCY_FORCE_UNSET,
227 LOW_LATENCY_FORCE_ON,
228 LOW_LATENCY_FORCE_OFF,
229 NUM_LOW_LATENCY_FORCE
230 };
231
232 /**
233 * struct iwl_mvm_low_latency_cause - low latency set causes
234 * @LOW_LATENCY_TRAFFIC: indicates low latency traffic was detected
235 * @LOW_LATENCY_DEBUGFS: low latency mode set from debugfs
236 * @LOW_LATENCY_VCMD: low latency mode set from vendor command
237 * @LOW_LATENCY_VIF_TYPE: low latency mode set because of vif type (ap)
238 * @LOW_LATENCY_DEBUGFS_FORCE_ENABLE: indicate that force mode is enabled
239 * the actual set/unset is done with LOW_LATENCY_DEBUGFS_FORCE
240 * @LOW_LATENCY_DEBUGFS_FORCE: low latency force mode from debugfs
241 * set this with LOW_LATENCY_DEBUGFS_FORCE_ENABLE flag
242 * in low_latency.
243 */
244 enum iwl_mvm_low_latency_cause {
245 LOW_LATENCY_TRAFFIC = BIT(0),
246 LOW_LATENCY_DEBUGFS = BIT(1),
247 LOW_LATENCY_VCMD = BIT(2),
248 LOW_LATENCY_VIF_TYPE = BIT(3),
249 LOW_LATENCY_DEBUGFS_FORCE_ENABLE = BIT(4),
250 LOW_LATENCY_DEBUGFS_FORCE = BIT(5),
251 };
252
253 /**
254 * struct iwl_mvm_vif_bf_data - beacon filtering related data
255 * @bf_enabled: indicates if beacon filtering is enabled
256 * @ba_enabled: indicated if beacon abort is enabled
257 * @ave_beacon_signal: average beacon signal
258 * @last_cqm_event: rssi of the last cqm event
259 * @bt_coex_min_thold: minimum threshold for BT coex
260 * @bt_coex_max_thold: maximum threshold for BT coex
261 * @last_bt_coex_event: rssi of the last BT coex event
262 */
263 struct iwl_mvm_vif_bf_data {
264 bool bf_enabled;
265 bool ba_enabled;
266 int ave_beacon_signal;
267 int last_cqm_event;
268 int bt_coex_min_thold;
269 int bt_coex_max_thold;
270 int last_bt_coex_event;
271 };
272
273 /**
274 * struct iwl_probe_resp_data - data for NoA/CSA updates
275 * @rcu_head: used for freeing the data on update
276 * @notif: notification data
277 * @noa_len: length of NoA attribute, calculated from the notification
278 */
279 struct iwl_probe_resp_data {
280 struct rcu_head rcu_head;
281 struct iwl_probe_resp_data_notif notif;
282 int noa_len;
283 };
284
285 /**
286 * struct iwl_mvm_vif - data per Virtual Interface, it is a MAC context
287 * @id: between 0 and 3
288 * @color: to solve races upon MAC addition and removal
289 * @ap_sta_id: the sta_id of the AP - valid only if VIF type is STA
290 * @bssid: BSSID for this (client) interface
291 * @associated: indicates that we're currently associated, used only for
292 * managing the firmware state in iwl_mvm_bss_info_changed_station()
293 * @ap_assoc_sta_count: count of stations associated to us - valid only
294 * if VIF type is AP
295 * @uploaded: indicates the MAC context has been added to the device
296 * @ap_ibss_active: indicates that AP/IBSS is configured and that the interface
297 * should get quota etc.
298 * @pm_enabled - Indicate if MAC power management is allowed
299 * @monitor_active: indicates that monitor context is configured, and that the
300 * interface should get quota etc.
301 * @low_latency: bit flags for low latency
302 * see enum &iwl_mvm_low_latency_cause for causes.
303 * @low_latency_actual: boolean, indicates low latency is set,
304 * as a result from low_latency bit flags and takes force into account.
305 * @authorized: indicates the AP station was set to authorized
306 * @ps_disabled: indicates that this interface requires PS to be disabled
307 * @queue_params: QoS params for this MAC
308 * @bcast_sta: station used for broadcast packets. Used by the following
309 * vifs: P2P_DEVICE, GO and AP.
310 * @beacon_skb: the skb used to hold the AP/GO beacon template
311 * @smps_requests: the SMPS requests of different parts of the driver,
312 * combined on update to yield the overall request to mac80211.
313 * @beacon_stats: beacon statistics, containing the # of received beacons,
314 * # of received beacons accumulated over FW restart, and the current
315 * average signal of beacons retrieved from the firmware
316 * @csa_failed: CSA failed to schedule time event, report an error later
317 * @features: hw features active for this vif
318 * @probe_resp_data: data from FW notification to store NOA and CSA related
319 * data to be inserted into probe response.
320 */
321 struct iwl_mvm_vif {
322 struct iwl_mvm *mvm;
323 u16 id;
324 u16 color;
325 u8 ap_sta_id;
326
327 u8 bssid[ETH_ALEN];
328 bool associated;
329 u8 ap_assoc_sta_count;
330
331 u16 cab_queue;
332
333 bool uploaded;
334 bool ap_ibss_active;
335 bool pm_enabled;
336 bool monitor_active;
337 u8 low_latency: 6;
338 u8 low_latency_actual: 1;
339 u8 authorized:1;
340 bool ps_disabled;
341 struct iwl_mvm_vif_bf_data bf_data;
342
343 struct {
344 u32 num_beacons, accu_num_beacons;
345 u8 avg_signal;
346 } beacon_stats;
347
348 u32 ap_beacon_time;
349
350 enum iwl_tsf_id tsf_id;
351
352 /*
353 * QoS data from mac80211, need to store this here
354 * as mac80211 has a separate callback but we need
355 * to have the data for the MAC context
356 */
357 struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
358 struct iwl_mvm_time_event_data time_event_data;
359 struct iwl_mvm_time_event_data hs_time_event_data;
360
361 struct iwl_mvm_int_sta bcast_sta;
362 struct iwl_mvm_int_sta mcast_sta;
363
364 /*
365 * Assigned while mac80211 has the interface in a channel context,
366 * or, for P2P Device, while it exists.
367 */
368 struct iwl_mvm_phy_ctxt *phy_ctxt;
369
370 #ifdef CONFIG_PM
371 /* WoWLAN GTK rekey data */
372 struct {
373 u8 kck[NL80211_KCK_EXT_LEN];
374 u8 kek[NL80211_KEK_EXT_LEN];
375 size_t kek_len;
376 size_t kck_len;
377 u32 akm;
378 __le64 replay_ctr;
379 bool valid;
380 } rekey_data;
381
382 int tx_key_idx;
383
384 bool seqno_valid;
385 u16 seqno;
386 #endif
387
388 #if IS_ENABLED(CONFIG_IPV6)
389 /* IPv6 addresses for WoWLAN */
390 struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX];
391 unsigned long tentative_addrs[BITS_TO_LONGS(IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX)];
392 int num_target_ipv6_addrs;
393 #endif
394
395 #ifdef CONFIG_IWLWIFI_DEBUGFS
396 struct dentry *dbgfs_dir;
397 struct dentry *dbgfs_slink;
398 struct iwl_dbgfs_pm dbgfs_pm;
399 struct iwl_dbgfs_bf dbgfs_bf;
400 struct iwl_mac_power_cmd mac_pwr_cmd;
401 int dbgfs_quota_min;
402 #endif
403
404 enum ieee80211_smps_mode smps_requests[NUM_IWL_MVM_SMPS_REQ];
405
406 /* FW identified misbehaving AP */
407 u8 uapsd_misbehaving_bssid[ETH_ALEN];
408
409 struct delayed_work uapsd_nonagg_detected_wk;
410
411 /* Indicates that CSA countdown may be started */
412 bool csa_countdown;
413 bool csa_failed;
414 u16 csa_target_freq;
415 u16 csa_count;
416 u16 csa_misbehave;
417 struct delayed_work csa_work;
418
419 /* Indicates that we are waiting for a beacon on a new channel */
420 bool csa_bcn_pending;
421
422 /* TCP Checksum Offload */
423 netdev_features_t features;
424
425 struct iwl_probe_resp_data __rcu *probe_resp_data;
426
427 /* we can only have 2 GTK + 2 IGTK active at a time */
428 struct ieee80211_key_conf *ap_early_keys[4];
429
430 /* 26-tone RU OFDMA transmissions should be blocked */
431 bool he_ru_2mhz_block;
432
433 struct {
434 struct ieee80211_key_conf __rcu *keys[2];
435 } bcn_prot;
436 };
437
438 static inline struct iwl_mvm_vif *
iwl_mvm_vif_from_mac80211(struct ieee80211_vif * vif)439 iwl_mvm_vif_from_mac80211(struct ieee80211_vif *vif)
440 {
441 return (void *)vif->drv_priv;
442 }
443
444 extern const u8 tid_to_mac80211_ac[];
445
446 #define IWL_MVM_SCAN_STOPPING_SHIFT 8
447
448 enum iwl_scan_status {
449 IWL_MVM_SCAN_REGULAR = BIT(0),
450 IWL_MVM_SCAN_SCHED = BIT(1),
451 IWL_MVM_SCAN_NETDETECT = BIT(2),
452
453 IWL_MVM_SCAN_STOPPING_REGULAR = BIT(8),
454 IWL_MVM_SCAN_STOPPING_SCHED = BIT(9),
455 IWL_MVM_SCAN_STOPPING_NETDETECT = BIT(10),
456
457 IWL_MVM_SCAN_REGULAR_MASK = IWL_MVM_SCAN_REGULAR |
458 IWL_MVM_SCAN_STOPPING_REGULAR,
459 IWL_MVM_SCAN_SCHED_MASK = IWL_MVM_SCAN_SCHED |
460 IWL_MVM_SCAN_STOPPING_SCHED,
461 IWL_MVM_SCAN_NETDETECT_MASK = IWL_MVM_SCAN_NETDETECT |
462 IWL_MVM_SCAN_STOPPING_NETDETECT,
463
464 IWL_MVM_SCAN_STOPPING_MASK = 0xff << IWL_MVM_SCAN_STOPPING_SHIFT,
465 IWL_MVM_SCAN_MASK = 0xff,
466 };
467
468 enum iwl_mvm_scan_type {
469 IWL_SCAN_TYPE_NOT_SET,
470 IWL_SCAN_TYPE_UNASSOC,
471 IWL_SCAN_TYPE_WILD,
472 IWL_SCAN_TYPE_MILD,
473 IWL_SCAN_TYPE_FRAGMENTED,
474 IWL_SCAN_TYPE_FAST_BALANCE,
475 };
476
477 enum iwl_mvm_sched_scan_pass_all_states {
478 SCHED_SCAN_PASS_ALL_DISABLED,
479 SCHED_SCAN_PASS_ALL_ENABLED,
480 SCHED_SCAN_PASS_ALL_FOUND,
481 };
482
483 /**
484 * struct iwl_mvm_tt_mgnt - Thermal Throttling Management structure
485 * @ct_kill_exit: worker to exit thermal kill
486 * @dynamic_smps: Is thermal throttling enabled dynamic_smps?
487 * @tx_backoff: The current thremal throttling tx backoff in uSec.
488 * @min_backoff: The minimal tx backoff due to power restrictions
489 * @params: Parameters to configure the thermal throttling algorithm.
490 * @throttle: Is thermal throttling is active?
491 */
492 struct iwl_mvm_tt_mgmt {
493 struct delayed_work ct_kill_exit;
494 bool dynamic_smps;
495 u32 tx_backoff;
496 u32 min_backoff;
497 struct iwl_tt_params params;
498 bool throttle;
499 };
500
501 #ifdef CONFIG_THERMAL
502 /**
503 *struct iwl_mvm_thermal_device - thermal zone related data
504 * @temp_trips: temperature thresholds for report
505 * @fw_trips_index: keep indexes to original array - temp_trips
506 * @tzone: thermal zone device data
507 */
508 struct iwl_mvm_thermal_device {
509 s16 temp_trips[IWL_MAX_DTS_TRIPS];
510 u8 fw_trips_index[IWL_MAX_DTS_TRIPS];
511 struct thermal_zone_device *tzone;
512 };
513
514 /*
515 * struct iwl_mvm_cooling_device
516 * @cur_state: current state
517 * @cdev: struct thermal cooling device
518 */
519 struct iwl_mvm_cooling_device {
520 u32 cur_state;
521 struct thermal_cooling_device *cdev;
522 };
523 #endif
524
525 #define IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES 8
526
527 struct iwl_mvm_frame_stats {
528 u32 legacy_frames;
529 u32 ht_frames;
530 u32 vht_frames;
531 u32 bw_20_frames;
532 u32 bw_40_frames;
533 u32 bw_80_frames;
534 u32 bw_160_frames;
535 u32 sgi_frames;
536 u32 ngi_frames;
537 u32 siso_frames;
538 u32 mimo2_frames;
539 u32 agg_frames;
540 u32 ampdu_count;
541 u32 success_frames;
542 u32 fail_frames;
543 u32 last_rates[IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES];
544 int last_frame_idx;
545 };
546
547 #define IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE 0xff
548 #define IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -100
549 #define IWL_MVM_DEBUG_SET_TEMPERATURE_MAX 200
550
551 enum iwl_mvm_tdls_cs_state {
552 IWL_MVM_TDLS_SW_IDLE = 0,
553 IWL_MVM_TDLS_SW_REQ_SENT,
554 IWL_MVM_TDLS_SW_RESP_RCVD,
555 IWL_MVM_TDLS_SW_REQ_RCVD,
556 IWL_MVM_TDLS_SW_ACTIVE,
557 };
558
559 enum iwl_mvm_traffic_load {
560 IWL_MVM_TRAFFIC_LOW,
561 IWL_MVM_TRAFFIC_MEDIUM,
562 IWL_MVM_TRAFFIC_HIGH,
563 };
564
565 DECLARE_EWMA(rate, 16, 16)
566
567 struct iwl_mvm_tcm_mac {
568 struct {
569 u32 pkts[IEEE80211_NUM_ACS];
570 u32 airtime;
571 } tx;
572 struct {
573 u32 pkts[IEEE80211_NUM_ACS];
574 u32 airtime;
575 u32 last_ampdu_ref;
576 } rx;
577 struct {
578 /* track AP's transfer in client mode */
579 u64 rx_bytes;
580 struct ewma_rate rate;
581 bool detected;
582 } uapsd_nonagg_detect;
583 bool opened_rx_ba_sessions;
584 };
585
586 struct iwl_mvm_tcm {
587 struct delayed_work work;
588 spinlock_t lock; /* used when time elapsed */
589 unsigned long ts; /* timestamp when period ends */
590 unsigned long ll_ts;
591 unsigned long uapsd_nonagg_ts;
592 bool paused;
593 struct iwl_mvm_tcm_mac data[NUM_MAC_INDEX_DRIVER];
594 struct {
595 u32 elapsed; /* milliseconds for this TCM period */
596 u32 airtime[NUM_MAC_INDEX_DRIVER];
597 enum iwl_mvm_traffic_load load[NUM_MAC_INDEX_DRIVER];
598 enum iwl_mvm_traffic_load band_load[NUM_NL80211_BANDS];
599 enum iwl_mvm_traffic_load global_load;
600 bool low_latency[NUM_MAC_INDEX_DRIVER];
601 bool change[NUM_MAC_INDEX_DRIVER];
602 } result;
603 };
604
605 /**
606 * struct iwl_mvm_reorder_buffer - per ra/tid/queue reorder buffer
607 * @head_sn: reorder window head sn
608 * @num_stored: number of mpdus stored in the buffer
609 * @buf_size: the reorder buffer size as set by the last addba request
610 * @queue: queue of this reorder buffer
611 * @last_amsdu: track last ASMDU SN for duplication detection
612 * @last_sub_index: track ASMDU sub frame index for duplication detection
613 * @reorder_timer: timer for frames are in the reorder buffer. For AMSDU
614 * it is the time of last received sub-frame
615 * @removed: prevent timer re-arming
616 * @valid: reordering is valid for this queue
617 * @lock: protect reorder buffer internal state
618 * @mvm: mvm pointer, needed for frame timer context
619 * @consec_oldsn_drops: consecutive drops due to old SN
620 * @consec_oldsn_ampdu_gp2: A-MPDU GP2 timestamp to track
621 * when to apply old SN consecutive drop workaround
622 * @consec_oldsn_prev_drop: track whether or not an MPDU
623 * that was single/part of the previous A-MPDU was
624 * dropped due to old SN
625 */
626 struct iwl_mvm_reorder_buffer {
627 u16 head_sn;
628 u16 num_stored;
629 u16 buf_size;
630 int queue;
631 u16 last_amsdu;
632 u8 last_sub_index;
633 struct timer_list reorder_timer;
634 bool removed;
635 bool valid;
636 spinlock_t lock;
637 struct iwl_mvm *mvm;
638 unsigned int consec_oldsn_drops;
639 u32 consec_oldsn_ampdu_gp2;
640 unsigned int consec_oldsn_prev_drop:1;
641 } ____cacheline_aligned_in_smp;
642
643 /**
644 * struct _iwl_mvm_reorder_buf_entry - reorder buffer entry per-queue/per-seqno
645 * @frames: list of skbs stored
646 * @reorder_time: time the packet was stored in the reorder buffer
647 */
648 struct _iwl_mvm_reorder_buf_entry {
649 struct sk_buff_head frames;
650 unsigned long reorder_time;
651 };
652
653 /* make this indirection to get the aligned thing */
654 struct iwl_mvm_reorder_buf_entry {
655 struct _iwl_mvm_reorder_buf_entry e;
656 }
657 #if defined(__FreeBSD__)
658 __aligned(roundup2(sizeof(struct _iwl_mvm_reorder_buf_entry), 32))
659 #elif !defined(__CHECKER__)
660 /* sparse doesn't like this construct: "bad integer constant expression" */
661 /* clang on FreeBSD: error: 'aligned' attribute requires integer constant */
662 __aligned(roundup_pow_of_two(sizeof(struct _iwl_mvm_reorder_buf_entry)))
663 #endif
664 ;
665
666 /**
667 * struct iwl_mvm_baid_data - BA session data
668 * @sta_id: station id
669 * @tid: tid of the session
670 * @baid baid of the session
671 * @timeout: the timeout set in the addba request
672 * @entries_per_queue: # of buffers per queue, this actually gets
673 * aligned up to avoid cache line sharing between queues
674 * @last_rx: last rx jiffies, updated only if timeout passed from last update
675 * @session_timer: timer to check if BA session expired, runs at 2 * timeout
676 * @mvm: mvm pointer, needed for timer context
677 * @reorder_buf: reorder buffer, allocated per queue
678 * @reorder_buf_data: data
679 */
680 struct iwl_mvm_baid_data {
681 struct rcu_head rcu_head;
682 u8 sta_id;
683 u8 tid;
684 u8 baid;
685 u16 timeout;
686 u16 entries_per_queue;
687 unsigned long last_rx;
688 struct timer_list session_timer;
689 struct iwl_mvm_baid_data __rcu **rcu_ptr;
690 struct iwl_mvm *mvm;
691 struct iwl_mvm_reorder_buffer reorder_buf[IWL_MAX_RX_HW_QUEUES];
692 struct iwl_mvm_reorder_buf_entry entries[];
693 };
694
695 static inline struct iwl_mvm_baid_data *
iwl_mvm_baid_data_from_reorder_buf(struct iwl_mvm_reorder_buffer * buf)696 iwl_mvm_baid_data_from_reorder_buf(struct iwl_mvm_reorder_buffer *buf)
697 {
698 return (void *)((u8 *)buf -
699 offsetof(struct iwl_mvm_baid_data, reorder_buf) -
700 sizeof(*buf) * buf->queue);
701 }
702
703 /*
704 * enum iwl_mvm_queue_status - queue status
705 * @IWL_MVM_QUEUE_FREE: the queue is not allocated nor reserved
706 * Basically, this means that this queue can be used for any purpose
707 * @IWL_MVM_QUEUE_RESERVED: queue is reserved but not yet in use
708 * This is the state of a queue that has been dedicated for some RATID
709 * (agg'd or not), but that hasn't yet gone through the actual enablement
710 * of iwl_mvm_enable_txq(), and therefore no traffic can go through it yet.
711 * Note that in this state there is no requirement to already know what TID
712 * should be used with this queue, it is just marked as a queue that will
713 * be used, and shouldn't be allocated to anyone else.
714 * @IWL_MVM_QUEUE_READY: queue is ready to be used
715 * This is the state of a queue that has been fully configured (including
716 * SCD pointers, etc), has a specific RA/TID assigned to it, and can be
717 * used to send traffic.
718 * @IWL_MVM_QUEUE_SHARED: queue is shared, or in a process of becoming shared
719 * This is a state in which a single queue serves more than one TID, all of
720 * which are not aggregated. Note that the queue is only associated to one
721 * RA.
722 */
723 enum iwl_mvm_queue_status {
724 IWL_MVM_QUEUE_FREE,
725 IWL_MVM_QUEUE_RESERVED,
726 IWL_MVM_QUEUE_READY,
727 IWL_MVM_QUEUE_SHARED,
728 };
729
730 #define IWL_MVM_DQA_QUEUE_TIMEOUT (5 * HZ)
731 #define IWL_MVM_INVALID_QUEUE 0xFFFF
732
733 #define IWL_MVM_NUM_CIPHERS 10
734
735
736 struct iwl_mvm_txq {
737 struct list_head list;
738 u16 txq_id;
739 atomic_t tx_request;
740 bool stopped;
741 };
742
743 static inline struct iwl_mvm_txq *
iwl_mvm_txq_from_mac80211(struct ieee80211_txq * txq)744 iwl_mvm_txq_from_mac80211(struct ieee80211_txq *txq)
745 {
746 return (void *)txq->drv_priv;
747 }
748
749 static inline struct iwl_mvm_txq *
iwl_mvm_txq_from_tid(struct ieee80211_sta * sta,u8 tid)750 iwl_mvm_txq_from_tid(struct ieee80211_sta *sta, u8 tid)
751 {
752 if (tid == IWL_MAX_TID_COUNT)
753 tid = IEEE80211_NUM_TIDS;
754
755 return (void *)sta->txq[tid]->drv_priv;
756 }
757
758 /**
759 * struct iwl_mvm_tvqm_txq_info - maps TVQM hw queue to tid
760 *
761 * @sta_id: sta id
762 * @txq_tid: txq tid
763 */
764 struct iwl_mvm_tvqm_txq_info {
765 u8 sta_id;
766 u8 txq_tid;
767 };
768
769 struct iwl_mvm_dqa_txq_info {
770 u8 ra_sta_id; /* The RA this queue is mapped to, if exists */
771 bool reserved; /* Is this the TXQ reserved for a STA */
772 u8 mac80211_ac; /* The mac80211 AC this queue is mapped to */
773 u8 txq_tid; /* The TID "owner" of this queue*/
774 u16 tid_bitmap; /* Bitmap of the TIDs mapped to this queue */
775 /* Timestamp for inactivation per TID of this queue */
776 unsigned long last_frame_time[IWL_MAX_TID_COUNT + 1];
777 enum iwl_mvm_queue_status status;
778 };
779
780 struct iwl_mvm {
781 /* for logger access */
782 struct device *dev;
783
784 struct iwl_trans *trans;
785 const struct iwl_fw *fw;
786 const struct iwl_cfg *cfg;
787 struct iwl_phy_db *phy_db;
788 struct ieee80211_hw *hw;
789
790 /* for protecting access to iwl_mvm */
791 struct mutex mutex;
792 struct list_head async_handlers_list;
793 spinlock_t async_handlers_lock;
794 struct work_struct async_handlers_wk;
795
796 struct work_struct roc_done_wk;
797
798 unsigned long init_status;
799
800 unsigned long status;
801
802 u32 queue_sync_cookie;
803 unsigned long queue_sync_state;
804 /*
805 * for beacon filtering -
806 * currently only one interface can be supported
807 */
808 struct iwl_mvm_vif *bf_allowed_vif;
809
810 bool hw_registered;
811 bool rfkill_safe_init_done;
812
813 u8 cca_40mhz_workaround;
814
815 u32 ampdu_ref;
816 bool ampdu_toggle;
817
818 struct iwl_notif_wait_data notif_wait;
819
820 union {
821 struct mvm_statistics_rx_v3 rx_stats_v3;
822 struct mvm_statistics_rx rx_stats;
823 };
824
825 struct {
826 u64 rx_time;
827 u64 tx_time;
828 u64 on_time_rf;
829 u64 on_time_scan;
830 } radio_stats, accu_radio_stats;
831
832 struct list_head add_stream_txqs;
833 union {
834 struct iwl_mvm_dqa_txq_info queue_info[IWL_MAX_HW_QUEUES];
835 struct iwl_mvm_tvqm_txq_info tvqm_info[IWL_MAX_TVQM_QUEUES];
836 };
837 struct work_struct add_stream_wk; /* To add streams to queues */
838
839 const char *nvm_file_name;
840 struct iwl_nvm_data *nvm_data;
841 struct iwl_mei_nvm *mei_nvm_data;
842 struct iwl_mvm_csme_conn_info __rcu *csme_conn_info;
843 bool mei_rfkill_blocked;
844 bool mei_registered;
845 struct work_struct sap_connected_wk;
846
847 /*
848 * NVM built based on the SAP data but that we can't free even after
849 * we get ownership because it contains the cfg80211's channel.
850 */
851 struct iwl_nvm_data *temp_nvm_data;
852
853 /* NVM sections */
854 struct iwl_nvm_section nvm_sections[NVM_MAX_NUM_SECTIONS];
855
856 struct iwl_fw_runtime fwrt;
857
858 /* EEPROM MAC addresses */
859 struct mac_address addresses[IWL_MVM_MAX_ADDRESSES];
860
861 /* data related to data path */
862 struct iwl_rx_phy_info last_phy_info;
863 struct ieee80211_sta __rcu *fw_id_to_mac_id[IWL_MVM_STATION_COUNT_MAX];
864 u8 rx_ba_sessions;
865
866 /* configured by mac80211 */
867 u32 rts_threshold;
868
869 /* Scan status, cmd (pre-allocated) and auxiliary station */
870 unsigned int scan_status;
871 void *scan_cmd;
872 struct iwl_mcast_filter_cmd *mcast_filter_cmd;
873 /* For CDB this is low band scan type, for non-CDB - type. */
874 enum iwl_mvm_scan_type scan_type;
875 enum iwl_mvm_scan_type hb_scan_type;
876
877 enum iwl_mvm_sched_scan_pass_all_states sched_scan_pass_all;
878 struct delayed_work scan_timeout_dwork;
879
880 /* max number of simultaneous scans the FW supports */
881 unsigned int max_scans;
882
883 /* UMAC scan tracking */
884 u32 scan_uid_status[IWL_MVM_MAX_UMAC_SCANS];
885
886 /* start time of last scan in TSF of the mac that requested the scan */
887 u64 scan_start;
888
889 /* the vif that requested the current scan */
890 struct iwl_mvm_vif *scan_vif;
891
892 /* rx chain antennas set through debugfs for the scan command */
893 u8 scan_rx_ant;
894
895 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
896 /* broadcast filters to configure for each associated station */
897 const struct iwl_fw_bcast_filter *bcast_filters;
898 #ifdef CONFIG_IWLWIFI_DEBUGFS
899 struct {
900 bool override;
901 struct iwl_bcast_filter_cmd cmd;
902 } dbgfs_bcast_filtering;
903 #endif
904 #endif
905
906 /* Internal station */
907 struct iwl_mvm_int_sta aux_sta;
908 struct iwl_mvm_int_sta snif_sta;
909
910 bool last_ebs_successful;
911
912 u8 scan_last_antenna_idx; /* to toggle TX between antennas */
913 u8 mgmt_last_antenna_idx;
914
915 /* last smart fifo state that was successfully sent to firmware */
916 enum iwl_sf_state sf_state;
917
918 /*
919 * Leave this pointer outside the ifdef below so that it can be
920 * assigned without ifdef in the source code.
921 */
922 struct dentry *debugfs_dir;
923 #ifdef CONFIG_IWLWIFI_DEBUGFS
924 u32 dbgfs_sram_offset, dbgfs_sram_len;
925 u32 dbgfs_prph_reg_addr;
926 bool disable_power_off;
927 bool disable_power_off_d3;
928 bool beacon_inject_active;
929
930 bool scan_iter_notif_enabled;
931
932 struct debugfs_blob_wrapper nvm_hw_blob;
933 struct debugfs_blob_wrapper nvm_sw_blob;
934 struct debugfs_blob_wrapper nvm_calib_blob;
935 struct debugfs_blob_wrapper nvm_prod_blob;
936 struct debugfs_blob_wrapper nvm_phy_sku_blob;
937 struct debugfs_blob_wrapper nvm_reg_blob;
938
939 struct iwl_mvm_frame_stats drv_rx_stats;
940 spinlock_t drv_stats_lock;
941 u16 dbgfs_rx_phyinfo;
942 #endif
943
944 struct iwl_mvm_phy_ctxt phy_ctxts[NUM_PHY_CTX];
945
946 struct list_head time_event_list;
947 spinlock_t time_event_lock;
948
949 /*
950 * A bitmap indicating the index of the key in use. The firmware
951 * can hold 16 keys at most. Reflect this fact.
952 */
953 unsigned long fw_key_table[BITS_TO_LONGS(STA_KEY_MAX_NUM)];
954 u8 fw_key_deleted[STA_KEY_MAX_NUM];
955
956 u8 vif_count;
957 struct ieee80211_vif __rcu *vif_id_to_mac[NUM_MAC_INDEX_DRIVER];
958
959 /* -1 for always, 0 for never, >0 for that many times */
960 s8 fw_restart;
961 u8 *error_recovery_buf;
962
963 #ifdef CONFIG_IWLWIFI_LEDS
964 struct led_classdev led;
965 #endif
966
967 struct ieee80211_vif *p2p_device_vif;
968
969 #ifdef CONFIG_PM
970 struct wiphy_wowlan_support wowlan;
971 int gtk_ivlen, gtk_icvlen, ptk_ivlen, ptk_icvlen;
972
973 /* sched scan settings for net detect */
974 struct ieee80211_scan_ies nd_ies;
975 struct cfg80211_match_set *nd_match_sets;
976 int n_nd_match_sets;
977 struct ieee80211_channel **nd_channels;
978 int n_nd_channels;
979 bool net_detect;
980 u8 offload_tid;
981 #ifdef CONFIG_IWLWIFI_DEBUGFS
982 bool d3_wake_sysassert;
983 bool d3_test_active;
984 u32 d3_test_pme_ptr;
985 struct ieee80211_vif *keep_vif;
986 u32 last_netdetect_scans; /* no. of scans in the last net-detect wake */
987 #endif
988 #endif
989
990 wait_queue_head_t rx_sync_waitq;
991
992 /* BT-Coex */
993 struct iwl_bt_coex_profile_notif last_bt_notif;
994 struct iwl_bt_coex_ci_cmd last_bt_ci_cmd;
995
996 u8 bt_tx_prio;
997 enum iwl_bt_force_ant_mode bt_force_ant_mode;
998
999 /* Aux ROC */
1000 struct list_head aux_roc_te_list;
1001
1002 /* Thermal Throttling and CTkill */
1003 struct iwl_mvm_tt_mgmt thermal_throttle;
1004 #ifdef CONFIG_THERMAL
1005 struct iwl_mvm_thermal_device tz_device;
1006 struct iwl_mvm_cooling_device cooling_dev;
1007 #endif
1008
1009 s32 temperature; /* Celsius */
1010 /*
1011 * Debug option to set the NIC temperature. This option makes the
1012 * driver think this is the actual NIC temperature, and ignore the
1013 * real temperature that is received from the fw
1014 */
1015 bool temperature_test; /* Debug test temperature is enabled */
1016
1017 bool fw_static_smps_request;
1018
1019 unsigned long bt_coex_last_tcm_ts;
1020 struct iwl_mvm_tcm tcm;
1021
1022 u8 uapsd_noagg_bssid_write_idx;
1023 struct mac_address uapsd_noagg_bssids[IWL_MVM_UAPSD_NOAGG_BSSIDS_NUM]
1024 __aligned(2);
1025
1026 struct iwl_time_quota_cmd last_quota_cmd;
1027
1028 #ifdef CONFIG_NL80211_TESTMODE
1029 u32 noa_duration;
1030 struct ieee80211_vif *noa_vif;
1031 #endif
1032
1033 /* Tx queues */
1034 u16 aux_queue;
1035 u16 snif_queue;
1036 u16 probe_queue;
1037 u16 p2p_dev_queue;
1038
1039 /* Indicate if device power save is allowed */
1040 u8 ps_disabled; /* u8 instead of bool to ease debugfs_create_* usage */
1041 /* Indicate if 32Khz external clock is valid */
1042 u32 ext_clock_valid;
1043
1044 /* This vif used by CSME to send / receive traffic */
1045 struct ieee80211_vif *csme_vif;
1046 struct ieee80211_vif __rcu *csa_vif;
1047 struct ieee80211_vif __rcu *csa_tx_blocked_vif;
1048 u8 csa_tx_block_bcn_timeout;
1049
1050 /* system time of last beacon (for AP/GO interface) */
1051 u32 ap_last_beacon_gp2;
1052
1053 /* indicates that we transmitted the last beacon */
1054 bool ibss_manager;
1055
1056 bool lar_regdom_set;
1057 enum iwl_mcc_source mcc_src;
1058
1059 /* TDLS channel switch data */
1060 struct {
1061 struct delayed_work dwork;
1062 enum iwl_mvm_tdls_cs_state state;
1063
1064 /*
1065 * Current cs sta - might be different from periodic cs peer
1066 * station. Value is meaningless when the cs-state is idle.
1067 */
1068 u8 cur_sta_id;
1069
1070 /* TDLS periodic channel-switch peer */
1071 struct {
1072 u8 sta_id;
1073 u8 op_class;
1074 bool initiator; /* are we the link initiator */
1075 struct cfg80211_chan_def chandef;
1076 struct sk_buff *skb; /* ch sw template */
1077 u32 ch_sw_tm_ie;
1078
1079 /* timestamp of last ch-sw request sent (GP2 time) */
1080 u32 sent_timestamp;
1081 } peer;
1082 } tdls_cs;
1083
1084
1085 u32 ciphers[IWL_MVM_NUM_CIPHERS];
1086 struct ieee80211_cipher_scheme cs[IWL_UCODE_MAX_CS];
1087
1088 struct cfg80211_ftm_responder_stats ftm_resp_stats;
1089 struct {
1090 struct cfg80211_pmsr_request *req;
1091 struct wireless_dev *req_wdev;
1092 struct list_head loc_list;
1093 int responses[IWL_MVM_TOF_MAX_APS];
1094 struct {
1095 struct list_head resp;
1096 } smooth;
1097 struct list_head pasn_list;
1098 } ftm_initiator;
1099
1100 struct list_head resp_pasn_list;
1101
1102 struct {
1103 u8 d0i3_resp;
1104 u8 range_resp;
1105 } cmd_ver;
1106
1107 struct ieee80211_vif *nan_vif;
1108 struct iwl_mvm_baid_data __rcu *baid_map[IWL_MAX_BAID];
1109
1110 /*
1111 * Drop beacons from other APs in AP mode when there are no connected
1112 * clients.
1113 */
1114 bool drop_bcn_ap_mode;
1115
1116 struct delayed_work cs_tx_unblock_dwork;
1117
1118 /* does a monitor vif exist (only one can exist hence bool) */
1119 bool monitor_on;
1120
1121 /* sniffer data to include in radiotap */
1122 __le16 cur_aid;
1123 u8 cur_bssid[ETH_ALEN];
1124
1125 unsigned long last_6ghz_passive_scan_jiffies;
1126 unsigned long last_reset_or_resume_time_jiffies;
1127
1128 bool sta_remove_requires_queue_remove;
1129 };
1130
1131 /* Extract MVM priv from op_mode and _hw */
1132 #define IWL_OP_MODE_GET_MVM(_iwl_op_mode) \
1133 ((struct iwl_mvm *)(_iwl_op_mode)->op_mode_specific)
1134
1135 #define IWL_MAC80211_GET_MVM(_hw) \
1136 IWL_OP_MODE_GET_MVM((struct iwl_op_mode *)((_hw)->priv))
1137
1138 /**
1139 * enum iwl_mvm_status - MVM status bits
1140 * @IWL_MVM_STATUS_HW_RFKILL: HW RF-kill is asserted
1141 * @IWL_MVM_STATUS_HW_CTKILL: CT-kill is active
1142 * @IWL_MVM_STATUS_ROC_RUNNING: remain-on-channel is running
1143 * @IWL_MVM_STATUS_HW_RESTART_REQUESTED: HW restart was requested
1144 * @IWL_MVM_STATUS_IN_HW_RESTART: HW restart is active
1145 * @IWL_MVM_STATUS_ROC_AUX_RUNNING: AUX remain-on-channel is running
1146 * @IWL_MVM_STATUS_FIRMWARE_RUNNING: firmware is running
1147 * @IWL_MVM_STATUS_NEED_FLUSH_P2P: need to flush P2P bcast STA
1148 * @IWL_MVM_STATUS_IN_D3: in D3 (or at least about to go into it)
1149 * @IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE: suppress one error log
1150 * if this is set, when intentionally triggered
1151 * @IWL_MVM_STATUS_STARTING: starting mac,
1152 * used to disable restart flow while in STARTING state
1153 */
1154 enum iwl_mvm_status {
1155 IWL_MVM_STATUS_HW_RFKILL,
1156 IWL_MVM_STATUS_HW_CTKILL,
1157 IWL_MVM_STATUS_ROC_RUNNING,
1158 IWL_MVM_STATUS_HW_RESTART_REQUESTED,
1159 IWL_MVM_STATUS_IN_HW_RESTART,
1160 IWL_MVM_STATUS_ROC_AUX_RUNNING,
1161 IWL_MVM_STATUS_FIRMWARE_RUNNING,
1162 IWL_MVM_STATUS_NEED_FLUSH_P2P,
1163 IWL_MVM_STATUS_IN_D3,
1164 IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE,
1165 IWL_MVM_STATUS_STARTING,
1166 };
1167
1168 struct iwl_mvm_csme_conn_info {
1169 struct rcu_head rcu_head;
1170 struct iwl_mei_conn_info conn_info;
1171 };
1172
1173 /* Keep track of completed init configuration */
1174 enum iwl_mvm_init_status {
1175 IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE = BIT(0),
1176 IWL_MVM_INIT_STATUS_LEDS_INIT_COMPLETE = BIT(1),
1177 };
1178
iwl_mvm_is_radio_killed(struct iwl_mvm * mvm)1179 static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm)
1180 {
1181 return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status) ||
1182 test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status);
1183 }
1184
iwl_mvm_is_radio_hw_killed(struct iwl_mvm * mvm)1185 static inline bool iwl_mvm_is_radio_hw_killed(struct iwl_mvm *mvm)
1186 {
1187 return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status);
1188 }
1189
iwl_mvm_firmware_running(struct iwl_mvm * mvm)1190 static inline bool iwl_mvm_firmware_running(struct iwl_mvm *mvm)
1191 {
1192 return test_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
1193 }
1194
1195 /* Must be called with rcu_read_lock() held and it can only be
1196 * released when mvmsta is not needed anymore.
1197 */
1198 static inline struct iwl_mvm_sta *
iwl_mvm_sta_from_staid_rcu(struct iwl_mvm * mvm,u8 sta_id)1199 iwl_mvm_sta_from_staid_rcu(struct iwl_mvm *mvm, u8 sta_id)
1200 {
1201 struct ieee80211_sta *sta;
1202
1203 if (sta_id >= mvm->fw->ucode_capa.num_stations)
1204 return NULL;
1205
1206 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
1207
1208 /* This can happen if the station has been removed right now */
1209 if (IS_ERR_OR_NULL(sta))
1210 return NULL;
1211
1212 return iwl_mvm_sta_from_mac80211(sta);
1213 }
1214
1215 static inline struct iwl_mvm_sta *
iwl_mvm_sta_from_staid_protected(struct iwl_mvm * mvm,u8 sta_id)1216 iwl_mvm_sta_from_staid_protected(struct iwl_mvm *mvm, u8 sta_id)
1217 {
1218 struct ieee80211_sta *sta;
1219
1220 if (sta_id >= mvm->fw->ucode_capa.num_stations)
1221 return NULL;
1222
1223 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
1224 lockdep_is_held(&mvm->mutex));
1225
1226 /* This can happen if the station has been removed right now */
1227 if (IS_ERR_OR_NULL(sta))
1228 return NULL;
1229
1230 return iwl_mvm_sta_from_mac80211(sta);
1231 }
1232
1233 static inline struct ieee80211_vif *
iwl_mvm_rcu_dereference_vif_id(struct iwl_mvm * mvm,u8 vif_id,bool rcu)1234 iwl_mvm_rcu_dereference_vif_id(struct iwl_mvm *mvm, u8 vif_id, bool rcu)
1235 {
1236 if (WARN_ON(vif_id >= ARRAY_SIZE(mvm->vif_id_to_mac)))
1237 return NULL;
1238
1239 if (rcu)
1240 return rcu_dereference(mvm->vif_id_to_mac[vif_id]);
1241
1242 return rcu_dereference_protected(mvm->vif_id_to_mac[vif_id],
1243 lockdep_is_held(&mvm->mutex));
1244 }
1245
iwl_mvm_is_adaptive_dwell_supported(struct iwl_mvm * mvm)1246 static inline bool iwl_mvm_is_adaptive_dwell_supported(struct iwl_mvm *mvm)
1247 {
1248 return fw_has_api(&mvm->fw->ucode_capa,
1249 IWL_UCODE_TLV_API_ADAPTIVE_DWELL);
1250 }
1251
iwl_mvm_is_adaptive_dwell_v2_supported(struct iwl_mvm * mvm)1252 static inline bool iwl_mvm_is_adaptive_dwell_v2_supported(struct iwl_mvm *mvm)
1253 {
1254 return fw_has_api(&mvm->fw->ucode_capa,
1255 IWL_UCODE_TLV_API_ADAPTIVE_DWELL_V2);
1256 }
1257
iwl_mvm_is_adwell_hb_ap_num_supported(struct iwl_mvm * mvm)1258 static inline bool iwl_mvm_is_adwell_hb_ap_num_supported(struct iwl_mvm *mvm)
1259 {
1260 return fw_has_api(&mvm->fw->ucode_capa,
1261 IWL_UCODE_TLV_API_ADWELL_HB_DEF_N_AP);
1262 }
1263
iwl_mvm_is_oce_supported(struct iwl_mvm * mvm)1264 static inline bool iwl_mvm_is_oce_supported(struct iwl_mvm *mvm)
1265 {
1266 /* OCE should never be enabled for LMAC scan FWs */
1267 return fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_OCE);
1268 }
1269
iwl_mvm_is_frag_ebs_supported(struct iwl_mvm * mvm)1270 static inline bool iwl_mvm_is_frag_ebs_supported(struct iwl_mvm *mvm)
1271 {
1272 return fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_FRAG_EBS);
1273 }
1274
iwl_mvm_is_short_beacon_notif_supported(struct iwl_mvm * mvm)1275 static inline bool iwl_mvm_is_short_beacon_notif_supported(struct iwl_mvm *mvm)
1276 {
1277 return fw_has_api(&mvm->fw->ucode_capa,
1278 IWL_UCODE_TLV_API_SHORT_BEACON_NOTIF);
1279 }
1280
iwl_mvm_is_dqa_data_queue(struct iwl_mvm * mvm,u8 queue)1281 static inline bool iwl_mvm_is_dqa_data_queue(struct iwl_mvm *mvm, u8 queue)
1282 {
1283 return (queue >= IWL_MVM_DQA_MIN_DATA_QUEUE) &&
1284 (queue <= IWL_MVM_DQA_MAX_DATA_QUEUE);
1285 }
1286
iwl_mvm_is_dqa_mgmt_queue(struct iwl_mvm * mvm,u8 queue)1287 static inline bool iwl_mvm_is_dqa_mgmt_queue(struct iwl_mvm *mvm, u8 queue)
1288 {
1289 return (queue >= IWL_MVM_DQA_MIN_MGMT_QUEUE) &&
1290 (queue <= IWL_MVM_DQA_MAX_MGMT_QUEUE);
1291 }
1292
iwl_mvm_is_lar_supported(struct iwl_mvm * mvm)1293 static inline bool iwl_mvm_is_lar_supported(struct iwl_mvm *mvm)
1294 {
1295 bool nvm_lar = mvm->nvm_data->lar_enabled;
1296 bool tlv_lar = fw_has_capa(&mvm->fw->ucode_capa,
1297 IWL_UCODE_TLV_CAPA_LAR_SUPPORT);
1298
1299 /*
1300 * Enable LAR only if it is supported by the FW (TLV) &&
1301 * enabled in the NVM
1302 */
1303 if (mvm->cfg->nvm_type == IWL_NVM_EXT)
1304 return nvm_lar && tlv_lar;
1305 else
1306 return tlv_lar;
1307 }
1308
iwl_mvm_is_wifi_mcc_supported(struct iwl_mvm * mvm)1309 static inline bool iwl_mvm_is_wifi_mcc_supported(struct iwl_mvm *mvm)
1310 {
1311 return fw_has_api(&mvm->fw->ucode_capa,
1312 IWL_UCODE_TLV_API_WIFI_MCC_UPDATE) ||
1313 fw_has_capa(&mvm->fw->ucode_capa,
1314 IWL_UCODE_TLV_CAPA_LAR_MULTI_MCC);
1315 }
1316
iwl_mvm_bt_is_rrc_supported(struct iwl_mvm * mvm)1317 static inline bool iwl_mvm_bt_is_rrc_supported(struct iwl_mvm *mvm)
1318 {
1319 return fw_has_capa(&mvm->fw->ucode_capa,
1320 IWL_UCODE_TLV_CAPA_BT_COEX_RRC) &&
1321 IWL_MVM_BT_COEX_RRC;
1322 }
1323
iwl_mvm_is_csum_supported(struct iwl_mvm * mvm)1324 static inline bool iwl_mvm_is_csum_supported(struct iwl_mvm *mvm)
1325 {
1326 return fw_has_capa(&mvm->fw->ucode_capa,
1327 IWL_UCODE_TLV_CAPA_CSUM_SUPPORT) &&
1328 !IWL_MVM_HW_CSUM_DISABLE;
1329 }
1330
iwl_mvm_is_mplut_supported(struct iwl_mvm * mvm)1331 static inline bool iwl_mvm_is_mplut_supported(struct iwl_mvm *mvm)
1332 {
1333 return fw_has_capa(&mvm->fw->ucode_capa,
1334 IWL_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT) &&
1335 IWL_MVM_BT_COEX_MPLUT;
1336 }
1337
1338 static inline
iwl_mvm_is_p2p_scm_uapsd_supported(struct iwl_mvm * mvm)1339 bool iwl_mvm_is_p2p_scm_uapsd_supported(struct iwl_mvm *mvm)
1340 {
1341 return fw_has_capa(&mvm->fw->ucode_capa,
1342 IWL_UCODE_TLV_CAPA_P2P_SCM_UAPSD) &&
1343 !(iwlwifi_mod_params.uapsd_disable &
1344 IWL_DISABLE_UAPSD_P2P_CLIENT);
1345 }
1346
iwl_mvm_has_new_rx_api(struct iwl_mvm * mvm)1347 static inline bool iwl_mvm_has_new_rx_api(struct iwl_mvm *mvm)
1348 {
1349 return fw_has_capa(&mvm->fw->ucode_capa,
1350 IWL_UCODE_TLV_CAPA_MULTI_QUEUE_RX_SUPPORT);
1351 }
1352
iwl_mvm_has_new_tx_api(struct iwl_mvm * mvm)1353 static inline bool iwl_mvm_has_new_tx_api(struct iwl_mvm *mvm)
1354 {
1355 /* TODO - replace with TLV once defined */
1356 return mvm->trans->trans_cfg->use_tfh;
1357 }
1358
iwl_mvm_has_unified_ucode(struct iwl_mvm * mvm)1359 static inline bool iwl_mvm_has_unified_ucode(struct iwl_mvm *mvm)
1360 {
1361 /* TODO - better define this */
1362 return mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_22000;
1363 }
1364
iwl_mvm_is_cdb_supported(struct iwl_mvm * mvm)1365 static inline bool iwl_mvm_is_cdb_supported(struct iwl_mvm *mvm)
1366 {
1367 /*
1368 * TODO:
1369 * The issue of how to determine CDB APIs and usage is still not fully
1370 * defined.
1371 * There is a compilation for CDB and non-CDB FW, but there may
1372 * be also runtime check.
1373 * For now there is a TLV for checking compilation mode, but a
1374 * runtime check will also have to be here - once defined.
1375 */
1376 return fw_has_capa(&mvm->fw->ucode_capa,
1377 IWL_UCODE_TLV_CAPA_CDB_SUPPORT);
1378 }
1379
iwl_mvm_cdb_scan_api(struct iwl_mvm * mvm)1380 static inline bool iwl_mvm_cdb_scan_api(struct iwl_mvm *mvm)
1381 {
1382 /*
1383 * TODO: should this be the same as iwl_mvm_is_cdb_supported()?
1384 * but then there's a little bit of code in scan that won't make
1385 * any sense...
1386 */
1387 return mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_22000;
1388 }
1389
iwl_mvm_is_scan_ext_chan_supported(struct iwl_mvm * mvm)1390 static inline bool iwl_mvm_is_scan_ext_chan_supported(struct iwl_mvm *mvm)
1391 {
1392 return fw_has_api(&mvm->fw->ucode_capa,
1393 IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER);
1394 }
1395
1396
iwl_mvm_is_reduced_config_scan_supported(struct iwl_mvm * mvm)1397 static inline bool iwl_mvm_is_reduced_config_scan_supported(struct iwl_mvm *mvm)
1398 {
1399 return fw_has_api(&mvm->fw->ucode_capa,
1400 IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG);
1401 }
1402
iwl_mvm_is_band_in_rx_supported(struct iwl_mvm * mvm)1403 static inline bool iwl_mvm_is_band_in_rx_supported(struct iwl_mvm *mvm)
1404 {
1405 return fw_has_api(&mvm->fw->ucode_capa,
1406 IWL_UCODE_TLV_API_BAND_IN_RX_DATA);
1407 }
1408
iwl_mvm_has_new_rx_stats_api(struct iwl_mvm * mvm)1409 static inline bool iwl_mvm_has_new_rx_stats_api(struct iwl_mvm *mvm)
1410 {
1411 return fw_has_api(&mvm->fw->ucode_capa,
1412 IWL_UCODE_TLV_API_NEW_RX_STATS);
1413 }
1414
iwl_mvm_has_quota_low_latency(struct iwl_mvm * mvm)1415 static inline bool iwl_mvm_has_quota_low_latency(struct iwl_mvm *mvm)
1416 {
1417 return fw_has_api(&mvm->fw->ucode_capa,
1418 IWL_UCODE_TLV_API_QUOTA_LOW_LATENCY);
1419 }
1420
iwl_mvm_has_tlc_offload(const struct iwl_mvm * mvm)1421 static inline bool iwl_mvm_has_tlc_offload(const struct iwl_mvm *mvm)
1422 {
1423 return fw_has_capa(&mvm->fw->ucode_capa,
1424 IWL_UCODE_TLV_CAPA_TLC_OFFLOAD);
1425 }
1426
1427 static inline struct agg_tx_status *
iwl_mvm_get_agg_status(struct iwl_mvm * mvm,void * tx_resp)1428 iwl_mvm_get_agg_status(struct iwl_mvm *mvm, void *tx_resp)
1429 {
1430 if (iwl_mvm_has_new_tx_api(mvm))
1431 return &((struct iwl_mvm_tx_resp *)tx_resp)->status;
1432 else
1433 return ((struct iwl_mvm_tx_resp_v3 *)tx_resp)->status;
1434 }
1435
iwl_mvm_is_tt_in_fw(struct iwl_mvm * mvm)1436 static inline bool iwl_mvm_is_tt_in_fw(struct iwl_mvm *mvm)
1437 {
1438 /* these two TLV are redundant since the responsibility to CT-kill by
1439 * FW happens only after we send at least one command of
1440 * temperature THs report.
1441 */
1442 return fw_has_capa(&mvm->fw->ucode_capa,
1443 IWL_UCODE_TLV_CAPA_CT_KILL_BY_FW) &&
1444 fw_has_capa(&mvm->fw->ucode_capa,
1445 IWL_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT);
1446 }
1447
iwl_mvm_is_ctdp_supported(struct iwl_mvm * mvm)1448 static inline bool iwl_mvm_is_ctdp_supported(struct iwl_mvm *mvm)
1449 {
1450 return fw_has_capa(&mvm->fw->ucode_capa,
1451 IWL_UCODE_TLV_CAPA_CTDP_SUPPORT);
1452 }
1453
1454 extern const u8 iwl_mvm_ac_to_tx_fifo[];
1455 extern const u8 iwl_mvm_ac_to_gen2_tx_fifo[];
1456
iwl_mvm_mac_ac_to_tx_fifo(struct iwl_mvm * mvm,enum ieee80211_ac_numbers ac)1457 static inline u8 iwl_mvm_mac_ac_to_tx_fifo(struct iwl_mvm *mvm,
1458 enum ieee80211_ac_numbers ac)
1459 {
1460 return iwl_mvm_has_new_tx_api(mvm) ?
1461 iwl_mvm_ac_to_gen2_tx_fifo[ac] : iwl_mvm_ac_to_tx_fifo[ac];
1462 }
1463
1464 struct iwl_rate_info {
1465 u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */
1466 u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */
1467 u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */
1468 u8 plcp_mimo3; /* uCode API: IWL_RATE_MIMO3_6M_PLCP, etc. */
1469 u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */
1470 };
1471
1472 void __iwl_mvm_mac_stop(struct iwl_mvm *mvm);
1473 int __iwl_mvm_mac_start(struct iwl_mvm *mvm);
1474
1475 /******************
1476 * MVM Methods
1477 ******************/
1478 /* uCode */
1479 int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm);
1480
1481 /* Utils */
1482 int iwl_mvm_legacy_hw_idx_to_mac80211_idx(u32 rate_n_flags,
1483 enum nl80211_band band);
1484 int iwl_mvm_legacy_rate_to_mac80211_idx(u32 rate_n_flags,
1485 enum nl80211_band band);
1486 void iwl_mvm_hwrate_to_tx_rate(u32 rate_n_flags,
1487 enum nl80211_band band,
1488 struct ieee80211_tx_rate *r);
1489 void iwl_mvm_hwrate_to_tx_rate_v1(u32 rate_n_flags,
1490 enum nl80211_band band,
1491 struct ieee80211_tx_rate *r);
1492 u8 iwl_mvm_mac80211_idx_to_hwrate(const struct iwl_fw *fw, int rate_idx);
1493 u8 iwl_mvm_mac80211_ac_to_ucode_ac(enum ieee80211_ac_numbers ac);
1494
iwl_mvm_dump_nic_error_log(struct iwl_mvm * mvm)1495 static inline void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm)
1496 {
1497 iwl_fwrt_dump_error_logs(&mvm->fwrt);
1498 }
1499
1500 u8 first_antenna(u8 mask);
1501 u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx);
1502 void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, int clock_type, u32 *gp2,
1503 u64 *boottime, ktime_t *realtime);
1504 u32 iwl_mvm_get_systime(struct iwl_mvm *mvm);
1505
1506 /* Tx / Host Commands */
1507 int __must_check iwl_mvm_send_cmd(struct iwl_mvm *mvm,
1508 struct iwl_host_cmd *cmd);
1509 int __must_check iwl_mvm_send_cmd_pdu(struct iwl_mvm *mvm, u32 id,
1510 u32 flags, u16 len, const void *data);
1511 int __must_check iwl_mvm_send_cmd_status(struct iwl_mvm *mvm,
1512 struct iwl_host_cmd *cmd,
1513 u32 *status);
1514 int __must_check iwl_mvm_send_cmd_pdu_status(struct iwl_mvm *mvm, u32 id,
1515 u16 len, const void *data,
1516 u32 *status);
1517 int iwl_mvm_tx_skb_sta(struct iwl_mvm *mvm, struct sk_buff *skb,
1518 struct ieee80211_sta *sta);
1519 int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb);
1520 void iwl_mvm_set_tx_cmd(struct iwl_mvm *mvm, struct sk_buff *skb,
1521 struct iwl_tx_cmd *tx_cmd,
1522 struct ieee80211_tx_info *info, u8 sta_id);
1523 void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm, struct iwl_tx_cmd *tx_cmd,
1524 struct ieee80211_tx_info *info,
1525 struct ieee80211_sta *sta, __le16 fc);
1526 void iwl_mvm_mac_itxq_xmit(struct ieee80211_hw *hw, struct ieee80211_txq *txq);
1527 unsigned int iwl_mvm_max_amsdu_size(struct iwl_mvm *mvm,
1528 struct ieee80211_sta *sta,
1529 unsigned int tid);
1530 u32 iwl_mvm_tx_csum_bz(struct iwl_mvm *mvm, struct sk_buff *skb, bool amsdu);
1531
1532 #ifdef CONFIG_IWLWIFI_DEBUG
1533 const char *iwl_mvm_get_tx_fail_reason(u32 status);
1534 #else
iwl_mvm_get_tx_fail_reason(u32 status)1535 static inline const char *iwl_mvm_get_tx_fail_reason(u32 status) { return ""; }
1536 #endif
1537 int iwl_mvm_flush_tx_path(struct iwl_mvm *mvm, u32 tfd_msk);
1538 int iwl_mvm_flush_sta(struct iwl_mvm *mvm, void *sta, bool internal);
1539 int iwl_mvm_flush_sta_tids(struct iwl_mvm *mvm, u32 sta_id, u16 tids);
1540
1541 void iwl_mvm_async_handlers_purge(struct iwl_mvm *mvm);
1542
iwl_mvm_set_tx_cmd_ccmp(struct ieee80211_tx_info * info,struct iwl_tx_cmd * tx_cmd)1543 static inline void iwl_mvm_set_tx_cmd_ccmp(struct ieee80211_tx_info *info,
1544 struct iwl_tx_cmd *tx_cmd)
1545 {
1546 struct ieee80211_key_conf *keyconf = info->control.hw_key;
1547
1548 tx_cmd->sec_ctl = TX_CMD_SEC_CCM;
1549 memcpy(tx_cmd->key, keyconf->key, keyconf->keylen);
1550 }
1551
iwl_mvm_wait_for_async_handlers(struct iwl_mvm * mvm)1552 static inline void iwl_mvm_wait_for_async_handlers(struct iwl_mvm *mvm)
1553 {
1554 flush_work(&mvm->async_handlers_wk);
1555 }
1556
1557 /* Statistics */
1558 void iwl_mvm_handle_rx_statistics(struct iwl_mvm *mvm,
1559 struct iwl_rx_packet *pkt);
1560 void iwl_mvm_rx_statistics(struct iwl_mvm *mvm,
1561 struct iwl_rx_cmd_buffer *rxb);
1562 int iwl_mvm_request_statistics(struct iwl_mvm *mvm, bool clear);
1563 void iwl_mvm_accu_radio_stats(struct iwl_mvm *mvm);
1564
1565 /* NVM */
1566 int iwl_nvm_init(struct iwl_mvm *mvm);
1567 int iwl_mvm_load_nvm_to_nic(struct iwl_mvm *mvm);
1568
iwl_mvm_get_valid_tx_ant(struct iwl_mvm * mvm)1569 static inline u8 iwl_mvm_get_valid_tx_ant(struct iwl_mvm *mvm)
1570 {
1571 return mvm->nvm_data && mvm->nvm_data->valid_tx_ant ?
1572 mvm->fw->valid_tx_ant & mvm->nvm_data->valid_tx_ant :
1573 mvm->fw->valid_tx_ant;
1574 }
1575
iwl_mvm_get_valid_rx_ant(struct iwl_mvm * mvm)1576 static inline u8 iwl_mvm_get_valid_rx_ant(struct iwl_mvm *mvm)
1577 {
1578 return mvm->nvm_data && mvm->nvm_data->valid_rx_ant ?
1579 mvm->fw->valid_rx_ant & mvm->nvm_data->valid_rx_ant :
1580 mvm->fw->valid_rx_ant;
1581 }
1582
iwl_mvm_toggle_tx_ant(struct iwl_mvm * mvm,u8 * ant)1583 static inline void iwl_mvm_toggle_tx_ant(struct iwl_mvm *mvm, u8 *ant)
1584 {
1585 *ant = iwl_mvm_next_antenna(mvm, iwl_mvm_get_valid_tx_ant(mvm), *ant);
1586 }
1587
iwl_mvm_get_phy_config(struct iwl_mvm * mvm)1588 static inline u32 iwl_mvm_get_phy_config(struct iwl_mvm *mvm)
1589 {
1590 u32 phy_config = ~(FW_PHY_CFG_TX_CHAIN |
1591 FW_PHY_CFG_RX_CHAIN);
1592 u32 valid_rx_ant = iwl_mvm_get_valid_rx_ant(mvm);
1593 u32 valid_tx_ant = iwl_mvm_get_valid_tx_ant(mvm);
1594
1595 phy_config |= valid_tx_ant << FW_PHY_CFG_TX_CHAIN_POS |
1596 valid_rx_ant << FW_PHY_CFG_RX_CHAIN_POS;
1597
1598 return mvm->fw->phy_config & phy_config;
1599 }
1600
1601 int iwl_mvm_up(struct iwl_mvm *mvm);
1602 int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm);
1603
1604 int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm);
1605 bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm *mvm,
1606 struct iwl_bcast_filter_cmd *cmd);
1607
1608 /*
1609 * FW notifications / CMD responses handlers
1610 * Convention: iwl_mvm_rx_<NAME OF THE CMD>
1611 */
1612 void iwl_mvm_rx_mq(struct iwl_op_mode *op_mode,
1613 struct napi_struct *napi,
1614 struct iwl_rx_cmd_buffer *rxb);
1615 void iwl_mvm_rx_rx_phy_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1616 void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi,
1617 struct iwl_rx_cmd_buffer *rxb);
1618 void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
1619 struct iwl_rx_cmd_buffer *rxb, int queue);
1620 void iwl_mvm_rx_monitor_no_data(struct iwl_mvm *mvm, struct napi_struct *napi,
1621 struct iwl_rx_cmd_buffer *rxb, int queue);
1622 void iwl_mvm_rx_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi,
1623 struct iwl_rx_cmd_buffer *rxb, int queue);
1624 void iwl_mvm_rx_bar_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi,
1625 struct iwl_rx_cmd_buffer *rxb, int queue);
1626 void iwl_mvm_rx_queue_notif(struct iwl_mvm *mvm, struct napi_struct *napi,
1627 struct iwl_rx_cmd_buffer *rxb, int queue);
1628 void iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1629 void iwl_mvm_mfu_assert_dump_notif(struct iwl_mvm *mvm,
1630 struct iwl_rx_cmd_buffer *rxb);
1631 void iwl_mvm_send_recovery_cmd(struct iwl_mvm *mvm, u32 flags);
1632 void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1633 void iwl_mvm_rx_ant_coupling_notif(struct iwl_mvm *mvm,
1634 struct iwl_rx_cmd_buffer *rxb);
1635 void iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1636 void iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm,
1637 struct iwl_rx_cmd_buffer *rxb);
1638 void iwl_mvm_rx_shared_mem_cfg_notif(struct iwl_mvm *mvm,
1639 struct iwl_rx_cmd_buffer *rxb);
1640
1641 /* MVM PHY */
1642 int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
1643 struct cfg80211_chan_def *chandef,
1644 u8 chains_static, u8 chains_dynamic);
1645 int iwl_mvm_phy_ctxt_changed(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
1646 struct cfg80211_chan_def *chandef,
1647 u8 chains_static, u8 chains_dynamic);
1648 void iwl_mvm_phy_ctxt_ref(struct iwl_mvm *mvm,
1649 struct iwl_mvm_phy_ctxt *ctxt);
1650 void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm,
1651 struct iwl_mvm_phy_ctxt *ctxt);
1652 int iwl_mvm_phy_ctx_count(struct iwl_mvm *mvm);
1653 u8 iwl_mvm_get_channel_width(struct cfg80211_chan_def *chandef);
1654 u8 iwl_mvm_get_ctrl_pos(struct cfg80211_chan_def *chandef);
1655
1656 /* MAC (virtual interface) programming */
1657 int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1658 int iwl_mvm_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1659 int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1660 bool force_assoc_off, const u8 *bssid_override);
1661 int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1662 int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
1663 struct ieee80211_vif *vif);
1664 int iwl_mvm_mac_ctxt_send_beacon(struct iwl_mvm *mvm,
1665 struct ieee80211_vif *vif,
1666 struct sk_buff *beacon);
1667 int iwl_mvm_mac_ctxt_send_beacon_cmd(struct iwl_mvm *mvm,
1668 struct sk_buff *beacon,
1669 void *data, int len);
1670 u8 iwl_mvm_mac_ctxt_get_lowest_rate(struct ieee80211_tx_info *info,
1671 struct ieee80211_vif *vif);
1672 u16 iwl_mvm_mac_ctxt_get_beacon_flags(const struct iwl_fw *fw,
1673 u8 rate_idx);
1674 void iwl_mvm_mac_ctxt_set_tim(struct iwl_mvm *mvm,
1675 __le32 *tim_index, __le32 *tim_size,
1676 u8 *beacon, u32 frame_size);
1677 void iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
1678 struct iwl_rx_cmd_buffer *rxb);
1679 void iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm,
1680 struct iwl_rx_cmd_buffer *rxb);
1681 void iwl_mvm_rx_stored_beacon_notif(struct iwl_mvm *mvm,
1682 struct iwl_rx_cmd_buffer *rxb);
1683 void iwl_mvm_mu_mimo_grp_notif(struct iwl_mvm *mvm,
1684 struct iwl_rx_cmd_buffer *rxb);
1685 void iwl_mvm_sta_pm_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1686 void iwl_mvm_window_status_notif(struct iwl_mvm *mvm,
1687 struct iwl_rx_cmd_buffer *rxb);
1688 void iwl_mvm_mac_ctxt_recalc_tsf_id(struct iwl_mvm *mvm,
1689 struct ieee80211_vif *vif);
1690 void iwl_mvm_probe_resp_data_notif(struct iwl_mvm *mvm,
1691 struct iwl_rx_cmd_buffer *rxb);
1692 void iwl_mvm_rx_missed_vap_notif(struct iwl_mvm *mvm,
1693 struct iwl_rx_cmd_buffer *rxb);
1694 void iwl_mvm_channel_switch_start_notif(struct iwl_mvm *mvm,
1695 struct iwl_rx_cmd_buffer *rxb);
1696 void iwl_mvm_channel_switch_error_notif(struct iwl_mvm *mvm,
1697 struct iwl_rx_cmd_buffer *rxb);
1698 /* Bindings */
1699 int iwl_mvm_binding_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1700 int iwl_mvm_binding_remove_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1701
1702 /* Quota management */
iwl_mvm_quota_cmd_size(struct iwl_mvm * mvm)1703 static inline size_t iwl_mvm_quota_cmd_size(struct iwl_mvm *mvm)
1704 {
1705 return iwl_mvm_has_quota_low_latency(mvm) ?
1706 sizeof(struct iwl_time_quota_cmd) :
1707 sizeof(struct iwl_time_quota_cmd_v1);
1708 }
1709
1710 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)1711 *iwl_mvm_quota_cmd_get_quota(struct iwl_mvm *mvm,
1712 struct iwl_time_quota_cmd *cmd,
1713 int i)
1714 {
1715 struct iwl_time_quota_data_v1 *quotas;
1716
1717 if (iwl_mvm_has_quota_low_latency(mvm))
1718 return &cmd->quotas[i];
1719
1720 quotas = (struct iwl_time_quota_data_v1 *)cmd->quotas;
1721 return (struct iwl_time_quota_data *)"as[i];
1722 }
1723
1724 int iwl_mvm_update_quotas(struct iwl_mvm *mvm, bool force_upload,
1725 struct ieee80211_vif *disabled_vif);
1726
1727 /* Scanning */
1728 int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1729 struct cfg80211_scan_request *req,
1730 struct ieee80211_scan_ies *ies);
1731 int iwl_mvm_scan_size(struct iwl_mvm *mvm);
1732 int iwl_mvm_scan_stop(struct iwl_mvm *mvm, int type, bool notify);
1733 int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm);
1734 void iwl_mvm_report_scan_aborted(struct iwl_mvm *mvm);
1735 void iwl_mvm_scan_timeout_wk(struct work_struct *work);
1736
1737 /* Scheduled scan */
1738 void iwl_mvm_rx_lmac_scan_complete_notif(struct iwl_mvm *mvm,
1739 struct iwl_rx_cmd_buffer *rxb);
1740 void iwl_mvm_rx_lmac_scan_iter_complete_notif(struct iwl_mvm *mvm,
1741 struct iwl_rx_cmd_buffer *rxb);
1742 int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
1743 struct ieee80211_vif *vif,
1744 struct cfg80211_sched_scan_request *req,
1745 struct ieee80211_scan_ies *ies,
1746 int type);
1747 void iwl_mvm_rx_scan_match_found(struct iwl_mvm *mvm,
1748 struct iwl_rx_cmd_buffer *rxb);
1749
1750 /* UMAC scan */
1751 int iwl_mvm_config_scan(struct iwl_mvm *mvm);
1752 void iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm,
1753 struct iwl_rx_cmd_buffer *rxb);
1754 void iwl_mvm_rx_umac_scan_iter_complete_notif(struct iwl_mvm *mvm,
1755 struct iwl_rx_cmd_buffer *rxb);
1756
1757 /* MVM debugfs */
1758 #ifdef CONFIG_IWLWIFI_DEBUGFS
1759 void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm);
1760 void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1761 void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1762 #else
iwl_mvm_dbgfs_register(struct iwl_mvm * mvm)1763 static inline void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm)
1764 {
1765 }
1766 static inline void
iwl_mvm_vif_dbgfs_register(struct iwl_mvm * mvm,struct ieee80211_vif * vif)1767 iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1768 {
1769 }
1770 static inline void
iwl_mvm_vif_dbgfs_clean(struct iwl_mvm * mvm,struct ieee80211_vif * vif)1771 iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1772 {
1773 }
1774 #endif /* CONFIG_IWLWIFI_DEBUGFS */
1775
1776 /* rate scaling */
1777 int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq);
1778 void iwl_mvm_update_frame_stats(struct iwl_mvm *mvm, u32 rate, bool agg);
1779 int rs_pretty_print_rate_v1(char *buf, int bufsz, const u32 rate);
1780 void rs_update_last_rssi(struct iwl_mvm *mvm,
1781 struct iwl_mvm_sta *mvmsta,
1782 struct ieee80211_rx_status *rx_status);
1783
1784 /* power management */
1785 int iwl_mvm_power_update_device(struct iwl_mvm *mvm);
1786 int iwl_mvm_power_update_mac(struct iwl_mvm *mvm);
1787 int iwl_mvm_power_update_ps(struct iwl_mvm *mvm);
1788 int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1789 char *buf, int bufsz);
1790
1791 void iwl_mvm_power_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1792 void iwl_mvm_power_uapsd_misbehaving_ap_notif(struct iwl_mvm *mvm,
1793 struct iwl_rx_cmd_buffer *rxb);
1794
1795 #ifdef CONFIG_IWLWIFI_LEDS
1796 int iwl_mvm_leds_init(struct iwl_mvm *mvm);
1797 void iwl_mvm_leds_exit(struct iwl_mvm *mvm);
1798 void iwl_mvm_leds_sync(struct iwl_mvm *mvm);
1799 #else
iwl_mvm_leds_init(struct iwl_mvm * mvm)1800 static inline int iwl_mvm_leds_init(struct iwl_mvm *mvm)
1801 {
1802 return 0;
1803 }
iwl_mvm_leds_exit(struct iwl_mvm * mvm)1804 static inline void iwl_mvm_leds_exit(struct iwl_mvm *mvm)
1805 {
1806 }
iwl_mvm_leds_sync(struct iwl_mvm * mvm)1807 static inline void iwl_mvm_leds_sync(struct iwl_mvm *mvm)
1808 {
1809 }
1810 #endif
1811
1812 /* D3 (WoWLAN, NetDetect) */
1813 int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
1814 int iwl_mvm_resume(struct ieee80211_hw *hw);
1815 void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled);
1816 void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw,
1817 struct ieee80211_vif *vif,
1818 struct cfg80211_gtk_rekey_data *data);
1819 void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw,
1820 struct ieee80211_vif *vif,
1821 struct inet6_dev *idev);
1822 void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw,
1823 struct ieee80211_vif *vif, int idx);
1824 extern const struct file_operations iwl_dbgfs_d3_test_ops;
1825 #ifdef CONFIG_PM
1826 void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm,
1827 struct ieee80211_vif *vif);
1828 #else
1829 static inline void
iwl_mvm_set_last_nonqos_seq(struct iwl_mvm * mvm,struct ieee80211_vif * vif)1830 iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1831 {
1832 }
1833 #endif
1834 void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta,
1835 struct iwl_wowlan_config_cmd *cmd);
1836 int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
1837 struct ieee80211_vif *vif,
1838 bool disable_offloading,
1839 bool offload_ns,
1840 u32 cmd_flags);
1841
1842 /* BT Coex */
1843 int iwl_mvm_send_bt_init_conf(struct iwl_mvm *mvm);
1844 void iwl_mvm_rx_bt_coex_notif(struct iwl_mvm *mvm,
1845 struct iwl_rx_cmd_buffer *rxb);
1846 void iwl_mvm_bt_rssi_event(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1847 enum ieee80211_rssi_event_data);
1848 void iwl_mvm_bt_coex_vif_change(struct iwl_mvm *mvm);
1849 u16 iwl_mvm_coex_agg_time_limit(struct iwl_mvm *mvm,
1850 struct ieee80211_sta *sta);
1851 bool iwl_mvm_bt_coex_is_mimo_allowed(struct iwl_mvm *mvm,
1852 struct ieee80211_sta *sta);
1853 bool iwl_mvm_bt_coex_is_ant_avail(struct iwl_mvm *mvm, u8 ant);
1854 bool iwl_mvm_bt_coex_is_shared_ant_avail(struct iwl_mvm *mvm);
1855 bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm *mvm,
1856 enum nl80211_band band);
1857 u8 iwl_mvm_bt_coex_get_single_ant_msk(struct iwl_mvm *mvm, u8 enabled_ants);
1858 u8 iwl_mvm_bt_coex_tx_prio(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
1859 struct ieee80211_tx_info *info, u8 ac);
1860
1861 /* beacon filtering */
1862 #ifdef CONFIG_IWLWIFI_DEBUGFS
1863 void
1864 iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
1865 struct iwl_beacon_filter_cmd *cmd);
1866 #else
1867 static inline void
iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif * vif,struct iwl_beacon_filter_cmd * cmd)1868 iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
1869 struct iwl_beacon_filter_cmd *cmd)
1870 {}
1871 #endif
1872 int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm,
1873 struct ieee80211_vif *vif,
1874 u32 flags);
1875 int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm,
1876 struct ieee80211_vif *vif,
1877 u32 flags);
1878 /* SMPS */
1879 void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1880 enum iwl_mvm_smps_type_request req_type,
1881 enum ieee80211_smps_mode smps_request);
1882 bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm,
1883 struct iwl_mvm_phy_ctxt *ctxt);
1884 void iwl_mvm_apply_fw_smps_request(struct ieee80211_vif *vif);
1885
1886 /* Low latency */
1887 int iwl_mvm_update_low_latency(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1888 bool low_latency,
1889 enum iwl_mvm_low_latency_cause cause);
1890 /* get SystemLowLatencyMode - only needed for beacon threshold? */
1891 bool iwl_mvm_low_latency(struct iwl_mvm *mvm);
1892 bool iwl_mvm_low_latency_band(struct iwl_mvm *mvm, enum nl80211_band band);
1893 void iwl_mvm_send_low_latency_cmd(struct iwl_mvm *mvm, bool low_latency,
1894 u16 mac_id);
1895
1896 /* get VMACLowLatencyMode */
iwl_mvm_vif_low_latency(struct iwl_mvm_vif * mvmvif)1897 static inline bool iwl_mvm_vif_low_latency(struct iwl_mvm_vif *mvmvif)
1898 {
1899 /*
1900 * should this consider associated/active/... state?
1901 *
1902 * Normally low-latency should only be active on interfaces
1903 * that are active, but at least with debugfs it can also be
1904 * enabled on interfaces that aren't active. However, when
1905 * interface aren't active then they aren't added into the
1906 * binding, so this has no real impact. For now, just return
1907 * the current desired low-latency state.
1908 */
1909 return mvmvif->low_latency_actual;
1910 }
1911
1912 static inline
iwl_mvm_vif_set_low_latency(struct iwl_mvm_vif * mvmvif,bool set,enum iwl_mvm_low_latency_cause cause)1913 void iwl_mvm_vif_set_low_latency(struct iwl_mvm_vif *mvmvif, bool set,
1914 enum iwl_mvm_low_latency_cause cause)
1915 {
1916 u8 new_state;
1917
1918 if (set)
1919 mvmvif->low_latency |= cause;
1920 else
1921 mvmvif->low_latency &= ~cause;
1922
1923 /*
1924 * if LOW_LATENCY_DEBUGFS_FORCE_ENABLE is enabled no changes are
1925 * allowed to actual mode.
1926 */
1927 if (mvmvif->low_latency & LOW_LATENCY_DEBUGFS_FORCE_ENABLE &&
1928 cause != LOW_LATENCY_DEBUGFS_FORCE_ENABLE)
1929 return;
1930
1931 if (cause == LOW_LATENCY_DEBUGFS_FORCE_ENABLE && set)
1932 /*
1933 * We enter force state
1934 */
1935 new_state = !!(mvmvif->low_latency &
1936 LOW_LATENCY_DEBUGFS_FORCE);
1937 else
1938 /*
1939 * Check if any other one set low latency
1940 */
1941 new_state = !!(mvmvif->low_latency &
1942 ~(LOW_LATENCY_DEBUGFS_FORCE_ENABLE |
1943 LOW_LATENCY_DEBUGFS_FORCE));
1944
1945 mvmvif->low_latency_actual = new_state;
1946 }
1947
1948 /* Return a bitmask with all the hw supported queues, except for the
1949 * command queue, which can't be flushed.
1950 */
iwl_mvm_flushable_queues(struct iwl_mvm * mvm)1951 static inline u32 iwl_mvm_flushable_queues(struct iwl_mvm *mvm)
1952 {
1953 return ((BIT(mvm->trans->trans_cfg->base_params->num_of_queues) - 1) &
1954 ~BIT(IWL_MVM_DQA_CMD_QUEUE));
1955 }
1956
1957 void iwl_mvm_stop_device(struct iwl_mvm *mvm);
1958
1959 /* Thermal management and CT-kill */
1960 void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff);
1961 void iwl_mvm_temp_notif(struct iwl_mvm *mvm,
1962 struct iwl_rx_cmd_buffer *rxb);
1963 void iwl_mvm_tt_handler(struct iwl_mvm *mvm);
1964 void iwl_mvm_thermal_initialize(struct iwl_mvm *mvm, u32 min_backoff);
1965 void iwl_mvm_thermal_exit(struct iwl_mvm *mvm);
1966 void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm *mvm, bool state);
1967 int iwl_mvm_get_temp(struct iwl_mvm *mvm, s32 *temp);
1968 void iwl_mvm_ct_kill_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1969 void iwl_mvm_enter_ctkill(struct iwl_mvm *mvm);
1970 int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm);
1971 int iwl_mvm_ctdp_command(struct iwl_mvm *mvm, u32 op, u32 budget);
1972
1973 #if IS_ENABLED(CONFIG_IWLMEI)
1974
1975 /* vendor commands */
1976 void iwl_mvm_vendor_cmds_register(struct iwl_mvm *mvm);
1977
1978 #else
1979
iwl_mvm_vendor_cmds_register(struct iwl_mvm * mvm)1980 static inline void iwl_mvm_vendor_cmds_register(struct iwl_mvm *mvm) {}
1981
1982 #endif
1983
1984 /* Location Aware Regulatory */
1985 struct iwl_mcc_update_resp *
1986 iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2,
1987 enum iwl_mcc_source src_id);
1988 int iwl_mvm_init_mcc(struct iwl_mvm *mvm);
1989 void iwl_mvm_rx_chub_update_mcc(struct iwl_mvm *mvm,
1990 struct iwl_rx_cmd_buffer *rxb);
1991 struct ieee80211_regdomain *iwl_mvm_get_regdomain(struct wiphy *wiphy,
1992 const char *alpha2,
1993 enum iwl_mcc_source src_id,
1994 bool *changed);
1995 struct ieee80211_regdomain *iwl_mvm_get_current_regdomain(struct iwl_mvm *mvm,
1996 bool *changed);
1997 int iwl_mvm_init_fw_regd(struct iwl_mvm *mvm);
1998 void iwl_mvm_update_changed_regdom(struct iwl_mvm *mvm);
1999
2000 /* smart fifo */
2001 int iwl_mvm_sf_update(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2002 bool added_vif);
2003
2004 /* FTM responder */
2005 int iwl_mvm_ftm_start_responder(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2006 void iwl_mvm_ftm_restart_responder(struct iwl_mvm *mvm,
2007 struct ieee80211_vif *vif);
2008 void iwl_mvm_ftm_responder_stats(struct iwl_mvm *mvm,
2009 struct iwl_rx_cmd_buffer *rxb);
2010 int iwl_mvm_ftm_resp_remove_pasn_sta(struct iwl_mvm *mvm,
2011 struct ieee80211_vif *vif, u8 *addr);
2012 int iwl_mvm_ftm_respoder_add_pasn_sta(struct iwl_mvm *mvm,
2013 struct ieee80211_vif *vif,
2014 u8 *addr, u32 cipher, u8 *tk, u32 tk_len,
2015 u8 *hltk, u32 hltk_len);
2016 void iwl_mvm_ftm_responder_clear(struct iwl_mvm *mvm,
2017 struct ieee80211_vif *vif);
2018
2019 /* FTM initiator */
2020 void iwl_mvm_ftm_restart(struct iwl_mvm *mvm);
2021 void iwl_mvm_ftm_range_resp(struct iwl_mvm *mvm,
2022 struct iwl_rx_cmd_buffer *rxb);
2023 void iwl_mvm_ftm_lc_notif(struct iwl_mvm *mvm,
2024 struct iwl_rx_cmd_buffer *rxb);
2025 int iwl_mvm_ftm_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2026 struct cfg80211_pmsr_request *request);
2027 void iwl_mvm_ftm_abort(struct iwl_mvm *mvm, struct cfg80211_pmsr_request *req);
2028 void iwl_mvm_ftm_initiator_smooth_config(struct iwl_mvm *mvm);
2029 void iwl_mvm_ftm_initiator_smooth_stop(struct iwl_mvm *mvm);
2030 int iwl_mvm_ftm_add_pasn_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2031 u8 *addr, u32 cipher, u8 *tk, u32 tk_len,
2032 u8 *hltk, u32 hltk_len);
2033 void iwl_mvm_ftm_remove_pasn_sta(struct iwl_mvm *mvm, u8 *addr);
2034
2035 /* TDLS */
2036
2037 /*
2038 * We use TID 4 (VI) as a FW-used-only TID when TDLS connections are present.
2039 * This TID is marked as used vs the AP and all connected TDLS peers.
2040 */
2041 #define IWL_MVM_TDLS_FW_TID 4
2042
2043 int iwl_mvm_tdls_sta_count(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2044 void iwl_mvm_teardown_tdls_peers(struct iwl_mvm *mvm);
2045 void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2046 bool sta_added);
2047 void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,
2048 struct ieee80211_vif *vif);
2049 int iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw,
2050 struct ieee80211_vif *vif,
2051 struct ieee80211_sta *sta, u8 oper_class,
2052 struct cfg80211_chan_def *chandef,
2053 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie);
2054 void iwl_mvm_tdls_recv_channel_switch(struct ieee80211_hw *hw,
2055 struct ieee80211_vif *vif,
2056 struct ieee80211_tdls_ch_sw_params *params);
2057 void iwl_mvm_tdls_cancel_channel_switch(struct ieee80211_hw *hw,
2058 struct ieee80211_vif *vif,
2059 struct ieee80211_sta *sta);
2060 void iwl_mvm_rx_tdls_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
2061 void iwl_mvm_tdls_ch_switch_work(struct work_struct *work);
2062
2063 void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm,
2064 enum iwl_mvm_rxq_notif_type type,
2065 bool sync,
2066 const void *data, u32 size);
2067 void iwl_mvm_reorder_timer_expired(struct timer_list *t);
2068 struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm);
2069 struct ieee80211_vif *iwl_mvm_get_vif_by_macid(struct iwl_mvm *mvm, u32 macid);
2070 bool iwl_mvm_is_vif_assoc(struct iwl_mvm *mvm);
2071
2072 #define MVM_TCM_PERIOD_MSEC 500
2073 #define MVM_TCM_PERIOD (HZ * MVM_TCM_PERIOD_MSEC / 1000)
2074 #define MVM_LL_PERIOD (10 * HZ)
2075 void iwl_mvm_tcm_work(struct work_struct *work);
2076 void iwl_mvm_recalc_tcm(struct iwl_mvm *mvm);
2077 void iwl_mvm_pause_tcm(struct iwl_mvm *mvm, bool with_cancel);
2078 void iwl_mvm_resume_tcm(struct iwl_mvm *mvm);
2079 void iwl_mvm_tcm_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2080 void iwl_mvm_tcm_rm_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2081 u8 iwl_mvm_tcm_load_percentage(u32 airtime, u32 elapsed);
2082
2083 void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error);
2084 unsigned int iwl_mvm_get_wd_timeout(struct iwl_mvm *mvm,
2085 struct ieee80211_vif *vif,
2086 bool tdls, bool cmd_q);
2087 void iwl_mvm_connection_loss(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2088 const char *errmsg);
2089 void iwl_mvm_event_frame_timeout_callback(struct iwl_mvm *mvm,
2090 struct ieee80211_vif *vif,
2091 const struct ieee80211_sta *sta,
2092 u16 tid);
2093
2094 int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b);
2095 int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm);
2096 int iwl_mvm_ppag_send_cmd(struct iwl_mvm *mvm);
2097 void iwl_mvm_get_acpi_tables(struct iwl_mvm *mvm);
2098 #ifdef CONFIG_IWLWIFI_DEBUGFS
2099 void iwl_mvm_sta_add_debugfs(struct ieee80211_hw *hw,
2100 struct ieee80211_vif *vif,
2101 struct ieee80211_sta *sta,
2102 struct dentry *dir);
2103 #endif
2104
2105 int iwl_rfi_send_config_cmd(struct iwl_mvm *mvm,
2106 struct iwl_rfi_lut_entry *rfi_table);
2107 struct iwl_rfi_freq_table_resp_cmd *iwl_rfi_get_freq_table(struct iwl_mvm *mvm);
2108 void iwl_rfi_deactivate_notif_handler(struct iwl_mvm *mvm,
2109 struct iwl_rx_cmd_buffer *rxb);
2110
iwl_mvm_phy_band_from_nl80211(enum nl80211_band band)2111 static inline u8 iwl_mvm_phy_band_from_nl80211(enum nl80211_band band)
2112 {
2113 switch (band) {
2114 case NL80211_BAND_2GHZ:
2115 return PHY_BAND_24;
2116 case NL80211_BAND_5GHZ:
2117 return PHY_BAND_5;
2118 case NL80211_BAND_6GHZ:
2119 return PHY_BAND_6;
2120 default:
2121 WARN_ONCE(1, "Unsupported band (%u)\n", band);
2122 return PHY_BAND_5;
2123 }
2124 }
2125
2126 /* Channel info utils */
iwl_mvm_has_ultra_hb_channel(struct iwl_mvm * mvm)2127 static inline bool iwl_mvm_has_ultra_hb_channel(struct iwl_mvm *mvm)
2128 {
2129 return fw_has_capa(&mvm->fw->ucode_capa,
2130 IWL_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS);
2131 }
2132
iwl_mvm_chan_info_cmd_tail(struct iwl_mvm * mvm,struct iwl_fw_channel_info * ci)2133 static inline void *iwl_mvm_chan_info_cmd_tail(struct iwl_mvm *mvm,
2134 struct iwl_fw_channel_info *ci)
2135 {
2136 return (u8 *)ci + (iwl_mvm_has_ultra_hb_channel(mvm) ?
2137 sizeof(struct iwl_fw_channel_info) :
2138 sizeof(struct iwl_fw_channel_info_v1));
2139 }
2140
iwl_mvm_chan_info_padding(struct iwl_mvm * mvm)2141 static inline size_t iwl_mvm_chan_info_padding(struct iwl_mvm *mvm)
2142 {
2143 return iwl_mvm_has_ultra_hb_channel(mvm) ? 0 :
2144 sizeof(struct iwl_fw_channel_info) -
2145 sizeof(struct iwl_fw_channel_info_v1);
2146 }
2147
iwl_mvm_set_chan_info(struct iwl_mvm * mvm,struct iwl_fw_channel_info * ci,u32 chan,u8 band,u8 width,u8 ctrl_pos)2148 static inline void iwl_mvm_set_chan_info(struct iwl_mvm *mvm,
2149 struct iwl_fw_channel_info *ci,
2150 u32 chan, u8 band, u8 width,
2151 u8 ctrl_pos)
2152 {
2153 if (iwl_mvm_has_ultra_hb_channel(mvm)) {
2154 ci->channel = cpu_to_le32(chan);
2155 ci->band = band;
2156 ci->width = width;
2157 ci->ctrl_pos = ctrl_pos;
2158 } else {
2159 struct iwl_fw_channel_info_v1 *ci_v1 =
2160 (struct iwl_fw_channel_info_v1 *)ci;
2161
2162 ci_v1->channel = chan;
2163 ci_v1->band = band;
2164 ci_v1->width = width;
2165 ci_v1->ctrl_pos = ctrl_pos;
2166 }
2167 }
2168
2169 static inline void
iwl_mvm_set_chan_info_chandef(struct iwl_mvm * mvm,struct iwl_fw_channel_info * ci,struct cfg80211_chan_def * chandef)2170 iwl_mvm_set_chan_info_chandef(struct iwl_mvm *mvm,
2171 struct iwl_fw_channel_info *ci,
2172 struct cfg80211_chan_def *chandef)
2173 {
2174 enum nl80211_band band = chandef->chan->band;
2175
2176 iwl_mvm_set_chan_info(mvm, ci, chandef->chan->hw_value,
2177 iwl_mvm_phy_band_from_nl80211(band),
2178 iwl_mvm_get_channel_width(chandef),
2179 iwl_mvm_get_ctrl_pos(chandef));
2180 }
2181
iwl_umac_scan_get_max_profiles(const struct iwl_fw * fw)2182 static inline int iwl_umac_scan_get_max_profiles(const struct iwl_fw *fw)
2183 {
2184 u8 ver = iwl_fw_lookup_cmd_ver(fw, SCAN_OFFLOAD_UPDATE_PROFILES_CMD,
2185 IWL_FW_CMD_VER_UNKNOWN);
2186 return (ver == IWL_FW_CMD_VER_UNKNOWN || ver < 3) ?
2187 IWL_SCAN_MAX_PROFILES : IWL_SCAN_MAX_PROFILES_V2;
2188 }
2189
2190 static inline
iwl_mvm_cipher_to_location_cipher(u32 cipher)2191 enum iwl_location_cipher iwl_mvm_cipher_to_location_cipher(u32 cipher)
2192 {
2193 switch (cipher) {
2194 case WLAN_CIPHER_SUITE_CCMP:
2195 return IWL_LOCATION_CIPHER_CCMP_128;
2196 case WLAN_CIPHER_SUITE_GCMP:
2197 return IWL_LOCATION_CIPHER_GCMP_128;
2198 case WLAN_CIPHER_SUITE_GCMP_256:
2199 return IWL_LOCATION_CIPHER_GCMP_256;
2200 default:
2201 return IWL_LOCATION_CIPHER_INVALID;
2202 }
2203 }
2204
2205 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)2206 static inline int iwl_mvm_mei_get_ownership(struct iwl_mvm *mvm)
2207 {
2208 if (mvm->mei_registered)
2209 return iwl_mei_get_ownership();
2210 return 0;
2211 }
2212
iwl_mvm_mei_tx_copy_to_csme(struct iwl_mvm * mvm,struct sk_buff * skb,unsigned int ivlen)2213 static inline void iwl_mvm_mei_tx_copy_to_csme(struct iwl_mvm *mvm,
2214 struct sk_buff *skb,
2215 unsigned int ivlen)
2216 {
2217 if (mvm->mei_registered)
2218 iwl_mei_tx_copy_to_csme(skb, ivlen);
2219 }
2220
iwl_mvm_mei_host_disassociated(struct iwl_mvm * mvm)2221 static inline void iwl_mvm_mei_host_disassociated(struct iwl_mvm *mvm)
2222 {
2223 if (mvm->mei_registered)
2224 iwl_mei_host_disassociated();
2225 }
2226
iwl_mvm_mei_device_down(struct iwl_mvm * mvm)2227 static inline void iwl_mvm_mei_device_down(struct iwl_mvm *mvm)
2228 {
2229 if (mvm->mei_registered)
2230 iwl_mei_device_down();
2231 }
2232
iwl_mvm_mei_set_sw_rfkill_state(struct iwl_mvm * mvm)2233 static inline void iwl_mvm_mei_set_sw_rfkill_state(struct iwl_mvm *mvm)
2234 {
2235 bool sw_rfkill =
2236 mvm->hw_registered ? rfkill_blocked(mvm->hw->wiphy->rfkill) : false;
2237
2238 if (mvm->mei_registered)
2239 iwl_mei_set_rfkill_state(iwl_mvm_is_radio_killed(mvm),
2240 sw_rfkill);
2241 }
2242
2243 void iwl_mvm_send_roaming_forbidden_event(struct iwl_mvm *mvm,
2244 struct ieee80211_vif *vif,
2245 bool forbidden);
2246
2247 #endif /* __IWL_MVM_H__ */
2248