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