Path: blob/main/sys/contrib/dev/athk/ath11k/core.h
105578 views
/* SPDX-License-Identifier: BSD-3-Clause-Clear */1/*2* Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.3* Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.4*/56#ifndef ATH11K_CORE_H7#define ATH11K_CORE_H89#include <linux/types.h>10#include <linux/interrupt.h>11#include <linux/irq.h>12#include <linux/bitfield.h>13#include <linux/dmi.h>14#include <linux/ctype.h>15#include <linux/rhashtable.h>16#include <linux/average.h>17#if defined(__FreeBSD__)18#include <linux/wait.h>19#endif20#include <linux/firmware.h>21#include <linux/suspend.h>22#if defined(CONFIG_OF)23#include <linux/of.h>24#endif2526#include "qmi.h"27#include "htc.h"28#include "wmi.h"29#include "hal.h"30#include "dp.h"31#include "ce.h"32#include "mac.h"33#include "hw.h"34#include "hal_rx.h"35#include "reg.h"36#include "thermal.h"37#include "dbring.h"38#include "spectral.h"39#include "wow.h"40#include "fw.h"41#include "coredump.h"4243#define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)4445#define ATH11K_TX_MGMT_NUM_PENDING_MAX 5124647#define ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI 644849/* Pending management packets threshold for dropping probe responses */50#define ATH11K_PRB_RSP_DROP_THRESHOLD ((ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI * 3) / 4)5152#define ATH11K_INVALID_HW_MAC_ID 0xFF53#define ATH11K_CONNECTION_LOSS_HZ (3 * HZ)5455/* SMBIOS type containing Board Data File Name Extension */56#define ATH11K_SMBIOS_BDF_EXT_TYPE 0xF85758/* SMBIOS type structure length (excluding strings-set) */59#define ATH11K_SMBIOS_BDF_EXT_LENGTH 0x96061/* The magic used by QCA spec */62#define ATH11K_SMBIOS_BDF_EXT_MAGIC "BDF_"6364extern unsigned int ath11k_frame_mode;65extern bool ath11k_ftm_mode;6667#define ATH11K_SCAN_TIMEOUT_HZ (20 * HZ)6869#define ATH11K_MON_TIMER_INTERVAL 1070#define ATH11K_RESET_TIMEOUT_HZ (20 * HZ)71#define ATH11K_RESET_MAX_FAIL_COUNT_FIRST 372#define ATH11K_RESET_MAX_FAIL_COUNT_FINAL 573#define ATH11K_RESET_FAIL_TIMEOUT_HZ (20 * HZ)74#define ATH11K_RECONFIGURE_TIMEOUT_HZ (10 * HZ)75#define ATH11K_RECOVER_START_TIMEOUT_HZ (20 * HZ)7677enum ath11k_supported_bw {78ATH11K_BW_20 = 0,79ATH11K_BW_40 = 1,80ATH11K_BW_80 = 2,81ATH11K_BW_160 = 3,82};8384enum ath11k_bdf_search {85ATH11K_BDF_SEARCH_DEFAULT,86ATH11K_BDF_SEARCH_BUS_AND_BOARD,87};8889#if defined(__FreeBSD__)90#ifdef WME_AC_BE91#undef WME_AC_BE92#endif93#ifdef WME_AC_BK94#undef WME_AC_BK95#endif96#ifdef WME_AC_VI97#undef WME_AC_VI98#endif99#ifdef WME_AC_VO100#undef WME_AC_VO101#endif102#ifdef WME_NUM_AC103#undef WME_NUM_AC104#endif105#endif106107enum wme_ac {108WME_AC_BE,109WME_AC_BK,110WME_AC_VI,111WME_AC_VO,112WME_NUM_AC113};114115#define ATH11K_HT_MCS_MAX 7116#define ATH11K_VHT_MCS_MAX 9117#define ATH11K_HE_MCS_MAX 11118119enum ath11k_crypt_mode {120/* Only use hardware crypto engine */121ATH11K_CRYPT_MODE_HW,122/* Only use software crypto */123ATH11K_CRYPT_MODE_SW,124};125126static inline enum wme_ac ath11k_tid_to_ac(u32 tid)127{128return (((tid == 0) || (tid == 3)) ? WME_AC_BE :129((tid == 1) || (tid == 2)) ? WME_AC_BK :130((tid == 4) || (tid == 5)) ? WME_AC_VI :131WME_AC_VO);132}133134enum ath11k_skb_flags {135ATH11K_SKB_HW_80211_ENCAP = BIT(0),136ATH11K_SKB_CIPHER_SET = BIT(1),137};138139struct ath11k_skb_cb {140dma_addr_t paddr;141u8 eid;142u8 flags;143u32 cipher;144struct ath11k *ar;145struct ieee80211_vif *vif;146} __packed;147148struct ath11k_skb_rxcb {149dma_addr_t paddr;150bool is_first_msdu;151bool is_last_msdu;152bool is_continuation;153bool is_mcbc;154bool is_eapol;155struct hal_rx_desc *rx_desc;156u8 err_rel_src;157u8 err_code;158u8 mac_id;159u8 unmapped;160u8 is_frag;161u8 tid;162u16 peer_id;163u16 seq_no;164};165166enum ath11k_hw_rev {167ATH11K_HW_IPQ8074,168ATH11K_HW_QCA6390_HW20,169ATH11K_HW_IPQ6018_HW10,170ATH11K_HW_QCN9074_HW10,171ATH11K_HW_WCN6855_HW20,172ATH11K_HW_WCN6855_HW21,173ATH11K_HW_WCN6750_HW10,174ATH11K_HW_IPQ5018_HW10,175ATH11K_HW_QCA2066_HW21,176ATH11K_HW_QCA6698AQ_HW21,177};178179enum ath11k_firmware_mode {180/* the default mode, standard 802.11 functionality */181ATH11K_FIRMWARE_MODE_NORMAL,182183/* factory tests etc */184ATH11K_FIRMWARE_MODE_FTM,185186/* Cold boot calibration */187ATH11K_FIRMWARE_MODE_COLD_BOOT = 7,188};189190extern bool ath11k_cold_boot_cal;191192#define ATH11K_IRQ_NUM_MAX 52193#define ATH11K_EXT_IRQ_NUM_MAX 16194195struct ath11k_ext_irq_grp {196struct ath11k_base *ab;197u32 irqs[ATH11K_EXT_IRQ_NUM_MAX];198u32 num_irq;199u32 grp_id;200u64 timestamp;201bool napi_enabled;202struct napi_struct napi;203struct net_device *napi_ndev;204};205206enum ath11k_smbios_cc_type {207/* disable country code setting from SMBIOS */208ATH11K_SMBIOS_CC_DISABLE = 0,209210/* set country code by ANSI country name, based on ISO3166-1 alpha2 */211ATH11K_SMBIOS_CC_ISO = 1,212213/* worldwide regdomain */214ATH11K_SMBIOS_CC_WW = 2,215};216217struct ath11k_smbios_bdf {218struct dmi_header hdr;219220u8 features_disabled;221222/* enum ath11k_smbios_cc_type */223u8 country_code_flag;224225/* To set specific country, you need to set country code226* flag=ATH11K_SMBIOS_CC_ISO first, then if country is United227* States, then country code value = 0x5553 ("US",'U' = 0x55, 'S'=228* 0x53). To set country to INDONESIA, then country code value =229* 0x4944 ("IN", 'I'=0x49, 'D'=0x44). If country code flag =230* ATH11K_SMBIOS_CC_WW, then you can use worldwide regulatory231* setting.232*/233u16 cc_code;234235u8 bdf_enabled;236u8 bdf_ext[];237} __packed;238239#define HEHANDLE_CAP_PHYINFO_SIZE 3240#define HECAP_PHYINFO_SIZE 9241#define HECAP_MACINFO_SIZE 5242#define HECAP_TXRX_MCS_NSS_SIZE 2243#define HECAP_PPET16_PPET8_MAX_SIZE 25244245#define HE_PPET16_PPET8_SIZE 8246247/* 802.11ax PPE (PPDU packet Extension) threshold */248struct he_ppe_threshold {249u32 numss_m1;250u32 ru_mask;251u32 ppet16_ppet8_ru3_ru0[HE_PPET16_PPET8_SIZE];252};253254struct ath11k_he {255u8 hecap_macinfo[HECAP_MACINFO_SIZE];256u32 hecap_rxmcsnssmap;257u32 hecap_txmcsnssmap;258u32 hecap_phyinfo[HEHANDLE_CAP_PHYINFO_SIZE];259struct he_ppe_threshold hecap_ppet;260u32 heop_param;261};262263#define MAX_RADIOS 3264265/* ipq5018 hw param macros */266#define MAX_RADIOS_5018 1267#define CE_CNT_5018 6268#define TARGET_CE_CNT_5018 9269#define SVC_CE_MAP_LEN_5018 17270#define RXDMA_PER_PDEV_5018 1271272enum {273WMI_HOST_TP_SCALE_MAX = 0,274WMI_HOST_TP_SCALE_50 = 1,275WMI_HOST_TP_SCALE_25 = 2,276WMI_HOST_TP_SCALE_12 = 3,277WMI_HOST_TP_SCALE_MIN = 4,278WMI_HOST_TP_SCALE_SIZE = 5,279};280281enum ath11k_scan_state {282ATH11K_SCAN_IDLE,283ATH11K_SCAN_STARTING,284ATH11K_SCAN_RUNNING,285ATH11K_SCAN_ABORTING,286};287288enum ath11k_11d_state {289ATH11K_11D_IDLE,290ATH11K_11D_PREPARING,291ATH11K_11D_RUNNING,292};293294enum ath11k_dev_flags {295ATH11K_CAC_RUNNING,296ATH11K_FLAG_CORE_REGISTERED,297ATH11K_FLAG_CRASH_FLUSH,298ATH11K_FLAG_RAW_MODE,299ATH11K_FLAG_HW_CRYPTO_DISABLED,300ATH11K_FLAG_BTCOEX,301ATH11K_FLAG_RECOVERY,302ATH11K_FLAG_UNREGISTERING,303ATH11K_FLAG_REGISTERED,304ATH11K_FLAG_QMI_FAIL,305ATH11K_FLAG_HTC_SUSPEND_COMPLETE,306ATH11K_FLAG_CE_IRQ_ENABLED,307ATH11K_FLAG_EXT_IRQ_ENABLED,308ATH11K_FLAG_FIXED_MEM_RGN,309ATH11K_FLAG_DEVICE_INIT_DONE,310ATH11K_FLAG_MULTI_MSI_VECTORS,311ATH11K_FLAG_FTM_SEGMENTED,312};313314enum ath11k_monitor_flags {315ATH11K_FLAG_MONITOR_CONF_ENABLED,316ATH11K_FLAG_MONITOR_STARTED,317ATH11K_FLAG_MONITOR_VDEV_CREATED,318};319320#define ATH11K_IPV6_UC_TYPE 0321#define ATH11K_IPV6_AC_TYPE 1322323#define ATH11K_IPV6_MAX_COUNT 16324#define ATH11K_IPV4_MAX_COUNT 2325326struct ath11k_arp_ns_offload {327u8 ipv4_addr[ATH11K_IPV4_MAX_COUNT][4];328u32 ipv4_count;329u32 ipv6_count;330u8 ipv6_addr[ATH11K_IPV6_MAX_COUNT][16];331u8 self_ipv6_addr[ATH11K_IPV6_MAX_COUNT][16];332u8 ipv6_type[ATH11K_IPV6_MAX_COUNT];333bool ipv6_valid[ATH11K_IPV6_MAX_COUNT];334u8 mac_addr[ETH_ALEN];335};336337struct ath11k_rekey_data {338u8 kck[NL80211_KCK_LEN];339u8 kek[NL80211_KCK_LEN];340u64 replay_ctr;341bool enable_offload;342};343344/**345* struct ath11k_chan_power_info - TPE containing power info per channel chunk346* @chan_cfreq: channel center freq (MHz)347* e.g.348* channel 37/20 MHz, it is 6135349* channel 37/40 MHz, it is 6125350* channel 37/80 MHz, it is 6145351* channel 37/160 MHz, it is 6185352* @tx_power: transmit power (dBm)353*/354struct ath11k_chan_power_info {355u16 chan_cfreq;356s8 tx_power;357};358359/* ath11k only deals with 160 MHz, so 8 subchannels */360#define ATH11K_NUM_PWR_LEVELS 8361362/**363* struct ath11k_reg_tpc_power_info - regulatory TPC power info364* @is_psd_power: is PSD power or not365* @eirp_power: Maximum EIRP power (dBm), valid only if power is PSD366* @ap_power_type: type of power (SP/LPI/VLP)367* @num_pwr_levels: number of power levels368* @reg_max: Array of maximum TX power (dBm) per PSD value369* @tpe: TPE values processed from TPE IE370* @chan_power_info: power info to send to firmware371*/372struct ath11k_reg_tpc_power_info {373bool is_psd_power;374u8 eirp_power;375enum wmi_reg_6ghz_ap_type ap_power_type;376u8 num_pwr_levels;377u8 reg_max[ATH11K_NUM_PWR_LEVELS];378s8 tpe[ATH11K_NUM_PWR_LEVELS];379struct ath11k_chan_power_info chan_power_info[ATH11K_NUM_PWR_LEVELS];380};381382struct ath11k_vif {383u32 vdev_id;384enum wmi_vdev_type vdev_type;385enum wmi_vdev_subtype vdev_subtype;386u32 beacon_interval;387u32 dtim_period;388u16 ast_hash;389u16 ast_idx;390u16 tcl_metadata;391u8 hal_addr_search_flags;392u8 search_type;393394struct ath11k *ar;395struct ieee80211_vif *vif;396397struct wmi_wmm_params_all_arg wmm_params;398struct wmi_wmm_params_all_arg muedca_params;399struct list_head list;400union {401struct {402u32 uapsd;403} sta;404struct {405/* 127 stations; wmi limit */406u8 tim_bitmap[16];407u8 tim_len;408u32 ssid_len;409u8 ssid[IEEE80211_MAX_SSID_LEN];410bool hidden_ssid;411/* P2P_IE with NoA attribute for P2P_GO case */412u32 noa_len;413u8 *noa_data;414} ap;415} u;416417bool is_started;418bool is_up;419bool ftm_responder;420bool spectral_enabled;421bool ps;422u32 aid;423u8 bssid[ETH_ALEN];424struct cfg80211_bitrate_mask bitrate_mask;425struct delayed_work connection_loss_work;426struct work_struct bcn_tx_work;427int num_legacy_stations;428int rtscts_prot_mode;429int txpower;430bool rsnie_present;431bool wpaie_present;432bool bcca_zero_sent;433bool do_not_send_tmpl;434struct ath11k_arp_ns_offload arp_ns_offload;435struct ath11k_rekey_data rekey_data;436u32 num_stations;437bool reinstall_group_keys;438439struct ath11k_reg_tpc_power_info reg_tpc_info;440441/* Must be last - ends in a flexible-array member.442*443* FIXME: Driver should not copy struct ieee80211_chanctx_conf,444* especially because it has a flexible array. Find a better way.445*/446struct ieee80211_chanctx_conf chanctx;447};448449struct ath11k_vif_iter {450u32 vdev_id;451struct ath11k_vif *arvif;452};453454struct ath11k_rx_peer_stats {455u64 num_msdu;456u64 num_mpdu_fcs_ok;457u64 num_mpdu_fcs_err;458u64 tcp_msdu_count;459u64 udp_msdu_count;460u64 other_msdu_count;461u64 ampdu_msdu_count;462u64 non_ampdu_msdu_count;463u64 stbc_count;464u64 beamformed_count;465u64 mcs_count[HAL_RX_MAX_MCS + 1];466u64 nss_count[HAL_RX_MAX_NSS];467u64 bw_count[HAL_RX_BW_MAX];468u64 gi_count[HAL_RX_GI_MAX];469u64 coding_count[HAL_RX_SU_MU_CODING_MAX];470u64 tid_count[IEEE80211_NUM_TIDS + 1];471u64 pream_cnt[HAL_RX_PREAMBLE_MAX];472u64 reception_type[HAL_RX_RECEPTION_TYPE_MAX];473u64 rx_duration;474u64 dcm_count;475u64 ru_alloc_cnt[HAL_RX_RU_ALLOC_TYPE_MAX];476};477478#define ATH11K_HE_MCS_NUM 12479#define ATH11K_VHT_MCS_NUM 10480#define ATH11K_BW_NUM 4481#define ATH11K_NSS_NUM 4482#define ATH11K_LEGACY_NUM 12483#define ATH11K_GI_NUM 4484#define ATH11K_HT_MCS_NUM 32485486enum ath11k_pkt_rx_err {487ATH11K_PKT_RX_ERR_FCS,488ATH11K_PKT_RX_ERR_TKIP,489ATH11K_PKT_RX_ERR_CRYPT,490ATH11K_PKT_RX_ERR_PEER_IDX_INVAL,491ATH11K_PKT_RX_ERR_MAX,492};493494enum ath11k_ampdu_subfrm_num {495ATH11K_AMPDU_SUBFRM_NUM_10,496ATH11K_AMPDU_SUBFRM_NUM_20,497ATH11K_AMPDU_SUBFRM_NUM_30,498ATH11K_AMPDU_SUBFRM_NUM_40,499ATH11K_AMPDU_SUBFRM_NUM_50,500ATH11K_AMPDU_SUBFRM_NUM_60,501ATH11K_AMPDU_SUBFRM_NUM_MORE,502ATH11K_AMPDU_SUBFRM_NUM_MAX,503};504505enum ath11k_amsdu_subfrm_num {506ATH11K_AMSDU_SUBFRM_NUM_1,507ATH11K_AMSDU_SUBFRM_NUM_2,508ATH11K_AMSDU_SUBFRM_NUM_3,509ATH11K_AMSDU_SUBFRM_NUM_4,510ATH11K_AMSDU_SUBFRM_NUM_MORE,511ATH11K_AMSDU_SUBFRM_NUM_MAX,512};513514enum ath11k_counter_type {515ATH11K_COUNTER_TYPE_BYTES,516ATH11K_COUNTER_TYPE_PKTS,517ATH11K_COUNTER_TYPE_MAX,518};519520enum ath11k_stats_type {521ATH11K_STATS_TYPE_SUCC,522ATH11K_STATS_TYPE_FAIL,523ATH11K_STATS_TYPE_RETRY,524ATH11K_STATS_TYPE_AMPDU,525ATH11K_STATS_TYPE_MAX,526};527528struct ath11k_htt_data_stats {529u64 legacy[ATH11K_COUNTER_TYPE_MAX][ATH11K_LEGACY_NUM];530u64 ht[ATH11K_COUNTER_TYPE_MAX][ATH11K_HT_MCS_NUM];531u64 vht[ATH11K_COUNTER_TYPE_MAX][ATH11K_VHT_MCS_NUM];532u64 he[ATH11K_COUNTER_TYPE_MAX][ATH11K_HE_MCS_NUM];533u64 bw[ATH11K_COUNTER_TYPE_MAX][ATH11K_BW_NUM];534u64 nss[ATH11K_COUNTER_TYPE_MAX][ATH11K_NSS_NUM];535u64 gi[ATH11K_COUNTER_TYPE_MAX][ATH11K_GI_NUM];536};537538struct ath11k_htt_tx_stats {539struct ath11k_htt_data_stats stats[ATH11K_STATS_TYPE_MAX];540u64 tx_duration;541u64 ba_fails;542u64 ack_fails;543};544545struct ath11k_per_ppdu_tx_stats {546u16 succ_pkts;547u16 failed_pkts;548u16 retry_pkts;549u32 succ_bytes;550u32 failed_bytes;551u32 retry_bytes;552};553554DECLARE_EWMA(avg_rssi, 10, 8)555556struct ath11k_sta {557struct ath11k_vif *arvif;558559/* the following are protected by ar->data_lock */560u32 changed; /* IEEE80211_RC_* */561u32 bw;562u32 nss;563u32 smps;564enum hal_pn_type pn_type;565566struct work_struct update_wk;567struct work_struct set_4addr_wk;568struct rate_info txrate;569u32 peer_nss;570struct rate_info last_txrate;571u64 rx_duration;572u64 tx_duration;573u8 rssi_comb;574struct ewma_avg_rssi avg_rssi;575s8 rssi_beacon;576s8 chain_signal[IEEE80211_MAX_CHAINS];577struct ath11k_htt_tx_stats *tx_stats;578struct ath11k_rx_peer_stats *rx_stats;579580#ifdef CONFIG_MAC80211_DEBUGFS581/* protected by conf_mutex */582bool aggr_mode;583#endif584585bool use_4addr_set;586u16 tcl_metadata;587588/* Protected with ar->data_lock */589enum ath11k_wmi_peer_ps_state peer_ps_state;590u64 ps_start_time;591u64 ps_start_jiffies;592u64 ps_total_duration;593bool peer_current_ps_valid;594595u32 bw_prev;596};597598#define ATH11K_MIN_5G_FREQ 4150599#define ATH11K_MIN_6G_FREQ 5925600#define ATH11K_MAX_6G_FREQ 7115601#define ATH11K_NUM_CHANS 102602#define ATH11K_MAX_5G_CHAN 177603604enum ath11k_state {605ATH11K_STATE_OFF,606ATH11K_STATE_ON,607ATH11K_STATE_RESTARTING,608ATH11K_STATE_RESTARTED,609ATH11K_STATE_WEDGED,610ATH11K_STATE_FTM,611/* Add other states as required */612};613614/* Antenna noise floor */615#define ATH11K_DEFAULT_NOISE_FLOOR -95616617#define ATH11K_INVALID_RSSI_FULL -1618619#define ATH11K_INVALID_RSSI_EMPTY -128620621struct ath11k_fw_stats {622struct dentry *debugfs_fwstats;623u32 pdev_id;624u32 stats_id;625struct list_head pdevs;626struct list_head vdevs;627struct list_head bcn;628u32 num_vdev_recvd;629u32 num_bcn_recvd;630};631632struct ath11k_dbg_htt_stats {633u8 type;634u8 reset;635struct debug_htt_stats_req *stats_req;636/* protects shared stats req buffer */637spinlock_t lock;638};639640#define MAX_MODULE_ID_BITMAP_WORDS 16641642struct ath11k_debug {643struct dentry *debugfs_pdev;644struct ath11k_dbg_htt_stats htt_stats;645u32 extd_tx_stats;646u32 extd_rx_stats;647u32 pktlog_filter;648u32 pktlog_mode;649u32 pktlog_peer_valid;650u8 pktlog_peer_addr[ETH_ALEN];651u32 rx_filter;652u32 mem_offset;653u32 module_id_bitmap[MAX_MODULE_ID_BITMAP_WORDS];654struct ath11k_debug_dbr *dbr_debug[WMI_DIRECT_BUF_MAX];655};656657struct ath11k_per_peer_tx_stats {658u32 succ_bytes;659u32 retry_bytes;660u32 failed_bytes;661u16 succ_pkts;662u16 retry_pkts;663u16 failed_pkts;664u32 duration;665u8 ba_fails;666bool is_ampdu;667};668669#define ATH11K_FLUSH_TIMEOUT (5 * HZ)670#define ATH11K_VDEV_DELETE_TIMEOUT_HZ (5 * HZ)671672struct ath11k {673struct ath11k_base *ab;674struct ath11k_pdev *pdev;675struct ieee80211_hw *hw;676struct ath11k_pdev_wmi *wmi;677struct ath11k_pdev_dp dp;678u8 mac_addr[ETH_ALEN];679struct ath11k_he ar_he;680enum ath11k_state state;681bool supports_6ghz;682struct {683struct completion started;684struct completion completed;685struct completion on_channel;686struct delayed_work timeout;687enum ath11k_scan_state state;688bool is_roc;689int vdev_id;690int roc_freq;691bool roc_notify;692} scan;693694struct {695struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];696struct ieee80211_sband_iftype_data697iftype[NUM_NL80211_BANDS][NUM_NL80211_IFTYPES];698} mac;699700unsigned long dev_flags;701unsigned int filter_flags;702unsigned long monitor_flags;703u32 min_tx_power;704u32 max_tx_power;705u32 txpower_limit_2g;706u32 txpower_limit_5g;707u32 txpower_scale;708u32 power_scale;709u32 chan_tx_pwr;710u32 num_stations;711u32 max_num_stations;712/* To synchronize concurrent synchronous mac80211 callback operations,713* concurrent debugfs configuration and concurrent FW statistics events.714*/715struct mutex conf_mutex;716/* protects the radio specific data like debug stats, ppdu_stats_info stats,717* vdev_stop_status info, scan data, ath11k_sta info, ath11k_vif info,718* channel context data, survey info, test mode data, channel_update_queue.719*/720spinlock_t data_lock;721722struct list_head arvifs;723/* should never be NULL; needed for regular htt rx */724struct ieee80211_channel *rx_channel;725726/* valid during scan; needed for mgmt rx during scan */727struct ieee80211_channel *scan_channel;728729u8 cfg_tx_chainmask;730u8 cfg_rx_chainmask;731u8 num_rx_chains;732u8 num_tx_chains;733/* pdev_idx starts from 0 whereas pdev->pdev_id starts with 1 */734u8 pdev_idx;735u8 lmac_id;736737struct completion peer_assoc_done;738struct completion peer_delete_done;739740int install_key_status;741struct completion install_key_done;742743int last_wmi_vdev_start_status;744struct completion vdev_setup_done;745struct completion vdev_delete_done;746747int num_peers;748int max_num_peers;749u32 num_started_vdevs;750u32 num_created_vdevs;751unsigned long long allocated_vdev_map;752753struct idr txmgmt_idr;754/* protects txmgmt_idr data */755spinlock_t txmgmt_idr_lock;756atomic_t num_pending_mgmt_tx;757wait_queue_head_t txmgmt_empty_waitq;758759/* cycle count is reported twice for each visited channel during scan.760* access protected by data_lock761*/762u32 survey_last_rx_clear_count;763u32 survey_last_cycle_count;764765/* Channel info events are expected to come in pairs without and with766* COMPLETE flag set respectively for each channel visit during scan.767*768* However there are deviations from this rule. This flag is used to769* avoid reporting garbage data.770*/771bool ch_info_can_report_survey;772struct survey_info survey[ATH11K_NUM_CHANS];773struct completion bss_survey_done;774775struct work_struct regd_update_work;776struct work_struct channel_update_work;777/* protected with data_lock */778struct list_head channel_update_queue;779780struct work_struct wmi_mgmt_tx_work;781struct sk_buff_head wmi_mgmt_tx_queue;782783struct ath11k_wow wow;784struct completion target_suspend;785bool target_suspend_ack;786struct ath11k_per_peer_tx_stats peer_tx_stats;787struct list_head ppdu_stats_info;788u32 ppdu_stat_list_depth;789790struct ath11k_per_peer_tx_stats cached_stats;791u32 last_ppdu_id;792u32 cached_ppdu_id;793int monitor_vdev_id;794struct completion fw_mode_reset;795u8 ftm_msgref;796#ifdef CONFIG_ATH11K_DEBUGFS797struct ath11k_debug debug;798#endif799#ifdef CONFIG_ATH11K_SPECTRAL800struct ath11k_spectral spectral;801#endif802bool dfs_block_radar_events;803struct ath11k_thermal thermal;804u32 vdev_id_11d_scan;805struct completion completed_11d_scan;806enum ath11k_11d_state state_11d;807bool regdom_set_by_user;808int hw_rate_code;809u8 twt_enabled;810bool nlo_enabled;811u8 alpha2[REG_ALPHA2_LEN + 1];812struct ath11k_fw_stats fw_stats;813struct completion fw_stats_complete;814struct completion fw_stats_done;815816/* protected by conf_mutex */817bool ps_state_enable;818bool ps_timekeeper_enable;819s8 max_allowed_tx_power;820};821822struct ath11k_band_cap {823u32 phy_id;824u32 max_bw_supported;825u32 ht_cap_info;826u32 he_cap_info[2];827u32 he_mcs;828u32 he_cap_phy_info[PSOC_HOST_MAX_PHY_SIZE];829struct ath11k_ppe_threshold he_ppet;830u16 he_6ghz_capa;831};832833struct ath11k_pdev_cap {834u32 supported_bands;835u32 ampdu_density;836u32 vht_cap;837u32 vht_mcs;838u32 he_mcs;839u32 tx_chain_mask;840u32 rx_chain_mask;841u32 tx_chain_mask_shift;842u32 rx_chain_mask_shift;843struct ath11k_band_cap band[NUM_NL80211_BANDS];844bool nss_ratio_enabled;845u8 nss_ratio_info;846};847848struct ath11k_pdev {849struct ath11k *ar;850u32 pdev_id;851struct ath11k_pdev_cap cap;852u8 mac_addr[ETH_ALEN];853};854855struct ath11k_board_data {856const struct firmware *fw;857const void *data;858size_t len;859};860861struct ath11k_pci_ops {862int (*wakeup)(struct ath11k_base *ab);863void (*release)(struct ath11k_base *ab);864int (*get_msi_irq)(struct ath11k_base *ab, unsigned int vector);865void (*window_write32)(struct ath11k_base *ab, u32 offset, u32 value);866u32 (*window_read32)(struct ath11k_base *ab, u32 offset);867};868869/* IPQ8074 HW channel counters frequency value in hertz */870#define IPQ8074_CC_FREQ_HERTZ 320000871872struct ath11k_bp_stats {873/* Head Pointer reported by the last HTT Backpressure event for the ring */874u16 hp;875876/* Tail Pointer reported by the last HTT Backpressure event for the ring */877u16 tp;878879/* Number of Backpressure events received for the ring */880u32 count;881882/* Last recorded event timestamp */883unsigned long jiffies;884};885886struct ath11k_dp_ring_bp_stats {887struct ath11k_bp_stats umac_ring_bp_stats[HTT_SW_UMAC_RING_IDX_MAX];888struct ath11k_bp_stats lmac_ring_bp_stats[HTT_SW_LMAC_RING_IDX_MAX][MAX_RADIOS];889};890891struct ath11k_soc_dp_tx_err_stats {892/* TCL Ring Descriptor unavailable */893u32 desc_na[DP_TCL_NUM_RING_MAX];894/* Other failures during dp_tx due to mem allocation failure895* idr unavailable etc.896*/897atomic_t misc_fail;898};899900struct ath11k_soc_dp_stats {901u32 err_ring_pkts;902u32 invalid_rbm;903u32 rxdma_error[HAL_REO_ENTR_RING_RXDMA_ECODE_MAX];904u32 reo_error[HAL_REO_DEST_RING_ERROR_CODE_MAX];905u32 hal_reo_error[DP_REO_DST_RING_MAX];906struct ath11k_soc_dp_tx_err_stats tx_err;907struct ath11k_dp_ring_bp_stats bp_stats;908};909910struct ath11k_msi_user {911char *name;912int num_vectors;913u32 base_vector;914};915916struct ath11k_msi_config {917int total_vectors;918int total_users;919struct ath11k_msi_user *users;920u16 hw_rev;921};922923enum ath11k_pm_policy {924ATH11K_PM_DEFAULT,925ATH11K_PM_WOW,926};927928/* Master structure to hold the hw data which may be used in core module */929struct ath11k_base {930enum ath11k_hw_rev hw_rev;931enum ath11k_firmware_mode fw_mode;932struct platform_device *pdev;933struct device *dev;934struct ath11k_qmi qmi;935struct ath11k_wmi_base wmi_ab;936struct completion fw_ready;937int num_radios;938/* HW channel counters frequency value in hertz common to all MACs */939u32 cc_freq_hz;940941struct ath11k_dump_file_data *dump_data;942size_t ath11k_coredump_len;943struct work_struct dump_work;944945struct ath11k_htc htc;946947struct ath11k_dp dp;948949void __iomem *mem;950void __iomem *mem_ce;951unsigned long mem_len;952953struct {954enum ath11k_bus bus;955const struct ath11k_hif_ops *ops;956} hif;957958struct {959struct completion wakeup_completed;960} wow;961962struct ath11k_ce ce;963struct timer_list rx_replenish_retry;964struct ath11k_hal hal;965/* To synchronize core_start/core_stop */966struct mutex core_lock;967/* Protects data like peers */968spinlock_t base_lock;969struct ath11k_pdev pdevs[MAX_RADIOS];970struct {971enum WMI_HOST_WLAN_BAND supported_bands;972u32 pdev_id;973} target_pdev_ids[MAX_RADIOS];974u8 target_pdev_count;975struct ath11k_pdev __rcu *pdevs_active[MAX_RADIOS];976struct ath11k_hal_reg_capabilities_ext hal_reg_cap[MAX_RADIOS];977unsigned long long free_vdev_map;978979/* To synchronize rhash tbl write operation */980struct mutex tbl_mtx_lock;981982/* The rhashtable containing struct ath11k_peer keyed by mac addr */983struct rhashtable *rhead_peer_addr;984struct rhashtable_params rhash_peer_addr_param;985986/* The rhashtable containing struct ath11k_peer keyed by id */987struct rhashtable *rhead_peer_id;988struct rhashtable_params rhash_peer_id_param;989990struct list_head peers;991wait_queue_head_t peer_mapping_wq;992u8 mac_addr[ETH_ALEN];993int irq_num[ATH11K_IRQ_NUM_MAX];994struct ath11k_ext_irq_grp ext_irq_grp[ATH11K_EXT_IRQ_GRP_NUM_MAX];995struct ath11k_targ_cap target_caps;996u32 ext_service_bitmap[WMI_SERVICE_EXT_BM_SIZE];997bool pdevs_macaddr_valid;998999struct ath11k_hw_params hw_params;10001001const struct firmware *cal_file;10021003/* Below regd's are protected by ab->data_lock */1004/* This is the regd set for every radio1005* by the firmware during initialization1006*/1007struct ieee80211_regdomain *default_regd[MAX_RADIOS];1008/* This regd is set during dynamic country setting1009* This may or may not be used during the runtime1010*/1011struct ieee80211_regdomain *new_regd[MAX_RADIOS];1012struct cur_regulatory_info *reg_info_store;10131014/* Current DFS Regulatory */1015enum ath11k_dfs_region dfs_region;1016#ifdef CONFIG_ATH11K_DEBUGFS1017struct dentry *debugfs_soc;1018#endif1019struct ath11k_soc_dp_stats soc_stats;10201021unsigned long dev_flags;1022struct completion driver_recovery;1023struct workqueue_struct *workqueue;1024struct work_struct restart_work;1025struct work_struct update_11d_work;1026u8 new_alpha2[3];1027struct workqueue_struct *workqueue_aux;1028struct work_struct reset_work;1029atomic_t reset_count;1030atomic_t recovery_count;1031atomic_t recovery_start_count;1032bool is_reset;1033struct completion reset_complete;1034struct completion reconfigure_complete;1035struct completion recovery_start;1036/* continuous recovery fail count */1037atomic_t fail_cont_count;1038unsigned long reset_fail_timeout;1039struct {1040/* protected by data_lock */1041u32 fw_crash_counter;1042} stats;1043u32 pktlog_defs_checksum;10441045struct ath11k_dbring_cap *db_caps;1046u32 num_db_cap;10471048/* To synchronize 11d scan vdev id */1049struct mutex vdev_id_11d_lock;1050struct timer_list mon_reap_timer;10511052struct completion htc_suspend;10531054struct {1055enum ath11k_bdf_search bdf_search;1056u32 vendor;1057u32 device;1058u32 subsystem_vendor;1059u32 subsystem_device;1060} id;10611062struct {1063struct {1064const struct ath11k_msi_config *config;1065u32 ep_base_data;1066u32 irqs[32];1067u32 addr_lo;1068u32 addr_hi;1069} msi;10701071const struct ath11k_pci_ops *ops;1072} pci;10731074struct {1075u32 api_version;10761077const struct firmware *fw;1078const u8 *amss_data;1079size_t amss_len;1080const u8 *m3_data;1081size_t m3_len;10821083DECLARE_BITMAP(fw_features, ATH11K_FW_FEATURE_COUNT);1084} fw;10851086struct completion restart_completed;10871088#ifdef CONFIG_NL80211_TESTMODE1089struct {1090u32 data_pos;1091u32 expected_seq;1092u8 *eventdata;1093} testmode;1094#endif10951096enum ath11k_pm_policy pm_policy;1097enum ath11k_pm_policy actual_pm_policy;1098struct notifier_block pm_nb;10991100/* must be last */1101u8 drv_priv[] __aligned(sizeof(void *));1102};11031104struct ath11k_fw_stats_pdev {1105struct list_head list;11061107/* PDEV stats */1108s32 ch_noise_floor;1109/* Cycles spent transmitting frames */1110u32 tx_frame_count;1111/* Cycles spent receiving frames */1112u32 rx_frame_count;1113/* Total channel busy time, evidently */1114u32 rx_clear_count;1115/* Total on-channel time */1116u32 cycle_count;1117u32 phy_err_count;1118u32 chan_tx_power;1119u32 ack_rx_bad;1120u32 rts_bad;1121u32 rts_good;1122u32 fcs_bad;1123u32 no_beacons;1124u32 mib_int_count;11251126/* PDEV TX stats */1127/* Num HTT cookies queued to dispatch list */1128s32 comp_queued;1129/* Num HTT cookies dispatched */1130s32 comp_delivered;1131/* Num MSDU queued to WAL */1132s32 msdu_enqued;1133/* Num MPDU queue to WAL */1134s32 mpdu_enqued;1135/* Num MSDUs dropped by WMM limit */1136s32 wmm_drop;1137/* Num Local frames queued */1138s32 local_enqued;1139/* Num Local frames done */1140s32 local_freed;1141/* Num queued to HW */1142s32 hw_queued;1143/* Num PPDU reaped from HW */1144s32 hw_reaped;1145/* Num underruns */1146s32 underrun;1147/* Num hw paused */1148u32 hw_paused;1149/* Num PPDUs cleaned up in TX abort */1150s32 tx_abort;1151/* Num MPDUs requeued by SW */1152s32 mpdus_requeued;1153/* excessive retries */1154u32 tx_ko;1155u32 tx_xretry;1156/* data hw rate code */1157u32 data_rc;1158/* Scheduler self triggers */1159u32 self_triggers;1160/* frames dropped due to excessive sw retries */1161u32 sw_retry_failure;1162/* illegal rate phy errors */1163u32 illgl_rate_phy_err;1164/* wal pdev continuous xretry */1165u32 pdev_cont_xretry;1166/* wal pdev tx timeouts */1167u32 pdev_tx_timeout;1168/* wal pdev resets */1169u32 pdev_resets;1170/* frames dropped due to non-availability of stateless TIDs */1171u32 stateless_tid_alloc_failure;1172/* PhY/BB underrun */1173u32 phy_underrun;1174/* MPDU is more than txop limit */1175u32 txop_ovf;1176/* Num sequences posted */1177u32 seq_posted;1178/* Num sequences failed in queueing */1179u32 seq_failed_queueing;1180/* Num sequences completed */1181u32 seq_completed;1182/* Num sequences restarted */1183u32 seq_restarted;1184/* Num of MU sequences posted */1185u32 mu_seq_posted;1186/* Num MPDUs flushed by SW, HWPAUSED, SW TXABORT1187* (Reset,channel change)1188*/1189s32 mpdus_sw_flush;1190/* Num MPDUs filtered by HW, all filter condition (TTL expired) */1191s32 mpdus_hw_filter;1192/* Num MPDUs truncated by PDG (TXOP, TBTT,1193* PPDU_duration based on rate, dyn_bw)1194*/1195s32 mpdus_truncated;1196/* Num MPDUs that was tried but didn't receive ACK or BA */1197s32 mpdus_ack_failed;1198/* Num MPDUs that was dropped du to expiry. */1199s32 mpdus_expired;12001201/* PDEV RX stats */1202/* Cnts any change in ring routing mid-ppdu */1203s32 mid_ppdu_route_change;1204/* Total number of statuses processed */1205s32 status_rcvd;1206/* Extra frags on rings 0-3 */1207s32 r0_frags;1208s32 r1_frags;1209s32 r2_frags;1210s32 r3_frags;1211/* MSDUs / MPDUs delivered to HTT */1212s32 htt_msdus;1213s32 htt_mpdus;1214/* MSDUs / MPDUs delivered to local stack */1215s32 loc_msdus;1216s32 loc_mpdus;1217/* AMSDUs that have more MSDUs than the status ring size */1218s32 oversize_amsdu;1219/* Number of PHY errors */1220s32 phy_errs;1221/* Number of PHY errors drops */1222s32 phy_err_drop;1223/* Number of mpdu errors - FCS, MIC, ENC etc. */1224s32 mpdu_errs;1225/* Num overflow errors */1226s32 rx_ovfl_errs;1227};12281229struct ath11k_fw_stats_vdev {1230struct list_head list;12311232u32 vdev_id;1233u32 beacon_snr;1234u32 data_snr;1235u32 num_tx_frames[WLAN_MAX_AC];1236u32 num_rx_frames;1237u32 num_tx_frames_retries[WLAN_MAX_AC];1238u32 num_tx_frames_failures[WLAN_MAX_AC];1239u32 num_rts_fail;1240u32 num_rts_success;1241u32 num_rx_err;1242u32 num_rx_discard;1243u32 num_tx_not_acked;1244u32 tx_rate_history[MAX_TX_RATE_VALUES];1245u32 beacon_rssi_history[MAX_TX_RATE_VALUES];1246};12471248struct ath11k_fw_stats_bcn {1249struct list_head list;12501251u32 vdev_id;1252u32 tx_bcn_succ_cnt;1253u32 tx_bcn_outage_cnt;1254};12551256void ath11k_fw_stats_init(struct ath11k *ar);1257void ath11k_fw_stats_pdevs_free(struct list_head *head);1258void ath11k_fw_stats_vdevs_free(struct list_head *head);1259void ath11k_fw_stats_bcn_free(struct list_head *head);1260void ath11k_fw_stats_free(struct ath11k_fw_stats *stats);12611262extern const struct ce_pipe_config ath11k_target_ce_config_wlan_ipq8074[];1263extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq8074[];1264extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq6018[];12651266extern const struct ce_pipe_config ath11k_target_ce_config_wlan_qca6390[];1267extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_qca6390[];12681269extern const struct ce_pipe_config ath11k_target_ce_config_wlan_ipq5018[];1270extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq5018[];12711272extern const struct ce_pipe_config ath11k_target_ce_config_wlan_qcn9074[];1273extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_qcn9074[];1274int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab);1275int ath11k_core_pre_init(struct ath11k_base *ab);1276int ath11k_core_init(struct ath11k_base *ath11k);1277void ath11k_core_deinit(struct ath11k_base *ath11k);1278struct ath11k_base *ath11k_core_alloc(struct device *dev, size_t priv_size,1279enum ath11k_bus bus);1280void ath11k_core_free(struct ath11k_base *ath11k);1281int ath11k_core_fetch_bdf(struct ath11k_base *ath11k,1282struct ath11k_board_data *bd);1283int ath11k_core_fetch_regdb(struct ath11k_base *ab, struct ath11k_board_data *bd);1284int ath11k_core_fetch_board_data_api_1(struct ath11k_base *ab,1285struct ath11k_board_data *bd,1286const char *name);1287void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd);1288int ath11k_core_check_dt(struct ath11k_base *ath11k);1289int ath11k_core_check_smbios(struct ath11k_base *ab);1290void ath11k_core_halt(struct ath11k *ar);1291int ath11k_core_resume_early(struct ath11k_base *ab);1292int ath11k_core_resume(struct ath11k_base *ab);1293int ath11k_core_suspend(struct ath11k_base *ab);1294int ath11k_core_suspend_late(struct ath11k_base *ab);1295void ath11k_core_pre_reconfigure_recovery(struct ath11k_base *ab);1296bool ath11k_core_coldboot_cal_support(struct ath11k_base *ab);12971298const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab,1299const char *filename);13001301static inline const char *ath11k_scan_state_str(enum ath11k_scan_state state)1302{1303switch (state) {1304case ATH11K_SCAN_IDLE:1305return "idle";1306case ATH11K_SCAN_STARTING:1307return "starting";1308case ATH11K_SCAN_RUNNING:1309return "running";1310case ATH11K_SCAN_ABORTING:1311return "aborting";1312}13131314return "unknown";1315}13161317static inline struct ath11k_skb_cb *ATH11K_SKB_CB(struct sk_buff *skb)1318{1319BUILD_BUG_ON(sizeof(struct ath11k_skb_cb) >1320IEEE80211_TX_INFO_DRIVER_DATA_SIZE);1321return (struct ath11k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;1322}13231324static inline struct ath11k_skb_rxcb *ATH11K_SKB_RXCB(struct sk_buff *skb)1325{1326BUILD_BUG_ON(sizeof(struct ath11k_skb_rxcb) > sizeof(skb->cb));1327return (struct ath11k_skb_rxcb *)skb->cb;1328}13291330static inline struct ath11k_vif *ath11k_vif_to_arvif(struct ieee80211_vif *vif)1331{1332return (struct ath11k_vif *)vif->drv_priv;1333}13341335static inline struct ath11k_sta *ath11k_sta_to_arsta(struct ieee80211_sta *sta)1336{1337return (struct ath11k_sta *)sta->drv_priv;1338}13391340static inline struct ath11k *ath11k_ab_to_ar(struct ath11k_base *ab,1341int mac_id)1342{1343return ab->pdevs[ath11k_hw_mac_id_to_pdev_id(&ab->hw_params, mac_id)].ar;1344}13451346static inline void ath11k_core_create_firmware_path(struct ath11k_base *ab,1347const char *filename,1348void *buf, size_t buf_len)1349{1350const char *fw_name = NULL;13511352#if defined(CONFIG_OF)1353of_property_read_string(ab->dev->of_node, "firmware-name", &fw_name);1354#endif13551356if (fw_name && strncmp(filename, "board", 5))1357snprintf(buf, buf_len, "%s/%s/%s/%s", ATH11K_FW_DIR,1358ab->hw_params.fw.dir, fw_name, filename);1359else1360snprintf(buf, buf_len, "%s/%s/%s", ATH11K_FW_DIR,1361ab->hw_params.fw.dir, filename);1362}13631364static inline const char *ath11k_bus_str(enum ath11k_bus bus)1365{1366switch (bus) {1367case ATH11K_BUS_PCI:1368return "pci";1369case ATH11K_BUS_AHB:1370return "ahb";1371}13721373return "unknown";1374}13751376void ath11k_core_pm_notifier_unregister(struct ath11k_base *ab);13771378#endif /* _CORE_H_ */137913801381