/*-1* SPDX-License-Identifier: ISC2*3* Copyright (c) 2002-2008 Sam Leffler, Errno Consulting4* Copyright (c) 2002-2008 Atheros Communications, Inc.5*6* Permission to use, copy, modify, and/or distribute this software for any7* purpose with or without fee is hereby granted, provided that the above8* copyright notice and this permission notice appear in all copies.9*10* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES11* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF12* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR13* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES14* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN15* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF16* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.17*/1819#ifndef _DEV_ATH_DESC_H20#define _DEV_ATH_DESC_H2122/*23* Transmit descriptor status. This structure is filled24* in only after the tx descriptor process method finds a25* ``done'' descriptor; at which point it returns something26* other than HAL_EINPROGRESS.27*28* Note that ts_antenna may not be valid for all h/w. It29* should be used only if non-zero.30*/31struct ath_tx_status {32uint16_t ts_seqnum; /* h/w assigned sequence number */33uint16_t ts_pad1[1];34uint32_t ts_tstamp; /* h/w assigned timestamp */35uint8_t ts_status; /* frame status, 0 => xmit ok */36uint8_t ts_rate; /* h/w transmit rate index */37int8_t ts_rssi; /* tx ack RSSI */38uint8_t ts_shortretry; /* # short retries */39uint8_t ts_longretry; /* # long retries */40uint8_t ts_virtcol; /* virtual collision count */41uint8_t ts_antenna; /* antenna information */42uint8_t ts_finaltsi; /* final transmit series index */43/* 802.11n status */44uint8_t ts_flags; /* misc flags */45uint8_t ts_queue_id; /* AR9300: TX queue id */46uint8_t ts_desc_id; /* AR9300: TX descriptor id */47uint8_t ts_tid; /* TID */48/* #define ts_rssi ts_rssi_combined */49uint32_t ts_ba_low; /* blockack bitmap low */50uint32_t ts_ba_high; /* blockack bitmap high */51uint32_t ts_evm0; /* evm bytes */52uint32_t ts_evm1;53uint32_t ts_evm2;54int8_t ts_rssi_ctl[3]; /* tx ack RSSI [ctl, chain 0-2] */55int8_t ts_rssi_ext[3]; /* tx ack RSSI [ext, chain 0-2] */56uint8_t ts_pad[2];57};5859/* bits found in ts_status */60#define HAL_TXERR_XRETRY 0x01 /* excessive retries */61#define HAL_TXERR_FILT 0x02 /* blocked by tx filtering */62#define HAL_TXERR_FIFO 0x04 /* fifo underrun */63#define HAL_TXERR_XTXOP 0x08 /* txop exceeded */64#define HAL_TXERR_TIMER_EXPIRED 0x10 /* Tx timer expired */6566/* bits found in ts_flags */67#define HAL_TX_BA 0x01 /* Block Ack seen */68#define HAL_TX_AGGR 0x02 /* Aggregate */69#define HAL_TX_DESC_CFG_ERR 0x10 /* Error in 20/40 desc config */70#define HAL_TX_DATA_UNDERRUN 0x20 /* Tx buffer underrun */71#define HAL_TX_DELIM_UNDERRUN 0x40 /* Tx delimiter underrun */72#define HAL_TX_FAST_TS 0x80 /* Tx locationing timestamp */7374/*75* Receive descriptor status. This structure is filled76* in only after the rx descriptor process method finds a77* ``done'' descriptor; at which point it returns something78* other than HAL_EINPROGRESS.79*80* If rx_status is zero, then the frame was received ok;81* otherwise the error information is indicated and rs_phyerr82* contains a phy error code if HAL_RXERR_PHY is set. In general83* the frame contents is undefined when an error occurred thought84* for some errors (e.g. a decryption error), it may be meaningful.85*86* Note that the receive timestamp is expanded using the TSF to87* at least 15 bits (regardless of what the h/w provides directly).88* Newer hardware supports a full 32-bits; use HAL_CAP_32TSTAMP to89* find out if the hardware is capable.90*91* rx_rssi is in units of dbm above the noise floor. This value92* is measured during the preamble and PLCP; i.e. with the initial93* 4us of detection. The noise floor is typically a consistent94* -96dBm absolute power in a 20MHz channel.95*/96struct ath_rx_status {97uint16_t rs_datalen; /* rx frame length */98uint8_t rs_status; /* rx status, 0 => recv ok */99uint8_t rs_phyerr; /* phy error code */100int8_t rs_rssi; /* rx frame RSSI (combined for 11n) */101uint8_t rs_keyix; /* key cache index */102uint8_t rs_rate; /* h/w receive rate index */103uint8_t rs_more; /* more descriptors follow */104uint32_t rs_tstamp; /* h/w assigned timestamp */105uint32_t rs_antenna; /* antenna information */106/* 802.11n status */107int8_t rs_rssi_ctl[3]; /* rx frame RSSI [ctl, chain 0-2] */108int8_t rs_rssi_ext[3]; /* rx frame RSSI [ext, chain 0-2] */109uint8_t rs_isaggr; /* is part of the aggregate */110uint8_t rs_moreaggr; /* more frames in aggr to follow */111uint16_t rs_flags; /* misc flags */112uint8_t rs_num_delims; /* number of delims in aggr */113uint8_t rs_spare0; /* padding */114uint8_t rs_ness; /* number of extension spatial streams */115uint8_t rs_hw_upload_data_type; /* hw upload format */116uint16_t rs_spare1;117uint32_t rs_evm0; /* evm bytes */118uint32_t rs_evm1;119uint32_t rs_evm2;120uint32_t rs_evm3; /* needed for ar9300 and later */121uint32_t rs_evm4; /* needed for ar9300 and later */122};123124/* bits found in rs_status */125#define HAL_RXERR_CRC 0x01 /* CRC error on frame */126#define HAL_RXERR_PHY 0x02 /* PHY error, rs_phyerr is valid */127#define HAL_RXERR_FIFO 0x04 /* fifo overrun */128#define HAL_RXERR_DECRYPT 0x08 /* non-Michael decrypt error */129#define HAL_RXERR_MIC 0x10 /* Michael MIC decrypt error */130#define HAL_RXERR_INCOMP 0x20 /* Rx Desc processing is incomplete */131#define HAL_RXERR_KEYMISS 0x40 /* Key not found in keycache */132133/* bits found in rs_flags */134#define HAL_RX_MORE 0x0001 /* more descriptors follow */135#define HAL_RX_MORE_AGGR 0x0002 /* more frames in aggr */136#define HAL_RX_GI 0x0004 /* full gi */137#define HAL_RX_2040 0x0008 /* 40 Mhz */138#define HAL_RX_DELIM_CRC_PRE 0x0010 /* crc error in delimiter pre */139#define HAL_RX_DELIM_CRC_POST 0x0020 /* crc error in delim after */140#define HAL_RX_DECRYPT_BUSY 0x0040 /* decrypt was too slow */141#define HAL_RX_HI_RX_CHAIN 0x0080 /* SM power save: hi Rx chain control */142#define HAL_RX_IS_APSD 0x0100 /* Is ASPD trigger frame */143#define HAL_RX_STBC 0x0200 /* Is an STBC frame */144#define HAL_RX_LOC_INFO 0x0400 /* RX locationing information */145146#define HAL_RX_HW_UPLOAD_DATA 0x1000 /* This is a hardware data frame */147#define HAL_RX_HW_SOUNDING 0x2000 /* Rx sounding frame (TxBF, positioning) */148#define HAL_RX_UPLOAD_VALID 0x4000 /* This hardware data frame is valid */149150/*151* This is the format of RSSI[2] on the AR9285/AR9485.152* It encodes the LNA configuration information.153*154* For boards with an external diversity antenna switch,155* HAL_RX_LNA_EXTCFG encodes which configuration was156* used (antenna 1 or antenna 2.) This feeds into the157* switch table and ensures that the given antenna was158* connected to an LNA.159*/160#define HAL_RX_LNA_LNACFG 0x80 /* 1 = main LNA config used, 0 = ALT */161#define HAL_RX_LNA_EXTCFG 0x40 /* 0 = external diversity ant1, 1 = ant2 */162#define HAL_RX_LNA_CFG_USED 0x30 /* 2 bits; LNA config used on RX */163#define HAL_RX_LNA_CFG_USED_S 4164#define HAL_RX_LNA_CFG_MAIN 0x0c /* 2 bits; "Main" LNA config */165#define HAL_RX_LNA_CFG_ALT 0x02 /* 2 bits; "Alt" LNA config */166167/*168* This is the format of RSSI_EXT[2] on the AR9285/AR9485.169* It encodes the switch table configuration and fast diversity170* value.171*/172#define HAL_RX_LNA_FASTDIV 0x40 /* 1 = fast diversity measurement done */173#define HAL_RX_LNA_SWITCH_0 0x30 /* 2 bits; sw_0[1:0] */174#define HAL_RX_LNA_SWITCH_COM 0x0f /* 4 bits, sw_com[3:0] */175176enum {177HAL_PHYERR_UNDERRUN = 0, /* Transmit underrun */178HAL_PHYERR_TIMING = 1, /* Timing error */179HAL_PHYERR_PARITY = 2, /* Illegal parity */180HAL_PHYERR_RATE = 3, /* Illegal rate */181HAL_PHYERR_LENGTH = 4, /* Illegal length */182HAL_PHYERR_RADAR = 5, /* Radar detect */183HAL_PHYERR_SERVICE = 6, /* Illegal service */184HAL_PHYERR_TOR = 7, /* Transmit override receive */185/* NB: these are specific to the 5212 and later */186HAL_PHYERR_OFDM_TIMING = 17, /* */187HAL_PHYERR_OFDM_SIGNAL_PARITY = 18, /* */188HAL_PHYERR_OFDM_RATE_ILLEGAL = 19, /* */189HAL_PHYERR_OFDM_LENGTH_ILLEGAL = 20, /* */190HAL_PHYERR_OFDM_POWER_DROP = 21, /* */191HAL_PHYERR_OFDM_SERVICE = 22, /* */192HAL_PHYERR_OFDM_RESTART = 23, /* */193HAL_PHYERR_FALSE_RADAR_EXT = 24, /* */194HAL_PHYERR_CCK_TIMING = 25, /* */195HAL_PHYERR_CCK_HEADER_CRC = 26, /* */196HAL_PHYERR_CCK_RATE_ILLEGAL = 27, /* */197HAL_PHYERR_CCK_SERVICE = 30, /* */198HAL_PHYERR_CCK_RESTART = 31, /* */199HAL_PHYERR_CCK_LENGTH_ILLEGAL = 32, /* */200HAL_PHYERR_CCK_POWER_DROP = 33, /* */201/* AR5416 and later */202HAL_PHYERR_HT_CRC_ERROR = 34, /* */203HAL_PHYERR_HT_LENGTH_ILLEGAL = 35, /* */204HAL_PHYERR_HT_RATE_ILLEGAL = 36, /* */205206HAL_PHYERR_SPECTRAL = 38,207};208209/* value found in rs_keyix to mark invalid entries */210#define HAL_RXKEYIX_INVALID ((uint8_t) -1)211/* value used to specify no encryption key for xmit */212#define HAL_TXKEYIX_INVALID ((u_int) -1)213214/* XXX rs_antenna definitions */215216/*217* Definitions for the software frame/packet descriptors used by218* the Atheros HAL. This definition obscures hardware-specific219* details from the driver. Drivers are expected to fillin the220* portions of a descriptor that are not opaque then use HAL calls221* to complete the work. Status for completed frames is returned222* in a device-independent format.223*/224#define HAL_DESC_HW_SIZE 20225226struct ath_desc {227/*228* The following definitions are passed directly229* the hardware and managed by the HAL. Drivers230* should not touch those elements marked opaque.231*/232uint32_t ds_link; /* phys address of next descriptor */233uint32_t ds_data; /* phys address of data buffer */234uint32_t ds_ctl0; /* opaque DMA control 0 */235uint32_t ds_ctl1; /* opaque DMA control 1 */236uint32_t ds_hw[HAL_DESC_HW_SIZE]; /* opaque h/w region */237};238239struct ath_desc_txedma {240uint32_t ds_info;241uint32_t ds_link;242uint32_t ds_hw[21]; /* includes buf/len */243};244245struct ath_desc_status {246union {247struct ath_tx_status tx;/* xmit status */248struct ath_rx_status rx;/* recv status */249} ds_us;250};251252#define ds_txstat ds_us.tx253#define ds_rxstat ds_us.rx254255/* flags passed to tx descriptor setup methods */256/* This is a uint16_t field in ath_buf, just be warned! */257#define HAL_TXDESC_CLRDMASK 0x0001 /* clear destination filter mask */258#define HAL_TXDESC_NOACK 0x0002 /* don't wait for ACK */259#define HAL_TXDESC_RTSENA 0x0004 /* enable RTS */260#define HAL_TXDESC_CTSENA 0x0008 /* enable CTS */261#define HAL_TXDESC_INTREQ 0x0010 /* enable per-descriptor interrupt */262#define HAL_TXDESC_VEOL 0x0020 /* mark virtual EOL */263/* NB: this only affects frame, not any RTS/CTS */264#define HAL_TXDESC_DURENA 0x0040 /* enable h/w write of duration field */265#define HAL_TXDESC_EXT_ONLY 0x0080 /* send on ext channel only (11n) */266#define HAL_TXDESC_EXT_AND_CTL 0x0100 /* send on ext + ctl channels (11n) */267#define HAL_TXDESC_VMF 0x0200 /* virtual more frag */268#define HAL_TXDESC_LOWRXCHAIN 0x0400 /* switch to low RX chain */269#define HAL_TXDESC_LDPC 0x1000 /* Set LDPC TX for all rates */270#define HAL_TXDESC_HWTS 0x2000 /* Request Azimuth Timestamp in TX payload */271#define HAL_TXDESC_POS 0x4000 /* Request ToD/ToA locationing */272273/* flags passed to rx descriptor setup methods */274#define HAL_RXDESC_INTREQ 0x0020 /* enable per-descriptor interrupt */275#endif /* _DEV_ATH_DESC_H */276277278