xref: /freebsd/sys/contrib/dev/iwlwifi/mvm/mvm.h (revision a4128aad8503277614f2d214011ef60a19447b83)
1bfcc09ddSBjoern A. Zeeb /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2bfcc09ddSBjoern A. Zeeb /*
3*a4128aadSBjoern A. Zeeb  * Copyright (C) 2012-2014, 2018-2024 Intel Corporation
4bfcc09ddSBjoern A. Zeeb  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5bfcc09ddSBjoern A. Zeeb  * Copyright (C) 2016-2017 Intel Deutschland GmbH
6bfcc09ddSBjoern A. Zeeb  */
7bfcc09ddSBjoern A. Zeeb #ifndef __IWL_MVM_H__
8bfcc09ddSBjoern A. Zeeb #define __IWL_MVM_H__
9bfcc09ddSBjoern A. Zeeb 
10bfcc09ddSBjoern A. Zeeb #include <linux/list.h>
11bfcc09ddSBjoern A. Zeeb #include <linux/spinlock.h>
12*a4128aadSBjoern A. Zeeb #include <linux/cleanup.h>
13bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_IWLWIFI_LEDS
14bfcc09ddSBjoern A. Zeeb #include <linux/leds.h>
15bfcc09ddSBjoern A. Zeeb #endif
16bfcc09ddSBjoern A. Zeeb #include <linux/in6.h>
17bfcc09ddSBjoern A. Zeeb 
18bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_THERMAL
19bfcc09ddSBjoern A. Zeeb #include <linux/thermal.h>
20bfcc09ddSBjoern A. Zeeb #endif
21bfcc09ddSBjoern A. Zeeb 
229af1bba4SBjoern A. Zeeb #include <linux/ptp_clock_kernel.h>
239af1bba4SBjoern A. Zeeb 
24bfcc09ddSBjoern A. Zeeb #include <linux/ktime.h>
25bfcc09ddSBjoern A. Zeeb 
26bfcc09ddSBjoern A. Zeeb #include "iwl-op-mode.h"
27bfcc09ddSBjoern A. Zeeb #include "iwl-trans.h"
28bfcc09ddSBjoern A. Zeeb #include "fw/notif-wait.h"
29*a4128aadSBjoern A. Zeeb #include "iwl-nvm-utils.h"
30bfcc09ddSBjoern A. Zeeb #include "fw/file.h"
31bfcc09ddSBjoern A. Zeeb #include "iwl-config.h"
32bfcc09ddSBjoern A. Zeeb #include "sta.h"
33bfcc09ddSBjoern A. Zeeb #include "fw-api.h"
34bfcc09ddSBjoern A. Zeeb #include "constants.h"
35bfcc09ddSBjoern A. Zeeb #include "fw/runtime.h"
36bfcc09ddSBjoern A. Zeeb #include "fw/dbg.h"
37bfcc09ddSBjoern A. Zeeb #include "fw/acpi.h"
38d9836fb4SBjoern A. Zeeb #include "mei/iwl-mei.h"
39bfcc09ddSBjoern A. Zeeb #include "iwl-nvm-parse.h"
40bfcc09ddSBjoern A. Zeeb 
41bfcc09ddSBjoern A. Zeeb #include <linux/average.h>
42bfcc09ddSBjoern A. Zeeb #if defined(__FreeBSD__)
43bfcc09ddSBjoern A. Zeeb #include <net/if_inet6.h>
44bfcc09ddSBjoern A. Zeeb #endif
45bfcc09ddSBjoern A. Zeeb 
46bfcc09ddSBjoern A. Zeeb #define IWL_MVM_MAX_ADDRESSES		5
47bfcc09ddSBjoern A. Zeeb /* RSSI offset for WkP */
48bfcc09ddSBjoern A. Zeeb #define IWL_RSSI_OFFSET 50
49*a4128aadSBjoern A. Zeeb #define IWL_MVM_MISSED_BEACONS_SINCE_RX_THOLD 4
50bfcc09ddSBjoern A. Zeeb #define IWL_MVM_MISSED_BEACONS_THRESHOLD 8
51*a4128aadSBjoern A. Zeeb #define IWL_MVM_MISSED_BEACONS_THRESHOLD_LONG 19
52bfcc09ddSBjoern A. Zeeb 
53bfcc09ddSBjoern A. Zeeb /* A TimeUnit is 1024 microsecond */
54bfcc09ddSBjoern A. Zeeb #define MSEC_TO_TU(_msec)	(_msec*1000/1024)
55bfcc09ddSBjoern A. Zeeb 
56bfcc09ddSBjoern A. Zeeb /* For GO, this value represents the number of TUs before CSA "beacon
57bfcc09ddSBjoern A. Zeeb  * 0" TBTT when the CSA time-event needs to be scheduled to start.  It
58bfcc09ddSBjoern A. Zeeb  * must be big enough to ensure that we switch in time.
59bfcc09ddSBjoern A. Zeeb  */
60bfcc09ddSBjoern A. Zeeb #define IWL_MVM_CHANNEL_SWITCH_TIME_GO		40
61bfcc09ddSBjoern A. Zeeb 
62bfcc09ddSBjoern A. Zeeb /* For client, this value represents the number of TUs before CSA
63bfcc09ddSBjoern A. Zeeb  * "beacon 1" TBTT, instead.  This is because we don't know when the
64bfcc09ddSBjoern A. Zeeb  * GO/AP will be in the new channel, so we switch early enough.
65bfcc09ddSBjoern A. Zeeb  */
66bfcc09ddSBjoern A. Zeeb #define IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT	10
67bfcc09ddSBjoern A. Zeeb 
68bfcc09ddSBjoern A. Zeeb /*
69bfcc09ddSBjoern A. Zeeb  * This value (in TUs) is used to fine tune the CSA NoA end time which should
70bfcc09ddSBjoern A. Zeeb  * be just before "beacon 0" TBTT.
71bfcc09ddSBjoern A. Zeeb  */
72bfcc09ddSBjoern A. Zeeb #define IWL_MVM_CHANNEL_SWITCH_MARGIN 4
73bfcc09ddSBjoern A. Zeeb 
74bfcc09ddSBjoern A. Zeeb /*
75bfcc09ddSBjoern A. Zeeb  * Number of beacons to transmit on a new channel until we unblock tx to
76bfcc09ddSBjoern A. Zeeb  * the stations, even if we didn't identify them on a new channel
77bfcc09ddSBjoern A. Zeeb  */
78bfcc09ddSBjoern A. Zeeb #define IWL_MVM_CS_UNBLOCK_TX_TIMEOUT 3
79bfcc09ddSBjoern A. Zeeb 
80bfcc09ddSBjoern A. Zeeb /* offchannel queue towards mac80211 */
81bfcc09ddSBjoern A. Zeeb #define IWL_MVM_OFFCHANNEL_QUEUE 0
82bfcc09ddSBjoern A. Zeeb 
839af1bba4SBjoern A. Zeeb /* invalid value for FW link id */
849af1bba4SBjoern A. Zeeb #define IWL_MVM_FW_LINK_ID_INVALID 0xff
859af1bba4SBjoern A. Zeeb 
86bfcc09ddSBjoern A. Zeeb extern const struct ieee80211_ops iwl_mvm_hw_ops;
879af1bba4SBjoern A. Zeeb extern const struct ieee80211_ops iwl_mvm_mld_hw_ops;
88bfcc09ddSBjoern A. Zeeb 
89bfcc09ddSBjoern A. Zeeb /**
90bfcc09ddSBjoern A. Zeeb  * struct iwl_mvm_mod_params - module parameters for iwlmvm
91bfcc09ddSBjoern A. Zeeb  * @power_scheme: one of enum iwl_power_scheme
92bfcc09ddSBjoern A. Zeeb  */
93bfcc09ddSBjoern A. Zeeb struct iwl_mvm_mod_params {
94bfcc09ddSBjoern A. Zeeb 	int power_scheme;
95bfcc09ddSBjoern A. Zeeb };
96bfcc09ddSBjoern A. Zeeb extern struct iwl_mvm_mod_params iwlmvm_mod_params;
97bfcc09ddSBjoern A. Zeeb 
98bfcc09ddSBjoern A. Zeeb struct iwl_mvm_phy_ctxt {
99bfcc09ddSBjoern A. Zeeb 	u16 id;
100bfcc09ddSBjoern A. Zeeb 	u16 color;
101bfcc09ddSBjoern A. Zeeb 	u32 ref;
102bfcc09ddSBjoern A. Zeeb 
103bfcc09ddSBjoern A. Zeeb 	enum nl80211_chan_width width;
104bfcc09ddSBjoern A. Zeeb 
105bfcc09ddSBjoern A. Zeeb 	struct ieee80211_channel *channel;
106d9836fb4SBjoern A. Zeeb 
107d9836fb4SBjoern A. Zeeb 	/* track for RLC config command */
108d9836fb4SBjoern A. Zeeb 	u32 center_freq1;
1099af1bba4SBjoern A. Zeeb 	bool rlc_disabled;
110*a4128aadSBjoern A. Zeeb 	u32 channel_load_by_us;
111bfcc09ddSBjoern A. Zeeb };
112bfcc09ddSBjoern A. Zeeb 
113bfcc09ddSBjoern A. Zeeb struct iwl_mvm_time_event_data {
114bfcc09ddSBjoern A. Zeeb 	struct ieee80211_vif *vif;
115bfcc09ddSBjoern A. Zeeb 	struct list_head list;
116bfcc09ddSBjoern A. Zeeb 	unsigned long end_jiffies;
117bfcc09ddSBjoern A. Zeeb 	u32 duration;
118bfcc09ddSBjoern A. Zeeb 	bool running;
119bfcc09ddSBjoern A. Zeeb 	u32 uid;
120bfcc09ddSBjoern A. Zeeb 
121bfcc09ddSBjoern A. Zeeb 	/*
122bfcc09ddSBjoern A. Zeeb 	 * The access to the 'id' field must be done when the
123bfcc09ddSBjoern A. Zeeb 	 * mvm->time_event_lock is held, as it value is used to indicate
124bfcc09ddSBjoern A. Zeeb 	 * if the te is in the time event list or not (when id == TE_MAX)
125bfcc09ddSBjoern A. Zeeb 	 */
126bfcc09ddSBjoern A. Zeeb 	u32 id;
127*a4128aadSBjoern A. Zeeb 	s8 link_id;
128bfcc09ddSBjoern A. Zeeb };
129bfcc09ddSBjoern A. Zeeb 
130bfcc09ddSBjoern A. Zeeb  /* Power management */
131bfcc09ddSBjoern A. Zeeb 
132bfcc09ddSBjoern A. Zeeb /**
133bfcc09ddSBjoern A. Zeeb  * enum iwl_power_scheme
134*a4128aadSBjoern A. Zeeb  * @IWL_POWER_SCHEME_CAM: Continuously Active Mode
135*a4128aadSBjoern A. Zeeb  * @IWL_POWER_SCHEME_BPS: Balanced Power Save (default)
136*a4128aadSBjoern A. Zeeb  * @IWL_POWER_SCHEME_LP: Low Power
137bfcc09ddSBjoern A. Zeeb  */
138bfcc09ddSBjoern A. Zeeb enum iwl_power_scheme {
139bfcc09ddSBjoern A. Zeeb 	IWL_POWER_SCHEME_CAM = 1,
140bfcc09ddSBjoern A. Zeeb 	IWL_POWER_SCHEME_BPS,
141bfcc09ddSBjoern A. Zeeb 	IWL_POWER_SCHEME_LP
142bfcc09ddSBjoern A. Zeeb };
143bfcc09ddSBjoern A. Zeeb 
144bfcc09ddSBjoern A. Zeeb #define IWL_UAPSD_MAX_SP		IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
145bfcc09ddSBjoern A. Zeeb 
146bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_IWLWIFI_DEBUGFS
147bfcc09ddSBjoern A. Zeeb enum iwl_dbgfs_pm_mask {
148bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_PM_KEEP_ALIVE = BIT(0),
149bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_PM_SKIP_OVER_DTIM = BIT(1),
150bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS = BIT(2),
151bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_PM_RX_DATA_TIMEOUT = BIT(3),
152bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_PM_TX_DATA_TIMEOUT = BIT(4),
153bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_PM_LPRX_ENA = BIT(6),
154bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD = BIT(7),
155bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_PM_SNOOZE_ENABLE = BIT(8),
156bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_PM_UAPSD_MISBEHAVING = BIT(9),
157bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_PM_USE_PS_POLL = BIT(10),
158bfcc09ddSBjoern A. Zeeb };
159bfcc09ddSBjoern A. Zeeb 
160bfcc09ddSBjoern A. Zeeb struct iwl_dbgfs_pm {
161bfcc09ddSBjoern A. Zeeb 	u16 keep_alive_seconds;
162bfcc09ddSBjoern A. Zeeb 	u32 rx_data_timeout;
163bfcc09ddSBjoern A. Zeeb 	u32 tx_data_timeout;
164bfcc09ddSBjoern A. Zeeb 	bool skip_over_dtim;
165bfcc09ddSBjoern A. Zeeb 	u8 skip_dtim_periods;
166bfcc09ddSBjoern A. Zeeb 	bool lprx_ena;
167bfcc09ddSBjoern A. Zeeb 	u32 lprx_rssi_threshold;
168bfcc09ddSBjoern A. Zeeb 	bool snooze_ena;
169bfcc09ddSBjoern A. Zeeb 	bool uapsd_misbehaving;
170bfcc09ddSBjoern A. Zeeb 	bool use_ps_poll;
171bfcc09ddSBjoern A. Zeeb 	int mask;
172bfcc09ddSBjoern A. Zeeb };
173bfcc09ddSBjoern A. Zeeb 
174bfcc09ddSBjoern A. Zeeb /* beacon filtering */
175bfcc09ddSBjoern A. Zeeb 
176bfcc09ddSBjoern A. Zeeb enum iwl_dbgfs_bf_mask {
177bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_BF_ENERGY_DELTA = BIT(0),
178bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA = BIT(1),
179bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_BF_ROAMING_STATE = BIT(2),
180bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_BF_TEMP_THRESHOLD = BIT(3),
181bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_BF_TEMP_FAST_FILTER = BIT(4),
182bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_BF_TEMP_SLOW_FILTER = BIT(5),
183bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER = BIT(6),
184bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_BF_DEBUG_FLAG = BIT(7),
185bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_BF_ESCAPE_TIMER = BIT(8),
186bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_BA_ESCAPE_TIMER = BIT(9),
187bfcc09ddSBjoern A. Zeeb 	MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT = BIT(10),
188bfcc09ddSBjoern A. Zeeb };
189bfcc09ddSBjoern A. Zeeb 
190bfcc09ddSBjoern A. Zeeb struct iwl_dbgfs_bf {
191bfcc09ddSBjoern A. Zeeb 	u32 bf_energy_delta;
192bfcc09ddSBjoern A. Zeeb 	u32 bf_roaming_energy_delta;
193bfcc09ddSBjoern A. Zeeb 	u32 bf_roaming_state;
194bfcc09ddSBjoern A. Zeeb 	u32 bf_temp_threshold;
195bfcc09ddSBjoern A. Zeeb 	u32 bf_temp_fast_filter;
196bfcc09ddSBjoern A. Zeeb 	u32 bf_temp_slow_filter;
197bfcc09ddSBjoern A. Zeeb 	u32 bf_enable_beacon_filter;
198bfcc09ddSBjoern A. Zeeb 	u32 bf_debug_flag;
199bfcc09ddSBjoern A. Zeeb 	u32 bf_escape_timer;
200bfcc09ddSBjoern A. Zeeb 	u32 ba_escape_timer;
201bfcc09ddSBjoern A. Zeeb 	u32 ba_enable_beacon_abort;
202bfcc09ddSBjoern A. Zeeb 	int mask;
203bfcc09ddSBjoern A. Zeeb };
204bfcc09ddSBjoern A. Zeeb #endif
205bfcc09ddSBjoern A. Zeeb 
206bfcc09ddSBjoern A. Zeeb enum iwl_mvm_smps_type_request {
207bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SMPS_REQ_BT_COEX,
208bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SMPS_REQ_TT,
209bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SMPS_REQ_PROT,
210bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SMPS_REQ_FW,
211bfcc09ddSBjoern A. Zeeb 	NUM_IWL_MVM_SMPS_REQ,
212bfcc09ddSBjoern A. Zeeb };
213bfcc09ddSBjoern A. Zeeb 
214bfcc09ddSBjoern A. Zeeb enum iwl_bt_force_ant_mode {
215bfcc09ddSBjoern A. Zeeb 	BT_FORCE_ANT_DIS = 0,
216bfcc09ddSBjoern A. Zeeb 	BT_FORCE_ANT_AUTO,
217bfcc09ddSBjoern A. Zeeb 	BT_FORCE_ANT_BT,
218bfcc09ddSBjoern A. Zeeb 	BT_FORCE_ANT_WIFI,
219bfcc09ddSBjoern A. Zeeb 
220bfcc09ddSBjoern A. Zeeb 	BT_FORCE_ANT_MAX,
221bfcc09ddSBjoern A. Zeeb };
222bfcc09ddSBjoern A. Zeeb 
223bfcc09ddSBjoern A. Zeeb /**
224*a4128aadSBjoern A. Zeeb  * enum iwl_mvm_low_latency_force - low latency force mode set by debugfs
225bfcc09ddSBjoern A. Zeeb  * @LOW_LATENCY_FORCE_UNSET: unset force mode
226bfcc09ddSBjoern A. Zeeb  * @LOW_LATENCY_FORCE_ON: for low latency on
227bfcc09ddSBjoern A. Zeeb  * @LOW_LATENCY_FORCE_OFF: for low latency off
228bfcc09ddSBjoern A. Zeeb  * @NUM_LOW_LATENCY_FORCE: max num of modes
229bfcc09ddSBjoern A. Zeeb  */
230bfcc09ddSBjoern A. Zeeb enum iwl_mvm_low_latency_force {
231bfcc09ddSBjoern A. Zeeb 	LOW_LATENCY_FORCE_UNSET,
232bfcc09ddSBjoern A. Zeeb 	LOW_LATENCY_FORCE_ON,
233bfcc09ddSBjoern A. Zeeb 	LOW_LATENCY_FORCE_OFF,
234bfcc09ddSBjoern A. Zeeb 	NUM_LOW_LATENCY_FORCE
235bfcc09ddSBjoern A. Zeeb };
236bfcc09ddSBjoern A. Zeeb 
237bfcc09ddSBjoern A. Zeeb /**
238*a4128aadSBjoern A. Zeeb * enum iwl_mvm_low_latency_cause - low latency set causes
239bfcc09ddSBjoern A. Zeeb * @LOW_LATENCY_TRAFFIC: indicates low latency traffic was detected
240bfcc09ddSBjoern A. Zeeb * @LOW_LATENCY_DEBUGFS: low latency mode set from debugfs
241bfcc09ddSBjoern A. Zeeb * @LOW_LATENCY_VCMD: low latency mode set from vendor command
242bfcc09ddSBjoern A. Zeeb * @LOW_LATENCY_VIF_TYPE: low latency mode set because of vif type (ap)
243bfcc09ddSBjoern A. Zeeb * @LOW_LATENCY_DEBUGFS_FORCE_ENABLE: indicate that force mode is enabled
244bfcc09ddSBjoern A. Zeeb *	the actual set/unset is done with LOW_LATENCY_DEBUGFS_FORCE
245bfcc09ddSBjoern A. Zeeb * @LOW_LATENCY_DEBUGFS_FORCE: low latency force mode from debugfs
246bfcc09ddSBjoern A. Zeeb *	set this with LOW_LATENCY_DEBUGFS_FORCE_ENABLE flag
247bfcc09ddSBjoern A. Zeeb *	in low_latency.
248bfcc09ddSBjoern A. Zeeb */
249bfcc09ddSBjoern A. Zeeb enum iwl_mvm_low_latency_cause {
250bfcc09ddSBjoern A. Zeeb 	LOW_LATENCY_TRAFFIC = BIT(0),
251bfcc09ddSBjoern A. Zeeb 	LOW_LATENCY_DEBUGFS = BIT(1),
252bfcc09ddSBjoern A. Zeeb 	LOW_LATENCY_VCMD = BIT(2),
253bfcc09ddSBjoern A. Zeeb 	LOW_LATENCY_VIF_TYPE = BIT(3),
254bfcc09ddSBjoern A. Zeeb 	LOW_LATENCY_DEBUGFS_FORCE_ENABLE = BIT(4),
255bfcc09ddSBjoern A. Zeeb 	LOW_LATENCY_DEBUGFS_FORCE = BIT(5),
256bfcc09ddSBjoern A. Zeeb };
257bfcc09ddSBjoern A. Zeeb 
258bfcc09ddSBjoern A. Zeeb /**
259*a4128aadSBjoern A. Zeeb * struct iwl_mvm_link_bf_data - beacon filtering related data
260bfcc09ddSBjoern A. Zeeb * @ave_beacon_signal: average beacon signal
261bfcc09ddSBjoern A. Zeeb * @last_cqm_event: rssi of the last cqm event
262bfcc09ddSBjoern A. Zeeb * @bt_coex_min_thold: minimum threshold for BT coex
263bfcc09ddSBjoern A. Zeeb * @bt_coex_max_thold: maximum threshold for BT coex
264bfcc09ddSBjoern A. Zeeb * @last_bt_coex_event: rssi of the last BT coex event
265bfcc09ddSBjoern A. Zeeb */
266*a4128aadSBjoern A. Zeeb struct iwl_mvm_link_bf_data {
267bfcc09ddSBjoern A. Zeeb 	int ave_beacon_signal;
268bfcc09ddSBjoern A. Zeeb 	int last_cqm_event;
269bfcc09ddSBjoern A. Zeeb 	int bt_coex_min_thold;
270bfcc09ddSBjoern A. Zeeb 	int bt_coex_max_thold;
271bfcc09ddSBjoern A. Zeeb 	int last_bt_coex_event;
272bfcc09ddSBjoern A. Zeeb };
273bfcc09ddSBjoern A. Zeeb 
274bfcc09ddSBjoern A. Zeeb /**
275bfcc09ddSBjoern A. Zeeb  * struct iwl_probe_resp_data - data for NoA/CSA updates
276bfcc09ddSBjoern A. Zeeb  * @rcu_head: used for freeing the data on update
277bfcc09ddSBjoern A. Zeeb  * @notif: notification data
278bfcc09ddSBjoern A. Zeeb  * @noa_len: length of NoA attribute, calculated from the notification
279bfcc09ddSBjoern A. Zeeb  */
280bfcc09ddSBjoern A. Zeeb struct iwl_probe_resp_data {
281bfcc09ddSBjoern A. Zeeb 	struct rcu_head rcu_head;
282bfcc09ddSBjoern A. Zeeb 	struct iwl_probe_resp_data_notif notif;
283bfcc09ddSBjoern A. Zeeb 	int noa_len;
284bfcc09ddSBjoern A. Zeeb };
285bfcc09ddSBjoern A. Zeeb 
286bfcc09ddSBjoern A. Zeeb /**
2879af1bba4SBjoern A. Zeeb  * struct iwl_mvm_vif_link_info - per link data in Virtual Interface
2889af1bba4SBjoern A. Zeeb  * @ap_sta_id: the sta_id of the AP - valid only if VIF type is STA
2899af1bba4SBjoern A. Zeeb  * @fw_link_id: the id of the link according to the FW API
2909af1bba4SBjoern A. Zeeb  * @bssid: BSSID for this (client) interface
2919af1bba4SBjoern A. Zeeb  * @bcast_sta: station used for broadcast packets. Used by the following
2929af1bba4SBjoern A. Zeeb  *	vifs: P2P_DEVICE, GO and AP.
2939af1bba4SBjoern A. Zeeb  * @beacon_stats: beacon statistics, containing the # of received beacons,
2949af1bba4SBjoern A. Zeeb  *	# of received beacons accumulated over FW restart, and the current
2959af1bba4SBjoern A. Zeeb  *	average signal of beacons retrieved from the firmware
2969af1bba4SBjoern A. Zeeb  * @smps_requests: the SMPS requests of different parts of the driver,
2979af1bba4SBjoern A. Zeeb  *	combined on update to yield the overall request to mac80211.
2989af1bba4SBjoern A. Zeeb  * @probe_resp_data: data from FW notification to store NOA and CSA related
2999af1bba4SBjoern A. Zeeb  *	data to be inserted into probe response.
3009af1bba4SBjoern A. Zeeb  * @he_ru_2mhz_block: 26-tone RU OFDMA transmissions should be blocked
3019af1bba4SBjoern A. Zeeb  * @queue_params: QoS params for this MAC
3029af1bba4SBjoern A. Zeeb  * @mgmt_queue: queue number for unbufferable management frames
3039af1bba4SBjoern A. Zeeb  * @igtk: the current IGTK programmed into the firmware
304*a4128aadSBjoern A. Zeeb  * @active: indicates the link is active in FW (for sanity checking)
305*a4128aadSBjoern A. Zeeb  * @cab_queue: content-after-beacon (multicast) queue
3069af1bba4SBjoern A. Zeeb  * @listen_lmac: indicates this link is allocated to the listen LMAC
307*a4128aadSBjoern A. Zeeb  * @mcast_sta: multicast station
308*a4128aadSBjoern A. Zeeb  * @phy_ctxt: phy context allocated to this link, if any
309*a4128aadSBjoern A. Zeeb  * @bf_data: beacon filtering data
3109af1bba4SBjoern A. Zeeb  */
3119af1bba4SBjoern A. Zeeb struct iwl_mvm_vif_link_info {
3129af1bba4SBjoern A. Zeeb 	u8 bssid[ETH_ALEN];
3139af1bba4SBjoern A. Zeeb 	u8 ap_sta_id;
3149af1bba4SBjoern A. Zeeb 	u8 fw_link_id;
3159af1bba4SBjoern A. Zeeb 
3169af1bba4SBjoern A. Zeeb 	struct iwl_mvm_int_sta bcast_sta;
3179af1bba4SBjoern A. Zeeb 	struct iwl_mvm_int_sta mcast_sta;
3189af1bba4SBjoern A. Zeeb 
3199af1bba4SBjoern A. Zeeb 	struct {
3209af1bba4SBjoern A. Zeeb 		u32 num_beacons, accu_num_beacons;
3219af1bba4SBjoern A. Zeeb 		u8 avg_signal;
3229af1bba4SBjoern A. Zeeb 	} beacon_stats;
3239af1bba4SBjoern A. Zeeb 
3249af1bba4SBjoern A. Zeeb 	enum ieee80211_smps_mode smps_requests[NUM_IWL_MVM_SMPS_REQ];
3259af1bba4SBjoern A. Zeeb 	struct iwl_probe_resp_data __rcu *probe_resp_data;
3269af1bba4SBjoern A. Zeeb 
3279af1bba4SBjoern A. Zeeb 	struct ieee80211_key_conf *igtk;
3289af1bba4SBjoern A. Zeeb 
3299af1bba4SBjoern A. Zeeb 	bool he_ru_2mhz_block;
3309af1bba4SBjoern A. Zeeb 	bool active;
3319af1bba4SBjoern A. Zeeb 	bool listen_lmac;
3329af1bba4SBjoern A. Zeeb 
3339af1bba4SBjoern A. Zeeb 	u16 cab_queue;
3349af1bba4SBjoern A. Zeeb 	/* Assigned while mac80211 has the link in a channel context,
3359af1bba4SBjoern A. Zeeb 	 * or, for P2P Device, while it exists.
3369af1bba4SBjoern A. Zeeb 	 */
3379af1bba4SBjoern A. Zeeb 	struct iwl_mvm_phy_ctxt *phy_ctxt;
3389af1bba4SBjoern A. Zeeb 	/* QoS data from mac80211, need to store this here
3399af1bba4SBjoern A. Zeeb 	 * as mac80211 has a separate callback but we need
3409af1bba4SBjoern A. Zeeb 	 * to have the data for the MAC context
3419af1bba4SBjoern A. Zeeb 	 */
3429af1bba4SBjoern A. Zeeb 	struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
3439af1bba4SBjoern A. Zeeb 
3449af1bba4SBjoern A. Zeeb 	u16 mgmt_queue;
345*a4128aadSBjoern A. Zeeb 
346*a4128aadSBjoern A. Zeeb 	struct iwl_mvm_link_bf_data bf_data;
347*a4128aadSBjoern A. Zeeb };
348*a4128aadSBjoern A. Zeeb 
349*a4128aadSBjoern A. Zeeb /**
350*a4128aadSBjoern A. Zeeb  * enum iwl_mvm_esr_state - defines reasons for which the EMLSR is exited or
351*a4128aadSBjoern A. Zeeb  * blocked.
352*a4128aadSBjoern A. Zeeb  * The low 16 bits are used for blocking reasons, and the 16 higher bits
353*a4128aadSBjoern A. Zeeb  * are used for exit reasons.
354*a4128aadSBjoern A. Zeeb  * For the blocking reasons - use iwl_mvm_(un)block_esr(), and for the exit
355*a4128aadSBjoern A. Zeeb  * reasons - use iwl_mvm_exit_esr().
356*a4128aadSBjoern A. Zeeb  *
357*a4128aadSBjoern A. Zeeb  * Note: new reasons shall be added to HANDLE_ESR_REASONS as well (for logs)
358*a4128aadSBjoern A. Zeeb  *
359*a4128aadSBjoern A. Zeeb  * @IWL_MVM_ESR_BLOCKED_PREVENTION: Prevent EMLSR to avoid entering and exiting
360*a4128aadSBjoern A. Zeeb  *	in a loop.
361*a4128aadSBjoern A. Zeeb  * @IWL_MVM_ESR_BLOCKED_WOWLAN: WOWLAN is preventing the enablement of EMLSR
362*a4128aadSBjoern A. Zeeb  * @IWL_MVM_ESR_BLOCKED_TPT: block EMLSR when there is not enough traffic
363*a4128aadSBjoern A. Zeeb  * @IWL_MVM_ESR_BLOCKED_FW: FW didn't recommended/forced exit from EMLSR
364*a4128aadSBjoern A. Zeeb  * @IWL_MVM_ESR_BLOCKED_NON_BSS: An active non-BSS interface's link is
365*a4128aadSBjoern A. Zeeb  *	preventing EMLSR
366*a4128aadSBjoern A. Zeeb  * @IWL_MVM_ESR_BLOCKED_ROC: remain-on-channel is preventing EMLSR
367*a4128aadSBjoern A. Zeeb  * @IWL_MVM_ESR_EXIT_MISSED_BEACON: exited EMLSR due to missed beacons
368*a4128aadSBjoern A. Zeeb  * @IWL_MVM_ESR_EXIT_LOW_RSSI: link is deactivated/not allowed for EMLSR
369*a4128aadSBjoern A. Zeeb  *	due to low RSSI.
370*a4128aadSBjoern A. Zeeb  * @IWL_MVM_ESR_EXIT_COEX: link is deactivated/not allowed for EMLSR
371*a4128aadSBjoern A. Zeeb  *	due to BT Coex.
372*a4128aadSBjoern A. Zeeb  * @IWL_MVM_ESR_EXIT_BANDWIDTH: Bandwidths of primary and secondry links
373*a4128aadSBjoern A. Zeeb  *	preventing the enablement of EMLSR
374*a4128aadSBjoern A. Zeeb  * @IWL_MVM_ESR_EXIT_CSA: CSA happened, so exit EMLSR
375*a4128aadSBjoern A. Zeeb  * @IWL_MVM_ESR_EXIT_LINK_USAGE: Exit EMLSR due to low tpt on secondary link
376*a4128aadSBjoern A. Zeeb  */
377*a4128aadSBjoern A. Zeeb enum iwl_mvm_esr_state {
378*a4128aadSBjoern A. Zeeb 	IWL_MVM_ESR_BLOCKED_PREVENTION	= 0x1,
379*a4128aadSBjoern A. Zeeb 	IWL_MVM_ESR_BLOCKED_WOWLAN	= 0x2,
380*a4128aadSBjoern A. Zeeb 	IWL_MVM_ESR_BLOCKED_TPT		= 0x4,
381*a4128aadSBjoern A. Zeeb 	IWL_MVM_ESR_BLOCKED_FW		= 0x8,
382*a4128aadSBjoern A. Zeeb 	IWL_MVM_ESR_BLOCKED_NON_BSS	= 0x10,
383*a4128aadSBjoern A. Zeeb 	IWL_MVM_ESR_BLOCKED_ROC		= 0x20,
384*a4128aadSBjoern A. Zeeb 	IWL_MVM_ESR_EXIT_MISSED_BEACON	= 0x10000,
385*a4128aadSBjoern A. Zeeb 	IWL_MVM_ESR_EXIT_LOW_RSSI	= 0x20000,
386*a4128aadSBjoern A. Zeeb 	IWL_MVM_ESR_EXIT_COEX		= 0x40000,
387*a4128aadSBjoern A. Zeeb 	IWL_MVM_ESR_EXIT_BANDWIDTH	= 0x80000,
388*a4128aadSBjoern A. Zeeb 	IWL_MVM_ESR_EXIT_CSA		= 0x100000,
389*a4128aadSBjoern A. Zeeb 	IWL_MVM_ESR_EXIT_LINK_USAGE	= 0x200000,
390*a4128aadSBjoern A. Zeeb };
391*a4128aadSBjoern A. Zeeb 
392*a4128aadSBjoern A. Zeeb #define IWL_MVM_BLOCK_ESR_REASONS 0xffff
393*a4128aadSBjoern A. Zeeb 
394*a4128aadSBjoern A. Zeeb const char *iwl_get_esr_state_string(enum iwl_mvm_esr_state state);
395*a4128aadSBjoern A. Zeeb 
396*a4128aadSBjoern A. Zeeb /**
397*a4128aadSBjoern A. Zeeb  * struct iwl_mvm_esr_exit - details of the last exit from EMLSR mode.
398*a4128aadSBjoern A. Zeeb  * @reason: The reason for the last exit from EMLSR.
399*a4128aadSBjoern A. Zeeb  *	&iwl_mvm_prevent_esr_reasons. Will be 0 before exiting EMLSR.
400*a4128aadSBjoern A. Zeeb  * @ts: the time stamp of the last time we existed EMLSR.
401*a4128aadSBjoern A. Zeeb  */
402*a4128aadSBjoern A. Zeeb struct iwl_mvm_esr_exit {
403*a4128aadSBjoern A. Zeeb 	unsigned long ts;
404*a4128aadSBjoern A. Zeeb 	enum iwl_mvm_esr_state reason;
4059af1bba4SBjoern A. Zeeb };
4069af1bba4SBjoern A. Zeeb 
4079af1bba4SBjoern A. Zeeb /**
408bfcc09ddSBjoern A. Zeeb  * struct iwl_mvm_vif - data per Virtual Interface, it is a MAC context
409*a4128aadSBjoern A. Zeeb  * @mvm: pointer back to the mvm struct
410bfcc09ddSBjoern A. Zeeb  * @id: between 0 and 3
411bfcc09ddSBjoern A. Zeeb  * @color: to solve races upon MAC addition and removal
412bfcc09ddSBjoern A. Zeeb  * @associated: indicates that we're currently associated, used only for
413bfcc09ddSBjoern A. Zeeb  *	managing the firmware state in iwl_mvm_bss_info_changed_station()
414bfcc09ddSBjoern A. Zeeb  * @ap_assoc_sta_count: count of stations associated to us - valid only
415bfcc09ddSBjoern A. Zeeb  *	if VIF type is AP
416bfcc09ddSBjoern A. Zeeb  * @uploaded: indicates the MAC context has been added to the device
417bfcc09ddSBjoern A. Zeeb  * @ap_ibss_active: indicates that AP/IBSS is configured and that the interface
418bfcc09ddSBjoern A. Zeeb  *	should get quota etc.
4199af1bba4SBjoern A. Zeeb  * @pm_enabled - indicate if MAC power management is allowed
420bfcc09ddSBjoern A. Zeeb  * @monitor_active: indicates that monitor context is configured, and that the
421bfcc09ddSBjoern A. Zeeb  *	interface should get quota etc.
422bfcc09ddSBjoern A. Zeeb  * @low_latency: bit flags for low latency
423bfcc09ddSBjoern A. Zeeb  *	see enum &iwl_mvm_low_latency_cause for causes.
424bfcc09ddSBjoern A. Zeeb  * @low_latency_actual: boolean, indicates low latency is set,
425bfcc09ddSBjoern A. Zeeb  *	as a result from low_latency bit flags and takes force into account.
426bfcc09ddSBjoern A. Zeeb  * @authorized: indicates the AP station was set to authorized
427bfcc09ddSBjoern A. Zeeb  * @ps_disabled: indicates that this interface requires PS to be disabled
4289af1bba4SBjoern A. Zeeb  * @csa_countdown: indicates that CSA countdown may be started
429bfcc09ddSBjoern A. Zeeb  * @csa_failed: CSA failed to schedule time event, report an error later
4309af1bba4SBjoern A. Zeeb  * @csa_bcn_pending: indicates that we are waiting for a beacon on a new channel
431*a4128aadSBjoern A. Zeeb  * @csa_blocks_tx: CSA is blocking TX
432bfcc09ddSBjoern A. Zeeb  * @features: hw features active for this vif
433*a4128aadSBjoern A. Zeeb  * @max_tx_op: max TXOP in usecs for all ACs, zero for no limit.
434*a4128aadSBjoern A. Zeeb  * @ap_beacon_time: AP beacon time for synchronisation (on older FW)
435*a4128aadSBjoern A. Zeeb  * @bf_enabled: indicates if beacon filtering is enabled
436*a4128aadSBjoern A. Zeeb  * @ba_enabled: indicated if beacon abort is enabled
437*a4128aadSBjoern A. Zeeb  * @bcn_prot: beacon protection data (keys; FIXME: needs to be per link)
438*a4128aadSBjoern A. Zeeb  * @deflink: default link data for use in non-MLO
439*a4128aadSBjoern A. Zeeb  * @link: link data for each link in MLO
440*a4128aadSBjoern A. Zeeb  * @esr_active: indicates eSR mode is active
441*a4128aadSBjoern A. Zeeb  * @esr_disable_reason: a bitmap of &enum iwl_mvm_esr_state
442*a4128aadSBjoern A. Zeeb  * @pm_enabled: indicates powersave is enabled
443*a4128aadSBjoern A. Zeeb  * @link_selection_res: bitmap of active links as it was decided in the last
444*a4128aadSBjoern A. Zeeb  *	link selection. Valid only for a MLO vif after assoc. 0 if there wasn't
445*a4128aadSBjoern A. Zeeb  *	any link selection yet.
446*a4128aadSBjoern A. Zeeb  * @link_selection_primary: primary link selected by link selection
447*a4128aadSBjoern A. Zeeb  * @primary_link: primary link in eSR. Valid only for an associated MLD vif,
448*a4128aadSBjoern A. Zeeb  *	and in eSR mode. Valid only for a STA.
449*a4128aadSBjoern A. Zeeb  * @last_esr_exit: Details of the last exit from EMLSR.
450*a4128aadSBjoern A. Zeeb  * @exit_same_reason_count: The number of times we exited due to the specified
451*a4128aadSBjoern A. Zeeb  *	@last_esr_exit::reason, only counting exits due to
452*a4128aadSBjoern A. Zeeb  *	&IWL_MVM_ESR_PREVENT_REASONS.
453*a4128aadSBjoern A. Zeeb  * @prevent_esr_done_wk: work that should be done when esr prevention ends.
454*a4128aadSBjoern A. Zeeb  * @mlo_int_scan_wk: work for the internal MLO scan.
455*a4128aadSBjoern A. Zeeb  * @unblock_esr_tpt_wk: work for unblocking EMLSR when tpt is high enough.
456*a4128aadSBjoern A. Zeeb  * @roc_activity: currently running ROC activity for this vif (or
457*a4128aadSBjoern A. Zeeb  *	ROC_NUM_ACTIVITIES if no activity is running).
458*a4128aadSBjoern A. Zeeb  * @session_prot_connection_loss: the connection was lost due to session
459*a4128aadSBjoern A. Zeeb  *	protection ending without receiving a beacon, so we need to now
460*a4128aadSBjoern A. Zeeb  *	protect the deauth separately
461*a4128aadSBjoern A. Zeeb  * @ap_early_keys: The firmware cannot install keys before stations etc.,
462*a4128aadSBjoern A. Zeeb  *	but higher layers work differently, so we store the keys here for
463*a4128aadSBjoern A. Zeeb  *	later installation.
464*a4128aadSBjoern A. Zeeb  * @ap_sta: pointer to the AP STA data structure
465*a4128aadSBjoern A. Zeeb  * @csa_count: CSA counter (old CSA implementation w/o firmware)
466*a4128aadSBjoern A. Zeeb  * @csa_misbehave: CSA AP misbehaviour flag (old implementation)
467*a4128aadSBjoern A. Zeeb  * @csa_target_freq: CSA target channel frequency (old implementation)
468*a4128aadSBjoern A. Zeeb  * @csa_work: CSA work (old implementation)
469*a4128aadSBjoern A. Zeeb  * @dbgfs_bf: beamforming debugfs data
470*a4128aadSBjoern A. Zeeb  * @dbgfs_dir: debugfs directory for this vif
471*a4128aadSBjoern A. Zeeb  * @dbgfs_pm: power management debugfs data
472*a4128aadSBjoern A. Zeeb  * @dbgfs_quota_min: debugfs value for minimal quota
473*a4128aadSBjoern A. Zeeb  * @dbgfs_slink: debugfs symlink for this interface
474*a4128aadSBjoern A. Zeeb  * @ftm_unprotected: unprotected FTM debugfs override
475*a4128aadSBjoern A. Zeeb  * @hs_time_event_data: hotspot/AUX ROC time event data
476*a4128aadSBjoern A. Zeeb  * @mac_pwr_cmd: debugfs override for MAC power command
477*a4128aadSBjoern A. Zeeb  * @target_ipv6_addrs: IPv6 addresses on this interface for offload
478*a4128aadSBjoern A. Zeeb  * @num_target_ipv6_addrs: number of @target_ipv6_addrs
479*a4128aadSBjoern A. Zeeb  * @tentative_addrs: bitmap of tentative IPv6 addresses in @target_ipv6_addrs
480*a4128aadSBjoern A. Zeeb  * @rekey_data: rekeying data for WoWLAN GTK rekey offload
481*a4128aadSBjoern A. Zeeb  * @seqno: storage for seqno for older firmware D0/D3 transition
482*a4128aadSBjoern A. Zeeb  * @seqno_valid: indicates @seqno is valid
483*a4128aadSBjoern A. Zeeb  * @time_event_data: session protection time event data
484*a4128aadSBjoern A. Zeeb  * @tsf_id: the TSF resource ID assigned in firmware (for firmware needing that)
485*a4128aadSBjoern A. Zeeb  * @tx_key_idx: WEP transmit key index for D3
486*a4128aadSBjoern A. Zeeb  * @uapsd_misbehaving_ap_addr: MLD address/BSSID of U-APSD misbehaving AP, to
487*a4128aadSBjoern A. Zeeb  *	not use U-APSD on reconnection
488*a4128aadSBjoern A. Zeeb  * @uapsd_nonagg_detected_wk: worker for handling detection of no aggregation
489*a4128aadSBjoern A. Zeeb  *	in U-APSD
490bfcc09ddSBjoern A. Zeeb  */
491bfcc09ddSBjoern A. Zeeb struct iwl_mvm_vif {
492bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm *mvm;
493bfcc09ddSBjoern A. Zeeb 	u16 id;
494bfcc09ddSBjoern A. Zeeb 	u16 color;
495bfcc09ddSBjoern A. Zeeb 
496bfcc09ddSBjoern A. Zeeb 	bool associated;
497bfcc09ddSBjoern A. Zeeb 	u8 ap_assoc_sta_count;
498bfcc09ddSBjoern A. Zeeb 	bool uploaded;
499bfcc09ddSBjoern A. Zeeb 	bool ap_ibss_active;
500bfcc09ddSBjoern A. Zeeb 	bool pm_enabled;
501bfcc09ddSBjoern A. Zeeb 	bool monitor_active;
5029af1bba4SBjoern A. Zeeb 	bool esr_active;
503*a4128aadSBjoern A. Zeeb 	bool session_prot_connection_loss;
5049af1bba4SBjoern A. Zeeb 
505bfcc09ddSBjoern A. Zeeb 	u8 low_latency: 6;
506bfcc09ddSBjoern A. Zeeb 	u8 low_latency_actual: 1;
5079af1bba4SBjoern A. Zeeb 
508bfcc09ddSBjoern A. Zeeb 	u8 authorized:1;
509bfcc09ddSBjoern A. Zeeb 	bool ps_disabled;
510bfcc09ddSBjoern A. Zeeb 
511*a4128aadSBjoern A. Zeeb 	u32 esr_disable_reason;
512bfcc09ddSBjoern A. Zeeb 	u32 ap_beacon_time;
513*a4128aadSBjoern A. Zeeb 	bool bf_enabled;
514*a4128aadSBjoern A. Zeeb 	bool ba_enabled;
515bfcc09ddSBjoern A. Zeeb 
516bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_PM
517bfcc09ddSBjoern A. Zeeb 	/* WoWLAN GTK rekey data */
518bfcc09ddSBjoern A. Zeeb 	struct {
519bfcc09ddSBjoern A. Zeeb 		u8 kck[NL80211_KCK_EXT_LEN];
520bfcc09ddSBjoern A. Zeeb 		u8 kek[NL80211_KEK_EXT_LEN];
521bfcc09ddSBjoern A. Zeeb 		size_t kek_len;
522bfcc09ddSBjoern A. Zeeb 		size_t kck_len;
523bfcc09ddSBjoern A. Zeeb 		u32 akm;
524bfcc09ddSBjoern A. Zeeb 		__le64 replay_ctr;
525bfcc09ddSBjoern A. Zeeb 		bool valid;
526bfcc09ddSBjoern A. Zeeb 	} rekey_data;
527bfcc09ddSBjoern A. Zeeb 
528bfcc09ddSBjoern A. Zeeb 	int tx_key_idx;
529bfcc09ddSBjoern A. Zeeb 
530bfcc09ddSBjoern A. Zeeb 	bool seqno_valid;
531bfcc09ddSBjoern A. Zeeb 	u16 seqno;
532bfcc09ddSBjoern A. Zeeb #endif
533bfcc09ddSBjoern A. Zeeb 
534bfcc09ddSBjoern A. Zeeb #if IS_ENABLED(CONFIG_IPV6)
535bfcc09ddSBjoern A. Zeeb 	/* IPv6 addresses for WoWLAN */
536bfcc09ddSBjoern A. Zeeb 	struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX];
537bfcc09ddSBjoern A. Zeeb 	unsigned long tentative_addrs[BITS_TO_LONGS(IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX)];
538bfcc09ddSBjoern A. Zeeb 	int num_target_ipv6_addrs;
539bfcc09ddSBjoern A. Zeeb #endif
540bfcc09ddSBjoern A. Zeeb 
541bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_IWLWIFI_DEBUGFS
542bfcc09ddSBjoern A. Zeeb 	struct dentry *dbgfs_dir;
543bfcc09ddSBjoern A. Zeeb 	struct dentry *dbgfs_slink;
544bfcc09ddSBjoern A. Zeeb 	struct iwl_dbgfs_pm dbgfs_pm;
545bfcc09ddSBjoern A. Zeeb 	struct iwl_dbgfs_bf dbgfs_bf;
546bfcc09ddSBjoern A. Zeeb 	struct iwl_mac_power_cmd mac_pwr_cmd;
547bfcc09ddSBjoern A. Zeeb 	int dbgfs_quota_min;
548*a4128aadSBjoern A. Zeeb 	bool ftm_unprotected;
549bfcc09ddSBjoern A. Zeeb #endif
550bfcc09ddSBjoern A. Zeeb 
551bfcc09ddSBjoern A. Zeeb 	/* FW identified misbehaving AP */
5529af1bba4SBjoern A. Zeeb 	u8 uapsd_misbehaving_ap_addr[ETH_ALEN] __aligned(2);
553bfcc09ddSBjoern A. Zeeb 	struct delayed_work uapsd_nonagg_detected_wk;
554bfcc09ddSBjoern A. Zeeb 
555bfcc09ddSBjoern A. Zeeb 	bool csa_countdown;
556bfcc09ddSBjoern A. Zeeb 	bool csa_failed;
5579af1bba4SBjoern A. Zeeb 	bool csa_bcn_pending;
558*a4128aadSBjoern A. Zeeb 	bool csa_blocks_tx;
559bfcc09ddSBjoern A. Zeeb 	u16 csa_target_freq;
560bfcc09ddSBjoern A. Zeeb 	u16 csa_count;
561bfcc09ddSBjoern A. Zeeb 	u16 csa_misbehave;
562bfcc09ddSBjoern A. Zeeb 	struct delayed_work csa_work;
563bfcc09ddSBjoern A. Zeeb 
5649af1bba4SBjoern A. Zeeb 	enum iwl_tsf_id tsf_id;
5659af1bba4SBjoern A. Zeeb 
5669af1bba4SBjoern A. Zeeb 	struct iwl_mvm_time_event_data time_event_data;
5679af1bba4SBjoern A. Zeeb 	struct iwl_mvm_time_event_data hs_time_event_data;
568*a4128aadSBjoern A. Zeeb 	enum iwl_roc_activity roc_activity;
569bfcc09ddSBjoern A. Zeeb 
570bfcc09ddSBjoern A. Zeeb 	/* TCP Checksum Offload */
571bfcc09ddSBjoern A. Zeeb 	netdev_features_t features;
572bfcc09ddSBjoern A. Zeeb 
5739af1bba4SBjoern A. Zeeb 	struct ieee80211_sta *ap_sta;
574bfcc09ddSBjoern A. Zeeb 
575bfcc09ddSBjoern A. Zeeb 	/* we can only have 2 GTK + 2 IGTK active at a time */
576bfcc09ddSBjoern A. Zeeb 	struct ieee80211_key_conf *ap_early_keys[4];
577bfcc09ddSBjoern A. Zeeb 
578bfcc09ddSBjoern A. Zeeb 	struct {
579bfcc09ddSBjoern A. Zeeb 		struct ieee80211_key_conf __rcu *keys[2];
580bfcc09ddSBjoern A. Zeeb 	} bcn_prot;
5819af1bba4SBjoern A. Zeeb 
582*a4128aadSBjoern A. Zeeb 	u16 max_tx_op;
583*a4128aadSBjoern A. Zeeb 
584*a4128aadSBjoern A. Zeeb 	u16 link_selection_res;
585*a4128aadSBjoern A. Zeeb 	u8 link_selection_primary;
586*a4128aadSBjoern A. Zeeb 	u8 primary_link;
587*a4128aadSBjoern A. Zeeb 	struct iwl_mvm_esr_exit last_esr_exit;
588*a4128aadSBjoern A. Zeeb 	u8 exit_same_reason_count;
589*a4128aadSBjoern A. Zeeb 	struct wiphy_delayed_work prevent_esr_done_wk;
590*a4128aadSBjoern A. Zeeb 	struct wiphy_delayed_work mlo_int_scan_wk;
591*a4128aadSBjoern A. Zeeb 	struct wiphy_work unblock_esr_tpt_wk;
592*a4128aadSBjoern A. Zeeb 
5939af1bba4SBjoern A. Zeeb 	struct iwl_mvm_vif_link_info deflink;
5949af1bba4SBjoern A. Zeeb 	struct iwl_mvm_vif_link_info *link[IEEE80211_MLD_MAX_NUM_LINKS];
595bfcc09ddSBjoern A. Zeeb };
596bfcc09ddSBjoern A. Zeeb 
5979af1bba4SBjoern A. Zeeb #define for_each_mvm_vif_valid_link(mvm_vif, link_id)			\
5989af1bba4SBjoern A. Zeeb 	for (link_id = 0;						\
5999af1bba4SBjoern A. Zeeb 	     link_id < ARRAY_SIZE((mvm_vif)->link);			\
6009af1bba4SBjoern A. Zeeb 	     link_id++)							\
6019af1bba4SBjoern A. Zeeb 		if ((mvm_vif)->link[link_id])
6029af1bba4SBjoern A. Zeeb 
603bfcc09ddSBjoern A. Zeeb static inline struct iwl_mvm_vif *
604bfcc09ddSBjoern A. Zeeb iwl_mvm_vif_from_mac80211(struct ieee80211_vif *vif)
605bfcc09ddSBjoern A. Zeeb {
606bfcc09ddSBjoern A. Zeeb 	return (void *)vif->drv_priv;
607bfcc09ddSBjoern A. Zeeb }
608bfcc09ddSBjoern A. Zeeb 
609bfcc09ddSBjoern A. Zeeb extern const u8 tid_to_mac80211_ac[];
610bfcc09ddSBjoern A. Zeeb 
611bfcc09ddSBjoern A. Zeeb #define IWL_MVM_SCAN_STOPPING_SHIFT	8
612bfcc09ddSBjoern A. Zeeb 
613bfcc09ddSBjoern A. Zeeb enum iwl_scan_status {
614bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SCAN_REGULAR		= BIT(0),
615bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SCAN_SCHED		= BIT(1),
616bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SCAN_NETDETECT		= BIT(2),
617*a4128aadSBjoern A. Zeeb 	IWL_MVM_SCAN_INT_MLO		= BIT(3),
618bfcc09ddSBjoern A. Zeeb 
619bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SCAN_STOPPING_REGULAR	= BIT(8),
620bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SCAN_STOPPING_SCHED	= BIT(9),
621bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SCAN_STOPPING_NETDETECT	= BIT(10),
622*a4128aadSBjoern A. Zeeb 	IWL_MVM_SCAN_STOPPING_INT_MLO	= BIT(11),
623bfcc09ddSBjoern A. Zeeb 
624bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SCAN_REGULAR_MASK	= IWL_MVM_SCAN_REGULAR |
625bfcc09ddSBjoern A. Zeeb 					  IWL_MVM_SCAN_STOPPING_REGULAR,
626bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SCAN_SCHED_MASK		= IWL_MVM_SCAN_SCHED |
627bfcc09ddSBjoern A. Zeeb 					  IWL_MVM_SCAN_STOPPING_SCHED,
628bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SCAN_NETDETECT_MASK	= IWL_MVM_SCAN_NETDETECT |
629bfcc09ddSBjoern A. Zeeb 					  IWL_MVM_SCAN_STOPPING_NETDETECT,
630*a4128aadSBjoern A. Zeeb 	IWL_MVM_SCAN_INT_MLO_MASK       = IWL_MVM_SCAN_INT_MLO |
631*a4128aadSBjoern A. Zeeb 					  IWL_MVM_SCAN_STOPPING_INT_MLO,
632bfcc09ddSBjoern A. Zeeb 
633bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SCAN_STOPPING_MASK	= 0xff << IWL_MVM_SCAN_STOPPING_SHIFT,
634bfcc09ddSBjoern A. Zeeb 	IWL_MVM_SCAN_MASK		= 0xff,
635bfcc09ddSBjoern A. Zeeb };
636bfcc09ddSBjoern A. Zeeb 
637bfcc09ddSBjoern A. Zeeb enum iwl_mvm_scan_type {
638bfcc09ddSBjoern A. Zeeb 	IWL_SCAN_TYPE_NOT_SET,
639bfcc09ddSBjoern A. Zeeb 	IWL_SCAN_TYPE_UNASSOC,
640bfcc09ddSBjoern A. Zeeb 	IWL_SCAN_TYPE_WILD,
641bfcc09ddSBjoern A. Zeeb 	IWL_SCAN_TYPE_MILD,
642bfcc09ddSBjoern A. Zeeb 	IWL_SCAN_TYPE_FRAGMENTED,
643bfcc09ddSBjoern A. Zeeb 	IWL_SCAN_TYPE_FAST_BALANCE,
644bfcc09ddSBjoern A. Zeeb };
645bfcc09ddSBjoern A. Zeeb 
646bfcc09ddSBjoern A. Zeeb enum iwl_mvm_sched_scan_pass_all_states {
647bfcc09ddSBjoern A. Zeeb 	SCHED_SCAN_PASS_ALL_DISABLED,
648bfcc09ddSBjoern A. Zeeb 	SCHED_SCAN_PASS_ALL_ENABLED,
649bfcc09ddSBjoern A. Zeeb 	SCHED_SCAN_PASS_ALL_FOUND,
650bfcc09ddSBjoern A. Zeeb };
651bfcc09ddSBjoern A. Zeeb 
652bfcc09ddSBjoern A. Zeeb /**
653*a4128aadSBjoern A. Zeeb  * struct iwl_mvm_tt_mgmt - Thermal Throttling Management structure
654bfcc09ddSBjoern A. Zeeb  * @ct_kill_exit: worker to exit thermal kill
655bfcc09ddSBjoern A. Zeeb  * @dynamic_smps: Is thermal throttling enabled dynamic_smps?
656bfcc09ddSBjoern A. Zeeb  * @tx_backoff: The current thremal throttling tx backoff in uSec.
657bfcc09ddSBjoern A. Zeeb  * @min_backoff: The minimal tx backoff due to power restrictions
658bfcc09ddSBjoern A. Zeeb  * @params: Parameters to configure the thermal throttling algorithm.
659bfcc09ddSBjoern A. Zeeb  * @throttle: Is thermal throttling is active?
660bfcc09ddSBjoern A. Zeeb  */
661bfcc09ddSBjoern A. Zeeb struct iwl_mvm_tt_mgmt {
662bfcc09ddSBjoern A. Zeeb 	struct delayed_work ct_kill_exit;
663bfcc09ddSBjoern A. Zeeb 	bool dynamic_smps;
664bfcc09ddSBjoern A. Zeeb 	u32 tx_backoff;
665bfcc09ddSBjoern A. Zeeb 	u32 min_backoff;
666bfcc09ddSBjoern A. Zeeb 	struct iwl_tt_params params;
667bfcc09ddSBjoern A. Zeeb 	bool throttle;
668bfcc09ddSBjoern A. Zeeb };
669bfcc09ddSBjoern A. Zeeb 
670bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_THERMAL
671bfcc09ddSBjoern A. Zeeb /**
672bfcc09ddSBjoern A. Zeeb  * struct iwl_mvm_thermal_device - thermal zone related data
673*a4128aadSBjoern A. Zeeb  * @trips: temperature thresholds for report
674bfcc09ddSBjoern A. Zeeb  * @tzone: thermal zone device data
675bfcc09ddSBjoern A. Zeeb */
676bfcc09ddSBjoern A. Zeeb struct iwl_mvm_thermal_device {
6779af1bba4SBjoern A. Zeeb 	struct thermal_trip trips[IWL_MAX_DTS_TRIPS];
678bfcc09ddSBjoern A. Zeeb 	struct thermal_zone_device *tzone;
679bfcc09ddSBjoern A. Zeeb };
680bfcc09ddSBjoern A. Zeeb 
681bfcc09ddSBjoern A. Zeeb /*
682bfcc09ddSBjoern A. Zeeb  * struct iwl_mvm_cooling_device
683bfcc09ddSBjoern A. Zeeb  * @cur_state: current state
684bfcc09ddSBjoern A. Zeeb  * @cdev: struct thermal cooling device
685bfcc09ddSBjoern A. Zeeb  */
686bfcc09ddSBjoern A. Zeeb struct iwl_mvm_cooling_device {
687bfcc09ddSBjoern A. Zeeb 	u32 cur_state;
688bfcc09ddSBjoern A. Zeeb 	struct thermal_cooling_device *cdev;
689bfcc09ddSBjoern A. Zeeb };
690bfcc09ddSBjoern A. Zeeb #endif
691bfcc09ddSBjoern A. Zeeb 
692bfcc09ddSBjoern A. Zeeb #define IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES 8
693bfcc09ddSBjoern A. Zeeb 
694bfcc09ddSBjoern A. Zeeb struct iwl_mvm_frame_stats {
695bfcc09ddSBjoern A. Zeeb 	u32 legacy_frames;
696bfcc09ddSBjoern A. Zeeb 	u32 ht_frames;
697bfcc09ddSBjoern A. Zeeb 	u32 vht_frames;
698bfcc09ddSBjoern A. Zeeb 	u32 bw_20_frames;
699bfcc09ddSBjoern A. Zeeb 	u32 bw_40_frames;
700bfcc09ddSBjoern A. Zeeb 	u32 bw_80_frames;
701bfcc09ddSBjoern A. Zeeb 	u32 bw_160_frames;
702bfcc09ddSBjoern A. Zeeb 	u32 sgi_frames;
703bfcc09ddSBjoern A. Zeeb 	u32 ngi_frames;
704bfcc09ddSBjoern A. Zeeb 	u32 siso_frames;
705bfcc09ddSBjoern A. Zeeb 	u32 mimo2_frames;
706bfcc09ddSBjoern A. Zeeb 	u32 agg_frames;
707bfcc09ddSBjoern A. Zeeb 	u32 ampdu_count;
708bfcc09ddSBjoern A. Zeeb 	u32 success_frames;
709bfcc09ddSBjoern A. Zeeb 	u32 fail_frames;
710bfcc09ddSBjoern A. Zeeb 	u32 last_rates[IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES];
711bfcc09ddSBjoern A. Zeeb 	int last_frame_idx;
712bfcc09ddSBjoern A. Zeeb };
713bfcc09ddSBjoern A. Zeeb 
714bfcc09ddSBjoern A. Zeeb #define IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE 0xff
715bfcc09ddSBjoern A. Zeeb #define IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -100
716bfcc09ddSBjoern A. Zeeb #define IWL_MVM_DEBUG_SET_TEMPERATURE_MAX 200
717bfcc09ddSBjoern A. Zeeb 
718bfcc09ddSBjoern A. Zeeb enum iwl_mvm_tdls_cs_state {
719bfcc09ddSBjoern A. Zeeb 	IWL_MVM_TDLS_SW_IDLE = 0,
720bfcc09ddSBjoern A. Zeeb 	IWL_MVM_TDLS_SW_REQ_SENT,
721bfcc09ddSBjoern A. Zeeb 	IWL_MVM_TDLS_SW_RESP_RCVD,
722bfcc09ddSBjoern A. Zeeb 	IWL_MVM_TDLS_SW_REQ_RCVD,
723bfcc09ddSBjoern A. Zeeb 	IWL_MVM_TDLS_SW_ACTIVE,
724bfcc09ddSBjoern A. Zeeb };
725bfcc09ddSBjoern A. Zeeb 
726bfcc09ddSBjoern A. Zeeb enum iwl_mvm_traffic_load {
727bfcc09ddSBjoern A. Zeeb 	IWL_MVM_TRAFFIC_LOW,
728bfcc09ddSBjoern A. Zeeb 	IWL_MVM_TRAFFIC_MEDIUM,
729bfcc09ddSBjoern A. Zeeb 	IWL_MVM_TRAFFIC_HIGH,
730bfcc09ddSBjoern A. Zeeb };
731bfcc09ddSBjoern A. Zeeb 
732bfcc09ddSBjoern A. Zeeb DECLARE_EWMA(rate, 16, 16)
733bfcc09ddSBjoern A. Zeeb 
734bfcc09ddSBjoern A. Zeeb struct iwl_mvm_tcm_mac {
735bfcc09ddSBjoern A. Zeeb 	struct {
736bfcc09ddSBjoern A. Zeeb 		u32 pkts[IEEE80211_NUM_ACS];
737bfcc09ddSBjoern A. Zeeb 		u32 airtime;
738bfcc09ddSBjoern A. Zeeb 	} tx;
739bfcc09ddSBjoern A. Zeeb 	struct {
740bfcc09ddSBjoern A. Zeeb 		u32 pkts[IEEE80211_NUM_ACS];
741bfcc09ddSBjoern A. Zeeb 		u32 airtime;
742bfcc09ddSBjoern A. Zeeb 		u32 last_ampdu_ref;
743bfcc09ddSBjoern A. Zeeb 	} rx;
744bfcc09ddSBjoern A. Zeeb 	struct {
745bfcc09ddSBjoern A. Zeeb 		/* track AP's transfer in client mode */
746bfcc09ddSBjoern A. Zeeb 		u64 rx_bytes;
747bfcc09ddSBjoern A. Zeeb 		struct ewma_rate rate;
748bfcc09ddSBjoern A. Zeeb 		bool detected;
749bfcc09ddSBjoern A. Zeeb 	} uapsd_nonagg_detect;
750bfcc09ddSBjoern A. Zeeb 	bool opened_rx_ba_sessions;
751bfcc09ddSBjoern A. Zeeb };
752bfcc09ddSBjoern A. Zeeb 
753bfcc09ddSBjoern A. Zeeb struct iwl_mvm_tcm {
754bfcc09ddSBjoern A. Zeeb 	struct delayed_work work;
755bfcc09ddSBjoern A. Zeeb 	spinlock_t lock; /* used when time elapsed */
756bfcc09ddSBjoern A. Zeeb 	unsigned long ts; /* timestamp when period ends */
757bfcc09ddSBjoern A. Zeeb 	unsigned long ll_ts;
758bfcc09ddSBjoern A. Zeeb 	unsigned long uapsd_nonagg_ts;
759bfcc09ddSBjoern A. Zeeb 	bool paused;
760bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm_tcm_mac data[NUM_MAC_INDEX_DRIVER];
761bfcc09ddSBjoern A. Zeeb 	struct {
762bfcc09ddSBjoern A. Zeeb 		u32 elapsed; /* milliseconds for this TCM period */
763bfcc09ddSBjoern A. Zeeb 		u32 airtime[NUM_MAC_INDEX_DRIVER];
764bfcc09ddSBjoern A. Zeeb 		enum iwl_mvm_traffic_load load[NUM_MAC_INDEX_DRIVER];
765bfcc09ddSBjoern A. Zeeb 		enum iwl_mvm_traffic_load band_load[NUM_NL80211_BANDS];
766bfcc09ddSBjoern A. Zeeb 		enum iwl_mvm_traffic_load global_load;
767bfcc09ddSBjoern A. Zeeb 		bool low_latency[NUM_MAC_INDEX_DRIVER];
768bfcc09ddSBjoern A. Zeeb 		bool change[NUM_MAC_INDEX_DRIVER];
769bfcc09ddSBjoern A. Zeeb 	} result;
770bfcc09ddSBjoern A. Zeeb };
771bfcc09ddSBjoern A. Zeeb 
772bfcc09ddSBjoern A. Zeeb /**
773bfcc09ddSBjoern A. Zeeb  * struct iwl_mvm_reorder_buffer - per ra/tid/queue reorder buffer
774bfcc09ddSBjoern A. Zeeb  * @head_sn: reorder window head sn
775bfcc09ddSBjoern A. Zeeb  * @num_stored: number of mpdus stored in the buffer
776bfcc09ddSBjoern A. Zeeb  * @queue: queue of this reorder buffer
777bfcc09ddSBjoern A. Zeeb  * @last_amsdu: track last ASMDU SN for duplication detection
778bfcc09ddSBjoern A. Zeeb  * @last_sub_index: track ASMDU sub frame index for duplication detection
779bfcc09ddSBjoern A. Zeeb  * @valid: reordering is valid for this queue
780bfcc09ddSBjoern A. Zeeb  * @lock: protect reorder buffer internal state
781bfcc09ddSBjoern A. Zeeb  */
782bfcc09ddSBjoern A. Zeeb struct iwl_mvm_reorder_buffer {
783bfcc09ddSBjoern A. Zeeb 	u16 head_sn;
784bfcc09ddSBjoern A. Zeeb 	u16 num_stored;
785bfcc09ddSBjoern A. Zeeb 	int queue;
786bfcc09ddSBjoern A. Zeeb 	u16 last_amsdu;
787bfcc09ddSBjoern A. Zeeb 	u8 last_sub_index;
788bfcc09ddSBjoern A. Zeeb 	bool valid;
789bfcc09ddSBjoern A. Zeeb 	spinlock_t lock;
790bfcc09ddSBjoern A. Zeeb } ____cacheline_aligned_in_smp;
791bfcc09ddSBjoern A. Zeeb 
792bfcc09ddSBjoern A. Zeeb /**
793*a4128aadSBjoern A. Zeeb  * struct iwl_mvm_reorder_buf_entry - reorder buffer entry per-queue/per-seqno
794bfcc09ddSBjoern A. Zeeb  * @frames: list of skbs stored
795bfcc09ddSBjoern A. Zeeb  */
796bfcc09ddSBjoern A. Zeeb struct iwl_mvm_reorder_buf_entry {
797*a4128aadSBjoern A. Zeeb 	struct sk_buff_head frames;
798bfcc09ddSBjoern A. Zeeb }
799*a4128aadSBjoern A. Zeeb #ifndef __CHECKER__
800bfcc09ddSBjoern A. Zeeb /* sparse doesn't like this construct: "bad integer constant expression" */
801*a4128aadSBjoern A. Zeeb __aligned(roundup_pow_of_two(sizeof(struct sk_buff_head)))
802bfcc09ddSBjoern A. Zeeb #endif
803bfcc09ddSBjoern A. Zeeb ;
804bfcc09ddSBjoern A. Zeeb 
805bfcc09ddSBjoern A. Zeeb /**
806bfcc09ddSBjoern A. Zeeb  * struct iwl_mvm_baid_data - BA session data
8079af1bba4SBjoern A. Zeeb  * @sta_mask: current station mask for the BAID
808bfcc09ddSBjoern A. Zeeb  * @tid: tid of the session
809*a4128aadSBjoern A. Zeeb  * @baid: baid of the session
810bfcc09ddSBjoern A. Zeeb  * @timeout: the timeout set in the addba request
811*a4128aadSBjoern A. Zeeb  * @buf_size: the reorder buffer size as set by the last addba request
812bfcc09ddSBjoern A. Zeeb  * @entries_per_queue: # of buffers per queue, this actually gets
813bfcc09ddSBjoern A. Zeeb  *	aligned up to avoid cache line sharing between queues
814bfcc09ddSBjoern A. Zeeb  * @last_rx: last rx jiffies, updated only if timeout passed from last update
815bfcc09ddSBjoern A. Zeeb  * @session_timer: timer to check if BA session expired, runs at 2 * timeout
816*a4128aadSBjoern A. Zeeb  * @rcu_ptr: BA data RCU protected access
817*a4128aadSBjoern A. Zeeb  * @rcu_head: RCU head for freeing this data
818bfcc09ddSBjoern A. Zeeb  * @mvm: mvm pointer, needed for timer context
819bfcc09ddSBjoern A. Zeeb  * @reorder_buf: reorder buffer, allocated per queue
820*a4128aadSBjoern A. Zeeb  * @entries: data
821bfcc09ddSBjoern A. Zeeb  */
822bfcc09ddSBjoern A. Zeeb struct iwl_mvm_baid_data {
823bfcc09ddSBjoern A. Zeeb 	struct rcu_head rcu_head;
8249af1bba4SBjoern A. Zeeb 	u32 sta_mask;
825bfcc09ddSBjoern A. Zeeb 	u8 tid;
826bfcc09ddSBjoern A. Zeeb 	u8 baid;
827bfcc09ddSBjoern A. Zeeb 	u16 timeout;
828*a4128aadSBjoern A. Zeeb 	u16 buf_size;
829bfcc09ddSBjoern A. Zeeb 	u16 entries_per_queue;
830bfcc09ddSBjoern A. Zeeb 	unsigned long last_rx;
831bfcc09ddSBjoern A. Zeeb 	struct timer_list session_timer;
832bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm_baid_data __rcu **rcu_ptr;
833bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm *mvm;
834bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm_reorder_buffer reorder_buf[IWL_MAX_RX_HW_QUEUES];
835*a4128aadSBjoern A. Zeeb 	struct iwl_mvm_reorder_buf_entry entries[] ____cacheline_aligned_in_smp;
836bfcc09ddSBjoern A. Zeeb };
837bfcc09ddSBjoern A. Zeeb 
838bfcc09ddSBjoern A. Zeeb static inline struct iwl_mvm_baid_data *
839bfcc09ddSBjoern A. Zeeb iwl_mvm_baid_data_from_reorder_buf(struct iwl_mvm_reorder_buffer *buf)
840bfcc09ddSBjoern A. Zeeb {
841bfcc09ddSBjoern A. Zeeb 	return (void *)((u8 *)buf -
842bfcc09ddSBjoern A. Zeeb 			offsetof(struct iwl_mvm_baid_data, reorder_buf) -
843bfcc09ddSBjoern A. Zeeb 			sizeof(*buf) * buf->queue);
844bfcc09ddSBjoern A. Zeeb }
845bfcc09ddSBjoern A. Zeeb 
846bfcc09ddSBjoern A. Zeeb /*
847bfcc09ddSBjoern A. Zeeb  * enum iwl_mvm_queue_status - queue status
848bfcc09ddSBjoern A. Zeeb  * @IWL_MVM_QUEUE_FREE: the queue is not allocated nor reserved
849bfcc09ddSBjoern A. Zeeb  *	Basically, this means that this queue can be used for any purpose
850bfcc09ddSBjoern A. Zeeb  * @IWL_MVM_QUEUE_RESERVED: queue is reserved but not yet in use
851bfcc09ddSBjoern A. Zeeb  *	This is the state of a queue that has been dedicated for some RATID
852bfcc09ddSBjoern A. Zeeb  *	(agg'd or not), but that hasn't yet gone through the actual enablement
853bfcc09ddSBjoern A. Zeeb  *	of iwl_mvm_enable_txq(), and therefore no traffic can go through it yet.
854bfcc09ddSBjoern A. Zeeb  *	Note that in this state there is no requirement to already know what TID
855bfcc09ddSBjoern A. Zeeb  *	should be used with this queue, it is just marked as a queue that will
856bfcc09ddSBjoern A. Zeeb  *	be used, and shouldn't be allocated to anyone else.
857bfcc09ddSBjoern A. Zeeb  * @IWL_MVM_QUEUE_READY: queue is ready to be used
858bfcc09ddSBjoern A. Zeeb  *	This is the state of a queue that has been fully configured (including
859bfcc09ddSBjoern A. Zeeb  *	SCD pointers, etc), has a specific RA/TID assigned to it, and can be
860bfcc09ddSBjoern A. Zeeb  *	used to send traffic.
861bfcc09ddSBjoern A. Zeeb  * @IWL_MVM_QUEUE_SHARED: queue is shared, or in a process of becoming shared
862bfcc09ddSBjoern A. Zeeb  *	This is a state in which a single queue serves more than one TID, all of
863bfcc09ddSBjoern A. Zeeb  *	which are not aggregated. Note that the queue is only associated to one
864bfcc09ddSBjoern A. Zeeb  *	RA.
865bfcc09ddSBjoern A. Zeeb  */
866bfcc09ddSBjoern A. Zeeb enum iwl_mvm_queue_status {
867bfcc09ddSBjoern A. Zeeb 	IWL_MVM_QUEUE_FREE,
868bfcc09ddSBjoern A. Zeeb 	IWL_MVM_QUEUE_RESERVED,
869bfcc09ddSBjoern A. Zeeb 	IWL_MVM_QUEUE_READY,
870bfcc09ddSBjoern A. Zeeb 	IWL_MVM_QUEUE_SHARED,
871bfcc09ddSBjoern A. Zeeb };
872bfcc09ddSBjoern A. Zeeb 
873bfcc09ddSBjoern A. Zeeb #define IWL_MVM_DQA_QUEUE_TIMEOUT	(5 * HZ)
874bfcc09ddSBjoern A. Zeeb #define IWL_MVM_INVALID_QUEUE		0xFFFF
875bfcc09ddSBjoern A. Zeeb 
876bfcc09ddSBjoern A. Zeeb #define IWL_MVM_NUM_CIPHERS             10
877bfcc09ddSBjoern A. Zeeb 
878bfcc09ddSBjoern A. Zeeb 
879bfcc09ddSBjoern A. Zeeb struct iwl_mvm_txq {
880bfcc09ddSBjoern A. Zeeb 	struct list_head list;
881bfcc09ddSBjoern A. Zeeb 	u16 txq_id;
882bfcc09ddSBjoern A. Zeeb 	atomic_t tx_request;
883*a4128aadSBjoern A. Zeeb #define IWL_MVM_TXQ_STATE_READY		0
884*a4128aadSBjoern A. Zeeb #define IWL_MVM_TXQ_STATE_STOP_FULL	1
885*a4128aadSBjoern A. Zeeb #define IWL_MVM_TXQ_STATE_STOP_REDIRECT	2
886*a4128aadSBjoern A. Zeeb #define IWL_MVM_TXQ_STATE_STOP_AP_CSA	3
8879af1bba4SBjoern A. Zeeb 	unsigned long state;
888bfcc09ddSBjoern A. Zeeb };
889bfcc09ddSBjoern A. Zeeb 
890bfcc09ddSBjoern A. Zeeb static inline struct iwl_mvm_txq *
891bfcc09ddSBjoern A. Zeeb iwl_mvm_txq_from_mac80211(struct ieee80211_txq *txq)
892bfcc09ddSBjoern A. Zeeb {
893bfcc09ddSBjoern A. Zeeb 	return (void *)txq->drv_priv;
894bfcc09ddSBjoern A. Zeeb }
895bfcc09ddSBjoern A. Zeeb 
896bfcc09ddSBjoern A. Zeeb static inline struct iwl_mvm_txq *
897bfcc09ddSBjoern A. Zeeb iwl_mvm_txq_from_tid(struct ieee80211_sta *sta, u8 tid)
898bfcc09ddSBjoern A. Zeeb {
899bfcc09ddSBjoern A. Zeeb 	if (tid == IWL_MAX_TID_COUNT)
900bfcc09ddSBjoern A. Zeeb 		tid = IEEE80211_NUM_TIDS;
901bfcc09ddSBjoern A. Zeeb 
902bfcc09ddSBjoern A. Zeeb 	return (void *)sta->txq[tid]->drv_priv;
903bfcc09ddSBjoern A. Zeeb }
904bfcc09ddSBjoern A. Zeeb 
905bfcc09ddSBjoern A. Zeeb /**
906bfcc09ddSBjoern A. Zeeb  * struct iwl_mvm_tvqm_txq_info - maps TVQM hw queue to tid
907bfcc09ddSBjoern A. Zeeb  *
908bfcc09ddSBjoern A. Zeeb  * @sta_id: sta id
909bfcc09ddSBjoern A. Zeeb  * @txq_tid: txq tid
910bfcc09ddSBjoern A. Zeeb  */
911bfcc09ddSBjoern A. Zeeb struct iwl_mvm_tvqm_txq_info {
912bfcc09ddSBjoern A. Zeeb 	u8 sta_id;
913bfcc09ddSBjoern A. Zeeb 	u8 txq_tid;
914bfcc09ddSBjoern A. Zeeb };
915bfcc09ddSBjoern A. Zeeb 
916bfcc09ddSBjoern A. Zeeb struct iwl_mvm_dqa_txq_info {
917bfcc09ddSBjoern A. Zeeb 	u8 ra_sta_id; /* The RA this queue is mapped to, if exists */
918bfcc09ddSBjoern A. Zeeb 	bool reserved; /* Is this the TXQ reserved for a STA */
919bfcc09ddSBjoern A. Zeeb 	u8 mac80211_ac; /* The mac80211 AC this queue is mapped to */
920bfcc09ddSBjoern A. Zeeb 	u8 txq_tid; /* The TID "owner" of this queue*/
921bfcc09ddSBjoern A. Zeeb 	u16 tid_bitmap; /* Bitmap of the TIDs mapped to this queue */
922bfcc09ddSBjoern A. Zeeb 	/* Timestamp for inactivation per TID of this queue */
923bfcc09ddSBjoern A. Zeeb 	unsigned long last_frame_time[IWL_MAX_TID_COUNT + 1];
924bfcc09ddSBjoern A. Zeeb 	enum iwl_mvm_queue_status status;
925bfcc09ddSBjoern A. Zeeb };
926bfcc09ddSBjoern A. Zeeb 
9279af1bba4SBjoern A. Zeeb struct ptp_data {
9289af1bba4SBjoern A. Zeeb 	struct ptp_clock *ptp_clock;
9299af1bba4SBjoern A. Zeeb 	struct ptp_clock_info ptp_clock_info;
9309af1bba4SBjoern A. Zeeb 
9319af1bba4SBjoern A. Zeeb 	struct delayed_work dwork;
9329af1bba4SBjoern A. Zeeb 
9339af1bba4SBjoern A. Zeeb 	/* The last GP2 reading from the hw */
9349af1bba4SBjoern A. Zeeb 	u32 last_gp2;
9359af1bba4SBjoern A. Zeeb 
9369af1bba4SBjoern A. Zeeb 	/* number of wraparounds since scale_update_adj_time_ns */
9379af1bba4SBjoern A. Zeeb 	u32 wrap_counter;
9389af1bba4SBjoern A. Zeeb 
9399af1bba4SBjoern A. Zeeb 	/* GP2 time when the scale was last updated */
9409af1bba4SBjoern A. Zeeb 	u32 scale_update_gp2;
9419af1bba4SBjoern A. Zeeb 
9429af1bba4SBjoern A. Zeeb 	/* Adjusted time when the scale was last updated in nanoseconds */
9439af1bba4SBjoern A. Zeeb 	u64 scale_update_adj_time_ns;
9449af1bba4SBjoern A. Zeeb 
9459af1bba4SBjoern A. Zeeb 	/* clock frequency offset, scaled to 65536000000 */
9469af1bba4SBjoern A. Zeeb 	u64 scaled_freq;
9479af1bba4SBjoern A. Zeeb 
9489af1bba4SBjoern A. Zeeb 	/* Delta between hardware clock and ptp clock in nanoseconds */
9499af1bba4SBjoern A. Zeeb 	s64 delta;
9509af1bba4SBjoern A. Zeeb };
9519af1bba4SBjoern A. Zeeb 
9529af1bba4SBjoern A. Zeeb struct iwl_time_sync_data {
9539af1bba4SBjoern A. Zeeb 	struct sk_buff_head frame_list;
9549af1bba4SBjoern A. Zeeb 	u8 peer_addr[ETH_ALEN];
9559af1bba4SBjoern A. Zeeb 	bool active;
9569af1bba4SBjoern A. Zeeb };
9579af1bba4SBjoern A. Zeeb 
9589af1bba4SBjoern A. Zeeb struct iwl_mei_scan_filter {
9599af1bba4SBjoern A. Zeeb 	bool is_mei_limited_scan;
9609af1bba4SBjoern A. Zeeb 	struct sk_buff_head scan_res;
9619af1bba4SBjoern A. Zeeb 	struct work_struct scan_work;
9629af1bba4SBjoern A. Zeeb };
9639af1bba4SBjoern A. Zeeb 
964*a4128aadSBjoern A. Zeeb /**
965*a4128aadSBjoern A. Zeeb  * struct iwl_mvm_acs_survey_channel - per-channel survey information
966*a4128aadSBjoern A. Zeeb  *
967*a4128aadSBjoern A. Zeeb  * Stripped down version of &struct survey_info.
968*a4128aadSBjoern A. Zeeb  *
969*a4128aadSBjoern A. Zeeb  * @time: time in ms the radio was on the channel
970*a4128aadSBjoern A. Zeeb  * @time_busy: time in ms the channel was sensed busy
971*a4128aadSBjoern A. Zeeb  * @time_tx: time in ms spent transmitting data
972*a4128aadSBjoern A. Zeeb  * @time_rx: time in ms spent receiving data
973*a4128aadSBjoern A. Zeeb  * @noise: channel noise in dBm
974*a4128aadSBjoern A. Zeeb  */
975*a4128aadSBjoern A. Zeeb struct iwl_mvm_acs_survey_channel {
976*a4128aadSBjoern A. Zeeb 	u32 time;
977*a4128aadSBjoern A. Zeeb 	u32 time_busy;
978*a4128aadSBjoern A. Zeeb 	u32 time_tx;
979*a4128aadSBjoern A. Zeeb 	u32 time_rx;
980*a4128aadSBjoern A. Zeeb 	s8 noise;
981*a4128aadSBjoern A. Zeeb };
982*a4128aadSBjoern A. Zeeb 
983*a4128aadSBjoern A. Zeeb struct iwl_mvm_acs_survey {
984*a4128aadSBjoern A. Zeeb 	struct iwl_mvm_acs_survey_channel *bands[NUM_NL80211_BANDS];
985*a4128aadSBjoern A. Zeeb 
986*a4128aadSBjoern A. Zeeb 	/* Overall number of channels */
987*a4128aadSBjoern A. Zeeb 	int n_channels;
988*a4128aadSBjoern A. Zeeb 
989*a4128aadSBjoern A. Zeeb 	/* Storage space for per-channel information follows */
990*a4128aadSBjoern A. Zeeb 	struct iwl_mvm_acs_survey_channel channels[] __counted_by(n_channels);
991*a4128aadSBjoern A. Zeeb };
992*a4128aadSBjoern A. Zeeb 
993bfcc09ddSBjoern A. Zeeb struct iwl_mvm {
994bfcc09ddSBjoern A. Zeeb 	/* for logger access */
995bfcc09ddSBjoern A. Zeeb 	struct device *dev;
996bfcc09ddSBjoern A. Zeeb 
997bfcc09ddSBjoern A. Zeeb 	struct iwl_trans *trans;
998bfcc09ddSBjoern A. Zeeb 	const struct iwl_fw *fw;
999bfcc09ddSBjoern A. Zeeb 	const struct iwl_cfg *cfg;
1000bfcc09ddSBjoern A. Zeeb 	struct iwl_phy_db *phy_db;
1001bfcc09ddSBjoern A. Zeeb 	struct ieee80211_hw *hw;
1002bfcc09ddSBjoern A. Zeeb 
1003bfcc09ddSBjoern A. Zeeb 	/* for protecting access to iwl_mvm */
1004bfcc09ddSBjoern A. Zeeb 	struct mutex mutex;
1005bfcc09ddSBjoern A. Zeeb 	struct list_head async_handlers_list;
1006bfcc09ddSBjoern A. Zeeb 	spinlock_t async_handlers_lock;
1007bfcc09ddSBjoern A. Zeeb 	struct work_struct async_handlers_wk;
1008bfcc09ddSBjoern A. Zeeb 
1009*a4128aadSBjoern A. Zeeb 	/* For async rx handlers that require the wiphy lock */
1010*a4128aadSBjoern A. Zeeb 	struct wiphy_work async_handlers_wiphy_wk;
1011*a4128aadSBjoern A. Zeeb 
1012*a4128aadSBjoern A. Zeeb 	struct wiphy_work trig_link_selection_wk;
1013*a4128aadSBjoern A. Zeeb 
1014bfcc09ddSBjoern A. Zeeb 	struct work_struct roc_done_wk;
1015bfcc09ddSBjoern A. Zeeb 
1016bfcc09ddSBjoern A. Zeeb 	unsigned long init_status;
1017bfcc09ddSBjoern A. Zeeb 
1018bfcc09ddSBjoern A. Zeeb 	unsigned long status;
1019bfcc09ddSBjoern A. Zeeb 
1020bfcc09ddSBjoern A. Zeeb 	u32 queue_sync_cookie;
1021bfcc09ddSBjoern A. Zeeb 	unsigned long queue_sync_state;
1022bfcc09ddSBjoern A. Zeeb 	/*
1023bfcc09ddSBjoern A. Zeeb 	 * for beacon filtering -
1024bfcc09ddSBjoern A. Zeeb 	 * currently only one interface can be supported
1025bfcc09ddSBjoern A. Zeeb 	 */
1026bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm_vif *bf_allowed_vif;
1027bfcc09ddSBjoern A. Zeeb 
1028bfcc09ddSBjoern A. Zeeb 	bool hw_registered;
1029bfcc09ddSBjoern A. Zeeb 	bool rfkill_safe_init_done;
1030bfcc09ddSBjoern A. Zeeb 
1031bfcc09ddSBjoern A. Zeeb 	u8 cca_40mhz_workaround;
1032bfcc09ddSBjoern A. Zeeb 
1033bfcc09ddSBjoern A. Zeeb 	u32 ampdu_ref;
1034bfcc09ddSBjoern A. Zeeb 	bool ampdu_toggle;
1035bfcc09ddSBjoern A. Zeeb 
1036bfcc09ddSBjoern A. Zeeb 	struct iwl_notif_wait_data notif_wait;
1037bfcc09ddSBjoern A. Zeeb 
1038bfcc09ddSBjoern A. Zeeb 	union {
1039bfcc09ddSBjoern A. Zeeb 		struct mvm_statistics_rx_v3 rx_stats_v3;
1040bfcc09ddSBjoern A. Zeeb 		struct mvm_statistics_rx rx_stats;
1041bfcc09ddSBjoern A. Zeeb 	};
1042bfcc09ddSBjoern A. Zeeb 
1043bfcc09ddSBjoern A. Zeeb 	struct {
1044bfcc09ddSBjoern A. Zeeb 		u64 rx_time;
1045bfcc09ddSBjoern A. Zeeb 		u64 tx_time;
1046bfcc09ddSBjoern A. Zeeb 		u64 on_time_rf;
1047bfcc09ddSBjoern A. Zeeb 		u64 on_time_scan;
1048bfcc09ddSBjoern A. Zeeb 	} radio_stats, accu_radio_stats;
1049bfcc09ddSBjoern A. Zeeb 
1050bfcc09ddSBjoern A. Zeeb 	struct list_head add_stream_txqs;
1051bfcc09ddSBjoern A. Zeeb 	union {
1052bfcc09ddSBjoern A. Zeeb 		struct iwl_mvm_dqa_txq_info queue_info[IWL_MAX_HW_QUEUES];
1053bfcc09ddSBjoern A. Zeeb 		struct iwl_mvm_tvqm_txq_info tvqm_info[IWL_MAX_TVQM_QUEUES];
1054bfcc09ddSBjoern A. Zeeb 	};
1055bfcc09ddSBjoern A. Zeeb 	struct work_struct add_stream_wk; /* To add streams to queues */
10569af1bba4SBjoern A. Zeeb 	spinlock_t add_stream_lock;
1057bfcc09ddSBjoern A. Zeeb 
1058bfcc09ddSBjoern A. Zeeb 	const char *nvm_file_name;
1059bfcc09ddSBjoern A. Zeeb 	struct iwl_nvm_data *nvm_data;
1060d9836fb4SBjoern A. Zeeb 	struct iwl_mei_nvm *mei_nvm_data;
1061d9836fb4SBjoern A. Zeeb 	struct iwl_mvm_csme_conn_info __rcu *csme_conn_info;
1062d9836fb4SBjoern A. Zeeb 	bool mei_rfkill_blocked;
1063d9836fb4SBjoern A. Zeeb 	bool mei_registered;
1064d9836fb4SBjoern A. Zeeb 	struct work_struct sap_connected_wk;
1065d9836fb4SBjoern A. Zeeb 
1066d9836fb4SBjoern A. Zeeb 	/*
1067d9836fb4SBjoern A. Zeeb 	 * NVM built based on the SAP data but that we can't free even after
1068d9836fb4SBjoern A. Zeeb 	 * we get ownership because it contains the cfg80211's channel.
1069d9836fb4SBjoern A. Zeeb 	 */
1070d9836fb4SBjoern A. Zeeb 	struct iwl_nvm_data *temp_nvm_data;
1071d9836fb4SBjoern A. Zeeb 
1072bfcc09ddSBjoern A. Zeeb 	/* NVM sections */
1073bfcc09ddSBjoern A. Zeeb 	struct iwl_nvm_section nvm_sections[NVM_MAX_NUM_SECTIONS];
1074bfcc09ddSBjoern A. Zeeb 
1075bfcc09ddSBjoern A. Zeeb 	struct iwl_fw_runtime fwrt;
1076bfcc09ddSBjoern A. Zeeb 
1077bfcc09ddSBjoern A. Zeeb 	/* EEPROM MAC addresses */
1078bfcc09ddSBjoern A. Zeeb 	struct mac_address addresses[IWL_MVM_MAX_ADDRESSES];
1079bfcc09ddSBjoern A. Zeeb 
1080bfcc09ddSBjoern A. Zeeb 	/* data related to data path */
1081bfcc09ddSBjoern A. Zeeb 	struct iwl_rx_phy_info last_phy_info;
1082bfcc09ddSBjoern A. Zeeb 	struct ieee80211_sta __rcu *fw_id_to_mac_id[IWL_MVM_STATION_COUNT_MAX];
10839af1bba4SBjoern A. Zeeb 	struct ieee80211_link_sta __rcu *fw_id_to_link_sta[IWL_MVM_STATION_COUNT_MAX];
1084bfcc09ddSBjoern A. Zeeb 	u8 rx_ba_sessions;
1085bfcc09ddSBjoern A. Zeeb 
1086bfcc09ddSBjoern A. Zeeb 	/* configured by mac80211 */
1087bfcc09ddSBjoern A. Zeeb 	u32 rts_threshold;
1088bfcc09ddSBjoern A. Zeeb 
1089bfcc09ddSBjoern A. Zeeb 	/* Scan status, cmd (pre-allocated) and auxiliary station */
1090bfcc09ddSBjoern A. Zeeb 	unsigned int scan_status;
10919af1bba4SBjoern A. Zeeb 	size_t scan_cmd_size;
1092bfcc09ddSBjoern A. Zeeb 	void *scan_cmd;
1093bfcc09ddSBjoern A. Zeeb 	struct iwl_mcast_filter_cmd *mcast_filter_cmd;
1094bfcc09ddSBjoern A. Zeeb 	/* For CDB this is low band scan type, for non-CDB - type. */
1095bfcc09ddSBjoern A. Zeeb 	enum iwl_mvm_scan_type scan_type;
1096bfcc09ddSBjoern A. Zeeb 	enum iwl_mvm_scan_type hb_scan_type;
1097bfcc09ddSBjoern A. Zeeb 
1098bfcc09ddSBjoern A. Zeeb 	enum iwl_mvm_sched_scan_pass_all_states sched_scan_pass_all;
1099bfcc09ddSBjoern A. Zeeb 	struct delayed_work scan_timeout_dwork;
1100bfcc09ddSBjoern A. Zeeb 
1101bfcc09ddSBjoern A. Zeeb 	/* max number of simultaneous scans the FW supports */
1102bfcc09ddSBjoern A. Zeeb 	unsigned int max_scans;
1103bfcc09ddSBjoern A. Zeeb 
1104bfcc09ddSBjoern A. Zeeb 	/* UMAC scan tracking */
1105*a4128aadSBjoern A. Zeeb 	u32 scan_uid_status[IWL_MAX_UMAC_SCANS];
1106bfcc09ddSBjoern A. Zeeb 
1107bfcc09ddSBjoern A. Zeeb 	/* start time of last scan in TSF of the mac that requested the scan */
1108bfcc09ddSBjoern A. Zeeb 	u64 scan_start;
1109bfcc09ddSBjoern A. Zeeb 
1110bfcc09ddSBjoern A. Zeeb 	/* the vif that requested the current scan */
1111bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm_vif *scan_vif;
1112*a4128aadSBjoern A. Zeeb 	u8 scan_link_id;
1113bfcc09ddSBjoern A. Zeeb 
1114bfcc09ddSBjoern A. Zeeb 	/* rx chain antennas set through debugfs for the scan command */
1115bfcc09ddSBjoern A. Zeeb 	u8 scan_rx_ant;
1116bfcc09ddSBjoern A. Zeeb 
1117bfcc09ddSBjoern A. Zeeb 	/* Internal station */
1118bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm_int_sta aux_sta;
1119bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm_int_sta snif_sta;
1120bfcc09ddSBjoern A. Zeeb 
1121bfcc09ddSBjoern A. Zeeb 	bool last_ebs_successful;
1122bfcc09ddSBjoern A. Zeeb 
1123bfcc09ddSBjoern A. Zeeb 	u8 scan_last_antenna_idx; /* to toggle TX between antennas */
1124bfcc09ddSBjoern A. Zeeb 	u8 mgmt_last_antenna_idx;
1125bfcc09ddSBjoern A. Zeeb 
1126*a4128aadSBjoern A. Zeeb 	u8 set_tx_ant;
1127*a4128aadSBjoern A. Zeeb 	u8 set_rx_ant;
1128*a4128aadSBjoern A. Zeeb 
1129bfcc09ddSBjoern A. Zeeb 	/* last smart fifo state that was successfully sent to firmware */
1130bfcc09ddSBjoern A. Zeeb 	enum iwl_sf_state sf_state;
1131bfcc09ddSBjoern A. Zeeb 
1132bfcc09ddSBjoern A. Zeeb 	/*
1133bfcc09ddSBjoern A. Zeeb 	 * Leave this pointer outside the ifdef below so that it can be
1134bfcc09ddSBjoern A. Zeeb 	 * assigned without ifdef in the source code.
1135bfcc09ddSBjoern A. Zeeb 	 */
1136bfcc09ddSBjoern A. Zeeb 	struct dentry *debugfs_dir;
1137bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_IWLWIFI_DEBUGFS
1138bfcc09ddSBjoern A. Zeeb 	u32 dbgfs_sram_offset, dbgfs_sram_len;
1139bfcc09ddSBjoern A. Zeeb 	u32 dbgfs_prph_reg_addr;
1140bfcc09ddSBjoern A. Zeeb 	bool disable_power_off;
1141bfcc09ddSBjoern A. Zeeb 	bool disable_power_off_d3;
1142bfcc09ddSBjoern A. Zeeb 	bool beacon_inject_active;
1143bfcc09ddSBjoern A. Zeeb 
1144bfcc09ddSBjoern A. Zeeb 	bool scan_iter_notif_enabled;
1145bfcc09ddSBjoern A. Zeeb 
1146bfcc09ddSBjoern A. Zeeb 	struct debugfs_blob_wrapper nvm_hw_blob;
1147bfcc09ddSBjoern A. Zeeb 	struct debugfs_blob_wrapper nvm_sw_blob;
1148bfcc09ddSBjoern A. Zeeb 	struct debugfs_blob_wrapper nvm_calib_blob;
1149bfcc09ddSBjoern A. Zeeb 	struct debugfs_blob_wrapper nvm_prod_blob;
1150bfcc09ddSBjoern A. Zeeb 	struct debugfs_blob_wrapper nvm_phy_sku_blob;
1151bfcc09ddSBjoern A. Zeeb 	struct debugfs_blob_wrapper nvm_reg_blob;
1152bfcc09ddSBjoern A. Zeeb 
1153bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm_frame_stats drv_rx_stats;
1154bfcc09ddSBjoern A. Zeeb 	spinlock_t drv_stats_lock;
1155bfcc09ddSBjoern A. Zeeb 	u16 dbgfs_rx_phyinfo;
1156bfcc09ddSBjoern A. Zeeb #endif
1157bfcc09ddSBjoern A. Zeeb 
1158bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm_phy_ctxt phy_ctxts[NUM_PHY_CTX];
1159bfcc09ddSBjoern A. Zeeb 
1160bfcc09ddSBjoern A. Zeeb 	struct list_head time_event_list;
1161bfcc09ddSBjoern A. Zeeb 	spinlock_t time_event_lock;
1162bfcc09ddSBjoern A. Zeeb 
1163bfcc09ddSBjoern A. Zeeb 	/*
1164bfcc09ddSBjoern A. Zeeb 	 * A bitmap indicating the index of the key in use. The firmware
1165bfcc09ddSBjoern A. Zeeb 	 * can hold 16 keys at most. Reflect this fact.
1166bfcc09ddSBjoern A. Zeeb 	 */
1167bfcc09ddSBjoern A. Zeeb 	unsigned long fw_key_table[BITS_TO_LONGS(STA_KEY_MAX_NUM)];
1168bfcc09ddSBjoern A. Zeeb 	u8 fw_key_deleted[STA_KEY_MAX_NUM];
1169bfcc09ddSBjoern A. Zeeb 
1170bfcc09ddSBjoern A. Zeeb 	struct ieee80211_vif __rcu *vif_id_to_mac[NUM_MAC_INDEX_DRIVER];
1171bfcc09ddSBjoern A. Zeeb 
11729af1bba4SBjoern A. Zeeb 	struct ieee80211_bss_conf __rcu *link_id_to_link_conf[IWL_MVM_FW_MAX_LINK_ID + 1];
11739af1bba4SBjoern A. Zeeb 
1174bfcc09ddSBjoern A. Zeeb 	/* -1 for always, 0 for never, >0 for that many times */
1175bfcc09ddSBjoern A. Zeeb 	s8 fw_restart;
1176bfcc09ddSBjoern A. Zeeb 	u8 *error_recovery_buf;
1177bfcc09ddSBjoern A. Zeeb 
1178bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_IWLWIFI_LEDS
1179bfcc09ddSBjoern A. Zeeb 	struct led_classdev led;
1180bfcc09ddSBjoern A. Zeeb #endif
1181bfcc09ddSBjoern A. Zeeb 
1182bfcc09ddSBjoern A. Zeeb 	struct ieee80211_vif *p2p_device_vif;
1183bfcc09ddSBjoern A. Zeeb 
1184bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_PM
1185bfcc09ddSBjoern A. Zeeb 	struct wiphy_wowlan_support wowlan;
1186bfcc09ddSBjoern A. Zeeb 	int gtk_ivlen, gtk_icvlen, ptk_ivlen, ptk_icvlen;
1187bfcc09ddSBjoern A. Zeeb 
1188bfcc09ddSBjoern A. Zeeb 	/* sched scan settings for net detect */
1189bfcc09ddSBjoern A. Zeeb 	struct ieee80211_scan_ies nd_ies;
1190bfcc09ddSBjoern A. Zeeb 	struct cfg80211_match_set *nd_match_sets;
1191bfcc09ddSBjoern A. Zeeb 	int n_nd_match_sets;
1192bfcc09ddSBjoern A. Zeeb 	struct ieee80211_channel **nd_channels;
1193bfcc09ddSBjoern A. Zeeb 	int n_nd_channels;
1194bfcc09ddSBjoern A. Zeeb 	bool net_detect;
1195*a4128aadSBjoern A. Zeeb 	bool fast_resume;
1196bfcc09ddSBjoern A. Zeeb 	u8 offload_tid;
1197bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_IWLWIFI_DEBUGFS
1198bfcc09ddSBjoern A. Zeeb 	bool d3_wake_sysassert;
1199bfcc09ddSBjoern A. Zeeb 	bool d3_test_active;
1200bfcc09ddSBjoern A. Zeeb 	u32 d3_test_pme_ptr;
1201bfcc09ddSBjoern A. Zeeb 	struct ieee80211_vif *keep_vif;
1202bfcc09ddSBjoern A. Zeeb 	u32 last_netdetect_scans; /* no. of scans in the last net-detect wake */
1203bfcc09ddSBjoern A. Zeeb #endif
1204bfcc09ddSBjoern A. Zeeb #endif
1205bfcc09ddSBjoern A. Zeeb 
1206bfcc09ddSBjoern A. Zeeb 	wait_queue_head_t rx_sync_waitq;
1207bfcc09ddSBjoern A. Zeeb 
1208bfcc09ddSBjoern A. Zeeb 	/* BT-Coex */
1209bfcc09ddSBjoern A. Zeeb 	struct iwl_bt_coex_profile_notif last_bt_notif;
1210bfcc09ddSBjoern A. Zeeb 	struct iwl_bt_coex_ci_cmd last_bt_ci_cmd;
1211bfcc09ddSBjoern A. Zeeb 
1212bfcc09ddSBjoern A. Zeeb 	u8 bt_tx_prio;
1213bfcc09ddSBjoern A. Zeeb 	enum iwl_bt_force_ant_mode bt_force_ant_mode;
1214bfcc09ddSBjoern A. Zeeb 
1215bfcc09ddSBjoern A. Zeeb 	/* Aux ROC */
1216bfcc09ddSBjoern A. Zeeb 	struct list_head aux_roc_te_list;
1217bfcc09ddSBjoern A. Zeeb 
1218bfcc09ddSBjoern A. Zeeb 	/* Thermal Throttling and CTkill */
1219bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm_tt_mgmt thermal_throttle;
1220bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_THERMAL
1221bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm_thermal_device tz_device;
1222bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm_cooling_device cooling_dev;
1223bfcc09ddSBjoern A. Zeeb #endif
1224bfcc09ddSBjoern A. Zeeb 
1225bfcc09ddSBjoern A. Zeeb 	s32 temperature;	/* Celsius */
1226bfcc09ddSBjoern A. Zeeb 	/*
1227bfcc09ddSBjoern A. Zeeb 	 * Debug option to set the NIC temperature. This option makes the
1228bfcc09ddSBjoern A. Zeeb 	 * driver think this is the actual NIC temperature, and ignore the
1229bfcc09ddSBjoern A. Zeeb 	 * real temperature that is received from the fw
1230bfcc09ddSBjoern A. Zeeb 	 */
1231bfcc09ddSBjoern A. Zeeb 	bool temperature_test;  /* Debug test temperature is enabled */
1232bfcc09ddSBjoern A. Zeeb 
1233bfcc09ddSBjoern A. Zeeb 	bool fw_static_smps_request;
1234bfcc09ddSBjoern A. Zeeb 
1235bfcc09ddSBjoern A. Zeeb 	unsigned long bt_coex_last_tcm_ts;
1236bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm_tcm tcm;
1237bfcc09ddSBjoern A. Zeeb 
1238bfcc09ddSBjoern A. Zeeb 	u8 uapsd_noagg_bssid_write_idx;
1239bfcc09ddSBjoern A. Zeeb 	struct mac_address uapsd_noagg_bssids[IWL_MVM_UAPSD_NOAGG_BSSIDS_NUM]
1240bfcc09ddSBjoern A. Zeeb 		__aligned(2);
1241bfcc09ddSBjoern A. Zeeb 
1242bfcc09ddSBjoern A. Zeeb 	struct iwl_time_quota_cmd last_quota_cmd;
1243bfcc09ddSBjoern A. Zeeb 
1244bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_NL80211_TESTMODE
1245bfcc09ddSBjoern A. Zeeb 	u32 noa_duration;
1246bfcc09ddSBjoern A. Zeeb 	struct ieee80211_vif *noa_vif;
1247bfcc09ddSBjoern A. Zeeb #endif
1248bfcc09ddSBjoern A. Zeeb 
1249bfcc09ddSBjoern A. Zeeb 	/* Tx queues */
1250bfcc09ddSBjoern A. Zeeb 	u16 aux_queue;
1251bfcc09ddSBjoern A. Zeeb 	u16 snif_queue;
1252bfcc09ddSBjoern A. Zeeb 	u16 probe_queue;
1253bfcc09ddSBjoern A. Zeeb 	u16 p2p_dev_queue;
1254bfcc09ddSBjoern A. Zeeb 
1255bfcc09ddSBjoern A. Zeeb 	/* Indicate if device power save is allowed */
1256bfcc09ddSBjoern A. Zeeb 	u8 ps_disabled; /* u8 instead of bool to ease debugfs_create_* usage */
1257bfcc09ddSBjoern A. Zeeb 	/* Indicate if 32Khz external clock is valid */
1258bfcc09ddSBjoern A. Zeeb 	u32 ext_clock_valid;
1259bfcc09ddSBjoern A. Zeeb 
1260d9836fb4SBjoern A. Zeeb 	/* This vif used by CSME to send / receive traffic */
1261d9836fb4SBjoern A. Zeeb 	struct ieee80211_vif *csme_vif;
1262bfcc09ddSBjoern A. Zeeb 	struct ieee80211_vif __rcu *csa_vif;
1263bfcc09ddSBjoern A. Zeeb 	struct ieee80211_vif __rcu *csa_tx_blocked_vif;
1264bfcc09ddSBjoern A. Zeeb 	u8 csa_tx_block_bcn_timeout;
1265bfcc09ddSBjoern A. Zeeb 
1266bfcc09ddSBjoern A. Zeeb 	/* system time of last beacon (for AP/GO interface) */
1267bfcc09ddSBjoern A. Zeeb 	u32 ap_last_beacon_gp2;
1268bfcc09ddSBjoern A. Zeeb 
1269bfcc09ddSBjoern A. Zeeb 	/* indicates that we transmitted the last beacon */
1270bfcc09ddSBjoern A. Zeeb 	bool ibss_manager;
1271bfcc09ddSBjoern A. Zeeb 
1272bfcc09ddSBjoern A. Zeeb 	bool lar_regdom_set;
1273bfcc09ddSBjoern A. Zeeb 	enum iwl_mcc_source mcc_src;
1274bfcc09ddSBjoern A. Zeeb 
1275bfcc09ddSBjoern A. Zeeb 	/* TDLS channel switch data */
1276bfcc09ddSBjoern A. Zeeb 	struct {
1277bfcc09ddSBjoern A. Zeeb 		struct delayed_work dwork;
1278bfcc09ddSBjoern A. Zeeb 		enum iwl_mvm_tdls_cs_state state;
1279bfcc09ddSBjoern A. Zeeb 
1280bfcc09ddSBjoern A. Zeeb 		/*
1281bfcc09ddSBjoern A. Zeeb 		 * Current cs sta - might be different from periodic cs peer
1282bfcc09ddSBjoern A. Zeeb 		 * station. Value is meaningless when the cs-state is idle.
1283bfcc09ddSBjoern A. Zeeb 		 */
1284bfcc09ddSBjoern A. Zeeb 		u8 cur_sta_id;
1285bfcc09ddSBjoern A. Zeeb 
1286bfcc09ddSBjoern A. Zeeb 		/* TDLS periodic channel-switch peer */
1287bfcc09ddSBjoern A. Zeeb 		struct {
1288bfcc09ddSBjoern A. Zeeb 			u8 sta_id;
1289bfcc09ddSBjoern A. Zeeb 			u8 op_class;
1290bfcc09ddSBjoern A. Zeeb 			bool initiator; /* are we the link initiator */
1291bfcc09ddSBjoern A. Zeeb 			struct cfg80211_chan_def chandef;
1292bfcc09ddSBjoern A. Zeeb 			struct sk_buff *skb; /* ch sw template */
1293bfcc09ddSBjoern A. Zeeb 			u32 ch_sw_tm_ie;
1294bfcc09ddSBjoern A. Zeeb 
1295bfcc09ddSBjoern A. Zeeb 			/* timestamp of last ch-sw request sent (GP2 time) */
1296bfcc09ddSBjoern A. Zeeb 			u32 sent_timestamp;
1297bfcc09ddSBjoern A. Zeeb 		} peer;
1298bfcc09ddSBjoern A. Zeeb 	} tdls_cs;
1299bfcc09ddSBjoern A. Zeeb 
1300bfcc09ddSBjoern A. Zeeb 
1301bfcc09ddSBjoern A. Zeeb 	u32 ciphers[IWL_MVM_NUM_CIPHERS];
1302bfcc09ddSBjoern A. Zeeb 
1303bfcc09ddSBjoern A. Zeeb 	struct cfg80211_ftm_responder_stats ftm_resp_stats;
1304bfcc09ddSBjoern A. Zeeb 	struct {
1305bfcc09ddSBjoern A. Zeeb 		struct cfg80211_pmsr_request *req;
1306bfcc09ddSBjoern A. Zeeb 		struct wireless_dev *req_wdev;
1307bfcc09ddSBjoern A. Zeeb 		struct list_head loc_list;
1308bfcc09ddSBjoern A. Zeeb 		int responses[IWL_MVM_TOF_MAX_APS];
1309bfcc09ddSBjoern A. Zeeb 		struct {
1310bfcc09ddSBjoern A. Zeeb 			struct list_head resp;
1311bfcc09ddSBjoern A. Zeeb 		} smooth;
1312bfcc09ddSBjoern A. Zeeb 		struct list_head pasn_list;
1313bfcc09ddSBjoern A. Zeeb 	} ftm_initiator;
1314bfcc09ddSBjoern A. Zeeb 
1315bfcc09ddSBjoern A. Zeeb 	struct list_head resp_pasn_list;
1316bfcc09ddSBjoern A. Zeeb 
13179af1bba4SBjoern A. Zeeb 	struct ptp_data ptp_data;
13189af1bba4SBjoern A. Zeeb 
1319bfcc09ddSBjoern A. Zeeb 	struct {
1320bfcc09ddSBjoern A. Zeeb 		u8 range_resp;
1321bfcc09ddSBjoern A. Zeeb 	} cmd_ver;
1322bfcc09ddSBjoern A. Zeeb 
1323bfcc09ddSBjoern A. Zeeb 	struct ieee80211_vif *nan_vif;
1324bfcc09ddSBjoern A. Zeeb 	struct iwl_mvm_baid_data __rcu *baid_map[IWL_MAX_BAID];
1325bfcc09ddSBjoern A. Zeeb 
1326bfcc09ddSBjoern A. Zeeb 	/*
1327bfcc09ddSBjoern A. Zeeb 	 * Drop beacons from other APs in AP mode when there are no connected
1328bfcc09ddSBjoern A. Zeeb 	 * clients.
1329bfcc09ddSBjoern A. Zeeb 	 */
1330bfcc09ddSBjoern A. Zeeb 	bool drop_bcn_ap_mode;
1331bfcc09ddSBjoern A. Zeeb 
1332bfcc09ddSBjoern A. Zeeb 	struct delayed_work cs_tx_unblock_dwork;
1333bfcc09ddSBjoern A. Zeeb 
1334bfcc09ddSBjoern A. Zeeb 	/* does a monitor vif exist (only one can exist hence bool) */
1335bfcc09ddSBjoern A. Zeeb 	bool monitor_on;
13369af1bba4SBjoern A. Zeeb 	/*
13379af1bba4SBjoern A. Zeeb 	 * primary channel position relative to he whole bandwidth,
13389af1bba4SBjoern A. Zeeb 	 * in steps of 80 MHz
13399af1bba4SBjoern A. Zeeb 	 */
13409af1bba4SBjoern A. Zeeb 	u8 monitor_p80;
1341bfcc09ddSBjoern A. Zeeb 
1342bfcc09ddSBjoern A. Zeeb 	/* sniffer data to include in radiotap */
1343bfcc09ddSBjoern A. Zeeb 	__le16 cur_aid;
1344bfcc09ddSBjoern A. Zeeb 	u8 cur_bssid[ETH_ALEN];
1345bfcc09ddSBjoern A. Zeeb 
13469af1bba4SBjoern A. Zeeb #ifdef CONFIG_ACPI
13479af1bba4SBjoern A. Zeeb 	struct iwl_phy_specific_cfg phy_filters;
13489af1bba4SBjoern A. Zeeb #endif
13499af1bba4SBjoern A. Zeeb 
1350*a4128aadSBjoern A. Zeeb 	/* report rx timestamp in ptp clock time */
1351*a4128aadSBjoern A. Zeeb 	bool rx_ts_ptp;
1352*a4128aadSBjoern A. Zeeb 
1353bfcc09ddSBjoern A. Zeeb 	unsigned long last_6ghz_passive_scan_jiffies;
1354bfcc09ddSBjoern A. Zeeb 	unsigned long last_reset_or_resume_time_jiffies;
1355d9836fb4SBjoern A. Zeeb 
1356d9836fb4SBjoern A. Zeeb 	bool sta_remove_requires_queue_remove;
13579af1bba4SBjoern A. Zeeb 	bool mld_api_is_used;
13589af1bba4SBjoern A. Zeeb 
1359*a4128aadSBjoern A. Zeeb 	/*
1360*a4128aadSBjoern A. Zeeb 	 * Indicates that firmware will do a product reset (and then
1361*a4128aadSBjoern A. Zeeb 	 * therefore fail to load) when we start it (due to OTP burn),
1362*a4128aadSBjoern A. Zeeb 	 * if so don't dump errors etc. since this is expected.
1363*a4128aadSBjoern A. Zeeb 	 */
1364*a4128aadSBjoern A. Zeeb 	bool fw_product_reset;
13659af1bba4SBjoern A. Zeeb 
13669af1bba4SBjoern A. Zeeb 	struct iwl_time_sync_data time_sync;
13679af1bba4SBjoern A. Zeeb 
13689af1bba4SBjoern A. Zeeb 	struct iwl_mei_scan_filter mei_scan_filter;
1369*a4128aadSBjoern A. Zeeb 
1370*a4128aadSBjoern A. Zeeb 	struct iwl_mvm_acs_survey *acs_survey;
1371*a4128aadSBjoern A. Zeeb 
1372*a4128aadSBjoern A. Zeeb 	bool statistics_clear;
1373bfcc09ddSBjoern A. Zeeb };
1374bfcc09ddSBjoern A. Zeeb 
1375bfcc09ddSBjoern A. Zeeb /* Extract MVM priv from op_mode and _hw */
1376bfcc09ddSBjoern A. Zeeb #define IWL_OP_MODE_GET_MVM(_iwl_op_mode)		\
1377bfcc09ddSBjoern A. Zeeb 	((struct iwl_mvm *)(_iwl_op_mode)->op_mode_specific)
1378bfcc09ddSBjoern A. Zeeb 
1379bfcc09ddSBjoern A. Zeeb #define IWL_MAC80211_GET_MVM(_hw)			\
1380bfcc09ddSBjoern A. Zeeb 	IWL_OP_MODE_GET_MVM((struct iwl_op_mode *)((_hw)->priv))
1381bfcc09ddSBjoern A. Zeeb 
1382*a4128aadSBjoern A. Zeeb DEFINE_GUARD(mvm, struct iwl_mvm *, mutex_lock(&_T->mutex), mutex_unlock(&_T->mutex))
1383*a4128aadSBjoern A. Zeeb 
1384bfcc09ddSBjoern A. Zeeb /**
1385bfcc09ddSBjoern A. Zeeb  * enum iwl_mvm_status - MVM status bits
1386bfcc09ddSBjoern A. Zeeb  * @IWL_MVM_STATUS_HW_RFKILL: HW RF-kill is asserted
1387bfcc09ddSBjoern A. Zeeb  * @IWL_MVM_STATUS_HW_CTKILL: CT-kill is active
1388*a4128aadSBjoern A. Zeeb  * @IWL_MVM_STATUS_ROC_P2P_RUNNING: remain-on-channel on P2P is running (when
1389*a4128aadSBjoern A. Zeeb  *	P2P is not over AUX)
1390bfcc09ddSBjoern A. Zeeb  * @IWL_MVM_STATUS_HW_RESTART_REQUESTED: HW restart was requested
1391bfcc09ddSBjoern A. Zeeb  * @IWL_MVM_STATUS_IN_HW_RESTART: HW restart is active
1392bfcc09ddSBjoern A. Zeeb  * @IWL_MVM_STATUS_ROC_AUX_RUNNING: AUX remain-on-channel is running
1393bfcc09ddSBjoern A. Zeeb  * @IWL_MVM_STATUS_FIRMWARE_RUNNING: firmware is running
1394bfcc09ddSBjoern A. Zeeb  * @IWL_MVM_STATUS_IN_D3: in D3 (or at least about to go into it)
1395d9836fb4SBjoern A. Zeeb  * @IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE: suppress one error log
1396d9836fb4SBjoern A. Zeeb  *	if this is set, when intentionally triggered
1397d9836fb4SBjoern A. Zeeb  * @IWL_MVM_STATUS_STARTING: starting mac,
1398d9836fb4SBjoern A. Zeeb  *	used to disable restart flow while in STARTING state
1399bfcc09ddSBjoern A. Zeeb  */
1400bfcc09ddSBjoern A. Zeeb enum iwl_mvm_status {
1401bfcc09ddSBjoern A. Zeeb 	IWL_MVM_STATUS_HW_RFKILL,
1402bfcc09ddSBjoern A. Zeeb 	IWL_MVM_STATUS_HW_CTKILL,
1403*a4128aadSBjoern A. Zeeb 	IWL_MVM_STATUS_ROC_P2P_RUNNING,
1404bfcc09ddSBjoern A. Zeeb 	IWL_MVM_STATUS_HW_RESTART_REQUESTED,
1405bfcc09ddSBjoern A. Zeeb 	IWL_MVM_STATUS_IN_HW_RESTART,
1406bfcc09ddSBjoern A. Zeeb 	IWL_MVM_STATUS_ROC_AUX_RUNNING,
1407bfcc09ddSBjoern A. Zeeb 	IWL_MVM_STATUS_FIRMWARE_RUNNING,
1408bfcc09ddSBjoern A. Zeeb 	IWL_MVM_STATUS_IN_D3,
1409d9836fb4SBjoern A. Zeeb 	IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE,
1410d9836fb4SBjoern A. Zeeb 	IWL_MVM_STATUS_STARTING,
1411d9836fb4SBjoern A. Zeeb };
1412d9836fb4SBjoern A. Zeeb 
1413d9836fb4SBjoern A. Zeeb struct iwl_mvm_csme_conn_info {
1414d9836fb4SBjoern A. Zeeb 	struct rcu_head rcu_head;
1415d9836fb4SBjoern A. Zeeb 	struct iwl_mei_conn_info conn_info;
1416bfcc09ddSBjoern A. Zeeb };
1417bfcc09ddSBjoern A. Zeeb 
1418bfcc09ddSBjoern A. Zeeb /* Keep track of completed init configuration */
1419bfcc09ddSBjoern A. Zeeb enum iwl_mvm_init_status {
1420bfcc09ddSBjoern A. Zeeb 	IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE = BIT(0),
1421bfcc09ddSBjoern A. Zeeb 	IWL_MVM_INIT_STATUS_LEDS_INIT_COMPLETE = BIT(1),
1422bfcc09ddSBjoern A. Zeeb };
1423bfcc09ddSBjoern A. Zeeb 
1424bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm)
1425bfcc09ddSBjoern A. Zeeb {
1426bfcc09ddSBjoern A. Zeeb 	return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status) ||
1427bfcc09ddSBjoern A. Zeeb 	       test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status);
1428bfcc09ddSBjoern A. Zeeb }
1429bfcc09ddSBjoern A. Zeeb 
1430bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_radio_hw_killed(struct iwl_mvm *mvm)
1431bfcc09ddSBjoern A. Zeeb {
1432bfcc09ddSBjoern A. Zeeb 	return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status);
1433bfcc09ddSBjoern A. Zeeb }
1434bfcc09ddSBjoern A. Zeeb 
1435bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_firmware_running(struct iwl_mvm *mvm)
1436bfcc09ddSBjoern A. Zeeb {
1437bfcc09ddSBjoern A. Zeeb 	return test_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
1438bfcc09ddSBjoern A. Zeeb }
1439bfcc09ddSBjoern A. Zeeb 
1440bfcc09ddSBjoern A. Zeeb /* Must be called with rcu_read_lock() held and it can only be
1441bfcc09ddSBjoern A. Zeeb  * released when mvmsta is not needed anymore.
1442bfcc09ddSBjoern A. Zeeb  */
1443bfcc09ddSBjoern A. Zeeb static inline struct iwl_mvm_sta *
1444bfcc09ddSBjoern A. Zeeb iwl_mvm_sta_from_staid_rcu(struct iwl_mvm *mvm, u8 sta_id)
1445bfcc09ddSBjoern A. Zeeb {
1446bfcc09ddSBjoern A. Zeeb 	struct ieee80211_sta *sta;
1447bfcc09ddSBjoern A. Zeeb 
1448bfcc09ddSBjoern A. Zeeb 	if (sta_id >= mvm->fw->ucode_capa.num_stations)
1449bfcc09ddSBjoern A. Zeeb 		return NULL;
1450bfcc09ddSBjoern A. Zeeb 
1451bfcc09ddSBjoern A. Zeeb 	sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
1452bfcc09ddSBjoern A. Zeeb 
1453bfcc09ddSBjoern A. Zeeb 	/* This can happen if the station has been removed right now */
1454bfcc09ddSBjoern A. Zeeb 	if (IS_ERR_OR_NULL(sta))
1455bfcc09ddSBjoern A. Zeeb 		return NULL;
1456bfcc09ddSBjoern A. Zeeb 
1457bfcc09ddSBjoern A. Zeeb 	return iwl_mvm_sta_from_mac80211(sta);
1458bfcc09ddSBjoern A. Zeeb }
1459bfcc09ddSBjoern A. Zeeb 
1460bfcc09ddSBjoern A. Zeeb static inline struct iwl_mvm_sta *
1461bfcc09ddSBjoern A. Zeeb iwl_mvm_sta_from_staid_protected(struct iwl_mvm *mvm, u8 sta_id)
1462bfcc09ddSBjoern A. Zeeb {
1463bfcc09ddSBjoern A. Zeeb 	struct ieee80211_sta *sta;
1464bfcc09ddSBjoern A. Zeeb 
1465bfcc09ddSBjoern A. Zeeb 	if (sta_id >= mvm->fw->ucode_capa.num_stations)
1466bfcc09ddSBjoern A. Zeeb 		return NULL;
1467bfcc09ddSBjoern A. Zeeb 
1468bfcc09ddSBjoern A. Zeeb 	sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
1469bfcc09ddSBjoern A. Zeeb 					lockdep_is_held(&mvm->mutex));
1470bfcc09ddSBjoern A. Zeeb 
1471bfcc09ddSBjoern A. Zeeb 	/* This can happen if the station has been removed right now */
1472bfcc09ddSBjoern A. Zeeb 	if (IS_ERR_OR_NULL(sta))
1473bfcc09ddSBjoern A. Zeeb 		return NULL;
1474bfcc09ddSBjoern A. Zeeb 
1475bfcc09ddSBjoern A. Zeeb 	return iwl_mvm_sta_from_mac80211(sta);
1476bfcc09ddSBjoern A. Zeeb }
1477bfcc09ddSBjoern A. Zeeb 
1478bfcc09ddSBjoern A. Zeeb static inline struct ieee80211_vif *
1479bfcc09ddSBjoern A. Zeeb iwl_mvm_rcu_dereference_vif_id(struct iwl_mvm *mvm, u8 vif_id, bool rcu)
1480bfcc09ddSBjoern A. Zeeb {
1481bfcc09ddSBjoern A. Zeeb 	if (WARN_ON(vif_id >= ARRAY_SIZE(mvm->vif_id_to_mac)))
1482bfcc09ddSBjoern A. Zeeb 		return NULL;
1483bfcc09ddSBjoern A. Zeeb 
1484bfcc09ddSBjoern A. Zeeb 	if (rcu)
1485bfcc09ddSBjoern A. Zeeb 		return rcu_dereference(mvm->vif_id_to_mac[vif_id]);
1486bfcc09ddSBjoern A. Zeeb 
1487bfcc09ddSBjoern A. Zeeb 	return rcu_dereference_protected(mvm->vif_id_to_mac[vif_id],
1488bfcc09ddSBjoern A. Zeeb 					 lockdep_is_held(&mvm->mutex));
1489bfcc09ddSBjoern A. Zeeb }
1490bfcc09ddSBjoern A. Zeeb 
14919af1bba4SBjoern A. Zeeb static inline struct ieee80211_bss_conf *
14929af1bba4SBjoern A. Zeeb iwl_mvm_rcu_fw_link_id_to_link_conf(struct iwl_mvm *mvm, u8 link_id, bool rcu)
14939af1bba4SBjoern A. Zeeb {
1494*a4128aadSBjoern A. Zeeb 	if (IWL_FW_CHECK(mvm, link_id >= ARRAY_SIZE(mvm->link_id_to_link_conf),
1495*a4128aadSBjoern A. Zeeb 			 "erroneous FW link ID: %d\n", link_id))
14969af1bba4SBjoern A. Zeeb 		return NULL;
14979af1bba4SBjoern A. Zeeb 
14989af1bba4SBjoern A. Zeeb 	if (rcu)
14999af1bba4SBjoern A. Zeeb 		return rcu_dereference(mvm->link_id_to_link_conf[link_id]);
15009af1bba4SBjoern A. Zeeb 
15019af1bba4SBjoern A. Zeeb 	return rcu_dereference_protected(mvm->link_id_to_link_conf[link_id],
15029af1bba4SBjoern A. Zeeb 					 lockdep_is_held(&mvm->mutex));
15039af1bba4SBjoern A. Zeeb }
15049af1bba4SBjoern A. Zeeb 
1505bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_adaptive_dwell_supported(struct iwl_mvm *mvm)
1506bfcc09ddSBjoern A. Zeeb {
1507bfcc09ddSBjoern A. Zeeb 	return fw_has_api(&mvm->fw->ucode_capa,
1508bfcc09ddSBjoern A. Zeeb 			  IWL_UCODE_TLV_API_ADAPTIVE_DWELL);
1509bfcc09ddSBjoern A. Zeeb }
1510bfcc09ddSBjoern A. Zeeb 
1511bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_adaptive_dwell_v2_supported(struct iwl_mvm *mvm)
1512bfcc09ddSBjoern A. Zeeb {
1513bfcc09ddSBjoern A. Zeeb 	return fw_has_api(&mvm->fw->ucode_capa,
1514bfcc09ddSBjoern A. Zeeb 			  IWL_UCODE_TLV_API_ADAPTIVE_DWELL_V2);
1515bfcc09ddSBjoern A. Zeeb }
1516bfcc09ddSBjoern A. Zeeb 
1517bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_adwell_hb_ap_num_supported(struct iwl_mvm *mvm)
1518bfcc09ddSBjoern A. Zeeb {
1519bfcc09ddSBjoern A. Zeeb 	return fw_has_api(&mvm->fw->ucode_capa,
1520bfcc09ddSBjoern A. Zeeb 			  IWL_UCODE_TLV_API_ADWELL_HB_DEF_N_AP);
1521bfcc09ddSBjoern A. Zeeb }
1522bfcc09ddSBjoern A. Zeeb 
1523bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_oce_supported(struct iwl_mvm *mvm)
1524bfcc09ddSBjoern A. Zeeb {
1525bfcc09ddSBjoern A. Zeeb 	/* OCE should never be enabled for LMAC scan FWs */
1526bfcc09ddSBjoern A. Zeeb 	return fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_OCE);
1527bfcc09ddSBjoern A. Zeeb }
1528bfcc09ddSBjoern A. Zeeb 
1529bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_frag_ebs_supported(struct iwl_mvm *mvm)
1530bfcc09ddSBjoern A. Zeeb {
1531bfcc09ddSBjoern A. Zeeb 	return fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_FRAG_EBS);
1532bfcc09ddSBjoern A. Zeeb }
1533bfcc09ddSBjoern A. Zeeb 
1534bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_short_beacon_notif_supported(struct iwl_mvm *mvm)
1535bfcc09ddSBjoern A. Zeeb {
1536bfcc09ddSBjoern A. Zeeb 	return fw_has_api(&mvm->fw->ucode_capa,
1537bfcc09ddSBjoern A. Zeeb 			  IWL_UCODE_TLV_API_SHORT_BEACON_NOTIF);
1538bfcc09ddSBjoern A. Zeeb }
1539bfcc09ddSBjoern A. Zeeb 
1540bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_dqa_data_queue(struct iwl_mvm *mvm, u8 queue)
1541bfcc09ddSBjoern A. Zeeb {
1542bfcc09ddSBjoern A. Zeeb 	return (queue >= IWL_MVM_DQA_MIN_DATA_QUEUE) &&
1543bfcc09ddSBjoern A. Zeeb 	       (queue <= IWL_MVM_DQA_MAX_DATA_QUEUE);
1544bfcc09ddSBjoern A. Zeeb }
1545bfcc09ddSBjoern A. Zeeb 
1546bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_dqa_mgmt_queue(struct iwl_mvm *mvm, u8 queue)
1547bfcc09ddSBjoern A. Zeeb {
1548bfcc09ddSBjoern A. Zeeb 	return (queue >= IWL_MVM_DQA_MIN_MGMT_QUEUE) &&
1549bfcc09ddSBjoern A. Zeeb 	       (queue <= IWL_MVM_DQA_MAX_MGMT_QUEUE);
1550bfcc09ddSBjoern A. Zeeb }
1551bfcc09ddSBjoern A. Zeeb 
1552bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_lar_supported(struct iwl_mvm *mvm)
1553bfcc09ddSBjoern A. Zeeb {
1554bfcc09ddSBjoern A. Zeeb 	bool nvm_lar = mvm->nvm_data->lar_enabled;
1555bfcc09ddSBjoern A. Zeeb 	bool tlv_lar = fw_has_capa(&mvm->fw->ucode_capa,
1556bfcc09ddSBjoern A. Zeeb 				   IWL_UCODE_TLV_CAPA_LAR_SUPPORT);
1557bfcc09ddSBjoern A. Zeeb 
1558bfcc09ddSBjoern A. Zeeb 	/*
1559bfcc09ddSBjoern A. Zeeb 	 * Enable LAR only if it is supported by the FW (TLV) &&
1560bfcc09ddSBjoern A. Zeeb 	 * enabled in the NVM
1561bfcc09ddSBjoern A. Zeeb 	 */
1562bfcc09ddSBjoern A. Zeeb 	if (mvm->cfg->nvm_type == IWL_NVM_EXT)
1563bfcc09ddSBjoern A. Zeeb 		return nvm_lar && tlv_lar;
1564bfcc09ddSBjoern A. Zeeb 	else
1565bfcc09ddSBjoern A. Zeeb 		return tlv_lar;
1566bfcc09ddSBjoern A. Zeeb }
1567bfcc09ddSBjoern A. Zeeb 
1568bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_wifi_mcc_supported(struct iwl_mvm *mvm)
1569bfcc09ddSBjoern A. Zeeb {
1570bfcc09ddSBjoern A. Zeeb 	return fw_has_api(&mvm->fw->ucode_capa,
1571bfcc09ddSBjoern A. Zeeb 			  IWL_UCODE_TLV_API_WIFI_MCC_UPDATE) ||
1572bfcc09ddSBjoern A. Zeeb 	       fw_has_capa(&mvm->fw->ucode_capa,
1573bfcc09ddSBjoern A. Zeeb 			   IWL_UCODE_TLV_CAPA_LAR_MULTI_MCC);
1574bfcc09ddSBjoern A. Zeeb }
1575bfcc09ddSBjoern A. Zeeb 
1576bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_bt_is_rrc_supported(struct iwl_mvm *mvm)
1577bfcc09ddSBjoern A. Zeeb {
1578bfcc09ddSBjoern A. Zeeb 	return fw_has_capa(&mvm->fw->ucode_capa,
1579bfcc09ddSBjoern A. Zeeb 			   IWL_UCODE_TLV_CAPA_BT_COEX_RRC) &&
1580bfcc09ddSBjoern A. Zeeb 		IWL_MVM_BT_COEX_RRC;
1581bfcc09ddSBjoern A. Zeeb }
1582bfcc09ddSBjoern A. Zeeb 
1583bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_csum_supported(struct iwl_mvm *mvm)
1584bfcc09ddSBjoern A. Zeeb {
1585bfcc09ddSBjoern A. Zeeb 	return fw_has_capa(&mvm->fw->ucode_capa,
1586bfcc09ddSBjoern A. Zeeb 			   IWL_UCODE_TLV_CAPA_CSUM_SUPPORT) &&
1587bfcc09ddSBjoern A. Zeeb 		!IWL_MVM_HW_CSUM_DISABLE;
1588bfcc09ddSBjoern A. Zeeb }
1589bfcc09ddSBjoern A. Zeeb 
1590bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_mplut_supported(struct iwl_mvm *mvm)
1591bfcc09ddSBjoern A. Zeeb {
1592bfcc09ddSBjoern A. Zeeb 	return fw_has_capa(&mvm->fw->ucode_capa,
1593bfcc09ddSBjoern A. Zeeb 			   IWL_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT) &&
1594bfcc09ddSBjoern A. Zeeb 		IWL_MVM_BT_COEX_MPLUT;
1595bfcc09ddSBjoern A. Zeeb }
1596bfcc09ddSBjoern A. Zeeb 
1597bfcc09ddSBjoern A. Zeeb static inline
1598bfcc09ddSBjoern A. Zeeb bool iwl_mvm_is_p2p_scm_uapsd_supported(struct iwl_mvm *mvm)
1599bfcc09ddSBjoern A. Zeeb {
1600bfcc09ddSBjoern A. Zeeb 	return fw_has_capa(&mvm->fw->ucode_capa,
1601bfcc09ddSBjoern A. Zeeb 			   IWL_UCODE_TLV_CAPA_P2P_SCM_UAPSD) &&
1602bfcc09ddSBjoern A. Zeeb 		!(iwlwifi_mod_params.uapsd_disable &
1603bfcc09ddSBjoern A. Zeeb 		  IWL_DISABLE_UAPSD_P2P_CLIENT);
1604bfcc09ddSBjoern A. Zeeb }
1605bfcc09ddSBjoern A. Zeeb 
1606bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_has_new_rx_api(struct iwl_mvm *mvm)
1607bfcc09ddSBjoern A. Zeeb {
1608bfcc09ddSBjoern A. Zeeb 	return fw_has_capa(&mvm->fw->ucode_capa,
1609bfcc09ddSBjoern A. Zeeb 			   IWL_UCODE_TLV_CAPA_MULTI_QUEUE_RX_SUPPORT);
1610bfcc09ddSBjoern A. Zeeb }
1611bfcc09ddSBjoern A. Zeeb 
16129af1bba4SBjoern A. Zeeb static inline bool iwl_mvm_has_mld_api(const struct iwl_fw *fw)
16139af1bba4SBjoern A. Zeeb {
16149af1bba4SBjoern A. Zeeb 	return fw_has_capa(&fw->ucode_capa,
16159af1bba4SBjoern A. Zeeb 			   IWL_UCODE_TLV_CAPA_MLD_API_SUPPORT);
16169af1bba4SBjoern A. Zeeb }
16179af1bba4SBjoern A. Zeeb 
16189af1bba4SBjoern A. Zeeb static inline bool iwl_mvm_has_new_station_api(const struct iwl_fw *fw)
16199af1bba4SBjoern A. Zeeb {
16209af1bba4SBjoern A. Zeeb 	return iwl_mvm_has_mld_api(fw) ||
16219af1bba4SBjoern A. Zeeb 	       iwl_fw_lookup_cmd_ver(fw, ADD_STA, 0) >= 12;
16229af1bba4SBjoern A. Zeeb }
16239af1bba4SBjoern A. Zeeb 
1624bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_has_new_tx_api(struct iwl_mvm *mvm)
1625bfcc09ddSBjoern A. Zeeb {
1626bfcc09ddSBjoern A. Zeeb 	/* TODO - replace with TLV once defined */
16279af1bba4SBjoern A. Zeeb 	return mvm->trans->trans_cfg->gen2;
1628bfcc09ddSBjoern A. Zeeb }
1629bfcc09ddSBjoern A. Zeeb 
1630bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_has_unified_ucode(struct iwl_mvm *mvm)
1631bfcc09ddSBjoern A. Zeeb {
1632bfcc09ddSBjoern A. Zeeb 	/* TODO - better define this */
1633bfcc09ddSBjoern A. Zeeb 	return mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_22000;
1634bfcc09ddSBjoern A. Zeeb }
1635bfcc09ddSBjoern A. Zeeb 
1636bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_cdb_supported(struct iwl_mvm *mvm)
1637bfcc09ddSBjoern A. Zeeb {
1638bfcc09ddSBjoern A. Zeeb 	/*
1639bfcc09ddSBjoern A. Zeeb 	 * TODO:
1640bfcc09ddSBjoern A. Zeeb 	 * The issue of how to determine CDB APIs and usage is still not fully
1641bfcc09ddSBjoern A. Zeeb 	 * defined.
1642bfcc09ddSBjoern A. Zeeb 	 * There is a compilation for CDB and non-CDB FW, but there may
1643bfcc09ddSBjoern A. Zeeb 	 * be also runtime check.
1644bfcc09ddSBjoern A. Zeeb 	 * For now there is a TLV for checking compilation mode, but a
1645bfcc09ddSBjoern A. Zeeb 	 * runtime check will also have to be here - once defined.
1646bfcc09ddSBjoern A. Zeeb 	 */
1647bfcc09ddSBjoern A. Zeeb 	return fw_has_capa(&mvm->fw->ucode_capa,
1648bfcc09ddSBjoern A. Zeeb 			   IWL_UCODE_TLV_CAPA_CDB_SUPPORT);
1649bfcc09ddSBjoern A. Zeeb }
1650bfcc09ddSBjoern A. Zeeb 
1651bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_cdb_scan_api(struct iwl_mvm *mvm)
1652bfcc09ddSBjoern A. Zeeb {
1653bfcc09ddSBjoern A. Zeeb 	/*
1654bfcc09ddSBjoern A. Zeeb 	 * TODO: should this be the same as iwl_mvm_is_cdb_supported()?
1655bfcc09ddSBjoern A. Zeeb 	 * but then there's a little bit of code in scan that won't make
1656bfcc09ddSBjoern A. Zeeb 	 * any sense...
1657bfcc09ddSBjoern A. Zeeb 	 */
1658bfcc09ddSBjoern A. Zeeb 	return mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_22000;
1659bfcc09ddSBjoern A. Zeeb }
1660bfcc09ddSBjoern A. Zeeb 
1661bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_scan_ext_chan_supported(struct iwl_mvm *mvm)
1662bfcc09ddSBjoern A. Zeeb {
1663bfcc09ddSBjoern A. Zeeb 	return fw_has_api(&mvm->fw->ucode_capa,
1664bfcc09ddSBjoern A. Zeeb 			  IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER);
1665bfcc09ddSBjoern A. Zeeb }
1666bfcc09ddSBjoern A. Zeeb 
1667bfcc09ddSBjoern A. Zeeb 
1668bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_reduced_config_scan_supported(struct iwl_mvm *mvm)
1669bfcc09ddSBjoern A. Zeeb {
1670bfcc09ddSBjoern A. Zeeb 	return fw_has_api(&mvm->fw->ucode_capa,
1671bfcc09ddSBjoern A. Zeeb 			  IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG);
1672bfcc09ddSBjoern A. Zeeb }
1673bfcc09ddSBjoern A. Zeeb 
1674bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_band_in_rx_supported(struct iwl_mvm *mvm)
1675bfcc09ddSBjoern A. Zeeb {
1676bfcc09ddSBjoern A. Zeeb 	return fw_has_api(&mvm->fw->ucode_capa,
1677bfcc09ddSBjoern A. Zeeb 			   IWL_UCODE_TLV_API_BAND_IN_RX_DATA);
1678bfcc09ddSBjoern A. Zeeb }
1679bfcc09ddSBjoern A. Zeeb 
1680bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_has_new_rx_stats_api(struct iwl_mvm *mvm)
1681bfcc09ddSBjoern A. Zeeb {
1682bfcc09ddSBjoern A. Zeeb 	return fw_has_api(&mvm->fw->ucode_capa,
1683bfcc09ddSBjoern A. Zeeb 			  IWL_UCODE_TLV_API_NEW_RX_STATS);
1684bfcc09ddSBjoern A. Zeeb }
1685bfcc09ddSBjoern A. Zeeb 
1686bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_has_quota_low_latency(struct iwl_mvm *mvm)
1687bfcc09ddSBjoern A. Zeeb {
1688bfcc09ddSBjoern A. Zeeb 	return fw_has_api(&mvm->fw->ucode_capa,
1689bfcc09ddSBjoern A. Zeeb 			  IWL_UCODE_TLV_API_QUOTA_LOW_LATENCY);
1690bfcc09ddSBjoern A. Zeeb }
1691bfcc09ddSBjoern A. Zeeb 
1692*a4128aadSBjoern A. Zeeb static inline bool iwl_mvm_has_no_host_disable_tx(struct iwl_mvm *mvm)
1693*a4128aadSBjoern A. Zeeb {
1694*a4128aadSBjoern A. Zeeb 	return fw_has_api(&mvm->fw->ucode_capa,
1695*a4128aadSBjoern A. Zeeb 			  IWL_UCODE_TLV_API_NO_HOST_DISABLE_TX);
1696*a4128aadSBjoern A. Zeeb }
1697*a4128aadSBjoern A. Zeeb 
1698bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_has_tlc_offload(const struct iwl_mvm *mvm)
1699bfcc09ddSBjoern A. Zeeb {
1700bfcc09ddSBjoern A. Zeeb 	return fw_has_capa(&mvm->fw->ucode_capa,
1701bfcc09ddSBjoern A. Zeeb 			   IWL_UCODE_TLV_CAPA_TLC_OFFLOAD);
1702bfcc09ddSBjoern A. Zeeb }
1703bfcc09ddSBjoern A. Zeeb 
1704bfcc09ddSBjoern A. Zeeb static inline struct agg_tx_status *
1705bfcc09ddSBjoern A. Zeeb iwl_mvm_get_agg_status(struct iwl_mvm *mvm, void *tx_resp)
1706bfcc09ddSBjoern A. Zeeb {
1707bfcc09ddSBjoern A. Zeeb 	if (iwl_mvm_has_new_tx_api(mvm))
1708bfcc09ddSBjoern A. Zeeb 		return &((struct iwl_mvm_tx_resp *)tx_resp)->status;
1709bfcc09ddSBjoern A. Zeeb 	else
1710bfcc09ddSBjoern A. Zeeb 		return ((struct iwl_mvm_tx_resp_v3 *)tx_resp)->status;
1711bfcc09ddSBjoern A. Zeeb }
1712bfcc09ddSBjoern A. Zeeb 
1713bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_tt_in_fw(struct iwl_mvm *mvm)
1714bfcc09ddSBjoern A. Zeeb {
1715bfcc09ddSBjoern A. Zeeb 	/* these two TLV are redundant since the responsibility to CT-kill by
1716bfcc09ddSBjoern A. Zeeb 	 * FW happens only after we send at least one command of
1717bfcc09ddSBjoern A. Zeeb 	 * temperature THs report.
1718bfcc09ddSBjoern A. Zeeb 	 */
1719bfcc09ddSBjoern A. Zeeb 	return fw_has_capa(&mvm->fw->ucode_capa,
1720bfcc09ddSBjoern A. Zeeb 			   IWL_UCODE_TLV_CAPA_CT_KILL_BY_FW) &&
1721bfcc09ddSBjoern A. Zeeb 	       fw_has_capa(&mvm->fw->ucode_capa,
1722bfcc09ddSBjoern A. Zeeb 			   IWL_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT);
1723bfcc09ddSBjoern A. Zeeb }
1724bfcc09ddSBjoern A. Zeeb 
1725bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_is_ctdp_supported(struct iwl_mvm *mvm)
1726bfcc09ddSBjoern A. Zeeb {
1727bfcc09ddSBjoern A. Zeeb 	return fw_has_capa(&mvm->fw->ucode_capa,
1728bfcc09ddSBjoern A. Zeeb 			   IWL_UCODE_TLV_CAPA_CTDP_SUPPORT);
1729bfcc09ddSBjoern A. Zeeb }
1730bfcc09ddSBjoern A. Zeeb 
17319af1bba4SBjoern A. Zeeb static inline bool iwl_mvm_is_esr_supported(struct iwl_trans *trans)
17329af1bba4SBjoern A. Zeeb {
17339af1bba4SBjoern A. Zeeb 	if ((CSR_HW_RFID_TYPE(trans->hw_rf_id) == IWL_CFG_RF_TYPE_FM) &&
17349af1bba4SBjoern A. Zeeb 	    !CSR_HW_RFID_IS_CDB(trans->hw_rf_id))
17359af1bba4SBjoern A. Zeeb 		/* Step A doesn't support eSR */
17369af1bba4SBjoern A. Zeeb 		return CSR_HW_RFID_STEP(trans->hw_rf_id);
17379af1bba4SBjoern A. Zeeb 
17389af1bba4SBjoern A. Zeeb 	return false;
17399af1bba4SBjoern A. Zeeb }
17409af1bba4SBjoern A. Zeeb 
17419af1bba4SBjoern A. Zeeb static inline int iwl_mvm_max_active_links(struct iwl_mvm *mvm,
17429af1bba4SBjoern A. Zeeb 					   struct ieee80211_vif *vif)
17439af1bba4SBjoern A. Zeeb {
17449af1bba4SBjoern A. Zeeb 	struct iwl_trans *trans = mvm->fwrt.trans;
17459af1bba4SBjoern A. Zeeb 
17469af1bba4SBjoern A. Zeeb 	if (vif->type == NL80211_IFTYPE_AP)
17479af1bba4SBjoern A. Zeeb 		return mvm->fw->ucode_capa.num_beacons;
17489af1bba4SBjoern A. Zeeb 
1749*a4128aadSBjoern A. Zeeb 	/* Check if HW supports eSR or STR */
17509af1bba4SBjoern A. Zeeb 	if (iwl_mvm_is_esr_supported(trans) ||
17519af1bba4SBjoern A. Zeeb 	    (CSR_HW_RFID_TYPE(trans->hw_rf_id) == IWL_CFG_RF_TYPE_FM &&
17529af1bba4SBjoern A. Zeeb 	     CSR_HW_RFID_IS_CDB(trans->hw_rf_id)))
17539af1bba4SBjoern A. Zeeb 		return IWL_MVM_FW_MAX_ACTIVE_LINKS_NUM;
17549af1bba4SBjoern A. Zeeb 
17559af1bba4SBjoern A. Zeeb 	return 1;
17569af1bba4SBjoern A. Zeeb }
17579af1bba4SBjoern A. Zeeb 
1758bfcc09ddSBjoern A. Zeeb extern const u8 iwl_mvm_ac_to_tx_fifo[];
1759bfcc09ddSBjoern A. Zeeb extern const u8 iwl_mvm_ac_to_gen2_tx_fifo[];
1760*a4128aadSBjoern A. Zeeb extern const u8 iwl_mvm_ac_to_bz_tx_fifo[];
1761bfcc09ddSBjoern A. Zeeb 
1762bfcc09ddSBjoern A. Zeeb static inline u8 iwl_mvm_mac_ac_to_tx_fifo(struct iwl_mvm *mvm,
1763bfcc09ddSBjoern A. Zeeb 					   enum ieee80211_ac_numbers ac)
1764bfcc09ddSBjoern A. Zeeb {
1765*a4128aadSBjoern A. Zeeb 	if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_BZ)
1766*a4128aadSBjoern A. Zeeb 		return iwl_mvm_ac_to_bz_tx_fifo[ac];
1767*a4128aadSBjoern A. Zeeb 	if (iwl_mvm_has_new_tx_api(mvm))
1768*a4128aadSBjoern A. Zeeb 		return iwl_mvm_ac_to_gen2_tx_fifo[ac];
1769*a4128aadSBjoern A. Zeeb 	return iwl_mvm_ac_to_tx_fifo[ac];
1770bfcc09ddSBjoern A. Zeeb }
1771bfcc09ddSBjoern A. Zeeb 
1772bfcc09ddSBjoern A. Zeeb struct iwl_rate_info {
1773bfcc09ddSBjoern A. Zeeb 	u8 plcp;	/* uCode API:  IWL_RATE_6M_PLCP, etc. */
1774bfcc09ddSBjoern A. Zeeb 	u8 plcp_siso;	/* uCode API:  IWL_RATE_SISO_6M_PLCP, etc. */
1775bfcc09ddSBjoern A. Zeeb 	u8 plcp_mimo2;	/* uCode API:  IWL_RATE_MIMO2_6M_PLCP, etc. */
1776bfcc09ddSBjoern A. Zeeb 	u8 plcp_mimo3;  /* uCode API:  IWL_RATE_MIMO3_6M_PLCP, etc. */
1777bfcc09ddSBjoern A. Zeeb 	u8 ieee;	/* MAC header:  IWL_RATE_6M_IEEE, etc. */
1778bfcc09ddSBjoern A. Zeeb };
1779bfcc09ddSBjoern A. Zeeb 
1780*a4128aadSBjoern A. Zeeb void __iwl_mvm_mac_stop(struct iwl_mvm *mvm, bool suspend);
1781bfcc09ddSBjoern A. Zeeb int __iwl_mvm_mac_start(struct iwl_mvm *mvm);
1782bfcc09ddSBjoern A. Zeeb 
1783bfcc09ddSBjoern A. Zeeb /******************
1784bfcc09ddSBjoern A. Zeeb  * MVM Methods
1785bfcc09ddSBjoern A. Zeeb  ******************/
1786bfcc09ddSBjoern A. Zeeb /* uCode */
1787bfcc09ddSBjoern A. Zeeb int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm);
1788bfcc09ddSBjoern A. Zeeb 
1789bfcc09ddSBjoern A. Zeeb /* Utils */
1790bfcc09ddSBjoern A. Zeeb int iwl_mvm_legacy_hw_idx_to_mac80211_idx(u32 rate_n_flags,
1791bfcc09ddSBjoern A. Zeeb 					  enum nl80211_band band);
1792bfcc09ddSBjoern A. Zeeb int iwl_mvm_legacy_rate_to_mac80211_idx(u32 rate_n_flags,
1793bfcc09ddSBjoern A. Zeeb 					enum nl80211_band band);
1794bfcc09ddSBjoern A. Zeeb void iwl_mvm_hwrate_to_tx_rate(u32 rate_n_flags,
1795bfcc09ddSBjoern A. Zeeb 			       enum nl80211_band band,
1796bfcc09ddSBjoern A. Zeeb 			       struct ieee80211_tx_rate *r);
1797bfcc09ddSBjoern A. Zeeb void iwl_mvm_hwrate_to_tx_rate_v1(u32 rate_n_flags,
1798bfcc09ddSBjoern A. Zeeb 				  enum nl80211_band band,
1799bfcc09ddSBjoern A. Zeeb 				  struct ieee80211_tx_rate *r);
1800bfcc09ddSBjoern A. Zeeb u8 iwl_mvm_mac80211_idx_to_hwrate(const struct iwl_fw *fw, int rate_idx);
1801bfcc09ddSBjoern A. Zeeb u8 iwl_mvm_mac80211_ac_to_ucode_ac(enum ieee80211_ac_numbers ac);
18029af1bba4SBjoern A. Zeeb bool iwl_mvm_is_nic_ack_enabled(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
1803bfcc09ddSBjoern A. Zeeb 
1804bfcc09ddSBjoern A. Zeeb static inline void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm)
1805bfcc09ddSBjoern A. Zeeb {
1806bfcc09ddSBjoern A. Zeeb 	iwl_fwrt_dump_error_logs(&mvm->fwrt);
1807bfcc09ddSBjoern A. Zeeb }
1808bfcc09ddSBjoern A. Zeeb 
1809bfcc09ddSBjoern A. Zeeb u8 first_antenna(u8 mask);
1810bfcc09ddSBjoern A. Zeeb u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx);
1811bfcc09ddSBjoern A. Zeeb void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, int clock_type, u32 *gp2,
1812bfcc09ddSBjoern A. Zeeb 			   u64 *boottime, ktime_t *realtime);
1813bfcc09ddSBjoern A. Zeeb u32 iwl_mvm_get_systime(struct iwl_mvm *mvm);
1814*a4128aadSBjoern A. Zeeb u32 iwl_mvm_find_ie_offset(u8 *beacon, u8 eid, u32 frame_size);
1815bfcc09ddSBjoern A. Zeeb 
1816bfcc09ddSBjoern A. Zeeb /* Tx / Host Commands */
1817bfcc09ddSBjoern A. Zeeb int __must_check iwl_mvm_send_cmd(struct iwl_mvm *mvm,
1818bfcc09ddSBjoern A. Zeeb 				  struct iwl_host_cmd *cmd);
1819bfcc09ddSBjoern A. Zeeb int __must_check iwl_mvm_send_cmd_pdu(struct iwl_mvm *mvm, u32 id,
1820bfcc09ddSBjoern A. Zeeb 				      u32 flags, u16 len, const void *data);
1821bfcc09ddSBjoern A. Zeeb int __must_check iwl_mvm_send_cmd_status(struct iwl_mvm *mvm,
1822bfcc09ddSBjoern A. Zeeb 					 struct iwl_host_cmd *cmd,
1823bfcc09ddSBjoern A. Zeeb 					 u32 *status);
1824bfcc09ddSBjoern A. Zeeb int __must_check iwl_mvm_send_cmd_pdu_status(struct iwl_mvm *mvm, u32 id,
1825bfcc09ddSBjoern A. Zeeb 					     u16 len, const void *data,
1826bfcc09ddSBjoern A. Zeeb 					     u32 *status);
1827bfcc09ddSBjoern A. Zeeb int iwl_mvm_tx_skb_sta(struct iwl_mvm *mvm, struct sk_buff *skb,
1828bfcc09ddSBjoern A. Zeeb 		       struct ieee80211_sta *sta);
1829bfcc09ddSBjoern A. Zeeb int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb);
1830bfcc09ddSBjoern A. Zeeb void iwl_mvm_set_tx_cmd(struct iwl_mvm *mvm, struct sk_buff *skb,
1831bfcc09ddSBjoern A. Zeeb 			struct iwl_tx_cmd *tx_cmd,
1832bfcc09ddSBjoern A. Zeeb 			struct ieee80211_tx_info *info, u8 sta_id);
1833bfcc09ddSBjoern A. Zeeb void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm, struct iwl_tx_cmd *tx_cmd,
1834bfcc09ddSBjoern A. Zeeb 			    struct ieee80211_tx_info *info,
1835bfcc09ddSBjoern A. Zeeb 			    struct ieee80211_sta *sta, __le16 fc);
1836bfcc09ddSBjoern A. Zeeb void iwl_mvm_mac_itxq_xmit(struct ieee80211_hw *hw, struct ieee80211_txq *txq);
1837bfcc09ddSBjoern A. Zeeb unsigned int iwl_mvm_max_amsdu_size(struct iwl_mvm *mvm,
1838bfcc09ddSBjoern A. Zeeb 				    struct ieee80211_sta *sta,
1839bfcc09ddSBjoern A. Zeeb 				    unsigned int tid);
1840bfcc09ddSBjoern A. Zeeb 
1841bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_IWLWIFI_DEBUG
1842bfcc09ddSBjoern A. Zeeb const char *iwl_mvm_get_tx_fail_reason(u32 status);
1843bfcc09ddSBjoern A. Zeeb #else
1844bfcc09ddSBjoern A. Zeeb static inline const char *iwl_mvm_get_tx_fail_reason(u32 status) { return ""; }
1845bfcc09ddSBjoern A. Zeeb #endif
1846bfcc09ddSBjoern A. Zeeb int iwl_mvm_flush_tx_path(struct iwl_mvm *mvm, u32 tfd_msk);
1847*a4128aadSBjoern A. Zeeb int iwl_mvm_flush_sta(struct iwl_mvm *mvm, u32 sta_id, u32 tfd_queue_mask);
1848bfcc09ddSBjoern A. Zeeb int iwl_mvm_flush_sta_tids(struct iwl_mvm *mvm, u32 sta_id, u16 tids);
1849bfcc09ddSBjoern A. Zeeb 
18509af1bba4SBjoern A. Zeeb /* Utils to extract sta related data */
18519af1bba4SBjoern A. Zeeb __le32 iwl_mvm_get_sta_htc_flags(struct ieee80211_sta *sta,
18529af1bba4SBjoern A. Zeeb 				 struct ieee80211_link_sta *link_sta);
18539af1bba4SBjoern A. Zeeb u8 iwl_mvm_get_sta_uapsd_acs(struct ieee80211_sta *sta);
18549af1bba4SBjoern A. Zeeb u32 iwl_mvm_get_sta_ampdu_dens(struct ieee80211_link_sta *link_sta,
18559af1bba4SBjoern A. Zeeb 			       struct ieee80211_bss_conf *link_conf,
18569af1bba4SBjoern A. Zeeb 			       u32 *_agg_size);
18579af1bba4SBjoern A. Zeeb int iwl_mvm_set_sta_pkt_ext(struct iwl_mvm *mvm,
18589af1bba4SBjoern A. Zeeb 			    struct ieee80211_link_sta *link_sta,
18599af1bba4SBjoern A. Zeeb 			    struct iwl_he_pkt_ext_v2 *pkt_ext);
18609af1bba4SBjoern A. Zeeb 
1861bfcc09ddSBjoern A. Zeeb void iwl_mvm_async_handlers_purge(struct iwl_mvm *mvm);
1862bfcc09ddSBjoern A. Zeeb 
1863bfcc09ddSBjoern A. Zeeb static inline void iwl_mvm_set_tx_cmd_ccmp(struct ieee80211_tx_info *info,
1864bfcc09ddSBjoern A. Zeeb 					   struct iwl_tx_cmd *tx_cmd)
1865bfcc09ddSBjoern A. Zeeb {
1866bfcc09ddSBjoern A. Zeeb 	struct ieee80211_key_conf *keyconf = info->control.hw_key;
1867bfcc09ddSBjoern A. Zeeb 
1868bfcc09ddSBjoern A. Zeeb 	tx_cmd->sec_ctl = TX_CMD_SEC_CCM;
1869bfcc09ddSBjoern A. Zeeb 	memcpy(tx_cmd->key, keyconf->key, keyconf->keylen);
1870bfcc09ddSBjoern A. Zeeb }
1871bfcc09ddSBjoern A. Zeeb 
1872bfcc09ddSBjoern A. Zeeb static inline void iwl_mvm_wait_for_async_handlers(struct iwl_mvm *mvm)
1873bfcc09ddSBjoern A. Zeeb {
1874bfcc09ddSBjoern A. Zeeb 	flush_work(&mvm->async_handlers_wk);
1875bfcc09ddSBjoern A. Zeeb }
1876bfcc09ddSBjoern A. Zeeb 
1877bfcc09ddSBjoern A. Zeeb /* Statistics */
1878*a4128aadSBjoern A. Zeeb void iwl_mvm_handle_rx_system_oper_stats(struct iwl_mvm *mvm,
1879*a4128aadSBjoern A. Zeeb 					 struct iwl_rx_cmd_buffer *rxb);
1880*a4128aadSBjoern A. Zeeb void iwl_mvm_handle_rx_system_oper_part1_stats(struct iwl_mvm *mvm,
1881*a4128aadSBjoern A. Zeeb 					       struct iwl_rx_cmd_buffer *rxb);
1882*a4128aadSBjoern A. Zeeb static inline void
1883*a4128aadSBjoern A. Zeeb iwl_mvm_handle_rx_system_end_stats_notif(struct iwl_mvm *mvm,
1884*a4128aadSBjoern A. Zeeb 					 struct iwl_rx_cmd_buffer *rxb)
1885*a4128aadSBjoern A. Zeeb {
1886*a4128aadSBjoern A. Zeeb }
1887*a4128aadSBjoern A. Zeeb 
1888bfcc09ddSBjoern A. Zeeb void iwl_mvm_handle_rx_statistics(struct iwl_mvm *mvm,
1889bfcc09ddSBjoern A. Zeeb 				  struct iwl_rx_packet *pkt);
1890bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_statistics(struct iwl_mvm *mvm,
1891bfcc09ddSBjoern A. Zeeb 			   struct iwl_rx_cmd_buffer *rxb);
1892bfcc09ddSBjoern A. Zeeb int iwl_mvm_request_statistics(struct iwl_mvm *mvm, bool clear);
1893*a4128aadSBjoern A. Zeeb int iwl_mvm_request_periodic_system_statistics(struct iwl_mvm *mvm,
1894*a4128aadSBjoern A. Zeeb 					       bool enable);
1895bfcc09ddSBjoern A. Zeeb void iwl_mvm_accu_radio_stats(struct iwl_mvm *mvm);
1896bfcc09ddSBjoern A. Zeeb 
1897bfcc09ddSBjoern A. Zeeb /* NVM */
1898bfcc09ddSBjoern A. Zeeb int iwl_nvm_init(struct iwl_mvm *mvm);
1899bfcc09ddSBjoern A. Zeeb int iwl_mvm_load_nvm_to_nic(struct iwl_mvm *mvm);
1900bfcc09ddSBjoern A. Zeeb 
1901bfcc09ddSBjoern A. Zeeb static inline u8 iwl_mvm_get_valid_tx_ant(struct iwl_mvm *mvm)
1902bfcc09ddSBjoern A. Zeeb {
1903*a4128aadSBjoern A. Zeeb 	u8 tx_ant = mvm->fw->valid_tx_ant;
1904*a4128aadSBjoern A. Zeeb 
1905*a4128aadSBjoern A. Zeeb 	if (mvm->nvm_data && mvm->nvm_data->valid_tx_ant)
1906*a4128aadSBjoern A. Zeeb 		tx_ant &= mvm->nvm_data->valid_tx_ant;
1907*a4128aadSBjoern A. Zeeb 
1908*a4128aadSBjoern A. Zeeb 	if (mvm->set_tx_ant)
1909*a4128aadSBjoern A. Zeeb 		tx_ant &= mvm->set_tx_ant;
1910*a4128aadSBjoern A. Zeeb 
1911*a4128aadSBjoern A. Zeeb 	return tx_ant;
1912bfcc09ddSBjoern A. Zeeb }
1913bfcc09ddSBjoern A. Zeeb 
1914bfcc09ddSBjoern A. Zeeb static inline u8 iwl_mvm_get_valid_rx_ant(struct iwl_mvm *mvm)
1915bfcc09ddSBjoern A. Zeeb {
1916*a4128aadSBjoern A. Zeeb 	u8 rx_ant = mvm->fw->valid_rx_ant;
1917*a4128aadSBjoern A. Zeeb 
1918*a4128aadSBjoern A. Zeeb 	if (mvm->nvm_data && mvm->nvm_data->valid_rx_ant)
1919*a4128aadSBjoern A. Zeeb 		rx_ant &= mvm->nvm_data->valid_rx_ant;
1920*a4128aadSBjoern A. Zeeb 
1921*a4128aadSBjoern A. Zeeb 	if (mvm->set_rx_ant)
1922*a4128aadSBjoern A. Zeeb 		rx_ant &= mvm->set_rx_ant;
1923*a4128aadSBjoern A. Zeeb 
1924*a4128aadSBjoern A. Zeeb 	return rx_ant;
1925*a4128aadSBjoern A. Zeeb 
1926bfcc09ddSBjoern A. Zeeb }
1927bfcc09ddSBjoern A. Zeeb 
1928bfcc09ddSBjoern A. Zeeb static inline void iwl_mvm_toggle_tx_ant(struct iwl_mvm *mvm, u8 *ant)
1929bfcc09ddSBjoern A. Zeeb {
1930bfcc09ddSBjoern A. Zeeb 	*ant = iwl_mvm_next_antenna(mvm, iwl_mvm_get_valid_tx_ant(mvm), *ant);
1931bfcc09ddSBjoern A. Zeeb }
1932bfcc09ddSBjoern A. Zeeb 
1933bfcc09ddSBjoern A. Zeeb static inline u32 iwl_mvm_get_phy_config(struct iwl_mvm *mvm)
1934bfcc09ddSBjoern A. Zeeb {
1935bfcc09ddSBjoern A. Zeeb 	u32 phy_config = ~(FW_PHY_CFG_TX_CHAIN |
1936bfcc09ddSBjoern A. Zeeb 			   FW_PHY_CFG_RX_CHAIN);
1937bfcc09ddSBjoern A. Zeeb 	u32 valid_rx_ant = iwl_mvm_get_valid_rx_ant(mvm);
1938bfcc09ddSBjoern A. Zeeb 	u32 valid_tx_ant = iwl_mvm_get_valid_tx_ant(mvm);
1939bfcc09ddSBjoern A. Zeeb 
1940bfcc09ddSBjoern A. Zeeb 	phy_config |= valid_tx_ant << FW_PHY_CFG_TX_CHAIN_POS |
1941bfcc09ddSBjoern A. Zeeb 		      valid_rx_ant << FW_PHY_CFG_RX_CHAIN_POS;
1942bfcc09ddSBjoern A. Zeeb 
1943bfcc09ddSBjoern A. Zeeb 	return mvm->fw->phy_config & phy_config;
1944bfcc09ddSBjoern A. Zeeb }
1945bfcc09ddSBjoern A. Zeeb 
1946bfcc09ddSBjoern A. Zeeb int iwl_mvm_up(struct iwl_mvm *mvm);
1947bfcc09ddSBjoern A. Zeeb int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm);
1948bfcc09ddSBjoern A. Zeeb 
1949bfcc09ddSBjoern A. Zeeb int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm);
1950bfcc09ddSBjoern A. Zeeb 
1951*a4128aadSBjoern A. Zeeb void iwl_mvm_mac_init_mvmvif(struct iwl_mvm *mvm, struct iwl_mvm_vif *mvmvif);
1952*a4128aadSBjoern A. Zeeb 
1953bfcc09ddSBjoern A. Zeeb /*
1954bfcc09ddSBjoern A. Zeeb  * FW notifications / CMD responses handlers
1955bfcc09ddSBjoern A. Zeeb  * Convention: iwl_mvm_rx_<NAME OF THE CMD>
1956bfcc09ddSBjoern A. Zeeb  */
1957bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_mq(struct iwl_op_mode *op_mode,
1958bfcc09ddSBjoern A. Zeeb 		   struct napi_struct *napi,
1959bfcc09ddSBjoern A. Zeeb 		   struct iwl_rx_cmd_buffer *rxb);
1960bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_rx_phy_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1961bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi,
1962bfcc09ddSBjoern A. Zeeb 			struct iwl_rx_cmd_buffer *rxb);
1963bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
1964bfcc09ddSBjoern A. Zeeb 			struct iwl_rx_cmd_buffer *rxb, int queue);
1965bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_monitor_no_data(struct iwl_mvm *mvm, struct napi_struct *napi,
1966bfcc09ddSBjoern A. Zeeb 				struct iwl_rx_cmd_buffer *rxb, int queue);
1967bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi,
1968bfcc09ddSBjoern A. Zeeb 			      struct iwl_rx_cmd_buffer *rxb, int queue);
1969bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_bar_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi,
1970bfcc09ddSBjoern A. Zeeb 				  struct iwl_rx_cmd_buffer *rxb, int queue);
1971bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_queue_notif(struct iwl_mvm *mvm, struct napi_struct *napi,
1972bfcc09ddSBjoern A. Zeeb 			    struct iwl_rx_cmd_buffer *rxb, int queue);
1973bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1974bfcc09ddSBjoern A. Zeeb void iwl_mvm_mfu_assert_dump_notif(struct iwl_mvm *mvm,
1975bfcc09ddSBjoern A. Zeeb 				   struct iwl_rx_cmd_buffer *rxb);
1976bfcc09ddSBjoern A. Zeeb void iwl_mvm_send_recovery_cmd(struct iwl_mvm *mvm, u32 flags);
1977bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1978bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_ant_coupling_notif(struct iwl_mvm *mvm,
1979bfcc09ddSBjoern A. Zeeb 				   struct iwl_rx_cmd_buffer *rxb);
1980bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
1981bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm,
1982bfcc09ddSBjoern A. Zeeb 			     struct iwl_rx_cmd_buffer *rxb);
1983bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_shared_mem_cfg_notif(struct iwl_mvm *mvm,
1984bfcc09ddSBjoern A. Zeeb 				     struct iwl_rx_cmd_buffer *rxb);
1985bfcc09ddSBjoern A. Zeeb 
1986bfcc09ddSBjoern A. Zeeb /* MVM PHY */
19879af1bba4SBjoern A. Zeeb struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm);
1988bfcc09ddSBjoern A. Zeeb int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
1989*a4128aadSBjoern A. Zeeb 			 const struct cfg80211_chan_def *chandef,
1990*a4128aadSBjoern A. Zeeb 			 const struct cfg80211_chan_def *ap,
1991bfcc09ddSBjoern A. Zeeb 			 u8 chains_static, u8 chains_dynamic);
1992bfcc09ddSBjoern A. Zeeb int iwl_mvm_phy_ctxt_changed(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
1993*a4128aadSBjoern A. Zeeb 			     const struct cfg80211_chan_def *chandef,
1994*a4128aadSBjoern A. Zeeb 			     const struct cfg80211_chan_def *ap,
1995bfcc09ddSBjoern A. Zeeb 			     u8 chains_static, u8 chains_dynamic);
1996bfcc09ddSBjoern A. Zeeb void iwl_mvm_phy_ctxt_ref(struct iwl_mvm *mvm,
1997bfcc09ddSBjoern A. Zeeb 			  struct iwl_mvm_phy_ctxt *ctxt);
1998bfcc09ddSBjoern A. Zeeb void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm,
1999bfcc09ddSBjoern A. Zeeb 			    struct iwl_mvm_phy_ctxt *ctxt);
2000bfcc09ddSBjoern A. Zeeb int iwl_mvm_phy_ctx_count(struct iwl_mvm *mvm);
2001*a4128aadSBjoern A. Zeeb u8 iwl_mvm_get_channel_width(const struct cfg80211_chan_def *chandef);
2002*a4128aadSBjoern A. Zeeb u8 iwl_mvm_get_ctrl_pos(const struct cfg80211_chan_def *chandef);
20039af1bba4SBjoern A. Zeeb int iwl_mvm_phy_send_rlc(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
20049af1bba4SBjoern A. Zeeb 			 u8 chains_static, u8 chains_dynamic);
2005bfcc09ddSBjoern A. Zeeb 
2006bfcc09ddSBjoern A. Zeeb /* MAC (virtual interface) programming */
20079af1bba4SBjoern A. Zeeb 
20089af1bba4SBjoern A. Zeeb void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm,
20099af1bba4SBjoern A. Zeeb 				 struct ieee80211_vif *vif);
20109af1bba4SBjoern A. Zeeb void iwl_mvm_set_fw_basic_rates(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
20119af1bba4SBjoern A. Zeeb 				struct ieee80211_bss_conf *link_conf,
20129af1bba4SBjoern A. Zeeb 				__le32 *cck_rates, __le32 *ofdm_rates);
20139af1bba4SBjoern A. Zeeb void iwl_mvm_set_fw_protection_flags(struct iwl_mvm *mvm,
20149af1bba4SBjoern A. Zeeb 				     struct ieee80211_vif *vif,
20159af1bba4SBjoern A. Zeeb 				     struct ieee80211_bss_conf *link_conf,
20169af1bba4SBjoern A. Zeeb 				     __le32 *protection_flags, u32 ht_flag,
20179af1bba4SBjoern A. Zeeb 				     u32 tgg_flag);
20189af1bba4SBjoern A. Zeeb void iwl_mvm_set_fw_qos_params(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
20199af1bba4SBjoern A. Zeeb 			       struct ieee80211_bss_conf *link_conf,
20209af1bba4SBjoern A. Zeeb 			       struct iwl_ac_qos *ac, __le32 *qos_flags);
20219af1bba4SBjoern A. Zeeb bool iwl_mvm_set_fw_mu_edca_params(struct iwl_mvm *mvm,
20229af1bba4SBjoern A. Zeeb 				   const struct iwl_mvm_vif_link_info *link_info,
20239af1bba4SBjoern A. Zeeb 				   struct iwl_he_backoff_conf *trig_based_txf);
20249af1bba4SBjoern A. Zeeb void iwl_mvm_set_fw_dtim_tbtt(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
20259af1bba4SBjoern A. Zeeb 			      struct ieee80211_bss_conf *link_conf,
20269af1bba4SBjoern A. Zeeb 			      __le64 *dtim_tsf, __le32 *dtim_time,
20279af1bba4SBjoern A. Zeeb 			      __le32 *assoc_beacon_arrive_time);
20289af1bba4SBjoern A. Zeeb __le32 iwl_mac_ctxt_p2p_dev_has_extended_disc(struct iwl_mvm *mvm,
20299af1bba4SBjoern A. Zeeb 					      struct ieee80211_vif *vif);
20309af1bba4SBjoern A. Zeeb void iwl_mvm_mac_ctxt_cmd_ap_set_filter_flags(struct iwl_mvm *mvm,
20319af1bba4SBjoern A. Zeeb 					      struct iwl_mvm_vif *mvmvif,
20329af1bba4SBjoern A. Zeeb 					      __le32 *filter_flags,
20339af1bba4SBjoern A. Zeeb 					      int accept_probe_req_flag,
20349af1bba4SBjoern A. Zeeb 					      int accept_beacon_flag);
20359af1bba4SBjoern A. Zeeb int iwl_mvm_get_mac_type(struct ieee80211_vif *vif);
20369af1bba4SBjoern A. Zeeb __le32 iwl_mvm_mac_ctxt_cmd_p2p_sta_get_oppps_ctwin(struct iwl_mvm *mvm,
20379af1bba4SBjoern A. Zeeb 						    struct ieee80211_vif *vif);
20389af1bba4SBjoern A. Zeeb u32 iwl_mvm_mac_ctxt_cmd_sta_get_twt_policy(struct iwl_mvm *mvm,
20399af1bba4SBjoern A. Zeeb 					    struct ieee80211_vif *vif);
20409af1bba4SBjoern A. Zeeb int iwl_mvm_mld_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
20419af1bba4SBjoern A. Zeeb int iwl_mvm_mld_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
20429af1bba4SBjoern A. Zeeb 				 bool force_assoc_off);
20439af1bba4SBjoern A. Zeeb int iwl_mvm_mld_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2044bfcc09ddSBjoern A. Zeeb int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2045bfcc09ddSBjoern A. Zeeb int iwl_mvm_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2046bfcc09ddSBjoern A. Zeeb int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2047bfcc09ddSBjoern A. Zeeb 			     bool force_assoc_off, const u8 *bssid_override);
2048bfcc09ddSBjoern A. Zeeb int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2049bfcc09ddSBjoern A. Zeeb int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
2050bfcc09ddSBjoern A. Zeeb 				    struct ieee80211_vif *vif,
20519af1bba4SBjoern A. Zeeb 				    struct ieee80211_bss_conf *link_conf);
2052bfcc09ddSBjoern A. Zeeb int iwl_mvm_mac_ctxt_send_beacon_cmd(struct iwl_mvm *mvm,
2053bfcc09ddSBjoern A. Zeeb 				     struct sk_buff *beacon,
2054bfcc09ddSBjoern A. Zeeb 				     void *data, int len);
20559af1bba4SBjoern A. Zeeb u8 iwl_mvm_mac_ctxt_get_beacon_rate(struct iwl_mvm *mvm,
20569af1bba4SBjoern A. Zeeb 				    struct ieee80211_tx_info *info,
20579af1bba4SBjoern A. Zeeb 				    struct ieee80211_vif *vif);
20589af1bba4SBjoern A. Zeeb u8 iwl_mvm_mac_ctxt_get_lowest_rate(struct iwl_mvm *mvm,
20599af1bba4SBjoern A. Zeeb 				    struct ieee80211_tx_info *info,
2060bfcc09ddSBjoern A. Zeeb 				    struct ieee80211_vif *vif);
2061bfcc09ddSBjoern A. Zeeb u16 iwl_mvm_mac_ctxt_get_beacon_flags(const struct iwl_fw *fw,
2062bfcc09ddSBjoern A. Zeeb 				      u8 rate_idx);
2063bfcc09ddSBjoern A. Zeeb void iwl_mvm_mac_ctxt_set_tim(struct iwl_mvm *mvm,
2064bfcc09ddSBjoern A. Zeeb 			      __le32 *tim_index, __le32 *tim_size,
2065bfcc09ddSBjoern A. Zeeb 			      u8 *beacon, u32 frame_size);
2066bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
2067bfcc09ddSBjoern A. Zeeb 			     struct iwl_rx_cmd_buffer *rxb);
2068bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm,
2069bfcc09ddSBjoern A. Zeeb 				     struct iwl_rx_cmd_buffer *rxb);
2070bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_stored_beacon_notif(struct iwl_mvm *mvm,
2071bfcc09ddSBjoern A. Zeeb 				    struct iwl_rx_cmd_buffer *rxb);
2072bfcc09ddSBjoern A. Zeeb void iwl_mvm_mu_mimo_grp_notif(struct iwl_mvm *mvm,
2073bfcc09ddSBjoern A. Zeeb 			       struct iwl_rx_cmd_buffer *rxb);
2074bfcc09ddSBjoern A. Zeeb void iwl_mvm_sta_pm_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
2075bfcc09ddSBjoern A. Zeeb void iwl_mvm_window_status_notif(struct iwl_mvm *mvm,
2076bfcc09ddSBjoern A. Zeeb 				 struct iwl_rx_cmd_buffer *rxb);
2077bfcc09ddSBjoern A. Zeeb void iwl_mvm_mac_ctxt_recalc_tsf_id(struct iwl_mvm *mvm,
2078bfcc09ddSBjoern A. Zeeb 				    struct ieee80211_vif *vif);
2079bfcc09ddSBjoern A. Zeeb void iwl_mvm_probe_resp_data_notif(struct iwl_mvm *mvm,
2080bfcc09ddSBjoern A. Zeeb 				   struct iwl_rx_cmd_buffer *rxb);
2081bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_missed_vap_notif(struct iwl_mvm *mvm,
2082bfcc09ddSBjoern A. Zeeb 				 struct iwl_rx_cmd_buffer *rxb);
2083bfcc09ddSBjoern A. Zeeb void iwl_mvm_channel_switch_start_notif(struct iwl_mvm *mvm,
2084bfcc09ddSBjoern A. Zeeb 					struct iwl_rx_cmd_buffer *rxb);
2085d9836fb4SBjoern A. Zeeb void iwl_mvm_channel_switch_error_notif(struct iwl_mvm *mvm,
2086d9836fb4SBjoern A. Zeeb 					struct iwl_rx_cmd_buffer *rxb);
2087bfcc09ddSBjoern A. Zeeb /* Bindings */
2088bfcc09ddSBjoern A. Zeeb int iwl_mvm_binding_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2089bfcc09ddSBjoern A. Zeeb int iwl_mvm_binding_remove_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
20909af1bba4SBjoern A. Zeeb u32 iwl_mvm_get_lmac_id(struct iwl_mvm *mvm, enum nl80211_band band);
20919af1bba4SBjoern A. Zeeb 
20929af1bba4SBjoern A. Zeeb /* Links */
2093*a4128aadSBjoern A. Zeeb int iwl_mvm_set_link_mapping(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2094*a4128aadSBjoern A. Zeeb 			     struct ieee80211_bss_conf *link_conf);
20959af1bba4SBjoern A. Zeeb int iwl_mvm_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
20969af1bba4SBjoern A. Zeeb 		     struct ieee80211_bss_conf *link_conf);
20979af1bba4SBjoern A. Zeeb int iwl_mvm_link_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
20989af1bba4SBjoern A. Zeeb 			 struct ieee80211_bss_conf *link_conf,
20999af1bba4SBjoern A. Zeeb 			 u32 changes, bool active);
2100*a4128aadSBjoern A. Zeeb int iwl_mvm_unset_link_mapping(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2101*a4128aadSBjoern A. Zeeb 			       struct ieee80211_bss_conf *link_conf);
21029af1bba4SBjoern A. Zeeb int iwl_mvm_remove_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
21039af1bba4SBjoern A. Zeeb 			struct ieee80211_bss_conf *link_conf);
21049af1bba4SBjoern A. Zeeb int iwl_mvm_disable_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
21059af1bba4SBjoern A. Zeeb 			 struct ieee80211_bss_conf *link_conf);
21069af1bba4SBjoern A. Zeeb 
2107*a4128aadSBjoern A. Zeeb void iwl_mvm_select_links(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2108*a4128aadSBjoern A. Zeeb u8 iwl_mvm_get_primary_link(struct ieee80211_vif *vif);
2109*a4128aadSBjoern A. Zeeb u8 iwl_mvm_get_other_link(struct ieee80211_vif *vif, u8 link_id);
2110*a4128aadSBjoern A. Zeeb 
2111*a4128aadSBjoern A. Zeeb struct iwl_mvm_link_sel_data {
2112*a4128aadSBjoern A. Zeeb 	u8 link_id;
2113*a4128aadSBjoern A. Zeeb 	const struct cfg80211_chan_def *chandef;
2114*a4128aadSBjoern A. Zeeb 	s32 signal;
2115*a4128aadSBjoern A. Zeeb 	u16 grade;
2116*a4128aadSBjoern A. Zeeb };
2117*a4128aadSBjoern A. Zeeb 
2118*a4128aadSBjoern A. Zeeb #if IS_ENABLED(CONFIG_IWLWIFI_KUNIT_TESTS)
2119*a4128aadSBjoern A. Zeeb unsigned int iwl_mvm_get_link_grade(struct ieee80211_bss_conf *link_conf);
2120*a4128aadSBjoern A. Zeeb bool iwl_mvm_mld_valid_link_pair(struct ieee80211_vif *vif,
2121*a4128aadSBjoern A. Zeeb 				 const struct iwl_mvm_link_sel_data *a,
2122*a4128aadSBjoern A. Zeeb 				 const struct iwl_mvm_link_sel_data *b);
2123*a4128aadSBjoern A. Zeeb 
2124*a4128aadSBjoern A. Zeeb s8 iwl_mvm_average_dbm_values(const struct iwl_umac_scan_channel_survey_notif *notif);
2125*a4128aadSBjoern A. Zeeb #endif
2126*a4128aadSBjoern A. Zeeb 
21279af1bba4SBjoern A. Zeeb /* AP and IBSS */
21289af1bba4SBjoern A. Zeeb bool iwl_mvm_start_ap_ibss_common(struct ieee80211_hw *hw,
21299af1bba4SBjoern A. Zeeb 				  struct ieee80211_vif *vif, int *ret);
21309af1bba4SBjoern A. Zeeb void iwl_mvm_stop_ap_ibss_common(struct iwl_mvm *mvm,
21319af1bba4SBjoern A. Zeeb 				 struct ieee80211_vif *vif);
21329af1bba4SBjoern A. Zeeb 
21339af1bba4SBjoern A. Zeeb /* BSS Info */
2134*a4128aadSBjoern A. Zeeb void iwl_mvm_bss_info_changed_station_common(struct iwl_mvm *mvm,
21359af1bba4SBjoern A. Zeeb 					     struct ieee80211_vif *vif,
21369af1bba4SBjoern A. Zeeb 					     struct ieee80211_bss_conf *link_conf,
21379af1bba4SBjoern A. Zeeb 					     u64 changes);
21389af1bba4SBjoern A. Zeeb void iwl_mvm_bss_info_changed_station_assoc(struct iwl_mvm *mvm,
21399af1bba4SBjoern A. Zeeb 					    struct ieee80211_vif *vif,
21409af1bba4SBjoern A. Zeeb 					    u64 changes);
21419af1bba4SBjoern A. Zeeb 
21429af1bba4SBjoern A. Zeeb /* ROC */
21439af1bba4SBjoern A. Zeeb /**
21449af1bba4SBjoern A. Zeeb  * struct iwl_mvm_roc_ops - callbacks for the remain_on_channel()
21459af1bba4SBjoern A. Zeeb  *
21469af1bba4SBjoern A. Zeeb  * Since the only difference between both MLD and
21479af1bba4SBjoern A. Zeeb  * non-MLD versions of remain_on_channel() is these function calls,
21489af1bba4SBjoern A. Zeeb  * each version will send its specific function calls to
21499af1bba4SBjoern A. Zeeb  * %iwl_mvm_roc_common().
21509af1bba4SBjoern A. Zeeb  *
21519af1bba4SBjoern A. Zeeb  * @add_aux_sta_for_hs20: pointer to the function that adds an aux sta
21529af1bba4SBjoern A. Zeeb  *	for Hot Spot 2.0
2153*a4128aadSBjoern A. Zeeb  * @link: For a P2P Device interface, pointer to a function that links the
2154*a4128aadSBjoern A. Zeeb  *      MAC/Link to the PHY context
21559af1bba4SBjoern A. Zeeb  */
21569af1bba4SBjoern A. Zeeb struct iwl_mvm_roc_ops {
21579af1bba4SBjoern A. Zeeb 	int (*add_aux_sta_for_hs20)(struct iwl_mvm *mvm, u32 lmac_id);
2158*a4128aadSBjoern A. Zeeb 	int (*link)(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
21599af1bba4SBjoern A. Zeeb };
21609af1bba4SBjoern A. Zeeb 
21619af1bba4SBjoern A. Zeeb int iwl_mvm_roc_common(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
21629af1bba4SBjoern A. Zeeb 		       struct ieee80211_channel *channel, int duration,
21639af1bba4SBjoern A. Zeeb 		       enum ieee80211_roc_type type,
21649af1bba4SBjoern A. Zeeb 		       const struct iwl_mvm_roc_ops *ops);
21659af1bba4SBjoern A. Zeeb int iwl_mvm_cancel_roc(struct ieee80211_hw *hw,
21669af1bba4SBjoern A. Zeeb 		       struct ieee80211_vif *vif);
21679af1bba4SBjoern A. Zeeb /*Session Protection */
21689af1bba4SBjoern A. Zeeb void iwl_mvm_protect_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2169*a4128aadSBjoern A. Zeeb 			   u32 duration_override, unsigned int link_id);
2170bfcc09ddSBjoern A. Zeeb 
2171bfcc09ddSBjoern A. Zeeb /* Quota management */
2172bfcc09ddSBjoern A. Zeeb static inline size_t iwl_mvm_quota_cmd_size(struct iwl_mvm *mvm)
2173bfcc09ddSBjoern A. Zeeb {
2174bfcc09ddSBjoern A. Zeeb 	return iwl_mvm_has_quota_low_latency(mvm) ?
2175bfcc09ddSBjoern A. Zeeb 		sizeof(struct iwl_time_quota_cmd) :
2176bfcc09ddSBjoern A. Zeeb 		sizeof(struct iwl_time_quota_cmd_v1);
2177bfcc09ddSBjoern A. Zeeb }
2178bfcc09ddSBjoern A. Zeeb 
2179bfcc09ddSBjoern A. Zeeb static inline struct iwl_time_quota_data
2180bfcc09ddSBjoern A. Zeeb *iwl_mvm_quota_cmd_get_quota(struct iwl_mvm *mvm,
2181bfcc09ddSBjoern A. Zeeb 			     struct iwl_time_quota_cmd *cmd,
2182bfcc09ddSBjoern A. Zeeb 			     int i)
2183bfcc09ddSBjoern A. Zeeb {
2184bfcc09ddSBjoern A. Zeeb 	struct iwl_time_quota_data_v1 *quotas;
2185bfcc09ddSBjoern A. Zeeb 
2186bfcc09ddSBjoern A. Zeeb 	if (iwl_mvm_has_quota_low_latency(mvm))
2187bfcc09ddSBjoern A. Zeeb 		return &cmd->quotas[i];
2188bfcc09ddSBjoern A. Zeeb 
2189bfcc09ddSBjoern A. Zeeb 	quotas = (struct iwl_time_quota_data_v1 *)cmd->quotas;
2190bfcc09ddSBjoern A. Zeeb 	return (struct iwl_time_quota_data *)&quotas[i];
2191bfcc09ddSBjoern A. Zeeb }
2192bfcc09ddSBjoern A. Zeeb 
2193bfcc09ddSBjoern A. Zeeb int iwl_mvm_update_quotas(struct iwl_mvm *mvm, bool force_upload,
2194bfcc09ddSBjoern A. Zeeb 			  struct ieee80211_vif *disabled_vif);
2195bfcc09ddSBjoern A. Zeeb 
2196bfcc09ddSBjoern A. Zeeb /* Scanning */
2197bfcc09ddSBjoern A. Zeeb int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2198bfcc09ddSBjoern A. Zeeb 			   struct cfg80211_scan_request *req,
2199bfcc09ddSBjoern A. Zeeb 			   struct ieee80211_scan_ies *ies);
22009af1bba4SBjoern A. Zeeb size_t iwl_mvm_scan_size(struct iwl_mvm *mvm);
2201bfcc09ddSBjoern A. Zeeb int iwl_mvm_scan_stop(struct iwl_mvm *mvm, int type, bool notify);
2202*a4128aadSBjoern A. Zeeb 
2203bfcc09ddSBjoern A. Zeeb int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm);
2204bfcc09ddSBjoern A. Zeeb void iwl_mvm_report_scan_aborted(struct iwl_mvm *mvm);
2205bfcc09ddSBjoern A. Zeeb void iwl_mvm_scan_timeout_wk(struct work_struct *work);
2206*a4128aadSBjoern A. Zeeb int iwl_mvm_int_mlo_scan(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2207*a4128aadSBjoern A. Zeeb void iwl_mvm_rx_channel_survey_notif(struct iwl_mvm *mvm,
2208*a4128aadSBjoern A. Zeeb 				     struct iwl_rx_cmd_buffer *rxb);
2209bfcc09ddSBjoern A. Zeeb 
2210bfcc09ddSBjoern A. Zeeb /* Scheduled scan */
2211bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_lmac_scan_complete_notif(struct iwl_mvm *mvm,
2212bfcc09ddSBjoern A. Zeeb 					 struct iwl_rx_cmd_buffer *rxb);
2213bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_lmac_scan_iter_complete_notif(struct iwl_mvm *mvm,
2214bfcc09ddSBjoern A. Zeeb 					      struct iwl_rx_cmd_buffer *rxb);
2215bfcc09ddSBjoern A. Zeeb int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
2216bfcc09ddSBjoern A. Zeeb 			     struct ieee80211_vif *vif,
2217bfcc09ddSBjoern A. Zeeb 			     struct cfg80211_sched_scan_request *req,
2218bfcc09ddSBjoern A. Zeeb 			     struct ieee80211_scan_ies *ies,
2219bfcc09ddSBjoern A. Zeeb 			     int type);
2220bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_scan_match_found(struct iwl_mvm *mvm,
2221bfcc09ddSBjoern A. Zeeb 				 struct iwl_rx_cmd_buffer *rxb);
2222bfcc09ddSBjoern A. Zeeb 
2223bfcc09ddSBjoern A. Zeeb /* UMAC scan */
2224bfcc09ddSBjoern A. Zeeb int iwl_mvm_config_scan(struct iwl_mvm *mvm);
2225bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm,
2226bfcc09ddSBjoern A. Zeeb 					 struct iwl_rx_cmd_buffer *rxb);
2227bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_umac_scan_iter_complete_notif(struct iwl_mvm *mvm,
2228bfcc09ddSBjoern A. Zeeb 					      struct iwl_rx_cmd_buffer *rxb);
2229bfcc09ddSBjoern A. Zeeb 
2230bfcc09ddSBjoern A. Zeeb /* MVM debugfs */
2231bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_IWLWIFI_DEBUGFS
2232bfcc09ddSBjoern A. Zeeb void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm);
2233*a4128aadSBjoern A. Zeeb void iwl_mvm_vif_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
2234*a4128aadSBjoern A. Zeeb void iwl_mvm_vif_dbgfs_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2235*a4128aadSBjoern A. Zeeb void iwl_mvm_vif_dbgfs_rm_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2236bfcc09ddSBjoern A. Zeeb #else
2237bfcc09ddSBjoern A. Zeeb static inline void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm)
2238bfcc09ddSBjoern A. Zeeb {
2239bfcc09ddSBjoern A. Zeeb }
2240bfcc09ddSBjoern A. Zeeb static inline void
2241*a4128aadSBjoern A. Zeeb iwl_mvm_vif_dbgfs_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2242bfcc09ddSBjoern A. Zeeb {
2243bfcc09ddSBjoern A. Zeeb }
2244bfcc09ddSBjoern A. Zeeb static inline void
2245*a4128aadSBjoern A. Zeeb iwl_mvm_vif_dbgfs_rm_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2246bfcc09ddSBjoern A. Zeeb {
2247bfcc09ddSBjoern A. Zeeb }
2248bfcc09ddSBjoern A. Zeeb #endif /* CONFIG_IWLWIFI_DEBUGFS */
2249bfcc09ddSBjoern A. Zeeb 
2250bfcc09ddSBjoern A. Zeeb /* rate scaling */
2251bfcc09ddSBjoern A. Zeeb int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq);
2252bfcc09ddSBjoern A. Zeeb void iwl_mvm_update_frame_stats(struct iwl_mvm *mvm, u32 rate, bool agg);
2253bfcc09ddSBjoern A. Zeeb int rs_pretty_print_rate_v1(char *buf, int bufsz, const u32 rate);
2254bfcc09ddSBjoern A. Zeeb void rs_update_last_rssi(struct iwl_mvm *mvm,
2255bfcc09ddSBjoern A. Zeeb 			 struct iwl_mvm_sta *mvmsta,
2256bfcc09ddSBjoern A. Zeeb 			 struct ieee80211_rx_status *rx_status);
2257bfcc09ddSBjoern A. Zeeb 
2258bfcc09ddSBjoern A. Zeeb /* power management */
2259bfcc09ddSBjoern A. Zeeb int iwl_mvm_power_update_device(struct iwl_mvm *mvm);
2260bfcc09ddSBjoern A. Zeeb int iwl_mvm_power_update_mac(struct iwl_mvm *mvm);
2261bfcc09ddSBjoern A. Zeeb int iwl_mvm_power_update_ps(struct iwl_mvm *mvm);
2262bfcc09ddSBjoern A. Zeeb int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2263bfcc09ddSBjoern A. Zeeb 				 char *buf, int bufsz);
2264bfcc09ddSBjoern A. Zeeb 
2265bfcc09ddSBjoern A. Zeeb void iwl_mvm_power_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2266bfcc09ddSBjoern A. Zeeb void iwl_mvm_power_uapsd_misbehaving_ap_notif(struct iwl_mvm *mvm,
2267bfcc09ddSBjoern A. Zeeb 					      struct iwl_rx_cmd_buffer *rxb);
2268bfcc09ddSBjoern A. Zeeb 
2269bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_IWLWIFI_LEDS
2270bfcc09ddSBjoern A. Zeeb int iwl_mvm_leds_init(struct iwl_mvm *mvm);
2271bfcc09ddSBjoern A. Zeeb void iwl_mvm_leds_exit(struct iwl_mvm *mvm);
2272bfcc09ddSBjoern A. Zeeb void iwl_mvm_leds_sync(struct iwl_mvm *mvm);
2273bfcc09ddSBjoern A. Zeeb #else
2274bfcc09ddSBjoern A. Zeeb static inline int iwl_mvm_leds_init(struct iwl_mvm *mvm)
2275bfcc09ddSBjoern A. Zeeb {
2276bfcc09ddSBjoern A. Zeeb 	return 0;
2277bfcc09ddSBjoern A. Zeeb }
2278bfcc09ddSBjoern A. Zeeb static inline void iwl_mvm_leds_exit(struct iwl_mvm *mvm)
2279bfcc09ddSBjoern A. Zeeb {
2280bfcc09ddSBjoern A. Zeeb }
2281bfcc09ddSBjoern A. Zeeb static inline void iwl_mvm_leds_sync(struct iwl_mvm *mvm)
2282bfcc09ddSBjoern A. Zeeb {
2283bfcc09ddSBjoern A. Zeeb }
2284bfcc09ddSBjoern A. Zeeb #endif
2285bfcc09ddSBjoern A. Zeeb 
2286bfcc09ddSBjoern A. Zeeb /* D3 (WoWLAN, NetDetect) */
2287bfcc09ddSBjoern A. Zeeb int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
2288bfcc09ddSBjoern A. Zeeb int iwl_mvm_resume(struct ieee80211_hw *hw);
2289bfcc09ddSBjoern A. Zeeb void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled);
2290bfcc09ddSBjoern A. Zeeb void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw,
2291bfcc09ddSBjoern A. Zeeb 			    struct ieee80211_vif *vif,
2292bfcc09ddSBjoern A. Zeeb 			    struct cfg80211_gtk_rekey_data *data);
2293bfcc09ddSBjoern A. Zeeb void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw,
2294bfcc09ddSBjoern A. Zeeb 			      struct ieee80211_vif *vif,
2295bfcc09ddSBjoern A. Zeeb 			      struct inet6_dev *idev);
2296bfcc09ddSBjoern A. Zeeb void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw,
2297bfcc09ddSBjoern A. Zeeb 				     struct ieee80211_vif *vif, int idx);
2298bfcc09ddSBjoern A. Zeeb extern const struct file_operations iwl_dbgfs_d3_test_ops;
2299bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_PM
2300bfcc09ddSBjoern A. Zeeb void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm,
2301bfcc09ddSBjoern A. Zeeb 				 struct ieee80211_vif *vif);
2302*a4128aadSBjoern A. Zeeb void iwl_mvm_fast_suspend(struct iwl_mvm *mvm);
2303*a4128aadSBjoern A. Zeeb int iwl_mvm_fast_resume(struct iwl_mvm *mvm);
2304bfcc09ddSBjoern A. Zeeb #else
2305bfcc09ddSBjoern A. Zeeb static inline void
2306bfcc09ddSBjoern A. Zeeb iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2307bfcc09ddSBjoern A. Zeeb {
2308bfcc09ddSBjoern A. Zeeb }
2309*a4128aadSBjoern A. Zeeb 
2310*a4128aadSBjoern A. Zeeb static inline void iwl_mvm_fast_suspend(struct iwl_mvm *mvm)
2311*a4128aadSBjoern A. Zeeb {
2312*a4128aadSBjoern A. Zeeb }
2313*a4128aadSBjoern A. Zeeb 
2314*a4128aadSBjoern A. Zeeb static inline int iwl_mvm_fast_resume(struct iwl_mvm *mvm)
2315*a4128aadSBjoern A. Zeeb {
2316*a4128aadSBjoern A. Zeeb 	return 0;
2317*a4128aadSBjoern A. Zeeb }
2318bfcc09ddSBjoern A. Zeeb #endif
2319bfcc09ddSBjoern A. Zeeb void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta,
2320bfcc09ddSBjoern A. Zeeb 				struct iwl_wowlan_config_cmd *cmd);
2321bfcc09ddSBjoern A. Zeeb int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
2322bfcc09ddSBjoern A. Zeeb 			       struct ieee80211_vif *vif,
2323bfcc09ddSBjoern A. Zeeb 			       bool disable_offloading,
2324bfcc09ddSBjoern A. Zeeb 			       bool offload_ns,
2325*a4128aadSBjoern A. Zeeb 			       u32 cmd_flags,
2326*a4128aadSBjoern A. Zeeb 			       u8 sta_id);
2327bfcc09ddSBjoern A. Zeeb 
2328bfcc09ddSBjoern A. Zeeb /* BT Coex */
2329bfcc09ddSBjoern A. Zeeb int iwl_mvm_send_bt_init_conf(struct iwl_mvm *mvm);
2330bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_bt_coex_notif(struct iwl_mvm *mvm,
2331bfcc09ddSBjoern A. Zeeb 			      struct iwl_rx_cmd_buffer *rxb);
2332bfcc09ddSBjoern A. Zeeb void iwl_mvm_bt_rssi_event(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2333bfcc09ddSBjoern A. Zeeb 			   enum ieee80211_rssi_event_data);
2334bfcc09ddSBjoern A. Zeeb void iwl_mvm_bt_coex_vif_change(struct iwl_mvm *mvm);
2335bfcc09ddSBjoern A. Zeeb u16 iwl_mvm_coex_agg_time_limit(struct iwl_mvm *mvm,
2336bfcc09ddSBjoern A. Zeeb 				struct ieee80211_sta *sta);
2337bfcc09ddSBjoern A. Zeeb bool iwl_mvm_bt_coex_is_mimo_allowed(struct iwl_mvm *mvm,
2338bfcc09ddSBjoern A. Zeeb 				     struct ieee80211_sta *sta);
2339bfcc09ddSBjoern A. Zeeb bool iwl_mvm_bt_coex_is_ant_avail(struct iwl_mvm *mvm, u8 ant);
2340bfcc09ddSBjoern A. Zeeb bool iwl_mvm_bt_coex_is_shared_ant_avail(struct iwl_mvm *mvm);
2341bfcc09ddSBjoern A. Zeeb bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm *mvm,
2342bfcc09ddSBjoern A. Zeeb 				    enum nl80211_band band);
2343bfcc09ddSBjoern A. Zeeb u8 iwl_mvm_bt_coex_get_single_ant_msk(struct iwl_mvm *mvm, u8 enabled_ants);
2344bfcc09ddSBjoern A. Zeeb u8 iwl_mvm_bt_coex_tx_prio(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
2345bfcc09ddSBjoern A. Zeeb 			   struct ieee80211_tx_info *info, u8 ac);
2346bfcc09ddSBjoern A. Zeeb 
2347bfcc09ddSBjoern A. Zeeb /* beacon filtering */
2348bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_IWLWIFI_DEBUGFS
2349bfcc09ddSBjoern A. Zeeb void
2350bfcc09ddSBjoern A. Zeeb iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
2351bfcc09ddSBjoern A. Zeeb 					 struct iwl_beacon_filter_cmd *cmd);
2352bfcc09ddSBjoern A. Zeeb #else
2353bfcc09ddSBjoern A. Zeeb static inline void
2354bfcc09ddSBjoern A. Zeeb iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
2355bfcc09ddSBjoern A. Zeeb 					 struct iwl_beacon_filter_cmd *cmd)
2356bfcc09ddSBjoern A. Zeeb {}
2357bfcc09ddSBjoern A. Zeeb #endif
2358bfcc09ddSBjoern A. Zeeb int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm,
2359*a4128aadSBjoern A. Zeeb 				 struct ieee80211_vif *vif);
2360bfcc09ddSBjoern A. Zeeb int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm,
2361*a4128aadSBjoern A. Zeeb 				  struct ieee80211_vif *vif);
2362bfcc09ddSBjoern A. Zeeb /* SMPS */
2363bfcc09ddSBjoern A. Zeeb void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2364bfcc09ddSBjoern A. Zeeb 				enum iwl_mvm_smps_type_request req_type,
23659af1bba4SBjoern A. Zeeb 				enum ieee80211_smps_mode smps_request,
23669af1bba4SBjoern A. Zeeb 				unsigned int link_id);
23679af1bba4SBjoern A. Zeeb void
23689af1bba4SBjoern A. Zeeb iwl_mvm_update_smps_on_active_links(struct iwl_mvm *mvm,
23699af1bba4SBjoern A. Zeeb 				    struct ieee80211_vif *vif,
23709af1bba4SBjoern A. Zeeb 				    enum iwl_mvm_smps_type_request req_type,
2371bfcc09ddSBjoern A. Zeeb 				    enum ieee80211_smps_mode smps_request);
2372bfcc09ddSBjoern A. Zeeb bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm,
2373bfcc09ddSBjoern A. Zeeb 				  struct iwl_mvm_phy_ctxt *ctxt);
23749af1bba4SBjoern A. Zeeb void iwl_mvm_update_link_smps(struct ieee80211_vif *vif,
23759af1bba4SBjoern A. Zeeb 			      struct ieee80211_bss_conf *link_conf);
2376bfcc09ddSBjoern A. Zeeb 
2377bfcc09ddSBjoern A. Zeeb /* Low latency */
2378bfcc09ddSBjoern A. Zeeb int iwl_mvm_update_low_latency(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2379bfcc09ddSBjoern A. Zeeb 			      bool low_latency,
2380bfcc09ddSBjoern A. Zeeb 			      enum iwl_mvm_low_latency_cause cause);
2381bfcc09ddSBjoern A. Zeeb /* get SystemLowLatencyMode - only needed for beacon threshold? */
2382bfcc09ddSBjoern A. Zeeb bool iwl_mvm_low_latency(struct iwl_mvm *mvm);
2383bfcc09ddSBjoern A. Zeeb bool iwl_mvm_low_latency_band(struct iwl_mvm *mvm, enum nl80211_band band);
2384bfcc09ddSBjoern A. Zeeb void iwl_mvm_send_low_latency_cmd(struct iwl_mvm *mvm, bool low_latency,
2385bfcc09ddSBjoern A. Zeeb 				  u16 mac_id);
2386bfcc09ddSBjoern A. Zeeb 
2387bfcc09ddSBjoern A. Zeeb /* get VMACLowLatencyMode */
2388bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_vif_low_latency(struct iwl_mvm_vif *mvmvif)
2389bfcc09ddSBjoern A. Zeeb {
2390bfcc09ddSBjoern A. Zeeb 	/*
2391bfcc09ddSBjoern A. Zeeb 	 * should this consider associated/active/... state?
2392bfcc09ddSBjoern A. Zeeb 	 *
2393bfcc09ddSBjoern A. Zeeb 	 * Normally low-latency should only be active on interfaces
2394bfcc09ddSBjoern A. Zeeb 	 * that are active, but at least with debugfs it can also be
2395bfcc09ddSBjoern A. Zeeb 	 * enabled on interfaces that aren't active. However, when
2396bfcc09ddSBjoern A. Zeeb 	 * interface aren't active then they aren't added into the
2397bfcc09ddSBjoern A. Zeeb 	 * binding, so this has no real impact. For now, just return
2398bfcc09ddSBjoern A. Zeeb 	 * the current desired low-latency state.
2399bfcc09ddSBjoern A. Zeeb 	 */
2400bfcc09ddSBjoern A. Zeeb 	return mvmvif->low_latency_actual;
2401bfcc09ddSBjoern A. Zeeb }
2402bfcc09ddSBjoern A. Zeeb 
2403bfcc09ddSBjoern A. Zeeb static inline
2404bfcc09ddSBjoern A. Zeeb void iwl_mvm_vif_set_low_latency(struct iwl_mvm_vif *mvmvif, bool set,
2405bfcc09ddSBjoern A. Zeeb 				 enum iwl_mvm_low_latency_cause cause)
2406bfcc09ddSBjoern A. Zeeb {
2407bfcc09ddSBjoern A. Zeeb 	u8 new_state;
2408bfcc09ddSBjoern A. Zeeb 
2409bfcc09ddSBjoern A. Zeeb 	if (set)
2410bfcc09ddSBjoern A. Zeeb 		mvmvif->low_latency |= cause;
2411bfcc09ddSBjoern A. Zeeb 	else
2412bfcc09ddSBjoern A. Zeeb 		mvmvif->low_latency &= ~cause;
2413bfcc09ddSBjoern A. Zeeb 
2414bfcc09ddSBjoern A. Zeeb 	/*
2415bfcc09ddSBjoern A. Zeeb 	 * if LOW_LATENCY_DEBUGFS_FORCE_ENABLE is enabled no changes are
2416bfcc09ddSBjoern A. Zeeb 	 * allowed to actual mode.
2417bfcc09ddSBjoern A. Zeeb 	 */
2418bfcc09ddSBjoern A. Zeeb 	if (mvmvif->low_latency & LOW_LATENCY_DEBUGFS_FORCE_ENABLE &&
2419bfcc09ddSBjoern A. Zeeb 	    cause != LOW_LATENCY_DEBUGFS_FORCE_ENABLE)
2420bfcc09ddSBjoern A. Zeeb 		return;
2421bfcc09ddSBjoern A. Zeeb 
2422bfcc09ddSBjoern A. Zeeb 	if (cause == LOW_LATENCY_DEBUGFS_FORCE_ENABLE && set)
2423bfcc09ddSBjoern A. Zeeb 		/*
2424bfcc09ddSBjoern A. Zeeb 		 * We enter force state
2425bfcc09ddSBjoern A. Zeeb 		 */
2426bfcc09ddSBjoern A. Zeeb 		new_state = !!(mvmvif->low_latency &
2427bfcc09ddSBjoern A. Zeeb 			       LOW_LATENCY_DEBUGFS_FORCE);
2428bfcc09ddSBjoern A. Zeeb 	else
2429bfcc09ddSBjoern A. Zeeb 		/*
2430bfcc09ddSBjoern A. Zeeb 		 * Check if any other one set low latency
2431bfcc09ddSBjoern A. Zeeb 		 */
2432bfcc09ddSBjoern A. Zeeb 		new_state = !!(mvmvif->low_latency &
2433bfcc09ddSBjoern A. Zeeb 				  ~(LOW_LATENCY_DEBUGFS_FORCE_ENABLE |
2434bfcc09ddSBjoern A. Zeeb 				    LOW_LATENCY_DEBUGFS_FORCE));
2435bfcc09ddSBjoern A. Zeeb 
2436bfcc09ddSBjoern A. Zeeb 	mvmvif->low_latency_actual = new_state;
2437bfcc09ddSBjoern A. Zeeb }
2438bfcc09ddSBjoern A. Zeeb 
2439bfcc09ddSBjoern A. Zeeb /* Return a bitmask with all the hw supported queues, except for the
2440bfcc09ddSBjoern A. Zeeb  * command queue, which can't be flushed.
2441bfcc09ddSBjoern A. Zeeb  */
2442bfcc09ddSBjoern A. Zeeb static inline u32 iwl_mvm_flushable_queues(struct iwl_mvm *mvm)
2443bfcc09ddSBjoern A. Zeeb {
2444bfcc09ddSBjoern A. Zeeb 	return ((BIT(mvm->trans->trans_cfg->base_params->num_of_queues) - 1) &
2445bfcc09ddSBjoern A. Zeeb 		~BIT(IWL_MVM_DQA_CMD_QUEUE));
2446bfcc09ddSBjoern A. Zeeb }
2447bfcc09ddSBjoern A. Zeeb 
2448bfcc09ddSBjoern A. Zeeb void iwl_mvm_stop_device(struct iwl_mvm *mvm);
2449bfcc09ddSBjoern A. Zeeb 
2450bfcc09ddSBjoern A. Zeeb /* Thermal management and CT-kill */
2451bfcc09ddSBjoern A. Zeeb void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff);
2452bfcc09ddSBjoern A. Zeeb void iwl_mvm_temp_notif(struct iwl_mvm *mvm,
2453bfcc09ddSBjoern A. Zeeb 			struct iwl_rx_cmd_buffer *rxb);
2454bfcc09ddSBjoern A. Zeeb void iwl_mvm_tt_handler(struct iwl_mvm *mvm);
2455bfcc09ddSBjoern A. Zeeb void iwl_mvm_thermal_initialize(struct iwl_mvm *mvm, u32 min_backoff);
2456bfcc09ddSBjoern A. Zeeb void iwl_mvm_thermal_exit(struct iwl_mvm *mvm);
2457bfcc09ddSBjoern A. Zeeb void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm *mvm, bool state);
2458bfcc09ddSBjoern A. Zeeb int iwl_mvm_get_temp(struct iwl_mvm *mvm, s32 *temp);
2459bfcc09ddSBjoern A. Zeeb void iwl_mvm_ct_kill_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
2460bfcc09ddSBjoern A. Zeeb void iwl_mvm_enter_ctkill(struct iwl_mvm *mvm);
2461bfcc09ddSBjoern A. Zeeb int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm);
2462bfcc09ddSBjoern A. Zeeb int iwl_mvm_ctdp_command(struct iwl_mvm *mvm, u32 op, u32 budget);
2463bfcc09ddSBjoern A. Zeeb 
2464d9836fb4SBjoern A. Zeeb #if IS_ENABLED(CONFIG_IWLMEI)
2465d9836fb4SBjoern A. Zeeb 
2466d9836fb4SBjoern A. Zeeb /* vendor commands */
2467d9836fb4SBjoern A. Zeeb void iwl_mvm_vendor_cmds_register(struct iwl_mvm *mvm);
2468d9836fb4SBjoern A. Zeeb 
2469d9836fb4SBjoern A. Zeeb #else
2470d9836fb4SBjoern A. Zeeb 
2471d9836fb4SBjoern A. Zeeb static inline void iwl_mvm_vendor_cmds_register(struct iwl_mvm *mvm) {}
2472d9836fb4SBjoern A. Zeeb 
2473d9836fb4SBjoern A. Zeeb #endif
2474d9836fb4SBjoern A. Zeeb 
2475bfcc09ddSBjoern A. Zeeb /* Location Aware Regulatory */
24769af1bba4SBjoern A. Zeeb struct iwl_mcc_update_resp_v8 *
2477bfcc09ddSBjoern A. Zeeb iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2,
2478bfcc09ddSBjoern A. Zeeb 		   enum iwl_mcc_source src_id);
2479bfcc09ddSBjoern A. Zeeb int iwl_mvm_init_mcc(struct iwl_mvm *mvm);
2480bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_chub_update_mcc(struct iwl_mvm *mvm,
2481bfcc09ddSBjoern A. Zeeb 				struct iwl_rx_cmd_buffer *rxb);
2482bfcc09ddSBjoern A. Zeeb struct ieee80211_regdomain *iwl_mvm_get_regdomain(struct wiphy *wiphy,
2483bfcc09ddSBjoern A. Zeeb 						  const char *alpha2,
2484bfcc09ddSBjoern A. Zeeb 						  enum iwl_mcc_source src_id,
2485bfcc09ddSBjoern A. Zeeb 						  bool *changed);
2486bfcc09ddSBjoern A. Zeeb struct ieee80211_regdomain *iwl_mvm_get_current_regdomain(struct iwl_mvm *mvm,
2487bfcc09ddSBjoern A. Zeeb 							  bool *changed);
2488*a4128aadSBjoern A. Zeeb int iwl_mvm_init_fw_regd(struct iwl_mvm *mvm, bool force_regd_sync);
2489bfcc09ddSBjoern A. Zeeb void iwl_mvm_update_changed_regdom(struct iwl_mvm *mvm);
2490bfcc09ddSBjoern A. Zeeb 
2491bfcc09ddSBjoern A. Zeeb /* smart fifo */
2492bfcc09ddSBjoern A. Zeeb int iwl_mvm_sf_update(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2493bfcc09ddSBjoern A. Zeeb 		      bool added_vif);
2494bfcc09ddSBjoern A. Zeeb 
2495bfcc09ddSBjoern A. Zeeb /* FTM responder */
24969af1bba4SBjoern A. Zeeb int iwl_mvm_ftm_start_responder(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
24979af1bba4SBjoern A. Zeeb 				struct ieee80211_bss_conf *bss_conf);
2498bfcc09ddSBjoern A. Zeeb void iwl_mvm_ftm_restart_responder(struct iwl_mvm *mvm,
24999af1bba4SBjoern A. Zeeb 				   struct ieee80211_vif *vif,
25009af1bba4SBjoern A. Zeeb 				   struct ieee80211_bss_conf *bss_conf);
2501bfcc09ddSBjoern A. Zeeb void iwl_mvm_ftm_responder_stats(struct iwl_mvm *mvm,
2502bfcc09ddSBjoern A. Zeeb 				 struct iwl_rx_cmd_buffer *rxb);
25037db7bfe1SBjoern A. Zeeb #if defined(__linux__)
2504bfcc09ddSBjoern A. Zeeb int iwl_mvm_ftm_resp_remove_pasn_sta(struct iwl_mvm *mvm,
2505bfcc09ddSBjoern A. Zeeb 				     struct ieee80211_vif *vif, u8 *addr);
2506bfcc09ddSBjoern A. Zeeb int iwl_mvm_ftm_respoder_add_pasn_sta(struct iwl_mvm *mvm,
2507bfcc09ddSBjoern A. Zeeb 				      struct ieee80211_vif *vif,
2508bfcc09ddSBjoern A. Zeeb 				      u8 *addr, u32 cipher, u8 *tk, u32 tk_len,
2509bfcc09ddSBjoern A. Zeeb 				      u8 *hltk, u32 hltk_len);
25107db7bfe1SBjoern A. Zeeb #endif
2511bfcc09ddSBjoern A. Zeeb void iwl_mvm_ftm_responder_clear(struct iwl_mvm *mvm,
2512bfcc09ddSBjoern A. Zeeb 				 struct ieee80211_vif *vif);
2513bfcc09ddSBjoern A. Zeeb 
2514bfcc09ddSBjoern A. Zeeb /* FTM initiator */
2515bfcc09ddSBjoern A. Zeeb void iwl_mvm_ftm_restart(struct iwl_mvm *mvm);
2516bfcc09ddSBjoern A. Zeeb void iwl_mvm_ftm_range_resp(struct iwl_mvm *mvm,
2517bfcc09ddSBjoern A. Zeeb 			    struct iwl_rx_cmd_buffer *rxb);
2518bfcc09ddSBjoern A. Zeeb void iwl_mvm_ftm_lc_notif(struct iwl_mvm *mvm,
2519bfcc09ddSBjoern A. Zeeb 			  struct iwl_rx_cmd_buffer *rxb);
2520bfcc09ddSBjoern A. Zeeb int iwl_mvm_ftm_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2521bfcc09ddSBjoern A. Zeeb 		      struct cfg80211_pmsr_request *request);
2522bfcc09ddSBjoern A. Zeeb void iwl_mvm_ftm_abort(struct iwl_mvm *mvm, struct cfg80211_pmsr_request *req);
2523bfcc09ddSBjoern A. Zeeb void iwl_mvm_ftm_initiator_smooth_config(struct iwl_mvm *mvm);
2524bfcc09ddSBjoern A. Zeeb void iwl_mvm_ftm_initiator_smooth_stop(struct iwl_mvm *mvm);
2525bfcc09ddSBjoern A. Zeeb int iwl_mvm_ftm_add_pasn_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2526bfcc09ddSBjoern A. Zeeb 			     u8 *addr, u32 cipher, u8 *tk, u32 tk_len,
2527bfcc09ddSBjoern A. Zeeb 			     u8 *hltk, u32 hltk_len);
2528bfcc09ddSBjoern A. Zeeb void iwl_mvm_ftm_remove_pasn_sta(struct iwl_mvm *mvm, u8 *addr);
2529bfcc09ddSBjoern A. Zeeb 
2530bfcc09ddSBjoern A. Zeeb /* TDLS */
2531bfcc09ddSBjoern A. Zeeb 
2532bfcc09ddSBjoern A. Zeeb /*
2533bfcc09ddSBjoern A. Zeeb  * We use TID 4 (VI) as a FW-used-only TID when TDLS connections are present.
2534bfcc09ddSBjoern A. Zeeb  * This TID is marked as used vs the AP and all connected TDLS peers.
2535bfcc09ddSBjoern A. Zeeb  */
2536bfcc09ddSBjoern A. Zeeb #define IWL_MVM_TDLS_FW_TID 4
2537bfcc09ddSBjoern A. Zeeb 
2538bfcc09ddSBjoern A. Zeeb int iwl_mvm_tdls_sta_count(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2539bfcc09ddSBjoern A. Zeeb void iwl_mvm_teardown_tdls_peers(struct iwl_mvm *mvm);
2540bfcc09ddSBjoern A. Zeeb void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2541bfcc09ddSBjoern A. Zeeb 			       bool sta_added);
2542bfcc09ddSBjoern A. Zeeb void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,
2543*a4128aadSBjoern A. Zeeb 					   struct ieee80211_vif *vif,
2544*a4128aadSBjoern A. Zeeb 					   unsigned int link_id);
2545bfcc09ddSBjoern A. Zeeb int iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw,
2546bfcc09ddSBjoern A. Zeeb 				struct ieee80211_vif *vif,
2547bfcc09ddSBjoern A. Zeeb 				struct ieee80211_sta *sta, u8 oper_class,
2548bfcc09ddSBjoern A. Zeeb 				struct cfg80211_chan_def *chandef,
2549bfcc09ddSBjoern A. Zeeb 				struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie);
2550bfcc09ddSBjoern A. Zeeb void iwl_mvm_tdls_recv_channel_switch(struct ieee80211_hw *hw,
2551bfcc09ddSBjoern A. Zeeb 				      struct ieee80211_vif *vif,
2552bfcc09ddSBjoern A. Zeeb 				      struct ieee80211_tdls_ch_sw_params *params);
2553bfcc09ddSBjoern A. Zeeb void iwl_mvm_tdls_cancel_channel_switch(struct ieee80211_hw *hw,
2554bfcc09ddSBjoern A. Zeeb 					struct ieee80211_vif *vif,
2555bfcc09ddSBjoern A. Zeeb 					struct ieee80211_sta *sta);
2556bfcc09ddSBjoern A. Zeeb void iwl_mvm_rx_tdls_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
2557bfcc09ddSBjoern A. Zeeb void iwl_mvm_tdls_ch_switch_work(struct work_struct *work);
2558bfcc09ddSBjoern A. Zeeb 
2559bfcc09ddSBjoern A. Zeeb void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm,
2560bfcc09ddSBjoern A. Zeeb 				     enum iwl_mvm_rxq_notif_type type,
2561bfcc09ddSBjoern A. Zeeb 				     bool sync,
2562bfcc09ddSBjoern A. Zeeb 				     const void *data, u32 size);
2563bfcc09ddSBjoern A. Zeeb struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm);
2564bfcc09ddSBjoern A. Zeeb struct ieee80211_vif *iwl_mvm_get_vif_by_macid(struct iwl_mvm *mvm, u32 macid);
2565bfcc09ddSBjoern A. Zeeb bool iwl_mvm_is_vif_assoc(struct iwl_mvm *mvm);
2566bfcc09ddSBjoern A. Zeeb 
2567bfcc09ddSBjoern A. Zeeb #define MVM_TCM_PERIOD_MSEC 500
2568bfcc09ddSBjoern A. Zeeb #define MVM_TCM_PERIOD (HZ * MVM_TCM_PERIOD_MSEC / 1000)
2569bfcc09ddSBjoern A. Zeeb #define MVM_LL_PERIOD (10 * HZ)
2570bfcc09ddSBjoern A. Zeeb void iwl_mvm_tcm_work(struct work_struct *work);
2571bfcc09ddSBjoern A. Zeeb void iwl_mvm_recalc_tcm(struct iwl_mvm *mvm);
2572bfcc09ddSBjoern A. Zeeb void iwl_mvm_pause_tcm(struct iwl_mvm *mvm, bool with_cancel);
2573bfcc09ddSBjoern A. Zeeb void iwl_mvm_resume_tcm(struct iwl_mvm *mvm);
2574bfcc09ddSBjoern A. Zeeb void iwl_mvm_tcm_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2575bfcc09ddSBjoern A. Zeeb void iwl_mvm_tcm_rm_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2576bfcc09ddSBjoern A. Zeeb u8 iwl_mvm_tcm_load_percentage(u32 airtime, u32 elapsed);
2577bfcc09ddSBjoern A. Zeeb 
2578bfcc09ddSBjoern A. Zeeb void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error);
2579bfcc09ddSBjoern A. Zeeb unsigned int iwl_mvm_get_wd_timeout(struct iwl_mvm *mvm,
2580bfcc09ddSBjoern A. Zeeb 				    struct ieee80211_vif *vif,
2581bfcc09ddSBjoern A. Zeeb 				    bool tdls, bool cmd_q);
2582bfcc09ddSBjoern A. Zeeb void iwl_mvm_connection_loss(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2583bfcc09ddSBjoern A. Zeeb 			     const char *errmsg);
2584bfcc09ddSBjoern A. Zeeb void iwl_mvm_event_frame_timeout_callback(struct iwl_mvm *mvm,
2585bfcc09ddSBjoern A. Zeeb 					  struct ieee80211_vif *vif,
2586bfcc09ddSBjoern A. Zeeb 					  const struct ieee80211_sta *sta,
2587bfcc09ddSBjoern A. Zeeb 					  u16 tid);
25889af1bba4SBjoern A. Zeeb void iwl_mvm_mei_scan_filter_init(struct iwl_mei_scan_filter *mei_scan_filter);
2589bfcc09ddSBjoern A. Zeeb 
25909af1bba4SBjoern A. Zeeb void iwl_mvm_ptp_init(struct iwl_mvm *mvm);
25919af1bba4SBjoern A. Zeeb void iwl_mvm_ptp_remove(struct iwl_mvm *mvm);
25929af1bba4SBjoern A. Zeeb u64 iwl_mvm_ptp_get_adj_time(struct iwl_mvm *mvm, u64 base_time);
2593bfcc09ddSBjoern A. Zeeb int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b);
2594bfcc09ddSBjoern A. Zeeb int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm);
2595bfcc09ddSBjoern A. Zeeb int iwl_mvm_ppag_send_cmd(struct iwl_mvm *mvm);
2596*a4128aadSBjoern A. Zeeb void iwl_mvm_get_bios_tables(struct iwl_mvm *mvm);
2597bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_IWLWIFI_DEBUGFS
25989af1bba4SBjoern A. Zeeb void iwl_mvm_link_sta_add_debugfs(struct ieee80211_hw *hw,
2599bfcc09ddSBjoern A. Zeeb 				  struct ieee80211_vif *vif,
26009af1bba4SBjoern A. Zeeb 				  struct ieee80211_link_sta *link_sta,
2601bfcc09ddSBjoern A. Zeeb 				  struct dentry *dir);
2602*a4128aadSBjoern A. Zeeb void iwl_mvm_link_add_debugfs(struct ieee80211_hw *hw,
2603*a4128aadSBjoern A. Zeeb 			      struct ieee80211_vif *vif,
2604*a4128aadSBjoern A. Zeeb 			      struct ieee80211_bss_conf *link_conf,
2605*a4128aadSBjoern A. Zeeb 			      struct dentry *dir);
2606bfcc09ddSBjoern A. Zeeb #endif
2607bfcc09ddSBjoern A. Zeeb 
26089af1bba4SBjoern A. Zeeb /* new MLD related APIs */
26099af1bba4SBjoern A. Zeeb int iwl_mvm_sec_key_add(struct iwl_mvm *mvm,
26109af1bba4SBjoern A. Zeeb 			struct ieee80211_vif *vif,
26119af1bba4SBjoern A. Zeeb 			struct ieee80211_sta *sta,
26129af1bba4SBjoern A. Zeeb 			struct ieee80211_key_conf *keyconf);
26139af1bba4SBjoern A. Zeeb int iwl_mvm_sec_key_del(struct iwl_mvm *mvm,
26149af1bba4SBjoern A. Zeeb 			struct ieee80211_vif *vif,
26159af1bba4SBjoern A. Zeeb 			struct ieee80211_sta *sta,
26169af1bba4SBjoern A. Zeeb 			struct ieee80211_key_conf *keyconf);
2617*a4128aadSBjoern A. Zeeb int iwl_mvm_sec_key_del_pasn(struct iwl_mvm *mvm,
2618*a4128aadSBjoern A. Zeeb 			     struct ieee80211_vif *vif,
2619*a4128aadSBjoern A. Zeeb 			     u32 sta_mask,
2620*a4128aadSBjoern A. Zeeb 			     struct ieee80211_key_conf *keyconf);
26219af1bba4SBjoern A. Zeeb void iwl_mvm_sec_key_remove_ap(struct iwl_mvm *mvm,
26229af1bba4SBjoern A. Zeeb 			       struct ieee80211_vif *vif,
26239af1bba4SBjoern A. Zeeb 			       struct iwl_mvm_vif_link_info *link,
26249af1bba4SBjoern A. Zeeb 			       unsigned int link_id);
26259af1bba4SBjoern A. Zeeb int iwl_mvm_mld_update_sta_keys(struct iwl_mvm *mvm,
26269af1bba4SBjoern A. Zeeb 				struct ieee80211_vif *vif,
26279af1bba4SBjoern A. Zeeb 				struct ieee80211_sta *sta,
26289af1bba4SBjoern A. Zeeb 				u32 old_sta_mask,
26299af1bba4SBjoern A. Zeeb 				u32 new_sta_mask);
26309af1bba4SBjoern A. Zeeb int iwl_mvm_mld_send_key(struct iwl_mvm *mvm, u32 sta_mask, u32 key_flags,
26319af1bba4SBjoern A. Zeeb 			 struct ieee80211_key_conf *keyconf);
26329af1bba4SBjoern A. Zeeb u32 iwl_mvm_get_sec_flags(struct iwl_mvm *mvm,
26339af1bba4SBjoern A. Zeeb 			  struct ieee80211_vif *vif,
26349af1bba4SBjoern A. Zeeb 			  struct ieee80211_sta *sta,
26359af1bba4SBjoern A. Zeeb 			  struct ieee80211_key_conf *keyconf);
26369af1bba4SBjoern A. Zeeb 
26379af1bba4SBjoern A. Zeeb bool iwl_rfi_supported(struct iwl_mvm *mvm);
2638bfcc09ddSBjoern A. Zeeb int iwl_rfi_send_config_cmd(struct iwl_mvm *mvm,
2639bfcc09ddSBjoern A. Zeeb 			    struct iwl_rfi_lut_entry *rfi_table);
2640bfcc09ddSBjoern A. Zeeb struct iwl_rfi_freq_table_resp_cmd *iwl_rfi_get_freq_table(struct iwl_mvm *mvm);
2641d9836fb4SBjoern A. Zeeb void iwl_rfi_deactivate_notif_handler(struct iwl_mvm *mvm,
2642d9836fb4SBjoern A. Zeeb 				      struct iwl_rx_cmd_buffer *rxb);
2643bfcc09ddSBjoern A. Zeeb 
2644bfcc09ddSBjoern A. Zeeb static inline u8 iwl_mvm_phy_band_from_nl80211(enum nl80211_band band)
2645bfcc09ddSBjoern A. Zeeb {
2646bfcc09ddSBjoern A. Zeeb 	switch (band) {
2647bfcc09ddSBjoern A. Zeeb 	case NL80211_BAND_2GHZ:
2648bfcc09ddSBjoern A. Zeeb 		return PHY_BAND_24;
2649bfcc09ddSBjoern A. Zeeb 	case NL80211_BAND_5GHZ:
2650bfcc09ddSBjoern A. Zeeb 		return PHY_BAND_5;
2651bfcc09ddSBjoern A. Zeeb 	case NL80211_BAND_6GHZ:
2652bfcc09ddSBjoern A. Zeeb 		return PHY_BAND_6;
2653bfcc09ddSBjoern A. Zeeb 	default:
2654bfcc09ddSBjoern A. Zeeb 		WARN_ONCE(1, "Unsupported band (%u)\n", band);
2655bfcc09ddSBjoern A. Zeeb 		return PHY_BAND_5;
2656bfcc09ddSBjoern A. Zeeb 	}
2657bfcc09ddSBjoern A. Zeeb }
2658bfcc09ddSBjoern A. Zeeb 
2659*a4128aadSBjoern A. Zeeb static inline u8 iwl_mvm_nl80211_band_from_phy(u8 phy_band)
2660*a4128aadSBjoern A. Zeeb {
2661*a4128aadSBjoern A. Zeeb 	switch (phy_band) {
2662*a4128aadSBjoern A. Zeeb 	case PHY_BAND_24:
2663*a4128aadSBjoern A. Zeeb 		return NL80211_BAND_2GHZ;
2664*a4128aadSBjoern A. Zeeb 	case PHY_BAND_5:
2665*a4128aadSBjoern A. Zeeb 		return NL80211_BAND_5GHZ;
2666*a4128aadSBjoern A. Zeeb 	case PHY_BAND_6:
2667*a4128aadSBjoern A. Zeeb 		return NL80211_BAND_6GHZ;
2668*a4128aadSBjoern A. Zeeb 	default:
2669*a4128aadSBjoern A. Zeeb 		WARN_ONCE(1, "Unsupported phy band (%u)\n", phy_band);
2670*a4128aadSBjoern A. Zeeb 		return NL80211_BAND_5GHZ;
2671*a4128aadSBjoern A. Zeeb 	}
2672*a4128aadSBjoern A. Zeeb }
2673*a4128aadSBjoern A. Zeeb 
26749af1bba4SBjoern A. Zeeb /* Channel Switch */
26759af1bba4SBjoern A. Zeeb void iwl_mvm_channel_switch_disconnect_wk(struct work_struct *wk);
26769af1bba4SBjoern A. Zeeb int iwl_mvm_post_channel_switch(struct ieee80211_hw *hw,
2677*a4128aadSBjoern A. Zeeb 				struct ieee80211_vif *vif,
2678*a4128aadSBjoern A. Zeeb 				struct ieee80211_bss_conf *link);
26799af1bba4SBjoern A. Zeeb 
26809af1bba4SBjoern A. Zeeb /* Channel Context */
26819af1bba4SBjoern A. Zeeb /**
26829af1bba4SBjoern A. Zeeb  * struct iwl_mvm_switch_vif_chanctx_ops - callbacks for switch_vif_chanctx()
26839af1bba4SBjoern A. Zeeb  *
26849af1bba4SBjoern A. Zeeb  * Since the only difference between both MLD and
26859af1bba4SBjoern A. Zeeb  * non-MLD versions of switch_vif_chanctx() is these function calls,
26869af1bba4SBjoern A. Zeeb  * each version will send its specific function calls to
26879af1bba4SBjoern A. Zeeb  * %iwl_mvm_switch_vif_chanctx_common().
26889af1bba4SBjoern A. Zeeb  *
26899af1bba4SBjoern A. Zeeb  * @__assign_vif_chanctx: pointer to the function that assigns a chanctx to
26909af1bba4SBjoern A. Zeeb  *	a given vif
26919af1bba4SBjoern A. Zeeb  * @__unassign_vif_chanctx: pointer to the function that unassigns a chanctx to
26929af1bba4SBjoern A. Zeeb  *	a given vif
26939af1bba4SBjoern A. Zeeb  */
26949af1bba4SBjoern A. Zeeb struct iwl_mvm_switch_vif_chanctx_ops {
26959af1bba4SBjoern A. Zeeb 	int (*__assign_vif_chanctx)(struct iwl_mvm *mvm,
26969af1bba4SBjoern A. Zeeb 				    struct ieee80211_vif *vif,
26979af1bba4SBjoern A. Zeeb 				    struct ieee80211_bss_conf *link_conf,
26989af1bba4SBjoern A. Zeeb 				    struct ieee80211_chanctx_conf *ctx,
26999af1bba4SBjoern A. Zeeb 				    bool switching_chanctx);
27009af1bba4SBjoern A. Zeeb 	void (*__unassign_vif_chanctx)(struct iwl_mvm *mvm,
27019af1bba4SBjoern A. Zeeb 				       struct ieee80211_vif *vif,
27029af1bba4SBjoern A. Zeeb 				       struct ieee80211_bss_conf *link_conf,
27039af1bba4SBjoern A. Zeeb 				       struct ieee80211_chanctx_conf *ctx,
27049af1bba4SBjoern A. Zeeb 				       bool switching_chanctx);
27059af1bba4SBjoern A. Zeeb };
27069af1bba4SBjoern A. Zeeb 
27079af1bba4SBjoern A. Zeeb int
27089af1bba4SBjoern A. Zeeb iwl_mvm_switch_vif_chanctx_common(struct ieee80211_hw *hw,
27099af1bba4SBjoern A. Zeeb 				  struct ieee80211_vif_chanctx_switch *vifs,
27109af1bba4SBjoern A. Zeeb 				  int n_vifs,
27119af1bba4SBjoern A. Zeeb 				  enum ieee80211_chanctx_switch_mode mode,
27129af1bba4SBjoern A. Zeeb 				  const struct iwl_mvm_switch_vif_chanctx_ops *ops);
27139af1bba4SBjoern A. Zeeb 
2714bfcc09ddSBjoern A. Zeeb /* Channel info utils */
2715bfcc09ddSBjoern A. Zeeb static inline bool iwl_mvm_has_ultra_hb_channel(struct iwl_mvm *mvm)
2716bfcc09ddSBjoern A. Zeeb {
2717bfcc09ddSBjoern A. Zeeb 	return fw_has_capa(&mvm->fw->ucode_capa,
2718bfcc09ddSBjoern A. Zeeb 			   IWL_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS);
2719bfcc09ddSBjoern A. Zeeb }
2720bfcc09ddSBjoern A. Zeeb 
2721bfcc09ddSBjoern A. Zeeb static inline void *iwl_mvm_chan_info_cmd_tail(struct iwl_mvm *mvm,
2722bfcc09ddSBjoern A. Zeeb 					       struct iwl_fw_channel_info *ci)
2723bfcc09ddSBjoern A. Zeeb {
2724bfcc09ddSBjoern A. Zeeb 	return (u8 *)ci + (iwl_mvm_has_ultra_hb_channel(mvm) ?
2725bfcc09ddSBjoern A. Zeeb 			   sizeof(struct iwl_fw_channel_info) :
2726bfcc09ddSBjoern A. Zeeb 			   sizeof(struct iwl_fw_channel_info_v1));
2727bfcc09ddSBjoern A. Zeeb }
2728bfcc09ddSBjoern A. Zeeb 
2729bfcc09ddSBjoern A. Zeeb static inline size_t iwl_mvm_chan_info_padding(struct iwl_mvm *mvm)
2730bfcc09ddSBjoern A. Zeeb {
2731bfcc09ddSBjoern A. Zeeb 	return iwl_mvm_has_ultra_hb_channel(mvm) ? 0 :
2732bfcc09ddSBjoern A. Zeeb 		sizeof(struct iwl_fw_channel_info) -
2733bfcc09ddSBjoern A. Zeeb 		sizeof(struct iwl_fw_channel_info_v1);
2734bfcc09ddSBjoern A. Zeeb }
2735bfcc09ddSBjoern A. Zeeb 
2736bfcc09ddSBjoern A. Zeeb static inline void iwl_mvm_set_chan_info(struct iwl_mvm *mvm,
2737bfcc09ddSBjoern A. Zeeb 					 struct iwl_fw_channel_info *ci,
2738bfcc09ddSBjoern A. Zeeb 					 u32 chan, u8 band, u8 width,
2739bfcc09ddSBjoern A. Zeeb 					 u8 ctrl_pos)
2740bfcc09ddSBjoern A. Zeeb {
2741bfcc09ddSBjoern A. Zeeb 	if (iwl_mvm_has_ultra_hb_channel(mvm)) {
2742bfcc09ddSBjoern A. Zeeb 		ci->channel = cpu_to_le32(chan);
2743bfcc09ddSBjoern A. Zeeb 		ci->band = band;
2744bfcc09ddSBjoern A. Zeeb 		ci->width = width;
2745bfcc09ddSBjoern A. Zeeb 		ci->ctrl_pos = ctrl_pos;
2746bfcc09ddSBjoern A. Zeeb 	} else {
2747bfcc09ddSBjoern A. Zeeb 		struct iwl_fw_channel_info_v1 *ci_v1 =
2748bfcc09ddSBjoern A. Zeeb 					(struct iwl_fw_channel_info_v1 *)ci;
2749bfcc09ddSBjoern A. Zeeb 
2750bfcc09ddSBjoern A. Zeeb 		ci_v1->channel = chan;
2751bfcc09ddSBjoern A. Zeeb 		ci_v1->band = band;
2752bfcc09ddSBjoern A. Zeeb 		ci_v1->width = width;
2753bfcc09ddSBjoern A. Zeeb 		ci_v1->ctrl_pos = ctrl_pos;
2754bfcc09ddSBjoern A. Zeeb 	}
2755bfcc09ddSBjoern A. Zeeb }
2756bfcc09ddSBjoern A. Zeeb 
2757bfcc09ddSBjoern A. Zeeb static inline void
2758bfcc09ddSBjoern A. Zeeb iwl_mvm_set_chan_info_chandef(struct iwl_mvm *mvm,
2759bfcc09ddSBjoern A. Zeeb 			      struct iwl_fw_channel_info *ci,
2760*a4128aadSBjoern A. Zeeb 			      const struct cfg80211_chan_def *chandef)
2761bfcc09ddSBjoern A. Zeeb {
2762bfcc09ddSBjoern A. Zeeb 	enum nl80211_band band = chandef->chan->band;
2763bfcc09ddSBjoern A. Zeeb 
2764bfcc09ddSBjoern A. Zeeb 	iwl_mvm_set_chan_info(mvm, ci, chandef->chan->hw_value,
2765bfcc09ddSBjoern A. Zeeb 			      iwl_mvm_phy_band_from_nl80211(band),
2766bfcc09ddSBjoern A. Zeeb 			      iwl_mvm_get_channel_width(chandef),
2767bfcc09ddSBjoern A. Zeeb 			      iwl_mvm_get_ctrl_pos(chandef));
2768bfcc09ddSBjoern A. Zeeb }
2769bfcc09ddSBjoern A. Zeeb 
2770bfcc09ddSBjoern A. Zeeb static inline int iwl_umac_scan_get_max_profiles(const struct iwl_fw *fw)
2771bfcc09ddSBjoern A. Zeeb {
2772d9836fb4SBjoern A. Zeeb 	u8 ver = iwl_fw_lookup_cmd_ver(fw, SCAN_OFFLOAD_UPDATE_PROFILES_CMD,
2773bfcc09ddSBjoern A. Zeeb 				       IWL_FW_CMD_VER_UNKNOWN);
2774bfcc09ddSBjoern A. Zeeb 	return (ver == IWL_FW_CMD_VER_UNKNOWN || ver < 3) ?
2775bfcc09ddSBjoern A. Zeeb 		IWL_SCAN_MAX_PROFILES : IWL_SCAN_MAX_PROFILES_V2;
2776bfcc09ddSBjoern A. Zeeb }
2777bfcc09ddSBjoern A. Zeeb 
2778bfcc09ddSBjoern A. Zeeb static inline
2779bfcc09ddSBjoern A. Zeeb enum iwl_location_cipher iwl_mvm_cipher_to_location_cipher(u32 cipher)
2780bfcc09ddSBjoern A. Zeeb {
2781bfcc09ddSBjoern A. Zeeb 	switch (cipher) {
2782bfcc09ddSBjoern A. Zeeb 	case WLAN_CIPHER_SUITE_CCMP:
2783bfcc09ddSBjoern A. Zeeb 		return IWL_LOCATION_CIPHER_CCMP_128;
2784bfcc09ddSBjoern A. Zeeb 	case WLAN_CIPHER_SUITE_GCMP:
2785bfcc09ddSBjoern A. Zeeb 		return IWL_LOCATION_CIPHER_GCMP_128;
2786bfcc09ddSBjoern A. Zeeb 	case WLAN_CIPHER_SUITE_GCMP_256:
2787bfcc09ddSBjoern A. Zeeb 		return IWL_LOCATION_CIPHER_GCMP_256;
2788bfcc09ddSBjoern A. Zeeb 	default:
2789bfcc09ddSBjoern A. Zeeb 		return IWL_LOCATION_CIPHER_INVALID;
2790bfcc09ddSBjoern A. Zeeb 	}
2791bfcc09ddSBjoern A. Zeeb }
2792d9836fb4SBjoern A. Zeeb 
2793d9836fb4SBjoern A. Zeeb struct iwl_mvm_csme_conn_info *iwl_mvm_get_csme_conn_info(struct iwl_mvm *mvm);
2794d9836fb4SBjoern A. Zeeb static inline int iwl_mvm_mei_get_ownership(struct iwl_mvm *mvm)
2795d9836fb4SBjoern A. Zeeb {
2796d9836fb4SBjoern A. Zeeb 	if (mvm->mei_registered)
2797d9836fb4SBjoern A. Zeeb 		return iwl_mei_get_ownership();
2798d9836fb4SBjoern A. Zeeb 	return 0;
2799d9836fb4SBjoern A. Zeeb }
2800d9836fb4SBjoern A. Zeeb 
2801d9836fb4SBjoern A. Zeeb static inline void iwl_mvm_mei_tx_copy_to_csme(struct iwl_mvm *mvm,
2802d9836fb4SBjoern A. Zeeb 					       struct sk_buff *skb,
2803d9836fb4SBjoern A. Zeeb 					       unsigned int ivlen)
2804d9836fb4SBjoern A. Zeeb {
2805d9836fb4SBjoern A. Zeeb 	if (mvm->mei_registered)
2806d9836fb4SBjoern A. Zeeb 		iwl_mei_tx_copy_to_csme(skb, ivlen);
2807d9836fb4SBjoern A. Zeeb }
2808d9836fb4SBjoern A. Zeeb 
2809d9836fb4SBjoern A. Zeeb static inline void iwl_mvm_mei_host_disassociated(struct iwl_mvm *mvm)
2810d9836fb4SBjoern A. Zeeb {
2811d9836fb4SBjoern A. Zeeb 	if (mvm->mei_registered)
2812d9836fb4SBjoern A. Zeeb 		iwl_mei_host_disassociated();
2813d9836fb4SBjoern A. Zeeb }
2814d9836fb4SBjoern A. Zeeb 
28159af1bba4SBjoern A. Zeeb static inline void iwl_mvm_mei_device_state(struct iwl_mvm *mvm, bool up)
2816d9836fb4SBjoern A. Zeeb {
2817d9836fb4SBjoern A. Zeeb 	if (mvm->mei_registered)
28189af1bba4SBjoern A. Zeeb 		iwl_mei_device_state(up);
2819d9836fb4SBjoern A. Zeeb }
2820d9836fb4SBjoern A. Zeeb 
2821d9836fb4SBjoern A. Zeeb static inline void iwl_mvm_mei_set_sw_rfkill_state(struct iwl_mvm *mvm)
2822d9836fb4SBjoern A. Zeeb {
2823d9836fb4SBjoern A. Zeeb 	bool sw_rfkill =
2824fac1f593SBjoern A. Zeeb 		mvm->hw_registered ? rfkill_soft_blocked(mvm->hw->wiphy->rfkill) : false;
2825d9836fb4SBjoern A. Zeeb 
2826d9836fb4SBjoern A. Zeeb 	if (mvm->mei_registered)
2827d9836fb4SBjoern A. Zeeb 		iwl_mei_set_rfkill_state(iwl_mvm_is_radio_killed(mvm),
2828d9836fb4SBjoern A. Zeeb 					 sw_rfkill);
2829d9836fb4SBjoern A. Zeeb }
2830d9836fb4SBjoern A. Zeeb 
2831*a4128aadSBjoern A. Zeeb static inline bool iwl_mvm_has_p2p_over_aux(struct iwl_mvm *mvm)
2832*a4128aadSBjoern A. Zeeb {
2833*a4128aadSBjoern A. Zeeb 	u32 cmd_id = WIDE_ID(MAC_CONF_GROUP, ROC_CMD);
2834*a4128aadSBjoern A. Zeeb 
2835*a4128aadSBjoern A. Zeeb 	return iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id, 0) >= 4;
2836*a4128aadSBjoern A. Zeeb }
2837*a4128aadSBjoern A. Zeeb 
28389af1bba4SBjoern A. Zeeb static inline bool iwl_mvm_mei_filter_scan(struct iwl_mvm *mvm,
28399af1bba4SBjoern A. Zeeb 					   struct sk_buff *skb)
28409af1bba4SBjoern A. Zeeb {
28419af1bba4SBjoern A. Zeeb 	struct ieee80211_mgmt *mgmt = (void *)skb->data;
28429af1bba4SBjoern A. Zeeb 
28439af1bba4SBjoern A. Zeeb 	if (mvm->mei_scan_filter.is_mei_limited_scan &&
28449af1bba4SBjoern A. Zeeb 	    (ieee80211_is_probe_resp(mgmt->frame_control) ||
28459af1bba4SBjoern A. Zeeb 	     ieee80211_is_beacon(mgmt->frame_control))) {
28469af1bba4SBjoern A. Zeeb 		skb_queue_tail(&mvm->mei_scan_filter.scan_res, skb);
28479af1bba4SBjoern A. Zeeb 		schedule_work(&mvm->mei_scan_filter.scan_work);
28489af1bba4SBjoern A. Zeeb 		return true;
28499af1bba4SBjoern A. Zeeb 	}
28509af1bba4SBjoern A. Zeeb 
28519af1bba4SBjoern A. Zeeb 	return false;
28529af1bba4SBjoern A. Zeeb }
28539af1bba4SBjoern A. Zeeb 
2854d9836fb4SBjoern A. Zeeb void iwl_mvm_send_roaming_forbidden_event(struct iwl_mvm *mvm,
2855d9836fb4SBjoern A. Zeeb 					  struct ieee80211_vif *vif,
2856d9836fb4SBjoern A. Zeeb 					  bool forbidden);
2857d9836fb4SBjoern A. Zeeb 
28589af1bba4SBjoern A. Zeeb /* Callbacks for ieee80211_ops */
28599af1bba4SBjoern A. Zeeb void iwl_mvm_mac_tx(struct ieee80211_hw *hw,
28609af1bba4SBjoern A. Zeeb 		    struct ieee80211_tx_control *control, struct sk_buff *skb);
28619af1bba4SBjoern A. Zeeb void iwl_mvm_mac_wake_tx_queue(struct ieee80211_hw *hw,
28629af1bba4SBjoern A. Zeeb 			       struct ieee80211_txq *txq);
28639af1bba4SBjoern A. Zeeb 
28649af1bba4SBjoern A. Zeeb int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw,
28659af1bba4SBjoern A. Zeeb 			     struct ieee80211_vif *vif,
28669af1bba4SBjoern A. Zeeb 			     struct ieee80211_ampdu_params *params);
28679af1bba4SBjoern A. Zeeb int iwl_mvm_op_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant);
2868*a4128aadSBjoern A. Zeeb int iwl_mvm_op_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant);
28699af1bba4SBjoern A. Zeeb int iwl_mvm_mac_start(struct ieee80211_hw *hw);
28709af1bba4SBjoern A. Zeeb void iwl_mvm_mac_reconfig_complete(struct ieee80211_hw *hw,
28719af1bba4SBjoern A. Zeeb 				   enum ieee80211_reconfig_type reconfig_type);
2872*a4128aadSBjoern A. Zeeb void iwl_mvm_mac_stop(struct ieee80211_hw *hw, bool suspend);
28739af1bba4SBjoern A. Zeeb static inline int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed)
28749af1bba4SBjoern A. Zeeb {
28759af1bba4SBjoern A. Zeeb 	return 0;
28769af1bba4SBjoern A. Zeeb }
28779af1bba4SBjoern A. Zeeb 
28789af1bba4SBjoern A. Zeeb u64 iwl_mvm_prepare_multicast(struct ieee80211_hw *hw,
28799af1bba4SBjoern A. Zeeb 			      struct netdev_hw_addr_list *mc_list);
28809af1bba4SBjoern A. Zeeb 
28819af1bba4SBjoern A. Zeeb void iwl_mvm_configure_filter(struct ieee80211_hw *hw,
28829af1bba4SBjoern A. Zeeb 			      unsigned int changed_flags,
28839af1bba4SBjoern A. Zeeb 			      unsigned int *total_flags, u64 multicast);
28849af1bba4SBjoern A. Zeeb int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
28859af1bba4SBjoern A. Zeeb 			struct ieee80211_scan_request *hw_req);
28869af1bba4SBjoern A. Zeeb void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw,
28879af1bba4SBjoern A. Zeeb 				struct ieee80211_vif *vif);
28889af1bba4SBjoern A. Zeeb void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw *hw,
28899af1bba4SBjoern A. Zeeb 				struct ieee80211_vif *vif,
28909af1bba4SBjoern A. Zeeb 				struct ieee80211_sta *sta);
28919af1bba4SBjoern A. Zeeb void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
28929af1bba4SBjoern A. Zeeb 			    enum sta_notify_cmd cmd,
28939af1bba4SBjoern A. Zeeb 			    struct ieee80211_sta *sta);
28949af1bba4SBjoern A. Zeeb void
28959af1bba4SBjoern A. Zeeb iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw,
28969af1bba4SBjoern A. Zeeb 				  struct ieee80211_sta *sta, u16 tids,
28979af1bba4SBjoern A. Zeeb 				  int num_frames,
28989af1bba4SBjoern A. Zeeb 				  enum ieee80211_frame_release_type reason,
28999af1bba4SBjoern A. Zeeb 				  bool more_data);
29009af1bba4SBjoern A. Zeeb void
29019af1bba4SBjoern A. Zeeb iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw *hw,
29029af1bba4SBjoern A. Zeeb 				    struct ieee80211_sta *sta, u16 tids,
29039af1bba4SBjoern A. Zeeb 				    int num_frames,
29049af1bba4SBjoern A. Zeeb 				    enum ieee80211_frame_release_type reason,
29059af1bba4SBjoern A. Zeeb 				    bool more_data);
29069af1bba4SBjoern A. Zeeb int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, u32 value);
29079af1bba4SBjoern A. Zeeb void iwl_mvm_sta_rc_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
29089af1bba4SBjoern A. Zeeb 			   struct ieee80211_sta *sta, u32 changed);
29099af1bba4SBjoern A. Zeeb void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw,
29109af1bba4SBjoern A. Zeeb 				struct ieee80211_vif *vif,
29119af1bba4SBjoern A. Zeeb 				struct ieee80211_prep_tx_info *info);
29129af1bba4SBjoern A. Zeeb void iwl_mvm_mac_mgd_complete_tx(struct ieee80211_hw *hw,
29139af1bba4SBjoern A. Zeeb 				 struct ieee80211_vif *vif,
29149af1bba4SBjoern A. Zeeb 				 struct ieee80211_prep_tx_info *info);
29159af1bba4SBjoern A. Zeeb void iwl_mvm_mac_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
29169af1bba4SBjoern A. Zeeb 		       u32 queues, bool drop);
29179af1bba4SBjoern A. Zeeb void iwl_mvm_mac_flush_sta(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
29189af1bba4SBjoern A. Zeeb 			   struct ieee80211_sta *sta);
29199af1bba4SBjoern A. Zeeb int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw,
29209af1bba4SBjoern A. Zeeb 				 struct ieee80211_vif *vif,
29219af1bba4SBjoern A. Zeeb 				 struct cfg80211_sched_scan_request *req,
29229af1bba4SBjoern A. Zeeb 				 struct ieee80211_scan_ies *ies);
29239af1bba4SBjoern A. Zeeb int iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw *hw,
29249af1bba4SBjoern A. Zeeb 				struct ieee80211_vif *vif);
29259af1bba4SBjoern A. Zeeb int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
29269af1bba4SBjoern A. Zeeb 			struct ieee80211_vif *vif, struct ieee80211_sta *sta,
29279af1bba4SBjoern A. Zeeb 			struct ieee80211_key_conf *key);
29289af1bba4SBjoern A. Zeeb void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw,
29299af1bba4SBjoern A. Zeeb 				 struct ieee80211_vif *vif,
29309af1bba4SBjoern A. Zeeb 				 struct ieee80211_key_conf *keyconf,
29319af1bba4SBjoern A. Zeeb 				 struct ieee80211_sta *sta,
29329af1bba4SBjoern A. Zeeb 				 u32 iv32, u16 *phase1key);
29339af1bba4SBjoern A. Zeeb int iwl_mvm_add_chanctx(struct ieee80211_hw *hw,
29349af1bba4SBjoern A. Zeeb 			struct ieee80211_chanctx_conf *ctx);
29359af1bba4SBjoern A. Zeeb void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw,
29369af1bba4SBjoern A. Zeeb 			    struct ieee80211_chanctx_conf *ctx);
29379af1bba4SBjoern A. Zeeb void iwl_mvm_change_chanctx(struct ieee80211_hw *hw,
29389af1bba4SBjoern A. Zeeb 			    struct ieee80211_chanctx_conf *ctx, u32 changed);
29399af1bba4SBjoern A. Zeeb int iwl_mvm_tx_last_beacon(struct ieee80211_hw *hw);
29409af1bba4SBjoern A. Zeeb void iwl_mvm_channel_switch(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
29419af1bba4SBjoern A. Zeeb 			    struct ieee80211_channel_switch *chsw);
2942*a4128aadSBjoern A. Zeeb int iwl_mvm_pre_channel_switch(struct iwl_mvm *mvm,
29439af1bba4SBjoern A. Zeeb 			       struct ieee80211_vif *vif,
29449af1bba4SBjoern A. Zeeb 			       struct ieee80211_channel_switch *chsw);
29459af1bba4SBjoern A. Zeeb void iwl_mvm_abort_channel_switch(struct ieee80211_hw *hw,
2946*a4128aadSBjoern A. Zeeb 				  struct ieee80211_vif *vif,
2947*a4128aadSBjoern A. Zeeb 				  struct ieee80211_bss_conf *link_conf);
29489af1bba4SBjoern A. Zeeb void iwl_mvm_channel_switch_rx_beacon(struct ieee80211_hw *hw,
29499af1bba4SBjoern A. Zeeb 				      struct ieee80211_vif *vif,
29509af1bba4SBjoern A. Zeeb 				      struct ieee80211_channel_switch *chsw);
29519af1bba4SBjoern A. Zeeb void iwl_mvm_mac_event_callback(struct ieee80211_hw *hw,
29529af1bba4SBjoern A. Zeeb 				struct ieee80211_vif *vif,
29539af1bba4SBjoern A. Zeeb 				const struct ieee80211_event *event);
29549af1bba4SBjoern A. Zeeb void iwl_mvm_sync_rx_queues(struct ieee80211_hw *hw);
29559af1bba4SBjoern A. Zeeb int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw *hw,
29569af1bba4SBjoern A. Zeeb 			     struct ieee80211_vif *vif,
29579af1bba4SBjoern A. Zeeb 			     void *data, int len);
29589af1bba4SBjoern A. Zeeb int iwl_mvm_mac_get_survey(struct ieee80211_hw *hw, int idx,
29599af1bba4SBjoern A. Zeeb 			   struct survey_info *survey);
29609af1bba4SBjoern A. Zeeb void iwl_mvm_mac_sta_statistics(struct ieee80211_hw *hw,
29619af1bba4SBjoern A. Zeeb 				struct ieee80211_vif *vif,
29629af1bba4SBjoern A. Zeeb 				struct ieee80211_sta *sta,
29639af1bba4SBjoern A. Zeeb 				struct station_info *sinfo);
29649af1bba4SBjoern A. Zeeb int
29659af1bba4SBjoern A. Zeeb iwl_mvm_mac_get_ftm_responder_stats(struct ieee80211_hw *hw,
29669af1bba4SBjoern A. Zeeb 				    struct ieee80211_vif *vif,
29679af1bba4SBjoern A. Zeeb 				    struct cfg80211_ftm_responder_stats *stats);
29689af1bba4SBjoern A. Zeeb int iwl_mvm_start_pmsr(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
29699af1bba4SBjoern A. Zeeb 		       struct cfg80211_pmsr_request *request);
29709af1bba4SBjoern A. Zeeb void iwl_mvm_abort_pmsr(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
29719af1bba4SBjoern A. Zeeb 			struct cfg80211_pmsr_request *request);
29729af1bba4SBjoern A. Zeeb 
29739af1bba4SBjoern A. Zeeb bool iwl_mvm_have_links_same_channel(struct iwl_mvm_vif *vif1,
29749af1bba4SBjoern A. Zeeb 				     struct iwl_mvm_vif *vif2);
29759af1bba4SBjoern A. Zeeb bool iwl_mvm_vif_is_active(struct iwl_mvm_vif *mvmvif);
29769af1bba4SBjoern A. Zeeb int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
29779af1bba4SBjoern A. Zeeb 			 s16 tx_power);
29789af1bba4SBjoern A. Zeeb int iwl_mvm_set_hw_timestamp(struct ieee80211_hw *hw,
29799af1bba4SBjoern A. Zeeb 			     struct ieee80211_vif *vif,
29809af1bba4SBjoern A. Zeeb 			     struct cfg80211_set_hw_timestamp *hwts);
29819af1bba4SBjoern A. Zeeb int iwl_mvm_update_mu_groups(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2982*a4128aadSBjoern A. Zeeb bool iwl_mvm_enable_fils(struct iwl_mvm *mvm,
2983*a4128aadSBjoern A. Zeeb 			 struct ieee80211_chanctx_conf *ctx);
2984*a4128aadSBjoern A. Zeeb bool iwl_mvm_is_ftm_responder_chanctx(struct iwl_mvm *mvm,
2985*a4128aadSBjoern A. Zeeb 				      struct ieee80211_chanctx_conf *ctx);
2986*a4128aadSBjoern A. Zeeb 
2987*a4128aadSBjoern A. Zeeb static inline struct cfg80211_chan_def *
2988*a4128aadSBjoern A. Zeeb iwl_mvm_chanctx_def(struct iwl_mvm *mvm, struct ieee80211_chanctx_conf *ctx)
2989*a4128aadSBjoern A. Zeeb {
2990*a4128aadSBjoern A. Zeeb 	bool use_def = iwl_mvm_is_ftm_responder_chanctx(mvm, ctx) ||
2991*a4128aadSBjoern A. Zeeb 		iwl_mvm_enable_fils(mvm, ctx);
2992*a4128aadSBjoern A. Zeeb 
2993*a4128aadSBjoern A. Zeeb 	return use_def ? &ctx->def : &ctx->min_def;
2994*a4128aadSBjoern A. Zeeb }
2995*a4128aadSBjoern A. Zeeb 
2996*a4128aadSBjoern A. Zeeb void iwl_mvm_roc_duration_and_delay(struct ieee80211_vif *vif,
2997*a4128aadSBjoern A. Zeeb 				    u32 duration_ms,
2998*a4128aadSBjoern A. Zeeb 				    u32 *duration_tu,
2999*a4128aadSBjoern A. Zeeb 				    u32 *delay);
3000*a4128aadSBjoern A. Zeeb int iwl_mvm_roc_add_cmd(struct iwl_mvm *mvm,
3001*a4128aadSBjoern A. Zeeb 			struct ieee80211_channel *channel,
3002*a4128aadSBjoern A. Zeeb 			struct ieee80211_vif *vif,
3003*a4128aadSBjoern A. Zeeb 			int duration, enum iwl_roc_activity activity);
3004*a4128aadSBjoern A. Zeeb 
3005*a4128aadSBjoern A. Zeeb /* EMLSR */
3006*a4128aadSBjoern A. Zeeb bool iwl_mvm_vif_has_esr_cap(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
3007*a4128aadSBjoern A. Zeeb void iwl_mvm_block_esr(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
3008*a4128aadSBjoern A. Zeeb 		       enum iwl_mvm_esr_state reason,
3009*a4128aadSBjoern A. Zeeb 		       u8 link_to_keep);
3010*a4128aadSBjoern A. Zeeb int iwl_mvm_block_esr_sync(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
3011*a4128aadSBjoern A. Zeeb 			   enum iwl_mvm_esr_state reason);
3012*a4128aadSBjoern A. Zeeb void iwl_mvm_unblock_esr(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
3013*a4128aadSBjoern A. Zeeb 			 enum iwl_mvm_esr_state reason);
3014*a4128aadSBjoern A. Zeeb void iwl_mvm_exit_esr(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
3015*a4128aadSBjoern A. Zeeb 		      enum iwl_mvm_esr_state reason,
3016*a4128aadSBjoern A. Zeeb 		      u8 link_to_keep);
3017*a4128aadSBjoern A. Zeeb s8 iwl_mvm_get_esr_rssi_thresh(struct iwl_mvm *mvm,
3018*a4128aadSBjoern A. Zeeb 			       const struct cfg80211_chan_def *chandef,
3019*a4128aadSBjoern A. Zeeb 			       bool low);
3020*a4128aadSBjoern A. Zeeb void iwl_mvm_bt_coex_update_link_esr(struct iwl_mvm *mvm,
3021*a4128aadSBjoern A. Zeeb 				     struct ieee80211_vif *vif,
3022*a4128aadSBjoern A. Zeeb 				     int link_id);
3023*a4128aadSBjoern A. Zeeb bool
3024*a4128aadSBjoern A. Zeeb iwl_mvm_bt_coex_calculate_esr_mode(struct iwl_mvm *mvm,
3025*a4128aadSBjoern A. Zeeb 				   struct ieee80211_vif *vif,
3026*a4128aadSBjoern A. Zeeb 				   s32 link_rssi,
3027*a4128aadSBjoern A. Zeeb 				   bool primary);
3028*a4128aadSBjoern A. Zeeb int iwl_mvm_esr_non_bss_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
3029*a4128aadSBjoern A. Zeeb 			     unsigned int link_id, bool active);
3030*a4128aadSBjoern A. Zeeb 
3031*a4128aadSBjoern A. Zeeb void
3032*a4128aadSBjoern A. Zeeb iwl_mvm_send_ap_tx_power_constraint_cmd(struct iwl_mvm *mvm,
3033*a4128aadSBjoern A. Zeeb 					struct ieee80211_vif *vif,
3034*a4128aadSBjoern A. Zeeb 					struct ieee80211_bss_conf *bss_conf,
3035*a4128aadSBjoern A. Zeeb 					bool is_ap);
3036bfcc09ddSBjoern A. Zeeb #endif /* __IWL_MVM_H__ */
3037