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>
17 #include <linux/average.h>
33 #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
35 #define ATH11K_TX_MGMT_NUM_PENDING_MAX 512
37 #define ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI 64
39 /* Pending management packets threshold for dropping probe responses */
40 #define ATH11K_PRB_RSP_DROP_THRESHOLD ((ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI * 3) / 4)
42 #define ATH11K_INVALID_HW_MAC_ID 0xFF
43 #define ATH11K_CONNECTION_LOSS_HZ (3 * HZ)
45 /* SMBIOS type containing Board Data File Name Extension */
46 #define ATH11K_SMBIOS_BDF_EXT_TYPE 0xF8
48 /* SMBIOS type structure length (excluding strings-set) */
49 #define ATH11K_SMBIOS_BDF_EXT_LENGTH 0x9
51 /* The magic used by QCA spec */
52 #define ATH11K_SMBIOS_BDF_EXT_MAGIC "BDF_"
54 extern unsigned int ath11k_frame_mode;
56 #define ATH11K_SCAN_TIMEOUT_HZ (20 * HZ)
58 #define ATH11K_MON_TIMER_INTERVAL 10
59 #define ATH11K_RESET_TIMEOUT_HZ (20 * HZ)
60 #define ATH11K_RESET_MAX_FAIL_COUNT_FIRST 3
61 #define ATH11K_RESET_MAX_FAIL_COUNT_FINAL 5
62 #define ATH11K_RESET_FAIL_TIMEOUT_HZ (20 * HZ)
63 #define ATH11K_RECONFIGURE_TIMEOUT_HZ (10 * HZ)
64 #define ATH11K_RECOVER_START_TIMEOUT_HZ (20 * HZ)
66 enum ath11k_supported_bw {
73 enum ath11k_bdf_search {
74 ATH11K_BDF_SEARCH_DEFAULT,
75 ATH11K_BDF_SEARCH_BUS_AND_BOARD,
86 #define ATH11K_HT_MCS_MAX 7
87 #define ATH11K_VHT_MCS_MAX 9
88 #define ATH11K_HE_MCS_MAX 11
90 enum ath11k_crypt_mode {
91 /* Only use hardware crypto engine */
93 /* Only use software crypto */
97 static inline enum wme_ac ath11k_tid_to_ac(u32 tid)
99 return (((tid == 0) || (tid == 3)) ? WME_AC_BE :
100 ((tid == 1) || (tid == 2)) ? WME_AC_BK :
101 ((tid == 4) || (tid == 5)) ? WME_AC_VI :
105 enum ath11k_skb_flags {
106 ATH11K_SKB_HW_80211_ENCAP = BIT(0),
107 ATH11K_SKB_CIPHER_SET = BIT(1),
110 struct ath11k_skb_cb {
116 struct ieee80211_vif *vif;
119 struct ath11k_skb_rxcb {
123 bool is_continuation;
126 struct hal_rx_desc *rx_desc;
139 ATH11K_HW_QCA6390_HW20,
140 ATH11K_HW_IPQ6018_HW10,
141 ATH11K_HW_QCN9074_HW10,
142 ATH11K_HW_WCN6855_HW20,
143 ATH11K_HW_WCN6855_HW21,
144 ATH11K_HW_WCN6750_HW10,
147 enum ath11k_firmware_mode {
148 /* the default mode, standard 802.11 functionality */
149 ATH11K_FIRMWARE_MODE_NORMAL,
151 /* factory tests etc */
152 ATH11K_FIRMWARE_MODE_FTM,
154 /* Cold boot calibration */
155 ATH11K_FIRMWARE_MODE_COLD_BOOT = 7,
158 extern bool ath11k_cold_boot_cal;
160 #define ATH11K_IRQ_NUM_MAX 52
161 #define ATH11K_EXT_IRQ_NUM_MAX 16
163 struct ath11k_ext_irq_grp {
164 struct ath11k_base *ab;
165 u32 irqs[ATH11K_EXT_IRQ_NUM_MAX];
170 struct napi_struct napi;
171 struct net_device napi_ndev;
174 enum ath11k_smbios_cc_type {
175 /* disable country code setting from SMBIOS */
176 ATH11K_SMBIOS_CC_DISABLE = 0,
178 /* set country code by ANSI country name, based on ISO3166-1 alpha2 */
179 ATH11K_SMBIOS_CC_ISO = 1,
181 /* worldwide regdomain */
182 ATH11K_SMBIOS_CC_WW = 2,
185 struct ath11k_smbios_bdf {
186 struct dmi_header hdr;
188 u8 features_disabled;
190 /* enum ath11k_smbios_cc_type */
191 u8 country_code_flag;
193 /* To set specific country, you need to set country code
194 * flag=ATH11K_SMBIOS_CC_ISO first, then if country is United
195 * States, then country code value = 0x5553 ("US",'U' = 0x55, 'S'=
196 * 0x53). To set country to INDONESIA, then country code value =
197 * 0x4944 ("IN", 'I'=0x49, 'D'=0x44). If country code flag =
198 * ATH11K_SMBIOS_CC_WW, then you can use worldwide regulatory
207 #define HEHANDLE_CAP_PHYINFO_SIZE 3
208 #define HECAP_PHYINFO_SIZE 9
209 #define HECAP_MACINFO_SIZE 5
210 #define HECAP_TXRX_MCS_NSS_SIZE 2
211 #define HECAP_PPET16_PPET8_MAX_SIZE 25
213 #define HE_PPET16_PPET8_SIZE 8
215 /* 802.11ax PPE (PPDU packet Extension) threshold */
216 struct he_ppe_threshold {
219 u32 ppet16_ppet8_ru3_ru0[HE_PPET16_PPET8_SIZE];
223 u8 hecap_macinfo[HECAP_MACINFO_SIZE];
224 u32 hecap_rxmcsnssmap;
225 u32 hecap_txmcsnssmap;
226 u32 hecap_phyinfo[HEHANDLE_CAP_PHYINFO_SIZE];
227 struct he_ppe_threshold hecap_ppet;
234 WMI_HOST_TP_SCALE_MAX = 0,
235 WMI_HOST_TP_SCALE_50 = 1,
236 WMI_HOST_TP_SCALE_25 = 2,
237 WMI_HOST_TP_SCALE_12 = 3,
238 WMI_HOST_TP_SCALE_MIN = 4,
239 WMI_HOST_TP_SCALE_SIZE = 5,
242 enum ath11k_scan_state {
244 ATH11K_SCAN_STARTING,
246 ATH11K_SCAN_ABORTING,
249 enum ath11k_11d_state {
251 ATH11K_11D_PREPARING,
255 enum ath11k_dev_flags {
257 ATH11K_FLAG_CORE_REGISTERED,
258 ATH11K_FLAG_CRASH_FLUSH,
259 ATH11K_FLAG_RAW_MODE,
260 ATH11K_FLAG_HW_CRYPTO_DISABLED,
262 ATH11K_FLAG_RECOVERY,
263 ATH11K_FLAG_UNREGISTERING,
264 ATH11K_FLAG_REGISTERED,
265 ATH11K_FLAG_QMI_FAIL,
266 ATH11K_FLAG_HTC_SUSPEND_COMPLETE,
267 ATH11K_FLAG_CE_IRQ_ENABLED,
268 ATH11K_FLAG_EXT_IRQ_ENABLED,
269 ATH11K_FLAG_FIXED_MEM_RGN,
270 ATH11K_FLAG_DEVICE_INIT_DONE,
271 ATH11K_FLAG_MULTI_MSI_VECTORS,
274 enum ath11k_monitor_flags {
275 ATH11K_FLAG_MONITOR_CONF_ENABLED,
276 ATH11K_FLAG_MONITOR_STARTED,
277 ATH11K_FLAG_MONITOR_VDEV_CREATED,
280 #define ATH11K_IPV6_UC_TYPE 0
281 #define ATH11K_IPV6_AC_TYPE 1
283 #define ATH11K_IPV6_MAX_COUNT 16
284 #define ATH11K_IPV4_MAX_COUNT 2
286 struct ath11k_arp_ns_offload {
287 u8 ipv4_addr[ATH11K_IPV4_MAX_COUNT][4];
290 u8 ipv6_addr[ATH11K_IPV6_MAX_COUNT][16];
291 u8 self_ipv6_addr[ATH11K_IPV6_MAX_COUNT][16];
292 u8 ipv6_type[ATH11K_IPV6_MAX_COUNT];
293 bool ipv6_valid[ATH11K_IPV6_MAX_COUNT];
294 u8 mac_addr[ETH_ALEN];
297 struct ath11k_rekey_data {
298 u8 kck[NL80211_KCK_LEN];
299 u8 kek[NL80211_KCK_LEN];
306 enum wmi_vdev_type vdev_type;
307 enum wmi_vdev_subtype vdev_subtype;
313 u8 hal_addr_search_flags;
317 struct ieee80211_vif *vif;
320 struct wmi_wmm_params_all_arg wmm_params;
321 struct list_head list;
327 /* 127 stations; wmi limit */
331 u8 ssid[IEEE80211_MAX_SSID_LEN];
333 /* P2P_IE with NoA attribute for P2P_GO case */
341 bool spectral_enabled;
345 struct cfg80211_bitrate_mask bitrate_mask;
346 struct delayed_work connection_loss_work;
347 int num_legacy_stations;
348 int rtscts_prot_mode;
353 bool do_not_send_tmpl;
354 struct ieee80211_chanctx_conf chanctx;
355 struct ath11k_arp_ns_offload arp_ns_offload;
356 struct ath11k_rekey_data rekey_data;
358 #ifdef CONFIG_ATH11K_DEBUGFS
359 struct dentry *debugfs_twt;
360 #endif /* CONFIG_ATH11K_DEBUGFS */
363 struct ath11k_vif_iter {
365 struct ath11k_vif *arvif;
368 struct ath11k_rx_peer_stats {
371 u64 num_mpdu_fcs_err;
374 u64 other_msdu_count;
375 u64 ampdu_msdu_count;
376 u64 non_ampdu_msdu_count;
378 u64 beamformed_count;
379 u64 mcs_count[HAL_RX_MAX_MCS + 1];
380 u64 nss_count[HAL_RX_MAX_NSS];
381 u64 bw_count[HAL_RX_BW_MAX];
382 u64 gi_count[HAL_RX_GI_MAX];
383 u64 coding_count[HAL_RX_SU_MU_CODING_MAX];
384 u64 tid_count[IEEE80211_NUM_TIDS + 1];
385 u64 pream_cnt[HAL_RX_PREAMBLE_MAX];
386 u64 reception_type[HAL_RX_RECEPTION_TYPE_MAX];
389 u64 ru_alloc_cnt[HAL_RX_RU_ALLOC_TYPE_MAX];
392 #define ATH11K_HE_MCS_NUM 12
393 #define ATH11K_VHT_MCS_NUM 10
394 #define ATH11K_BW_NUM 4
395 #define ATH11K_NSS_NUM 4
396 #define ATH11K_LEGACY_NUM 12
397 #define ATH11K_GI_NUM 4
398 #define ATH11K_HT_MCS_NUM 32
400 enum ath11k_pkt_rx_err {
401 ATH11K_PKT_RX_ERR_FCS,
402 ATH11K_PKT_RX_ERR_TKIP,
403 ATH11K_PKT_RX_ERR_CRYPT,
404 ATH11K_PKT_RX_ERR_PEER_IDX_INVAL,
405 ATH11K_PKT_RX_ERR_MAX,
408 enum ath11k_ampdu_subfrm_num {
409 ATH11K_AMPDU_SUBFRM_NUM_10,
410 ATH11K_AMPDU_SUBFRM_NUM_20,
411 ATH11K_AMPDU_SUBFRM_NUM_30,
412 ATH11K_AMPDU_SUBFRM_NUM_40,
413 ATH11K_AMPDU_SUBFRM_NUM_50,
414 ATH11K_AMPDU_SUBFRM_NUM_60,
415 ATH11K_AMPDU_SUBFRM_NUM_MORE,
416 ATH11K_AMPDU_SUBFRM_NUM_MAX,
419 enum ath11k_amsdu_subfrm_num {
420 ATH11K_AMSDU_SUBFRM_NUM_1,
421 ATH11K_AMSDU_SUBFRM_NUM_2,
422 ATH11K_AMSDU_SUBFRM_NUM_3,
423 ATH11K_AMSDU_SUBFRM_NUM_4,
424 ATH11K_AMSDU_SUBFRM_NUM_MORE,
425 ATH11K_AMSDU_SUBFRM_NUM_MAX,
428 enum ath11k_counter_type {
429 ATH11K_COUNTER_TYPE_BYTES,
430 ATH11K_COUNTER_TYPE_PKTS,
431 ATH11K_COUNTER_TYPE_MAX,
434 enum ath11k_stats_type {
435 ATH11K_STATS_TYPE_SUCC,
436 ATH11K_STATS_TYPE_FAIL,
437 ATH11K_STATS_TYPE_RETRY,
438 ATH11K_STATS_TYPE_AMPDU,
439 ATH11K_STATS_TYPE_MAX,
442 struct ath11k_htt_data_stats {
443 u64 legacy[ATH11K_COUNTER_TYPE_MAX][ATH11K_LEGACY_NUM];
444 u64 ht[ATH11K_COUNTER_TYPE_MAX][ATH11K_HT_MCS_NUM];
445 u64 vht[ATH11K_COUNTER_TYPE_MAX][ATH11K_VHT_MCS_NUM];
446 u64 he[ATH11K_COUNTER_TYPE_MAX][ATH11K_HE_MCS_NUM];
447 u64 bw[ATH11K_COUNTER_TYPE_MAX][ATH11K_BW_NUM];
448 u64 nss[ATH11K_COUNTER_TYPE_MAX][ATH11K_NSS_NUM];
449 u64 gi[ATH11K_COUNTER_TYPE_MAX][ATH11K_GI_NUM];
452 struct ath11k_htt_tx_stats {
453 struct ath11k_htt_data_stats stats[ATH11K_STATS_TYPE_MAX];
459 struct ath11k_per_ppdu_tx_stats {
468 DECLARE_EWMA(avg_rssi, 10, 8)
471 struct ath11k_vif *arvif;
473 /* the following are protected by ar->data_lock */
474 u32 changed; /* IEEE80211_RC_* */
478 enum hal_pn_type pn_type;
480 struct work_struct update_wk;
481 struct work_struct set_4addr_wk;
482 struct rate_info txrate;
484 struct rate_info last_txrate;
488 struct ewma_avg_rssi avg_rssi;
490 s8 chain_signal[IEEE80211_MAX_CHAINS];
491 struct ath11k_htt_tx_stats *tx_stats;
492 struct ath11k_rx_peer_stats *rx_stats;
494 #ifdef CONFIG_MAC80211_DEBUGFS
495 /* protected by conf_mutex */
502 /* Protected with ar->data_lock */
503 enum ath11k_wmi_peer_ps_state peer_ps_state;
505 u64 ps_start_jiffies;
506 u64 ps_total_duration;
507 bool peer_current_ps_valid;
512 #define ATH11K_MIN_5G_FREQ 4150
513 #define ATH11K_MIN_6G_FREQ 5925
514 #define ATH11K_MAX_6G_FREQ 7115
515 #define ATH11K_NUM_CHANS 101
516 #define ATH11K_MAX_5G_CHAN 173
521 ATH11K_STATE_RESTARTING,
522 ATH11K_STATE_RESTARTED,
524 /* Add other states as required */
527 /* Antenna noise floor */
528 #define ATH11K_DEFAULT_NOISE_FLOOR -95
530 #define ATH11K_INVALID_RSSI_FULL -1
532 #define ATH11K_INVALID_RSSI_EMPTY -128
534 struct ath11k_fw_stats {
535 struct dentry *debugfs_fwstats;
538 struct list_head pdevs;
539 struct list_head vdevs;
540 struct list_head bcn;
543 struct ath11k_dbg_htt_stats {
546 struct debug_htt_stats_req *stats_req;
547 /* protects shared stats req buffer */
551 #define MAX_MODULE_ID_BITMAP_WORDS 16
553 struct ath11k_debug {
554 struct dentry *debugfs_pdev;
555 struct ath11k_dbg_htt_stats htt_stats;
560 u32 pktlog_peer_valid;
561 u8 pktlog_peer_addr[ETH_ALEN];
564 u32 module_id_bitmap[MAX_MODULE_ID_BITMAP_WORDS];
565 struct ath11k_debug_dbr *dbr_debug[WMI_DIRECT_BUF_MAX];
568 struct ath11k_per_peer_tx_stats {
580 #define ATH11K_FLUSH_TIMEOUT (5 * HZ)
581 #define ATH11K_VDEV_DELETE_TIMEOUT_HZ (5 * HZ)
584 struct ath11k_base *ab;
585 struct ath11k_pdev *pdev;
586 struct ieee80211_hw *hw;
587 struct ieee80211_ops *ops;
588 struct ath11k_pdev_wmi *wmi;
589 struct ath11k_pdev_dp dp;
590 u8 mac_addr[ETH_ALEN];
591 struct ath11k_he ar_he;
592 enum ath11k_state state;
595 struct completion started;
596 struct completion completed;
597 struct completion on_channel;
598 struct delayed_work timeout;
599 enum ath11k_scan_state state;
607 struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
608 struct ieee80211_sband_iftype_data
609 iftype[NUM_NL80211_BANDS][NUM_NL80211_IFTYPES];
612 unsigned long dev_flags;
613 unsigned int filter_flags;
614 unsigned long monitor_flags;
617 u32 txpower_limit_2g;
618 u32 txpower_limit_5g;
623 u32 max_num_stations;
624 /* To synchronize concurrent synchronous mac80211 callback operations,
625 * concurrent debugfs configuration and concurrent FW statistics events.
627 struct mutex conf_mutex;
628 /* protects the radio specific data like debug stats, ppdu_stats_info stats,
629 * vdev_stop_status info, scan data, ath11k_sta info, ath11k_vif info,
630 * channel context data, survey info, test mode data.
632 spinlock_t data_lock;
634 struct list_head arvifs;
635 /* should never be NULL; needed for regular htt rx */
636 struct ieee80211_channel *rx_channel;
638 /* valid during scan; needed for mgmt rx during scan */
639 struct ieee80211_channel *scan_channel;
645 /* pdev_idx starts from 0 whereas pdev->pdev_id starts with 1 */
649 struct completion peer_assoc_done;
650 struct completion peer_delete_done;
652 int install_key_status;
653 struct completion install_key_done;
655 int last_wmi_vdev_start_status;
656 struct completion vdev_setup_done;
657 struct completion vdev_delete_done;
661 u32 num_started_vdevs;
662 u32 num_created_vdevs;
663 unsigned long long allocated_vdev_map;
665 struct idr txmgmt_idr;
666 /* protects txmgmt_idr data */
667 spinlock_t txmgmt_idr_lock;
668 atomic_t num_pending_mgmt_tx;
669 wait_queue_head_t txmgmt_empty_waitq;
671 /* cycle count is reported twice for each visited channel during scan.
672 * access protected by data_lock
674 u32 survey_last_rx_clear_count;
675 u32 survey_last_cycle_count;
677 /* Channel info events are expected to come in pairs without and with
678 * COMPLETE flag set respectively for each channel visit during scan.
680 * However there are deviations from this rule. This flag is used to
681 * avoid reporting garbage data.
683 bool ch_info_can_report_survey;
684 struct survey_info survey[ATH11K_NUM_CHANS];
685 struct completion bss_survey_done;
687 struct work_struct regd_update_work;
689 struct work_struct wmi_mgmt_tx_work;
690 struct sk_buff_head wmi_mgmt_tx_queue;
692 struct ath11k_wow wow;
693 struct completion target_suspend;
694 bool target_suspend_ack;
695 struct ath11k_per_peer_tx_stats peer_tx_stats;
696 struct list_head ppdu_stats_info;
697 u32 ppdu_stat_list_depth;
699 struct ath11k_per_peer_tx_stats cached_stats;
703 #ifdef CONFIG_ATH11K_DEBUGFS
704 struct ath11k_debug debug;
706 #ifdef CONFIG_ATH11K_SPECTRAL
707 struct ath11k_spectral spectral;
709 bool dfs_block_radar_events;
710 struct ath11k_thermal thermal;
711 u32 vdev_id_11d_scan;
712 struct completion completed_11d_scan;
713 enum ath11k_11d_state state_11d;
714 bool regdom_set_by_user;
718 u8 alpha2[REG_ALPHA2_LEN + 1];
719 struct ath11k_fw_stats fw_stats;
720 struct completion fw_stats_complete;
723 /* protected by conf_mutex */
724 bool ps_state_enable;
725 bool ps_timekeeper_enable;
728 struct ath11k_band_cap {
730 u32 max_bw_supported;
734 u32 he_cap_phy_info[PSOC_HOST_MAX_PHY_SIZE];
735 struct ath11k_ppe_threshold he_ppet;
739 struct ath11k_pdev_cap {
747 u32 tx_chain_mask_shift;
748 u32 rx_chain_mask_shift;
749 struct ath11k_band_cap band[NUM_NL80211_BANDS];
750 bool nss_ratio_enabled;
757 struct ath11k_pdev_cap cap;
758 u8 mac_addr[ETH_ALEN];
761 struct ath11k_board_data {
762 const struct firmware *fw;
767 struct ath11k_pci_ops {
768 int (*wakeup)(struct ath11k_base *ab);
769 void (*release)(struct ath11k_base *ab);
770 int (*get_msi_irq)(struct ath11k_base *ab, unsigned int vector);
771 void (*window_write32)(struct ath11k_base *ab, u32 offset, u32 value);
772 u32 (*window_read32)(struct ath11k_base *ab, u32 offset);
775 /* IPQ8074 HW channel counters frequency value in hertz */
776 #define IPQ8074_CC_FREQ_HERTZ 320000
778 struct ath11k_bp_stats {
779 /* Head Pointer reported by the last HTT Backpressure event for the ring */
782 /* Tail Pointer reported by the last HTT Backpressure event for the ring */
785 /* Number of Backpressure events received for the ring */
788 /* Last recorded event timestamp */
789 unsigned long jiffies;
792 struct ath11k_dp_ring_bp_stats {
793 struct ath11k_bp_stats umac_ring_bp_stats[HTT_SW_UMAC_RING_IDX_MAX];
794 struct ath11k_bp_stats lmac_ring_bp_stats[HTT_SW_LMAC_RING_IDX_MAX][MAX_RADIOS];
797 struct ath11k_soc_dp_tx_err_stats {
798 /* TCL Ring Descriptor unavailable */
799 u32 desc_na[DP_TCL_NUM_RING_MAX];
800 /* Other failures during dp_tx due to mem allocation failure
801 * idr unavailable etc.
806 struct ath11k_soc_dp_stats {
809 u32 rxdma_error[HAL_REO_ENTR_RING_RXDMA_ECODE_MAX];
810 u32 reo_error[HAL_REO_DEST_RING_ERROR_CODE_MAX];
811 u32 hal_reo_error[DP_REO_DST_RING_MAX];
812 struct ath11k_soc_dp_tx_err_stats tx_err;
813 struct ath11k_dp_ring_bp_stats bp_stats;
816 struct ath11k_msi_user {
822 struct ath11k_msi_config {
825 struct ath11k_msi_user *users;
829 /* Master structure to hold the hw data which may be used in core module */
831 enum ath11k_hw_rev hw_rev;
832 struct platform_device *pdev;
834 struct ath11k_qmi qmi;
835 struct ath11k_wmi_base wmi_ab;
836 struct completion fw_ready;
838 /* HW channel counters frequency value in hertz common to all MACs */
841 struct ath11k_htc htc;
846 unsigned long mem_len;
850 const struct ath11k_hif_ops *ops;
854 struct completion wakeup_completed;
858 struct timer_list rx_replenish_retry;
859 struct ath11k_hal hal;
860 /* To synchronize core_start/core_stop */
861 struct mutex core_lock;
862 /* Protects data like peers */
863 spinlock_t base_lock;
864 struct ath11k_pdev pdevs[MAX_RADIOS];
866 enum WMI_HOST_WLAN_BAND supported_bands;
868 } target_pdev_ids[MAX_RADIOS];
869 u8 target_pdev_count;
870 struct ath11k_pdev __rcu *pdevs_active[MAX_RADIOS];
871 struct ath11k_hal_reg_capabilities_ext hal_reg_cap[MAX_RADIOS];
872 unsigned long long free_vdev_map;
874 /* To synchronize rhash tbl write operation */
875 struct mutex tbl_mtx_lock;
877 /* The rhashtable containing struct ath11k_peer keyed by mac addr */
878 struct rhashtable *rhead_peer_addr;
879 struct rhashtable_params rhash_peer_addr_param;
881 /* The rhashtable containing struct ath11k_peer keyed by id */
882 struct rhashtable *rhead_peer_id;
883 struct rhashtable_params rhash_peer_id_param;
885 struct list_head peers;
886 wait_queue_head_t peer_mapping_wq;
887 u8 mac_addr[ETH_ALEN];
889 u32 wlan_init_status;
890 int irq_num[ATH11K_IRQ_NUM_MAX];
891 struct ath11k_ext_irq_grp ext_irq_grp[ATH11K_EXT_IRQ_GRP_NUM_MAX];
892 struct ath11k_targ_cap target_caps;
893 u32 ext_service_bitmap[WMI_SERVICE_EXT_BM_SIZE];
894 bool pdevs_macaddr_valid;
897 struct ath11k_hw_params hw_params;
899 const struct firmware *cal_file;
901 /* Below regd's are protected by ab->data_lock */
902 /* This is the regd set for every radio
903 * by the firmware during initialization
905 struct ieee80211_regdomain *default_regd[MAX_RADIOS];
906 /* This regd is set during dynamic country setting
907 * This may or may not be used during the runtime
909 struct ieee80211_regdomain *new_regd[MAX_RADIOS];
911 /* Current DFS Regulatory */
912 enum ath11k_dfs_region dfs_region;
913 #ifdef CONFIG_ATH11K_DEBUGFS
914 struct dentry *debugfs_soc;
916 struct ath11k_soc_dp_stats soc_stats;
918 unsigned long dev_flags;
919 struct completion driver_recovery;
920 struct workqueue_struct *workqueue;
921 struct work_struct restart_work;
922 struct work_struct update_11d_work;
924 struct workqueue_struct *workqueue_aux;
925 struct work_struct reset_work;
926 atomic_t reset_count;
927 atomic_t recovery_count;
928 atomic_t recovery_start_count;
930 struct completion reset_complete;
931 struct completion reconfigure_complete;
932 struct completion recovery_start;
933 /* continuous recovery fail count */
934 atomic_t fail_cont_count;
935 unsigned long reset_fail_timeout;
937 /* protected by data_lock */
938 u32 fw_crash_counter;
940 u32 pktlog_defs_checksum;
942 struct ath11k_dbring_cap *db_caps;
945 /* To synchronize 11d scan vdev id */
946 struct mutex vdev_id_11d_lock;
947 struct timer_list mon_reap_timer;
949 struct completion htc_suspend;
952 enum ath11k_bdf_search bdf_search;
955 u32 subsystem_vendor;
956 u32 subsystem_device;
961 const struct ath11k_msi_config *config;
968 const struct ath11k_pci_ops *ops;
972 u8 drv_priv[] __aligned(sizeof(void *));
975 struct ath11k_fw_stats_pdev {
976 struct list_head list;
980 /* Cycles spent transmitting frames */
982 /* Cycles spent receiving frames */
984 /* Total channel busy time, evidently */
986 /* Total on-channel time */
998 /* Num HTT cookies queued to dispatch list */
1000 /* Num HTT cookies dispatched */
1002 /* Num MSDU queued to WAL */
1004 /* Num MPDU queue to WAL */
1006 /* Num MSDUs dropped by WMM limit */
1008 /* Num Local frames queued */
1010 /* Num Local frames done */
1012 /* Num queued to HW */
1014 /* Num PPDU reaped from HW */
1020 /* Num PPDUs cleaned up in TX abort */
1022 /* Num MPDUs requeued by SW */
1024 /* excessive retries */
1027 /* data hw rate code */
1029 /* Scheduler self triggers */
1031 /* frames dropped due to excessive sw retries */
1032 u32 sw_retry_failure;
1033 /* illegal rate phy errors */
1034 u32 illgl_rate_phy_err;
1035 /* wal pdev continuous xretry */
1036 u32 pdev_cont_xretry;
1037 /* wal pdev tx timeouts */
1038 u32 pdev_tx_timeout;
1039 /* wal pdev resets */
1041 /* frames dropped due to non-availability of stateless TIDs */
1042 u32 stateless_tid_alloc_failure;
1043 /* PhY/BB underrun */
1045 /* MPDU is more than txop limit */
1047 /* Num sequences posted */
1049 /* Num sequences failed in queueing */
1050 u32 seq_failed_queueing;
1051 /* Num sequences completed */
1053 /* Num sequences restarted */
1055 /* Num of MU sequences posted */
1057 /* Num MPDUs flushed by SW, HWPAUSED, SW TXABORT
1058 * (Reset,channel change)
1061 /* Num MPDUs filtered by HW, all filter condition (TTL expired) */
1062 s32 mpdus_hw_filter;
1063 /* Num MPDUs truncated by PDG (TXOP, TBTT,
1064 * PPDU_duration based on rate, dyn_bw)
1066 s32 mpdus_truncated;
1067 /* Num MPDUs that was tried but didn't receive ACK or BA */
1068 s32 mpdus_ack_failed;
1069 /* Num MPDUs that was dropped du to expiry. */
1073 /* Cnts any change in ring routing mid-ppdu */
1074 s32 mid_ppdu_route_change;
1075 /* Total number of statuses processed */
1077 /* Extra frags on rings 0-3 */
1082 /* MSDUs / MPDUs delivered to HTT */
1085 /* MSDUs / MPDUs delivered to local stack */
1088 /* AMSDUs that have more MSDUs than the status ring size */
1090 /* Number of PHY errors */
1092 /* Number of PHY errors drops */
1094 /* Number of mpdu errors - FCS, MIC, ENC etc. */
1096 /* Num overflow errors */
1100 struct ath11k_fw_stats_vdev {
1101 struct list_head list;
1106 u32 num_tx_frames[WLAN_MAX_AC];
1108 u32 num_tx_frames_retries[WLAN_MAX_AC];
1109 u32 num_tx_frames_failures[WLAN_MAX_AC];
1111 u32 num_rts_success;
1114 u32 num_tx_not_acked;
1115 u32 tx_rate_history[MAX_TX_RATE_VALUES];
1116 u32 beacon_rssi_history[MAX_TX_RATE_VALUES];
1119 struct ath11k_fw_stats_bcn {
1120 struct list_head list;
1123 u32 tx_bcn_succ_cnt;
1124 u32 tx_bcn_outage_cnt;
1127 void ath11k_fw_stats_init(struct ath11k *ar);
1128 void ath11k_fw_stats_pdevs_free(struct list_head *head);
1129 void ath11k_fw_stats_vdevs_free(struct list_head *head);
1130 void ath11k_fw_stats_bcn_free(struct list_head *head);
1131 void ath11k_fw_stats_free(struct ath11k_fw_stats *stats);
1133 extern const struct ce_pipe_config ath11k_target_ce_config_wlan_ipq8074[];
1134 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq8074[];
1135 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq6018[];
1137 extern const struct ce_pipe_config ath11k_target_ce_config_wlan_qca6390[];
1138 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_qca6390[];
1140 extern const struct ce_pipe_config ath11k_target_ce_config_wlan_qcn9074[];
1141 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_qcn9074[];
1142 int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab);
1143 int ath11k_core_pre_init(struct ath11k_base *ab);
1144 int ath11k_core_init(struct ath11k_base *ath11k);
1145 void ath11k_core_deinit(struct ath11k_base *ath11k);
1146 struct ath11k_base *ath11k_core_alloc(struct device *dev, size_t priv_size,
1147 enum ath11k_bus bus);
1148 void ath11k_core_free(struct ath11k_base *ath11k);
1149 int ath11k_core_fetch_bdf(struct ath11k_base *ath11k,
1150 struct ath11k_board_data *bd);
1151 int ath11k_core_fetch_regdb(struct ath11k_base *ab, struct ath11k_board_data *bd);
1152 int ath11k_core_fetch_board_data_api_1(struct ath11k_base *ab,
1153 struct ath11k_board_data *bd,
1155 void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd);
1156 int ath11k_core_check_dt(struct ath11k_base *ath11k);
1157 int ath11k_core_check_smbios(struct ath11k_base *ab);
1158 void ath11k_core_halt(struct ath11k *ar);
1159 int ath11k_core_resume(struct ath11k_base *ab);
1160 int ath11k_core_suspend(struct ath11k_base *ab);
1162 const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab,
1163 const char *filename);
1165 static inline const char *ath11k_scan_state_str(enum ath11k_scan_state state)
1168 case ATH11K_SCAN_IDLE:
1170 case ATH11K_SCAN_STARTING:
1172 case ATH11K_SCAN_RUNNING:
1174 case ATH11K_SCAN_ABORTING:
1181 static inline struct ath11k_skb_cb *ATH11K_SKB_CB(struct sk_buff *skb)
1183 BUILD_BUG_ON(sizeof(struct ath11k_skb_cb) >
1184 IEEE80211_TX_INFO_DRIVER_DATA_SIZE);
1185 return (struct ath11k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
1188 static inline struct ath11k_skb_rxcb *ATH11K_SKB_RXCB(struct sk_buff *skb)
1190 BUILD_BUG_ON(sizeof(struct ath11k_skb_rxcb) > sizeof(skb->cb));
1191 return (struct ath11k_skb_rxcb *)skb->cb;
1194 static inline struct ath11k_vif *ath11k_vif_to_arvif(struct ieee80211_vif *vif)
1196 return (struct ath11k_vif *)vif->drv_priv;
1199 static inline struct ath11k *ath11k_ab_to_ar(struct ath11k_base *ab,
1202 return ab->pdevs[ath11k_hw_mac_id_to_pdev_id(&ab->hw_params, mac_id)].ar;
1205 static inline void ath11k_core_create_firmware_path(struct ath11k_base *ab,
1206 const char *filename,
1207 void *buf, size_t buf_len)
1209 snprintf(buf, buf_len, "%s/%s/%s", ATH11K_FW_DIR,
1210 ab->hw_params.fw.dir, filename);
1213 static inline const char *ath11k_bus_str(enum ath11k_bus bus)
1216 case ATH11K_BUS_PCI:
1218 case ATH11K_BUS_AHB:
1225 #endif /* _CORE_H_ */