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