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