1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
3 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4 * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
10 #include <linux/types.h>
11 #include <linux/interrupt.h>
12 #include <linux/irq.h>
13 #include <linux/bitfield.h>
14 #include <linux/dmi.h>
15 #include <linux/ctype.h>
16 #include <linux/rhashtable.h>
17 #include <linux/average.h>
18 #include <linux/firmware.h>
36 #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
38 #define ATH11K_TX_MGMT_NUM_PENDING_MAX 512
40 #define ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI 64
42 /* Pending management packets threshold for dropping probe responses */
43 #define ATH11K_PRB_RSP_DROP_THRESHOLD ((ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI * 3) / 4)
45 #define ATH11K_INVALID_HW_MAC_ID 0xFF
46 #define ATH11K_CONNECTION_LOSS_HZ (3 * HZ)
48 /* SMBIOS type containing Board Data File Name Extension */
49 #define ATH11K_SMBIOS_BDF_EXT_TYPE 0xF8
51 /* SMBIOS type structure length (excluding strings-set) */
52 #define ATH11K_SMBIOS_BDF_EXT_LENGTH 0x9
54 /* The magic used by QCA spec */
55 #define ATH11K_SMBIOS_BDF_EXT_MAGIC "BDF_"
57 extern unsigned int ath11k_frame_mode;
58 extern bool ath11k_ftm_mode;
60 #define ATH11K_SCAN_TIMEOUT_HZ (20 * HZ)
62 #define ATH11K_MON_TIMER_INTERVAL 10
63 #define ATH11K_RESET_TIMEOUT_HZ (20 * HZ)
64 #define ATH11K_RESET_MAX_FAIL_COUNT_FIRST 3
65 #define ATH11K_RESET_MAX_FAIL_COUNT_FINAL 5
66 #define ATH11K_RESET_FAIL_TIMEOUT_HZ (20 * HZ)
67 #define ATH11K_RECONFIGURE_TIMEOUT_HZ (10 * HZ)
68 #define ATH11K_RECOVER_START_TIMEOUT_HZ (20 * HZ)
70 enum ath11k_supported_bw {
77 enum ath11k_bdf_search {
78 ATH11K_BDF_SEARCH_DEFAULT,
79 ATH11K_BDF_SEARCH_BUS_AND_BOARD,
90 #define ATH11K_HT_MCS_MAX 7
91 #define ATH11K_VHT_MCS_MAX 9
92 #define ATH11K_HE_MCS_MAX 11
94 enum ath11k_crypt_mode {
95 /* Only use hardware crypto engine */
97 /* Only use software crypto */
101 static inline enum wme_ac ath11k_tid_to_ac(u32 tid)
103 return (((tid == 0) || (tid == 3)) ? WME_AC_BE :
104 ((tid == 1) || (tid == 2)) ? WME_AC_BK :
105 ((tid == 4) || (tid == 5)) ? WME_AC_VI :
109 enum ath11k_skb_flags {
110 ATH11K_SKB_HW_80211_ENCAP = BIT(0),
111 ATH11K_SKB_CIPHER_SET = BIT(1),
114 struct ath11k_skb_cb {
120 struct ieee80211_vif *vif;
123 struct ath11k_skb_rxcb {
127 bool is_continuation;
130 struct hal_rx_desc *rx_desc;
143 ATH11K_HW_QCA6390_HW20,
144 ATH11K_HW_IPQ6018_HW10,
145 ATH11K_HW_QCN9074_HW10,
146 ATH11K_HW_WCN6855_HW20,
147 ATH11K_HW_WCN6855_HW21,
148 ATH11K_HW_WCN6750_HW10,
149 ATH11K_HW_IPQ5018_HW10,
152 enum ath11k_firmware_mode {
153 /* the default mode, standard 802.11 functionality */
154 ATH11K_FIRMWARE_MODE_NORMAL,
156 /* factory tests etc */
157 ATH11K_FIRMWARE_MODE_FTM,
159 /* Cold boot calibration */
160 ATH11K_FIRMWARE_MODE_COLD_BOOT = 7,
163 extern bool ath11k_cold_boot_cal;
165 #define ATH11K_IRQ_NUM_MAX 52
166 #define ATH11K_EXT_IRQ_NUM_MAX 16
168 struct ath11k_ext_irq_grp {
169 struct ath11k_base *ab;
170 u32 irqs[ATH11K_EXT_IRQ_NUM_MAX];
175 struct napi_struct napi;
176 struct net_device napi_ndev;
179 enum ath11k_smbios_cc_type {
180 /* disable country code setting from SMBIOS */
181 ATH11K_SMBIOS_CC_DISABLE = 0,
183 /* set country code by ANSI country name, based on ISO3166-1 alpha2 */
184 ATH11K_SMBIOS_CC_ISO = 1,
186 /* worldwide regdomain */
187 ATH11K_SMBIOS_CC_WW = 2,
190 struct ath11k_smbios_bdf {
191 struct dmi_header hdr;
193 u8 features_disabled;
195 /* enum ath11k_smbios_cc_type */
196 u8 country_code_flag;
198 /* To set specific country, you need to set country code
199 * flag=ATH11K_SMBIOS_CC_ISO first, then if country is United
200 * States, then country code value = 0x5553 ("US",'U' = 0x55, 'S'=
201 * 0x53). To set country to INDONESIA, then country code value =
202 * 0x4944 ("IN", 'I'=0x49, 'D'=0x44). If country code flag =
203 * ATH11K_SMBIOS_CC_WW, then you can use worldwide regulatory
212 #define HEHANDLE_CAP_PHYINFO_SIZE 3
213 #define HECAP_PHYINFO_SIZE 9
214 #define HECAP_MACINFO_SIZE 5
215 #define HECAP_TXRX_MCS_NSS_SIZE 2
216 #define HECAP_PPET16_PPET8_MAX_SIZE 25
218 #define HE_PPET16_PPET8_SIZE 8
220 /* 802.11ax PPE (PPDU packet Extension) threshold */
221 struct he_ppe_threshold {
224 u32 ppet16_ppet8_ru3_ru0[HE_PPET16_PPET8_SIZE];
228 u8 hecap_macinfo[HECAP_MACINFO_SIZE];
229 u32 hecap_rxmcsnssmap;
230 u32 hecap_txmcsnssmap;
231 u32 hecap_phyinfo[HEHANDLE_CAP_PHYINFO_SIZE];
232 struct he_ppe_threshold hecap_ppet;
238 /* ipq5018 hw param macros */
239 #define MAX_RADIOS_5018 1
240 #define CE_CNT_5018 6
241 #define TARGET_CE_CNT_5018 9
242 #define SVC_CE_MAP_LEN_5018 17
243 #define RXDMA_PER_PDEV_5018 1
246 WMI_HOST_TP_SCALE_MAX = 0,
247 WMI_HOST_TP_SCALE_50 = 1,
248 WMI_HOST_TP_SCALE_25 = 2,
249 WMI_HOST_TP_SCALE_12 = 3,
250 WMI_HOST_TP_SCALE_MIN = 4,
251 WMI_HOST_TP_SCALE_SIZE = 5,
254 enum ath11k_scan_state {
256 ATH11K_SCAN_STARTING,
258 ATH11K_SCAN_ABORTING,
261 enum ath11k_11d_state {
263 ATH11K_11D_PREPARING,
267 enum ath11k_dev_flags {
269 ATH11K_FLAG_CORE_REGISTERED,
270 ATH11K_FLAG_CRASH_FLUSH,
271 ATH11K_FLAG_RAW_MODE,
272 ATH11K_FLAG_HW_CRYPTO_DISABLED,
274 ATH11K_FLAG_RECOVERY,
275 ATH11K_FLAG_UNREGISTERING,
276 ATH11K_FLAG_REGISTERED,
277 ATH11K_FLAG_QMI_FAIL,
278 ATH11K_FLAG_HTC_SUSPEND_COMPLETE,
279 ATH11K_FLAG_CE_IRQ_ENABLED,
280 ATH11K_FLAG_EXT_IRQ_ENABLED,
281 ATH11K_FLAG_FIXED_MEM_RGN,
282 ATH11K_FLAG_DEVICE_INIT_DONE,
283 ATH11K_FLAG_MULTI_MSI_VECTORS,
284 ATH11K_FLAG_FTM_SEGMENTED,
287 enum ath11k_monitor_flags {
288 ATH11K_FLAG_MONITOR_CONF_ENABLED,
289 ATH11K_FLAG_MONITOR_STARTED,
290 ATH11K_FLAG_MONITOR_VDEV_CREATED,
293 #define ATH11K_IPV6_UC_TYPE 0
294 #define ATH11K_IPV6_AC_TYPE 1
296 #define ATH11K_IPV6_MAX_COUNT 16
297 #define ATH11K_IPV4_MAX_COUNT 2
299 struct ath11k_arp_ns_offload {
300 u8 ipv4_addr[ATH11K_IPV4_MAX_COUNT][4];
303 u8 ipv6_addr[ATH11K_IPV6_MAX_COUNT][16];
304 u8 self_ipv6_addr[ATH11K_IPV6_MAX_COUNT][16];
305 u8 ipv6_type[ATH11K_IPV6_MAX_COUNT];
306 bool ipv6_valid[ATH11K_IPV6_MAX_COUNT];
307 u8 mac_addr[ETH_ALEN];
310 struct ath11k_rekey_data {
311 u8 kck[NL80211_KCK_LEN];
312 u8 kek[NL80211_KCK_LEN];
319 enum wmi_vdev_type vdev_type;
320 enum wmi_vdev_subtype vdev_subtype;
326 u8 hal_addr_search_flags;
330 struct ieee80211_vif *vif;
333 struct wmi_wmm_params_all_arg wmm_params;
334 struct list_head list;
340 /* 127 stations; wmi limit */
344 u8 ssid[IEEE80211_MAX_SSID_LEN];
346 /* P2P_IE with NoA attribute for P2P_GO case */
355 bool spectral_enabled;
359 struct cfg80211_bitrate_mask bitrate_mask;
360 struct delayed_work connection_loss_work;
361 int num_legacy_stations;
362 int rtscts_prot_mode;
367 bool do_not_send_tmpl;
368 struct ieee80211_chanctx_conf chanctx;
369 struct ath11k_arp_ns_offload arp_ns_offload;
370 struct ath11k_rekey_data rekey_data;
373 struct ath11k_vif_iter {
375 struct ath11k_vif *arvif;
378 struct ath11k_rx_peer_stats {
381 u64 num_mpdu_fcs_err;
384 u64 other_msdu_count;
385 u64 ampdu_msdu_count;
386 u64 non_ampdu_msdu_count;
388 u64 beamformed_count;
389 u64 mcs_count[HAL_RX_MAX_MCS + 1];
390 u64 nss_count[HAL_RX_MAX_NSS];
391 u64 bw_count[HAL_RX_BW_MAX];
392 u64 gi_count[HAL_RX_GI_MAX];
393 u64 coding_count[HAL_RX_SU_MU_CODING_MAX];
394 u64 tid_count[IEEE80211_NUM_TIDS + 1];
395 u64 pream_cnt[HAL_RX_PREAMBLE_MAX];
396 u64 reception_type[HAL_RX_RECEPTION_TYPE_MAX];
399 u64 ru_alloc_cnt[HAL_RX_RU_ALLOC_TYPE_MAX];
402 #define ATH11K_HE_MCS_NUM 12
403 #define ATH11K_VHT_MCS_NUM 10
404 #define ATH11K_BW_NUM 4
405 #define ATH11K_NSS_NUM 4
406 #define ATH11K_LEGACY_NUM 12
407 #define ATH11K_GI_NUM 4
408 #define ATH11K_HT_MCS_NUM 32
410 enum ath11k_pkt_rx_err {
411 ATH11K_PKT_RX_ERR_FCS,
412 ATH11K_PKT_RX_ERR_TKIP,
413 ATH11K_PKT_RX_ERR_CRYPT,
414 ATH11K_PKT_RX_ERR_PEER_IDX_INVAL,
415 ATH11K_PKT_RX_ERR_MAX,
418 enum ath11k_ampdu_subfrm_num {
419 ATH11K_AMPDU_SUBFRM_NUM_10,
420 ATH11K_AMPDU_SUBFRM_NUM_20,
421 ATH11K_AMPDU_SUBFRM_NUM_30,
422 ATH11K_AMPDU_SUBFRM_NUM_40,
423 ATH11K_AMPDU_SUBFRM_NUM_50,
424 ATH11K_AMPDU_SUBFRM_NUM_60,
425 ATH11K_AMPDU_SUBFRM_NUM_MORE,
426 ATH11K_AMPDU_SUBFRM_NUM_MAX,
429 enum ath11k_amsdu_subfrm_num {
430 ATH11K_AMSDU_SUBFRM_NUM_1,
431 ATH11K_AMSDU_SUBFRM_NUM_2,
432 ATH11K_AMSDU_SUBFRM_NUM_3,
433 ATH11K_AMSDU_SUBFRM_NUM_4,
434 ATH11K_AMSDU_SUBFRM_NUM_MORE,
435 ATH11K_AMSDU_SUBFRM_NUM_MAX,
438 enum ath11k_counter_type {
439 ATH11K_COUNTER_TYPE_BYTES,
440 ATH11K_COUNTER_TYPE_PKTS,
441 ATH11K_COUNTER_TYPE_MAX,
444 enum ath11k_stats_type {
445 ATH11K_STATS_TYPE_SUCC,
446 ATH11K_STATS_TYPE_FAIL,
447 ATH11K_STATS_TYPE_RETRY,
448 ATH11K_STATS_TYPE_AMPDU,
449 ATH11K_STATS_TYPE_MAX,
452 struct ath11k_htt_data_stats {
453 u64 legacy[ATH11K_COUNTER_TYPE_MAX][ATH11K_LEGACY_NUM];
454 u64 ht[ATH11K_COUNTER_TYPE_MAX][ATH11K_HT_MCS_NUM];
455 u64 vht[ATH11K_COUNTER_TYPE_MAX][ATH11K_VHT_MCS_NUM];
456 u64 he[ATH11K_COUNTER_TYPE_MAX][ATH11K_HE_MCS_NUM];
457 u64 bw[ATH11K_COUNTER_TYPE_MAX][ATH11K_BW_NUM];
458 u64 nss[ATH11K_COUNTER_TYPE_MAX][ATH11K_NSS_NUM];
459 u64 gi[ATH11K_COUNTER_TYPE_MAX][ATH11K_GI_NUM];
462 struct ath11k_htt_tx_stats {
463 struct ath11k_htt_data_stats stats[ATH11K_STATS_TYPE_MAX];
469 struct ath11k_per_ppdu_tx_stats {
478 DECLARE_EWMA(avg_rssi, 10, 8)
481 struct ath11k_vif *arvif;
483 /* the following are protected by ar->data_lock */
484 u32 changed; /* IEEE80211_RC_* */
488 enum hal_pn_type pn_type;
490 struct work_struct update_wk;
491 struct work_struct set_4addr_wk;
492 struct rate_info txrate;
494 struct rate_info last_txrate;
498 struct ewma_avg_rssi avg_rssi;
500 s8 chain_signal[IEEE80211_MAX_CHAINS];
501 struct ath11k_htt_tx_stats *tx_stats;
502 struct ath11k_rx_peer_stats *rx_stats;
504 #ifdef CONFIG_MAC80211_DEBUGFS
505 /* protected by conf_mutex */
512 /* Protected with ar->data_lock */
513 enum ath11k_wmi_peer_ps_state peer_ps_state;
515 u64 ps_start_jiffies;
516 u64 ps_total_duration;
517 bool peer_current_ps_valid;
522 #define ATH11K_MIN_5G_FREQ 4150
523 #define ATH11K_MIN_6G_FREQ 5925
524 #define ATH11K_MAX_6G_FREQ 7115
525 #define ATH11K_NUM_CHANS 102
526 #define ATH11K_MAX_5G_CHAN 177
531 ATH11K_STATE_RESTARTING,
532 ATH11K_STATE_RESTARTED,
535 /* Add other states as required */
538 /* Antenna noise floor */
539 #define ATH11K_DEFAULT_NOISE_FLOOR -95
541 #define ATH11K_INVALID_RSSI_FULL -1
543 #define ATH11K_INVALID_RSSI_EMPTY -128
545 struct ath11k_fw_stats {
546 struct dentry *debugfs_fwstats;
549 struct list_head pdevs;
550 struct list_head vdevs;
551 struct list_head bcn;
554 struct ath11k_dbg_htt_stats {
557 struct debug_htt_stats_req *stats_req;
558 /* protects shared stats req buffer */
562 #define MAX_MODULE_ID_BITMAP_WORDS 16
564 struct ath11k_debug {
565 struct dentry *debugfs_pdev;
566 struct ath11k_dbg_htt_stats htt_stats;
571 u32 pktlog_peer_valid;
572 u8 pktlog_peer_addr[ETH_ALEN];
575 u32 module_id_bitmap[MAX_MODULE_ID_BITMAP_WORDS];
576 struct ath11k_debug_dbr *dbr_debug[WMI_DIRECT_BUF_MAX];
579 struct ath11k_per_peer_tx_stats {
591 #define ATH11K_FLUSH_TIMEOUT (5 * HZ)
592 #define ATH11K_VDEV_DELETE_TIMEOUT_HZ (5 * HZ)
595 struct ath11k_base *ab;
596 struct ath11k_pdev *pdev;
597 struct ieee80211_hw *hw;
598 struct ath11k_pdev_wmi *wmi;
599 struct ath11k_pdev_dp dp;
600 u8 mac_addr[ETH_ALEN];
601 struct ath11k_he ar_he;
602 enum ath11k_state state;
605 struct completion started;
606 struct completion completed;
607 struct completion on_channel;
608 struct delayed_work timeout;
609 enum ath11k_scan_state state;
617 struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
618 struct ieee80211_sband_iftype_data
619 iftype[NUM_NL80211_BANDS][NUM_NL80211_IFTYPES];
622 unsigned long dev_flags;
623 unsigned int filter_flags;
624 unsigned long monitor_flags;
627 u32 txpower_limit_2g;
628 u32 txpower_limit_5g;
633 u32 max_num_stations;
634 /* To synchronize concurrent synchronous mac80211 callback operations,
635 * concurrent debugfs configuration and concurrent FW statistics events.
637 struct mutex conf_mutex;
638 /* protects the radio specific data like debug stats, ppdu_stats_info stats,
639 * vdev_stop_status info, scan data, ath11k_sta info, ath11k_vif info,
640 * channel context data, survey info, test mode data.
642 spinlock_t data_lock;
644 struct list_head arvifs;
645 /* should never be NULL; needed for regular htt rx */
646 struct ieee80211_channel *rx_channel;
648 /* valid during scan; needed for mgmt rx during scan */
649 struct ieee80211_channel *scan_channel;
655 /* pdev_idx starts from 0 whereas pdev->pdev_id starts with 1 */
659 struct completion peer_assoc_done;
660 struct completion peer_delete_done;
662 int install_key_status;
663 struct completion install_key_done;
665 int last_wmi_vdev_start_status;
666 struct completion vdev_setup_done;
667 struct completion vdev_delete_done;
671 u32 num_started_vdevs;
672 u32 num_created_vdevs;
673 unsigned long long allocated_vdev_map;
675 struct idr txmgmt_idr;
676 /* protects txmgmt_idr data */
677 spinlock_t txmgmt_idr_lock;
678 atomic_t num_pending_mgmt_tx;
679 wait_queue_head_t txmgmt_empty_waitq;
681 /* cycle count is reported twice for each visited channel during scan.
682 * access protected by data_lock
684 u32 survey_last_rx_clear_count;
685 u32 survey_last_cycle_count;
687 /* Channel info events are expected to come in pairs without and with
688 * COMPLETE flag set respectively for each channel visit during scan.
690 * However there are deviations from this rule. This flag is used to
691 * avoid reporting garbage data.
693 bool ch_info_can_report_survey;
694 struct survey_info survey[ATH11K_NUM_CHANS];
695 struct completion bss_survey_done;
697 struct work_struct regd_update_work;
699 struct work_struct wmi_mgmt_tx_work;
700 struct sk_buff_head wmi_mgmt_tx_queue;
702 struct ath11k_wow wow;
703 struct completion target_suspend;
704 bool target_suspend_ack;
705 struct ath11k_per_peer_tx_stats peer_tx_stats;
706 struct list_head ppdu_stats_info;
707 u32 ppdu_stat_list_depth;
709 struct ath11k_per_peer_tx_stats cached_stats;
713 struct completion fw_mode_reset;
715 #ifdef CONFIG_ATH11K_DEBUGFS
716 struct ath11k_debug debug;
718 #ifdef CONFIG_ATH11K_SPECTRAL
719 struct ath11k_spectral spectral;
721 bool dfs_block_radar_events;
722 struct ath11k_thermal thermal;
723 u32 vdev_id_11d_scan;
724 struct completion completed_11d_scan;
725 enum ath11k_11d_state state_11d;
726 bool regdom_set_by_user;
730 u8 alpha2[REG_ALPHA2_LEN + 1];
731 struct ath11k_fw_stats fw_stats;
732 struct completion fw_stats_complete;
735 /* protected by conf_mutex */
736 bool ps_state_enable;
737 bool ps_timekeeper_enable;
740 struct ath11k_band_cap {
742 u32 max_bw_supported;
746 u32 he_cap_phy_info[PSOC_HOST_MAX_PHY_SIZE];
747 struct ath11k_ppe_threshold he_ppet;
751 struct ath11k_pdev_cap {
759 u32 tx_chain_mask_shift;
760 u32 rx_chain_mask_shift;
761 struct ath11k_band_cap band[NUM_NL80211_BANDS];
762 bool nss_ratio_enabled;
769 struct ath11k_pdev_cap cap;
770 u8 mac_addr[ETH_ALEN];
773 struct ath11k_board_data {
774 const struct firmware *fw;
779 struct ath11k_pci_ops {
780 int (*wakeup)(struct ath11k_base *ab);
781 void (*release)(struct ath11k_base *ab);
782 int (*get_msi_irq)(struct ath11k_base *ab, unsigned int vector);
783 void (*window_write32)(struct ath11k_base *ab, u32 offset, u32 value);
784 u32 (*window_read32)(struct ath11k_base *ab, u32 offset);
787 /* IPQ8074 HW channel counters frequency value in hertz */
788 #define IPQ8074_CC_FREQ_HERTZ 320000
790 struct ath11k_bp_stats {
791 /* Head Pointer reported by the last HTT Backpressure event for the ring */
794 /* Tail Pointer reported by the last HTT Backpressure event for the ring */
797 /* Number of Backpressure events received for the ring */
800 /* Last recorded event timestamp */
801 unsigned long jiffies;
804 struct ath11k_dp_ring_bp_stats {
805 struct ath11k_bp_stats umac_ring_bp_stats[HTT_SW_UMAC_RING_IDX_MAX];
806 struct ath11k_bp_stats lmac_ring_bp_stats[HTT_SW_LMAC_RING_IDX_MAX][MAX_RADIOS];
809 struct ath11k_soc_dp_tx_err_stats {
810 /* TCL Ring Descriptor unavailable */
811 u32 desc_na[DP_TCL_NUM_RING_MAX];
812 /* Other failures during dp_tx due to mem allocation failure
813 * idr unavailable etc.
818 struct ath11k_soc_dp_stats {
821 u32 rxdma_error[HAL_REO_ENTR_RING_RXDMA_ECODE_MAX];
822 u32 reo_error[HAL_REO_DEST_RING_ERROR_CODE_MAX];
823 u32 hal_reo_error[DP_REO_DST_RING_MAX];
824 struct ath11k_soc_dp_tx_err_stats tx_err;
825 struct ath11k_dp_ring_bp_stats bp_stats;
828 struct ath11k_msi_user {
834 struct ath11k_msi_config {
837 struct ath11k_msi_user *users;
841 /* Master structure to hold the hw data which may be used in core module */
843 enum ath11k_hw_rev hw_rev;
844 enum ath11k_firmware_mode fw_mode;
845 struct platform_device *pdev;
847 struct ath11k_qmi qmi;
848 struct ath11k_wmi_base wmi_ab;
849 struct completion fw_ready;
851 /* HW channel counters frequency value in hertz common to all MACs */
854 struct ath11k_htc htc;
859 void __iomem *mem_ce;
860 unsigned long mem_len;
864 const struct ath11k_hif_ops *ops;
868 struct completion wakeup_completed;
872 struct timer_list rx_replenish_retry;
873 struct ath11k_hal hal;
874 /* To synchronize core_start/core_stop */
875 struct mutex core_lock;
876 /* Protects data like peers */
877 spinlock_t base_lock;
878 struct ath11k_pdev pdevs[MAX_RADIOS];
880 enum WMI_HOST_WLAN_BAND supported_bands;
882 } target_pdev_ids[MAX_RADIOS];
883 u8 target_pdev_count;
884 struct ath11k_pdev __rcu *pdevs_active[MAX_RADIOS];
885 struct ath11k_hal_reg_capabilities_ext hal_reg_cap[MAX_RADIOS];
886 unsigned long long free_vdev_map;
888 /* To synchronize rhash tbl write operation */
889 struct mutex tbl_mtx_lock;
891 /* The rhashtable containing struct ath11k_peer keyed by mac addr */
892 struct rhashtable *rhead_peer_addr;
893 struct rhashtable_params rhash_peer_addr_param;
895 /* The rhashtable containing struct ath11k_peer keyed by id */
896 struct rhashtable *rhead_peer_id;
897 struct rhashtable_params rhash_peer_id_param;
899 struct list_head peers;
900 wait_queue_head_t peer_mapping_wq;
901 u8 mac_addr[ETH_ALEN];
902 int irq_num[ATH11K_IRQ_NUM_MAX];
903 struct ath11k_ext_irq_grp ext_irq_grp[ATH11K_EXT_IRQ_GRP_NUM_MAX];
904 struct ath11k_targ_cap target_caps;
905 u32 ext_service_bitmap[WMI_SERVICE_EXT_BM_SIZE];
906 bool pdevs_macaddr_valid;
908 struct ath11k_hw_params hw_params;
910 const struct firmware *cal_file;
912 /* Below regd's are protected by ab->data_lock */
913 /* This is the regd set for every radio
914 * by the firmware during initialization
916 struct ieee80211_regdomain *default_regd[MAX_RADIOS];
917 /* This regd is set during dynamic country setting
918 * This may or may not be used during the runtime
920 struct ieee80211_regdomain *new_regd[MAX_RADIOS];
921 struct cur_regulatory_info *reg_info_store;
923 /* Current DFS Regulatory */
924 enum ath11k_dfs_region dfs_region;
925 #ifdef CONFIG_ATH11K_DEBUGFS
926 struct dentry *debugfs_soc;
928 struct ath11k_soc_dp_stats soc_stats;
930 unsigned long dev_flags;
931 struct completion driver_recovery;
932 struct workqueue_struct *workqueue;
933 struct work_struct restart_work;
934 struct work_struct update_11d_work;
936 struct workqueue_struct *workqueue_aux;
937 struct work_struct reset_work;
938 atomic_t reset_count;
939 atomic_t recovery_count;
940 atomic_t recovery_start_count;
942 struct completion reset_complete;
943 struct completion reconfigure_complete;
944 struct completion recovery_start;
945 /* continuous recovery fail count */
946 atomic_t fail_cont_count;
947 unsigned long reset_fail_timeout;
949 /* protected by data_lock */
950 u32 fw_crash_counter;
952 u32 pktlog_defs_checksum;
954 struct ath11k_dbring_cap *db_caps;
957 /* To synchronize 11d scan vdev id */
958 struct mutex vdev_id_11d_lock;
959 struct timer_list mon_reap_timer;
961 struct completion htc_suspend;
964 enum ath11k_bdf_search bdf_search;
967 u32 subsystem_vendor;
968 u32 subsystem_device;
973 const struct ath11k_msi_config *config;
980 const struct ath11k_pci_ops *ops;
986 const struct firmware *fw;
992 DECLARE_BITMAP(fw_features, ATH11K_FW_FEATURE_COUNT);
995 #ifdef CONFIG_NL80211_TESTMODE
1004 u8 drv_priv[] __aligned(sizeof(void *));
1007 struct ath11k_fw_stats_pdev {
1008 struct list_head list;
1012 /* Cycles spent transmitting frames */
1014 /* Cycles spent receiving frames */
1016 /* Total channel busy time, evidently */
1018 /* Total on-channel time */
1030 /* Num HTT cookies queued to dispatch list */
1032 /* Num HTT cookies dispatched */
1034 /* Num MSDU queued to WAL */
1036 /* Num MPDU queue to WAL */
1038 /* Num MSDUs dropped by WMM limit */
1040 /* Num Local frames queued */
1042 /* Num Local frames done */
1044 /* Num queued to HW */
1046 /* Num PPDU reaped from HW */
1052 /* Num PPDUs cleaned up in TX abort */
1054 /* Num MPDUs requeued by SW */
1056 /* excessive retries */
1059 /* data hw rate code */
1061 /* Scheduler self triggers */
1063 /* frames dropped due to excessive sw retries */
1064 u32 sw_retry_failure;
1065 /* illegal rate phy errors */
1066 u32 illgl_rate_phy_err;
1067 /* wal pdev continuous xretry */
1068 u32 pdev_cont_xretry;
1069 /* wal pdev tx timeouts */
1070 u32 pdev_tx_timeout;
1071 /* wal pdev resets */
1073 /* frames dropped due to non-availability of stateless TIDs */
1074 u32 stateless_tid_alloc_failure;
1075 /* PhY/BB underrun */
1077 /* MPDU is more than txop limit */
1079 /* Num sequences posted */
1081 /* Num sequences failed in queueing */
1082 u32 seq_failed_queueing;
1083 /* Num sequences completed */
1085 /* Num sequences restarted */
1087 /* Num of MU sequences posted */
1089 /* Num MPDUs flushed by SW, HWPAUSED, SW TXABORT
1090 * (Reset,channel change)
1093 /* Num MPDUs filtered by HW, all filter condition (TTL expired) */
1094 s32 mpdus_hw_filter;
1095 /* Num MPDUs truncated by PDG (TXOP, TBTT,
1096 * PPDU_duration based on rate, dyn_bw)
1098 s32 mpdus_truncated;
1099 /* Num MPDUs that was tried but didn't receive ACK or BA */
1100 s32 mpdus_ack_failed;
1101 /* Num MPDUs that was dropped du to expiry. */
1105 /* Cnts any change in ring routing mid-ppdu */
1106 s32 mid_ppdu_route_change;
1107 /* Total number of statuses processed */
1109 /* Extra frags on rings 0-3 */
1114 /* MSDUs / MPDUs delivered to HTT */
1117 /* MSDUs / MPDUs delivered to local stack */
1120 /* AMSDUs that have more MSDUs than the status ring size */
1122 /* Number of PHY errors */
1124 /* Number of PHY errors drops */
1126 /* Number of mpdu errors - FCS, MIC, ENC etc. */
1128 /* Num overflow errors */
1132 struct ath11k_fw_stats_vdev {
1133 struct list_head list;
1138 u32 num_tx_frames[WLAN_MAX_AC];
1140 u32 num_tx_frames_retries[WLAN_MAX_AC];
1141 u32 num_tx_frames_failures[WLAN_MAX_AC];
1143 u32 num_rts_success;
1146 u32 num_tx_not_acked;
1147 u32 tx_rate_history[MAX_TX_RATE_VALUES];
1148 u32 beacon_rssi_history[MAX_TX_RATE_VALUES];
1151 struct ath11k_fw_stats_bcn {
1152 struct list_head list;
1155 u32 tx_bcn_succ_cnt;
1156 u32 tx_bcn_outage_cnt;
1159 void ath11k_fw_stats_init(struct ath11k *ar);
1160 void ath11k_fw_stats_pdevs_free(struct list_head *head);
1161 void ath11k_fw_stats_vdevs_free(struct list_head *head);
1162 void ath11k_fw_stats_bcn_free(struct list_head *head);
1163 void ath11k_fw_stats_free(struct ath11k_fw_stats *stats);
1165 extern const struct ce_pipe_config ath11k_target_ce_config_wlan_ipq8074[];
1166 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq8074[];
1167 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq6018[];
1169 extern const struct ce_pipe_config ath11k_target_ce_config_wlan_qca6390[];
1170 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_qca6390[];
1172 extern const struct ce_pipe_config ath11k_target_ce_config_wlan_ipq5018[];
1173 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq5018[];
1175 extern const struct ce_pipe_config ath11k_target_ce_config_wlan_qcn9074[];
1176 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_qcn9074[];
1177 int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab);
1178 int ath11k_core_pre_init(struct ath11k_base *ab);
1179 int ath11k_core_init(struct ath11k_base *ath11k);
1180 void ath11k_core_deinit(struct ath11k_base *ath11k);
1181 struct ath11k_base *ath11k_core_alloc(struct device *dev, size_t priv_size,
1182 enum ath11k_bus bus);
1183 void ath11k_core_free(struct ath11k_base *ath11k);
1184 int ath11k_core_fetch_bdf(struct ath11k_base *ath11k,
1185 struct ath11k_board_data *bd);
1186 int ath11k_core_fetch_regdb(struct ath11k_base *ab, struct ath11k_board_data *bd);
1187 int ath11k_core_fetch_board_data_api_1(struct ath11k_base *ab,
1188 struct ath11k_board_data *bd,
1190 void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd);
1191 int ath11k_core_check_dt(struct ath11k_base *ath11k);
1192 int ath11k_core_check_smbios(struct ath11k_base *ab);
1193 void ath11k_core_halt(struct ath11k *ar);
1194 int ath11k_core_resume(struct ath11k_base *ab);
1195 int ath11k_core_suspend(struct ath11k_base *ab);
1196 void ath11k_core_pre_reconfigure_recovery(struct ath11k_base *ab);
1197 bool ath11k_core_coldboot_cal_support(struct ath11k_base *ab);
1199 const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab,
1200 const char *filename);
1202 static inline const char *ath11k_scan_state_str(enum ath11k_scan_state state)
1205 case ATH11K_SCAN_IDLE:
1207 case ATH11K_SCAN_STARTING:
1209 case ATH11K_SCAN_RUNNING:
1211 case ATH11K_SCAN_ABORTING:
1218 static inline struct ath11k_skb_cb *ATH11K_SKB_CB(struct sk_buff *skb)
1220 BUILD_BUG_ON(sizeof(struct ath11k_skb_cb) >
1221 IEEE80211_TX_INFO_DRIVER_DATA_SIZE);
1222 return (struct ath11k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
1225 static inline struct ath11k_skb_rxcb *ATH11K_SKB_RXCB(struct sk_buff *skb)
1227 BUILD_BUG_ON(sizeof(struct ath11k_skb_rxcb) > sizeof(skb->cb));
1228 return (struct ath11k_skb_rxcb *)skb->cb;
1231 static inline struct ath11k_vif *ath11k_vif_to_arvif(struct ieee80211_vif *vif)
1233 return (struct ath11k_vif *)vif->drv_priv;
1236 static inline struct ath11k_sta *ath11k_sta_to_arsta(struct ieee80211_sta *sta)
1238 return (struct ath11k_sta *)sta->drv_priv;
1241 static inline struct ath11k *ath11k_ab_to_ar(struct ath11k_base *ab,
1244 return ab->pdevs[ath11k_hw_mac_id_to_pdev_id(&ab->hw_params, mac_id)].ar;
1247 static inline void ath11k_core_create_firmware_path(struct ath11k_base *ab,
1248 const char *filename,
1249 void *buf, size_t buf_len)
1251 snprintf(buf, buf_len, "%s/%s/%s", ATH11K_FW_DIR,
1252 ab->hw_params.fw.dir, filename);
1255 static inline const char *ath11k_bus_str(enum ath11k_bus bus)
1258 case ATH11K_BUS_PCI:
1260 case ATH11K_BUS_AHB:
1267 #endif /* _CORE_H_ */