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