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