1 /* SPDX-License-Identifier: ISC */
3 * Copyright (c) 2005-2011 Atheros Communications Inc.
4 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
5 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
6 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
12 #include <linux/completion.h>
13 #include <linux/if_ether.h>
14 #include <linux/types.h>
15 #include <linux/pci.h>
16 #include <linux/uuid.h>
17 #include <linux/time.h>
18 #include <linux/leds.h>
23 #include "targaddrs.h"
27 #include "../dfs_pattern_detector.h"
33 #define MS(_v, _f) (((_v) & _f##_MASK) >> _f##_LSB)
34 #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
35 #define WO(_f) ((_f##_OFFSET) >> 2)
37 #define ATH10K_SCAN_ID 0
38 #define ATH10K_SCAN_CHANNEL_SWITCH_WMI_EVT_OVERHEAD 10 /* msec */
39 #define WMI_READY_TIMEOUT (5 * HZ)
40 #define ATH10K_FLUSH_TIMEOUT_HZ (5 * HZ)
41 #define ATH10K_CONNECTION_LOSS_HZ (3 * HZ)
42 #define ATH10K_NUM_CHANS 41
43 #define ATH10K_MAX_5G_CHAN 173
45 /* Antenna noise floor */
46 #define ATH10K_DEFAULT_NOISE_FLOOR -95
48 #define ATH10K_INVALID_RSSI 128
50 #define ATH10K_MAX_NUM_MGMT_PENDING 128
52 /* number of failed packets (20 packets with 16 sw reties each) */
53 #define ATH10K_KICKOUT_THRESHOLD (20 * 16)
56 * Use insanely high numbers to make sure that the firmware implementation
57 * won't start, we have the same functionality already in hostapd. Unit
60 #define ATH10K_KEEPALIVE_MIN_IDLE 3747
61 #define ATH10K_KEEPALIVE_MAX_IDLE 3895
62 #define ATH10K_KEEPALIVE_MAX_UNRESPONSIVE 3900
64 /* SMBIOS type containing Board Data File Name Extension */
65 #define ATH10K_SMBIOS_BDF_EXT_TYPE 0xF8
67 /* SMBIOS type structure length (excluding strings-set) */
68 #define ATH10K_SMBIOS_BDF_EXT_LENGTH 0x9
70 /* Offset pointing to Board Data File Name Extension */
71 #define ATH10K_SMBIOS_BDF_EXT_OFFSET 0x8
73 /* Board Data File Name Extension string length.
74 * String format: BDF_<Customer ID>_<Extension>\0
76 #define ATH10K_SMBIOS_BDF_EXT_STR_LENGTH 0x20
78 /* The magic used by QCA spec */
79 #define ATH10K_SMBIOS_BDF_EXT_MAGIC "BDF_"
81 /* Default Airtime weight multiplier (Tuned for multiclient performance) */
82 #define ATH10K_AIRTIME_WEIGHT_MULTIPLIER 4
84 #define ATH10K_MAX_RETRY_COUNT 30
86 #define ATH10K_ITER_NORMAL_FLAGS (IEEE80211_IFACE_ITER_NORMAL | \
87 IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER)
88 #define ATH10K_ITER_RESUME_FLAGS (IEEE80211_IFACE_ITER_RESUME_ALL |\
89 IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER)
93 static inline const char *ath10k_bus_str(enum ath10k_bus bus
)
100 case ATH10K_BUS_SDIO
:
104 case ATH10K_BUS_SNOC
:
111 enum ath10k_skb_flags
{
112 ATH10K_SKB_F_NO_HWCRYPT
= BIT(0),
113 ATH10K_SKB_F_DTIM_ZERO
= BIT(1),
114 ATH10K_SKB_F_DELIVER_CAB
= BIT(2),
115 ATH10K_SKB_F_MGMT
= BIT(3),
116 ATH10K_SKB_F_QOS
= BIT(4),
117 ATH10K_SKB_F_RAW_TX
= BIT(5),
118 ATH10K_SKB_F_NOACK_TID
= BIT(6),
121 struct ath10k_skb_cb
{
127 struct ieee80211_vif
*vif
;
128 struct ieee80211_txq
*txq
;
132 struct ath10k_skb_rxcb
{
134 struct hlist_node hlist
;
138 static inline struct ath10k_skb_cb
*ATH10K_SKB_CB(struct sk_buff
*skb
)
140 BUILD_BUG_ON(sizeof(struct ath10k_skb_cb
) >
141 IEEE80211_TX_INFO_DRIVER_DATA_SIZE
);
142 return (struct ath10k_skb_cb
*)&IEEE80211_SKB_CB(skb
)->driver_data
;
145 static inline struct ath10k_skb_rxcb
*ATH10K_SKB_RXCB(struct sk_buff
*skb
)
147 BUILD_BUG_ON(sizeof(struct ath10k_skb_rxcb
) > sizeof(skb
->cb
));
148 return (struct ath10k_skb_rxcb
*)skb
->cb
;
151 #define ATH10K_RXCB_SKB(rxcb) \
152 container_of((void *)rxcb, struct sk_buff, cb)
154 static inline u32
host_interest_item_address(u32 item_offset
)
156 return QCA988X_HOST_INTEREST_ADDRESS
+ item_offset
;
159 enum ath10k_phy_mode
{
160 ATH10K_PHY_MODE_LEGACY
= 0,
161 ATH10K_PHY_MODE_HT
= 1,
162 ATH10K_PHY_MODE_VHT
= 2,
165 /* Data rate 100KBPS based on IE Index */
166 struct ath10k_index_ht_data_rate_type
{
167 u8 beacon_rate_index
;
168 u16 supported_rate
[4];
171 /* Data rate 100KBPS based on IE Index */
172 struct ath10k_index_vht_data_rate_type
{
173 u8 beacon_rate_index
;
174 u16 supported_VHT80_rate
[2];
175 u16 supported_VHT40_rate
[2];
176 u16 supported_VHT20_rate
[2];
183 struct ath10k_mem_chunk
{
191 enum ath10k_htc_ep_id eid
;
192 struct completion service_ready
;
193 struct completion unified_ready
;
194 struct completion barrier
;
195 struct completion radar_confirm
;
196 wait_queue_head_t tx_credits_wq
;
197 DECLARE_BITMAP(svc_map
, WMI_SERVICE_MAX
);
198 struct wmi_cmd_map
*cmd
;
199 struct wmi_vdev_param_map
*vdev_param
;
200 struct wmi_pdev_param_map
*pdev_param
;
201 struct wmi_peer_param_map
*peer_param
;
202 const struct wmi_ops
*ops
;
203 const struct wmi_peer_flags_map
*peer_flags
;
205 u32 mgmt_max_num_pending_tx
;
207 /* Protected by data_lock */
208 struct idr mgmt_pending_tx
;
212 struct ath10k_mem_chunk mem_chunks
[WMI_MAX_MEM_REQS
];
215 struct ath10k_fw_stats_peer
{
216 struct list_head list
;
218 u8 peer_macaddr
[ETH_ALEN
];
221 u32 peer_rx_rate
; /* 10x only */
225 struct ath10k_fw_extd_stats_peer
{
226 struct list_head list
;
228 u8 peer_macaddr
[ETH_ALEN
];
232 struct ath10k_fw_stats_vdev
{
233 struct list_head list
;
238 u32 num_tx_frames
[4];
240 u32 num_tx_frames_retries
[4];
241 u32 num_tx_frames_failures
[4];
246 u32 num_tx_not_acked
;
247 u32 tx_rate_history
[10];
248 u32 beacon_rssi_history
[10];
251 struct ath10k_fw_stats_vdev_extd
{
252 struct list_head list
;
258 u32 ppdu_nonaggr_cnt
;
259 u32 mpdu_sw_requeued
;
261 u32 mpdu_suc_multitry
;
264 u32 tx_ftm_suc_retry
;
269 u32 rx_iftmr_dup_cnt
;
272 struct ath10k_fw_stats_pdev
{
273 struct list_head list
;
277 u32 tx_frame_count
; /* Cycles spent transmitting frames */
278 u32 rx_frame_count
; /* Cycles spent receiving frames */
279 u32 rx_clear_count
; /* Total channel busy time, evidently */
280 u32 cycle_count
; /* Total on-channel time */
307 u32 sw_retry_failure
;
308 u32 illgl_rate_phy_err
;
309 u32 pdev_cont_xretry
;
315 u32 seq_failed_queueing
;
322 u32 mpdus_ack_failed
;
326 s32 mid_ppdu_route_change
;
343 struct ath10k_fw_stats
{
345 struct list_head pdevs
;
346 struct list_head vdevs
;
347 struct list_head peers
;
348 struct list_head peers_extd
;
351 #define ATH10K_TPC_TABLE_TYPE_FLAG 1
352 #define ATH10K_TPC_PREAM_TABLE_END 0xFFFF
354 struct ath10k_tpc_table
{
355 u32 pream_idx
[WMI_TPC_RATE_MAX
];
356 u8 rate_code
[WMI_TPC_RATE_MAX
];
357 char tpc_value
[WMI_TPC_RATE_MAX
][WMI_TPC_TX_N_CHAIN
* WMI_TPC_BUF_SIZE
];
360 struct ath10k_tpc_stats
{
364 u32 twice_antenna_reduction
;
365 u32 twice_max_rd_power
;
366 s32 twice_antenna_gain
;
371 u8 flag
[WMI_TPC_FLAG
];
372 struct ath10k_tpc_table tpc_table
[WMI_TPC_FLAG
];
375 struct ath10k_tpc_table_final
{
376 u32 pream_idx
[WMI_TPC_FINAL_RATE_MAX
];
377 u8 rate_code
[WMI_TPC_FINAL_RATE_MAX
];
378 char tpc_value
[WMI_TPC_FINAL_RATE_MAX
][WMI_TPC_TX_N_CHAIN
* WMI_TPC_BUF_SIZE
];
381 struct ath10k_tpc_stats_final
{
385 u32 twice_antenna_reduction
;
386 u32 twice_max_rd_power
;
387 s32 twice_antenna_gain
;
392 u8 flag
[WMI_TPC_FLAG
];
393 struct ath10k_tpc_table_final tpc_table_final
[WMI_TPC_FLAG
];
396 struct ath10k_dfs_stats
{
400 u32 pulses_discarded
;
404 enum ath10k_radar_confirmation_state
{
405 ATH10K_RADAR_CONFIRMATION_IDLE
= 0,
406 ATH10K_RADAR_CONFIRMATION_INPROGRESS
,
407 ATH10K_RADAR_CONFIRMATION_STOPPED
,
410 struct ath10k_radar_found_info
{
419 #define ATH10K_MAX_NUM_PEER_IDS (1 << 11) /* htt rx_desc limit */
422 struct list_head list
;
423 struct ieee80211_vif
*vif
;
424 struct ieee80211_sta
*sta
;
429 DECLARE_BITMAP(peer_ids
, ATH10K_MAX_NUM_PEER_IDS
);
431 /* protected by ar->data_lock */
432 struct ieee80211_key_conf
*keys
[WMI_MAX_KEY_INDEX
+ 1];
433 union htt_rx_pn_t tids_last_pn
[ATH10K_TXRX_NUM_EXT_TIDS
];
434 bool tids_last_pn_valid
[ATH10K_TXRX_NUM_EXT_TIDS
];
435 union htt_rx_pn_t frag_tids_last_pn
[ATH10K_TXRX_NUM_EXT_TIDS
];
436 u32 frag_tids_seq
[ATH10K_TXRX_NUM_EXT_TIDS
];
438 enum htt_security_types sec_type
;
440 } rx_pn
[ATH10K_HTT_TXRX_PEER_SECURITY_MAX
];
444 struct list_head list
;
445 unsigned long num_fw_queued
;
446 unsigned long num_push_allowed
;
449 enum ath10k_pkt_rx_err
{
450 ATH10K_PKT_RX_ERR_FCS
,
451 ATH10K_PKT_RX_ERR_TKIP
,
452 ATH10K_PKT_RX_ERR_CRYPT
,
453 ATH10K_PKT_RX_ERR_PEER_IDX_INVAL
,
454 ATH10K_PKT_RX_ERR_MAX
,
457 enum ath10k_ampdu_subfrm_num
{
458 ATH10K_AMPDU_SUBFRM_NUM_10
,
459 ATH10K_AMPDU_SUBFRM_NUM_20
,
460 ATH10K_AMPDU_SUBFRM_NUM_30
,
461 ATH10K_AMPDU_SUBFRM_NUM_40
,
462 ATH10K_AMPDU_SUBFRM_NUM_50
,
463 ATH10K_AMPDU_SUBFRM_NUM_60
,
464 ATH10K_AMPDU_SUBFRM_NUM_MORE
,
465 ATH10K_AMPDU_SUBFRM_NUM_MAX
,
468 enum ath10k_amsdu_subfrm_num
{
469 ATH10K_AMSDU_SUBFRM_NUM_1
,
470 ATH10K_AMSDU_SUBFRM_NUM_2
,
471 ATH10K_AMSDU_SUBFRM_NUM_3
,
472 ATH10K_AMSDU_SUBFRM_NUM_4
,
473 ATH10K_AMSDU_SUBFRM_NUM_MORE
,
474 ATH10K_AMSDU_SUBFRM_NUM_MAX
,
477 struct ath10k_sta_tid_stats
{
478 unsigned long rx_pkt_from_fw
;
479 unsigned long rx_pkt_unchained
;
480 unsigned long rx_pkt_drop_chained
;
481 unsigned long rx_pkt_drop_filter
;
482 unsigned long rx_pkt_err
[ATH10K_PKT_RX_ERR_MAX
];
483 unsigned long rx_pkt_queued_for_mac
;
484 unsigned long rx_pkt_ampdu
[ATH10K_AMPDU_SUBFRM_NUM_MAX
];
485 unsigned long rx_pkt_amsdu
[ATH10K_AMSDU_SUBFRM_NUM_MAX
];
488 enum ath10k_counter_type
{
489 ATH10K_COUNTER_TYPE_BYTES
,
490 ATH10K_COUNTER_TYPE_PKTS
,
491 ATH10K_COUNTER_TYPE_MAX
,
494 enum ath10k_stats_type
{
495 ATH10K_STATS_TYPE_SUCC
,
496 ATH10K_STATS_TYPE_FAIL
,
497 ATH10K_STATS_TYPE_RETRY
,
498 ATH10K_STATS_TYPE_AMPDU
,
499 ATH10K_STATS_TYPE_MAX
,
502 struct ath10k_htt_data_stats
{
503 u64 legacy
[ATH10K_COUNTER_TYPE_MAX
][ATH10K_LEGACY_NUM
];
504 u64 ht
[ATH10K_COUNTER_TYPE_MAX
][ATH10K_HT_MCS_NUM
];
505 u64 vht
[ATH10K_COUNTER_TYPE_MAX
][ATH10K_VHT_MCS_NUM
];
506 u64 bw
[ATH10K_COUNTER_TYPE_MAX
][ATH10K_BW_NUM
];
507 u64 nss
[ATH10K_COUNTER_TYPE_MAX
][ATH10K_NSS_NUM
];
508 u64 gi
[ATH10K_COUNTER_TYPE_MAX
][ATH10K_GI_NUM
];
509 u64 rate_table
[ATH10K_COUNTER_TYPE_MAX
][ATH10K_RATE_TABLE_NUM
];
512 struct ath10k_htt_tx_stats
{
513 struct ath10k_htt_data_stats stats
[ATH10K_STATS_TYPE_MAX
];
519 #define ATH10K_TID_MAX 8
522 struct ath10k_vif
*arvif
;
524 /* the following are protected by ar->data_lock */
525 u32 changed
; /* IEEE80211_RC_* */
530 struct rate_info txrate
;
531 struct ieee80211_tx_info tx_info
;
540 struct work_struct update_wk
;
542 struct ath10k_htt_tx_stats
*tx_stats
;
545 #ifdef CONFIG_MAC80211_DEBUGFS
546 /* protected by conf_mutex */
549 /* Protected with ar->data_lock */
550 struct ath10k_sta_tid_stats tid_stats
[IEEE80211_NUM_TIDS
+ 1];
552 /* Protected with ar->data_lock */
554 struct work_struct tid_config_wk
;
555 int noack
[ATH10K_TID_MAX
];
556 int retry_long
[ATH10K_TID_MAX
];
557 int ampdu
[ATH10K_TID_MAX
];
558 u8 rate_ctrl
[ATH10K_TID_MAX
];
559 u32 rate_code
[ATH10K_TID_MAX
];
560 int rtscts
[ATH10K_TID_MAX
];
563 #define ATH10K_VDEV_SETUP_TIMEOUT_HZ (5 * HZ)
564 #define ATH10K_VDEV_DELETE_TIMEOUT_HZ (5 * HZ)
566 enum ath10k_beacon_state
{
567 ATH10K_BEACON_SCHEDULED
= 0,
568 ATH10K_BEACON_SENDING
,
573 struct list_head list
;
577 enum wmi_vdev_type vdev_type
;
578 enum wmi_vdev_subtype vdev_subtype
;
581 struct sk_buff
*beacon
;
582 /* protected by data_lock */
583 enum ath10k_beacon_state beacon_state
;
585 dma_addr_t beacon_paddr
;
586 unsigned long tx_paused
; /* arbitrary values defined by target */
589 struct ieee80211_vif
*vif
;
593 bool spectral_enabled
;
598 struct ieee80211_key_conf
*wep_keys
[WMI_MAX_KEY_INDEX
+ 1];
612 u8 ssid
[IEEE80211_MAX_SSID_LEN
] __nonstring
;
614 /* P2P_IE with NoA attribute for P2P_GO case */
622 int num_legacy_stations
;
625 struct wmi_wmm_params_all_arg wmm_params
;
626 struct work_struct ap_csa_work
;
627 struct delayed_work connection_loss_work
;
628 struct cfg80211_bitrate_mask bitrate_mask
;
630 /* For setting VHT peer fixed rate, protected by conf_mutex */
633 u32 tid_conf_changed
[ATH10K_TID_MAX
];
634 int noack
[ATH10K_TID_MAX
];
635 int retry_long
[ATH10K_TID_MAX
];
636 int ampdu
[ATH10K_TID_MAX
];
637 u8 rate_ctrl
[ATH10K_TID_MAX
];
638 u32 rate_code
[ATH10K_TID_MAX
];
639 int rtscts
[ATH10K_TID_MAX
];
643 struct ath10k_vif_iter
{
645 struct ath10k_vif
*arvif
;
648 /* Copy Engine register dump, protected by ce-lock */
649 struct ath10k_ce_crash_data
{
657 struct ath10k_ce_crash_hdr
{
659 __le32 reserved
[3]; /* for future use */
660 struct ath10k_ce_crash_data entries
[];
663 #define MAX_MEM_DUMP_TYPE 5
665 /* used for crash-dump storage, protected by data-lock */
666 struct ath10k_fw_crash_data
{
668 struct timespec64 timestamp
;
669 __le32 registers
[REG_DUMP_COUNT_QCA988X
];
670 struct ath10k_ce_crash_data ce_crash_data
[CE_COUNT_MAX
];
673 size_t ramdump_buf_len
;
676 struct ath10k_debug
{
677 struct dentry
*debugfs_phy
;
679 struct ath10k_fw_stats fw_stats
;
680 struct completion fw_stats_complete
;
683 unsigned long htt_stats_mask
;
684 unsigned long reset_htt_stats
;
685 struct delayed_work htt_stats_dwork
;
686 struct ath10k_dfs_stats dfs_stats
;
687 struct ath_dfs_pool_stats dfs_pool_stats
;
689 /* used for tpc-dump storage, protected by data-lock */
690 struct ath10k_tpc_stats
*tpc_stats
;
691 struct ath10k_tpc_stats_final
*tpc_stats_final
;
693 struct completion tpc_complete
;
695 /* protected by conf_mutex */
701 u32 enable_extd_tx_stats
;
706 ATH10K_STATE_OFF
= 0,
709 /* When doing firmware recovery the device is first powered down.
710 * mac80211 is supposed to call in to start() hook later on. It is
711 * however possible that driver unloading and firmware crash overlap.
712 * mac80211 can wait on conf_mutex in stop() while the device is
713 * stopped in ath10k_core_restart() work holding conf_mutex. The state
714 * RESTARTED means that the device is up and mac80211 has started hw
715 * reconfiguration. Once mac80211 is done with the reconfiguration we
716 * set the state to STATE_ON in reconfig_complete().
718 ATH10K_STATE_RESTARTING
,
719 ATH10K_STATE_RESTARTED
,
721 /* The device has crashed while restarting hw. This state is like ON
722 * but commands are blocked in HTC and -ECOMM response is given. This
723 * prevents completion timeouts and makes the driver more responsive to
724 * userspace commands. This is also prevents recursive recovery.
732 enum ath10k_firmware_mode
{
733 /* the default mode, standard 802.11 functionality */
734 ATH10K_FIRMWARE_MODE_NORMAL
,
736 /* factory tests etc */
737 ATH10K_FIRMWARE_MODE_UTF
,
740 enum ath10k_fw_features
{
741 /* wmi_mgmt_rx_hdr contains extra RSSI information */
742 ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX
= 0,
744 /* Firmware from 10X branch. Deprecated, don't use in new code. */
745 ATH10K_FW_FEATURE_WMI_10X
= 1,
747 /* firmware support tx frame management over WMI, otherwise it's HTT */
748 ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX
= 2,
750 /* Firmware does not support P2P */
751 ATH10K_FW_FEATURE_NO_P2P
= 3,
753 /* Firmware 10.2 feature bit. The ATH10K_FW_FEATURE_WMI_10X feature
754 * bit is required to be set as well. Deprecated, don't use in new
757 ATH10K_FW_FEATURE_WMI_10_2
= 4,
759 /* Some firmware revisions lack proper multi-interface client powersave
760 * implementation. Enabling PS could result in connection drops,
761 * traffic stalls, etc.
763 ATH10K_FW_FEATURE_MULTI_VIF_PS_SUPPORT
= 5,
765 /* Some firmware revisions have an incomplete WoWLAN implementation
766 * despite WMI service bit being advertised. This feature flag is used
767 * to distinguish whether WoWLAN is really supported or not.
769 ATH10K_FW_FEATURE_WOWLAN_SUPPORT
= 6,
771 /* Don't trust error code from otp.bin */
772 ATH10K_FW_FEATURE_IGNORE_OTP_RESULT
= 7,
774 /* Some firmware revisions pad 4th hw address to 4 byte boundary making
775 * it 8 bytes long in Native Wifi Rx decap.
777 ATH10K_FW_FEATURE_NO_NWIFI_DECAP_4ADDR_PADDING
= 8,
779 /* Firmware supports bypassing PLL setting on init. */
780 ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT
= 9,
782 /* Raw mode support. If supported, FW supports receiving and trasmitting
783 * frames in raw mode.
785 ATH10K_FW_FEATURE_RAW_MODE_SUPPORT
= 10,
787 /* Firmware Supports Adaptive CCA*/
788 ATH10K_FW_FEATURE_SUPPORTS_ADAPTIVE_CCA
= 11,
790 /* Firmware supports management frame protection */
791 ATH10K_FW_FEATURE_MFP_SUPPORT
= 12,
793 /* Firmware supports pull-push model where host shares it's software
794 * queue state with firmware and firmware generates fetch requests
795 * telling host which queues to dequeue tx from.
797 * Primary function of this is improved MU-MIMO performance with
800 ATH10K_FW_FEATURE_PEER_FLOW_CONTROL
= 13,
802 /* Firmware supports BT-Coex without reloading firmware via pdev param.
803 * To support Bluetooth coexistence pdev param, WMI_COEX_GPIO_SUPPORT of
804 * extended resource config should be enabled always. This firmware IE
805 * is used to configure WMI_COEX_GPIO_SUPPORT.
807 ATH10K_FW_FEATURE_BTCOEX_PARAM
= 14,
809 /* Unused flag and proven to be not working, enable this if you want
810 * to experiment sending NULL func data frames in HTT TX
812 ATH10K_FW_FEATURE_SKIP_NULL_FUNC_WAR
= 15,
814 /* Firmware allow other BSS mesh broadcast/multicast frames without
815 * creating monitor interface. Appropriate rxfilters are programmed for
816 * mesh vdev by firmware itself. This feature flags will be used for
817 * not creating monitor vdev while configuring mesh node.
819 ATH10K_FW_FEATURE_ALLOWS_MESH_BCAST
= 16,
821 /* Firmware does not support power save in station mode. */
822 ATH10K_FW_FEATURE_NO_PS
= 17,
824 /* Firmware allows management tx by reference instead of by value. */
825 ATH10K_FW_FEATURE_MGMT_TX_BY_REF
= 18,
827 /* Firmware load is done externally, not by bmi */
828 ATH10K_FW_FEATURE_NON_BMI
= 19,
830 /* Firmware sends only one chan_info event per channel */
831 ATH10K_FW_FEATURE_SINGLE_CHAN_INFO_PER_CHANNEL
= 20,
833 /* Firmware allows setting peer fixed rate */
834 ATH10K_FW_FEATURE_PEER_FIXED_RATE
= 21,
836 /* Firmware support IRAM recovery */
837 ATH10K_FW_FEATURE_IRAM_RECOVERY
= 22,
840 ATH10K_FW_FEATURE_COUNT
,
843 enum ath10k_dev_flags
{
844 /* Indicates that ath10k device is during CAC phase of DFS */
846 ATH10K_FLAG_CORE_REGISTERED
,
848 /* Device has crashed and needs to restart. This indicates any pending
849 * waiters should immediately cancel instead of waiting for a time out.
851 ATH10K_FLAG_CRASH_FLUSH
,
853 /* Use Raw mode instead of native WiFi Tx/Rx encap mode.
854 * Raw mode supports both hardware and software crypto. Native WiFi only
855 * supports hardware crypto.
857 ATH10K_FLAG_RAW_MODE
,
859 /* Disable HW crypto engine */
860 ATH10K_FLAG_HW_CRYPTO_DISABLED
,
862 /* Bluetooth coexistence enabled */
865 /* Per Station statistics service */
866 ATH10K_FLAG_PEER_STATS
,
868 /* Indicates that ath10k device is during recovery process and not complete */
869 ATH10K_FLAG_RESTARTING
,
871 /* protected by conf_mutex */
872 ATH10K_FLAG_NAPI_ENABLED
,
875 enum ath10k_cal_mode
{
876 ATH10K_CAL_MODE_FILE
,
879 ATH10K_CAL_MODE_NVMEM
,
880 ATH10K_PRE_CAL_MODE_FILE
,
881 ATH10K_PRE_CAL_MODE_DT
,
882 ATH10K_PRE_CAL_MODE_NVMEM
,
883 ATH10K_CAL_MODE_EEPROM
,
886 enum ath10k_crypt_mode
{
887 /* Only use hardware crypto engine */
888 ATH10K_CRYPT_MODE_HW
,
889 /* Only use software crypto engine */
890 ATH10K_CRYPT_MODE_SW
,
893 static inline const char *ath10k_cal_mode_str(enum ath10k_cal_mode mode
)
896 case ATH10K_CAL_MODE_FILE
:
898 case ATH10K_CAL_MODE_OTP
:
900 case ATH10K_CAL_MODE_DT
:
902 case ATH10K_CAL_MODE_NVMEM
:
904 case ATH10K_PRE_CAL_MODE_FILE
:
905 return "pre-cal-file";
906 case ATH10K_PRE_CAL_MODE_DT
:
908 case ATH10K_PRE_CAL_MODE_NVMEM
:
909 return "pre-cal-nvmem";
910 case ATH10K_CAL_MODE_EEPROM
:
917 enum ath10k_scan_state
{
919 ATH10K_SCAN_STARTING
,
921 ATH10K_SCAN_ABORTING
,
924 static inline const char *ath10k_scan_state_str(enum ath10k_scan_state state
)
927 case ATH10K_SCAN_IDLE
:
929 case ATH10K_SCAN_STARTING
:
931 case ATH10K_SCAN_RUNNING
:
933 case ATH10K_SCAN_ABORTING
:
940 enum ath10k_tx_pause_reason
{
941 ATH10K_TX_PAUSE_Q_FULL
,
945 struct ath10k_fw_file
{
946 const struct firmware
*firmware
;
948 char fw_version
[ETHTOOL_FWVERS_LEN
];
950 DECLARE_BITMAP(fw_features
, ATH10K_FW_FEATURE_COUNT
);
952 enum ath10k_fw_wmi_op_version wmi_op_version
;
953 enum ath10k_fw_htt_op_version htt_op_version
;
955 const void *firmware_data
;
958 const void *otp_data
;
961 const void *codeswap_data
;
964 /* The original idea of struct ath10k_fw_file was that it only
965 * contains struct firmware and pointers to various parts (actual
966 * firmware binary, otp, metadata etc) of the file. This seg_info
967 * is actually created separate but as this is used similarly as
968 * the other firmware components it's more convenient to have it
971 struct ath10k_swap_code_seg_info
*firmware_swap_code_seg_info
;
974 struct ath10k_fw_components
{
975 const struct firmware
*board
;
976 const void *board_data
;
978 const struct firmware
*ext_board
;
979 const void *ext_board_data
;
980 size_t ext_board_len
;
982 struct ath10k_fw_file fw_file
;
985 struct ath10k_per_peer_tx_stats
{
1000 enum ath10k_dev_type
{
1005 struct ath10k_bus_params
{
1007 enum ath10k_dev_type dev_type
;
1008 bool link_can_suspend
;
1013 struct ath_common ath_common
;
1014 struct ieee80211_hw
*hw
;
1015 struct ieee80211_ops
*ops
;
1022 u8 mac_addr
[ETH_ALEN
];
1024 enum ath10k_hw_rev hw_rev
;
1028 u8 fw_version_major
;
1029 u32 fw_version_minor
;
1030 u16 fw_version_release
;
1031 u16 fw_version_build
;
1032 u32 fw_stats_req_mask
;
1034 u32 hw_min_tx_power
;
1035 u32 hw_max_tx_power
;
1041 u32 max_spatial_stream
;
1042 /* protected by conf_mutex */
1050 /* protected by data_lock */
1053 /* protected by conf_mutex */
1060 enum ath10k_bus bus
;
1061 const struct ath10k_hif_ops
*ops
;
1064 struct completion target_suspend
;
1065 struct completion driver_recovery
;
1067 const struct ath10k_hw_regs
*regs
;
1068 const struct ath10k_hw_ce_regs
*hw_ce_regs
;
1069 const struct ath10k_hw_values
*hw_values
;
1070 struct ath10k_bmi bmi
;
1071 struct ath10k_wmi wmi
;
1072 struct ath10k_htc htc
;
1073 struct ath10k_htt htt
;
1075 struct ath10k_hw_params hw_params
;
1077 /* contains the firmware images used with ATH10K_FIRMWARE_MODE_NORMAL */
1078 struct ath10k_fw_components normal_mode_fw
;
1080 /* READ-ONLY images of the running firmware, which can be either
1081 * normal or UTF. Do not modify, release etc!
1083 const struct ath10k_fw_components
*running_fw
;
1085 const char *board_name
;
1087 const struct firmware
*pre_cal_file
;
1088 const struct firmware
*cal_file
;
1093 u32 subsystem_vendor
;
1094 u32 subsystem_device
;
1103 bool ext_bid_supported
;
1105 char bdf_ext
[ATH10K_SMBIOS_BDF_EXT_STR_LENGTH
];
1110 enum ath10k_cal_mode cal_mode
;
1113 struct completion started
;
1114 struct completion completed
;
1115 struct completion on_channel
;
1116 struct delayed_work timeout
;
1117 enum ath10k_scan_state state
;
1125 struct ieee80211_supported_band sbands
[NUM_NL80211_BANDS
];
1128 /* should never be NULL; needed for regular htt rx */
1129 struct ieee80211_channel
*rx_channel
;
1131 /* valid during scan; needed for mgmt rx during scan */
1132 struct ieee80211_channel
*scan_channel
;
1134 /* current operating channel definition */
1135 struct cfg80211_chan_def chandef
;
1137 /* currently configured operating channel in firmware */
1138 struct ieee80211_channel
*tgt_oper_chan
;
1140 unsigned long long free_vdev_map
;
1141 struct ath10k_vif
*monitor_arvif
;
1143 int monitor_vdev_id
;
1144 bool monitor_started
;
1145 unsigned int filter_flags
;
1146 unsigned long dev_flags
;
1147 bool dfs_block_radar_events
;
1149 /* protected by conf_mutex */
1151 int num_started_vdevs
;
1153 /* Protected by conf-mutex */
1154 u8 cfg_tx_chainmask
;
1155 u8 cfg_rx_chainmask
;
1157 struct completion install_key_done
;
1159 int last_wmi_vdev_start_status
;
1160 struct completion vdev_setup_done
;
1161 struct completion vdev_delete_done
;
1162 struct completion peer_stats_info_complete
;
1164 struct workqueue_struct
*workqueue
;
1165 /* Auxiliary workqueue */
1166 struct workqueue_struct
*workqueue_aux
;
1167 struct workqueue_struct
*workqueue_tx_complete
;
1168 /* prevents concurrent FW reconfiguration */
1169 struct mutex conf_mutex
;
1171 /* protects coredump data */
1172 struct mutex dump_mutex
;
1174 /* protects shared structure data */
1175 spinlock_t data_lock
;
1177 /* serialize wake_tx_queue calls per ac */
1178 spinlock_t queue_lock
[IEEE80211_NUM_ACS
];
1180 struct list_head arvifs
;
1181 struct list_head peers
;
1182 struct ath10k_peer
*peer_map
[ATH10K_MAX_NUM_PEER_IDS
];
1183 wait_queue_head_t peer_mapping_wq
;
1185 /* protected by conf_mutex */
1190 int max_num_stations
;
1192 int max_num_tdls_vdevs
;
1193 int num_active_peers
;
1196 struct work_struct svc_rdy_work
;
1197 struct sk_buff
*svc_rdy_skb
;
1199 struct work_struct offchan_tx_work
;
1200 struct sk_buff_head offchan_tx_queue
;
1201 struct completion offchan_tx_completed
;
1202 struct sk_buff
*offchan_tx_skb
;
1204 struct work_struct wmi_mgmt_tx_work
;
1205 struct sk_buff_head wmi_mgmt_tx_queue
;
1207 enum ath10k_state state
;
1209 struct work_struct register_work
;
1210 struct work_struct restart_work
;
1211 struct work_struct bundle_tx_work
;
1212 struct work_struct tx_complete_work
;
1214 /* cycle count is reported twice for each visited channel during scan.
1215 * access protected by data_lock
1217 u32 survey_last_rx_clear_count
;
1218 u32 survey_last_cycle_count
;
1219 struct survey_info survey
[ATH10K_NUM_CHANS
];
1221 /* Channel info events are expected to come in pairs without and with
1222 * COMPLETE flag set respectively for each channel visit during scan.
1224 * However there are deviations from this rule. This flag is used to
1225 * avoid reporting garbage data.
1227 bool ch_info_can_report_survey
;
1228 struct completion bss_survey_done
;
1230 struct dfs_pattern_detector
*dfs_detector
;
1232 unsigned long tx_paused
; /* see ATH10K_TX_PAUSE_ */
1234 #ifdef CONFIG_ATH10K_DEBUGFS
1235 struct ath10k_debug debug
;
1237 /* relay(fs) channel for spectral scan */
1238 struct rchan
*rfs_chan_spec_scan
;
1240 /* spectral_mode and spec_config are protected by conf_mutex */
1241 enum ath10k_spectral_mode mode
;
1242 struct ath10k_spec_scan config
;
1248 #ifdef CONFIG_DEV_COREDUMP
1250 struct ath10k_fw_crash_data
*fw_crash_data
;
1255 /* protected by conf_mutex */
1256 struct ath10k_fw_components utf_mode_fw
;
1258 /* protected by data_lock */
1263 struct gpio_led wifi_led
;
1264 struct led_classdev cdev
;
1270 /* protected by data_lock */
1271 u32 rx_crc_err_drop
;
1272 u32 fw_crash_counter
;
1273 u32 fw_warm_reset_counter
;
1274 u32 fw_cold_reset_counter
;
1277 struct ath10k_thermal thermal
;
1278 struct ath10k_wow wow
;
1279 struct ath10k_per_peer_tx_stats peer_tx_stats
;
1282 struct net_device
*napi_dev
;
1283 struct napi_struct napi
;
1285 struct work_struct set_coverage_class_work
;
1286 /* protected by conf_mutex */
1288 /* writing also protected by data_lock */
1292 u32 reg_slottime_conf
;
1293 u32 reg_slottime_orig
;
1294 u32 reg_ack_cts_timeout_conf
;
1295 u32 reg_ack_cts_timeout_orig
;
1298 u32 ampdu_reference
;
1300 const u8
*wmi_key_cipher
;
1303 u32 sta_tid_stats_mask
;
1305 /* protected by data_lock */
1306 enum ath10k_radar_confirmation_state radar_conf_state
;
1307 struct ath10k_radar_found_info last_radar_info
;
1308 struct work_struct radar_confirmation_work
;
1309 struct ath10k_bus_params bus_param
;
1310 struct completion peer_delete_done
;
1315 s32 tx_power_2g_limit
;
1316 s32 tx_power_5g_limit
;
1319 u8 drv_priv
[] __aligned(sizeof(void *));
1322 static inline bool ath10k_peer_stats_enabled(struct ath10k
*ar
)
1324 if (test_bit(ATH10K_FLAG_PEER_STATS
, &ar
->dev_flags
) &&
1325 test_bit(WMI_SERVICE_PEER_STATS
, ar
->wmi
.svc_map
))
1331 extern unsigned int ath10k_frame_mode
;
1332 extern unsigned long ath10k_coredump_mask
;
1334 void ath10k_core_napi_sync_disable(struct ath10k
*ar
);
1335 void ath10k_core_napi_enable(struct ath10k
*ar
);
1336 struct ath10k
*ath10k_core_create(size_t priv_size
, struct device
*dev
,
1337 enum ath10k_bus bus
,
1338 enum ath10k_hw_rev hw_rev
,
1339 const struct ath10k_hif_ops
*hif_ops
);
1340 void ath10k_core_destroy(struct ath10k
*ar
);
1341 void ath10k_core_get_fw_features_str(struct ath10k
*ar
,
1344 int ath10k_core_fetch_firmware_api_n(struct ath10k
*ar
, const char *name
,
1345 struct ath10k_fw_file
*fw_file
);
1347 int ath10k_core_start(struct ath10k
*ar
, enum ath10k_firmware_mode mode
,
1348 const struct ath10k_fw_components
*fw_components
);
1349 int ath10k_wait_for_suspend(struct ath10k
*ar
, u32 suspend_opt
);
1350 void ath10k_core_stop(struct ath10k
*ar
);
1351 void ath10k_core_start_recovery(struct ath10k
*ar
);
1352 int ath10k_core_register(struct ath10k
*ar
,
1353 const struct ath10k_bus_params
*bus_params
);
1354 void ath10k_core_unregister(struct ath10k
*ar
);
1355 int ath10k_core_fetch_board_file(struct ath10k
*ar
, int bd_ie_type
);
1356 int ath10k_core_check_dt(struct ath10k
*ar
);
1357 void ath10k_core_free_board_files(struct ath10k
*ar
);
1359 #endif /* _CORE_H_ */