Path: blob/main/sys/contrib/dev/athk/ath10k/htt.h
105545 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, The Linux Foundation. All rights reserved.5* Copyright (c) 2021, 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.6*/78#ifndef _HTT_H_9#define _HTT_H_1011#include <linux/bug.h>12#include <linux/interrupt.h>13#include <linux/dmapool.h>14#include <linux/hashtable.h>15#include <linux/kfifo.h>16#include <net/mac80211.h>17#if defined(__FreeBSD__)18#include <linux/wait.h>19#endif2021#include "htc.h"22#include "hw.h"23#include "rx_desc.h"2425enum htt_dbg_stats_type {26HTT_DBG_STATS_WAL_PDEV_TXRX = 1 << 0,27HTT_DBG_STATS_RX_REORDER = 1 << 1,28HTT_DBG_STATS_RX_RATE_INFO = 1 << 2,29HTT_DBG_STATS_TX_PPDU_LOG = 1 << 3,30HTT_DBG_STATS_TX_RATE_INFO = 1 << 4,31/* bits 5-23 currently reserved */3233HTT_DBG_NUM_STATS /* keep this last */34};3536enum htt_h2t_msg_type { /* host-to-target */37HTT_H2T_MSG_TYPE_VERSION_REQ = 0,38HTT_H2T_MSG_TYPE_TX_FRM = 1,39HTT_H2T_MSG_TYPE_RX_RING_CFG = 2,40HTT_H2T_MSG_TYPE_STATS_REQ = 3,41HTT_H2T_MSG_TYPE_SYNC = 4,42HTT_H2T_MSG_TYPE_AGGR_CFG = 5,43HTT_H2T_MSG_TYPE_FRAG_DESC_BANK_CFG = 6,4445/* This command is used for sending management frames in HTT < 3.0.46* HTT >= 3.0 uses TX_FRM for everything.47*/48HTT_H2T_MSG_TYPE_MGMT_TX = 7,49HTT_H2T_MSG_TYPE_TX_FETCH_RESP = 11,5051HTT_H2T_NUM_MSGS /* keep this last */52};5354struct htt_cmd_hdr {55u8 msg_type;56} __packed;5758struct htt_ver_req {59u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];60} __packed;6162/*63* HTT tx MSDU descriptor64*65* The HTT tx MSDU descriptor is created by the host HTT SW for each66* tx MSDU. The HTT tx MSDU descriptor contains the information that67* the target firmware needs for the FW's tx processing, particularly68* for creating the HW msdu descriptor.69* The same HTT tx descriptor is used for HL and LL systems, though70* a few fields within the tx descriptor are used only by LL or71* only by HL.72* The HTT tx descriptor is defined in two manners: by a struct with73* bitfields, and by a series of [dword offset, bit mask, bit shift]74* definitions.75* The target should use the struct def, for simplicity and clarity,76* but the host shall use the bit-mast + bit-shift defs, to be endian-77* neutral. Specifically, the host shall use the get/set macros built78* around the mask + shift defs.79*/80struct htt_data_tx_desc_frag {81union {82struct double_word_addr {83__le32 paddr;84__le32 len;85} __packed dword_addr;86struct triple_word_addr {87__le32 paddr_lo;88__le16 paddr_hi;89__le16 len_16;90} __packed tword_addr;91} __packed;92} __packed;9394struct htt_msdu_ext_desc {95__le32 tso_flag[3];96__le16 ip_identification;97u8 flags;98u8 reserved;99struct htt_data_tx_desc_frag frags[6];100};101102struct htt_msdu_ext_desc_64 {103__le32 tso_flag[5];104__le16 ip_identification;105u8 flags;106u8 reserved;107struct htt_data_tx_desc_frag frags[6];108};109110#define HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE BIT(0)111#define HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE BIT(1)112#define HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE BIT(2)113#define HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE BIT(3)114#define HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE BIT(4)115116#define HTT_MSDU_CHECKSUM_ENABLE (HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE \117| HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE \118| HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE \119| HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE \120| HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE)121122#define HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE_64 BIT(16)123#define HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE_64 BIT(17)124#define HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE_64 BIT(18)125#define HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE_64 BIT(19)126#define HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE_64 BIT(20)127#define HTT_MSDU_EXT_DESC_FLAG_PARTIAL_CSUM_ENABLE_64 BIT(21)128129#define HTT_MSDU_CHECKSUM_ENABLE_64 (HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE_64 \130| HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE_64 \131| HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE_64 \132| HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE_64 \133| HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE_64)134135enum htt_data_tx_desc_flags0 {136HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT = 1 << 0,137HTT_DATA_TX_DESC_FLAGS0_NO_AGGR = 1 << 1,138HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT = 1 << 2,139HTT_DATA_TX_DESC_FLAGS0_NO_CLASSIFY = 1 << 3,140HTT_DATA_TX_DESC_FLAGS0_RSVD0 = 1 << 4141#define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_MASK 0xE0142#define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_LSB 5143};144145enum htt_data_tx_desc_flags1 {146#define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_BITS 6147#define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_MASK 0x003F148#define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_LSB 0149#define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_BITS 5150#define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_MASK 0x07C0151#define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_LSB 6152HTT_DATA_TX_DESC_FLAGS1_POSTPONED = 1 << 11,153HTT_DATA_TX_DESC_FLAGS1_MORE_IN_BATCH = 1 << 12,154HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD = 1 << 13,155HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD = 1 << 14,156HTT_DATA_TX_DESC_FLAGS1_TX_COMPLETE = 1 << 15157};158159#define HTT_TX_CREDIT_DELTA_ABS_M 0xffff0000160#define HTT_TX_CREDIT_DELTA_ABS_S 16161#define HTT_TX_CREDIT_DELTA_ABS_GET(word) \162(((word) & HTT_TX_CREDIT_DELTA_ABS_M) >> HTT_TX_CREDIT_DELTA_ABS_S)163164#define HTT_TX_CREDIT_SIGN_BIT_M 0x00000100165#define HTT_TX_CREDIT_SIGN_BIT_S 8166#define HTT_TX_CREDIT_SIGN_BIT_GET(word) \167(((word) & HTT_TX_CREDIT_SIGN_BIT_M) >> HTT_TX_CREDIT_SIGN_BIT_S)168169enum htt_data_tx_ext_tid {170HTT_DATA_TX_EXT_TID_NON_QOS_MCAST_BCAST = 16,171HTT_DATA_TX_EXT_TID_MGMT = 17,172HTT_DATA_TX_EXT_TID_INVALID = 31173};174175#define HTT_INVALID_PEERID 0xFFFF176177/*178* htt_data_tx_desc - used for data tx path179*180* Note: vdev_id irrelevant for pkt_type == raw and no_classify == 1.181* ext_tid: for qos-data frames (0-15), see %HTT_DATA_TX_EXT_TID_182* for special kinds of tids183* postponed: only for HL hosts. indicates if this is a resend184* (HL hosts manage queues on the host )185* more_in_batch: only for HL hosts. indicates if more packets are186* pending. this allows target to wait and aggregate187* freq: 0 means home channel of given vdev. intended for offchannel188*/189struct htt_data_tx_desc {190u8 flags0; /* %HTT_DATA_TX_DESC_FLAGS0_ */191__le16 flags1; /* %HTT_DATA_TX_DESC_FLAGS1_ */192__le16 len;193__le16 id;194__le32 frags_paddr;195union {196__le32 peerid;197struct {198__le16 peerid;199__le16 freq;200} __packed offchan_tx;201} __packed;202u8 prefetch[0]; /* start of frame, for FW classification engine */203} __packed;204205struct htt_data_tx_desc_64 {206u8 flags0; /* %HTT_DATA_TX_DESC_FLAGS0_ */207__le16 flags1; /* %HTT_DATA_TX_DESC_FLAGS1_ */208__le16 len;209__le16 id;210__le64 frags_paddr;211union {212__le32 peerid;213struct {214__le16 peerid;215__le16 freq;216} __packed offchan_tx;217} __packed;218u8 prefetch[0]; /* start of frame, for FW classification engine */219} __packed;220221enum htt_rx_ring_flags {222HTT_RX_RING_FLAGS_MAC80211_HDR = 1 << 0,223HTT_RX_RING_FLAGS_MSDU_PAYLOAD = 1 << 1,224HTT_RX_RING_FLAGS_PPDU_START = 1 << 2,225HTT_RX_RING_FLAGS_PPDU_END = 1 << 3,226HTT_RX_RING_FLAGS_MPDU_START = 1 << 4,227HTT_RX_RING_FLAGS_MPDU_END = 1 << 5,228HTT_RX_RING_FLAGS_MSDU_START = 1 << 6,229HTT_RX_RING_FLAGS_MSDU_END = 1 << 7,230HTT_RX_RING_FLAGS_RX_ATTENTION = 1 << 8,231HTT_RX_RING_FLAGS_FRAG_INFO = 1 << 9,232HTT_RX_RING_FLAGS_UNICAST_RX = 1 << 10,233HTT_RX_RING_FLAGS_MULTICAST_RX = 1 << 11,234HTT_RX_RING_FLAGS_CTRL_RX = 1 << 12,235HTT_RX_RING_FLAGS_MGMT_RX = 1 << 13,236HTT_RX_RING_FLAGS_NULL_RX = 1 << 14,237HTT_RX_RING_FLAGS_PHY_DATA_RX = 1 << 15238};239240#define HTT_RX_RING_SIZE_MIN 128241#define HTT_RX_RING_SIZE_MAX 2048242#define HTT_RX_RING_SIZE HTT_RX_RING_SIZE_MAX243#define HTT_RX_RING_FILL_LEVEL (((HTT_RX_RING_SIZE) / 2) - 1)244#define HTT_RX_RING_FILL_LEVEL_DUAL_MAC (HTT_RX_RING_SIZE - 1)245246struct htt_rx_ring_rx_desc_offsets {247/* the following offsets are in 4-byte units */248__le16 mac80211_hdr_offset;249__le16 msdu_payload_offset;250__le16 ppdu_start_offset;251__le16 ppdu_end_offset;252__le16 mpdu_start_offset;253__le16 mpdu_end_offset;254__le16 msdu_start_offset;255__le16 msdu_end_offset;256__le16 rx_attention_offset;257__le16 frag_info_offset;258} __packed;259260struct htt_rx_ring_setup_ring32 {261__le32 fw_idx_shadow_reg_paddr;262__le32 rx_ring_base_paddr;263__le16 rx_ring_len; /* in 4-byte words */264__le16 rx_ring_bufsize; /* rx skb size - in bytes */265__le16 flags; /* %HTT_RX_RING_FLAGS_ */266__le16 fw_idx_init_val;267268struct htt_rx_ring_rx_desc_offsets offsets;269} __packed;270271struct htt_rx_ring_setup_ring64 {272__le64 fw_idx_shadow_reg_paddr;273__le64 rx_ring_base_paddr;274__le16 rx_ring_len; /* in 4-byte words */275__le16 rx_ring_bufsize; /* rx skb size - in bytes */276__le16 flags; /* %HTT_RX_RING_FLAGS_ */277__le16 fw_idx_init_val;278279struct htt_rx_ring_rx_desc_offsets offsets;280} __packed;281282struct htt_rx_ring_setup_hdr {283u8 num_rings; /* supported values: 1, 2 */284__le16 rsvd0;285} __packed;286287struct htt_rx_ring_setup_32 {288struct htt_rx_ring_setup_hdr hdr;289struct htt_rx_ring_setup_ring32 rings[];290} __packed;291292struct htt_rx_ring_setup_64 {293struct htt_rx_ring_setup_hdr hdr;294struct htt_rx_ring_setup_ring64 rings[];295} __packed;296297/*298* htt_stats_req - request target to send specified statistics299*300* @msg_type: hardcoded %HTT_H2T_MSG_TYPE_STATS_REQ301* @upload_types: see %htt_dbg_stats_type. this is 24bit field actually302* so make sure its little-endian.303* @reset_types: see %htt_dbg_stats_type. this is 24bit field actually304* so make sure its little-endian.305* @cfg_val: stat_type specific configuration306* @stat_type: see %htt_dbg_stats_type307* @cookie_lsb: used for confirmation message from target->host308* @cookie_msb: ditto as %cookie309*/310struct htt_stats_req {311u8 upload_types[3];312u8 rsvd0;313u8 reset_types[3];314struct {315u8 mpdu_bytes;316u8 mpdu_num_msdus;317u8 msdu_bytes;318} __packed;319u8 stat_type;320__le32 cookie_lsb;321__le32 cookie_msb;322} __packed;323324#define HTT_STATS_REQ_CFG_STAT_TYPE_INVALID 0xff325#define HTT_STATS_BIT_MASK GENMASK(16, 0)326327/*328* htt_oob_sync_req - request out-of-band sync329*330* The HTT SYNC tells the target to suspend processing of subsequent331* HTT host-to-target messages until some other target agent locally332* informs the target HTT FW that the current sync counter is equal to333* or greater than (in a modulo sense) the sync counter specified in334* the SYNC message.335*336* This allows other host-target components to synchronize their operation337* with HTT, e.g. to ensure that tx frames don't get transmitted until a338* security key has been downloaded to and activated by the target.339* In the absence of any explicit synchronization counter value340* specification, the target HTT FW will use zero as the default current341* sync value.342*343* The HTT target FW will suspend its host->target message processing as long344* as 0 < (in-band sync counter - out-of-band sync counter) & 0xff < 128.345*/346struct htt_oob_sync_req {347u8 sync_count;348__le16 rsvd0;349} __packed;350351struct htt_aggr_conf {352u8 max_num_ampdu_subframes;353/* amsdu_subframes is limited by 0x1F mask */354u8 max_num_amsdu_subframes;355} __packed;356357struct htt_aggr_conf_v2 {358u8 max_num_ampdu_subframes;359/* amsdu_subframes is limited by 0x1F mask */360u8 max_num_amsdu_subframes;361u8 reserved;362} __packed;363364#define HTT_MGMT_FRM_HDR_DOWNLOAD_LEN 32365struct htt_mgmt_tx_desc_qca99x0 {366__le32 rate;367} __packed;368369struct htt_mgmt_tx_desc {370u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];371__le32 msdu_paddr;372__le32 desc_id;373__le32 len;374__le32 vdev_id;375u8 hdr[HTT_MGMT_FRM_HDR_DOWNLOAD_LEN];376union {377struct htt_mgmt_tx_desc_qca99x0 qca99x0;378} __packed;379} __packed;380381enum htt_mgmt_tx_status {382HTT_MGMT_TX_STATUS_OK = 0,383HTT_MGMT_TX_STATUS_RETRY = 1,384HTT_MGMT_TX_STATUS_DROP = 2385};386387/*=== target -> host messages ===============================================*/388389enum htt_main_t2h_msg_type {390HTT_MAIN_T2H_MSG_TYPE_VERSION_CONF = 0x0,391HTT_MAIN_T2H_MSG_TYPE_RX_IND = 0x1,392HTT_MAIN_T2H_MSG_TYPE_RX_FLUSH = 0x2,393HTT_MAIN_T2H_MSG_TYPE_PEER_MAP = 0x3,394HTT_MAIN_T2H_MSG_TYPE_PEER_UNMAP = 0x4,395HTT_MAIN_T2H_MSG_TYPE_RX_ADDBA = 0x5,396HTT_MAIN_T2H_MSG_TYPE_RX_DELBA = 0x6,397HTT_MAIN_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,398HTT_MAIN_T2H_MSG_TYPE_PKTLOG = 0x8,399HTT_MAIN_T2H_MSG_TYPE_STATS_CONF = 0x9,400HTT_MAIN_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,401HTT_MAIN_T2H_MSG_TYPE_SEC_IND = 0xb,402HTT_MAIN_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,403HTT_MAIN_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,404HTT_MAIN_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0xf,405HTT_MAIN_T2H_MSG_TYPE_RX_PN_IND = 0x10,406HTT_MAIN_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x11,407HTT_MAIN_T2H_MSG_TYPE_TEST,408/* keep this last */409HTT_MAIN_T2H_NUM_MSGS410};411412enum htt_10x_t2h_msg_type {413HTT_10X_T2H_MSG_TYPE_VERSION_CONF = 0x0,414HTT_10X_T2H_MSG_TYPE_RX_IND = 0x1,415HTT_10X_T2H_MSG_TYPE_RX_FLUSH = 0x2,416HTT_10X_T2H_MSG_TYPE_PEER_MAP = 0x3,417HTT_10X_T2H_MSG_TYPE_PEER_UNMAP = 0x4,418HTT_10X_T2H_MSG_TYPE_RX_ADDBA = 0x5,419HTT_10X_T2H_MSG_TYPE_RX_DELBA = 0x6,420HTT_10X_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,421HTT_10X_T2H_MSG_TYPE_PKTLOG = 0x8,422HTT_10X_T2H_MSG_TYPE_STATS_CONF = 0x9,423HTT_10X_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,424HTT_10X_T2H_MSG_TYPE_SEC_IND = 0xb,425HTT_10X_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc,426HTT_10X_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,427HTT_10X_T2H_MSG_TYPE_TEST = 0xe,428HTT_10X_T2H_MSG_TYPE_CHAN_CHANGE = 0xf,429HTT_10X_T2H_MSG_TYPE_AGGR_CONF = 0x11,430HTT_10X_T2H_MSG_TYPE_STATS_NOUPLOAD = 0x12,431HTT_10X_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0x13,432/* keep this last */433HTT_10X_T2H_NUM_MSGS434};435436enum htt_tlv_t2h_msg_type {437HTT_TLV_T2H_MSG_TYPE_VERSION_CONF = 0x0,438HTT_TLV_T2H_MSG_TYPE_RX_IND = 0x1,439HTT_TLV_T2H_MSG_TYPE_RX_FLUSH = 0x2,440HTT_TLV_T2H_MSG_TYPE_PEER_MAP = 0x3,441HTT_TLV_T2H_MSG_TYPE_PEER_UNMAP = 0x4,442HTT_TLV_T2H_MSG_TYPE_RX_ADDBA = 0x5,443HTT_TLV_T2H_MSG_TYPE_RX_DELBA = 0x6,444HTT_TLV_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,445HTT_TLV_T2H_MSG_TYPE_PKTLOG = 0x8,446HTT_TLV_T2H_MSG_TYPE_STATS_CONF = 0x9,447HTT_TLV_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,448HTT_TLV_T2H_MSG_TYPE_SEC_IND = 0xb,449HTT_TLV_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc, /* deprecated */450HTT_TLV_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,451HTT_TLV_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,452HTT_TLV_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0xf,453HTT_TLV_T2H_MSG_TYPE_RX_PN_IND = 0x10,454HTT_TLV_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x11,455HTT_TLV_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND = 0x12,456/* 0x13 reservd */457HTT_TLV_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE = 0x14,458HTT_TLV_T2H_MSG_TYPE_CHAN_CHANGE = 0x15,459HTT_TLV_T2H_MSG_TYPE_RX_OFLD_PKT_ERR = 0x16,460HTT_TLV_T2H_MSG_TYPE_TEST,461/* keep this last */462HTT_TLV_T2H_NUM_MSGS463};464465enum htt_10_4_t2h_msg_type {466HTT_10_4_T2H_MSG_TYPE_VERSION_CONF = 0x0,467HTT_10_4_T2H_MSG_TYPE_RX_IND = 0x1,468HTT_10_4_T2H_MSG_TYPE_RX_FLUSH = 0x2,469HTT_10_4_T2H_MSG_TYPE_PEER_MAP = 0x3,470HTT_10_4_T2H_MSG_TYPE_PEER_UNMAP = 0x4,471HTT_10_4_T2H_MSG_TYPE_RX_ADDBA = 0x5,472HTT_10_4_T2H_MSG_TYPE_RX_DELBA = 0x6,473HTT_10_4_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,474HTT_10_4_T2H_MSG_TYPE_PKTLOG = 0x8,475HTT_10_4_T2H_MSG_TYPE_STATS_CONF = 0x9,476HTT_10_4_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,477HTT_10_4_T2H_MSG_TYPE_SEC_IND = 0xb,478HTT_10_4_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc,479HTT_10_4_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,480HTT_10_4_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,481HTT_10_4_T2H_MSG_TYPE_CHAN_CHANGE = 0xf,482HTT_10_4_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0x10,483HTT_10_4_T2H_MSG_TYPE_RX_PN_IND = 0x11,484HTT_10_4_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x12,485HTT_10_4_T2H_MSG_TYPE_TEST = 0x13,486HTT_10_4_T2H_MSG_TYPE_EN_STATS = 0x14,487HTT_10_4_T2H_MSG_TYPE_AGGR_CONF = 0x15,488HTT_10_4_T2H_MSG_TYPE_TX_FETCH_IND = 0x16,489HTT_10_4_T2H_MSG_TYPE_TX_FETCH_CONFIRM = 0x17,490HTT_10_4_T2H_MSG_TYPE_STATS_NOUPLOAD = 0x18,491/* 0x19 to 0x2f are reserved */492HTT_10_4_T2H_MSG_TYPE_TX_MODE_SWITCH_IND = 0x30,493HTT_10_4_T2H_MSG_TYPE_PEER_STATS = 0x31,494/* keep this last */495HTT_10_4_T2H_NUM_MSGS496};497498enum htt_t2h_msg_type {499HTT_T2H_MSG_TYPE_VERSION_CONF,500HTT_T2H_MSG_TYPE_RX_IND,501HTT_T2H_MSG_TYPE_RX_FLUSH,502HTT_T2H_MSG_TYPE_PEER_MAP,503HTT_T2H_MSG_TYPE_PEER_UNMAP,504HTT_T2H_MSG_TYPE_RX_ADDBA,505HTT_T2H_MSG_TYPE_RX_DELBA,506HTT_T2H_MSG_TYPE_TX_COMPL_IND,507HTT_T2H_MSG_TYPE_PKTLOG,508HTT_T2H_MSG_TYPE_STATS_CONF,509HTT_T2H_MSG_TYPE_RX_FRAG_IND,510HTT_T2H_MSG_TYPE_SEC_IND,511HTT_T2H_MSG_TYPE_RC_UPDATE_IND,512HTT_T2H_MSG_TYPE_TX_INSPECT_IND,513HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION,514HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND,515HTT_T2H_MSG_TYPE_RX_PN_IND,516HTT_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND,517HTT_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND,518HTT_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE,519HTT_T2H_MSG_TYPE_CHAN_CHANGE,520HTT_T2H_MSG_TYPE_RX_OFLD_PKT_ERR,521HTT_T2H_MSG_TYPE_AGGR_CONF,522HTT_T2H_MSG_TYPE_STATS_NOUPLOAD,523HTT_T2H_MSG_TYPE_TEST,524HTT_T2H_MSG_TYPE_EN_STATS,525HTT_T2H_MSG_TYPE_TX_FETCH_IND,526HTT_T2H_MSG_TYPE_TX_FETCH_CONFIRM,527HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,528HTT_T2H_MSG_TYPE_PEER_STATS,529/* keep this last */530HTT_T2H_NUM_MSGS531};532533/*534* htt_resp_hdr - header for target-to-host messages535*536* msg_type: see htt_t2h_msg_type537*/538struct htt_resp_hdr {539u8 msg_type;540} __packed;541542#define HTT_RESP_HDR_MSG_TYPE_OFFSET 0543#define HTT_RESP_HDR_MSG_TYPE_MASK 0xff544#define HTT_RESP_HDR_MSG_TYPE_LSB 0545546/* htt_ver_resp - response sent for htt_ver_req */547struct htt_ver_resp {548u8 minor;549u8 major;550u8 rsvd0;551} __packed;552553#define HTT_MGMT_TX_CMPL_FLAG_ACK_RSSI BIT(0)554555#define HTT_MGMT_TX_CMPL_INFO_ACK_RSSI_MASK GENMASK(7, 0)556557struct htt_mgmt_tx_completion {558u8 rsvd0;559u8 rsvd1;560u8 flags;561__le32 desc_id;562__le32 status;563__le32 ppdu_id;564__le32 info;565} __packed;566567#define HTT_RX_INDICATION_INFO0_EXT_TID_MASK (0x1F)568#define HTT_RX_INDICATION_INFO0_EXT_TID_LSB (0)569#define HTT_RX_INDICATION_INFO0_FLUSH_VALID (1 << 5)570#define HTT_RX_INDICATION_INFO0_RELEASE_VALID (1 << 6)571#define HTT_RX_INDICATION_INFO0_PPDU_DURATION BIT(7)572573#define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_MASK 0x0000003F574#define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_LSB 0575#define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_MASK 0x00000FC0576#define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_LSB 6577#define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_MASK 0x0003F000578#define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_LSB 12579#define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_MASK 0x00FC0000580#define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_LSB 18581#define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_MASK 0xFF000000582#define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_LSB 24583584#define HTT_TX_CMPL_FLAG_DATA_RSSI BIT(0)585#define HTT_TX_CMPL_FLAG_PPID_PRESENT BIT(1)586#define HTT_TX_CMPL_FLAG_PA_PRESENT BIT(2)587#define HTT_TX_CMPL_FLAG_PPDU_DURATION_PRESENT BIT(3)588589#define HTT_TX_DATA_RSSI_ENABLE_WCN3990 BIT(3)590#define HTT_TX_DATA_APPEND_RETRIES BIT(0)591#define HTT_TX_DATA_APPEND_TIMESTAMP BIT(1)592593struct htt_rx_indication_hdr {594u8 info0; /* %HTT_RX_INDICATION_INFO0_ */595__le16 peer_id;596__le32 info1; /* %HTT_RX_INDICATION_INFO1_ */597} __packed;598599#define HTT_RX_INDICATION_INFO0_PHY_ERR_VALID (1 << 0)600#define HTT_RX_INDICATION_INFO0_LEGACY_RATE_MASK (0x1E)601#define HTT_RX_INDICATION_INFO0_LEGACY_RATE_LSB (1)602#define HTT_RX_INDICATION_INFO0_LEGACY_RATE_CCK (1 << 5)603#define HTT_RX_INDICATION_INFO0_END_VALID (1 << 6)604#define HTT_RX_INDICATION_INFO0_START_VALID (1 << 7)605606#define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_MASK 0x00FFFFFF607#define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_LSB 0608#define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_MASK 0xFF000000609#define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_LSB 24610611#define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_MASK 0x00FFFFFF612#define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_LSB 0613#define HTT_RX_INDICATION_INFO2_SERVICE_MASK 0xFF000000614#define HTT_RX_INDICATION_INFO2_SERVICE_LSB 24615616enum htt_rx_legacy_rate {617HTT_RX_OFDM_48 = 0,618HTT_RX_OFDM_24 = 1,619HTT_RX_OFDM_12,620HTT_RX_OFDM_6,621HTT_RX_OFDM_54,622HTT_RX_OFDM_36,623HTT_RX_OFDM_18,624HTT_RX_OFDM_9,625626/* long preamble */627HTT_RX_CCK_11_LP = 0,628HTT_RX_CCK_5_5_LP = 1,629HTT_RX_CCK_2_LP,630HTT_RX_CCK_1_LP,631/* short preamble */632HTT_RX_CCK_11_SP,633HTT_RX_CCK_5_5_SP,634HTT_RX_CCK_2_SP635};636637enum htt_rx_legacy_rate_type {638HTT_RX_LEGACY_RATE_OFDM = 0,639HTT_RX_LEGACY_RATE_CCK640};641642enum htt_rx_preamble_type {643HTT_RX_LEGACY = 0x4,644HTT_RX_HT = 0x8,645HTT_RX_HT_WITH_TXBF = 0x9,646HTT_RX_VHT = 0xC,647HTT_RX_VHT_WITH_TXBF = 0xD,648};649650/*651* Fields: phy_err_valid, phy_err_code, tsf,652* usec_timestamp, sub_usec_timestamp653* ..are valid only if end_valid == 1.654*655* Fields: rssi_chains, legacy_rate_type,656* legacy_rate_cck, preamble_type, service,657* vht_sig_*658* ..are valid only if start_valid == 1;659*/660struct htt_rx_indication_ppdu {661u8 combined_rssi;662u8 sub_usec_timestamp;663u8 phy_err_code;664u8 info0; /* HTT_RX_INDICATION_INFO0_ */665struct {666u8 pri20_db;667u8 ext20_db;668u8 ext40_db;669u8 ext80_db;670} __packed rssi_chains[4];671__le32 tsf;672__le32 usec_timestamp;673__le32 info1; /* HTT_RX_INDICATION_INFO1_ */674__le32 info2; /* HTT_RX_INDICATION_INFO2_ */675} __packed;676677enum htt_rx_mpdu_status {678HTT_RX_IND_MPDU_STATUS_UNKNOWN = 0x0,679HTT_RX_IND_MPDU_STATUS_OK,680HTT_RX_IND_MPDU_STATUS_ERR_FCS,681HTT_RX_IND_MPDU_STATUS_ERR_DUP,682HTT_RX_IND_MPDU_STATUS_ERR_REPLAY,683HTT_RX_IND_MPDU_STATUS_ERR_INV_PEER,684/* only accept EAPOL frames */685HTT_RX_IND_MPDU_STATUS_UNAUTH_PEER,686HTT_RX_IND_MPDU_STATUS_OUT_OF_SYNC,687/* Non-data in promiscuous mode */688HTT_RX_IND_MPDU_STATUS_MGMT_CTRL,689HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR,690HTT_RX_IND_MPDU_STATUS_DECRYPT_ERR,691HTT_RX_IND_MPDU_STATUS_MPDU_LENGTH_ERR,692HTT_RX_IND_MPDU_STATUS_ENCRYPT_REQUIRED_ERR,693HTT_RX_IND_MPDU_STATUS_PRIVACY_ERR,694695/*696* MISC: discard for unspecified reasons.697* Leave this enum value last.698*/699HTT_RX_IND_MPDU_STATUS_ERR_MISC = 0xFF700};701702struct htt_rx_indication_mpdu_range {703u8 mpdu_count;704u8 mpdu_range_status; /* %htt_rx_mpdu_status */705u8 pad0;706u8 pad1;707} __packed;708709struct htt_rx_indication_prefix {710__le16 fw_rx_desc_bytes;711u8 pad0;712u8 pad1;713} __packed;714715struct htt_rx_indication {716struct htt_rx_indication_hdr hdr;717struct htt_rx_indication_ppdu ppdu;718struct htt_rx_indication_prefix prefix;719720/*721* the following fields are both dynamically sized, so722* take care addressing them723*/724725/* the size of this is %fw_rx_desc_bytes */726struct fw_rx_desc_base fw_desc;727728/*729* %mpdu_ranges starts after &%prefix + roundup(%fw_rx_desc_bytes, 4)730* and has %num_mpdu_ranges elements.731*/732struct htt_rx_indication_mpdu_range mpdu_ranges[];733} __packed;734735/* High latency version of the RX indication */736struct htt_rx_indication_hl {737struct htt_rx_indication_hdr hdr;738struct htt_rx_indication_ppdu ppdu;739struct htt_rx_indication_prefix prefix;740struct fw_rx_desc_hl fw_desc;741struct htt_rx_indication_mpdu_range mpdu_ranges[];742} __packed;743744struct htt_hl_rx_desc {745__le32 info;746__le32 pn_31_0;747union {748struct {749__le16 pn_47_32;750__le16 pn_63_48;751} pn16;752__le32 pn_63_32;753} u0;754__le32 pn_95_64;755__le32 pn_127_96;756} __packed;757758static inline struct htt_rx_indication_mpdu_range *759htt_rx_ind_get_mpdu_ranges(struct htt_rx_indication *rx_ind)760{761#if defined(__linux__)762void *ptr = rx_ind;763#elif defined(__FreeBSD__)764u8 *ptr = (void *)rx_ind;765#endif766767ptr += sizeof(rx_ind->hdr)768+ sizeof(rx_ind->ppdu)769+ sizeof(rx_ind->prefix)770+ roundup(__le16_to_cpu(rx_ind->prefix.fw_rx_desc_bytes), 4);771#if defined(__linux__)772return ptr;773#elif defined(__FreeBSD__)774return ((void *)ptr);775#endif776}777778static inline struct htt_rx_indication_mpdu_range *779htt_rx_ind_get_mpdu_ranges_hl(struct htt_rx_indication_hl *rx_ind)780{781#if defined(__linux__)782void *ptr = rx_ind;783#elif defined(__FreeBSD__)784u8 *ptr = (void *)rx_ind;785#endif786787ptr += sizeof(rx_ind->hdr)788+ sizeof(rx_ind->ppdu)789+ sizeof(rx_ind->prefix)790+ sizeof(rx_ind->fw_desc);791#if defined(__linux__)792return ptr;793#elif defined(__FreeBSD__)794return ((void *)ptr);795#endif796}797798enum htt_rx_flush_mpdu_status {799HTT_RX_FLUSH_MPDU_DISCARD = 0,800HTT_RX_FLUSH_MPDU_REORDER = 1,801};802803/*804* htt_rx_flush - discard or reorder given range of mpdus805*806* Note: host must check if all sequence numbers between807* [seq_num_start, seq_num_end-1] are valid.808*/809struct htt_rx_flush {810__le16 peer_id;811u8 tid;812u8 rsvd0;813u8 mpdu_status; /* %htt_rx_flush_mpdu_status */814u8 seq_num_start; /* it is 6 LSBs of 802.11 seq no */815u8 seq_num_end; /* it is 6 LSBs of 802.11 seq no */816};817818struct htt_rx_peer_map {819u8 vdev_id;820__le16 peer_id;821u8 addr[6];822u8 rsvd0;823u8 rsvd1;824} __packed;825826struct htt_rx_peer_unmap {827u8 rsvd0;828__le16 peer_id;829} __packed;830831enum htt_txrx_sec_cast_type {832HTT_TXRX_SEC_MCAST = 0,833HTT_TXRX_SEC_UCAST834};835836enum htt_rx_pn_check_type {837HTT_RX_NON_PN_CHECK = 0,838HTT_RX_PN_CHECK839};840841enum htt_rx_tkip_demic_type {842HTT_RX_NON_TKIP_MIC = 0,843HTT_RX_TKIP_MIC844};845846enum htt_security_types {847HTT_SECURITY_NONE,848HTT_SECURITY_WEP128,849HTT_SECURITY_WEP104,850HTT_SECURITY_WEP40,851HTT_SECURITY_TKIP,852HTT_SECURITY_TKIP_NOMIC,853HTT_SECURITY_AES_CCMP,854HTT_SECURITY_WAPI,855856HTT_NUM_SECURITY_TYPES /* keep this last! */857};858859#define ATH10K_HTT_TXRX_PEER_SECURITY_MAX 2860#define ATH10K_TXRX_NUM_EXT_TIDS 19861#define ATH10K_TXRX_NON_QOS_TID 16862863enum htt_security_flags {864#define HTT_SECURITY_TYPE_MASK 0x7F865#define HTT_SECURITY_TYPE_LSB 0866HTT_SECURITY_IS_UNICAST = 1 << 7867};868869struct htt_security_indication {870union {871/* dont use bitfields; undefined behaviour */872u8 flags; /* %htt_security_flags */873struct {874u8 security_type:7, /* %htt_security_types */875is_unicast:1;876} __packed;877} __packed;878__le16 peer_id;879u8 michael_key[8];880u8 wapi_rsc[16];881} __packed;882883#define HTT_RX_BA_INFO0_TID_MASK 0x000F884#define HTT_RX_BA_INFO0_TID_LSB 0885#define HTT_RX_BA_INFO0_PEER_ID_MASK 0xFFF0886#define HTT_RX_BA_INFO0_PEER_ID_LSB 4887888struct htt_rx_addba {889u8 window_size;890__le16 info0; /* %HTT_RX_BA_INFO0_ */891} __packed;892893struct htt_rx_delba {894u8 rsvd0;895__le16 info0; /* %HTT_RX_BA_INFO0_ */896} __packed;897898enum htt_data_tx_status {899HTT_DATA_TX_STATUS_OK = 0,900HTT_DATA_TX_STATUS_DISCARD = 1,901HTT_DATA_TX_STATUS_NO_ACK = 2,902HTT_DATA_TX_STATUS_POSTPONE = 3 /* HL only */903};904905enum htt_data_tx_flags {906#define HTT_DATA_TX_STATUS_MASK 0x07907#define HTT_DATA_TX_STATUS_LSB 0908#define HTT_DATA_TX_TID_MASK 0x78909#define HTT_DATA_TX_TID_LSB 3910HTT_DATA_TX_TID_INVALID = 1 << 7911};912913#define HTT_TX_COMPL_INV_MSDU_ID 0xFFFF914915struct htt_append_retries {916__le16 msdu_id;917u8 tx_retries;918u8 flag;919} __packed;920921struct htt_data_tx_completion_ext {922struct htt_append_retries a_retries;923__le32 t_stamp;924__le16 msdus_rssi[];925} __packed;926927/*928* @brief target -> host TX completion indication message definition929*930* @details931* The following diagram shows the format of the TX completion indication sent932* from the target to the host933*934* |31 28|27|26|25|24|23 16| 15 |14 11|10 8|7 0|935* |-------------------------------------------------------------|936* header: |rsvd |A2|TP|A1|A0| num | t_i| tid |status| msg_type |937* |-------------------------------------------------------------|938* payload: | MSDU1 ID | MSDU0 ID |939* |-------------------------------------------------------------|940* : MSDU3 ID : MSDU2 ID :941* |-------------------------------------------------------------|942* | struct htt_tx_compl_ind_append_retries |943* |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|944* | struct htt_tx_compl_ind_append_tx_tstamp |945* |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|946* | MSDU1 ACK RSSI | MSDU0 ACK RSSI |947* |-------------------------------------------------------------|948* : MSDU3 ACK RSSI : MSDU2 ACK RSSI :949* |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|950* -msg_type951* Bits 7:0952* Purpose: identifies this as HTT TX completion indication953* -status954* Bits 10:8955* Purpose: the TX completion status of payload fragmentations descriptors956* Value: could be HTT_TX_COMPL_IND_STAT_OK or HTT_TX_COMPL_IND_STAT_DISCARD957* -tid958* Bits 14:11959* Purpose: the tid associated with those fragmentation descriptors. It is960* valid or not, depending on the tid_invalid bit.961* Value: 0 to 15962* -tid_invalid963* Bits 15:15964* Purpose: this bit indicates whether the tid field is valid or not965* Value: 0 indicates valid, 1 indicates invalid966* -num967* Bits 23:16968* Purpose: the number of payload in this indication969* Value: 1 to 255970* -A0 = append971* Bits 24:24972* Purpose: append the struct htt_tx_compl_ind_append_retries which contains973* the number of tx retries for one MSDU at the end of this message974* Value: 0 indicates no appending, 1 indicates appending975* -A1 = append1976* Bits 25:25977* Purpose: Append the struct htt_tx_compl_ind_append_tx_tstamp which978* contains the timestamp info for each TX msdu id in payload.979* Value: 0 indicates no appending, 1 indicates appending980* -TP = MSDU tx power presence981* Bits 26:26982* Purpose: Indicate whether the TX_COMPL_IND includes a tx power report983* for each MSDU referenced by the TX_COMPL_IND message.984* The order of the per-MSDU tx power reports matches the order985* of the MSDU IDs.986* Value: 0 indicates not appending, 1 indicates appending987* -A2 = append2988* Bits 27:27989* Purpose: Indicate whether data ACK RSSI is appended for each MSDU in990* TX_COMP_IND message. The order of the per-MSDU ACK RSSI report991* matches the order of the MSDU IDs.992* The ACK RSSI values are valid when status is COMPLETE_OK (and993* this append2 bit is set).994* Value: 0 indicates not appending, 1 indicates appending995*/996997struct htt_data_tx_completion {998union {999u8 flags;1000struct {1001u8 status:3,1002tid:4,1003tid_invalid:1;1004} __packed;1005} __packed;1006u8 num_msdus;1007u8 flags2; /* HTT_TX_CMPL_FLAG_DATA_RSSI */1008__le16 msdus[]; /* variable length based on %num_msdus */1009} __packed;10101011#define HTT_TX_PPDU_DUR_INFO0_PEER_ID_MASK GENMASK(15, 0)1012#define HTT_TX_PPDU_DUR_INFO0_TID_MASK GENMASK(20, 16)10131014struct htt_data_tx_ppdu_dur {1015__le32 info0; /* HTT_TX_PPDU_DUR_INFO0_ */1016__le32 tx_duration; /* in usecs */1017} __packed;10181019#define HTT_TX_COMPL_PPDU_DUR_INFO0_NUM_ENTRIES_MASK GENMASK(7, 0)10201021struct htt_data_tx_compl_ppdu_dur {1022__le32 info0; /* HTT_TX_COMPL_PPDU_DUR_INFO0_ */1023struct htt_data_tx_ppdu_dur ppdu_dur[];1024} __packed;10251026struct htt_tx_compl_ind_base {1027u32 hdr;1028u16 payload[1/*or more*/];1029} __packed;10301031struct htt_rc_tx_done_params {1032u32 rate_code;1033u32 rate_code_flags;1034u32 flags;1035u32 num_enqued; /* 1 for non-AMPDU */1036u32 num_retries;1037u32 num_failed; /* for AMPDU */1038u32 ack_rssi;1039u32 time_stamp;1040u32 is_probe;1041};10421043struct htt_rc_update {1044u8 vdev_id;1045__le16 peer_id;1046u8 addr[6];1047u8 num_elems;1048u8 rsvd0;1049struct htt_rc_tx_done_params params[]; /* variable length %num_elems */1050} __packed;10511052/* see htt_rx_indication for similar fields and descriptions */1053struct htt_rx_fragment_indication {1054union {1055u8 info0; /* %HTT_RX_FRAG_IND_INFO0_ */1056struct {1057u8 ext_tid:5,1058flush_valid:1;1059} __packed;1060} __packed;1061__le16 peer_id;1062__le32 info1; /* %HTT_RX_FRAG_IND_INFO1_ */1063__le16 fw_rx_desc_bytes;1064__le16 rsvd0;10651066u8 fw_msdu_rx_desc[];1067} __packed;10681069#define ATH10K_IEEE80211_EXTIV BIT(5)1070#define ATH10K_IEEE80211_TKIP_MICLEN 8 /* trailing MIC */10711072#define HTT_RX_FRAG_IND_INFO0_HEADER_LEN 1610731074#define HTT_RX_FRAG_IND_INFO0_EXT_TID_MASK 0x1F1075#define HTT_RX_FRAG_IND_INFO0_EXT_TID_LSB 01076#define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_MASK 0x201077#define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_LSB 510781079#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_MASK 0x0000003F1080#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_LSB 01081#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_MASK 0x00000FC01082#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_LSB 610831084struct htt_rx_pn_ind {1085__le16 peer_id;1086u8 tid;1087u8 seqno_start;1088u8 seqno_end;1089u8 pn_ie_count;1090u8 reserved;1091u8 pn_ies[];1092} __packed;10931094struct htt_rx_offload_msdu {1095__le16 msdu_len;1096__le16 peer_id;1097u8 vdev_id;1098u8 tid;1099u8 fw_desc;1100u8 payload[];1101} __packed;11021103struct htt_rx_offload_ind {1104u8 reserved;1105__le16 msdu_count;1106} __packed;11071108struct htt_rx_in_ord_msdu_desc {1109__le32 msdu_paddr;1110__le16 msdu_len;1111u8 fw_desc;1112u8 reserved;1113} __packed;11141115struct htt_rx_in_ord_msdu_desc_ext {1116__le64 msdu_paddr;1117__le16 msdu_len;1118u8 fw_desc;1119u8 reserved;1120} __packed;11211122struct htt_rx_in_ord_ind {1123u8 info;1124__le16 peer_id;1125u8 vdev_id;1126u8 reserved;1127__le16 msdu_count;1128union {1129DECLARE_FLEX_ARRAY(struct htt_rx_in_ord_msdu_desc,1130msdu_descs32);1131DECLARE_FLEX_ARRAY(struct htt_rx_in_ord_msdu_desc_ext,1132msdu_descs64);1133} __packed;1134} __packed;11351136#define HTT_RX_IN_ORD_IND_INFO_TID_MASK 0x0000001f1137#define HTT_RX_IN_ORD_IND_INFO_TID_LSB 01138#define HTT_RX_IN_ORD_IND_INFO_OFFLOAD_MASK 0x000000201139#define HTT_RX_IN_ORD_IND_INFO_OFFLOAD_LSB 51140#define HTT_RX_IN_ORD_IND_INFO_FRAG_MASK 0x000000401141#define HTT_RX_IN_ORD_IND_INFO_FRAG_LSB 611421143/*1144* target -> host test message definition1145*1146* The following field definitions describe the format of the test1147* message sent from the target to the host.1148* The message consists of a 4-octet header, followed by a variable1149* number of 32-bit integer values, followed by a variable number1150* of 8-bit character values.1151*1152* |31 16|15 8|7 0|1153* |-----------------------------------------------------------|1154* | num chars | num ints | msg type |1155* |-----------------------------------------------------------|1156* | int 0 |1157* |-----------------------------------------------------------|1158* | int 1 |1159* |-----------------------------------------------------------|1160* | ... |1161* |-----------------------------------------------------------|1162* | char 3 | char 2 | char 1 | char 0 |1163* |-----------------------------------------------------------|1164* | | | ... | char 4 |1165* |-----------------------------------------------------------|1166* - MSG_TYPE1167* Bits 7:01168* Purpose: identifies this as a test message1169* Value: HTT_MSG_TYPE_TEST1170* - NUM_INTS1171* Bits 15:81172* Purpose: indicate how many 32-bit integers follow the message header1173* - NUM_CHARS1174* Bits 31:161175* Purpose: indicate how many 8-bit characters follow the series of integers1176*/1177struct htt_rx_test {1178u8 num_ints;1179__le16 num_chars;11801181/* payload consists of 2 lists:1182* a) num_ints * sizeof(__le32)1183* b) num_chars * sizeof(u8) aligned to 4bytes1184*/1185u8 payload[];1186} __packed;11871188static inline __le32 *htt_rx_test_get_ints(struct htt_rx_test *rx_test)1189{1190return (__le32 *)rx_test->payload;1191}11921193static inline u8 *htt_rx_test_get_chars(struct htt_rx_test *rx_test)1194{1195return rx_test->payload + (rx_test->num_ints * sizeof(__le32));1196}11971198/*1199* target -> host packet log message1200*1201* The following field definitions describe the format of the packet log1202* message sent from the target to the host.1203* The message consists of a 4-octet header,followed by a variable number1204* of 32-bit character values.1205*1206* |31 24|23 16|15 8|7 0|1207* |-----------------------------------------------------------|1208* | | | | msg type |1209* |-----------------------------------------------------------|1210* | payload |1211* |-----------------------------------------------------------|1212* - MSG_TYPE1213* Bits 7:01214* Purpose: identifies this as a test message1215* Value: HTT_MSG_TYPE_PACKETLOG1216*/1217struct htt_pktlog_msg {1218u8 pad[3];1219u8 payload[];1220} __packed;12211222struct htt_dbg_stats_rx_reorder_stats {1223/* Non QoS MPDUs received */1224__le32 deliver_non_qos;12251226/* MPDUs received in-order */1227__le32 deliver_in_order;12281229/* Flush due to reorder timer expired */1230__le32 deliver_flush_timeout;12311232/* Flush due to move out of window */1233__le32 deliver_flush_oow;12341235/* Flush due to DELBA */1236__le32 deliver_flush_delba;12371238/* MPDUs dropped due to FCS error */1239__le32 fcs_error;12401241/* MPDUs dropped due to monitor mode non-data packet */1242__le32 mgmt_ctrl;12431244/* MPDUs dropped due to invalid peer */1245__le32 invalid_peer;12461247/* MPDUs dropped due to duplication (non aggregation) */1248__le32 dup_non_aggr;12491250/* MPDUs dropped due to processed before */1251__le32 dup_past;12521253/* MPDUs dropped due to duplicate in reorder queue */1254__le32 dup_in_reorder;12551256/* Reorder timeout happened */1257__le32 reorder_timeout;12581259/* invalid bar ssn */1260__le32 invalid_bar_ssn;12611262/* reorder reset due to bar ssn */1263__le32 ssn_reset;1264};12651266struct htt_dbg_stats_wal_tx_stats {1267/* Num HTT cookies queued to dispatch list */1268__le32 comp_queued;12691270/* Num HTT cookies dispatched */1271__le32 comp_delivered;12721273/* Num MSDU queued to WAL */1274__le32 msdu_enqued;12751276/* Num MPDU queue to WAL */1277__le32 mpdu_enqued;12781279/* Num MSDUs dropped by WMM limit */1280__le32 wmm_drop;12811282/* Num Local frames queued */1283__le32 local_enqued;12841285/* Num Local frames done */1286__le32 local_freed;12871288/* Num queued to HW */1289__le32 hw_queued;12901291/* Num PPDU reaped from HW */1292__le32 hw_reaped;12931294/* Num underruns */1295__le32 underrun;12961297/* Num PPDUs cleaned up in TX abort */1298__le32 tx_abort;12991300/* Num MPDUs requeued by SW */1301__le32 mpdus_requeued;13021303/* excessive retries */1304__le32 tx_ko;13051306/* data hw rate code */1307__le32 data_rc;13081309/* Scheduler self triggers */1310__le32 self_triggers;13111312/* frames dropped due to excessive sw retries */1313__le32 sw_retry_failure;13141315/* illegal rate phy errors */1316__le32 illgl_rate_phy_err;13171318/* wal pdev continuous xretry */1319__le32 pdev_cont_xretry;13201321/* wal pdev continuous xretry */1322__le32 pdev_tx_timeout;13231324/* wal pdev resets */1325__le32 pdev_resets;13261327__le32 phy_underrun;13281329/* MPDU is more than txop limit */1330__le32 txop_ovf;1331} __packed;13321333struct htt_dbg_stats_wal_rx_stats {1334/* Cnts any change in ring routing mid-ppdu */1335__le32 mid_ppdu_route_change;13361337/* Total number of statuses processed */1338__le32 status_rcvd;13391340/* Extra frags on rings 0-3 */1341__le32 r0_frags;1342__le32 r1_frags;1343__le32 r2_frags;1344__le32 r3_frags;13451346/* MSDUs / MPDUs delivered to HTT */1347__le32 htt_msdus;1348__le32 htt_mpdus;13491350/* MSDUs / MPDUs delivered to local stack */1351__le32 loc_msdus;1352__le32 loc_mpdus;13531354/* AMSDUs that have more MSDUs than the status ring size */1355__le32 oversize_amsdu;13561357/* Number of PHY errors */1358__le32 phy_errs;13591360/* Number of PHY errors drops */1361__le32 phy_err_drop;13621363/* Number of mpdu errors - FCS, MIC, ENC etc. */1364__le32 mpdu_errs;1365} __packed;13661367struct htt_dbg_stats_wal_peer_stats {1368__le32 dummy; /* REMOVE THIS ONCE REAL PEER STAT COUNTERS ARE ADDED */1369} __packed;13701371struct htt_dbg_stats_wal_pdev_txrx {1372struct htt_dbg_stats_wal_tx_stats tx_stats;1373struct htt_dbg_stats_wal_rx_stats rx_stats;1374struct htt_dbg_stats_wal_peer_stats peer_stats;1375} __packed;13761377struct htt_dbg_stats_rx_rate_info {1378__le32 mcs[10];1379__le32 sgi[10];1380__le32 nss[4];1381__le32 stbc[10];1382__le32 bw[3];1383__le32 pream[6];1384__le32 ldpc;1385__le32 txbf;1386};13871388/*1389* htt_dbg_stats_status -1390* present - The requested stats have been delivered in full.1391* This indicates that either the stats information was contained1392* in its entirety within this message, or else this message1393* completes the delivery of the requested stats info that was1394* partially delivered through earlier STATS_CONF messages.1395* partial - The requested stats have been delivered in part.1396* One or more subsequent STATS_CONF messages with the same1397* cookie value will be sent to deliver the remainder of the1398* information.1399* error - The requested stats could not be delivered, for example due1400* to a shortage of memory to construct a message holding the1401* requested stats.1402* invalid - The requested stat type is either not recognized, or the1403* target is configured to not gather the stats type in question.1404* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -1405* series_done - This special value indicates that no further stats info1406* elements are present within a series of stats info elems1407* (within a stats upload confirmation message).1408*/1409enum htt_dbg_stats_status {1410HTT_DBG_STATS_STATUS_PRESENT = 0,1411HTT_DBG_STATS_STATUS_PARTIAL = 1,1412HTT_DBG_STATS_STATUS_ERROR = 2,1413HTT_DBG_STATS_STATUS_INVALID = 3,1414HTT_DBG_STATS_STATUS_SERIES_DONE = 71415};14161417/*1418* host -> target FRAG DESCRIPTOR/MSDU_EXT DESC bank1419*1420* The following field definitions describe the format of the HTT host1421* to target frag_desc/msdu_ext bank configuration message.1422* The message contains the based address and the min and max id of the1423* MSDU_EXT/FRAG_DESC that will be used by the HTT to map MSDU DESC and1424* MSDU_EXT/FRAG_DESC.1425* HTT will use id in HTT descriptor instead sending the frag_desc_ptr.1426* For QCA988X HW the firmware will use fragment_desc_ptr but in WIFI2.01427* the hardware does the mapping/translation.1428*1429* Total banks that can be configured is configured to 16.1430*1431* This should be called before any TX has be initiated by the HTT1432*1433* |31 16|15 8|7 5|4 0|1434* |------------------------------------------------------------|1435* | DESC_SIZE | NUM_BANKS | RES |SWP|pdev| msg type |1436* |------------------------------------------------------------|1437* | BANK0_BASE_ADDRESS |1438* |------------------------------------------------------------|1439* | ... |1440* |------------------------------------------------------------|1441* | BANK15_BASE_ADDRESS |1442* |------------------------------------------------------------|1443* | BANK0_MAX_ID | BANK0_MIN_ID |1444* |------------------------------------------------------------|1445* | ... |1446* |------------------------------------------------------------|1447* | BANK15_MAX_ID | BANK15_MIN_ID |1448* |------------------------------------------------------------|1449* Header fields:1450* - MSG_TYPE1451* Bits 7:01452* Value: 0x61453* - BANKx_BASE_ADDRESS1454* Bits 31:01455* Purpose: Provide a mechanism to specify the base address of the MSDU_EXT1456* bank physical/bus address.1457* - BANKx_MIN_ID1458* Bits 15:01459* Purpose: Provide a mechanism to specify the min index that needs to1460* mapped.1461* - BANKx_MAX_ID1462* Bits 31:161463* Purpose: Provide a mechanism to specify the max index that needs to1464*1465*/1466struct htt_frag_desc_bank_id {1467__le16 bank_min_id;1468__le16 bank_max_id;1469} __packed;14701471/* real is 16 but it wouldn't fit in the max htt message size1472* so we use a conservatively safe value for now1473*/1474#define HTT_FRAG_DESC_BANK_MAX 414751476#define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_MASK 0x031477#define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_LSB 01478#define HTT_FRAG_DESC_BANK_CFG_INFO_SWAP BIT(2)1479#define HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_VALID BIT(3)1480#define HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_DEPTH_TYPE_MASK BIT(4)1481#define HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_DEPTH_TYPE_LSB 414821483enum htt_q_depth_type {1484HTT_Q_DEPTH_TYPE_BYTES = 0,1485HTT_Q_DEPTH_TYPE_MSDUS = 1,1486};14871488#define HTT_TX_Q_STATE_NUM_PEERS (TARGET_10_4_NUM_QCACHE_PEERS_MAX + \1489TARGET_10_4_NUM_VDEVS)1490#define HTT_TX_Q_STATE_NUM_TIDS 81491#define HTT_TX_Q_STATE_ENTRY_SIZE 11492#define HTT_TX_Q_STATE_ENTRY_MULTIPLIER 014931494/**1495* struct htt_q_state_conf - part of htt_frag_desc_bank_cfg for host q state config1496*1497* Defines host q state format and behavior. See htt_q_state.1498*1499* @paddr: Queue physical address1500* @num_peers: Number of supported peers1501* @num_tids: Number of supported TIDs1502* @record_size: Defines the size of each host q entry in bytes. In practice1503* however firmware (at least 10.4.3-00191) ignores this host1504* configuration value and uses hardcoded value of 1.1505* @record_multiplier: This is valid only when q depth type is MSDUs. It1506* defines the exponent for the power of 2 multiplication.1507* @pad: struct padding for 32-bit alignment1508*/1509struct htt_q_state_conf {1510__le32 paddr;1511__le16 num_peers;1512__le16 num_tids;1513u8 record_size;1514u8 record_multiplier;1515u8 pad[2];1516} __packed;15171518struct htt_frag_desc_bank_cfg32 {1519u8 info; /* HTT_FRAG_DESC_BANK_CFG_INFO_ */1520u8 num_banks;1521u8 desc_size;1522__le32 bank_base_addrs[HTT_FRAG_DESC_BANK_MAX];1523struct htt_frag_desc_bank_id bank_id[HTT_FRAG_DESC_BANK_MAX];1524struct htt_q_state_conf q_state;1525} __packed;15261527struct htt_frag_desc_bank_cfg64 {1528u8 info; /* HTT_FRAG_DESC_BANK_CFG_INFO_ */1529u8 num_banks;1530u8 desc_size;1531__le64 bank_base_addrs[HTT_FRAG_DESC_BANK_MAX];1532struct htt_frag_desc_bank_id bank_id[HTT_FRAG_DESC_BANK_MAX];1533struct htt_q_state_conf q_state;1534} __packed;15351536#define HTT_TX_Q_STATE_ENTRY_COEFFICIENT 1281537#define HTT_TX_Q_STATE_ENTRY_FACTOR_MASK 0x3f1538#define HTT_TX_Q_STATE_ENTRY_FACTOR_LSB 01539#define HTT_TX_Q_STATE_ENTRY_EXP_MASK 0xc01540#define HTT_TX_Q_STATE_ENTRY_EXP_LSB 615411542/**1543* struct htt_q_state - shared between host and firmware via DMA1544*1545* This structure is used for the host to expose it's software queue state to1546* firmware so that its rate control can schedule fetch requests for optimized1547* performance. This is most notably used for MU-MIMO aggregation when multiple1548* MU clients are connected.1549*1550* @count: Each element defines the host queue depth. When q depth type was1551* configured as HTT_Q_DEPTH_TYPE_BYTES then each entry is defined as:1552* FACTOR * 128 * 8^EXP (see HTT_TX_Q_STATE_ENTRY_FACTOR_MASK and1553* HTT_TX_Q_STATE_ENTRY_EXP_MASK). When q depth type was configured as1554* HTT_Q_DEPTH_TYPE_MSDUS the number of packets is scaled by 2 **1555* record_multiplier (see htt_q_state_conf).1556* @map: Used by firmware to quickly check which host queues are not empty. It1557* is a bitmap simply saying.1558* @seq: Used by firmware to quickly check if the host queues were updated1559* since it last checked.1560*1561* FIXME: Is the q_state map[] size calculation really correct?1562*/1563struct htt_q_state {1564u8 count[HTT_TX_Q_STATE_NUM_TIDS][HTT_TX_Q_STATE_NUM_PEERS];1565u32 map[HTT_TX_Q_STATE_NUM_TIDS][(HTT_TX_Q_STATE_NUM_PEERS + 31) / 32];1566__le32 seq;1567} __packed;15681569#define HTT_TX_FETCH_RECORD_INFO_PEER_ID_MASK 0x0fff1570#define HTT_TX_FETCH_RECORD_INFO_PEER_ID_LSB 01571#define HTT_TX_FETCH_RECORD_INFO_TID_MASK 0xf0001572#define HTT_TX_FETCH_RECORD_INFO_TID_LSB 1215731574struct htt_tx_fetch_record {1575__le16 info; /* HTT_TX_FETCH_IND_RECORD_INFO_ */1576__le16 num_msdus;1577__le32 num_bytes;1578} __packed;15791580struct htt_tx_fetch_ind {1581u8 pad0;1582__le16 fetch_seq_num;1583__le32 token;1584__le16 num_resp_ids;1585__le16 num_records;1586union {1587/* ath10k_htt_get_tx_fetch_ind_resp_ids() */1588DECLARE_FLEX_ARRAY(__le32, resp_ids);1589DECLARE_FLEX_ARRAY(struct htt_tx_fetch_record, records);1590} __packed;1591} __packed;15921593static inline void *1594ath10k_htt_get_tx_fetch_ind_resp_ids(struct htt_tx_fetch_ind *ind)1595{1596return (void *)&ind->records[le16_to_cpu(ind->num_records)];1597}15981599struct htt_tx_fetch_resp {1600u8 pad0;1601__le16 resp_id;1602__le16 fetch_seq_num;1603__le16 num_records;1604__le32 token;1605struct htt_tx_fetch_record records[];1606} __packed;16071608struct htt_tx_fetch_confirm {1609u8 pad0;1610__le16 num_resp_ids;1611__le32 resp_ids[];1612} __packed;16131614enum htt_tx_mode_switch_mode {1615HTT_TX_MODE_SWITCH_PUSH = 0,1616HTT_TX_MODE_SWITCH_PUSH_PULL = 1,1617};16181619#define HTT_TX_MODE_SWITCH_IND_INFO0_ENABLE BIT(0)1620#define HTT_TX_MODE_SWITCH_IND_INFO0_NUM_RECORDS_MASK 0xfffe1621#define HTT_TX_MODE_SWITCH_IND_INFO0_NUM_RECORDS_LSB 116221623#define HTT_TX_MODE_SWITCH_IND_INFO1_MODE_MASK 0x00031624#define HTT_TX_MODE_SWITCH_IND_INFO1_MODE_LSB 01625#define HTT_TX_MODE_SWITCH_IND_INFO1_THRESHOLD_MASK 0xfffc1626#define HTT_TX_MODE_SWITCH_IND_INFO1_THRESHOLD_LSB 216271628#define HTT_TX_MODE_SWITCH_RECORD_INFO0_PEER_ID_MASK 0x0fff1629#define HTT_TX_MODE_SWITCH_RECORD_INFO0_PEER_ID_LSB 01630#define HTT_TX_MODE_SWITCH_RECORD_INFO0_TID_MASK 0xf0001631#define HTT_TX_MODE_SWITCH_RECORD_INFO0_TID_LSB 1216321633struct htt_tx_mode_switch_record {1634__le16 info0; /* HTT_TX_MODE_SWITCH_RECORD_INFO0_ */1635__le16 num_max_msdus;1636} __packed;16371638struct htt_tx_mode_switch_ind {1639u8 pad0;1640__le16 info0; /* HTT_TX_MODE_SWITCH_IND_INFO0_ */1641__le16 info1; /* HTT_TX_MODE_SWITCH_IND_INFO1_ */1642u8 pad1[2];1643struct htt_tx_mode_switch_record records[];1644} __packed;16451646struct htt_channel_change {1647u8 pad[3];1648__le32 freq;1649__le32 center_freq1;1650__le32 center_freq2;1651__le32 phymode;1652} __packed;16531654struct htt_per_peer_tx_stats_ind {1655__le32 succ_bytes;1656__le32 retry_bytes;1657__le32 failed_bytes;1658u8 ratecode;1659u8 flags;1660__le16 peer_id;1661__le16 succ_pkts;1662__le16 retry_pkts;1663__le16 failed_pkts;1664__le16 tx_duration;1665__le32 reserved1;1666__le32 reserved2;1667} __packed;16681669struct htt_peer_tx_stats {1670u8 num_ppdu;1671u8 ppdu_len;1672u8 version;1673u8 payload[];1674} __packed;16751676#define ATH10K_10_2_TX_STATS_OFFSET 1361677#define PEER_STATS_FOR_NO_OF_PPDUS 416781679struct ath10k_10_2_peer_tx_stats {1680u8 ratecode[PEER_STATS_FOR_NO_OF_PPDUS];1681u8 success_pkts[PEER_STATS_FOR_NO_OF_PPDUS];1682__le16 success_bytes[PEER_STATS_FOR_NO_OF_PPDUS];1683u8 retry_pkts[PEER_STATS_FOR_NO_OF_PPDUS];1684__le16 retry_bytes[PEER_STATS_FOR_NO_OF_PPDUS];1685u8 failed_pkts[PEER_STATS_FOR_NO_OF_PPDUS];1686__le16 failed_bytes[PEER_STATS_FOR_NO_OF_PPDUS];1687u8 flags[PEER_STATS_FOR_NO_OF_PPDUS];1688__le32 tx_duration;1689u8 tx_ppdu_cnt;1690u8 peer_id;1691} __packed;16921693union htt_rx_pn_t {1694/* WEP: 24-bit PN */1695u32 pn24;16961697/* TKIP or CCMP: 48-bit PN */1698u64 pn48;16991700/* WAPI: 128-bit PN */1701u64 pn128[2];1702};17031704struct htt_cmd {1705struct htt_cmd_hdr hdr;1706union {1707struct htt_ver_req ver_req;1708struct htt_mgmt_tx_desc mgmt_tx;1709struct htt_data_tx_desc data_tx;1710struct htt_rx_ring_setup_32 rx_setup_32;1711struct htt_rx_ring_setup_64 rx_setup_64;1712struct htt_stats_req stats_req;1713struct htt_oob_sync_req oob_sync_req;1714struct htt_aggr_conf aggr_conf;1715struct htt_aggr_conf_v2 aggr_conf_v2;1716struct htt_frag_desc_bank_cfg32 frag_desc_bank_cfg32;1717struct htt_frag_desc_bank_cfg64 frag_desc_bank_cfg64;1718struct htt_tx_fetch_resp tx_fetch_resp;1719};1720} __packed;17211722struct htt_resp {1723struct htt_resp_hdr hdr;1724union {1725struct htt_ver_resp ver_resp;1726struct htt_mgmt_tx_completion mgmt_tx_completion;1727struct htt_data_tx_completion data_tx_completion;1728struct htt_rx_indication rx_ind;1729struct htt_rx_indication_hl rx_ind_hl;1730struct htt_rx_fragment_indication rx_frag_ind;1731struct htt_rx_peer_map peer_map;1732struct htt_rx_peer_unmap peer_unmap;1733struct htt_rx_flush rx_flush;1734struct htt_rx_addba rx_addba;1735struct htt_rx_delba rx_delba;1736struct htt_security_indication security_indication;1737struct htt_rc_update rc_update;1738struct htt_rx_test rx_test;1739struct htt_pktlog_msg pktlog_msg;1740struct htt_rx_pn_ind rx_pn_ind;1741struct htt_rx_offload_ind rx_offload_ind;1742struct htt_rx_in_ord_ind rx_in_ord_ind;1743struct htt_tx_fetch_ind tx_fetch_ind;1744struct htt_tx_fetch_confirm tx_fetch_confirm;1745struct htt_tx_mode_switch_ind tx_mode_switch_ind;1746struct htt_channel_change chan_change;1747struct htt_peer_tx_stats peer_tx_stats;1748} __packed;1749} __packed;17501751/*** host side structures follow ***/17521753struct htt_tx_done {1754u16 msdu_id;1755u16 status;1756u8 ack_rssi;1757};17581759enum htt_tx_compl_state {1760HTT_TX_COMPL_STATE_NONE,1761HTT_TX_COMPL_STATE_ACK,1762HTT_TX_COMPL_STATE_NOACK,1763HTT_TX_COMPL_STATE_DISCARD,1764};17651766struct htt_peer_map_event {1767u8 vdev_id;1768u16 peer_id;1769u8 addr[ETH_ALEN];1770};17711772struct htt_peer_unmap_event {1773u16 peer_id;1774};17751776struct ath10k_htt_txbuf_32 {1777struct htt_data_tx_desc_frag frags[2];1778struct ath10k_htc_hdr htc_hdr;1779struct htt_cmd_hdr cmd_hdr;1780struct htt_data_tx_desc cmd_tx;1781} __packed __aligned(4);17821783struct ath10k_htt_txbuf_64 {1784struct htt_data_tx_desc_frag frags[2];1785struct ath10k_htc_hdr htc_hdr;1786struct htt_cmd_hdr cmd_hdr;1787struct htt_data_tx_desc_64 cmd_tx;1788} __packed __aligned(4);17891790struct ath10k_htt {1791struct ath10k *ar;1792enum ath10k_htc_ep_id eid;17931794struct sk_buff_head rx_indication_head;17951796u8 target_version_major;1797u8 target_version_minor;1798struct completion target_version_received;1799u8 max_num_amsdu;1800u8 max_num_ampdu;18011802const enum htt_t2h_msg_type *t2h_msg_types;1803u32 t2h_msg_types_max;18041805struct {1806/*1807* Ring of network buffer objects - This ring is1808* used exclusively by the host SW. This ring1809* mirrors the dev_addrs_ring that is shared1810* between the host SW and the MAC HW. The host SW1811* uses this netbufs ring to locate the network1812* buffer objects whose data buffers the HW has1813* filled.1814*/1815struct sk_buff **netbufs_ring;18161817/* This is used only with firmware supporting IN_ORD_IND.1818*1819* With Full Rx Reorder the HTT Rx Ring is more of a temporary1820* buffer ring from which buffer addresses are copied by the1821* firmware to MAC Rx ring. Firmware then delivers IN_ORD_IND1822* pointing to specific (re-ordered) buffers.1823*1824* FIXME: With kernel generic hashing functions there's a lot1825* of hash collisions for sk_buffs.1826*/1827bool in_ord_rx;1828DECLARE_HASHTABLE(skb_table, 4);18291830/*1831* Ring of buffer addresses -1832* This ring holds the "physical" device address of the1833* rx buffers the host SW provides for the MAC HW to1834* fill.1835*/1836union {1837__le64 *paddrs_ring_64;1838__le32 *paddrs_ring_32;1839};18401841/*1842* Base address of ring, as a "physical" device address1843* rather than a CPU address.1844*/1845dma_addr_t base_paddr;18461847/* how many elems in the ring (power of 2) */1848int size;18491850/* size - 1 */1851unsigned int size_mask;18521853/* how many rx buffers to keep in the ring */1854int fill_level;18551856/* how many rx buffers (full+empty) are in the ring */1857int fill_cnt;18581859/*1860* alloc_idx - where HTT SW has deposited empty buffers1861* This is allocated in consistent mem, so that the FW can1862* read this variable, and program the HW's FW_IDX reg with1863* the value of this shadow register.1864*/1865struct {1866__le32 *vaddr;1867dma_addr_t paddr;1868} alloc_idx;18691870/* where HTT SW has processed bufs filled by rx MAC DMA */1871struct {1872unsigned int msdu_payld;1873} sw_rd_idx;18741875/*1876* refill_retry_timer - timer triggered when the ring is1877* not refilled to the level expected1878*/1879struct timer_list refill_retry_timer;18801881/* Protects access to all rx ring buffer state variables */1882spinlock_t lock;1883} rx_ring;18841885unsigned int prefetch_len;18861887/* Protects access to pending_tx, num_pending_tx */1888spinlock_t tx_lock;1889int max_num_pending_tx;1890int num_pending_tx;1891int num_pending_mgmt_tx;1892struct idr pending_tx;1893wait_queue_head_t empty_tx_wq;18941895/* FIFO for storing tx done status {ack, no-ack, discard} and msdu id */1896DECLARE_KFIFO_PTR(txdone_fifo, struct htt_tx_done);18971898/* set if host-fw communication goes haywire1899* used to avoid further failures1900*/1901bool rx_confused;1902atomic_t num_mpdus_ready;19031904/* This is used to group tx/rx completions separately and process them1905* in batches to reduce cache stalls1906*/1907struct sk_buff_head rx_msdus_q;1908struct sk_buff_head rx_in_ord_compl_q;1909struct sk_buff_head tx_fetch_ind_q;19101911/* rx_status template */1912struct ieee80211_rx_status rx_status;19131914struct {1915dma_addr_t paddr;1916union {1917struct htt_msdu_ext_desc *vaddr_desc_32;1918struct htt_msdu_ext_desc_64 *vaddr_desc_64;1919};1920size_t size;1921} frag_desc;19221923struct {1924dma_addr_t paddr;1925union {1926struct ath10k_htt_txbuf_32 *vaddr_txbuff_32;1927struct ath10k_htt_txbuf_64 *vaddr_txbuff_64;1928};1929size_t size;1930} txbuf;19311932struct {1933bool enabled;1934struct htt_q_state *vaddr;1935dma_addr_t paddr;1936u16 num_push_allowed;1937u16 num_peers;1938u16 num_tids;1939enum htt_tx_mode_switch_mode mode;1940enum htt_q_depth_type type;1941} tx_q_state;19421943bool tx_mem_allocated;1944const struct ath10k_htt_tx_ops *tx_ops;1945const struct ath10k_htt_rx_ops *rx_ops;1946bool disable_tx_comp;1947bool bundle_tx;1948struct sk_buff_head tx_req_head;1949struct sk_buff_head tx_complete_head;1950};19511952struct ath10k_htt_tx_ops {1953int (*htt_send_rx_ring_cfg)(struct ath10k_htt *htt);1954int (*htt_send_frag_desc_bank_cfg)(struct ath10k_htt *htt);1955int (*htt_alloc_frag_desc)(struct ath10k_htt *htt);1956void (*htt_free_frag_desc)(struct ath10k_htt *htt);1957int (*htt_tx)(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txmode,1958struct sk_buff *msdu);1959int (*htt_alloc_txbuff)(struct ath10k_htt *htt);1960void (*htt_free_txbuff)(struct ath10k_htt *htt);1961int (*htt_h2t_aggr_cfg_msg)(struct ath10k_htt *htt,1962u8 max_subfrms_ampdu,1963u8 max_subfrms_amsdu);1964void (*htt_flush_tx)(struct ath10k_htt *htt);1965};19661967static inline int ath10k_htt_send_rx_ring_cfg(struct ath10k_htt *htt)1968{1969if (!htt->tx_ops->htt_send_rx_ring_cfg)1970return -EOPNOTSUPP;19711972return htt->tx_ops->htt_send_rx_ring_cfg(htt);1973}19741975static inline int ath10k_htt_send_frag_desc_bank_cfg(struct ath10k_htt *htt)1976{1977if (!htt->tx_ops->htt_send_frag_desc_bank_cfg)1978return -EOPNOTSUPP;19791980return htt->tx_ops->htt_send_frag_desc_bank_cfg(htt);1981}19821983static inline int ath10k_htt_alloc_frag_desc(struct ath10k_htt *htt)1984{1985if (!htt->tx_ops->htt_alloc_frag_desc)1986return -EOPNOTSUPP;19871988return htt->tx_ops->htt_alloc_frag_desc(htt);1989}19901991static inline void ath10k_htt_free_frag_desc(struct ath10k_htt *htt)1992{1993if (htt->tx_ops->htt_free_frag_desc)1994htt->tx_ops->htt_free_frag_desc(htt);1995}19961997static inline int ath10k_htt_tx(struct ath10k_htt *htt,1998enum ath10k_hw_txrx_mode txmode,1999struct sk_buff *msdu)2000{2001return htt->tx_ops->htt_tx(htt, txmode, msdu);2002}20032004static inline void ath10k_htt_flush_tx(struct ath10k_htt *htt)2005{2006if (htt->tx_ops->htt_flush_tx)2007htt->tx_ops->htt_flush_tx(htt);2008}20092010static inline int ath10k_htt_alloc_txbuff(struct ath10k_htt *htt)2011{2012if (!htt->tx_ops->htt_alloc_txbuff)2013return -EOPNOTSUPP;20142015return htt->tx_ops->htt_alloc_txbuff(htt);2016}20172018static inline void ath10k_htt_free_txbuff(struct ath10k_htt *htt)2019{2020if (htt->tx_ops->htt_free_txbuff)2021htt->tx_ops->htt_free_txbuff(htt);2022}20232024static inline int ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt *htt,2025u8 max_subfrms_ampdu,2026u8 max_subfrms_amsdu)20272028{2029if (!htt->tx_ops->htt_h2t_aggr_cfg_msg)2030return -EOPNOTSUPP;20312032return htt->tx_ops->htt_h2t_aggr_cfg_msg(htt,2033max_subfrms_ampdu,2034max_subfrms_amsdu);2035}20362037struct ath10k_htt_rx_ops {2038size_t (*htt_get_rx_ring_size)(struct ath10k_htt *htt);2039void (*htt_config_paddrs_ring)(struct ath10k_htt *htt, void *vaddr);2040void (*htt_set_paddrs_ring)(struct ath10k_htt *htt, dma_addr_t paddr,2041int idx);2042void* (*htt_get_vaddr_ring)(struct ath10k_htt *htt);2043void (*htt_reset_paddrs_ring)(struct ath10k_htt *htt, int idx);2044bool (*htt_rx_proc_rx_frag_ind)(struct ath10k_htt *htt,2045struct htt_rx_fragment_indication *rx,2046struct sk_buff *skb);2047};20482049static inline size_t ath10k_htt_get_rx_ring_size(struct ath10k_htt *htt)2050{2051if (!htt->rx_ops->htt_get_rx_ring_size)2052return 0;20532054return htt->rx_ops->htt_get_rx_ring_size(htt);2055}20562057static inline void ath10k_htt_config_paddrs_ring(struct ath10k_htt *htt,2058void *vaddr)2059{2060if (htt->rx_ops->htt_config_paddrs_ring)2061htt->rx_ops->htt_config_paddrs_ring(htt, vaddr);2062}20632064static inline void ath10k_htt_set_paddrs_ring(struct ath10k_htt *htt,2065dma_addr_t paddr,2066int idx)2067{2068if (htt->rx_ops->htt_set_paddrs_ring)2069htt->rx_ops->htt_set_paddrs_ring(htt, paddr, idx);2070}20712072static inline void *ath10k_htt_get_vaddr_ring(struct ath10k_htt *htt)2073{2074if (!htt->rx_ops->htt_get_vaddr_ring)2075return NULL;20762077return htt->rx_ops->htt_get_vaddr_ring(htt);2078}20792080static inline void ath10k_htt_reset_paddrs_ring(struct ath10k_htt *htt, int idx)2081{2082if (htt->rx_ops->htt_reset_paddrs_ring)2083htt->rx_ops->htt_reset_paddrs_ring(htt, idx);2084}20852086static inline bool ath10k_htt_rx_proc_rx_frag_ind(struct ath10k_htt *htt,2087struct htt_rx_fragment_indication *rx,2088struct sk_buff *skb)2089{2090if (!htt->rx_ops->htt_rx_proc_rx_frag_ind)2091return true;20922093return htt->rx_ops->htt_rx_proc_rx_frag_ind(htt, rx, skb);2094}20952096/* the driver strongly assumes that the rx header status be 64 bytes long,2097* so all possible rx_desc structures must respect this assumption.2098*/2099#define RX_HTT_HDR_STATUS_LEN 6421002101/* The rx descriptor structure layout is programmed via rx ring setup2102* so that FW knows how to transfer the rx descriptor to the host.2103* Unfortunately, though, QCA6174's firmware doesn't currently behave correctly2104* when modifying the structure layout of the rx descriptor beyond what it expects2105* (even if it correctly programmed during the rx ring setup).2106* Therefore we must keep two different memory layouts, abstract the rx descriptor2107* representation and use ath10k_rx_desc_ops2108* for correctly accessing rx descriptor data.2109*/21102111/* base struct used for abstracting the rx descriptor representation */2112struct htt_rx_desc {2113union {2114/* This field is filled on the host using the msdu buffer2115* from htt_rx_indication2116*/2117struct fw_rx_desc_base fw_desc;2118u32 pad;2119} __packed;2120} __packed;21212122/* rx descriptor for wcn3990 and possibly extensible for newer cards2123* Buffers like this are placed on the rx ring.2124*/2125struct htt_rx_desc_v2 {2126struct htt_rx_desc base;2127struct {2128struct rx_attention attention;2129struct rx_frag_info frag_info;2130struct rx_mpdu_start mpdu_start;2131struct rx_msdu_start msdu_start;2132struct rx_msdu_end msdu_end;2133struct rx_mpdu_end mpdu_end;2134struct rx_ppdu_start ppdu_start;2135struct rx_ppdu_end ppdu_end;2136} __packed;2137u8 rx_hdr_status[RX_HTT_HDR_STATUS_LEN];2138u8 msdu_payload[];2139};21402141/* QCA6174, QCA988x, QCA99x0 dedicated rx descriptor to make sure their firmware2142* works correctly. We keep a single rx descriptor for all these three2143* families of cards because from tests it seems to be the most stable solution,2144* e.g. having a rx descriptor only for QCA6174 seldom caused firmware crashes2145* during some tests.2146* Buffers like this are placed on the rx ring.2147*/2148struct htt_rx_desc_v1 {2149struct htt_rx_desc base;2150struct {2151struct rx_attention attention;2152struct rx_frag_info_v1 frag_info;2153struct rx_mpdu_start mpdu_start;2154struct rx_msdu_start_v1 msdu_start;2155struct rx_msdu_end_v1 msdu_end;2156struct rx_mpdu_end mpdu_end;2157struct rx_ppdu_start ppdu_start;2158struct rx_ppdu_end_v1 ppdu_end;2159} __packed;2160u8 rx_hdr_status[RX_HTT_HDR_STATUS_LEN];2161u8 msdu_payload[];2162};21632164/* rx_desc abstraction */2165struct ath10k_htt_rx_desc_ops {2166/* These fields are mandatory, they must be specified in any instance */21672168/* sizeof() of the rx_desc structure used by this hw */2169size_t rx_desc_size;21702171/* offset of msdu_payload inside the rx_desc structure used by this hw */2172size_t rx_desc_msdu_payload_offset;21732174/* These fields are options.2175* When a field is not provided the default implementation gets used2176* (see the ath10k_rx_desc_* operations below for more info about the defaults)2177*/2178bool (*rx_desc_get_msdu_limit_error)(struct htt_rx_desc *rxd);2179int (*rx_desc_get_l3_pad_bytes)(struct htt_rx_desc *rxd);21802181/* Safely cast from a void* buffer containing an rx descriptor2182* to the proper rx_desc structure2183*/2184struct htt_rx_desc *(*rx_desc_from_raw_buffer)(void *buff);21852186void (*rx_desc_get_offsets)(struct htt_rx_ring_rx_desc_offsets *offs);2187struct rx_attention *(*rx_desc_get_attention)(struct htt_rx_desc *rxd);2188struct rx_frag_info_common *(*rx_desc_get_frag_info)(struct htt_rx_desc *rxd);2189struct rx_mpdu_start *(*rx_desc_get_mpdu_start)(struct htt_rx_desc *rxd);2190struct rx_mpdu_end *(*rx_desc_get_mpdu_end)(struct htt_rx_desc *rxd);2191struct rx_msdu_start_common *(*rx_desc_get_msdu_start)(struct htt_rx_desc *rxd);2192struct rx_msdu_end_common *(*rx_desc_get_msdu_end)(struct htt_rx_desc *rxd);2193struct rx_ppdu_start *(*rx_desc_get_ppdu_start)(struct htt_rx_desc *rxd);2194struct rx_ppdu_end_common *(*rx_desc_get_ppdu_end)(struct htt_rx_desc *rxd);2195u8 *(*rx_desc_get_rx_hdr_status)(struct htt_rx_desc *rxd);2196u8 *(*rx_desc_get_msdu_payload)(struct htt_rx_desc *rxd);2197};21982199extern const struct ath10k_htt_rx_desc_ops qca988x_rx_desc_ops;2200extern const struct ath10k_htt_rx_desc_ops qca99x0_rx_desc_ops;2201extern const struct ath10k_htt_rx_desc_ops wcn3990_rx_desc_ops;22022203static inline int2204ath10k_htt_rx_desc_get_l3_pad_bytes(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)2205{2206if (hw->rx_desc_ops->rx_desc_get_l3_pad_bytes)2207return hw->rx_desc_ops->rx_desc_get_l3_pad_bytes(rxd);2208return 0;2209}22102211static inline bool2212ath10k_htt_rx_desc_msdu_limit_error(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)2213{2214if (hw->rx_desc_ops->rx_desc_get_msdu_limit_error)2215return hw->rx_desc_ops->rx_desc_get_msdu_limit_error(rxd);2216return false;2217}22182219/* The default implementation of all these getters is using the old rx_desc,2220* so that it is easier to define the ath10k_htt_rx_desc_ops instances.2221* But probably, if new wireless cards must be supported, it would be better2222* to switch the default implementation to the new rx_desc, since this would2223* make the extension easier .2224*/2225static inline struct htt_rx_desc *2226ath10k_htt_rx_desc_from_raw_buffer(struct ath10k_hw_params *hw, void *buff)2227{2228if (hw->rx_desc_ops->rx_desc_from_raw_buffer)2229return hw->rx_desc_ops->rx_desc_from_raw_buffer(buff);2230return &((struct htt_rx_desc_v1 *)buff)->base;2231}22322233static inline void2234ath10k_htt_rx_desc_get_offsets(struct ath10k_hw_params *hw,2235struct htt_rx_ring_rx_desc_offsets *off)2236{2237if (hw->rx_desc_ops->rx_desc_get_offsets) {2238hw->rx_desc_ops->rx_desc_get_offsets(off);2239} else {2240#define desc_offset(x) (offsetof(struct htt_rx_desc_v1, x) / 4)2241off->mac80211_hdr_offset = __cpu_to_le16(desc_offset(rx_hdr_status));2242off->msdu_payload_offset = __cpu_to_le16(desc_offset(msdu_payload));2243off->ppdu_start_offset = __cpu_to_le16(desc_offset(ppdu_start));2244off->ppdu_end_offset = __cpu_to_le16(desc_offset(ppdu_end));2245off->mpdu_start_offset = __cpu_to_le16(desc_offset(mpdu_start));2246off->mpdu_end_offset = __cpu_to_le16(desc_offset(mpdu_end));2247off->msdu_start_offset = __cpu_to_le16(desc_offset(msdu_start));2248off->msdu_end_offset = __cpu_to_le16(desc_offset(msdu_end));2249off->rx_attention_offset = __cpu_to_le16(desc_offset(attention));2250off->frag_info_offset = __cpu_to_le16(desc_offset(frag_info));2251#undef desc_offset2252}2253}22542255static inline struct rx_attention *2256ath10k_htt_rx_desc_get_attention(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)2257{2258struct htt_rx_desc_v1 *rx_desc;22592260if (hw->rx_desc_ops->rx_desc_get_attention)2261return hw->rx_desc_ops->rx_desc_get_attention(rxd);22622263rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);2264return &rx_desc->attention;2265}22662267static inline struct rx_frag_info_common *2268ath10k_htt_rx_desc_get_frag_info(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)2269{2270struct htt_rx_desc_v1 *rx_desc;22712272if (hw->rx_desc_ops->rx_desc_get_frag_info)2273return hw->rx_desc_ops->rx_desc_get_frag_info(rxd);22742275rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);2276return &rx_desc->frag_info.common;2277}22782279static inline struct rx_mpdu_start *2280ath10k_htt_rx_desc_get_mpdu_start(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)2281{2282struct htt_rx_desc_v1 *rx_desc;22832284if (hw->rx_desc_ops->rx_desc_get_mpdu_start)2285return hw->rx_desc_ops->rx_desc_get_mpdu_start(rxd);22862287rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);2288return &rx_desc->mpdu_start;2289}22902291static inline struct rx_mpdu_end *2292ath10k_htt_rx_desc_get_mpdu_end(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)2293{2294struct htt_rx_desc_v1 *rx_desc;22952296if (hw->rx_desc_ops->rx_desc_get_mpdu_end)2297return hw->rx_desc_ops->rx_desc_get_mpdu_end(rxd);22982299rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);2300return &rx_desc->mpdu_end;2301}23022303static inline struct rx_msdu_start_common *2304ath10k_htt_rx_desc_get_msdu_start(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)2305{2306struct htt_rx_desc_v1 *rx_desc;23072308if (hw->rx_desc_ops->rx_desc_get_msdu_start)2309return hw->rx_desc_ops->rx_desc_get_msdu_start(rxd);23102311rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);2312return &rx_desc->msdu_start.common;2313}23142315static inline struct rx_msdu_end_common *2316ath10k_htt_rx_desc_get_msdu_end(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)2317{2318struct htt_rx_desc_v1 *rx_desc;23192320if (hw->rx_desc_ops->rx_desc_get_msdu_end)2321return hw->rx_desc_ops->rx_desc_get_msdu_end(rxd);23222323rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);2324return &rx_desc->msdu_end.common;2325}23262327static inline struct rx_ppdu_start *2328ath10k_htt_rx_desc_get_ppdu_start(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)2329{2330struct htt_rx_desc_v1 *rx_desc;23312332if (hw->rx_desc_ops->rx_desc_get_ppdu_start)2333return hw->rx_desc_ops->rx_desc_get_ppdu_start(rxd);23342335rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);2336return &rx_desc->ppdu_start;2337}23382339static inline struct rx_ppdu_end_common *2340ath10k_htt_rx_desc_get_ppdu_end(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)2341{2342struct htt_rx_desc_v1 *rx_desc;23432344if (hw->rx_desc_ops->rx_desc_get_ppdu_end)2345return hw->rx_desc_ops->rx_desc_get_ppdu_end(rxd);23462347rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);2348return &rx_desc->ppdu_end.common;2349}23502351static inline u8 *2352ath10k_htt_rx_desc_get_rx_hdr_status(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)2353{2354struct htt_rx_desc_v1 *rx_desc;23552356if (hw->rx_desc_ops->rx_desc_get_rx_hdr_status)2357return hw->rx_desc_ops->rx_desc_get_rx_hdr_status(rxd);23582359rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);2360return rx_desc->rx_hdr_status;2361}23622363static inline u8 *2364ath10k_htt_rx_desc_get_msdu_payload(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)2365{2366struct htt_rx_desc_v1 *rx_desc;23672368if (hw->rx_desc_ops->rx_desc_get_msdu_payload)2369return hw->rx_desc_ops->rx_desc_get_msdu_payload(rxd);23702371rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);2372return rx_desc->msdu_payload;2373}23742375#define HTT_RX_DESC_HL_INFO_SEQ_NUM_MASK 0x00000fff2376#define HTT_RX_DESC_HL_INFO_SEQ_NUM_LSB 02377#define HTT_RX_DESC_HL_INFO_ENCRYPTED_MASK 0x000010002378#define HTT_RX_DESC_HL_INFO_ENCRYPTED_LSB 122379#define HTT_RX_DESC_HL_INFO_CHAN_INFO_PRESENT_MASK 0x000020002380#define HTT_RX_DESC_HL_INFO_CHAN_INFO_PRESENT_LSB 132381#define HTT_RX_DESC_HL_INFO_MCAST_BCAST_MASK 0x000100002382#define HTT_RX_DESC_HL_INFO_MCAST_BCAST_LSB 162383#define HTT_RX_DESC_HL_INFO_KEY_ID_OCT_MASK 0x01fe00002384#define HTT_RX_DESC_HL_INFO_KEY_ID_OCT_LSB 1723852386struct htt_rx_desc_base_hl {2387__le32 info; /* HTT_RX_DESC_HL_INFO_ */2388};23892390struct htt_rx_chan_info {2391__le16 primary_chan_center_freq_mhz;2392__le16 contig_chan1_center_freq_mhz;2393__le16 contig_chan2_center_freq_mhz;2394u8 phy_mode;2395u8 reserved;2396} __packed;23972398#define HTT_RX_DESC_ALIGN 823992400#define HTT_MAC_ADDR_LEN 624012402/*2403* FIX THIS2404* Should be: sizeof(struct htt_host_rx_desc) + max rx MSDU size,2405* rounded up to a cache line size.2406*/2407#define HTT_RX_BUF_SIZE 204824082409/* The HTT_RX_MSDU_SIZE can't be statically computed anymore,2410* because it depends on the underlying device rx_desc representation2411*/2412static inline int ath10k_htt_rx_msdu_size(struct ath10k_hw_params *hw)2413{2414return HTT_RX_BUF_SIZE - (int)hw->rx_desc_ops->rx_desc_size;2415}24162417/* Refill a bunch of RX buffers for each refill round so that FW/HW can handle2418* aggregated traffic more nicely.2419*/2420#define ATH10K_HTT_MAX_NUM_REFILL 10024212422/*2423* DMA_MAP expects the buffer to be an integral number of cache lines.2424* Rather than checking the actual cache line size, this code makes a2425* conservative estimate of what the cache line size could be.2426*/2427#define HTT_LOG2_MAX_CACHE_LINE_SIZE 7 /* 2^7 = 128 */2428#define HTT_MAX_CACHE_LINE_SIZE_MASK ((1 << HTT_LOG2_MAX_CACHE_LINE_SIZE) - 1)24292430/* These values are default in most firmware revisions and apparently are a2431* sweet spot performance wise.2432*/2433#define ATH10K_HTT_MAX_NUM_AMSDU_DEFAULT 32434#define ATH10K_HTT_MAX_NUM_AMPDU_DEFAULT 6424352436int ath10k_htt_connect(struct ath10k_htt *htt);2437int ath10k_htt_init(struct ath10k *ar);2438int ath10k_htt_setup(struct ath10k_htt *htt);24392440int ath10k_htt_tx_start(struct ath10k_htt *htt);2441void ath10k_htt_tx_stop(struct ath10k_htt *htt);2442void ath10k_htt_tx_destroy(struct ath10k_htt *htt);2443void ath10k_htt_tx_free(struct ath10k_htt *htt);24442445int ath10k_htt_rx_alloc(struct ath10k_htt *htt);2446int ath10k_htt_rx_ring_refill(struct ath10k *ar);2447void ath10k_htt_rx_free(struct ath10k_htt *htt);24482449void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb);2450void ath10k_htt_htc_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);2451bool ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);2452int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt);2453int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u32 mask, u32 reset_mask,2454u64 cookie);2455void ath10k_htt_hif_tx_complete(struct ath10k *ar, struct sk_buff *skb);2456int ath10k_htt_tx_fetch_resp(struct ath10k *ar,2457__le32 token,2458__le16 fetch_seq_num,2459struct htt_tx_fetch_record *records,2460size_t num_records);2461void ath10k_htt_op_ep_tx_credits(struct ath10k *ar);24622463void ath10k_htt_tx_txq_update(struct ieee80211_hw *hw,2464struct ieee80211_txq *txq);2465void ath10k_htt_tx_txq_recalc(struct ieee80211_hw *hw,2466struct ieee80211_txq *txq);2467void ath10k_htt_tx_txq_sync(struct ath10k *ar);2468void ath10k_htt_tx_dec_pending(struct ath10k_htt *htt);2469int ath10k_htt_tx_inc_pending(struct ath10k_htt *htt);2470void ath10k_htt_tx_mgmt_dec_pending(struct ath10k_htt *htt);2471int ath10k_htt_tx_mgmt_inc_pending(struct ath10k_htt *htt, bool is_mgmt,2472bool is_presp);24732474int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt *htt, struct sk_buff *skb);2475void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id);2476int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu);2477void ath10k_htt_rx_pktlog_completion_handler(struct ath10k *ar,2478struct sk_buff *skb);2479int ath10k_htt_txrx_compl_task(struct ath10k *ar, int budget);2480int ath10k_htt_rx_hl_indication(struct ath10k *ar, int budget);2481void ath10k_htt_set_tx_ops(struct ath10k_htt *htt);2482void ath10k_htt_set_rx_ops(struct ath10k_htt *htt);2483#endif248424852486