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