Path: blob/main/sys/contrib/dev/athk/ath10k/core.h
48378 views
/* SPDX-License-Identifier: ISC */1/*2* Copyright (c) 2005-2011 Atheros Communications Inc.3* Copyright (c) 2011-2017 Qualcomm Atheros, Inc.4* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.5*/67#ifndef _CORE_H_8#define _CORE_H_910#include <linux/completion.h>11#include <linux/if_ether.h>12#include <linux/types.h>13#include <linux/pci.h>14#include <linux/uuid.h>15#include <linux/time.h>1617#include "htt.h"18#include "htc.h"19#include "hw.h"20#include "targaddrs.h"21#include "wmi.h"22#include "../ath.h"23#include "../regd.h"24#include "../dfs_pattern_detector.h"25#include "spectral.h"26#include "thermal.h"27#include "wow.h"28#include "swap.h"2930#define MS(_v, _f) (((_v) & _f##_MASK) >> _f##_LSB)31#define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)32#define WO(_f) ((_f##_OFFSET) >> 2)3334#define ATH10K_SCAN_ID 035#define ATH10K_SCAN_CHANNEL_SWITCH_WMI_EVT_OVERHEAD 10 /* msec */36#define WMI_READY_TIMEOUT (5 * HZ)37#define ATH10K_FLUSH_TIMEOUT_HZ (5 * HZ)38#define ATH10K_CONNECTION_LOSS_HZ (3 * HZ)39#define ATH10K_NUM_CHANS 4140#define ATH10K_MAX_5G_CHAN 1734142#if defined(CONFIG_FWLOG)43#define ATH10K_FWLOG_MODULE_ID_MAX_10_2_4 2844#define ATH10K_FWLOG_MODULE_ID_MAX_10_4 3545#endif4647/* Antenna noise floor */48#define ATH10K_DEFAULT_NOISE_FLOOR -954950#define ATH10K_INVALID_RSSI 1285152#define ATH10K_MAX_NUM_MGMT_PENDING 1285354/* number of failed packets (20 packets with 16 sw reties each) */55#define ATH10K_KICKOUT_THRESHOLD (20 * 16)5657/*58* Use insanely high numbers to make sure that the firmware implementation59* won't start, we have the same functionality already in hostapd. Unit60* is seconds.61*/62#define ATH10K_KEEPALIVE_MIN_IDLE 374763#define ATH10K_KEEPALIVE_MAX_IDLE 389564#define ATH10K_KEEPALIVE_MAX_UNRESPONSIVE 39006566/* SMBIOS type containing Board Data File Name Extension */67#define ATH10K_SMBIOS_BDF_EXT_TYPE 0xF86869/* SMBIOS type structure length (excluding strings-set) */70#define ATH10K_SMBIOS_BDF_EXT_LENGTH 0x97172/* Offset pointing to Board Data File Name Extension */73#define ATH10K_SMBIOS_BDF_EXT_OFFSET 0x87475/* Board Data File Name Extension string length.76* String format: BDF_<Customer ID>_<Extension>\077*/78#define ATH10K_SMBIOS_BDF_EXT_STR_LENGTH 0x207980/* The magic used by QCA spec */81#define ATH10K_SMBIOS_BDF_EXT_MAGIC "BDF_"8283/* Default Airtime weight multiplier (Tuned for multiclient performance) */84#define ATH10K_AIRTIME_WEIGHT_MULTIPLIER 48586#define ATH10K_MAX_RETRY_COUNT 308788#define ATH10K_ITER_NORMAL_FLAGS (IEEE80211_IFACE_ITER_NORMAL | \89IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER)90#define ATH10K_ITER_RESUME_FLAGS (IEEE80211_IFACE_ITER_RESUME_ALL |\91IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER)9293struct ath10k;9495static inline const char *ath10k_bus_str(enum ath10k_bus bus)96{97switch (bus) {98case ATH10K_BUS_PCI:99return "pci";100case ATH10K_BUS_AHB:101return "ahb";102case ATH10K_BUS_SDIO:103return "sdio";104case ATH10K_BUS_USB:105return "usb";106case ATH10K_BUS_SNOC:107return "snoc";108}109110return "unknown";111}112113enum ath10k_skb_flags {114ATH10K_SKB_F_NO_HWCRYPT = BIT(0),115ATH10K_SKB_F_DTIM_ZERO = BIT(1),116ATH10K_SKB_F_DELIVER_CAB = BIT(2),117ATH10K_SKB_F_MGMT = BIT(3),118ATH10K_SKB_F_QOS = BIT(4),119ATH10K_SKB_F_RAW_TX = BIT(5),120ATH10K_SKB_F_NOACK_TID = BIT(6),121};122123struct ath10k_skb_cb {124dma_addr_t paddr;125u8 flags;126u8 eid;127u16 msdu_id;128u16 airtime_est;129struct ieee80211_vif *vif;130struct ieee80211_txq *txq;131u32 ucast_cipher;132} __packed;133134struct ath10k_skb_rxcb {135dma_addr_t paddr;136struct hlist_node hlist;137u8 eid;138};139140static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)141{142BUILD_BUG_ON(sizeof(struct ath10k_skb_cb) >143IEEE80211_TX_INFO_DRIVER_DATA_SIZE);144return (struct ath10k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;145}146147static inline struct ath10k_skb_rxcb *ATH10K_SKB_RXCB(struct sk_buff *skb)148{149BUILD_BUG_ON(sizeof(struct ath10k_skb_rxcb) > sizeof(skb->cb));150return (struct ath10k_skb_rxcb *)skb->cb;151}152153#define ATH10K_RXCB_SKB(rxcb) \154container_of((void *)rxcb, struct sk_buff, cb)155156static inline u32 host_interest_item_address(u32 item_offset)157{158return QCA988X_HOST_INTEREST_ADDRESS + item_offset;159}160161enum ath10k_phy_mode {162ATH10K_PHY_MODE_LEGACY = 0,163ATH10K_PHY_MODE_HT = 1,164ATH10K_PHY_MODE_VHT = 2,165};166167/* Data rate 100KBPS based on IE Index */168struct ath10k_index_ht_data_rate_type {169u8 beacon_rate_index;170u16 supported_rate[4];171};172173/* Data rate 100KBPS based on IE Index */174struct ath10k_index_vht_data_rate_type {175u8 beacon_rate_index;176u16 supported_VHT80_rate[2];177u16 supported_VHT40_rate[2];178u16 supported_VHT20_rate[2];179};180181struct ath10k_bmi {182bool done_sent;183};184185struct ath10k_mem_chunk {186void *vaddr;187dma_addr_t paddr;188u32 len;189u32 req_id;190};191192struct ath10k_wmi {193enum ath10k_htc_ep_id eid;194struct completion service_ready;195struct completion unified_ready;196struct completion barrier;197struct completion radar_confirm;198wait_queue_head_t tx_credits_wq;199DECLARE_BITMAP(svc_map, WMI_SERVICE_MAX);200struct wmi_cmd_map *cmd;201struct wmi_vdev_param_map *vdev_param;202struct wmi_pdev_param_map *pdev_param;203struct wmi_peer_param_map *peer_param;204const struct wmi_ops *ops;205const struct wmi_peer_flags_map *peer_flags;206207u32 mgmt_max_num_pending_tx;208209/* Protected by data_lock */210struct idr mgmt_pending_tx;211212u32 num_mem_chunks;213u32 rx_decap_mode;214struct ath10k_mem_chunk mem_chunks[WMI_MAX_MEM_REQS];215};216217struct ath10k_fw_stats_peer {218struct list_head list;219220u8 peer_macaddr[ETH_ALEN];221u32 peer_rssi;222u32 peer_tx_rate;223u32 peer_rx_rate; /* 10x only */224u64 rx_duration;225};226227struct ath10k_fw_extd_stats_peer {228struct list_head list;229230u8 peer_macaddr[ETH_ALEN];231u64 rx_duration;232};233234struct ath10k_fw_stats_vdev {235struct list_head list;236237u32 vdev_id;238u32 beacon_snr;239u32 data_snr;240u32 num_tx_frames[4];241u32 num_rx_frames;242u32 num_tx_frames_retries[4];243u32 num_tx_frames_failures[4];244u32 num_rts_fail;245u32 num_rts_success;246u32 num_rx_err;247u32 num_rx_discard;248u32 num_tx_not_acked;249u32 tx_rate_history[10];250u32 beacon_rssi_history[10];251};252253struct ath10k_fw_stats_vdev_extd {254struct list_head list;255256u32 vdev_id;257u32 ppdu_aggr_cnt;258u32 ppdu_noack;259u32 mpdu_queued;260u32 ppdu_nonaggr_cnt;261u32 mpdu_sw_requeued;262u32 mpdu_suc_retry;263u32 mpdu_suc_multitry;264u32 mpdu_fail_retry;265u32 tx_ftm_suc;266u32 tx_ftm_suc_retry;267u32 tx_ftm_fail;268u32 rx_ftmr_cnt;269u32 rx_ftmr_dup_cnt;270u32 rx_iftmr_cnt;271u32 rx_iftmr_dup_cnt;272};273274struct ath10k_fw_stats_pdev {275struct list_head list;276277/* PDEV stats */278s32 ch_noise_floor;279u32 tx_frame_count; /* Cycles spent transmitting frames */280u32 rx_frame_count; /* Cycles spent receiving frames */281u32 rx_clear_count; /* Total channel busy time, evidently */282u32 cycle_count; /* Total on-channel time */283u32 phy_err_count;284u32 chan_tx_power;285u32 ack_rx_bad;286u32 rts_bad;287u32 rts_good;288u32 fcs_bad;289u32 no_beacons;290u32 mib_int_count;291292/* PDEV TX stats */293s32 comp_queued;294s32 comp_delivered;295s32 msdu_enqued;296s32 mpdu_enqued;297s32 wmm_drop;298s32 local_enqued;299s32 local_freed;300s32 hw_queued;301s32 hw_reaped;302s32 underrun;303u32 hw_paused;304s32 tx_abort;305s32 mpdus_requeued;306u32 tx_ko;307u32 data_rc;308u32 self_triggers;309u32 sw_retry_failure;310u32 illgl_rate_phy_err;311u32 pdev_cont_xretry;312u32 pdev_tx_timeout;313u32 pdev_resets;314u32 phy_underrun;315u32 txop_ovf;316u32 seq_posted;317u32 seq_failed_queueing;318u32 seq_completed;319u32 seq_restarted;320u32 mu_seq_posted;321u32 mpdus_sw_flush;322u32 mpdus_hw_filter;323u32 mpdus_truncated;324u32 mpdus_ack_failed;325u32 mpdus_expired;326327/* PDEV RX stats */328s32 mid_ppdu_route_change;329s32 status_rcvd;330s32 r0_frags;331s32 r1_frags;332s32 r2_frags;333s32 r3_frags;334s32 htt_msdus;335s32 htt_mpdus;336s32 loc_msdus;337s32 loc_mpdus;338s32 oversize_amsdu;339s32 phy_errs;340s32 phy_err_drop;341s32 mpdu_errs;342s32 rx_ovfl_errs;343};344345struct ath10k_fw_stats {346bool extended;347struct list_head pdevs;348struct list_head vdevs;349struct list_head peers;350struct list_head peers_extd;351};352353#define ATH10K_TPC_TABLE_TYPE_FLAG 1354#define ATH10K_TPC_PREAM_TABLE_END 0xFFFF355356struct ath10k_tpc_table {357u32 pream_idx[WMI_TPC_RATE_MAX];358u8 rate_code[WMI_TPC_RATE_MAX];359char tpc_value[WMI_TPC_RATE_MAX][WMI_TPC_TX_N_CHAIN * WMI_TPC_BUF_SIZE];360};361362struct ath10k_tpc_stats {363u32 reg_domain;364u32 chan_freq;365u32 phy_mode;366u32 twice_antenna_reduction;367u32 twice_max_rd_power;368s32 twice_antenna_gain;369u32 power_limit;370u32 num_tx_chain;371u32 ctl;372u32 rate_max;373u8 flag[WMI_TPC_FLAG];374struct ath10k_tpc_table tpc_table[WMI_TPC_FLAG];375};376377struct ath10k_tpc_table_final {378u32 pream_idx[WMI_TPC_FINAL_RATE_MAX];379u8 rate_code[WMI_TPC_FINAL_RATE_MAX];380char tpc_value[WMI_TPC_FINAL_RATE_MAX][WMI_TPC_TX_N_CHAIN * WMI_TPC_BUF_SIZE];381};382383struct ath10k_tpc_stats_final {384u32 reg_domain;385u32 chan_freq;386u32 phy_mode;387u32 twice_antenna_reduction;388u32 twice_max_rd_power;389s32 twice_antenna_gain;390u32 power_limit;391u32 num_tx_chain;392u32 ctl;393u32 rate_max;394u8 flag[WMI_TPC_FLAG];395struct ath10k_tpc_table_final tpc_table_final[WMI_TPC_FLAG];396};397398struct ath10k_dfs_stats {399u32 phy_errors;400u32 pulses_total;401u32 pulses_detected;402u32 pulses_discarded;403u32 radar_detected;404};405406enum ath10k_radar_confirmation_state {407ATH10K_RADAR_CONFIRMATION_IDLE = 0,408ATH10K_RADAR_CONFIRMATION_INPROGRESS,409ATH10K_RADAR_CONFIRMATION_STOPPED,410};411412struct ath10k_radar_found_info {413u32 pri_min;414u32 pri_max;415u32 width_min;416u32 width_max;417u32 sidx_min;418u32 sidx_max;419};420421#define ATH10K_MAX_NUM_PEER_IDS (1 << 11) /* htt rx_desc limit */422423struct ath10k_peer {424struct list_head list;425struct ieee80211_vif *vif;426struct ieee80211_sta *sta;427428bool removed;429int vdev_id;430u8 addr[ETH_ALEN];431DECLARE_BITMAP(peer_ids, ATH10K_MAX_NUM_PEER_IDS);432433/* protected by ar->data_lock */434struct ieee80211_key_conf *keys[WMI_MAX_KEY_INDEX + 1];435union htt_rx_pn_t tids_last_pn[ATH10K_TXRX_NUM_EXT_TIDS];436bool tids_last_pn_valid[ATH10K_TXRX_NUM_EXT_TIDS];437union htt_rx_pn_t frag_tids_last_pn[ATH10K_TXRX_NUM_EXT_TIDS];438u32 frag_tids_seq[ATH10K_TXRX_NUM_EXT_TIDS];439struct {440enum htt_security_types sec_type;441int pn_len;442} rx_pn[ATH10K_HTT_TXRX_PEER_SECURITY_MAX];443};444445struct ath10k_txq {446struct list_head list;447unsigned long num_fw_queued;448unsigned long num_push_allowed;449};450451enum ath10k_pkt_rx_err {452ATH10K_PKT_RX_ERR_FCS,453ATH10K_PKT_RX_ERR_TKIP,454ATH10K_PKT_RX_ERR_CRYPT,455ATH10K_PKT_RX_ERR_PEER_IDX_INVAL,456ATH10K_PKT_RX_ERR_MAX,457};458459enum ath10k_ampdu_subfrm_num {460ATH10K_AMPDU_SUBFRM_NUM_10,461ATH10K_AMPDU_SUBFRM_NUM_20,462ATH10K_AMPDU_SUBFRM_NUM_30,463ATH10K_AMPDU_SUBFRM_NUM_40,464ATH10K_AMPDU_SUBFRM_NUM_50,465ATH10K_AMPDU_SUBFRM_NUM_60,466ATH10K_AMPDU_SUBFRM_NUM_MORE,467ATH10K_AMPDU_SUBFRM_NUM_MAX,468};469470enum ath10k_amsdu_subfrm_num {471ATH10K_AMSDU_SUBFRM_NUM_1,472ATH10K_AMSDU_SUBFRM_NUM_2,473ATH10K_AMSDU_SUBFRM_NUM_3,474ATH10K_AMSDU_SUBFRM_NUM_4,475ATH10K_AMSDU_SUBFRM_NUM_MORE,476ATH10K_AMSDU_SUBFRM_NUM_MAX,477};478479struct ath10k_sta_tid_stats {480unsigned long rx_pkt_from_fw;481unsigned long rx_pkt_unchained;482unsigned long rx_pkt_drop_chained;483unsigned long rx_pkt_drop_filter;484unsigned long rx_pkt_err[ATH10K_PKT_RX_ERR_MAX];485unsigned long rx_pkt_queued_for_mac;486unsigned long rx_pkt_ampdu[ATH10K_AMPDU_SUBFRM_NUM_MAX];487unsigned long rx_pkt_amsdu[ATH10K_AMSDU_SUBFRM_NUM_MAX];488};489490enum ath10k_counter_type {491ATH10K_COUNTER_TYPE_BYTES,492ATH10K_COUNTER_TYPE_PKTS,493ATH10K_COUNTER_TYPE_MAX,494};495496enum ath10k_stats_type {497ATH10K_STATS_TYPE_SUCC,498ATH10K_STATS_TYPE_FAIL,499ATH10K_STATS_TYPE_RETRY,500ATH10K_STATS_TYPE_AMPDU,501ATH10K_STATS_TYPE_MAX,502};503504struct ath10k_htt_data_stats {505u64 legacy[ATH10K_COUNTER_TYPE_MAX][ATH10K_LEGACY_NUM];506u64 ht[ATH10K_COUNTER_TYPE_MAX][ATH10K_HT_MCS_NUM];507u64 vht[ATH10K_COUNTER_TYPE_MAX][ATH10K_VHT_MCS_NUM];508u64 bw[ATH10K_COUNTER_TYPE_MAX][ATH10K_BW_NUM];509u64 nss[ATH10K_COUNTER_TYPE_MAX][ATH10K_NSS_NUM];510u64 gi[ATH10K_COUNTER_TYPE_MAX][ATH10K_GI_NUM];511u64 rate_table[ATH10K_COUNTER_TYPE_MAX][ATH10K_RATE_TABLE_NUM];512};513514struct ath10k_htt_tx_stats {515struct ath10k_htt_data_stats stats[ATH10K_STATS_TYPE_MAX];516u64 tx_duration;517u64 ba_fails;518u64 ack_fails;519};520521#define ATH10K_TID_MAX 8522523struct ath10k_sta {524struct ath10k_vif *arvif;525526/* the following are protected by ar->data_lock */527u32 changed; /* IEEE80211_RC_* */528u32 bw;529u32 nss;530u32 smps;531u16 peer_id;532struct rate_info txrate;533struct ieee80211_tx_info tx_info;534u32 tx_retries;535u32 tx_failed;536u32 last_tx_bitrate;537538u32 rx_rate_code;539u32 rx_bitrate_kbps;540u32 tx_rate_code;541u32 tx_bitrate_kbps;542struct work_struct update_wk;543u64 rx_duration;544struct ath10k_htt_tx_stats *tx_stats;545u32 ucast_cipher;546547#ifdef CONFIG_MAC80211_DEBUGFS548/* protected by conf_mutex */549bool aggr_mode;550551/* Protected with ar->data_lock */552struct ath10k_sta_tid_stats tid_stats[IEEE80211_NUM_TIDS + 1];553#endif554/* Protected with ar->data_lock */555u32 peer_ps_state;556struct work_struct tid_config_wk;557int noack[ATH10K_TID_MAX];558int retry_long[ATH10K_TID_MAX];559int ampdu[ATH10K_TID_MAX];560u8 rate_ctrl[ATH10K_TID_MAX];561u32 rate_code[ATH10K_TID_MAX];562int rtscts[ATH10K_TID_MAX];563};564565#define ATH10K_VDEV_SETUP_TIMEOUT_HZ (5 * HZ)566#define ATH10K_VDEV_DELETE_TIMEOUT_HZ (5 * HZ)567568enum ath10k_beacon_state {569ATH10K_BEACON_SCHEDULED = 0,570ATH10K_BEACON_SENDING,571ATH10K_BEACON_SENT,572};573574struct ath10k_vif {575struct list_head list;576577u32 vdev_id;578u16 peer_id;579enum wmi_vdev_type vdev_type;580enum wmi_vdev_subtype vdev_subtype;581u32 beacon_interval;582u32 dtim_period;583struct sk_buff *beacon;584/* protected by data_lock */585enum ath10k_beacon_state beacon_state;586void *beacon_buf;587dma_addr_t beacon_paddr;588unsigned long tx_paused; /* arbitrary values defined by target */589590struct ath10k *ar;591struct ieee80211_vif *vif;592593bool is_started;594bool is_up;595bool spectral_enabled;596bool ps;597u32 aid;598u8 bssid[ETH_ALEN];599600struct ieee80211_key_conf *wep_keys[WMI_MAX_KEY_INDEX + 1];601s8 def_wep_key_idx;602603u16 tx_seq_no;604605union {606struct {607u32 uapsd;608} sta;609struct {610/* 512 stations */611u8 tim_bitmap[64];612u8 tim_len;613u32 ssid_len;614u8 ssid[IEEE80211_MAX_SSID_LEN];615bool hidden_ssid;616/* P2P_IE with NoA attribute for P2P_GO case */617u32 noa_len;618u8 *noa_data;619} ap;620} u;621622bool use_cts_prot;623bool nohwcrypt;624int num_legacy_stations;625int txpower;626bool ftm_responder;627struct wmi_wmm_params_all_arg wmm_params;628struct work_struct ap_csa_work;629struct delayed_work connection_loss_work;630struct cfg80211_bitrate_mask bitrate_mask;631632/* For setting VHT peer fixed rate, protected by conf_mutex */633int vht_num_rates;634u8 vht_pfr;635u32 tid_conf_changed[ATH10K_TID_MAX];636int noack[ATH10K_TID_MAX];637int retry_long[ATH10K_TID_MAX];638int ampdu[ATH10K_TID_MAX];639u8 rate_ctrl[ATH10K_TID_MAX];640u32 rate_code[ATH10K_TID_MAX];641int rtscts[ATH10K_TID_MAX];642u32 tids_rst;643};644645struct ath10k_vif_iter {646u32 vdev_id;647struct ath10k_vif *arvif;648};649650/* Copy Engine register dump, protected by ce-lock */651struct ath10k_ce_crash_data {652__le32 base_addr;653__le32 src_wr_idx;654__le32 src_r_idx;655__le32 dst_wr_idx;656__le32 dst_r_idx;657};658659struct ath10k_ce_crash_hdr {660__le32 ce_count;661__le32 reserved[3]; /* for future use */662struct ath10k_ce_crash_data entries[];663};664665#define MAX_MEM_DUMP_TYPE 5666667/* used for crash-dump storage, protected by data-lock */668struct ath10k_fw_crash_data {669guid_t guid;670struct timespec64 timestamp;671__le32 registers[REG_DUMP_COUNT_QCA988X];672struct ath10k_ce_crash_data ce_crash_data[CE_COUNT_MAX];673674u8 *ramdump_buf;675size_t ramdump_buf_len;676};677678struct ath10k_debug {679struct dentry *debugfs_phy;680681struct ath10k_fw_stats fw_stats;682struct completion fw_stats_complete;683bool fw_stats_done;684685unsigned long htt_stats_mask;686unsigned long reset_htt_stats;687struct delayed_work htt_stats_dwork;688struct ath10k_dfs_stats dfs_stats;689struct ath_dfs_pool_stats dfs_pool_stats;690691/* used for tpc-dump storage, protected by data-lock */692struct ath10k_tpc_stats *tpc_stats;693struct ath10k_tpc_stats_final *tpc_stats_final;694695struct completion tpc_complete;696697/* protected by conf_mutex */698u64 fw_dbglog_mask;699u32 fw_dbglog_level;700u32 reg_addr;701u32 nf_cal_period;702void *cal_data;703u32 enable_extd_tx_stats;704u8 fw_dbglog_mode;705};706707enum ath10k_state {708ATH10K_STATE_OFF = 0,709ATH10K_STATE_ON,710711/* When doing firmware recovery the device is first powered down.712* mac80211 is supposed to call in to start() hook later on. It is713* however possible that driver unloading and firmware crash overlap.714* mac80211 can wait on conf_mutex in stop() while the device is715* stopped in ath10k_core_restart() work holding conf_mutex. The state716* RESTARTED means that the device is up and mac80211 has started hw717* reconfiguration. Once mac80211 is done with the reconfiguration we718* set the state to STATE_ON in reconfig_complete().719*/720ATH10K_STATE_RESTARTING,721ATH10K_STATE_RESTARTED,722723/* The device has crashed while restarting hw. This state is like ON724* but commands are blocked in HTC and -ECOMM response is given. This725* prevents completion timeouts and makes the driver more responsive to726* userspace commands. This is also prevents recursive recovery.727*/728ATH10K_STATE_WEDGED,729730/* factory tests */731ATH10K_STATE_UTF,732};733734enum ath10k_firmware_mode {735/* the default mode, standard 802.11 functionality */736ATH10K_FIRMWARE_MODE_NORMAL,737738/* factory tests etc */739ATH10K_FIRMWARE_MODE_UTF,740};741742enum ath10k_fw_features {743/* wmi_mgmt_rx_hdr contains extra RSSI information */744ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX = 0,745746/* Firmware from 10X branch. Deprecated, don't use in new code. */747ATH10K_FW_FEATURE_WMI_10X = 1,748749/* firmware support tx frame management over WMI, otherwise it's HTT */750ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX = 2,751752/* Firmware does not support P2P */753ATH10K_FW_FEATURE_NO_P2P = 3,754755/* Firmware 10.2 feature bit. The ATH10K_FW_FEATURE_WMI_10X feature756* bit is required to be set as well. Deprecated, don't use in new757* code.758*/759ATH10K_FW_FEATURE_WMI_10_2 = 4,760761/* Some firmware revisions lack proper multi-interface client powersave762* implementation. Enabling PS could result in connection drops,763* traffic stalls, etc.764*/765ATH10K_FW_FEATURE_MULTI_VIF_PS_SUPPORT = 5,766767/* Some firmware revisions have an incomplete WoWLAN implementation768* despite WMI service bit being advertised. This feature flag is used769* to distinguish whether WoWLAN is really supported or not.770*/771ATH10K_FW_FEATURE_WOWLAN_SUPPORT = 6,772773/* Don't trust error code from otp.bin */774ATH10K_FW_FEATURE_IGNORE_OTP_RESULT = 7,775776/* Some firmware revisions pad 4th hw address to 4 byte boundary making777* it 8 bytes long in Native Wifi Rx decap.778*/779ATH10K_FW_FEATURE_NO_NWIFI_DECAP_4ADDR_PADDING = 8,780781/* Firmware supports bypassing PLL setting on init. */782ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT = 9,783784/* Raw mode support. If supported, FW supports receiving and trasmitting785* frames in raw mode.786*/787ATH10K_FW_FEATURE_RAW_MODE_SUPPORT = 10,788789/* Firmware Supports Adaptive CCA*/790ATH10K_FW_FEATURE_SUPPORTS_ADAPTIVE_CCA = 11,791792/* Firmware supports management frame protection */793ATH10K_FW_FEATURE_MFP_SUPPORT = 12,794795/* Firmware supports pull-push model where host shares it's software796* queue state with firmware and firmware generates fetch requests797* telling host which queues to dequeue tx from.798*799* Primary function of this is improved MU-MIMO performance with800* multiple clients.801*/802ATH10K_FW_FEATURE_PEER_FLOW_CONTROL = 13,803804/* Firmware supports BT-Coex without reloading firmware via pdev param.805* To support Bluetooth coexistence pdev param, WMI_COEX_GPIO_SUPPORT of806* extended resource config should be enabled always. This firmware IE807* is used to configure WMI_COEX_GPIO_SUPPORT.808*/809ATH10K_FW_FEATURE_BTCOEX_PARAM = 14,810811/* Unused flag and proven to be not working, enable this if you want812* to experiment sending NULL func data frames in HTT TX813*/814ATH10K_FW_FEATURE_SKIP_NULL_FUNC_WAR = 15,815816/* Firmware allow other BSS mesh broadcast/multicast frames without817* creating monitor interface. Appropriate rxfilters are programmed for818* mesh vdev by firmware itself. This feature flags will be used for819* not creating monitor vdev while configuring mesh node.820*/821ATH10K_FW_FEATURE_ALLOWS_MESH_BCAST = 16,822823/* Firmware does not support power save in station mode. */824ATH10K_FW_FEATURE_NO_PS = 17,825826/* Firmware allows management tx by reference instead of by value. */827ATH10K_FW_FEATURE_MGMT_TX_BY_REF = 18,828829/* Firmware load is done externally, not by bmi */830ATH10K_FW_FEATURE_NON_BMI = 19,831832/* Firmware sends only one chan_info event per channel */833ATH10K_FW_FEATURE_SINGLE_CHAN_INFO_PER_CHANNEL = 20,834835/* Firmware allows setting peer fixed rate */836ATH10K_FW_FEATURE_PEER_FIXED_RATE = 21,837838/* Firmware support IRAM recovery */839ATH10K_FW_FEATURE_IRAM_RECOVERY = 22,840841/* keep last */842ATH10K_FW_FEATURE_COUNT,843};844845enum ath10k_dev_flags {846/* Indicates that ath10k device is during CAC phase of DFS */847ATH10K_CAC_RUNNING,848ATH10K_FLAG_CORE_REGISTERED,849850/* Device has crashed and needs to restart. This indicates any pending851* waiters should immediately cancel instead of waiting for a time out.852*/853ATH10K_FLAG_CRASH_FLUSH,854855/* Use Raw mode instead of native WiFi Tx/Rx encap mode.856* Raw mode supports both hardware and software crypto. Native WiFi only857* supports hardware crypto.858*/859ATH10K_FLAG_RAW_MODE,860861/* Disable HW crypto engine */862ATH10K_FLAG_HW_CRYPTO_DISABLED,863864/* Bluetooth coexistence enabled */865ATH10K_FLAG_BTCOEX,866867/* Per Station statistics service */868ATH10K_FLAG_PEER_STATS,869870/* Indicates that ath10k device is during recovery process and not complete */871ATH10K_FLAG_RESTARTING,872873/* protected by conf_mutex */874ATH10K_FLAG_NAPI_ENABLED,875};876877enum ath10k_cal_mode {878ATH10K_CAL_MODE_FILE,879ATH10K_CAL_MODE_OTP,880ATH10K_CAL_MODE_DT,881ATH10K_CAL_MODE_NVMEM,882ATH10K_PRE_CAL_MODE_FILE,883ATH10K_PRE_CAL_MODE_DT,884ATH10K_PRE_CAL_MODE_NVMEM,885ATH10K_CAL_MODE_EEPROM,886};887888enum ath10k_crypt_mode {889/* Only use hardware crypto engine */890ATH10K_CRYPT_MODE_HW,891/* Only use software crypto engine */892ATH10K_CRYPT_MODE_SW,893};894895static inline const char *ath10k_cal_mode_str(enum ath10k_cal_mode mode)896{897switch (mode) {898case ATH10K_CAL_MODE_FILE:899return "file";900case ATH10K_CAL_MODE_OTP:901return "otp";902case ATH10K_CAL_MODE_DT:903return "dt";904case ATH10K_CAL_MODE_NVMEM:905return "nvmem";906case ATH10K_PRE_CAL_MODE_FILE:907return "pre-cal-file";908case ATH10K_PRE_CAL_MODE_DT:909return "pre-cal-dt";910case ATH10K_PRE_CAL_MODE_NVMEM:911return "pre-cal-nvmem";912case ATH10K_CAL_MODE_EEPROM:913return "eeprom";914}915916return "unknown";917}918919enum ath10k_scan_state {920ATH10K_SCAN_IDLE,921ATH10K_SCAN_STARTING,922ATH10K_SCAN_RUNNING,923ATH10K_SCAN_ABORTING,924};925926static inline const char *ath10k_scan_state_str(enum ath10k_scan_state state)927{928switch (state) {929case ATH10K_SCAN_IDLE:930return "idle";931case ATH10K_SCAN_STARTING:932return "starting";933case ATH10K_SCAN_RUNNING:934return "running";935case ATH10K_SCAN_ABORTING:936return "aborting";937}938939return "unknown";940}941942enum ath10k_tx_pause_reason {943ATH10K_TX_PAUSE_Q_FULL,944ATH10K_TX_PAUSE_MAX,945};946947struct ath10k_fw_file {948const struct firmware *firmware;949950char fw_version[ETHTOOL_FWVERS_LEN];951952DECLARE_BITMAP(fw_features, ATH10K_FW_FEATURE_COUNT);953954enum ath10k_fw_wmi_op_version wmi_op_version;955enum ath10k_fw_htt_op_version htt_op_version;956957const void *firmware_data;958size_t firmware_len;959960const void *otp_data;961size_t otp_len;962963const void *codeswap_data;964size_t codeswap_len;965966/* The original idea of struct ath10k_fw_file was that it only967* contains struct firmware and pointers to various parts (actual968* firmware binary, otp, metadata etc) of the file. This seg_info969* is actually created separate but as this is used similarly as970* the other firmware components it's more convenient to have it971* here.972*/973struct ath10k_swap_code_seg_info *firmware_swap_code_seg_info;974};975976struct ath10k_fw_components {977const struct firmware *board;978const void *board_data;979size_t board_len;980const struct firmware *ext_board;981const void *ext_board_data;982size_t ext_board_len;983984struct ath10k_fw_file fw_file;985};986987struct ath10k_per_peer_tx_stats {988u32 succ_bytes;989u32 retry_bytes;990u32 failed_bytes;991u8 ratecode;992u8 flags;993u16 peer_id;994u16 succ_pkts;995u16 retry_pkts;996u16 failed_pkts;997u16 duration;998u32 reserved1;999u32 reserved2;1000};10011002enum ath10k_dev_type {1003ATH10K_DEV_TYPE_LL,1004ATH10K_DEV_TYPE_HL,1005};10061007struct ath10k_bus_params {1008u32 chip_id;1009enum ath10k_dev_type dev_type;1010bool link_can_suspend;1011bool hl_msdu_ids;1012};10131014struct ath10k {1015struct ath_common ath_common;1016struct ieee80211_hw *hw;1017struct ieee80211_ops *ops;1018struct device *dev;1019struct msa_region {1020dma_addr_t paddr;1021u32 mem_size;1022void *vaddr;1023} msa;1024u8 mac_addr[ETH_ALEN];10251026enum ath10k_hw_rev hw_rev;1027u16 dev_id;1028u32 chip_id;1029u32 target_version;1030u8 fw_version_major;1031u32 fw_version_minor;1032u16 fw_version_release;1033u16 fw_version_build;1034u32 fw_stats_req_mask;1035u32 phy_capability;1036u32 hw_min_tx_power;1037u32 hw_max_tx_power;1038u32 hw_eeprom_rd;1039u32 ht_cap_info;1040u32 vht_cap_info;1041u32 vht_supp_mcs;1042u32 num_rf_chains;1043u32 max_spatial_stream;1044#if defined(CONFIG_FWLOG)1045u32 fwlog_max_moduleid;1046#endif1047/* protected by conf_mutex */1048u32 low_2ghz_chan;1049u32 high_2ghz_chan;1050u32 low_5ghz_chan;1051u32 high_5ghz_chan;1052bool ani_enabled;1053u32 sys_cap_info;10541055/* protected by data_lock */1056bool hw_rfkill_on;10571058/* protected by conf_mutex */1059u8 ps_state_enable;10601061bool nlo_enabled;1062bool p2p;10631064struct {1065enum ath10k_bus bus;1066const struct ath10k_hif_ops *ops;1067} hif;10681069struct completion target_suspend;1070struct completion driver_recovery;10711072const struct ath10k_hw_regs *regs;1073const struct ath10k_hw_ce_regs *hw_ce_regs;1074const struct ath10k_hw_values *hw_values;1075struct ath10k_bmi bmi;1076struct ath10k_wmi wmi;1077struct ath10k_htc htc;1078struct ath10k_htt htt;10791080struct ath10k_hw_params hw_params;10811082/* contains the firmware images used with ATH10K_FIRMWARE_MODE_NORMAL */1083struct ath10k_fw_components normal_mode_fw;10841085/* READ-ONLY images of the running firmware, which can be either1086* normal or UTF. Do not modify, release etc!1087*/1088const struct ath10k_fw_components *running_fw;10891090const struct firmware *pre_cal_file;1091const struct firmware *cal_file;10921093struct {1094u32 vendor;1095u32 device;1096u32 subsystem_vendor;1097u32 subsystem_device;10981099bool bmi_ids_valid;1100bool qmi_ids_valid;1101u32 qmi_board_id;1102u32 qmi_chip_id;1103u8 bmi_board_id;1104u8 bmi_eboard_id;1105u8 bmi_chip_id;1106bool ext_bid_supported;11071108char bdf_ext[ATH10K_SMBIOS_BDF_EXT_STR_LENGTH];1109} id;11101111int fw_api;1112int bd_api;1113enum ath10k_cal_mode cal_mode;11141115struct {1116struct completion started;1117struct completion completed;1118struct completion on_channel;1119struct delayed_work timeout;1120enum ath10k_scan_state state;1121bool is_roc;1122int vdev_id;1123int roc_freq;1124bool roc_notify;1125} scan;11261127struct {1128struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];1129} mac;11301131/* should never be NULL; needed for regular htt rx */1132struct ieee80211_channel *rx_channel;11331134/* valid during scan; needed for mgmt rx during scan */1135struct ieee80211_channel *scan_channel;11361137/* current operating channel definition */1138struct cfg80211_chan_def chandef;11391140/* currently configured operating channel in firmware */1141struct ieee80211_channel *tgt_oper_chan;11421143unsigned long long free_vdev_map;1144struct ath10k_vif *monitor_arvif;1145bool monitor;1146int monitor_vdev_id;1147bool monitor_started;1148unsigned int filter_flags;1149unsigned long dev_flags;1150bool dfs_block_radar_events;11511152/* protected by conf_mutex */1153bool radar_enabled;1154int num_started_vdevs;11551156/* Protected by conf-mutex */1157u8 cfg_tx_chainmask;1158u8 cfg_rx_chainmask;11591160struct completion install_key_done;11611162int last_wmi_vdev_start_status;1163struct completion vdev_setup_done;1164struct completion vdev_delete_done;1165struct completion peer_stats_info_complete;11661167struct workqueue_struct *workqueue;1168/* Auxiliary workqueue */1169struct workqueue_struct *workqueue_aux;1170struct workqueue_struct *workqueue_tx_complete;1171/* prevents concurrent FW reconfiguration */1172struct mutex conf_mutex;11731174/* protects coredump data */1175struct mutex dump_mutex;11761177/* protects shared structure data */1178spinlock_t data_lock;11791180/* serialize wake_tx_queue calls per ac */1181spinlock_t queue_lock[IEEE80211_NUM_ACS];11821183struct list_head arvifs;1184struct list_head peers;1185struct ath10k_peer *peer_map[ATH10K_MAX_NUM_PEER_IDS];1186wait_queue_head_t peer_mapping_wq;11871188/* protected by conf_mutex */1189int num_peers;1190int num_stations;11911192int max_num_peers;1193int max_num_stations;1194int max_num_vdevs;1195int max_num_tdls_vdevs;1196int num_active_peers;1197int num_tids;11981199struct work_struct svc_rdy_work;1200struct sk_buff *svc_rdy_skb;12011202struct work_struct offchan_tx_work;1203struct sk_buff_head offchan_tx_queue;1204struct completion offchan_tx_completed;1205struct sk_buff *offchan_tx_skb;12061207struct work_struct wmi_mgmt_tx_work;1208struct sk_buff_head wmi_mgmt_tx_queue;12091210enum ath10k_state state;12111212struct work_struct register_work;1213struct work_struct restart_work;1214struct work_struct bundle_tx_work;1215struct work_struct tx_complete_work;12161217/* cycle count is reported twice for each visited channel during scan.1218* access protected by data_lock1219*/1220u32 survey_last_rx_clear_count;1221u32 survey_last_cycle_count;1222struct survey_info survey[ATH10K_NUM_CHANS];12231224/* Channel info events are expected to come in pairs without and with1225* COMPLETE flag set respectively for each channel visit during scan.1226*1227* However there are deviations from this rule. This flag is used to1228* avoid reporting garbage data.1229*/1230bool ch_info_can_report_survey;1231struct completion bss_survey_done;12321233struct dfs_pattern_detector *dfs_detector;12341235unsigned long tx_paused; /* see ATH10K_TX_PAUSE_ */12361237#ifdef CONFIG_ATH10K_DEBUGFS1238struct ath10k_debug debug;1239struct {1240/* relay(fs) channel for spectral scan */1241struct rchan *rfs_chan_spec_scan;12421243/* spectral_mode and spec_config are protected by conf_mutex */1244enum ath10k_spectral_mode mode;1245struct ath10k_spec_scan config;1246} spectral;1247#endif12481249u32 pktlog_filter;12501251#ifdef CONFIG_DEV_COREDUMP1252struct {1253struct ath10k_fw_crash_data *fw_crash_data;1254} coredump;1255#endif12561257struct {1258/* protected by conf_mutex */1259struct ath10k_fw_components utf_mode_fw;12601261/* protected by data_lock */1262bool utf_monitor;1263} testmode;12641265struct {1266/* protected by data_lock */1267u32 rx_crc_err_drop;1268u32 fw_crash_counter;1269u32 fw_warm_reset_counter;1270u32 fw_cold_reset_counter;1271} stats;12721273struct ath10k_thermal thermal;1274struct ath10k_wow wow;1275struct ath10k_per_peer_tx_stats peer_tx_stats;12761277#if defined(CONFIG_FWLOG)1278struct work_struct fwlog_tx_work;1279struct sk_buff_head fwlog_tx_queue;1280#endif12811282/* NAPI */1283struct net_device napi_dev;1284struct napi_struct napi;12851286struct work_struct set_coverage_class_work;1287/* protected by conf_mutex */1288struct {1289/* writing also protected by data_lock */1290s16 coverage_class;12911292u32 reg_phyclk;1293u32 reg_slottime_conf;1294u32 reg_slottime_orig;1295u32 reg_ack_cts_timeout_conf;1296u32 reg_ack_cts_timeout_orig;1297} fw_coverage;12981299u32 ampdu_reference;13001301const u8 *wmi_key_cipher;1302void *ce_priv;13031304u32 sta_tid_stats_mask;13051306/* protected by data_lock */1307enum ath10k_radar_confirmation_state radar_conf_state;1308struct ath10k_radar_found_info last_radar_info;1309struct work_struct radar_confirmation_work;1310struct ath10k_bus_params bus_param;1311struct completion peer_delete_done;13121313bool coex_support;1314int coex_gpio_pin;13151316s32 tx_power_2g_limit;1317s32 tx_power_5g_limit;13181319/* must be last */1320u8 drv_priv[] __aligned(sizeof(void *));1321};13221323static inline bool ath10k_peer_stats_enabled(struct ath10k *ar)1324{1325if (test_bit(ATH10K_FLAG_PEER_STATS, &ar->dev_flags) &&1326test_bit(WMI_SERVICE_PEER_STATS, ar->wmi.svc_map))1327return true;13281329return false;1330}13311332extern unsigned int ath10k_frame_mode;1333extern unsigned long ath10k_coredump_mask;13341335void ath10k_core_napi_sync_disable(struct ath10k *ar);1336void ath10k_core_napi_enable(struct ath10k *ar);1337struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,1338enum ath10k_bus bus,1339enum ath10k_hw_rev hw_rev,1340const struct ath10k_hif_ops *hif_ops);1341void ath10k_core_destroy(struct ath10k *ar);1342void ath10k_core_get_fw_features_str(struct ath10k *ar,1343char *buf,1344size_t max_len);1345int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name,1346struct ath10k_fw_file *fw_file);13471348int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode,1349const struct ath10k_fw_components *fw_components);1350int ath10k_wait_for_suspend(struct ath10k *ar, u32 suspend_opt);1351void ath10k_core_stop(struct ath10k *ar);1352void ath10k_core_start_recovery(struct ath10k *ar);1353int ath10k_core_register(struct ath10k *ar,1354const struct ath10k_bus_params *bus_params);1355void ath10k_core_unregister(struct ath10k *ar);1356int ath10k_core_fetch_board_file(struct ath10k *ar, int bd_ie_type);1357int ath10k_core_check_dt(struct ath10k *ar);1358void ath10k_core_free_board_files(struct ath10k *ar);13591360#endif /* _CORE_H_ */136113621363