Path: blob/main/sys/contrib/dev/athk/ath11k/core.h
48378 views
/* SPDX-License-Identifier: BSD-3-Clause-Clear */1/*2* Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.3* Copyright (c) 2021-2023 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 "qmi.h"21#include "htc.h"22#include "wmi.h"23#include "hal.h"24#include "dp.h"25#include "ce.h"26#include "mac.h"27#include "hw.h"28#include "hal_rx.h"29#include "reg.h"30#include "thermal.h"31#include "dbring.h"32#include "spectral.h"33#include "wow.h"3435#define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)3637#define ATH11K_TX_MGMT_NUM_PENDING_MAX 5123839#define ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI 644041/* Pending management packets threshold for dropping probe responses */42#define ATH11K_PRB_RSP_DROP_THRESHOLD ((ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI * 3) / 4)4344#define ATH11K_INVALID_HW_MAC_ID 0xFF45#define ATH11K_CONNECTION_LOSS_HZ (3 * HZ)4647/* SMBIOS type containing Board Data File Name Extension */48#define ATH11K_SMBIOS_BDF_EXT_TYPE 0xF84950/* SMBIOS type structure length (excluding strings-set) */51#define ATH11K_SMBIOS_BDF_EXT_LENGTH 0x95253/* The magic used by QCA spec */54#define ATH11K_SMBIOS_BDF_EXT_MAGIC "BDF_"5556extern unsigned int ath11k_frame_mode;57extern bool ath11k_ftm_mode;5859#define ATH11K_SCAN_TIMEOUT_HZ (20 * HZ)6061#define ATH11K_MON_TIMER_INTERVAL 1062#define ATH11K_RESET_TIMEOUT_HZ (20 * HZ)63#define ATH11K_RESET_MAX_FAIL_COUNT_FIRST 364#define ATH11K_RESET_MAX_FAIL_COUNT_FINAL 565#define ATH11K_RESET_FAIL_TIMEOUT_HZ (20 * HZ)66#define ATH11K_RECONFIGURE_TIMEOUT_HZ (10 * HZ)67#define ATH11K_RECOVER_START_TIMEOUT_HZ (20 * HZ)6869enum ath11k_supported_bw {70ATH11K_BW_20 = 0,71ATH11K_BW_40 = 1,72ATH11K_BW_80 = 2,73ATH11K_BW_160 = 3,74};7576enum ath11k_bdf_search {77ATH11K_BDF_SEARCH_DEFAULT,78ATH11K_BDF_SEARCH_BUS_AND_BOARD,79};8081#if defined(__FreeBSD__)82#ifdef WME_AC_BE83#undef WME_AC_BE84#endif85#ifdef WME_AC_BK86#undef WME_AC_BK87#endif88#ifdef WME_AC_VI89#undef WME_AC_VI90#endif91#ifdef WME_AC_VO92#undef WME_AC_VO93#endif94#ifdef WME_NUM_AC95#undef WME_NUM_AC96#endif97#endif9899enum wme_ac {100WME_AC_BE,101WME_AC_BK,102WME_AC_VI,103WME_AC_VO,104WME_NUM_AC105};106107#define ATH11K_HT_MCS_MAX 7108#define ATH11K_VHT_MCS_MAX 9109#define ATH11K_HE_MCS_MAX 11110111enum ath11k_crypt_mode {112/* Only use hardware crypto engine */113ATH11K_CRYPT_MODE_HW,114/* Only use software crypto */115ATH11K_CRYPT_MODE_SW,116};117118static inline enum wme_ac ath11k_tid_to_ac(u32 tid)119{120return (((tid == 0) || (tid == 3)) ? WME_AC_BE :121((tid == 1) || (tid == 2)) ? WME_AC_BK :122((tid == 4) || (tid == 5)) ? WME_AC_VI :123WME_AC_VO);124}125126enum ath11k_skb_flags {127ATH11K_SKB_HW_80211_ENCAP = BIT(0),128ATH11K_SKB_CIPHER_SET = BIT(1),129};130131struct ath11k_skb_cb {132dma_addr_t paddr;133u8 eid;134u8 flags;135u32 cipher;136struct ath11k *ar;137struct ieee80211_vif *vif;138} __packed;139140struct ath11k_skb_rxcb {141dma_addr_t paddr;142bool is_first_msdu;143bool is_last_msdu;144bool is_continuation;145bool is_mcbc;146bool is_eapol;147struct hal_rx_desc *rx_desc;148u8 err_rel_src;149u8 err_code;150u8 mac_id;151u8 unmapped;152u8 is_frag;153u8 tid;154u16 peer_id;155u16 seq_no;156};157158enum ath11k_hw_rev {159ATH11K_HW_IPQ8074,160ATH11K_HW_QCA6390_HW20,161ATH11K_HW_IPQ6018_HW10,162ATH11K_HW_QCN9074_HW10,163ATH11K_HW_WCN6855_HW20,164ATH11K_HW_WCN6855_HW21,165ATH11K_HW_WCN6750_HW10,166ATH11K_HW_IPQ5018_HW10,167};168169enum ath11k_firmware_mode {170/* the default mode, standard 802.11 functionality */171ATH11K_FIRMWARE_MODE_NORMAL,172173/* factory tests etc */174ATH11K_FIRMWARE_MODE_FTM,175176/* Cold boot calibration */177ATH11K_FIRMWARE_MODE_COLD_BOOT = 7,178};179180extern bool ath11k_cold_boot_cal;181182#define ATH11K_IRQ_NUM_MAX 52183#define ATH11K_EXT_IRQ_NUM_MAX 16184185struct ath11k_ext_irq_grp {186struct ath11k_base *ab;187u32 irqs[ATH11K_EXT_IRQ_NUM_MAX];188u32 num_irq;189u32 grp_id;190u64 timestamp;191bool napi_enabled;192struct napi_struct napi;193struct net_device napi_ndev;194};195196enum ath11k_smbios_cc_type {197/* disable country code setting from SMBIOS */198ATH11K_SMBIOS_CC_DISABLE = 0,199200/* set country code by ANSI country name, based on ISO3166-1 alpha2 */201ATH11K_SMBIOS_CC_ISO = 1,202203/* worldwide regdomain */204ATH11K_SMBIOS_CC_WW = 2,205};206207struct ath11k_smbios_bdf {208struct dmi_header hdr;209210u8 features_disabled;211212/* enum ath11k_smbios_cc_type */213u8 country_code_flag;214215/* To set specific country, you need to set country code216* flag=ATH11K_SMBIOS_CC_ISO first, then if country is United217* States, then country code value = 0x5553 ("US",'U' = 0x55, 'S'=218* 0x53). To set country to INDONESIA, then country code value =219* 0x4944 ("IN", 'I'=0x49, 'D'=0x44). If country code flag =220* ATH11K_SMBIOS_CC_WW, then you can use worldwide regulatory221* setting.222*/223u16 cc_code;224225u8 bdf_enabled;226u8 bdf_ext[];227} __packed;228229#define HEHANDLE_CAP_PHYINFO_SIZE 3230#define HECAP_PHYINFO_SIZE 9231#define HECAP_MACINFO_SIZE 5232#define HECAP_TXRX_MCS_NSS_SIZE 2233#define HECAP_PPET16_PPET8_MAX_SIZE 25234235#define HE_PPET16_PPET8_SIZE 8236237/* 802.11ax PPE (PPDU packet Extension) threshold */238struct he_ppe_threshold {239u32 numss_m1;240u32 ru_mask;241u32 ppet16_ppet8_ru3_ru0[HE_PPET16_PPET8_SIZE];242};243244struct ath11k_he {245u8 hecap_macinfo[HECAP_MACINFO_SIZE];246u32 hecap_rxmcsnssmap;247u32 hecap_txmcsnssmap;248u32 hecap_phyinfo[HEHANDLE_CAP_PHYINFO_SIZE];249struct he_ppe_threshold hecap_ppet;250u32 heop_param;251};252253#define MAX_RADIOS 3254255/* ipq5018 hw param macros */256#define MAX_RADIOS_5018 1257#define CE_CNT_5018 6258#define TARGET_CE_CNT_5018 9259#define SVC_CE_MAP_LEN_5018 17260#define RXDMA_PER_PDEV_5018 1261262enum {263WMI_HOST_TP_SCALE_MAX = 0,264WMI_HOST_TP_SCALE_50 = 1,265WMI_HOST_TP_SCALE_25 = 2,266WMI_HOST_TP_SCALE_12 = 3,267WMI_HOST_TP_SCALE_MIN = 4,268WMI_HOST_TP_SCALE_SIZE = 5,269};270271enum ath11k_scan_state {272ATH11K_SCAN_IDLE,273ATH11K_SCAN_STARTING,274ATH11K_SCAN_RUNNING,275ATH11K_SCAN_ABORTING,276};277278enum ath11k_11d_state {279ATH11K_11D_IDLE,280ATH11K_11D_PREPARING,281ATH11K_11D_RUNNING,282};283284enum ath11k_dev_flags {285ATH11K_CAC_RUNNING,286ATH11K_FLAG_CORE_REGISTERED,287ATH11K_FLAG_CRASH_FLUSH,288ATH11K_FLAG_RAW_MODE,289ATH11K_FLAG_HW_CRYPTO_DISABLED,290ATH11K_FLAG_BTCOEX,291ATH11K_FLAG_RECOVERY,292ATH11K_FLAG_UNREGISTERING,293ATH11K_FLAG_REGISTERED,294ATH11K_FLAG_QMI_FAIL,295ATH11K_FLAG_HTC_SUSPEND_COMPLETE,296ATH11K_FLAG_CE_IRQ_ENABLED,297ATH11K_FLAG_EXT_IRQ_ENABLED,298ATH11K_FLAG_FIXED_MEM_RGN,299ATH11K_FLAG_DEVICE_INIT_DONE,300ATH11K_FLAG_MULTI_MSI_VECTORS,301ATH11K_FLAG_FTM_SEGMENTED,302};303304enum ath11k_monitor_flags {305ATH11K_FLAG_MONITOR_CONF_ENABLED,306ATH11K_FLAG_MONITOR_STARTED,307ATH11K_FLAG_MONITOR_VDEV_CREATED,308};309310#define ATH11K_IPV6_UC_TYPE 0311#define ATH11K_IPV6_AC_TYPE 1312313#define ATH11K_IPV6_MAX_COUNT 16314#define ATH11K_IPV4_MAX_COUNT 2315316struct ath11k_arp_ns_offload {317u8 ipv4_addr[ATH11K_IPV4_MAX_COUNT][4];318u32 ipv4_count;319u32 ipv6_count;320u8 ipv6_addr[ATH11K_IPV6_MAX_COUNT][16];321u8 self_ipv6_addr[ATH11K_IPV6_MAX_COUNT][16];322u8 ipv6_type[ATH11K_IPV6_MAX_COUNT];323bool ipv6_valid[ATH11K_IPV6_MAX_COUNT];324u8 mac_addr[ETH_ALEN];325};326327struct ath11k_rekey_data {328u8 kck[NL80211_KCK_LEN];329u8 kek[NL80211_KCK_LEN];330u64 replay_ctr;331bool enable_offload;332};333334struct ath11k_vif {335u32 vdev_id;336enum wmi_vdev_type vdev_type;337enum wmi_vdev_subtype vdev_subtype;338u32 beacon_interval;339u32 dtim_period;340u16 ast_hash;341u16 ast_idx;342u16 tcl_metadata;343u8 hal_addr_search_flags;344u8 search_type;345346struct ath11k *ar;347struct ieee80211_vif *vif;348349u16 tx_seq_no;350struct wmi_wmm_params_all_arg wmm_params;351struct list_head list;352union {353struct {354u32 uapsd;355} sta;356struct {357/* 127 stations; wmi limit */358u8 tim_bitmap[16];359u8 tim_len;360u32 ssid_len;361u8 ssid[IEEE80211_MAX_SSID_LEN];362bool hidden_ssid;363/* P2P_IE with NoA attribute for P2P_GO case */364u32 noa_len;365u8 *noa_data;366} ap;367} u;368369bool is_started;370bool is_up;371bool ftm_responder;372bool spectral_enabled;373bool ps;374u32 aid;375u8 bssid[ETH_ALEN];376struct cfg80211_bitrate_mask bitrate_mask;377struct delayed_work connection_loss_work;378int num_legacy_stations;379int rtscts_prot_mode;380int txpower;381bool rsnie_present;382bool wpaie_present;383bool bcca_zero_sent;384bool do_not_send_tmpl;385struct ieee80211_chanctx_conf chanctx;386struct ath11k_arp_ns_offload arp_ns_offload;387struct ath11k_rekey_data rekey_data;388389#ifdef CONFIG_ATH11K_DEBUGFS390struct dentry *debugfs_twt;391#endif /* CONFIG_ATH11K_DEBUGFS */392};393394struct ath11k_vif_iter {395u32 vdev_id;396struct ath11k_vif *arvif;397};398399struct ath11k_rx_peer_stats {400u64 num_msdu;401u64 num_mpdu_fcs_ok;402u64 num_mpdu_fcs_err;403u64 tcp_msdu_count;404u64 udp_msdu_count;405u64 other_msdu_count;406u64 ampdu_msdu_count;407u64 non_ampdu_msdu_count;408u64 stbc_count;409u64 beamformed_count;410u64 mcs_count[HAL_RX_MAX_MCS + 1];411u64 nss_count[HAL_RX_MAX_NSS];412u64 bw_count[HAL_RX_BW_MAX];413u64 gi_count[HAL_RX_GI_MAX];414u64 coding_count[HAL_RX_SU_MU_CODING_MAX];415u64 tid_count[IEEE80211_NUM_TIDS + 1];416u64 pream_cnt[HAL_RX_PREAMBLE_MAX];417u64 reception_type[HAL_RX_RECEPTION_TYPE_MAX];418u64 rx_duration;419u64 dcm_count;420u64 ru_alloc_cnt[HAL_RX_RU_ALLOC_TYPE_MAX];421};422423#define ATH11K_HE_MCS_NUM 12424#define ATH11K_VHT_MCS_NUM 10425#define ATH11K_BW_NUM 4426#define ATH11K_NSS_NUM 4427#define ATH11K_LEGACY_NUM 12428#define ATH11K_GI_NUM 4429#define ATH11K_HT_MCS_NUM 32430431enum ath11k_pkt_rx_err {432ATH11K_PKT_RX_ERR_FCS,433ATH11K_PKT_RX_ERR_TKIP,434ATH11K_PKT_RX_ERR_CRYPT,435ATH11K_PKT_RX_ERR_PEER_IDX_INVAL,436ATH11K_PKT_RX_ERR_MAX,437};438439enum ath11k_ampdu_subfrm_num {440ATH11K_AMPDU_SUBFRM_NUM_10,441ATH11K_AMPDU_SUBFRM_NUM_20,442ATH11K_AMPDU_SUBFRM_NUM_30,443ATH11K_AMPDU_SUBFRM_NUM_40,444ATH11K_AMPDU_SUBFRM_NUM_50,445ATH11K_AMPDU_SUBFRM_NUM_60,446ATH11K_AMPDU_SUBFRM_NUM_MORE,447ATH11K_AMPDU_SUBFRM_NUM_MAX,448};449450enum ath11k_amsdu_subfrm_num {451ATH11K_AMSDU_SUBFRM_NUM_1,452ATH11K_AMSDU_SUBFRM_NUM_2,453ATH11K_AMSDU_SUBFRM_NUM_3,454ATH11K_AMSDU_SUBFRM_NUM_4,455ATH11K_AMSDU_SUBFRM_NUM_MORE,456ATH11K_AMSDU_SUBFRM_NUM_MAX,457};458459enum ath11k_counter_type {460ATH11K_COUNTER_TYPE_BYTES,461ATH11K_COUNTER_TYPE_PKTS,462ATH11K_COUNTER_TYPE_MAX,463};464465enum ath11k_stats_type {466ATH11K_STATS_TYPE_SUCC,467ATH11K_STATS_TYPE_FAIL,468ATH11K_STATS_TYPE_RETRY,469ATH11K_STATS_TYPE_AMPDU,470ATH11K_STATS_TYPE_MAX,471};472473struct ath11k_htt_data_stats {474u64 legacy[ATH11K_COUNTER_TYPE_MAX][ATH11K_LEGACY_NUM];475u64 ht[ATH11K_COUNTER_TYPE_MAX][ATH11K_HT_MCS_NUM];476u64 vht[ATH11K_COUNTER_TYPE_MAX][ATH11K_VHT_MCS_NUM];477u64 he[ATH11K_COUNTER_TYPE_MAX][ATH11K_HE_MCS_NUM];478u64 bw[ATH11K_COUNTER_TYPE_MAX][ATH11K_BW_NUM];479u64 nss[ATH11K_COUNTER_TYPE_MAX][ATH11K_NSS_NUM];480u64 gi[ATH11K_COUNTER_TYPE_MAX][ATH11K_GI_NUM];481};482483struct ath11k_htt_tx_stats {484struct ath11k_htt_data_stats stats[ATH11K_STATS_TYPE_MAX];485u64 tx_duration;486u64 ba_fails;487u64 ack_fails;488};489490struct ath11k_per_ppdu_tx_stats {491u16 succ_pkts;492u16 failed_pkts;493u16 retry_pkts;494u32 succ_bytes;495u32 failed_bytes;496u32 retry_bytes;497};498499DECLARE_EWMA(avg_rssi, 10, 8)500501struct ath11k_sta {502struct ath11k_vif *arvif;503504/* the following are protected by ar->data_lock */505u32 changed; /* IEEE80211_RC_* */506u32 bw;507u32 nss;508u32 smps;509enum hal_pn_type pn_type;510511struct work_struct update_wk;512struct work_struct set_4addr_wk;513struct rate_info txrate;514u32 peer_nss;515struct rate_info last_txrate;516u64 rx_duration;517u64 tx_duration;518u8 rssi_comb;519struct ewma_avg_rssi avg_rssi;520s8 rssi_beacon;521s8 chain_signal[IEEE80211_MAX_CHAINS];522struct ath11k_htt_tx_stats *tx_stats;523struct ath11k_rx_peer_stats *rx_stats;524525#ifdef CONFIG_MAC80211_DEBUGFS526/* protected by conf_mutex */527bool aggr_mode;528#endif529530bool use_4addr_set;531u16 tcl_metadata;532533/* Protected with ar->data_lock */534enum ath11k_wmi_peer_ps_state peer_ps_state;535u64 ps_start_time;536u64 ps_start_jiffies;537u64 ps_total_duration;538bool peer_current_ps_valid;539540u32 bw_prev;541};542543#define ATH11K_MIN_5G_FREQ 4150544#define ATH11K_MIN_6G_FREQ 5925545#define ATH11K_MAX_6G_FREQ 7115546#define ATH11K_NUM_CHANS 102547#define ATH11K_MAX_5G_CHAN 177548549enum ath11k_state {550ATH11K_STATE_OFF,551ATH11K_STATE_ON,552ATH11K_STATE_RESTARTING,553ATH11K_STATE_RESTARTED,554ATH11K_STATE_WEDGED,555ATH11K_STATE_FTM,556/* Add other states as required */557};558559/* Antenna noise floor */560#define ATH11K_DEFAULT_NOISE_FLOOR -95561562#define ATH11K_INVALID_RSSI_FULL -1563564#define ATH11K_INVALID_RSSI_EMPTY -128565566struct ath11k_fw_stats {567struct dentry *debugfs_fwstats;568u32 pdev_id;569u32 stats_id;570struct list_head pdevs;571struct list_head vdevs;572struct list_head bcn;573};574575struct ath11k_dbg_htt_stats {576u8 type;577u8 reset;578struct debug_htt_stats_req *stats_req;579/* protects shared stats req buffer */580spinlock_t lock;581};582583#define MAX_MODULE_ID_BITMAP_WORDS 16584585struct ath11k_debug {586struct dentry *debugfs_pdev;587struct ath11k_dbg_htt_stats htt_stats;588u32 extd_tx_stats;589u32 extd_rx_stats;590u32 pktlog_filter;591u32 pktlog_mode;592u32 pktlog_peer_valid;593u8 pktlog_peer_addr[ETH_ALEN];594u32 rx_filter;595u32 mem_offset;596u32 module_id_bitmap[MAX_MODULE_ID_BITMAP_WORDS];597struct ath11k_debug_dbr *dbr_debug[WMI_DIRECT_BUF_MAX];598};599600struct ath11k_per_peer_tx_stats {601u32 succ_bytes;602u32 retry_bytes;603u32 failed_bytes;604u16 succ_pkts;605u16 retry_pkts;606u16 failed_pkts;607u32 duration;608u8 ba_fails;609bool is_ampdu;610};611612#define ATH11K_FLUSH_TIMEOUT (5 * HZ)613#define ATH11K_VDEV_DELETE_TIMEOUT_HZ (5 * HZ)614615struct ath11k {616struct ath11k_base *ab;617struct ath11k_pdev *pdev;618struct ieee80211_hw *hw;619struct ieee80211_ops *ops;620struct ath11k_pdev_wmi *wmi;621struct ath11k_pdev_dp dp;622u8 mac_addr[ETH_ALEN];623struct ath11k_he ar_he;624enum ath11k_state state;625bool supports_6ghz;626struct {627struct completion started;628struct completion completed;629struct completion on_channel;630struct delayed_work timeout;631enum ath11k_scan_state state;632bool is_roc;633int vdev_id;634int roc_freq;635bool roc_notify;636} scan;637638struct {639struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];640struct ieee80211_sband_iftype_data641iftype[NUM_NL80211_BANDS][NUM_NL80211_IFTYPES];642} mac;643644unsigned long dev_flags;645unsigned int filter_flags;646unsigned long monitor_flags;647u32 min_tx_power;648u32 max_tx_power;649u32 txpower_limit_2g;650u32 txpower_limit_5g;651u32 txpower_scale;652u32 power_scale;653u32 chan_tx_pwr;654u32 num_stations;655u32 max_num_stations;656/* To synchronize concurrent synchronous mac80211 callback operations,657* concurrent debugfs configuration and concurrent FW statistics events.658*/659struct mutex conf_mutex;660/* protects the radio specific data like debug stats, ppdu_stats_info stats,661* vdev_stop_status info, scan data, ath11k_sta info, ath11k_vif info,662* channel context data, survey info, test mode data.663*/664spinlock_t data_lock;665666struct list_head arvifs;667/* should never be NULL; needed for regular htt rx */668struct ieee80211_channel *rx_channel;669670/* valid during scan; needed for mgmt rx during scan */671struct ieee80211_channel *scan_channel;672673u8 cfg_tx_chainmask;674u8 cfg_rx_chainmask;675u8 num_rx_chains;676u8 num_tx_chains;677/* pdev_idx starts from 0 whereas pdev->pdev_id starts with 1 */678u8 pdev_idx;679u8 lmac_id;680681struct completion peer_assoc_done;682struct completion peer_delete_done;683684int install_key_status;685struct completion install_key_done;686687int last_wmi_vdev_start_status;688struct completion vdev_setup_done;689struct completion vdev_delete_done;690691int num_peers;692int max_num_peers;693u32 num_started_vdevs;694u32 num_created_vdevs;695unsigned long long allocated_vdev_map;696697struct idr txmgmt_idr;698/* protects txmgmt_idr data */699spinlock_t txmgmt_idr_lock;700atomic_t num_pending_mgmt_tx;701wait_queue_head_t txmgmt_empty_waitq;702703/* cycle count is reported twice for each visited channel during scan.704* access protected by data_lock705*/706u32 survey_last_rx_clear_count;707u32 survey_last_cycle_count;708709/* Channel info events are expected to come in pairs without and with710* COMPLETE flag set respectively for each channel visit during scan.711*712* However there are deviations from this rule. This flag is used to713* avoid reporting garbage data.714*/715bool ch_info_can_report_survey;716struct survey_info survey[ATH11K_NUM_CHANS];717struct completion bss_survey_done;718719struct work_struct regd_update_work;720721struct work_struct wmi_mgmt_tx_work;722struct sk_buff_head wmi_mgmt_tx_queue;723724struct ath11k_wow wow;725struct completion target_suspend;726bool target_suspend_ack;727struct ath11k_per_peer_tx_stats peer_tx_stats;728struct list_head ppdu_stats_info;729u32 ppdu_stat_list_depth;730731struct ath11k_per_peer_tx_stats cached_stats;732u32 last_ppdu_id;733u32 cached_ppdu_id;734int monitor_vdev_id;735struct completion fw_mode_reset;736u8 ftm_msgref;737#ifdef CONFIG_ATH11K_DEBUGFS738struct ath11k_debug debug;739#endif740#ifdef CONFIG_ATH11K_SPECTRAL741struct ath11k_spectral spectral;742#endif743bool dfs_block_radar_events;744struct ath11k_thermal thermal;745u32 vdev_id_11d_scan;746struct completion completed_11d_scan;747enum ath11k_11d_state state_11d;748bool regdom_set_by_user;749int hw_rate_code;750u8 twt_enabled;751bool nlo_enabled;752u8 alpha2[REG_ALPHA2_LEN + 1];753struct ath11k_fw_stats fw_stats;754struct completion fw_stats_complete;755bool fw_stats_done;756757/* protected by conf_mutex */758bool ps_state_enable;759bool ps_timekeeper_enable;760};761762struct ath11k_band_cap {763u32 phy_id;764u32 max_bw_supported;765u32 ht_cap_info;766u32 he_cap_info[2];767u32 he_mcs;768u32 he_cap_phy_info[PSOC_HOST_MAX_PHY_SIZE];769struct ath11k_ppe_threshold he_ppet;770u16 he_6ghz_capa;771};772773struct ath11k_pdev_cap {774u32 supported_bands;775u32 ampdu_density;776u32 vht_cap;777u32 vht_mcs;778u32 he_mcs;779u32 tx_chain_mask;780u32 rx_chain_mask;781u32 tx_chain_mask_shift;782u32 rx_chain_mask_shift;783struct ath11k_band_cap band[NUM_NL80211_BANDS];784bool nss_ratio_enabled;785u8 nss_ratio_info;786};787788struct ath11k_pdev {789struct ath11k *ar;790u32 pdev_id;791struct ath11k_pdev_cap cap;792u8 mac_addr[ETH_ALEN];793};794795struct ath11k_board_data {796const struct firmware *fw;797const void *data;798size_t len;799};800801struct ath11k_pci_ops {802int (*wakeup)(struct ath11k_base *ab);803void (*release)(struct ath11k_base *ab);804int (*get_msi_irq)(struct ath11k_base *ab, unsigned int vector);805void (*window_write32)(struct ath11k_base *ab, u32 offset, u32 value);806u32 (*window_read32)(struct ath11k_base *ab, u32 offset);807};808809/* IPQ8074 HW channel counters frequency value in hertz */810#define IPQ8074_CC_FREQ_HERTZ 320000811812struct ath11k_bp_stats {813/* Head Pointer reported by the last HTT Backpressure event for the ring */814u16 hp;815816/* Tail Pointer reported by the last HTT Backpressure event for the ring */817u16 tp;818819/* Number of Backpressure events received for the ring */820u32 count;821822/* Last recorded event timestamp */823unsigned long jiffies;824};825826struct ath11k_dp_ring_bp_stats {827struct ath11k_bp_stats umac_ring_bp_stats[HTT_SW_UMAC_RING_IDX_MAX];828struct ath11k_bp_stats lmac_ring_bp_stats[HTT_SW_LMAC_RING_IDX_MAX][MAX_RADIOS];829};830831struct ath11k_soc_dp_tx_err_stats {832/* TCL Ring Descriptor unavailable */833u32 desc_na[DP_TCL_NUM_RING_MAX];834/* Other failures during dp_tx due to mem allocation failure835* idr unavailable etc.836*/837atomic_t misc_fail;838};839840struct ath11k_soc_dp_stats {841u32 err_ring_pkts;842u32 invalid_rbm;843u32 rxdma_error[HAL_REO_ENTR_RING_RXDMA_ECODE_MAX];844u32 reo_error[HAL_REO_DEST_RING_ERROR_CODE_MAX];845u32 hal_reo_error[DP_REO_DST_RING_MAX];846struct ath11k_soc_dp_tx_err_stats tx_err;847struct ath11k_dp_ring_bp_stats bp_stats;848};849850struct ath11k_msi_user {851char *name;852int num_vectors;853u32 base_vector;854};855856struct ath11k_msi_config {857int total_vectors;858int total_users;859struct ath11k_msi_user *users;860u16 hw_rev;861};862863/* Master structure to hold the hw data which may be used in core module */864struct ath11k_base {865enum ath11k_hw_rev hw_rev;866enum ath11k_firmware_mode fw_mode;867struct platform_device *pdev;868struct device *dev;869struct ath11k_qmi qmi;870struct ath11k_wmi_base wmi_ab;871struct completion fw_ready;872int num_radios;873/* HW channel counters frequency value in hertz common to all MACs */874u32 cc_freq_hz;875876struct ath11k_htc htc;877878struct ath11k_dp dp;879880void __iomem *mem;881void __iomem *mem_ce;882unsigned long mem_len;883884struct {885enum ath11k_bus bus;886const struct ath11k_hif_ops *ops;887} hif;888889struct {890struct completion wakeup_completed;891} wow;892893struct ath11k_ce ce;894struct timer_list rx_replenish_retry;895struct ath11k_hal hal;896/* To synchronize core_start/core_stop */897struct mutex core_lock;898/* Protects data like peers */899spinlock_t base_lock;900struct ath11k_pdev pdevs[MAX_RADIOS];901struct {902enum WMI_HOST_WLAN_BAND supported_bands;903u32 pdev_id;904} target_pdev_ids[MAX_RADIOS];905u8 target_pdev_count;906struct ath11k_pdev __rcu *pdevs_active[MAX_RADIOS];907struct ath11k_hal_reg_capabilities_ext hal_reg_cap[MAX_RADIOS];908unsigned long long free_vdev_map;909910/* To synchronize rhash tbl write operation */911struct mutex tbl_mtx_lock;912913/* The rhashtable containing struct ath11k_peer keyed by mac addr */914struct rhashtable *rhead_peer_addr;915struct rhashtable_params rhash_peer_addr_param;916917/* The rhashtable containing struct ath11k_peer keyed by id */918struct rhashtable *rhead_peer_id;919struct rhashtable_params rhash_peer_id_param;920921struct list_head peers;922wait_queue_head_t peer_mapping_wq;923u8 mac_addr[ETH_ALEN];924bool wmi_ready;925u32 wlan_init_status;926int irq_num[ATH11K_IRQ_NUM_MAX];927struct ath11k_ext_irq_grp ext_irq_grp[ATH11K_EXT_IRQ_GRP_NUM_MAX];928struct ath11k_targ_cap target_caps;929u32 ext_service_bitmap[WMI_SERVICE_EXT_BM_SIZE];930bool pdevs_macaddr_valid;931int bd_api;932933struct ath11k_hw_params hw_params;934935const struct firmware *cal_file;936937/* Below regd's are protected by ab->data_lock */938/* This is the regd set for every radio939* by the firmware during initialization940*/941struct ieee80211_regdomain *default_regd[MAX_RADIOS];942/* This regd is set during dynamic country setting943* This may or may not be used during the runtime944*/945struct ieee80211_regdomain *new_regd[MAX_RADIOS];946947/* Current DFS Regulatory */948enum ath11k_dfs_region dfs_region;949#ifdef CONFIG_ATH11K_DEBUGFS950struct dentry *debugfs_soc;951#endif952struct ath11k_soc_dp_stats soc_stats;953954unsigned long dev_flags;955struct completion driver_recovery;956struct workqueue_struct *workqueue;957struct work_struct restart_work;958struct work_struct update_11d_work;959u8 new_alpha2[3];960struct workqueue_struct *workqueue_aux;961struct work_struct reset_work;962atomic_t reset_count;963atomic_t recovery_count;964atomic_t recovery_start_count;965bool is_reset;966struct completion reset_complete;967struct completion reconfigure_complete;968struct completion recovery_start;969/* continuous recovery fail count */970atomic_t fail_cont_count;971unsigned long reset_fail_timeout;972struct {973/* protected by data_lock */974u32 fw_crash_counter;975} stats;976u32 pktlog_defs_checksum;977978struct ath11k_dbring_cap *db_caps;979u32 num_db_cap;980981/* To synchronize 11d scan vdev id */982struct mutex vdev_id_11d_lock;983struct timer_list mon_reap_timer;984985struct completion htc_suspend;986987struct {988enum ath11k_bdf_search bdf_search;989u32 vendor;990u32 device;991u32 subsystem_vendor;992u32 subsystem_device;993} id;994995struct {996struct {997const struct ath11k_msi_config *config;998u32 ep_base_data;999u32 irqs[32];1000u32 addr_lo;1001u32 addr_hi;1002} msi;10031004const struct ath11k_pci_ops *ops;1005} pci;10061007#ifdef CONFIG_NL80211_TESTMODE1008struct {1009u32 data_pos;1010u32 expected_seq;1011u8 *eventdata;1012} testmode;1013#endif10141015/* must be last */1016u8 drv_priv[] __aligned(sizeof(void *));1017};10181019struct ath11k_fw_stats_pdev {1020struct list_head list;10211022/* PDEV stats */1023s32 ch_noise_floor;1024/* Cycles spent transmitting frames */1025u32 tx_frame_count;1026/* Cycles spent receiving frames */1027u32 rx_frame_count;1028/* Total channel busy time, evidently */1029u32 rx_clear_count;1030/* Total on-channel time */1031u32 cycle_count;1032u32 phy_err_count;1033u32 chan_tx_power;1034u32 ack_rx_bad;1035u32 rts_bad;1036u32 rts_good;1037u32 fcs_bad;1038u32 no_beacons;1039u32 mib_int_count;10401041/* PDEV TX stats */1042/* Num HTT cookies queued to dispatch list */1043s32 comp_queued;1044/* Num HTT cookies dispatched */1045s32 comp_delivered;1046/* Num MSDU queued to WAL */1047s32 msdu_enqued;1048/* Num MPDU queue to WAL */1049s32 mpdu_enqued;1050/* Num MSDUs dropped by WMM limit */1051s32 wmm_drop;1052/* Num Local frames queued */1053s32 local_enqued;1054/* Num Local frames done */1055s32 local_freed;1056/* Num queued to HW */1057s32 hw_queued;1058/* Num PPDU reaped from HW */1059s32 hw_reaped;1060/* Num underruns */1061s32 underrun;1062/* Num hw paused */1063u32 hw_paused;1064/* Num PPDUs cleaned up in TX abort */1065s32 tx_abort;1066/* Num MPDUs requeued by SW */1067s32 mpdus_requeued;1068/* excessive retries */1069u32 tx_ko;1070u32 tx_xretry;1071/* data hw rate code */1072u32 data_rc;1073/* Scheduler self triggers */1074u32 self_triggers;1075/* frames dropped due to excessive sw retries */1076u32 sw_retry_failure;1077/* illegal rate phy errors */1078u32 illgl_rate_phy_err;1079/* wal pdev continuous xretry */1080u32 pdev_cont_xretry;1081/* wal pdev tx timeouts */1082u32 pdev_tx_timeout;1083/* wal pdev resets */1084u32 pdev_resets;1085/* frames dropped due to non-availability of stateless TIDs */1086u32 stateless_tid_alloc_failure;1087/* PhY/BB underrun */1088u32 phy_underrun;1089/* MPDU is more than txop limit */1090u32 txop_ovf;1091/* Num sequences posted */1092u32 seq_posted;1093/* Num sequences failed in queueing */1094u32 seq_failed_queueing;1095/* Num sequences completed */1096u32 seq_completed;1097/* Num sequences restarted */1098u32 seq_restarted;1099/* Num of MU sequences posted */1100u32 mu_seq_posted;1101/* Num MPDUs flushed by SW, HWPAUSED, SW TXABORT1102* (Reset,channel change)1103*/1104s32 mpdus_sw_flush;1105/* Num MPDUs filtered by HW, all filter condition (TTL expired) */1106s32 mpdus_hw_filter;1107/* Num MPDUs truncated by PDG (TXOP, TBTT,1108* PPDU_duration based on rate, dyn_bw)1109*/1110s32 mpdus_truncated;1111/* Num MPDUs that was tried but didn't receive ACK or BA */1112s32 mpdus_ack_failed;1113/* Num MPDUs that was dropped du to expiry. */1114s32 mpdus_expired;11151116/* PDEV RX stats */1117/* Cnts any change in ring routing mid-ppdu */1118s32 mid_ppdu_route_change;1119/* Total number of statuses processed */1120s32 status_rcvd;1121/* Extra frags on rings 0-3 */1122s32 r0_frags;1123s32 r1_frags;1124s32 r2_frags;1125s32 r3_frags;1126/* MSDUs / MPDUs delivered to HTT */1127s32 htt_msdus;1128s32 htt_mpdus;1129/* MSDUs / MPDUs delivered to local stack */1130s32 loc_msdus;1131s32 loc_mpdus;1132/* AMSDUs that have more MSDUs than the status ring size */1133s32 oversize_amsdu;1134/* Number of PHY errors */1135s32 phy_errs;1136/* Number of PHY errors drops */1137s32 phy_err_drop;1138/* Number of mpdu errors - FCS, MIC, ENC etc. */1139s32 mpdu_errs;1140/* Num overflow errors */1141s32 rx_ovfl_errs;1142};11431144struct ath11k_fw_stats_vdev {1145struct list_head list;11461147u32 vdev_id;1148u32 beacon_snr;1149u32 data_snr;1150u32 num_tx_frames[WLAN_MAX_AC];1151u32 num_rx_frames;1152u32 num_tx_frames_retries[WLAN_MAX_AC];1153u32 num_tx_frames_failures[WLAN_MAX_AC];1154u32 num_rts_fail;1155u32 num_rts_success;1156u32 num_rx_err;1157u32 num_rx_discard;1158u32 num_tx_not_acked;1159u32 tx_rate_history[MAX_TX_RATE_VALUES];1160u32 beacon_rssi_history[MAX_TX_RATE_VALUES];1161};11621163struct ath11k_fw_stats_bcn {1164struct list_head list;11651166u32 vdev_id;1167u32 tx_bcn_succ_cnt;1168u32 tx_bcn_outage_cnt;1169};11701171void ath11k_fw_stats_init(struct ath11k *ar);1172void ath11k_fw_stats_pdevs_free(struct list_head *head);1173void ath11k_fw_stats_vdevs_free(struct list_head *head);1174void ath11k_fw_stats_bcn_free(struct list_head *head);1175void ath11k_fw_stats_free(struct ath11k_fw_stats *stats);11761177extern const struct ce_pipe_config ath11k_target_ce_config_wlan_ipq8074[];1178extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq8074[];1179extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq6018[];11801181extern const struct ce_pipe_config ath11k_target_ce_config_wlan_qca6390[];1182extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_qca6390[];11831184extern const struct ce_pipe_config ath11k_target_ce_config_wlan_ipq5018[];1185extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq5018[];11861187extern const struct ce_pipe_config ath11k_target_ce_config_wlan_qcn9074[];1188extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_qcn9074[];1189int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab);1190int ath11k_core_pre_init(struct ath11k_base *ab);1191int ath11k_core_init(struct ath11k_base *ath11k);1192void ath11k_core_deinit(struct ath11k_base *ath11k);1193struct ath11k_base *ath11k_core_alloc(struct device *dev, size_t priv_size,1194enum ath11k_bus bus);1195void ath11k_core_free(struct ath11k_base *ath11k);1196int ath11k_core_fetch_bdf(struct ath11k_base *ath11k,1197struct ath11k_board_data *bd);1198int ath11k_core_fetch_regdb(struct ath11k_base *ab, struct ath11k_board_data *bd);1199int ath11k_core_fetch_board_data_api_1(struct ath11k_base *ab,1200struct ath11k_board_data *bd,1201const char *name);1202void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd);1203int ath11k_core_check_dt(struct ath11k_base *ath11k);1204int ath11k_core_check_smbios(struct ath11k_base *ab);1205void ath11k_core_halt(struct ath11k *ar);1206int ath11k_core_resume(struct ath11k_base *ab);1207int ath11k_core_suspend(struct ath11k_base *ab);1208void ath11k_core_pre_reconfigure_recovery(struct ath11k_base *ab);1209bool ath11k_core_coldboot_cal_support(struct ath11k_base *ab);12101211const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab,1212const char *filename);12131214static inline const char *ath11k_scan_state_str(enum ath11k_scan_state state)1215{1216switch (state) {1217case ATH11K_SCAN_IDLE:1218return "idle";1219case ATH11K_SCAN_STARTING:1220return "starting";1221case ATH11K_SCAN_RUNNING:1222return "running";1223case ATH11K_SCAN_ABORTING:1224return "aborting";1225}12261227return "unknown";1228}12291230static inline struct ath11k_skb_cb *ATH11K_SKB_CB(struct sk_buff *skb)1231{1232BUILD_BUG_ON(sizeof(struct ath11k_skb_cb) >1233IEEE80211_TX_INFO_DRIVER_DATA_SIZE);1234return (struct ath11k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;1235}12361237static inline struct ath11k_skb_rxcb *ATH11K_SKB_RXCB(struct sk_buff *skb)1238{1239BUILD_BUG_ON(sizeof(struct ath11k_skb_rxcb) > sizeof(skb->cb));1240return (struct ath11k_skb_rxcb *)skb->cb;1241}12421243static inline struct ath11k_vif *ath11k_vif_to_arvif(struct ieee80211_vif *vif)1244{1245return (struct ath11k_vif *)vif->drv_priv;1246}12471248static inline struct ath11k *ath11k_ab_to_ar(struct ath11k_base *ab,1249int mac_id)1250{1251return ab->pdevs[ath11k_hw_mac_id_to_pdev_id(&ab->hw_params, mac_id)].ar;1252}12531254static inline void ath11k_core_create_firmware_path(struct ath11k_base *ab,1255const char *filename,1256void *buf, size_t buf_len)1257{1258snprintf(buf, buf_len, "%s/%s/%s", ATH11K_FW_DIR,1259ab->hw_params.fw.dir, filename);1260}12611262static inline const char *ath11k_bus_str(enum ath11k_bus bus)1263{1264switch (bus) {1265case ATH11K_BUS_PCI:1266return "pci";1267case ATH11K_BUS_AHB:1268return "ahb";1269}12701271return "unknown";1272}12731274#endif /* _CORE_H_ */127512761277