1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
3 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4 * Copyright (c) 2021-2022 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>
32 #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
34 #define ATH11K_TX_MGMT_NUM_PENDING_MAX 512
36 #define ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI 64
38 /* Pending management packets threshold for dropping probe responses */
39 #define ATH11K_PRB_RSP_DROP_THRESHOLD ((ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI * 3) / 4)
41 #define ATH11K_INVALID_HW_MAC_ID 0xFF
42 #define ATH11K_CONNECTION_LOSS_HZ (3 * HZ)
44 /* SMBIOS type containing Board Data File Name Extension */
45 #define ATH11K_SMBIOS_BDF_EXT_TYPE 0xF8
47 /* SMBIOS type structure length (excluding strings-set) */
48 #define ATH11K_SMBIOS_BDF_EXT_LENGTH 0x9
50 /* The magic used by QCA spec */
51 #define ATH11K_SMBIOS_BDF_EXT_MAGIC "BDF_"
53 extern unsigned int ath11k_frame_mode;
55 #define ATH11K_SCAN_TIMEOUT_HZ (20 * HZ)
57 #define ATH11K_MON_TIMER_INTERVAL 10
58 #define ATH11K_RESET_TIMEOUT_HZ (20 * HZ)
59 #define ATH11K_RESET_MAX_FAIL_COUNT_FIRST 3
60 #define ATH11K_RESET_MAX_FAIL_COUNT_FINAL 5
61 #define ATH11K_RESET_FAIL_TIMEOUT_HZ (20 * HZ)
62 #define ATH11K_RECONFIGURE_TIMEOUT_HZ (10 * HZ)
63 #define ATH11K_RECOVER_START_TIMEOUT_HZ (20 * HZ)
65 enum ath11k_supported_bw {
72 enum ath11k_bdf_search {
73 ATH11K_BDF_SEARCH_DEFAULT,
74 ATH11K_BDF_SEARCH_BUS_AND_BOARD,
85 #define ATH11K_HT_MCS_MAX 7
86 #define ATH11K_VHT_MCS_MAX 9
87 #define ATH11K_HE_MCS_MAX 11
89 enum ath11k_crypt_mode {
90 /* Only use hardware crypto engine */
92 /* Only use software crypto */
96 static inline enum wme_ac ath11k_tid_to_ac(u32 tid)
98 return (((tid == 0) || (tid == 3)) ? WME_AC_BE :
99 ((tid == 1) || (tid == 2)) ? WME_AC_BK :
100 ((tid == 4) || (tid == 5)) ? WME_AC_VI :
104 enum ath11k_skb_flags {
105 ATH11K_SKB_HW_80211_ENCAP = BIT(0),
106 ATH11K_SKB_CIPHER_SET = BIT(1),
109 struct ath11k_skb_cb {
115 struct ieee80211_vif *vif;
118 struct ath11k_skb_rxcb {
122 bool is_continuation;
125 struct hal_rx_desc *rx_desc;
138 ATH11K_HW_QCA6390_HW20,
139 ATH11K_HW_IPQ6018_HW10,
140 ATH11K_HW_QCN9074_HW10,
141 ATH11K_HW_WCN6855_HW20,
142 ATH11K_HW_WCN6855_HW21,
143 ATH11K_HW_WCN6750_HW10,
146 enum ath11k_firmware_mode {
147 /* the default mode, standard 802.11 functionality */
148 ATH11K_FIRMWARE_MODE_NORMAL,
150 /* factory tests etc */
151 ATH11K_FIRMWARE_MODE_FTM,
153 /* Cold boot calibration */
154 ATH11K_FIRMWARE_MODE_COLD_BOOT = 7,
157 extern bool ath11k_cold_boot_cal;
159 #define ATH11K_IRQ_NUM_MAX 52
160 #define ATH11K_EXT_IRQ_NUM_MAX 16
162 struct ath11k_ext_irq_grp {
163 struct ath11k_base *ab;
164 u32 irqs[ATH11K_EXT_IRQ_NUM_MAX];
169 struct napi_struct napi;
170 struct net_device napi_ndev;
173 enum ath11k_smbios_cc_type {
174 /* disable country code setting from SMBIOS */
175 ATH11K_SMBIOS_CC_DISABLE = 0,
177 /* set country code by ANSI country name, based on ISO3166-1 alpha2 */
178 ATH11K_SMBIOS_CC_ISO = 1,
180 /* worldwide regdomain */
181 ATH11K_SMBIOS_CC_WW = 2,
184 struct ath11k_smbios_bdf {
185 struct dmi_header hdr;
187 u8 features_disabled;
189 /* enum ath11k_smbios_cc_type */
190 u8 country_code_flag;
192 /* To set specific country, you need to set country code
193 * flag=ATH11K_SMBIOS_CC_ISO first, then if country is United
194 * States, then country code value = 0x5553 ("US",'U' = 0x55, 'S'=
195 * 0x53). To set country to INDONESIA, then country code value =
196 * 0x4944 ("IN", 'I'=0x49, 'D'=0x44). If country code flag =
197 * ATH11K_SMBIOS_CC_WW, then you can use worldwide regulatory
206 #define HEHANDLE_CAP_PHYINFO_SIZE 3
207 #define HECAP_PHYINFO_SIZE 9
208 #define HECAP_MACINFO_SIZE 5
209 #define HECAP_TXRX_MCS_NSS_SIZE 2
210 #define HECAP_PPET16_PPET8_MAX_SIZE 25
212 #define HE_PPET16_PPET8_SIZE 8
214 /* 802.11ax PPE (PPDU packet Extension) threshold */
215 struct he_ppe_threshold {
218 u32 ppet16_ppet8_ru3_ru0[HE_PPET16_PPET8_SIZE];
222 u8 hecap_macinfo[HECAP_MACINFO_SIZE];
223 u32 hecap_rxmcsnssmap;
224 u32 hecap_txmcsnssmap;
225 u32 hecap_phyinfo[HEHANDLE_CAP_PHYINFO_SIZE];
226 struct he_ppe_threshold hecap_ppet;
233 WMI_HOST_TP_SCALE_MAX = 0,
234 WMI_HOST_TP_SCALE_50 = 1,
235 WMI_HOST_TP_SCALE_25 = 2,
236 WMI_HOST_TP_SCALE_12 = 3,
237 WMI_HOST_TP_SCALE_MIN = 4,
238 WMI_HOST_TP_SCALE_SIZE = 5,
241 enum ath11k_scan_state {
243 ATH11K_SCAN_STARTING,
245 ATH11K_SCAN_ABORTING,
248 enum ath11k_11d_state {
250 ATH11K_11D_PREPARING,
254 enum ath11k_dev_flags {
256 ATH11K_FLAG_CORE_REGISTERED,
257 ATH11K_FLAG_CRASH_FLUSH,
258 ATH11K_FLAG_RAW_MODE,
259 ATH11K_FLAG_HW_CRYPTO_DISABLED,
261 ATH11K_FLAG_RECOVERY,
262 ATH11K_FLAG_UNREGISTERING,
263 ATH11K_FLAG_REGISTERED,
264 ATH11K_FLAG_QMI_FAIL,
265 ATH11K_FLAG_HTC_SUSPEND_COMPLETE,
266 ATH11K_FLAG_CE_IRQ_ENABLED,
267 ATH11K_FLAG_EXT_IRQ_ENABLED,
268 ATH11K_FLAG_FIXED_MEM_RGN,
269 ATH11K_FLAG_DEVICE_INIT_DONE,
270 ATH11K_FLAG_MULTI_MSI_VECTORS,
273 enum ath11k_monitor_flags {
274 ATH11K_FLAG_MONITOR_CONF_ENABLED,
275 ATH11K_FLAG_MONITOR_STARTED,
276 ATH11K_FLAG_MONITOR_VDEV_CREATED,
279 #define ATH11K_IPV6_UC_TYPE 0
280 #define ATH11K_IPV6_AC_TYPE 1
282 #define ATH11K_IPV6_MAX_COUNT 16
283 #define ATH11K_IPV4_MAX_COUNT 2
285 struct ath11k_arp_ns_offload {
286 u8 ipv4_addr[ATH11K_IPV4_MAX_COUNT][4];
289 u8 ipv6_addr[ATH11K_IPV6_MAX_COUNT][16];
290 u8 self_ipv6_addr[ATH11K_IPV6_MAX_COUNT][16];
291 u8 ipv6_type[ATH11K_IPV6_MAX_COUNT];
292 bool ipv6_valid[ATH11K_IPV6_MAX_COUNT];
293 u8 mac_addr[ETH_ALEN];
296 struct ath11k_rekey_data {
297 u8 kck[NL80211_KCK_LEN];
298 u8 kek[NL80211_KCK_LEN];
305 enum wmi_vdev_type vdev_type;
306 enum wmi_vdev_subtype vdev_subtype;
312 u8 hal_addr_search_flags;
316 struct ieee80211_vif *vif;
319 struct wmi_wmm_params_all_arg wmm_params;
320 struct list_head list;
326 /* 127 stations; wmi limit */
330 u8 ssid[IEEE80211_MAX_SSID_LEN];
332 /* P2P_IE with NoA attribute for P2P_GO case */
340 bool spectral_enabled;
344 struct cfg80211_bitrate_mask bitrate_mask;
345 struct delayed_work connection_loss_work;
346 int num_legacy_stations;
347 int rtscts_prot_mode;
352 bool do_not_send_tmpl;
353 struct ieee80211_chanctx_conf chanctx;
354 struct ath11k_arp_ns_offload arp_ns_offload;
355 struct ath11k_rekey_data rekey_data;
357 #ifdef CONFIG_ATH11K_DEBUGFS
358 struct dentry *debugfs_twt;
359 #endif /* CONFIG_ATH11K_DEBUGFS */
362 struct ath11k_vif_iter {
364 struct ath11k_vif *arvif;
367 struct ath11k_rx_peer_stats {
370 u64 num_mpdu_fcs_err;
373 u64 other_msdu_count;
374 u64 ampdu_msdu_count;
375 u64 non_ampdu_msdu_count;
377 u64 beamformed_count;
378 u64 mcs_count[HAL_RX_MAX_MCS + 1];
379 u64 nss_count[HAL_RX_MAX_NSS];
380 u64 bw_count[HAL_RX_BW_MAX];
381 u64 gi_count[HAL_RX_GI_MAX];
382 u64 coding_count[HAL_RX_SU_MU_CODING_MAX];
383 u64 tid_count[IEEE80211_NUM_TIDS + 1];
384 u64 pream_cnt[HAL_RX_PREAMBLE_MAX];
385 u64 reception_type[HAL_RX_RECEPTION_TYPE_MAX];
388 u64 ru_alloc_cnt[HAL_RX_RU_ALLOC_TYPE_MAX];
391 #define ATH11K_HE_MCS_NUM 12
392 #define ATH11K_VHT_MCS_NUM 10
393 #define ATH11K_BW_NUM 4
394 #define ATH11K_NSS_NUM 4
395 #define ATH11K_LEGACY_NUM 12
396 #define ATH11K_GI_NUM 4
397 #define ATH11K_HT_MCS_NUM 32
399 enum ath11k_pkt_rx_err {
400 ATH11K_PKT_RX_ERR_FCS,
401 ATH11K_PKT_RX_ERR_TKIP,
402 ATH11K_PKT_RX_ERR_CRYPT,
403 ATH11K_PKT_RX_ERR_PEER_IDX_INVAL,
404 ATH11K_PKT_RX_ERR_MAX,
407 enum ath11k_ampdu_subfrm_num {
408 ATH11K_AMPDU_SUBFRM_NUM_10,
409 ATH11K_AMPDU_SUBFRM_NUM_20,
410 ATH11K_AMPDU_SUBFRM_NUM_30,
411 ATH11K_AMPDU_SUBFRM_NUM_40,
412 ATH11K_AMPDU_SUBFRM_NUM_50,
413 ATH11K_AMPDU_SUBFRM_NUM_60,
414 ATH11K_AMPDU_SUBFRM_NUM_MORE,
415 ATH11K_AMPDU_SUBFRM_NUM_MAX,
418 enum ath11k_amsdu_subfrm_num {
419 ATH11K_AMSDU_SUBFRM_NUM_1,
420 ATH11K_AMSDU_SUBFRM_NUM_2,
421 ATH11K_AMSDU_SUBFRM_NUM_3,
422 ATH11K_AMSDU_SUBFRM_NUM_4,
423 ATH11K_AMSDU_SUBFRM_NUM_MORE,
424 ATH11K_AMSDU_SUBFRM_NUM_MAX,
427 enum ath11k_counter_type {
428 ATH11K_COUNTER_TYPE_BYTES,
429 ATH11K_COUNTER_TYPE_PKTS,
430 ATH11K_COUNTER_TYPE_MAX,
433 enum ath11k_stats_type {
434 ATH11K_STATS_TYPE_SUCC,
435 ATH11K_STATS_TYPE_FAIL,
436 ATH11K_STATS_TYPE_RETRY,
437 ATH11K_STATS_TYPE_AMPDU,
438 ATH11K_STATS_TYPE_MAX,
441 struct ath11k_htt_data_stats {
442 u64 legacy[ATH11K_COUNTER_TYPE_MAX][ATH11K_LEGACY_NUM];
443 u64 ht[ATH11K_COUNTER_TYPE_MAX][ATH11K_HT_MCS_NUM];
444 u64 vht[ATH11K_COUNTER_TYPE_MAX][ATH11K_VHT_MCS_NUM];
445 u64 he[ATH11K_COUNTER_TYPE_MAX][ATH11K_HE_MCS_NUM];
446 u64 bw[ATH11K_COUNTER_TYPE_MAX][ATH11K_BW_NUM];
447 u64 nss[ATH11K_COUNTER_TYPE_MAX][ATH11K_NSS_NUM];
448 u64 gi[ATH11K_COUNTER_TYPE_MAX][ATH11K_GI_NUM];
451 struct ath11k_htt_tx_stats {
452 struct ath11k_htt_data_stats stats[ATH11K_STATS_TYPE_MAX];
458 struct ath11k_per_ppdu_tx_stats {
468 struct ath11k_vif *arvif;
470 /* the following are protected by ar->data_lock */
471 u32 changed; /* IEEE80211_RC_* */
475 enum hal_pn_type pn_type;
477 struct work_struct update_wk;
478 struct work_struct set_4addr_wk;
479 struct rate_info txrate;
481 struct rate_info last_txrate;
486 s8 chain_signal[IEEE80211_MAX_CHAINS];
487 struct ath11k_htt_tx_stats *tx_stats;
488 struct ath11k_rx_peer_stats *rx_stats;
490 #ifdef CONFIG_MAC80211_DEBUGFS
491 /* protected by conf_mutex */
499 #define ATH11K_MIN_5G_FREQ 4150
500 #define ATH11K_MIN_6G_FREQ 5925
501 #define ATH11K_MAX_6G_FREQ 7115
502 #define ATH11K_NUM_CHANS 101
503 #define ATH11K_MAX_5G_CHAN 173
508 ATH11K_STATE_RESTARTING,
509 ATH11K_STATE_RESTARTED,
511 /* Add other states as required */
514 /* Antenna noise floor */
515 #define ATH11K_DEFAULT_NOISE_FLOOR -95
517 #define ATH11K_INVALID_RSSI_FULL -1
519 #define ATH11K_INVALID_RSSI_EMPTY -128
521 struct ath11k_fw_stats {
522 struct dentry *debugfs_fwstats;
525 struct list_head pdevs;
526 struct list_head vdevs;
527 struct list_head bcn;
530 struct ath11k_dbg_htt_stats {
533 struct debug_htt_stats_req *stats_req;
534 /* protects shared stats req buffer */
538 #define MAX_MODULE_ID_BITMAP_WORDS 16
540 struct ath11k_debug {
541 struct dentry *debugfs_pdev;
542 struct ath11k_dbg_htt_stats htt_stats;
544 struct ath11k_fw_stats fw_stats;
545 struct completion fw_stats_complete;
550 u32 pktlog_peer_valid;
551 u8 pktlog_peer_addr[ETH_ALEN];
554 u32 module_id_bitmap[MAX_MODULE_ID_BITMAP_WORDS];
555 struct ath11k_debug_dbr *dbr_debug[WMI_DIRECT_BUF_MAX];
558 struct ath11k_per_peer_tx_stats {
570 #define ATH11K_FLUSH_TIMEOUT (5 * HZ)
571 #define ATH11K_VDEV_DELETE_TIMEOUT_HZ (5 * HZ)
574 struct ath11k_base *ab;
575 struct ath11k_pdev *pdev;
576 struct ieee80211_hw *hw;
577 struct ieee80211_ops *ops;
578 struct ath11k_pdev_wmi *wmi;
579 struct ath11k_pdev_dp dp;
580 u8 mac_addr[ETH_ALEN];
583 struct ath11k_he ar_he;
584 enum ath11k_state state;
587 struct completion started;
588 struct completion completed;
589 struct completion on_channel;
590 struct delayed_work timeout;
591 enum ath11k_scan_state state;
599 struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
600 struct ieee80211_sband_iftype_data
601 iftype[NUM_NL80211_BANDS][NUM_NL80211_IFTYPES];
604 unsigned long dev_flags;
605 unsigned int filter_flags;
606 unsigned long monitor_flags;
609 u32 txpower_limit_2g;
610 u32 txpower_limit_5g;
615 u32 max_num_stations;
616 /* To synchronize concurrent synchronous mac80211 callback operations,
617 * concurrent debugfs configuration and concurrent FW statistics events.
619 struct mutex conf_mutex;
620 /* protects the radio specific data like debug stats, ppdu_stats_info stats,
621 * vdev_stop_status info, scan data, ath11k_sta info, ath11k_vif info,
622 * channel context data, survey info, test mode data.
624 spinlock_t data_lock;
626 struct list_head arvifs;
627 /* should never be NULL; needed for regular htt rx */
628 struct ieee80211_channel *rx_channel;
630 /* valid during scan; needed for mgmt rx during scan */
631 struct ieee80211_channel *scan_channel;
637 /* pdev_idx starts from 0 whereas pdev->pdev_id starts with 1 */
641 struct completion peer_assoc_done;
642 struct completion peer_delete_done;
644 int install_key_status;
645 struct completion install_key_done;
647 int last_wmi_vdev_start_status;
648 struct completion vdev_setup_done;
649 struct completion vdev_delete_done;
653 u32 num_started_vdevs;
654 u32 num_created_vdevs;
655 unsigned long long allocated_vdev_map;
657 struct idr txmgmt_idr;
658 /* protects txmgmt_idr data */
659 spinlock_t txmgmt_idr_lock;
660 atomic_t num_pending_mgmt_tx;
661 wait_queue_head_t txmgmt_empty_waitq;
663 /* cycle count is reported twice for each visited channel during scan.
664 * access protected by data_lock
666 u32 survey_last_rx_clear_count;
667 u32 survey_last_cycle_count;
669 /* Channel info events are expected to come in pairs without and with
670 * COMPLETE flag set respectively for each channel visit during scan.
672 * However there are deviations from this rule. This flag is used to
673 * avoid reporting garbage data.
675 bool ch_info_can_report_survey;
676 struct survey_info survey[ATH11K_NUM_CHANS];
677 struct completion bss_survey_done;
679 struct work_struct regd_update_work;
681 struct work_struct wmi_mgmt_tx_work;
682 struct sk_buff_head wmi_mgmt_tx_queue;
684 struct ath11k_wow wow;
685 struct completion target_suspend;
686 bool target_suspend_ack;
687 struct ath11k_per_peer_tx_stats peer_tx_stats;
688 struct list_head ppdu_stats_info;
689 u32 ppdu_stat_list_depth;
691 struct ath11k_per_peer_tx_stats cached_stats;
695 #ifdef CONFIG_ATH11K_DEBUGFS
696 struct ath11k_debug debug;
698 #ifdef CONFIG_ATH11K_SPECTRAL
699 struct ath11k_spectral spectral;
701 bool dfs_block_radar_events;
702 struct ath11k_thermal thermal;
703 u32 vdev_id_11d_scan;
704 struct completion completed_11d_scan;
705 enum ath11k_11d_state state_11d;
706 bool regdom_set_by_user;
710 u8 alpha2[REG_ALPHA2_LEN + 1];
713 struct ath11k_band_cap {
715 u32 max_bw_supported;
719 u32 he_cap_phy_info[PSOC_HOST_MAX_PHY_SIZE];
720 struct ath11k_ppe_threshold he_ppet;
724 struct ath11k_pdev_cap {
732 u32 tx_chain_mask_shift;
733 u32 rx_chain_mask_shift;
734 struct ath11k_band_cap band[NUM_NL80211_BANDS];
735 bool nss_ratio_enabled;
742 struct ath11k_pdev_cap cap;
743 u8 mac_addr[ETH_ALEN];
746 struct ath11k_board_data {
747 const struct firmware *fw;
752 struct ath11k_pci_ops {
753 int (*wakeup)(struct ath11k_base *ab);
754 void (*release)(struct ath11k_base *ab);
755 int (*get_msi_irq)(struct ath11k_base *ab, unsigned int vector);
756 void (*window_write32)(struct ath11k_base *ab, u32 offset, u32 value);
757 u32 (*window_read32)(struct ath11k_base *ab, u32 offset);
760 /* IPQ8074 HW channel counters frequency value in hertz */
761 #define IPQ8074_CC_FREQ_HERTZ 320000
763 struct ath11k_bp_stats {
764 /* Head Pointer reported by the last HTT Backpressure event for the ring */
767 /* Tail Pointer reported by the last HTT Backpressure event for the ring */
770 /* Number of Backpressure events received for the ring */
773 /* Last recorded event timestamp */
774 unsigned long jiffies;
777 struct ath11k_dp_ring_bp_stats {
778 struct ath11k_bp_stats umac_ring_bp_stats[HTT_SW_UMAC_RING_IDX_MAX];
779 struct ath11k_bp_stats lmac_ring_bp_stats[HTT_SW_LMAC_RING_IDX_MAX][MAX_RADIOS];
782 struct ath11k_soc_dp_tx_err_stats {
783 /* TCL Ring Descriptor unavailable */
784 u32 desc_na[DP_TCL_NUM_RING_MAX];
785 /* Other failures during dp_tx due to mem allocation failure
786 * idr unavailable etc.
791 struct ath11k_soc_dp_stats {
794 u32 rxdma_error[HAL_REO_ENTR_RING_RXDMA_ECODE_MAX];
795 u32 reo_error[HAL_REO_DEST_RING_ERROR_CODE_MAX];
796 u32 hal_reo_error[DP_REO_DST_RING_MAX];
797 struct ath11k_soc_dp_tx_err_stats tx_err;
798 struct ath11k_dp_ring_bp_stats bp_stats;
801 struct ath11k_msi_user {
807 struct ath11k_msi_config {
810 struct ath11k_msi_user *users;
814 /* Master structure to hold the hw data which may be used in core module */
816 enum ath11k_hw_rev hw_rev;
817 struct platform_device *pdev;
819 struct ath11k_qmi qmi;
820 struct ath11k_wmi_base wmi_ab;
821 struct completion fw_ready;
823 /* HW channel counters frequency value in hertz common to all MACs */
826 struct ath11k_htc htc;
831 unsigned long mem_len;
835 const struct ath11k_hif_ops *ops;
839 struct completion wakeup_completed;
843 struct timer_list rx_replenish_retry;
844 struct ath11k_hal hal;
845 /* To synchronize core_start/core_stop */
846 struct mutex core_lock;
847 /* Protects data like peers */
848 spinlock_t base_lock;
849 struct ath11k_pdev pdevs[MAX_RADIOS];
851 enum WMI_HOST_WLAN_BAND supported_bands;
853 } target_pdev_ids[MAX_RADIOS];
854 u8 target_pdev_count;
855 struct ath11k_pdev __rcu *pdevs_active[MAX_RADIOS];
856 struct ath11k_hal_reg_capabilities_ext hal_reg_cap[MAX_RADIOS];
857 unsigned long long free_vdev_map;
859 /* To synchronize rhash tbl write operation */
860 struct mutex tbl_mtx_lock;
862 /* The rhashtable containing struct ath11k_peer keyed by mac addr */
863 struct rhashtable *rhead_peer_addr;
864 struct rhashtable_params rhash_peer_addr_param;
866 /* The rhashtable containing struct ath11k_peer keyed by id */
867 struct rhashtable *rhead_peer_id;
868 struct rhashtable_params rhash_peer_id_param;
870 struct list_head peers;
871 wait_queue_head_t peer_mapping_wq;
872 u8 mac_addr[ETH_ALEN];
874 u32 wlan_init_status;
875 int irq_num[ATH11K_IRQ_NUM_MAX];
876 struct ath11k_ext_irq_grp ext_irq_grp[ATH11K_EXT_IRQ_GRP_NUM_MAX];
877 struct ath11k_targ_cap target_caps;
878 u32 ext_service_bitmap[WMI_SERVICE_EXT_BM_SIZE];
879 bool pdevs_macaddr_valid;
882 struct ath11k_hw_params hw_params;
884 const struct firmware *cal_file;
886 /* Below regd's are protected by ab->data_lock */
887 /* This is the regd set for every radio
888 * by the firmware during initializatin
890 struct ieee80211_regdomain *default_regd[MAX_RADIOS];
891 /* This regd is set during dynamic country setting
892 * This may or may not be used during the runtime
894 struct ieee80211_regdomain *new_regd[MAX_RADIOS];
896 /* Current DFS Regulatory */
897 enum ath11k_dfs_region dfs_region;
898 #ifdef CONFIG_ATH11K_DEBUGFS
899 struct dentry *debugfs_soc;
900 struct dentry *debugfs_ath11k;
902 struct ath11k_soc_dp_stats soc_stats;
904 unsigned long dev_flags;
905 struct completion driver_recovery;
906 struct workqueue_struct *workqueue;
907 struct work_struct restart_work;
908 struct work_struct update_11d_work;
910 struct workqueue_struct *workqueue_aux;
911 struct work_struct reset_work;
912 atomic_t reset_count;
913 atomic_t recovery_count;
914 atomic_t recovery_start_count;
916 struct completion reset_complete;
917 struct completion reconfigure_complete;
918 struct completion recovery_start;
919 /* continuous recovery fail count */
920 atomic_t fail_cont_count;
921 unsigned long reset_fail_timeout;
923 /* protected by data_lock */
924 u32 fw_crash_counter;
926 u32 pktlog_defs_checksum;
928 struct ath11k_dbring_cap *db_caps;
930 struct work_struct rfkill_work;
932 /* true means radio is on */
933 bool rfkill_radio_on;
935 /* To synchronize 11d scan vdev id */
936 struct mutex vdev_id_11d_lock;
937 struct timer_list mon_reap_timer;
939 struct completion htc_suspend;
942 enum ath11k_bdf_search bdf_search;
945 u32 subsystem_vendor;
946 u32 subsystem_device;
951 const struct ath11k_msi_config *config;
958 const struct ath11k_pci_ops *ops;
962 u8 drv_priv[] __aligned(sizeof(void *));
965 struct ath11k_fw_stats_pdev {
966 struct list_head list;
970 /* Cycles spent transmitting frames */
972 /* Cycles spent receiving frames */
974 /* Total channel busy time, evidently */
976 /* Total on-channel time */
988 /* Num HTT cookies queued to dispatch list */
990 /* Num HTT cookies dispatched */
992 /* Num MSDU queued to WAL */
994 /* Num MPDU queue to WAL */
996 /* Num MSDUs dropped by WMM limit */
998 /* Num Local frames queued */
1000 /* Num Local frames done */
1002 /* Num queued to HW */
1004 /* Num PPDU reaped from HW */
1010 /* Num PPDUs cleaned up in TX abort */
1012 /* Num MPDUs requeued by SW */
1014 /* excessive retries */
1017 /* data hw rate code */
1019 /* Scheduler self triggers */
1021 /* frames dropped due to excessive sw retries */
1022 u32 sw_retry_failure;
1023 /* illegal rate phy errors */
1024 u32 illgl_rate_phy_err;
1025 /* wal pdev continuous xretry */
1026 u32 pdev_cont_xretry;
1027 /* wal pdev tx timeouts */
1028 u32 pdev_tx_timeout;
1029 /* wal pdev resets */
1031 /* frames dropped due to non-availability of stateless TIDs */
1032 u32 stateless_tid_alloc_failure;
1033 /* PhY/BB underrun */
1035 /* MPDU is more than txop limit */
1037 /* Num sequences posted */
1039 /* Num sequences failed in queueing */
1040 u32 seq_failed_queueing;
1041 /* Num sequences completed */
1043 /* Num sequences restarted */
1045 /* Num of MU sequences posted */
1047 /* Num MPDUs flushed by SW, HWPAUSED, SW TXABORT
1048 * (Reset,channel change)
1051 /* Num MPDUs filtered by HW, all filter condition (TTL expired) */
1052 s32 mpdus_hw_filter;
1053 /* Num MPDUs truncated by PDG (TXOP, TBTT,
1054 * PPDU_duration based on rate, dyn_bw)
1056 s32 mpdus_truncated;
1057 /* Num MPDUs that was tried but didn't receive ACK or BA */
1058 s32 mpdus_ack_failed;
1059 /* Num MPDUs that was dropped du to expiry. */
1063 /* Cnts any change in ring routing mid-ppdu */
1064 s32 mid_ppdu_route_change;
1065 /* Total number of statuses processed */
1067 /* Extra frags on rings 0-3 */
1072 /* MSDUs / MPDUs delivered to HTT */
1075 /* MSDUs / MPDUs delivered to local stack */
1078 /* AMSDUs that have more MSDUs than the status ring size */
1080 /* Number of PHY errors */
1082 /* Number of PHY errors drops */
1084 /* Number of mpdu errors - FCS, MIC, ENC etc. */
1086 /* Num overflow errors */
1090 struct ath11k_fw_stats_vdev {
1091 struct list_head list;
1096 u32 num_tx_frames[WLAN_MAX_AC];
1098 u32 num_tx_frames_retries[WLAN_MAX_AC];
1099 u32 num_tx_frames_failures[WLAN_MAX_AC];
1101 u32 num_rts_success;
1104 u32 num_tx_not_acked;
1105 u32 tx_rate_history[MAX_TX_RATE_VALUES];
1106 u32 beacon_rssi_history[MAX_TX_RATE_VALUES];
1109 struct ath11k_fw_stats_bcn {
1110 struct list_head list;
1113 u32 tx_bcn_succ_cnt;
1114 u32 tx_bcn_outage_cnt;
1117 extern const struct ce_pipe_config ath11k_target_ce_config_wlan_ipq8074[];
1118 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq8074[];
1119 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq6018[];
1121 extern const struct ce_pipe_config ath11k_target_ce_config_wlan_qca6390[];
1122 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_qca6390[];
1124 extern const struct ce_pipe_config ath11k_target_ce_config_wlan_qcn9074[];
1125 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_qcn9074[];
1126 int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab);
1127 int ath11k_core_pre_init(struct ath11k_base *ab);
1128 int ath11k_core_init(struct ath11k_base *ath11k);
1129 void ath11k_core_deinit(struct ath11k_base *ath11k);
1130 struct ath11k_base *ath11k_core_alloc(struct device *dev, size_t priv_size,
1131 enum ath11k_bus bus);
1132 void ath11k_core_free(struct ath11k_base *ath11k);
1133 int ath11k_core_fetch_bdf(struct ath11k_base *ath11k,
1134 struct ath11k_board_data *bd);
1135 int ath11k_core_fetch_regdb(struct ath11k_base *ab, struct ath11k_board_data *bd);
1136 int ath11k_core_fetch_board_data_api_1(struct ath11k_base *ab,
1137 struct ath11k_board_data *bd,
1139 void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd);
1140 int ath11k_core_check_dt(struct ath11k_base *ath11k);
1141 int ath11k_core_check_smbios(struct ath11k_base *ab);
1142 void ath11k_core_halt(struct ath11k *ar);
1143 int ath11k_core_resume(struct ath11k_base *ab);
1144 int ath11k_core_suspend(struct ath11k_base *ab);
1146 const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab,
1147 const char *filename);
1149 static inline const char *ath11k_scan_state_str(enum ath11k_scan_state state)
1152 case ATH11K_SCAN_IDLE:
1154 case ATH11K_SCAN_STARTING:
1156 case ATH11K_SCAN_RUNNING:
1158 case ATH11K_SCAN_ABORTING:
1165 static inline struct ath11k_skb_cb *ATH11K_SKB_CB(struct sk_buff *skb)
1167 BUILD_BUG_ON(sizeof(struct ath11k_skb_cb) >
1168 IEEE80211_TX_INFO_DRIVER_DATA_SIZE);
1169 return (struct ath11k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
1172 static inline struct ath11k_skb_rxcb *ATH11K_SKB_RXCB(struct sk_buff *skb)
1174 BUILD_BUG_ON(sizeof(struct ath11k_skb_rxcb) > sizeof(skb->cb));
1175 return (struct ath11k_skb_rxcb *)skb->cb;
1178 static inline struct ath11k_vif *ath11k_vif_to_arvif(struct ieee80211_vif *vif)
1180 return (struct ath11k_vif *)vif->drv_priv;
1183 static inline struct ath11k *ath11k_ab_to_ar(struct ath11k_base *ab,
1186 return ab->pdevs[ath11k_hw_mac_id_to_pdev_id(&ab->hw_params, mac_id)].ar;
1189 static inline void ath11k_core_create_firmware_path(struct ath11k_base *ab,
1190 const char *filename,
1191 void *buf, size_t buf_len)
1193 snprintf(buf, buf_len, "%s/%s/%s", ATH11K_FW_DIR,
1194 ab->hw_params.fw.dir, filename);
1197 static inline const char *ath11k_bus_str(enum ath11k_bus bus)
1200 case ATH11K_BUS_PCI:
1202 case ATH11K_BUS_AHB:
1209 #endif /* _CORE_H_ */