1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
3 * Copyright (C) 2012-2014, 2018-2020 Intel Corporation
4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5 * Copyright (C) 2016-2017 Intel Deutschland GmbH
10 #include <linux/list.h>
11 #include <linux/spinlock.h>
12 #include <linux/leds.h>
13 #include <linux/in6.h>
16 #include <linux/thermal.h>
19 #include "iwl-op-mode.h"
20 #include "iwl-trans.h"
21 #include "fw/notif-wait.h"
22 #include "iwl-eeprom-parse.h"
24 #include "iwl-config.h"
27 #include "constants.h"
28 #include "fw/runtime.h"
31 #include "iwl-nvm-parse.h"
33 #include <linux/average.h>
35 #define IWL_MVM_MAX_ADDRESSES 5
36 /* RSSI offset for WkP */
37 #define IWL_RSSI_OFFSET 50
38 #define IWL_MVM_MISSED_BEACONS_THRESHOLD 8
39 #define IWL_MVM_MISSED_BEACONS_THRESHOLD_LONG 16
41 /* A TimeUnit is 1024 microsecond */
42 #define MSEC_TO_TU(_msec) (_msec*1000/1024)
44 /* For GO, this value represents the number of TUs before CSA "beacon
45 * 0" TBTT when the CSA time-event needs to be scheduled to start. It
46 * must be big enough to ensure that we switch in time.
48 #define IWL_MVM_CHANNEL_SWITCH_TIME_GO 40
50 /* For client, this value represents the number of TUs before CSA
51 * "beacon 1" TBTT, instead. This is because we don't know when the
52 * GO/AP will be in the new channel, so we switch early enough.
54 #define IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT 10
57 * This value (in TUs) is used to fine tune the CSA NoA end time which should
58 * be just before "beacon 0" TBTT.
60 #define IWL_MVM_CHANNEL_SWITCH_MARGIN 4
63 * Number of beacons to transmit on a new channel until we unblock tx to
64 * the stations, even if we didn't identify them on a new channel
66 #define IWL_MVM_CS_UNBLOCK_TX_TIMEOUT 3
68 /* offchannel queue towards mac80211 */
69 #define IWL_MVM_OFFCHANNEL_QUEUE 0
71 extern const struct ieee80211_ops iwl_mvm_hw_ops
;
74 * struct iwl_mvm_mod_params - module parameters for iwlmvm
75 * @init_dbg: if true, then the NIC won't be stopped if the INIT fw asserted.
76 * We will register to mac80211 to have testmode working. The NIC must not
77 * be up'ed after the INIT fw asserted. This is useful to be able to use
78 * proprietary tools over testmode to debug the INIT fw.
79 * @power_scheme: one of enum iwl_power_scheme
81 struct iwl_mvm_mod_params
{
85 extern struct iwl_mvm_mod_params iwlmvm_mod_params
;
87 struct iwl_mvm_phy_ctxt
{
92 enum nl80211_chan_width width
;
95 * TODO: This should probably be removed. Currently here only for rate
98 struct ieee80211_channel
*channel
;
101 struct iwl_mvm_time_event_data
{
102 struct ieee80211_vif
*vif
;
103 struct list_head list
;
104 unsigned long end_jiffies
;
110 * The access to the 'id' field must be done when the
111 * mvm->time_event_lock is held, as it value is used to indicate
112 * if the te is in the time event list or not (when id == TE_MAX)
117 /* Power management */
120 * enum iwl_power_scheme
121 * @IWL_POWER_LEVEL_CAM - Continuously Active Mode
122 * @IWL_POWER_LEVEL_BPS - Balanced Power Save (default)
123 * @IWL_POWER_LEVEL_LP - Low Power
125 enum iwl_power_scheme
{
126 IWL_POWER_SCHEME_CAM
= 1,
127 IWL_POWER_SCHEME_BPS
,
131 #define IWL_CONN_MAX_LISTEN_INTERVAL 10
132 #define IWL_UAPSD_MAX_SP IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
134 #ifdef CONFIG_IWLWIFI_DEBUGFS
135 enum iwl_dbgfs_pm_mask
{
136 MVM_DEBUGFS_PM_KEEP_ALIVE
= BIT(0),
137 MVM_DEBUGFS_PM_SKIP_OVER_DTIM
= BIT(1),
138 MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS
= BIT(2),
139 MVM_DEBUGFS_PM_RX_DATA_TIMEOUT
= BIT(3),
140 MVM_DEBUGFS_PM_TX_DATA_TIMEOUT
= BIT(4),
141 MVM_DEBUGFS_PM_LPRX_ENA
= BIT(6),
142 MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD
= BIT(7),
143 MVM_DEBUGFS_PM_SNOOZE_ENABLE
= BIT(8),
144 MVM_DEBUGFS_PM_UAPSD_MISBEHAVING
= BIT(9),
145 MVM_DEBUGFS_PM_USE_PS_POLL
= BIT(10),
148 struct iwl_dbgfs_pm
{
149 u16 keep_alive_seconds
;
153 u8 skip_dtim_periods
;
155 u32 lprx_rssi_threshold
;
157 bool uapsd_misbehaving
;
162 /* beacon filtering */
164 enum iwl_dbgfs_bf_mask
{
165 MVM_DEBUGFS_BF_ENERGY_DELTA
= BIT(0),
166 MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA
= BIT(1),
167 MVM_DEBUGFS_BF_ROAMING_STATE
= BIT(2),
168 MVM_DEBUGFS_BF_TEMP_THRESHOLD
= BIT(3),
169 MVM_DEBUGFS_BF_TEMP_FAST_FILTER
= BIT(4),
170 MVM_DEBUGFS_BF_TEMP_SLOW_FILTER
= BIT(5),
171 MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER
= BIT(6),
172 MVM_DEBUGFS_BF_DEBUG_FLAG
= BIT(7),
173 MVM_DEBUGFS_BF_ESCAPE_TIMER
= BIT(8),
174 MVM_DEBUGFS_BA_ESCAPE_TIMER
= BIT(9),
175 MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT
= BIT(10),
178 struct iwl_dbgfs_bf
{
180 u32 bf_roaming_energy_delta
;
181 u32 bf_roaming_state
;
182 u32 bf_temp_threshold
;
183 u32 bf_temp_fast_filter
;
184 u32 bf_temp_slow_filter
;
185 u32 bf_enable_beacon_filter
;
189 u32 ba_enable_beacon_abort
;
194 enum iwl_mvm_smps_type_request
{
195 IWL_MVM_SMPS_REQ_BT_COEX
,
197 IWL_MVM_SMPS_REQ_PROT
,
198 NUM_IWL_MVM_SMPS_REQ
,
201 enum iwl_bt_force_ant_mode
{
202 BT_FORCE_ANT_DIS
= 0,
211 * struct iwl_mvm_low_latency_force - low latency force mode set by debugfs
212 * @LOW_LATENCY_FORCE_UNSET: unset force mode
213 * @LOW_LATENCY_FORCE_ON: for low latency on
214 * @LOW_LATENCY_FORCE_OFF: for low latency off
215 * @NUM_LOW_LATENCY_FORCE: max num of modes
217 enum iwl_mvm_low_latency_force
{
218 LOW_LATENCY_FORCE_UNSET
,
219 LOW_LATENCY_FORCE_ON
,
220 LOW_LATENCY_FORCE_OFF
,
221 NUM_LOW_LATENCY_FORCE
225 * struct iwl_mvm_low_latency_cause - low latency set causes
226 * @LOW_LATENCY_TRAFFIC: indicates low latency traffic was detected
227 * @LOW_LATENCY_DEBUGFS: low latency mode set from debugfs
228 * @LOW_LATENCY_VCMD: low latency mode set from vendor command
229 * @LOW_LATENCY_VIF_TYPE: low latency mode set because of vif type (ap)
230 * @LOW_LATENCY_DEBUGFS_FORCE_ENABLE: indicate that force mode is enabled
231 * the actual set/unset is done with LOW_LATENCY_DEBUGFS_FORCE
232 * @LOW_LATENCY_DEBUGFS_FORCE: low latency force mode from debugfs
233 * set this with LOW_LATENCY_DEBUGFS_FORCE_ENABLE flag
236 enum iwl_mvm_low_latency_cause
{
237 LOW_LATENCY_TRAFFIC
= BIT(0),
238 LOW_LATENCY_DEBUGFS
= BIT(1),
239 LOW_LATENCY_VCMD
= BIT(2),
240 LOW_LATENCY_VIF_TYPE
= BIT(3),
241 LOW_LATENCY_DEBUGFS_FORCE_ENABLE
= BIT(4),
242 LOW_LATENCY_DEBUGFS_FORCE
= BIT(5),
246 * struct iwl_mvm_vif_bf_data - beacon filtering related data
247 * @bf_enabled: indicates if beacon filtering is enabled
248 * @ba_enabled: indicated if beacon abort is enabled
249 * @ave_beacon_signal: average beacon signal
250 * @last_cqm_event: rssi of the last cqm event
251 * @bt_coex_min_thold: minimum threshold for BT coex
252 * @bt_coex_max_thold: maximum threshold for BT coex
253 * @last_bt_coex_event: rssi of the last BT coex event
255 struct iwl_mvm_vif_bf_data
{
258 int ave_beacon_signal
;
260 int bt_coex_min_thold
;
261 int bt_coex_max_thold
;
262 int last_bt_coex_event
;
266 * struct iwl_probe_resp_data - data for NoA/CSA updates
267 * @rcu_head: used for freeing the data on update
268 * @notif: notification data
269 * @noa_len: length of NoA attribute, calculated from the notification
271 struct iwl_probe_resp_data
{
272 struct rcu_head rcu_head
;
273 struct iwl_probe_resp_data_notif notif
;
278 * struct iwl_mvm_vif - data per Virtual Interface, it is a MAC context
279 * @id: between 0 and 3
280 * @color: to solve races upon MAC addition and removal
281 * @ap_sta_id: the sta_id of the AP - valid only if VIF type is STA
282 * @bssid: BSSID for this (client) interface
283 * @associated: indicates that we're currently associated, used only for
284 * managing the firmware state in iwl_mvm_bss_info_changed_station()
285 * @ap_assoc_sta_count: count of stations associated to us - valid only
287 * @uploaded: indicates the MAC context has been added to the device
288 * @ap_ibss_active: indicates that AP/IBSS is configured and that the interface
289 * should get quota etc.
290 * @pm_enabled - Indicate if MAC power management is allowed
291 * @monitor_active: indicates that monitor context is configured, and that the
292 * interface should get quota etc.
293 * @low_latency: bit flags for low latency
294 * see enum &iwl_mvm_low_latency_cause for causes.
295 * @low_latency_actual: boolean, indicates low latency is set,
296 * as a result from low_latency bit flags and takes force into account.
297 * @ps_disabled: indicates that this interface requires PS to be disabled
298 * @queue_params: QoS params for this MAC
299 * @bcast_sta: station used for broadcast packets. Used by the following
300 * vifs: P2P_DEVICE, GO and AP.
301 * @beacon_skb: the skb used to hold the AP/GO beacon template
302 * @smps_requests: the SMPS requests of different parts of the driver,
303 * combined on update to yield the overall request to mac80211.
304 * @beacon_stats: beacon statistics, containing the # of received beacons,
305 * # of received beacons accumulated over FW restart, and the current
306 * average signal of beacons retrieved from the firmware
307 * @csa_failed: CSA failed to schedule time event, report an error later
308 * @features: hw features active for this vif
309 * @probe_resp_data: data from FW notification to store NOA and CSA related
310 * data to be inserted into probe response.
320 u8 ap_assoc_sta_count
;
329 u8 low_latency_actual
: 1;
331 struct iwl_mvm_vif_bf_data bf_data
;
334 u32 num_beacons
, accu_num_beacons
;
340 enum iwl_tsf_id tsf_id
;
343 * QoS data from mac80211, need to store this here
344 * as mac80211 has a separate callback but we need
345 * to have the data for the MAC context
347 struct ieee80211_tx_queue_params queue_params
[IEEE80211_NUM_ACS
];
348 struct iwl_mvm_time_event_data time_event_data
;
349 struct iwl_mvm_time_event_data hs_time_event_data
;
351 struct iwl_mvm_int_sta bcast_sta
;
352 struct iwl_mvm_int_sta mcast_sta
;
355 * Assigned while mac80211 has the interface in a channel context,
356 * or, for P2P Device, while it exists.
358 struct iwl_mvm_phy_ctxt
*phy_ctxt
;
361 /* WoWLAN GTK rekey data */
363 u8 kck
[NL80211_KCK_EXT_LEN
];
364 u8 kek
[NL80211_KEK_EXT_LEN
];
378 #if IS_ENABLED(CONFIG_IPV6)
379 /* IPv6 addresses for WoWLAN */
380 struct in6_addr target_ipv6_addrs
[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX
];
381 unsigned long tentative_addrs
[BITS_TO_LONGS(IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX
)];
382 int num_target_ipv6_addrs
;
385 #ifdef CONFIG_IWLWIFI_DEBUGFS
386 struct dentry
*dbgfs_dir
;
387 struct dentry
*dbgfs_slink
;
388 struct iwl_dbgfs_pm dbgfs_pm
;
389 struct iwl_dbgfs_bf dbgfs_bf
;
390 struct iwl_mac_power_cmd mac_pwr_cmd
;
394 enum ieee80211_smps_mode smps_requests
[NUM_IWL_MVM_SMPS_REQ
];
396 /* FW identified misbehaving AP */
397 u8 uapsd_misbehaving_bssid
[ETH_ALEN
];
399 struct delayed_work uapsd_nonagg_detected_wk
;
401 /* Indicates that CSA countdown may be started */
407 struct delayed_work csa_work
;
409 /* Indicates that we are waiting for a beacon on a new channel */
410 bool csa_bcn_pending
;
412 /* TCP Checksum Offload */
413 netdev_features_t features
;
415 struct iwl_probe_resp_data __rcu
*probe_resp_data
;
417 /* we can only have 2 GTK + 2 IGTK active at a time */
418 struct ieee80211_key_conf
*ap_early_keys
[4];
420 /* 26-tone RU OFDMA transmissions should be blocked */
421 bool he_ru_2mhz_block
;
424 static inline struct iwl_mvm_vif
*
425 iwl_mvm_vif_from_mac80211(struct ieee80211_vif
*vif
)
429 return (void *)vif
->drv_priv
;
432 extern const u8 tid_to_mac80211_ac
[];
434 #define IWL_MVM_SCAN_STOPPING_SHIFT 8
436 enum iwl_scan_status
{
437 IWL_MVM_SCAN_REGULAR
= BIT(0),
438 IWL_MVM_SCAN_SCHED
= BIT(1),
439 IWL_MVM_SCAN_NETDETECT
= BIT(2),
441 IWL_MVM_SCAN_STOPPING_REGULAR
= BIT(8),
442 IWL_MVM_SCAN_STOPPING_SCHED
= BIT(9),
443 IWL_MVM_SCAN_STOPPING_NETDETECT
= BIT(10),
445 IWL_MVM_SCAN_REGULAR_MASK
= IWL_MVM_SCAN_REGULAR
|
446 IWL_MVM_SCAN_STOPPING_REGULAR
,
447 IWL_MVM_SCAN_SCHED_MASK
= IWL_MVM_SCAN_SCHED
|
448 IWL_MVM_SCAN_STOPPING_SCHED
,
449 IWL_MVM_SCAN_NETDETECT_MASK
= IWL_MVM_SCAN_NETDETECT
|
450 IWL_MVM_SCAN_STOPPING_NETDETECT
,
452 IWL_MVM_SCAN_STOPPING_MASK
= 0xff << IWL_MVM_SCAN_STOPPING_SHIFT
,
453 IWL_MVM_SCAN_MASK
= 0xff,
456 enum iwl_mvm_scan_type
{
457 IWL_SCAN_TYPE_NOT_SET
,
458 IWL_SCAN_TYPE_UNASSOC
,
461 IWL_SCAN_TYPE_FRAGMENTED
,
462 IWL_SCAN_TYPE_FAST_BALANCE
,
465 enum iwl_mvm_sched_scan_pass_all_states
{
466 SCHED_SCAN_PASS_ALL_DISABLED
,
467 SCHED_SCAN_PASS_ALL_ENABLED
,
468 SCHED_SCAN_PASS_ALL_FOUND
,
472 * struct iwl_mvm_tt_mgnt - Thermal Throttling Management structure
473 * @ct_kill_exit: worker to exit thermal kill
474 * @dynamic_smps: Is thermal throttling enabled dynamic_smps?
475 * @tx_backoff: The current thremal throttling tx backoff in uSec.
476 * @min_backoff: The minimal tx backoff due to power restrictions
477 * @params: Parameters to configure the thermal throttling algorithm.
478 * @throttle: Is thermal throttling is active?
480 struct iwl_mvm_tt_mgmt
{
481 struct delayed_work ct_kill_exit
;
485 struct iwl_tt_params params
;
489 #ifdef CONFIG_THERMAL
491 *struct iwl_mvm_thermal_device - thermal zone related data
492 * @temp_trips: temperature thresholds for report
493 * @fw_trips_index: keep indexes to original array - temp_trips
494 * @tzone: thermal zone device data
496 struct iwl_mvm_thermal_device
{
497 s16 temp_trips
[IWL_MAX_DTS_TRIPS
];
498 u8 fw_trips_index
[IWL_MAX_DTS_TRIPS
];
499 struct thermal_zone_device
*tzone
;
503 * struct iwl_mvm_cooling_device
504 * @cur_state: current state
505 * @cdev: struct thermal cooling device
507 struct iwl_mvm_cooling_device
{
509 struct thermal_cooling_device
*cdev
;
513 #define IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES 8
515 struct iwl_mvm_frame_stats
{
531 u32 last_rates
[IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES
];
535 #define IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE 0xff
536 #define IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -100
537 #define IWL_MVM_DEBUG_SET_TEMPERATURE_MAX 200
539 enum iwl_mvm_tdls_cs_state
{
540 IWL_MVM_TDLS_SW_IDLE
= 0,
541 IWL_MVM_TDLS_SW_REQ_SENT
,
542 IWL_MVM_TDLS_SW_RESP_RCVD
,
543 IWL_MVM_TDLS_SW_REQ_RCVD
,
544 IWL_MVM_TDLS_SW_ACTIVE
,
547 enum iwl_mvm_traffic_load
{
549 IWL_MVM_TRAFFIC_MEDIUM
,
550 IWL_MVM_TRAFFIC_HIGH
,
553 DECLARE_EWMA(rate
, 16, 16)
555 struct iwl_mvm_tcm_mac
{
557 u32 pkts
[IEEE80211_NUM_ACS
];
561 u32 pkts
[IEEE80211_NUM_ACS
];
566 /* track AP's transfer in client mode */
568 struct ewma_rate rate
;
570 } uapsd_nonagg_detect
;
571 bool opened_rx_ba_sessions
;
575 struct delayed_work work
;
576 spinlock_t lock
; /* used when time elapsed */
577 unsigned long ts
; /* timestamp when period ends */
579 unsigned long uapsd_nonagg_ts
;
581 struct iwl_mvm_tcm_mac data
[NUM_MAC_INDEX_DRIVER
];
583 u32 elapsed
; /* milliseconds for this TCM period */
584 u32 airtime
[NUM_MAC_INDEX_DRIVER
];
585 enum iwl_mvm_traffic_load load
[NUM_MAC_INDEX_DRIVER
];
586 enum iwl_mvm_traffic_load band_load
[NUM_NL80211_BANDS
];
587 enum iwl_mvm_traffic_load global_load
;
588 bool low_latency
[NUM_MAC_INDEX_DRIVER
];
589 bool change
[NUM_MAC_INDEX_DRIVER
];
595 * struct iwl_mvm_reorder_buffer - per ra/tid/queue reorder buffer
596 * @head_sn: reorder window head sn
597 * @num_stored: number of mpdus stored in the buffer
598 * @buf_size: the reorder buffer size as set by the last addba request
599 * @queue: queue of this reorder buffer
600 * @last_amsdu: track last ASMDU SN for duplication detection
601 * @last_sub_index: track ASMDU sub frame index for duplication detection
602 * @reorder_timer: timer for frames are in the reorder buffer. For AMSDU
603 * it is the time of last received sub-frame
604 * @removed: prevent timer re-arming
605 * @valid: reordering is valid for this queue
606 * @lock: protect reorder buffer internal state
607 * @mvm: mvm pointer, needed for frame timer context
608 * @consec_oldsn_drops: consecutive drops due to old SN
609 * @consec_oldsn_ampdu_gp2: A-MPDU GP2 timestamp to track
610 * when to apply old SN consecutive drop workaround
611 * @consec_oldsn_prev_drop: track whether or not an MPDU
612 * that was single/part of the previous A-MPDU was
613 * dropped due to old SN
615 struct iwl_mvm_reorder_buffer
{
622 struct timer_list reorder_timer
;
627 unsigned int consec_oldsn_drops
;
628 u32 consec_oldsn_ampdu_gp2
;
629 unsigned int consec_oldsn_prev_drop
:1;
630 } ____cacheline_aligned_in_smp
;
633 * struct _iwl_mvm_reorder_buf_entry - reorder buffer entry per-queue/per-seqno
634 * @frames: list of skbs stored
635 * @reorder_time: time the packet was stored in the reorder buffer
637 struct _iwl_mvm_reorder_buf_entry
{
638 struct sk_buff_head frames
;
639 unsigned long reorder_time
;
642 /* make this indirection to get the aligned thing */
643 struct iwl_mvm_reorder_buf_entry
{
644 struct _iwl_mvm_reorder_buf_entry e
;
647 /* sparse doesn't like this construct: "bad integer constant expression" */
648 __aligned(roundup_pow_of_two(sizeof(struct _iwl_mvm_reorder_buf_entry
)))
653 * struct iwl_mvm_baid_data - BA session data
654 * @sta_id: station id
655 * @tid: tid of the session
656 * @baid baid of the session
657 * @timeout: the timeout set in the addba request
658 * @entries_per_queue: # of buffers per queue, this actually gets
659 * aligned up to avoid cache line sharing between queues
660 * @last_rx: last rx jiffies, updated only if timeout passed from last update
661 * @session_timer: timer to check if BA session expired, runs at 2 * timeout
662 * @mvm: mvm pointer, needed for timer context
663 * @reorder_buf: reorder buffer, allocated per queue
664 * @reorder_buf_data: data
666 struct iwl_mvm_baid_data
{
667 struct rcu_head rcu_head
;
672 u16 entries_per_queue
;
673 unsigned long last_rx
;
674 struct timer_list session_timer
;
675 struct iwl_mvm_baid_data __rcu
**rcu_ptr
;
677 struct iwl_mvm_reorder_buffer reorder_buf
[IWL_MAX_RX_HW_QUEUES
];
678 struct iwl_mvm_reorder_buf_entry entries
[];
681 static inline struct iwl_mvm_baid_data
*
682 iwl_mvm_baid_data_from_reorder_buf(struct iwl_mvm_reorder_buffer
*buf
)
684 return (void *)((u8
*)buf
-
685 offsetof(struct iwl_mvm_baid_data
, reorder_buf
) -
686 sizeof(*buf
) * buf
->queue
);
690 * enum iwl_mvm_queue_status - queue status
691 * @IWL_MVM_QUEUE_FREE: the queue is not allocated nor reserved
692 * Basically, this means that this queue can be used for any purpose
693 * @IWL_MVM_QUEUE_RESERVED: queue is reserved but not yet in use
694 * This is the state of a queue that has been dedicated for some RATID
695 * (agg'd or not), but that hasn't yet gone through the actual enablement
696 * of iwl_mvm_enable_txq(), and therefore no traffic can go through it yet.
697 * Note that in this state there is no requirement to already know what TID
698 * should be used with this queue, it is just marked as a queue that will
699 * be used, and shouldn't be allocated to anyone else.
700 * @IWL_MVM_QUEUE_READY: queue is ready to be used
701 * This is the state of a queue that has been fully configured (including
702 * SCD pointers, etc), has a specific RA/TID assigned to it, and can be
703 * used to send traffic.
704 * @IWL_MVM_QUEUE_SHARED: queue is shared, or in a process of becoming shared
705 * This is a state in which a single queue serves more than one TID, all of
706 * which are not aggregated. Note that the queue is only associated to one
709 enum iwl_mvm_queue_status
{
711 IWL_MVM_QUEUE_RESERVED
,
713 IWL_MVM_QUEUE_SHARED
,
716 #define IWL_MVM_DQA_QUEUE_TIMEOUT (5 * HZ)
717 #define IWL_MVM_INVALID_QUEUE 0xFFFF
719 #define IWL_MVM_NUM_CIPHERS 10
723 struct list_head list
;
729 static inline struct iwl_mvm_txq
*
730 iwl_mvm_txq_from_mac80211(struct ieee80211_txq
*txq
)
732 return (void *)txq
->drv_priv
;
735 static inline struct iwl_mvm_txq
*
736 iwl_mvm_txq_from_tid(struct ieee80211_sta
*sta
, u8 tid
)
738 if (tid
== IWL_MAX_TID_COUNT
)
739 tid
= IEEE80211_NUM_TIDS
;
741 return (void *)sta
->txq
[tid
]->drv_priv
;
745 * struct iwl_mvm_tvqm_txq_info - maps TVQM hw queue to tid
750 struct iwl_mvm_tvqm_txq_info
{
755 struct iwl_mvm_dqa_txq_info
{
756 u8 ra_sta_id
; /* The RA this queue is mapped to, if exists */
757 bool reserved
; /* Is this the TXQ reserved for a STA */
758 u8 mac80211_ac
; /* The mac80211 AC this queue is mapped to */
759 u8 txq_tid
; /* The TID "owner" of this queue*/
760 u16 tid_bitmap
; /* Bitmap of the TIDs mapped to this queue */
761 /* Timestamp for inactivation per TID of this queue */
762 unsigned long last_frame_time
[IWL_MAX_TID_COUNT
+ 1];
763 enum iwl_mvm_queue_status status
;
767 /* for logger access */
770 struct iwl_trans
*trans
;
771 const struct iwl_fw
*fw
;
772 const struct iwl_cfg
*cfg
;
773 struct iwl_phy_db
*phy_db
;
774 struct ieee80211_hw
*hw
;
776 /* for protecting access to iwl_mvm */
778 struct list_head async_handlers_list
;
779 spinlock_t async_handlers_lock
;
780 struct work_struct async_handlers_wk
;
782 struct work_struct roc_done_wk
;
784 unsigned long init_status
;
786 unsigned long status
;
788 u32 queue_sync_cookie
;
789 unsigned long queue_sync_state
;
791 * for beacon filtering -
792 * currently only one interface can be supported
794 struct iwl_mvm_vif
*bf_allowed_vif
;
797 bool rfkill_safe_init_done
;
799 u8 cca_40mhz_workaround
;
804 struct iwl_notif_wait_data notif_wait
;
807 struct mvm_statistics_rx_v3 rx_stats_v3
;
808 struct mvm_statistics_rx rx_stats
;
816 } radio_stats
, accu_radio_stats
;
818 struct list_head add_stream_txqs
;
820 struct iwl_mvm_dqa_txq_info queue_info
[IWL_MAX_HW_QUEUES
];
821 struct iwl_mvm_tvqm_txq_info tvqm_info
[IWL_MAX_TVQM_QUEUES
];
823 struct work_struct add_stream_wk
; /* To add streams to queues */
825 const char *nvm_file_name
;
826 struct iwl_nvm_data
*nvm_data
;
828 struct iwl_nvm_section nvm_sections
[NVM_MAX_NUM_SECTIONS
];
830 struct iwl_fw_runtime fwrt
;
832 /* EEPROM MAC addresses */
833 struct mac_address addresses
[IWL_MVM_MAX_ADDRESSES
];
835 /* data related to data path */
836 struct iwl_rx_phy_info last_phy_info
;
837 struct ieee80211_sta __rcu
*fw_id_to_mac_id
[IWL_MVM_STATION_COUNT_MAX
];
840 /* configured by mac80211 */
843 /* Scan status, cmd (pre-allocated) and auxiliary station */
844 unsigned int scan_status
;
846 struct iwl_mcast_filter_cmd
*mcast_filter_cmd
;
847 /* For CDB this is low band scan type, for non-CDB - type. */
848 enum iwl_mvm_scan_type scan_type
;
849 enum iwl_mvm_scan_type hb_scan_type
;
851 enum iwl_mvm_sched_scan_pass_all_states sched_scan_pass_all
;
852 struct delayed_work scan_timeout_dwork
;
854 /* max number of simultaneous scans the FW supports */
855 unsigned int max_scans
;
857 /* UMAC scan tracking */
858 u32 scan_uid_status
[IWL_MVM_MAX_UMAC_SCANS
];
860 /* start time of last scan in TSF of the mac that requested the scan */
863 /* the vif that requested the current scan */
864 struct iwl_mvm_vif
*scan_vif
;
866 /* rx chain antennas set through debugfs for the scan command */
869 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
870 /* broadcast filters to configure for each associated station */
871 const struct iwl_fw_bcast_filter
*bcast_filters
;
872 #ifdef CONFIG_IWLWIFI_DEBUGFS
875 struct iwl_bcast_filter_cmd cmd
;
876 } dbgfs_bcast_filtering
;
880 /* Internal station */
881 struct iwl_mvm_int_sta aux_sta
;
882 struct iwl_mvm_int_sta snif_sta
;
884 bool last_ebs_successful
;
886 u8 scan_last_antenna_idx
; /* to toggle TX between antennas */
887 u8 mgmt_last_antenna_idx
;
889 /* last smart fifo state that was successfully sent to firmware */
890 enum iwl_sf_state sf_state
;
892 #ifdef CONFIG_IWLWIFI_DEBUGFS
893 struct dentry
*debugfs_dir
;
894 u32 dbgfs_sram_offset
, dbgfs_sram_len
;
895 u32 dbgfs_prph_reg_addr
;
896 bool disable_power_off
;
897 bool disable_power_off_d3
;
898 bool beacon_inject_active
;
900 bool scan_iter_notif_enabled
;
902 struct debugfs_blob_wrapper nvm_hw_blob
;
903 struct debugfs_blob_wrapper nvm_sw_blob
;
904 struct debugfs_blob_wrapper nvm_calib_blob
;
905 struct debugfs_blob_wrapper nvm_prod_blob
;
906 struct debugfs_blob_wrapper nvm_phy_sku_blob
;
907 struct debugfs_blob_wrapper nvm_reg_blob
;
909 struct iwl_mvm_frame_stats drv_rx_stats
;
910 spinlock_t drv_stats_lock
;
911 u16 dbgfs_rx_phyinfo
;
914 struct iwl_mvm_phy_ctxt phy_ctxts
[NUM_PHY_CTX
];
916 struct list_head time_event_list
;
917 spinlock_t time_event_lock
;
920 * A bitmap indicating the index of the key in use. The firmware
921 * can hold 16 keys at most. Reflect this fact.
923 unsigned long fw_key_table
[BITS_TO_LONGS(STA_KEY_MAX_NUM
)];
924 u8 fw_key_deleted
[STA_KEY_MAX_NUM
];
927 struct ieee80211_vif __rcu
*vif_id_to_mac
[NUM_MAC_INDEX_DRIVER
];
929 /* -1 for always, 0 for never, >0 for that many times */
931 u8
*error_recovery_buf
;
933 #ifdef CONFIG_IWLWIFI_LEDS
934 struct led_classdev led
;
937 struct ieee80211_vif
*p2p_device_vif
;
940 struct wiphy_wowlan_support wowlan
;
941 int gtk_ivlen
, gtk_icvlen
, ptk_ivlen
, ptk_icvlen
;
943 /* sched scan settings for net detect */
944 struct ieee80211_scan_ies nd_ies
;
945 struct cfg80211_match_set
*nd_match_sets
;
947 struct ieee80211_channel
**nd_channels
;
951 #ifdef CONFIG_IWLWIFI_DEBUGFS
952 bool d3_wake_sysassert
;
955 struct ieee80211_vif
*keep_vif
;
956 u32 last_netdetect_scans
; /* no. of scans in the last net-detect wake */
960 wait_queue_head_t rx_sync_waitq
;
963 struct iwl_bt_coex_profile_notif last_bt_notif
;
964 struct iwl_bt_coex_ci_cmd last_bt_ci_cmd
;
967 enum iwl_bt_force_ant_mode bt_force_ant_mode
;
970 struct list_head aux_roc_te_list
;
972 /* Thermal Throttling and CTkill */
973 struct iwl_mvm_tt_mgmt thermal_throttle
;
974 #ifdef CONFIG_THERMAL
975 struct iwl_mvm_thermal_device tz_device
;
976 struct iwl_mvm_cooling_device cooling_dev
;
979 s32 temperature
; /* Celsius */
981 * Debug option to set the NIC temperature. This option makes the
982 * driver think this is the actual NIC temperature, and ignore the
983 * real temperature that is received from the fw
985 bool temperature_test
; /* Debug test temperature is enabled */
987 unsigned long bt_coex_last_tcm_ts
;
988 struct iwl_mvm_tcm tcm
;
990 u8 uapsd_noagg_bssid_write_idx
;
991 struct mac_address uapsd_noagg_bssids
[IWL_MVM_UAPSD_NOAGG_BSSIDS_NUM
]
994 struct iwl_time_quota_cmd last_quota_cmd
;
996 #ifdef CONFIG_NL80211_TESTMODE
998 struct ieee80211_vif
*noa_vif
;
1007 /* Indicate if device power save is allowed */
1008 u8 ps_disabled
; /* u8 instead of bool to ease debugfs_create_* usage */
1009 /* Indicate if 32Khz external clock is valid */
1010 u32 ext_clock_valid
;
1012 struct ieee80211_vif __rcu
*csa_vif
;
1013 struct ieee80211_vif __rcu
*csa_tx_blocked_vif
;
1014 u8 csa_tx_block_bcn_timeout
;
1016 /* system time of last beacon (for AP/GO interface) */
1017 u32 ap_last_beacon_gp2
;
1019 /* indicates that we transmitted the last beacon */
1022 bool lar_regdom_set
;
1023 enum iwl_mcc_source mcc_src
;
1025 /* TDLS channel switch data */
1027 struct delayed_work dwork
;
1028 enum iwl_mvm_tdls_cs_state state
;
1031 * Current cs sta - might be different from periodic cs peer
1032 * station. Value is meaningless when the cs-state is idle.
1036 /* TDLS periodic channel-switch peer */
1040 bool initiator
; /* are we the link initiator */
1041 struct cfg80211_chan_def chandef
;
1042 struct sk_buff
*skb
; /* ch sw template */
1045 /* timestamp of last ch-sw request sent (GP2 time) */
1051 u32 ciphers
[IWL_MVM_NUM_CIPHERS
];
1052 struct ieee80211_cipher_scheme cs
[IWL_UCODE_MAX_CS
];
1054 struct cfg80211_ftm_responder_stats ftm_resp_stats
;
1056 struct cfg80211_pmsr_request
*req
;
1057 struct wireless_dev
*req_wdev
;
1058 struct list_head loc_list
;
1059 int responses
[IWL_MVM_TOF_MAX_APS
];
1061 struct list_head resp
;
1063 struct list_head pasn_list
;
1066 struct list_head resp_pasn_list
;
1073 struct ieee80211_vif
*nan_vif
;
1074 #define IWL_MAX_BAID 32
1075 struct iwl_mvm_baid_data __rcu
*baid_map
[IWL_MAX_BAID
];
1078 * Drop beacons from other APs in AP mode when there are no connected
1081 bool drop_bcn_ap_mode
;
1083 struct delayed_work cs_tx_unblock_dwork
;
1085 /* does a monitor vif exist (only one can exist hence bool) */
1088 /* sniffer data to include in radiotap */
1090 u8 cur_bssid
[ETH_ALEN
];
1093 /* Extract MVM priv from op_mode and _hw */
1094 #define IWL_OP_MODE_GET_MVM(_iwl_op_mode) \
1095 ((struct iwl_mvm *)(_iwl_op_mode)->op_mode_specific)
1097 #define IWL_MAC80211_GET_MVM(_hw) \
1098 IWL_OP_MODE_GET_MVM((struct iwl_op_mode *)((_hw)->priv))
1101 * enum iwl_mvm_status - MVM status bits
1102 * @IWL_MVM_STATUS_HW_RFKILL: HW RF-kill is asserted
1103 * @IWL_MVM_STATUS_HW_CTKILL: CT-kill is active
1104 * @IWL_MVM_STATUS_ROC_RUNNING: remain-on-channel is running
1105 * @IWL_MVM_STATUS_HW_RESTART_REQUESTED: HW restart was requested
1106 * @IWL_MVM_STATUS_IN_HW_RESTART: HW restart is active
1107 * @IWL_MVM_STATUS_ROC_AUX_RUNNING: AUX remain-on-channel is running
1108 * @IWL_MVM_STATUS_FIRMWARE_RUNNING: firmware is running
1109 * @IWL_MVM_STATUS_NEED_FLUSH_P2P: need to flush P2P bcast STA
1110 * @IWL_MVM_STATUS_IN_D3: in D3 (or at least about to go into it)
1112 enum iwl_mvm_status
{
1113 IWL_MVM_STATUS_HW_RFKILL
,
1114 IWL_MVM_STATUS_HW_CTKILL
,
1115 IWL_MVM_STATUS_ROC_RUNNING
,
1116 IWL_MVM_STATUS_HW_RESTART_REQUESTED
,
1117 IWL_MVM_STATUS_IN_HW_RESTART
,
1118 IWL_MVM_STATUS_ROC_AUX_RUNNING
,
1119 IWL_MVM_STATUS_FIRMWARE_RUNNING
,
1120 IWL_MVM_STATUS_NEED_FLUSH_P2P
,
1121 IWL_MVM_STATUS_IN_D3
,
1124 /* Keep track of completed init configuration */
1125 enum iwl_mvm_init_status
{
1126 IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE
= BIT(0),
1127 IWL_MVM_INIT_STATUS_LEDS_INIT_COMPLETE
= BIT(1),
1130 static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm
*mvm
)
1132 return test_bit(IWL_MVM_STATUS_HW_RFKILL
, &mvm
->status
) ||
1133 test_bit(IWL_MVM_STATUS_HW_CTKILL
, &mvm
->status
);
1136 static inline bool iwl_mvm_is_radio_hw_killed(struct iwl_mvm
*mvm
)
1138 return test_bit(IWL_MVM_STATUS_HW_RFKILL
, &mvm
->status
);
1141 static inline bool iwl_mvm_firmware_running(struct iwl_mvm
*mvm
)
1143 return test_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING
, &mvm
->status
);
1146 /* Must be called with rcu_read_lock() held and it can only be
1147 * released when mvmsta is not needed anymore.
1149 static inline struct iwl_mvm_sta
*
1150 iwl_mvm_sta_from_staid_rcu(struct iwl_mvm
*mvm
, u8 sta_id
)
1152 struct ieee80211_sta
*sta
;
1154 if (sta_id
>= mvm
->fw
->ucode_capa
.num_stations
)
1157 sta
= rcu_dereference(mvm
->fw_id_to_mac_id
[sta_id
]);
1159 /* This can happen if the station has been removed right now */
1160 if (IS_ERR_OR_NULL(sta
))
1163 return iwl_mvm_sta_from_mac80211(sta
);
1166 static inline struct iwl_mvm_sta
*
1167 iwl_mvm_sta_from_staid_protected(struct iwl_mvm
*mvm
, u8 sta_id
)
1169 struct ieee80211_sta
*sta
;
1171 if (sta_id
>= mvm
->fw
->ucode_capa
.num_stations
)
1174 sta
= rcu_dereference_protected(mvm
->fw_id_to_mac_id
[sta_id
],
1175 lockdep_is_held(&mvm
->mutex
));
1177 /* This can happen if the station has been removed right now */
1178 if (IS_ERR_OR_NULL(sta
))
1181 return iwl_mvm_sta_from_mac80211(sta
);
1184 static inline struct ieee80211_vif
*
1185 iwl_mvm_rcu_dereference_vif_id(struct iwl_mvm
*mvm
, u8 vif_id
, bool rcu
)
1187 if (WARN_ON(vif_id
>= ARRAY_SIZE(mvm
->vif_id_to_mac
)))
1191 return rcu_dereference(mvm
->vif_id_to_mac
[vif_id
]);
1193 return rcu_dereference_protected(mvm
->vif_id_to_mac
[vif_id
],
1194 lockdep_is_held(&mvm
->mutex
));
1197 static inline bool iwl_mvm_is_adaptive_dwell_supported(struct iwl_mvm
*mvm
)
1199 return fw_has_api(&mvm
->fw
->ucode_capa
,
1200 IWL_UCODE_TLV_API_ADAPTIVE_DWELL
);
1203 static inline bool iwl_mvm_is_adaptive_dwell_v2_supported(struct iwl_mvm
*mvm
)
1205 return fw_has_api(&mvm
->fw
->ucode_capa
,
1206 IWL_UCODE_TLV_API_ADAPTIVE_DWELL_V2
);
1209 static inline bool iwl_mvm_is_adwell_hb_ap_num_supported(struct iwl_mvm
*mvm
)
1211 return fw_has_api(&mvm
->fw
->ucode_capa
,
1212 IWL_UCODE_TLV_API_ADWELL_HB_DEF_N_AP
);
1215 static inline bool iwl_mvm_is_oce_supported(struct iwl_mvm
*mvm
)
1217 /* OCE should never be enabled for LMAC scan FWs */
1218 return fw_has_api(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_API_OCE
);
1221 static inline bool iwl_mvm_is_frag_ebs_supported(struct iwl_mvm
*mvm
)
1223 return fw_has_api(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_API_FRAG_EBS
);
1226 static inline bool iwl_mvm_is_short_beacon_notif_supported(struct iwl_mvm
*mvm
)
1228 return fw_has_api(&mvm
->fw
->ucode_capa
,
1229 IWL_UCODE_TLV_API_SHORT_BEACON_NOTIF
);
1232 static inline bool iwl_mvm_is_dqa_data_queue(struct iwl_mvm
*mvm
, u8 queue
)
1234 return (queue
>= IWL_MVM_DQA_MIN_DATA_QUEUE
) &&
1235 (queue
<= IWL_MVM_DQA_MAX_DATA_QUEUE
);
1238 static inline bool iwl_mvm_is_dqa_mgmt_queue(struct iwl_mvm
*mvm
, u8 queue
)
1240 return (queue
>= IWL_MVM_DQA_MIN_MGMT_QUEUE
) &&
1241 (queue
<= IWL_MVM_DQA_MAX_MGMT_QUEUE
);
1244 static inline bool iwl_mvm_is_lar_supported(struct iwl_mvm
*mvm
)
1246 bool nvm_lar
= mvm
->nvm_data
->lar_enabled
;
1247 bool tlv_lar
= fw_has_capa(&mvm
->fw
->ucode_capa
,
1248 IWL_UCODE_TLV_CAPA_LAR_SUPPORT
);
1251 * Enable LAR only if it is supported by the FW (TLV) &&
1252 * enabled in the NVM
1254 if (mvm
->cfg
->nvm_type
== IWL_NVM_EXT
)
1255 return nvm_lar
&& tlv_lar
;
1260 static inline bool iwl_mvm_is_wifi_mcc_supported(struct iwl_mvm
*mvm
)
1262 return fw_has_api(&mvm
->fw
->ucode_capa
,
1263 IWL_UCODE_TLV_API_WIFI_MCC_UPDATE
) ||
1264 fw_has_capa(&mvm
->fw
->ucode_capa
,
1265 IWL_UCODE_TLV_CAPA_LAR_MULTI_MCC
);
1268 static inline bool iwl_mvm_bt_is_rrc_supported(struct iwl_mvm
*mvm
)
1270 return fw_has_capa(&mvm
->fw
->ucode_capa
,
1271 IWL_UCODE_TLV_CAPA_BT_COEX_RRC
) &&
1272 IWL_MVM_BT_COEX_RRC
;
1275 static inline bool iwl_mvm_is_csum_supported(struct iwl_mvm
*mvm
)
1277 return fw_has_capa(&mvm
->fw
->ucode_capa
,
1278 IWL_UCODE_TLV_CAPA_CSUM_SUPPORT
) &&
1279 !IWL_MVM_HW_CSUM_DISABLE
;
1282 static inline bool iwl_mvm_is_mplut_supported(struct iwl_mvm
*mvm
)
1284 return fw_has_capa(&mvm
->fw
->ucode_capa
,
1285 IWL_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT
) &&
1286 IWL_MVM_BT_COEX_MPLUT
;
1290 bool iwl_mvm_is_p2p_scm_uapsd_supported(struct iwl_mvm
*mvm
)
1292 return fw_has_capa(&mvm
->fw
->ucode_capa
,
1293 IWL_UCODE_TLV_CAPA_P2P_SCM_UAPSD
) &&
1294 !(iwlwifi_mod_params
.uapsd_disable
&
1295 IWL_DISABLE_UAPSD_P2P_CLIENT
);
1298 static inline bool iwl_mvm_has_new_rx_api(struct iwl_mvm
*mvm
)
1300 return fw_has_capa(&mvm
->fw
->ucode_capa
,
1301 IWL_UCODE_TLV_CAPA_MULTI_QUEUE_RX_SUPPORT
);
1304 static inline bool iwl_mvm_has_new_tx_api(struct iwl_mvm
*mvm
)
1306 /* TODO - replace with TLV once defined */
1307 return mvm
->trans
->trans_cfg
->use_tfh
;
1310 static inline bool iwl_mvm_has_unified_ucode(struct iwl_mvm
*mvm
)
1312 /* TODO - better define this */
1313 return mvm
->trans
->trans_cfg
->device_family
>= IWL_DEVICE_FAMILY_22000
;
1316 static inline bool iwl_mvm_is_cdb_supported(struct iwl_mvm
*mvm
)
1320 * The issue of how to determine CDB APIs and usage is still not fully
1322 * There is a compilation for CDB and non-CDB FW, but there may
1323 * be also runtime check.
1324 * For now there is a TLV for checking compilation mode, but a
1325 * runtime check will also have to be here - once defined.
1327 return fw_has_capa(&mvm
->fw
->ucode_capa
,
1328 IWL_UCODE_TLV_CAPA_CDB_SUPPORT
);
1331 static inline bool iwl_mvm_cdb_scan_api(struct iwl_mvm
*mvm
)
1334 * TODO: should this be the same as iwl_mvm_is_cdb_supported()?
1335 * but then there's a little bit of code in scan that won't make
1338 return mvm
->trans
->trans_cfg
->device_family
>= IWL_DEVICE_FAMILY_22000
;
1341 static inline bool iwl_mvm_is_scan_ext_chan_supported(struct iwl_mvm
*mvm
)
1343 return fw_has_api(&mvm
->fw
->ucode_capa
,
1344 IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER
);
1348 static inline bool iwl_mvm_is_reduced_config_scan_supported(struct iwl_mvm
*mvm
)
1350 return fw_has_api(&mvm
->fw
->ucode_capa
,
1351 IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG
);
1354 static inline bool iwl_mvm_is_band_in_rx_supported(struct iwl_mvm
*mvm
)
1356 return fw_has_api(&mvm
->fw
->ucode_capa
,
1357 IWL_UCODE_TLV_API_BAND_IN_RX_DATA
);
1360 static inline bool iwl_mvm_has_new_rx_stats_api(struct iwl_mvm
*mvm
)
1362 return fw_has_api(&mvm
->fw
->ucode_capa
,
1363 IWL_UCODE_TLV_API_NEW_RX_STATS
);
1366 static inline bool iwl_mvm_has_quota_low_latency(struct iwl_mvm
*mvm
)
1368 return fw_has_api(&mvm
->fw
->ucode_capa
,
1369 IWL_UCODE_TLV_API_QUOTA_LOW_LATENCY
);
1372 static inline bool iwl_mvm_has_tlc_offload(const struct iwl_mvm
*mvm
)
1374 return fw_has_capa(&mvm
->fw
->ucode_capa
,
1375 IWL_UCODE_TLV_CAPA_TLC_OFFLOAD
);
1378 static inline struct agg_tx_status
*
1379 iwl_mvm_get_agg_status(struct iwl_mvm
*mvm
, void *tx_resp
)
1381 if (iwl_mvm_has_new_tx_api(mvm
))
1382 return &((struct iwl_mvm_tx_resp
*)tx_resp
)->status
;
1384 return ((struct iwl_mvm_tx_resp_v3
*)tx_resp
)->status
;
1387 static inline bool iwl_mvm_is_tt_in_fw(struct iwl_mvm
*mvm
)
1389 /* these two TLV are redundant since the responsibility to CT-kill by
1390 * FW happens only after we send at least one command of
1391 * temperature THs report.
1393 return fw_has_capa(&mvm
->fw
->ucode_capa
,
1394 IWL_UCODE_TLV_CAPA_CT_KILL_BY_FW
) &&
1395 fw_has_capa(&mvm
->fw
->ucode_capa
,
1396 IWL_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT
);
1399 static inline bool iwl_mvm_is_ctdp_supported(struct iwl_mvm
*mvm
)
1401 return fw_has_capa(&mvm
->fw
->ucode_capa
,
1402 IWL_UCODE_TLV_CAPA_CTDP_SUPPORT
);
1405 extern const u8 iwl_mvm_ac_to_tx_fifo
[];
1406 extern const u8 iwl_mvm_ac_to_gen2_tx_fifo
[];
1408 static inline u8
iwl_mvm_mac_ac_to_tx_fifo(struct iwl_mvm
*mvm
,
1409 enum ieee80211_ac_numbers ac
)
1411 return iwl_mvm_has_new_tx_api(mvm
) ?
1412 iwl_mvm_ac_to_gen2_tx_fifo
[ac
] : iwl_mvm_ac_to_tx_fifo
[ac
];
1415 struct iwl_rate_info
{
1416 u8 plcp
; /* uCode API: IWL_RATE_6M_PLCP, etc. */
1417 u8 plcp_siso
; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */
1418 u8 plcp_mimo2
; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */
1419 u8 plcp_mimo3
; /* uCode API: IWL_RATE_MIMO3_6M_PLCP, etc. */
1420 u8 ieee
; /* MAC header: IWL_RATE_6M_IEEE, etc. */
1423 void __iwl_mvm_mac_stop(struct iwl_mvm
*mvm
);
1424 int __iwl_mvm_mac_start(struct iwl_mvm
*mvm
);
1430 int iwl_run_init_mvm_ucode(struct iwl_mvm
*mvm
);
1433 int iwl_mvm_legacy_rate_to_mac80211_idx(u32 rate_n_flags
,
1434 enum nl80211_band band
);
1435 void iwl_mvm_hwrate_to_tx_rate(u32 rate_n_flags
,
1436 enum nl80211_band band
,
1437 struct ieee80211_tx_rate
*r
);
1438 u8
iwl_mvm_mac80211_idx_to_hwrate(int rate_idx
);
1439 u8
iwl_mvm_mac80211_ac_to_ucode_ac(enum ieee80211_ac_numbers ac
);
1440 void iwl_mvm_dump_nic_error_log(struct iwl_mvm
*mvm
);
1441 u8
first_antenna(u8 mask
);
1442 u8
iwl_mvm_next_antenna(struct iwl_mvm
*mvm
, u8 valid
, u8 last_idx
);
1443 void iwl_mvm_get_sync_time(struct iwl_mvm
*mvm
, u32
*gp2
, u64
*boottime
);
1444 u32
iwl_mvm_get_systime(struct iwl_mvm
*mvm
);
1446 /* Tx / Host Commands */
1447 int __must_check
iwl_mvm_send_cmd(struct iwl_mvm
*mvm
,
1448 struct iwl_host_cmd
*cmd
);
1449 int __must_check
iwl_mvm_send_cmd_pdu(struct iwl_mvm
*mvm
, u32 id
,
1450 u32 flags
, u16 len
, const void *data
);
1451 int __must_check
iwl_mvm_send_cmd_status(struct iwl_mvm
*mvm
,
1452 struct iwl_host_cmd
*cmd
,
1454 int __must_check
iwl_mvm_send_cmd_pdu_status(struct iwl_mvm
*mvm
, u32 id
,
1455 u16 len
, const void *data
,
1457 int iwl_mvm_tx_skb_sta(struct iwl_mvm
*mvm
, struct sk_buff
*skb
,
1458 struct ieee80211_sta
*sta
);
1459 int iwl_mvm_tx_skb_non_sta(struct iwl_mvm
*mvm
, struct sk_buff
*skb
);
1460 void iwl_mvm_set_tx_cmd(struct iwl_mvm
*mvm
, struct sk_buff
*skb
,
1461 struct iwl_tx_cmd
*tx_cmd
,
1462 struct ieee80211_tx_info
*info
, u8 sta_id
);
1463 void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm
*mvm
, struct iwl_tx_cmd
*tx_cmd
,
1464 struct ieee80211_tx_info
*info
,
1465 struct ieee80211_sta
*sta
, __le16 fc
);
1466 void iwl_mvm_mac_itxq_xmit(struct ieee80211_hw
*hw
, struct ieee80211_txq
*txq
);
1467 unsigned int iwl_mvm_max_amsdu_size(struct iwl_mvm
*mvm
,
1468 struct ieee80211_sta
*sta
,
1471 #ifdef CONFIG_IWLWIFI_DEBUG
1472 const char *iwl_mvm_get_tx_fail_reason(u32 status
);
1474 static inline const char *iwl_mvm_get_tx_fail_reason(u32 status
) { return ""; }
1476 int iwl_mvm_flush_tx_path(struct iwl_mvm
*mvm
, u32 tfd_msk
, u32 flags
);
1477 int iwl_mvm_flush_sta(struct iwl_mvm
*mvm
, void *sta
, bool internal
);
1478 int iwl_mvm_flush_sta_tids(struct iwl_mvm
*mvm
, u32 sta_id
,
1479 u16 tids
, u32 flags
);
1481 void iwl_mvm_async_handlers_purge(struct iwl_mvm
*mvm
);
1483 static inline void iwl_mvm_set_tx_cmd_ccmp(struct ieee80211_tx_info
*info
,
1484 struct iwl_tx_cmd
*tx_cmd
)
1486 struct ieee80211_key_conf
*keyconf
= info
->control
.hw_key
;
1488 tx_cmd
->sec_ctl
= TX_CMD_SEC_CCM
;
1489 memcpy(tx_cmd
->key
, keyconf
->key
, keyconf
->keylen
);
1492 static inline void iwl_mvm_wait_for_async_handlers(struct iwl_mvm
*mvm
)
1494 flush_work(&mvm
->async_handlers_wk
);
1498 void iwl_mvm_handle_rx_statistics(struct iwl_mvm
*mvm
,
1499 struct iwl_rx_packet
*pkt
);
1500 void iwl_mvm_rx_statistics(struct iwl_mvm
*mvm
,
1501 struct iwl_rx_cmd_buffer
*rxb
);
1502 int iwl_mvm_request_statistics(struct iwl_mvm
*mvm
, bool clear
);
1503 void iwl_mvm_accu_radio_stats(struct iwl_mvm
*mvm
);
1506 int iwl_nvm_init(struct iwl_mvm
*mvm
);
1507 int iwl_mvm_load_nvm_to_nic(struct iwl_mvm
*mvm
);
1509 static inline u8
iwl_mvm_get_valid_tx_ant(struct iwl_mvm
*mvm
)
1511 return mvm
->nvm_data
&& mvm
->nvm_data
->valid_tx_ant
?
1512 mvm
->fw
->valid_tx_ant
& mvm
->nvm_data
->valid_tx_ant
:
1513 mvm
->fw
->valid_tx_ant
;
1516 static inline u8
iwl_mvm_get_valid_rx_ant(struct iwl_mvm
*mvm
)
1518 return mvm
->nvm_data
&& mvm
->nvm_data
->valid_rx_ant
?
1519 mvm
->fw
->valid_rx_ant
& mvm
->nvm_data
->valid_rx_ant
:
1520 mvm
->fw
->valid_rx_ant
;
1523 static inline void iwl_mvm_toggle_tx_ant(struct iwl_mvm
*mvm
, u8
*ant
)
1525 *ant
= iwl_mvm_next_antenna(mvm
, iwl_mvm_get_valid_tx_ant(mvm
), *ant
);
1528 static inline u32
iwl_mvm_get_phy_config(struct iwl_mvm
*mvm
)
1530 u32 phy_config
= ~(FW_PHY_CFG_TX_CHAIN
|
1531 FW_PHY_CFG_RX_CHAIN
);
1532 u32 valid_rx_ant
= iwl_mvm_get_valid_rx_ant(mvm
);
1533 u32 valid_tx_ant
= iwl_mvm_get_valid_tx_ant(mvm
);
1535 phy_config
|= valid_tx_ant
<< FW_PHY_CFG_TX_CHAIN_POS
|
1536 valid_rx_ant
<< FW_PHY_CFG_RX_CHAIN_POS
;
1538 return mvm
->fw
->phy_config
& phy_config
;
1541 int iwl_mvm_up(struct iwl_mvm
*mvm
);
1542 int iwl_mvm_load_d3_fw(struct iwl_mvm
*mvm
);
1544 int iwl_mvm_mac_setup_register(struct iwl_mvm
*mvm
);
1545 bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm
*mvm
,
1546 struct iwl_bcast_filter_cmd
*cmd
);
1549 * FW notifications / CMD responses handlers
1550 * Convention: iwl_mvm_rx_<NAME OF THE CMD>
1552 void iwl_mvm_rx_rx_phy_cmd(struct iwl_mvm
*mvm
, struct iwl_rx_cmd_buffer
*rxb
);
1553 void iwl_mvm_rx_rx_mpdu(struct iwl_mvm
*mvm
, struct napi_struct
*napi
,
1554 struct iwl_rx_cmd_buffer
*rxb
);
1555 void iwl_mvm_rx_mpdu_mq(struct iwl_mvm
*mvm
, struct napi_struct
*napi
,
1556 struct iwl_rx_cmd_buffer
*rxb
, int queue
);
1557 void iwl_mvm_rx_monitor_no_data(struct iwl_mvm
*mvm
, struct napi_struct
*napi
,
1558 struct iwl_rx_cmd_buffer
*rxb
, int queue
);
1559 void iwl_mvm_rx_frame_release(struct iwl_mvm
*mvm
, struct napi_struct
*napi
,
1560 struct iwl_rx_cmd_buffer
*rxb
, int queue
);
1561 void iwl_mvm_rx_bar_frame_release(struct iwl_mvm
*mvm
, struct napi_struct
*napi
,
1562 struct iwl_rx_cmd_buffer
*rxb
, int queue
);
1563 int iwl_mvm_notify_rx_queue(struct iwl_mvm
*mvm
, u32 rxq_mask
,
1564 const struct iwl_mvm_internal_rxq_notif
*notif
,
1565 u32 notif_size
, bool async
);
1566 void iwl_mvm_rx_queue_notif(struct iwl_mvm
*mvm
, struct napi_struct
*napi
,
1567 struct iwl_rx_cmd_buffer
*rxb
, int queue
);
1568 void iwl_mvm_rx_tx_cmd(struct iwl_mvm
*mvm
, struct iwl_rx_cmd_buffer
*rxb
);
1569 void iwl_mvm_mfu_assert_dump_notif(struct iwl_mvm
*mvm
,
1570 struct iwl_rx_cmd_buffer
*rxb
);
1571 void iwl_mvm_send_recovery_cmd(struct iwl_mvm
*mvm
, u32 flags
);
1572 void iwl_mvm_rx_ba_notif(struct iwl_mvm
*mvm
, struct iwl_rx_cmd_buffer
*rxb
);
1573 void iwl_mvm_rx_ant_coupling_notif(struct iwl_mvm
*mvm
,
1574 struct iwl_rx_cmd_buffer
*rxb
);
1575 void iwl_mvm_rx_fw_error(struct iwl_mvm
*mvm
, struct iwl_rx_cmd_buffer
*rxb
);
1576 void iwl_mvm_rx_card_state_notif(struct iwl_mvm
*mvm
,
1577 struct iwl_rx_cmd_buffer
*rxb
);
1578 void iwl_mvm_rx_mfuart_notif(struct iwl_mvm
*mvm
,
1579 struct iwl_rx_cmd_buffer
*rxb
);
1580 void iwl_mvm_rx_shared_mem_cfg_notif(struct iwl_mvm
*mvm
,
1581 struct iwl_rx_cmd_buffer
*rxb
);
1584 int iwl_mvm_phy_ctxt_add(struct iwl_mvm
*mvm
, struct iwl_mvm_phy_ctxt
*ctxt
,
1585 struct cfg80211_chan_def
*chandef
,
1586 u8 chains_static
, u8 chains_dynamic
);
1587 int iwl_mvm_phy_ctxt_changed(struct iwl_mvm
*mvm
, struct iwl_mvm_phy_ctxt
*ctxt
,
1588 struct cfg80211_chan_def
*chandef
,
1589 u8 chains_static
, u8 chains_dynamic
);
1590 void iwl_mvm_phy_ctxt_ref(struct iwl_mvm
*mvm
,
1591 struct iwl_mvm_phy_ctxt
*ctxt
);
1592 void iwl_mvm_phy_ctxt_unref(struct iwl_mvm
*mvm
,
1593 struct iwl_mvm_phy_ctxt
*ctxt
);
1594 int iwl_mvm_phy_ctx_count(struct iwl_mvm
*mvm
);
1595 u8
iwl_mvm_get_channel_width(struct cfg80211_chan_def
*chandef
);
1596 u8
iwl_mvm_get_ctrl_pos(struct cfg80211_chan_def
*chandef
);
1598 /* MAC (virtual interface) programming */
1599 int iwl_mvm_mac_ctxt_init(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
);
1600 int iwl_mvm_mac_ctxt_add(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
);
1601 int iwl_mvm_mac_ctxt_changed(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
1602 bool force_assoc_off
, const u8
*bssid_override
);
1603 int iwl_mvm_mac_ctxt_remove(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
);
1604 int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm
*mvm
,
1605 struct ieee80211_vif
*vif
);
1606 int iwl_mvm_mac_ctxt_send_beacon(struct iwl_mvm
*mvm
,
1607 struct ieee80211_vif
*vif
,
1608 struct sk_buff
*beacon
);
1609 int iwl_mvm_mac_ctxt_send_beacon_cmd(struct iwl_mvm
*mvm
,
1610 struct sk_buff
*beacon
,
1611 void *data
, int len
);
1612 u8
iwl_mvm_mac_ctxt_get_lowest_rate(struct ieee80211_tx_info
*info
,
1613 struct ieee80211_vif
*vif
);
1614 void iwl_mvm_mac_ctxt_set_tim(struct iwl_mvm
*mvm
,
1615 __le32
*tim_index
, __le32
*tim_size
,
1616 u8
*beacon
, u32 frame_size
);
1617 void iwl_mvm_rx_beacon_notif(struct iwl_mvm
*mvm
,
1618 struct iwl_rx_cmd_buffer
*rxb
);
1619 void iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm
*mvm
,
1620 struct iwl_rx_cmd_buffer
*rxb
);
1621 void iwl_mvm_rx_stored_beacon_notif(struct iwl_mvm
*mvm
,
1622 struct iwl_rx_cmd_buffer
*rxb
);
1623 void iwl_mvm_mu_mimo_grp_notif(struct iwl_mvm
*mvm
,
1624 struct iwl_rx_cmd_buffer
*rxb
);
1625 void iwl_mvm_sta_pm_notif(struct iwl_mvm
*mvm
, struct iwl_rx_cmd_buffer
*rxb
);
1626 void iwl_mvm_window_status_notif(struct iwl_mvm
*mvm
,
1627 struct iwl_rx_cmd_buffer
*rxb
);
1628 void iwl_mvm_mac_ctxt_recalc_tsf_id(struct iwl_mvm
*mvm
,
1629 struct ieee80211_vif
*vif
);
1630 void iwl_mvm_probe_resp_data_notif(struct iwl_mvm
*mvm
,
1631 struct iwl_rx_cmd_buffer
*rxb
);
1632 void iwl_mvm_rx_missed_vap_notif(struct iwl_mvm
*mvm
,
1633 struct iwl_rx_cmd_buffer
*rxb
);
1634 void iwl_mvm_channel_switch_noa_notif(struct iwl_mvm
*mvm
,
1635 struct iwl_rx_cmd_buffer
*rxb
);
1637 int iwl_mvm_binding_add_vif(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
);
1638 int iwl_mvm_binding_remove_vif(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
);
1640 /* Quota management */
1641 static inline size_t iwl_mvm_quota_cmd_size(struct iwl_mvm
*mvm
)
1643 return iwl_mvm_has_quota_low_latency(mvm
) ?
1644 sizeof(struct iwl_time_quota_cmd
) :
1645 sizeof(struct iwl_time_quota_cmd_v1
);
1648 static inline struct iwl_time_quota_data
1649 *iwl_mvm_quota_cmd_get_quota(struct iwl_mvm
*mvm
,
1650 struct iwl_time_quota_cmd
*cmd
,
1653 struct iwl_time_quota_data_v1
*quotas
;
1655 if (iwl_mvm_has_quota_low_latency(mvm
))
1656 return &cmd
->quotas
[i
];
1658 quotas
= (struct iwl_time_quota_data_v1
*)cmd
->quotas
;
1659 return (struct iwl_time_quota_data
*)"as
[i
];
1662 int iwl_mvm_update_quotas(struct iwl_mvm
*mvm
, bool force_upload
,
1663 struct ieee80211_vif
*disabled_vif
);
1666 int iwl_mvm_reg_scan_start(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
1667 struct cfg80211_scan_request
*req
,
1668 struct ieee80211_scan_ies
*ies
);
1669 int iwl_mvm_scan_size(struct iwl_mvm
*mvm
);
1670 int iwl_mvm_scan_stop(struct iwl_mvm
*mvm
, int type
, bool notify
);
1671 int iwl_mvm_max_scan_ie_len(struct iwl_mvm
*mvm
);
1672 void iwl_mvm_report_scan_aborted(struct iwl_mvm
*mvm
);
1673 void iwl_mvm_scan_timeout_wk(struct work_struct
*work
);
1675 /* Scheduled scan */
1676 void iwl_mvm_rx_lmac_scan_complete_notif(struct iwl_mvm
*mvm
,
1677 struct iwl_rx_cmd_buffer
*rxb
);
1678 void iwl_mvm_rx_lmac_scan_iter_complete_notif(struct iwl_mvm
*mvm
,
1679 struct iwl_rx_cmd_buffer
*rxb
);
1680 int iwl_mvm_sched_scan_start(struct iwl_mvm
*mvm
,
1681 struct ieee80211_vif
*vif
,
1682 struct cfg80211_sched_scan_request
*req
,
1683 struct ieee80211_scan_ies
*ies
,
1685 void iwl_mvm_rx_scan_match_found(struct iwl_mvm
*mvm
,
1686 struct iwl_rx_cmd_buffer
*rxb
);
1689 int iwl_mvm_config_scan(struct iwl_mvm
*mvm
);
1690 void iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm
*mvm
,
1691 struct iwl_rx_cmd_buffer
*rxb
);
1692 void iwl_mvm_rx_umac_scan_iter_complete_notif(struct iwl_mvm
*mvm
,
1693 struct iwl_rx_cmd_buffer
*rxb
);
1696 #ifdef CONFIG_IWLWIFI_DEBUGFS
1697 void iwl_mvm_dbgfs_register(struct iwl_mvm
*mvm
, struct dentry
*dbgfs_dir
);
1698 void iwl_mvm_vif_dbgfs_register(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
);
1699 void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
);
1701 static inline void iwl_mvm_dbgfs_register(struct iwl_mvm
*mvm
,
1702 struct dentry
*dbgfs_dir
)
1706 iwl_mvm_vif_dbgfs_register(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
)
1710 iwl_mvm_vif_dbgfs_clean(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
)
1713 #endif /* CONFIG_IWLWIFI_DEBUGFS */
1716 int iwl_mvm_send_lq_cmd(struct iwl_mvm
*mvm
, struct iwl_lq_cmd
*lq
);
1717 void iwl_mvm_update_frame_stats(struct iwl_mvm
*mvm
, u32 rate
, bool agg
);
1718 int rs_pretty_print_rate(char *buf
, int bufsz
, const u32 rate
);
1719 void rs_update_last_rssi(struct iwl_mvm
*mvm
,
1720 struct iwl_mvm_sta
*mvmsta
,
1721 struct ieee80211_rx_status
*rx_status
);
1723 /* power management */
1724 int iwl_mvm_power_update_device(struct iwl_mvm
*mvm
);
1725 int iwl_mvm_power_update_mac(struct iwl_mvm
*mvm
);
1726 int iwl_mvm_power_update_ps(struct iwl_mvm
*mvm
);
1727 int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
1728 char *buf
, int bufsz
);
1730 void iwl_mvm_power_vif_assoc(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
);
1731 void iwl_mvm_power_uapsd_misbehaving_ap_notif(struct iwl_mvm
*mvm
,
1732 struct iwl_rx_cmd_buffer
*rxb
);
1734 #ifdef CONFIG_IWLWIFI_LEDS
1735 int iwl_mvm_leds_init(struct iwl_mvm
*mvm
);
1736 void iwl_mvm_leds_exit(struct iwl_mvm
*mvm
);
1737 void iwl_mvm_leds_sync(struct iwl_mvm
*mvm
);
1739 static inline int iwl_mvm_leds_init(struct iwl_mvm
*mvm
)
1743 static inline void iwl_mvm_leds_exit(struct iwl_mvm
*mvm
)
1746 static inline void iwl_mvm_leds_sync(struct iwl_mvm
*mvm
)
1751 /* D3 (WoWLAN, NetDetect) */
1752 int iwl_mvm_suspend(struct ieee80211_hw
*hw
, struct cfg80211_wowlan
*wowlan
);
1753 int iwl_mvm_resume(struct ieee80211_hw
*hw
);
1754 void iwl_mvm_set_wakeup(struct ieee80211_hw
*hw
, bool enabled
);
1755 void iwl_mvm_set_rekey_data(struct ieee80211_hw
*hw
,
1756 struct ieee80211_vif
*vif
,
1757 struct cfg80211_gtk_rekey_data
*data
);
1758 void iwl_mvm_ipv6_addr_change(struct ieee80211_hw
*hw
,
1759 struct ieee80211_vif
*vif
,
1760 struct inet6_dev
*idev
);
1761 void iwl_mvm_set_default_unicast_key(struct ieee80211_hw
*hw
,
1762 struct ieee80211_vif
*vif
, int idx
);
1763 extern const struct file_operations iwl_dbgfs_d3_test_ops
;
1764 struct iwl_wowlan_status
*iwl_mvm_send_wowlan_get_status(struct iwl_mvm
*mvm
);
1766 void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm
*mvm
,
1767 struct ieee80211_vif
*vif
);
1770 iwl_mvm_set_last_nonqos_seq(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
)
1774 void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta
*mvm_ap_sta
,
1775 struct iwl_wowlan_config_cmd
*cmd
);
1776 int iwl_mvm_send_proto_offload(struct iwl_mvm
*mvm
,
1777 struct ieee80211_vif
*vif
,
1778 bool disable_offloading
,
1783 int iwl_mvm_send_bt_init_conf(struct iwl_mvm
*mvm
);
1784 void iwl_mvm_rx_bt_coex_notif(struct iwl_mvm
*mvm
,
1785 struct iwl_rx_cmd_buffer
*rxb
);
1786 void iwl_mvm_bt_rssi_event(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
1787 enum ieee80211_rssi_event_data
);
1788 void iwl_mvm_bt_coex_vif_change(struct iwl_mvm
*mvm
);
1789 u16
iwl_mvm_coex_agg_time_limit(struct iwl_mvm
*mvm
,
1790 struct ieee80211_sta
*sta
);
1791 bool iwl_mvm_bt_coex_is_mimo_allowed(struct iwl_mvm
*mvm
,
1792 struct ieee80211_sta
*sta
);
1793 bool iwl_mvm_bt_coex_is_ant_avail(struct iwl_mvm
*mvm
, u8 ant
);
1794 bool iwl_mvm_bt_coex_is_shared_ant_avail(struct iwl_mvm
*mvm
);
1795 bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm
*mvm
,
1796 enum nl80211_band band
);
1797 u8
iwl_mvm_bt_coex_get_single_ant_msk(struct iwl_mvm
*mvm
, u8 enabled_ants
);
1798 u8
iwl_mvm_bt_coex_tx_prio(struct iwl_mvm
*mvm
, struct ieee80211_hdr
*hdr
,
1799 struct ieee80211_tx_info
*info
, u8 ac
);
1801 /* beacon filtering */
1802 #ifdef CONFIG_IWLWIFI_DEBUGFS
1804 iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif
*vif
,
1805 struct iwl_beacon_filter_cmd
*cmd
);
1808 iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif
*vif
,
1809 struct iwl_beacon_filter_cmd
*cmd
)
1812 int iwl_mvm_enable_beacon_filter(struct iwl_mvm
*mvm
,
1813 struct ieee80211_vif
*vif
,
1815 int iwl_mvm_disable_beacon_filter(struct iwl_mvm
*mvm
,
1816 struct ieee80211_vif
*vif
,
1819 void iwl_mvm_update_smps(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
1820 enum iwl_mvm_smps_type_request req_type
,
1821 enum ieee80211_smps_mode smps_request
);
1822 bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm
*mvm
);
1825 int iwl_mvm_update_low_latency(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
1827 enum iwl_mvm_low_latency_cause cause
);
1828 /* get SystemLowLatencyMode - only needed for beacon threshold? */
1829 bool iwl_mvm_low_latency(struct iwl_mvm
*mvm
);
1830 bool iwl_mvm_low_latency_band(struct iwl_mvm
*mvm
, enum nl80211_band band
);
1831 void iwl_mvm_send_low_latency_cmd(struct iwl_mvm
*mvm
, bool low_latency
,
1834 /* get VMACLowLatencyMode */
1835 static inline bool iwl_mvm_vif_low_latency(struct iwl_mvm_vif
*mvmvif
)
1838 * should this consider associated/active/... state?
1840 * Normally low-latency should only be active on interfaces
1841 * that are active, but at least with debugfs it can also be
1842 * enabled on interfaces that aren't active. However, when
1843 * interface aren't active then they aren't added into the
1844 * binding, so this has no real impact. For now, just return
1845 * the current desired low-latency state.
1847 return mvmvif
->low_latency_actual
;
1851 void iwl_mvm_vif_set_low_latency(struct iwl_mvm_vif
*mvmvif
, bool set
,
1852 enum iwl_mvm_low_latency_cause cause
)
1857 mvmvif
->low_latency
|= cause
;
1859 mvmvif
->low_latency
&= ~cause
;
1862 * if LOW_LATENCY_DEBUGFS_FORCE_ENABLE is enabled no changes are
1863 * allowed to actual mode.
1865 if (mvmvif
->low_latency
& LOW_LATENCY_DEBUGFS_FORCE_ENABLE
&&
1866 cause
!= LOW_LATENCY_DEBUGFS_FORCE_ENABLE
)
1869 if (cause
== LOW_LATENCY_DEBUGFS_FORCE_ENABLE
&& set
)
1871 * We enter force state
1873 new_state
= !!(mvmvif
->low_latency
&
1874 LOW_LATENCY_DEBUGFS_FORCE
);
1877 * Check if any other one set low latency
1879 new_state
= !!(mvmvif
->low_latency
&
1880 ~(LOW_LATENCY_DEBUGFS_FORCE_ENABLE
|
1881 LOW_LATENCY_DEBUGFS_FORCE
));
1883 mvmvif
->low_latency_actual
= new_state
;
1886 /* Return a bitmask with all the hw supported queues, except for the
1887 * command queue, which can't be flushed.
1889 static inline u32
iwl_mvm_flushable_queues(struct iwl_mvm
*mvm
)
1891 return ((BIT(mvm
->trans
->trans_cfg
->base_params
->num_of_queues
) - 1) &
1892 ~BIT(IWL_MVM_DQA_CMD_QUEUE
));
1895 void iwl_mvm_stop_device(struct iwl_mvm
*mvm
);
1897 /* Re-configure the SCD for a queue that has already been configured */
1898 int iwl_mvm_reconfig_scd(struct iwl_mvm
*mvm
, int queue
, int fifo
, int sta_id
,
1899 int tid
, int frame_limit
, u16 ssn
);
1901 /* Thermal management and CT-kill */
1902 void iwl_mvm_tt_tx_backoff(struct iwl_mvm
*mvm
, u32 backoff
);
1903 void iwl_mvm_tt_temp_changed(struct iwl_mvm
*mvm
, u32 temp
);
1904 void iwl_mvm_temp_notif(struct iwl_mvm
*mvm
,
1905 struct iwl_rx_cmd_buffer
*rxb
);
1906 void iwl_mvm_tt_handler(struct iwl_mvm
*mvm
);
1907 void iwl_mvm_thermal_initialize(struct iwl_mvm
*mvm
, u32 min_backoff
);
1908 void iwl_mvm_thermal_exit(struct iwl_mvm
*mvm
);
1909 void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm
*mvm
, bool state
);
1910 int iwl_mvm_get_temp(struct iwl_mvm
*mvm
, s32
*temp
);
1911 void iwl_mvm_ct_kill_notif(struct iwl_mvm
*mvm
, struct iwl_rx_cmd_buffer
*rxb
);
1912 void iwl_mvm_enter_ctkill(struct iwl_mvm
*mvm
);
1913 int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm
*mvm
);
1914 int iwl_mvm_ctdp_command(struct iwl_mvm
*mvm
, u32 op
, u32 budget
);
1916 /* Location Aware Regulatory */
1917 struct iwl_mcc_update_resp
*
1918 iwl_mvm_update_mcc(struct iwl_mvm
*mvm
, const char *alpha2
,
1919 enum iwl_mcc_source src_id
);
1920 int iwl_mvm_init_mcc(struct iwl_mvm
*mvm
);
1921 void iwl_mvm_rx_chub_update_mcc(struct iwl_mvm
*mvm
,
1922 struct iwl_rx_cmd_buffer
*rxb
);
1923 struct ieee80211_regdomain
*iwl_mvm_get_regdomain(struct wiphy
*wiphy
,
1925 enum iwl_mcc_source src_id
,
1927 struct ieee80211_regdomain
*iwl_mvm_get_current_regdomain(struct iwl_mvm
*mvm
,
1929 int iwl_mvm_init_fw_regd(struct iwl_mvm
*mvm
);
1930 void iwl_mvm_update_changed_regdom(struct iwl_mvm
*mvm
);
1933 int iwl_mvm_sf_update(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
1937 int iwl_mvm_ftm_start_responder(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
);
1938 void iwl_mvm_ftm_restart_responder(struct iwl_mvm
*mvm
,
1939 struct ieee80211_vif
*vif
);
1940 void iwl_mvm_ftm_responder_stats(struct iwl_mvm
*mvm
,
1941 struct iwl_rx_cmd_buffer
*rxb
);
1942 int iwl_mvm_ftm_resp_remove_pasn_sta(struct iwl_mvm
*mvm
,
1943 struct ieee80211_vif
*vif
, u8
*addr
);
1944 int iwl_mvm_ftm_respoder_add_pasn_sta(struct iwl_mvm
*mvm
,
1945 struct ieee80211_vif
*vif
,
1946 u8
*addr
, u32 cipher
, u8
*tk
, u32 tk_len
,
1947 u8
*hltk
, u32 hltk_len
);
1948 void iwl_mvm_ftm_responder_clear(struct iwl_mvm
*mvm
,
1949 struct ieee80211_vif
*vif
);
1952 void iwl_mvm_ftm_restart(struct iwl_mvm
*mvm
);
1953 void iwl_mvm_ftm_range_resp(struct iwl_mvm
*mvm
,
1954 struct iwl_rx_cmd_buffer
*rxb
);
1955 void iwl_mvm_ftm_lc_notif(struct iwl_mvm
*mvm
,
1956 struct iwl_rx_cmd_buffer
*rxb
);
1957 int iwl_mvm_ftm_start(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
1958 struct cfg80211_pmsr_request
*request
);
1959 void iwl_mvm_ftm_abort(struct iwl_mvm
*mvm
, struct cfg80211_pmsr_request
*req
);
1960 void iwl_mvm_ftm_initiator_smooth_config(struct iwl_mvm
*mvm
);
1961 void iwl_mvm_ftm_initiator_smooth_stop(struct iwl_mvm
*mvm
);
1962 int iwl_mvm_ftm_add_pasn_sta(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
1963 u8
*addr
, u32 cipher
, u8
*tk
, u32 tk_len
,
1964 u8
*hltk
, u32 hltk_len
);
1965 void iwl_mvm_ftm_remove_pasn_sta(struct iwl_mvm
*mvm
, u8
*addr
);
1970 * We use TID 4 (VI) as a FW-used-only TID when TDLS connections are present.
1971 * This TID is marked as used vs the AP and all connected TDLS peers.
1973 #define IWL_MVM_TDLS_FW_TID 4
1975 int iwl_mvm_tdls_sta_count(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
);
1976 void iwl_mvm_teardown_tdls_peers(struct iwl_mvm
*mvm
);
1977 void iwl_mvm_recalc_tdls_state(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
1979 void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw
*hw
,
1980 struct ieee80211_vif
*vif
);
1981 int iwl_mvm_tdls_channel_switch(struct ieee80211_hw
*hw
,
1982 struct ieee80211_vif
*vif
,
1983 struct ieee80211_sta
*sta
, u8 oper_class
,
1984 struct cfg80211_chan_def
*chandef
,
1985 struct sk_buff
*tmpl_skb
, u32 ch_sw_tm_ie
);
1986 void iwl_mvm_tdls_recv_channel_switch(struct ieee80211_hw
*hw
,
1987 struct ieee80211_vif
*vif
,
1988 struct ieee80211_tdls_ch_sw_params
*params
);
1989 void iwl_mvm_tdls_cancel_channel_switch(struct ieee80211_hw
*hw
,
1990 struct ieee80211_vif
*vif
,
1991 struct ieee80211_sta
*sta
);
1992 void iwl_mvm_rx_tdls_notif(struct iwl_mvm
*mvm
, struct iwl_rx_cmd_buffer
*rxb
);
1993 void iwl_mvm_tdls_ch_switch_work(struct work_struct
*work
);
1995 void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm
*mvm
,
1996 struct iwl_mvm_internal_rxq_notif
*notif
,
1998 void iwl_mvm_reorder_timer_expired(struct timer_list
*t
);
1999 struct ieee80211_vif
*iwl_mvm_get_bss_vif(struct iwl_mvm
*mvm
);
2000 struct ieee80211_vif
*iwl_mvm_get_vif_by_macid(struct iwl_mvm
*mvm
, u32 macid
);
2001 bool iwl_mvm_is_vif_assoc(struct iwl_mvm
*mvm
);
2003 #define MVM_TCM_PERIOD_MSEC 500
2004 #define MVM_TCM_PERIOD (HZ * MVM_TCM_PERIOD_MSEC / 1000)
2005 #define MVM_LL_PERIOD (10 * HZ)
2006 void iwl_mvm_tcm_work(struct work_struct
*work
);
2007 void iwl_mvm_recalc_tcm(struct iwl_mvm
*mvm
);
2008 void iwl_mvm_pause_tcm(struct iwl_mvm
*mvm
, bool with_cancel
);
2009 void iwl_mvm_resume_tcm(struct iwl_mvm
*mvm
);
2010 void iwl_mvm_tcm_add_vif(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
);
2011 void iwl_mvm_tcm_rm_vif(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
);
2012 u8
iwl_mvm_tcm_load_percentage(u32 airtime
, u32 elapsed
);
2014 void iwl_mvm_nic_restart(struct iwl_mvm
*mvm
, bool fw_error
);
2015 unsigned int iwl_mvm_get_wd_timeout(struct iwl_mvm
*mvm
,
2016 struct ieee80211_vif
*vif
,
2017 bool tdls
, bool cmd_q
);
2018 void iwl_mvm_connection_loss(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
2019 const char *errmsg
);
2020 void iwl_mvm_event_frame_timeout_callback(struct iwl_mvm
*mvm
,
2021 struct ieee80211_vif
*vif
,
2022 const struct ieee80211_sta
*sta
,
2025 int iwl_mvm_sar_select_profile(struct iwl_mvm
*mvm
, int prof_a
, int prof_b
);
2026 int iwl_mvm_get_sar_geo_profile(struct iwl_mvm
*mvm
);
2027 int iwl_mvm_ppag_send_cmd(struct iwl_mvm
*mvm
);
2028 #ifdef CONFIG_IWLWIFI_DEBUGFS
2029 void iwl_mvm_sta_add_debugfs(struct ieee80211_hw
*hw
,
2030 struct ieee80211_vif
*vif
,
2031 struct ieee80211_sta
*sta
,
2032 struct dentry
*dir
);
2035 static inline u8
iwl_mvm_phy_band_from_nl80211(enum nl80211_band band
)
2038 case NL80211_BAND_2GHZ
:
2040 case NL80211_BAND_5GHZ
:
2042 case NL80211_BAND_6GHZ
:
2045 WARN_ONCE(1, "Unsupported band (%u)\n", band
);
2050 /* Channel info utils */
2051 static inline bool iwl_mvm_has_ultra_hb_channel(struct iwl_mvm
*mvm
)
2053 return fw_has_capa(&mvm
->fw
->ucode_capa
,
2054 IWL_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS
);
2057 static inline void *iwl_mvm_chan_info_cmd_tail(struct iwl_mvm
*mvm
,
2058 struct iwl_fw_channel_info
*ci
)
2060 return (u8
*)ci
+ (iwl_mvm_has_ultra_hb_channel(mvm
) ?
2061 sizeof(struct iwl_fw_channel_info
) :
2062 sizeof(struct iwl_fw_channel_info_v1
));
2065 static inline size_t iwl_mvm_chan_info_padding(struct iwl_mvm
*mvm
)
2067 return iwl_mvm_has_ultra_hb_channel(mvm
) ? 0 :
2068 sizeof(struct iwl_fw_channel_info
) -
2069 sizeof(struct iwl_fw_channel_info_v1
);
2072 static inline void iwl_mvm_set_chan_info(struct iwl_mvm
*mvm
,
2073 struct iwl_fw_channel_info
*ci
,
2074 u32 chan
, u8 band
, u8 width
,
2077 if (iwl_mvm_has_ultra_hb_channel(mvm
)) {
2078 ci
->channel
= cpu_to_le32(chan
);
2081 ci
->ctrl_pos
= ctrl_pos
;
2083 struct iwl_fw_channel_info_v1
*ci_v1
=
2084 (struct iwl_fw_channel_info_v1
*)ci
;
2086 ci_v1
->channel
= chan
;
2088 ci_v1
->width
= width
;
2089 ci_v1
->ctrl_pos
= ctrl_pos
;
2094 iwl_mvm_set_chan_info_chandef(struct iwl_mvm
*mvm
,
2095 struct iwl_fw_channel_info
*ci
,
2096 struct cfg80211_chan_def
*chandef
)
2098 enum nl80211_band band
= chandef
->chan
->band
;
2100 iwl_mvm_set_chan_info(mvm
, ci
, chandef
->chan
->hw_value
,
2101 iwl_mvm_phy_band_from_nl80211(band
),
2102 iwl_mvm_get_channel_width(chandef
),
2103 iwl_mvm_get_ctrl_pos(chandef
));
2106 static inline int iwl_umac_scan_get_max_profiles(const struct iwl_fw
*fw
)
2108 u8 ver
= iwl_fw_lookup_cmd_ver(fw
, IWL_ALWAYS_LONG_GROUP
,
2109 SCAN_OFFLOAD_UPDATE_PROFILES_CMD
,
2110 IWL_FW_CMD_VER_UNKNOWN
);
2111 return (ver
== IWL_FW_CMD_VER_UNKNOWN
|| ver
< 3) ?
2112 IWL_SCAN_MAX_PROFILES
: IWL_SCAN_MAX_PROFILES_V2
;
2116 enum iwl_location_cipher
iwl_mvm_cipher_to_location_cipher(u32 cipher
)
2119 case WLAN_CIPHER_SUITE_CCMP
:
2120 return IWL_LOCATION_CIPHER_CCMP_128
;
2121 case WLAN_CIPHER_SUITE_GCMP
:
2122 return IWL_LOCATION_CIPHER_GCMP_128
;
2123 case WLAN_CIPHER_SUITE_GCMP_256
:
2124 return IWL_LOCATION_CIPHER_GCMP_256
;
2126 return IWL_LOCATION_CIPHER_INVALID
;
2129 #endif /* __IWL_MVM_H__ */