ah_desc.h revision 239381
1185377Ssam/* 2185377Ssam * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting 3185377Ssam * Copyright (c) 2002-2008 Atheros Communications, Inc. 4185377Ssam * 5185377Ssam * Permission to use, copy, modify, and/or distribute this software for any 6185377Ssam * purpose with or without fee is hereby granted, provided that the above 7185377Ssam * copyright notice and this permission notice appear in all copies. 8185377Ssam * 9185377Ssam * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10185377Ssam * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11185377Ssam * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12185377Ssam * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13185377Ssam * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14185377Ssam * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15185377Ssam * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16185377Ssam * 17194135Ssam * $FreeBSD: head/sys/dev/ath/ath_hal/ah_desc.h 239381 2012-08-19 02:22:16Z adrian $ 18185377Ssam */ 19185377Ssam 20185377Ssam#ifndef _DEV_ATH_DESC_H 21185377Ssam#define _DEV_ATH_DESC_H 22185377Ssam 23185377Ssam#include "opt_ah.h" /* NB: required for AH_SUPPORT_AR5416 */ 24185377Ssam 25185377Ssam/* 26229790Sadrian * For now, define this for the structure definitions. 27229790Sadrian * Because of how the HAL / driver module currently builds, 28229790Sadrian * it's not very feasible to build the module without 29229790Sadrian * this defined. The rest of the code (eg in the driver 30229790Sadrian * body) can work fine with these fields being uninitialised; 31229790Sadrian * they'll be initialised to 0 anyway. 32229790Sadrian */ 33229790Sadrian 34229791Sadrian#ifndef AH_SUPPORT_AR5416 35229790Sadrian#define AH_SUPPORT_AR5416 1 36229791Sadrian#endif 37229790Sadrian 38229790Sadrian/* 39185377Ssam * Transmit descriptor status. This structure is filled 40185377Ssam * in only after the tx descriptor process method finds a 41185377Ssam * ``done'' descriptor; at which point it returns something 42185377Ssam * other than HAL_EINPROGRESS. 43185377Ssam * 44185377Ssam * Note that ts_antenna may not be valid for all h/w. It 45185377Ssam * should be used only if non-zero. 46185377Ssam */ 47185377Ssamstruct ath_tx_status { 48185377Ssam uint16_t ts_seqnum; /* h/w assigned sequence number */ 49185377Ssam uint16_t ts_tstamp; /* h/w assigned timestamp */ 50185377Ssam uint8_t ts_status; /* frame status, 0 => xmit ok */ 51185377Ssam uint8_t ts_rate; /* h/w transmit rate index */ 52185377Ssam int8_t ts_rssi; /* tx ack RSSI */ 53185377Ssam uint8_t ts_shortretry; /* # short retries */ 54185377Ssam uint8_t ts_longretry; /* # long retries */ 55185377Ssam uint8_t ts_virtcol; /* virtual collision count */ 56185377Ssam uint8_t ts_antenna; /* antenna information */ 57185377Ssam uint8_t ts_finaltsi; /* final transmit series index */ 58185377Ssam#ifdef AH_SUPPORT_AR5416 59185377Ssam /* 802.11n status */ 60238843Sadrian uint8_t ts_flags; /* misc flags */ 61238843Sadrian uint8_t ts_queue_id; /* AR9300: TX queue id */ 62238843Sadrian uint8_t ts_desc_id; /* AR9300: TX descriptor id */ 63238843Sadrian uint8_t ts_tid; /* TID */ 64185377Ssam/* #define ts_rssi ts_rssi_combined */ 65238843Sadrian uint32_t ts_ba_low; /* blockack bitmap low */ 66238843Sadrian uint32_t ts_ba_high; /* blockack bitmap high */ 67238843Sadrian uint32_t ts_evm0; /* evm bytes */ 68238843Sadrian uint32_t ts_evm1; 69238843Sadrian uint32_t ts_evm2; 70238843Sadrian int8_t ts_rssi_ctl[3]; /* tx ack RSSI [ctl, chain 0-2] */ 71238843Sadrian int8_t ts_rssi_ext[3]; /* tx ack RSSI [ext, chain 0-2] */ 72238843Sadrian uint8_t ts_pad[2]; 73185377Ssam#endif /* AH_SUPPORT_AR5416 */ 74185377Ssam}; 75185377Ssam 76185377Ssam/* bits found in ts_status */ 77185377Ssam#define HAL_TXERR_XRETRY 0x01 /* excessive retries */ 78185377Ssam#define HAL_TXERR_FILT 0x02 /* blocked by tx filtering */ 79185377Ssam#define HAL_TXERR_FIFO 0x04 /* fifo underrun */ 80185377Ssam#define HAL_TXERR_XTXOP 0x08 /* txop exceeded */ 81185377Ssam#define HAL_TXERR_TIMER_EXPIRED 0x10 /* Tx timer expired */ 82185377Ssam 83185377Ssam/* bits found in ts_flags */ 84185377Ssam#define HAL_TX_BA 0x01 /* Block Ack seen */ 85185377Ssam#define HAL_TX_AGGR 0x02 /* Aggregate */ 86185377Ssam#define HAL_TX_DESC_CFG_ERR 0x10 /* Error in 20/40 desc config */ 87185377Ssam#define HAL_TX_DATA_UNDERRUN 0x20 /* Tx buffer underrun */ 88185377Ssam#define HAL_TX_DELIM_UNDERRUN 0x40 /* Tx delimiter underrun */ 89185377Ssam 90185377Ssam/* 91185377Ssam * Receive descriptor status. This structure is filled 92185377Ssam * in only after the rx descriptor process method finds a 93185377Ssam * ``done'' descriptor; at which point it returns something 94185377Ssam * other than HAL_EINPROGRESS. 95185377Ssam * 96185377Ssam * If rx_status is zero, then the frame was received ok; 97185377Ssam * otherwise the error information is indicated and rs_phyerr 98185377Ssam * contains a phy error code if HAL_RXERR_PHY is set. In general 99185377Ssam * the frame contents is undefined when an error occurred thought 100185377Ssam * for some errors (e.g. a decryption error), it may be meaningful. 101185377Ssam * 102185377Ssam * Note that the receive timestamp is expanded using the TSF to 103185377Ssam * at least 15 bits (regardless of what the h/w provides directly). 104185377Ssam * Newer hardware supports a full 32-bits; use HAL_CAP_32TSTAMP to 105185377Ssam * find out if the hardware is capable. 106185377Ssam * 107185377Ssam * rx_rssi is in units of dbm above the noise floor. This value 108185377Ssam * is measured during the preamble and PLCP; i.e. with the initial 109185377Ssam * 4us of detection. The noise floor is typically a consistent 110185377Ssam * -96dBm absolute power in a 20MHz channel. 111185377Ssam */ 112185377Ssamstruct ath_rx_status { 113185377Ssam uint16_t rs_datalen; /* rx frame length */ 114185377Ssam uint8_t rs_status; /* rx status, 0 => recv ok */ 115185377Ssam uint8_t rs_phyerr; /* phy error code */ 116185377Ssam int8_t rs_rssi; /* rx frame RSSI (combined for 11n) */ 117185377Ssam uint8_t rs_keyix; /* key cache index */ 118185377Ssam uint8_t rs_rate; /* h/w receive rate index */ 119185377Ssam uint8_t rs_more; /* more descriptors follow */ 120185377Ssam uint32_t rs_tstamp; /* h/w assigned timestamp */ 121185377Ssam uint32_t rs_antenna; /* antenna information */ 122185377Ssam#ifdef AH_SUPPORT_AR5416 123185377Ssam /* 802.11n status */ 124185377Ssam int8_t rs_rssi_ctl[3]; /* rx frame RSSI [ctl, chain 0-2] */ 125185377Ssam int8_t rs_rssi_ext[3]; /* rx frame RSSI [ext, chain 0-2] */ 126185377Ssam uint8_t rs_isaggr; /* is part of the aggregate */ 127185377Ssam uint8_t rs_moreaggr; /* more frames in aggr to follow */ 128238314Sadrian uint16_t rs_flags; /* misc flags */ 129185377Ssam uint8_t rs_num_delims; /* number of delims in aggr */ 130238314Sadrian uint8_t rs_spare0; /* padding */ 131185377Ssam uint32_t rs_evm0; /* evm bytes */ 132185377Ssam uint32_t rs_evm1; 133238314Sadrian uint32_t rs_evm2; 134220438Sadrian uint32_t rs_evm3; /* needed for ar9300 and later */ 135220438Sadrian uint32_t rs_evm4; /* needed for ar9300 and later */ 136185377Ssam#endif /* AH_SUPPORT_AR5416 */ 137185377Ssam}; 138185377Ssam 139185377Ssam/* bits found in rs_status */ 140185377Ssam#define HAL_RXERR_CRC 0x01 /* CRC error on frame */ 141185377Ssam#define HAL_RXERR_PHY 0x02 /* PHY error, rs_phyerr is valid */ 142185377Ssam#define HAL_RXERR_FIFO 0x04 /* fifo overrun */ 143185377Ssam#define HAL_RXERR_DECRYPT 0x08 /* non-Michael decrypt error */ 144185377Ssam#define HAL_RXERR_MIC 0x10 /* Michael MIC decrypt error */ 145238314Sadrian#define HAL_RXERR_INCOMP 0x20 /* Rx Desc processing is incomplete */ 146238314Sadrian#define HAL_RXERR_KEYMISS 0x40 /* Key not found in keycache */ 147185377Ssam 148185377Ssam/* bits found in rs_flags */ 149238314Sadrian#define HAL_RX_MORE 0x0001 /* more descriptors follow */ 150238314Sadrian#define HAL_RX_MORE_AGGR 0x0002 /* more frames in aggr */ 151238314Sadrian#define HAL_RX_GI 0x0004 /* full gi */ 152238314Sadrian#define HAL_RX_2040 0x0008 /* 40 Mhz */ 153238314Sadrian#define HAL_RX_DELIM_CRC_PRE 0x0010 /* crc error in delimiter pre */ 154238314Sadrian#define HAL_RX_DELIM_CRC_POST 0x0020 /* crc error in delim after */ 155238314Sadrian#define HAL_RX_DECRYPT_BUSY 0x0040 /* decrypt was too slow */ 156238314Sadrian#define HAL_RX_HI_RX_CHAIN 0x0080 /* SM power save: hi Rx chain control */ 157238314Sadrian#define HAL_RX_IS_APSD 0x0100 /* Is ASPD trigger frame */ 158185377Ssam 159185377Ssamenum { 160185377Ssam HAL_PHYERR_UNDERRUN = 0, /* Transmit underrun */ 161185377Ssam HAL_PHYERR_TIMING = 1, /* Timing error */ 162185377Ssam HAL_PHYERR_PARITY = 2, /* Illegal parity */ 163185377Ssam HAL_PHYERR_RATE = 3, /* Illegal rate */ 164185377Ssam HAL_PHYERR_LENGTH = 4, /* Illegal length */ 165185377Ssam HAL_PHYERR_RADAR = 5, /* Radar detect */ 166185377Ssam HAL_PHYERR_SERVICE = 6, /* Illegal service */ 167185377Ssam HAL_PHYERR_TOR = 7, /* Transmit override receive */ 168222584Sadrian /* NB: these are specific to the 5212 and later */ 169185377Ssam HAL_PHYERR_OFDM_TIMING = 17, /* */ 170185377Ssam HAL_PHYERR_OFDM_SIGNAL_PARITY = 18, /* */ 171185377Ssam HAL_PHYERR_OFDM_RATE_ILLEGAL = 19, /* */ 172185377Ssam HAL_PHYERR_OFDM_LENGTH_ILLEGAL = 20, /* */ 173185377Ssam HAL_PHYERR_OFDM_POWER_DROP = 21, /* */ 174185377Ssam HAL_PHYERR_OFDM_SERVICE = 22, /* */ 175185377Ssam HAL_PHYERR_OFDM_RESTART = 23, /* */ 176222584Sadrian HAL_PHYERR_FALSE_RADAR_EXT = 24, /* */ 177185377Ssam HAL_PHYERR_CCK_TIMING = 25, /* */ 178185377Ssam HAL_PHYERR_CCK_HEADER_CRC = 26, /* */ 179185377Ssam HAL_PHYERR_CCK_RATE_ILLEGAL = 27, /* */ 180185377Ssam HAL_PHYERR_CCK_SERVICE = 30, /* */ 181185377Ssam HAL_PHYERR_CCK_RESTART = 31, /* */ 182224538Sadrian HAL_PHYERR_CCK_LENGTH_ILLEGAL = 32, /* */ 183224538Sadrian HAL_PHYERR_CCK_POWER_DROP = 33, /* */ 184224538Sadrian /* AR5416 and later */ 185224538Sadrian HAL_PHYERR_HT_CRC_ERROR = 34, /* */ 186224538Sadrian HAL_PHYERR_HT_LENGTH_ILLEGAL = 35, /* */ 187224538Sadrian HAL_PHYERR_HT_RATE_ILLEGAL = 36, /* */ 188238314Sadrian 189238314Sadrian HAL_PHYERR_SPECTRAL = 38, 190185377Ssam}; 191185377Ssam 192185377Ssam/* value found in rs_keyix to mark invalid entries */ 193185377Ssam#define HAL_RXKEYIX_INVALID ((uint8_t) -1) 194185377Ssam/* value used to specify no encryption key for xmit */ 195185377Ssam#define HAL_TXKEYIX_INVALID ((u_int) -1) 196185377Ssam 197185377Ssam/* XXX rs_antenna definitions */ 198185377Ssam 199185377Ssam/* 200185377Ssam * Definitions for the software frame/packet descriptors used by 201185380Ssam * the Atheros HAL. This definition obscures hardware-specific 202185380Ssam * details from the driver. Drivers are expected to fillin the 203185377Ssam * portions of a descriptor that are not opaque then use HAL calls 204185377Ssam * to complete the work. Status for completed frames is returned 205185377Ssam * in a device-independent format. 206185377Ssam */ 207185377Ssam#ifdef AH_SUPPORT_AR5416 208185377Ssam#define HAL_DESC_HW_SIZE 20 209185377Ssam#else 210185377Ssam#define HAL_DESC_HW_SIZE 4 211185377Ssam#endif /* AH_SUPPORT_AR5416 */ 212185377Ssam 213185377Ssamstruct ath_desc { 214185377Ssam /* 215185377Ssam * The following definitions are passed directly 216185377Ssam * the hardware and managed by the HAL. Drivers 217185377Ssam * should not touch those elements marked opaque. 218185377Ssam */ 219185377Ssam uint32_t ds_link; /* phys address of next descriptor */ 220185377Ssam uint32_t ds_data; /* phys address of data buffer */ 221185377Ssam uint32_t ds_ctl0; /* opaque DMA control 0 */ 222185377Ssam uint32_t ds_ctl1; /* opaque DMA control 1 */ 223185377Ssam uint32_t ds_hw[HAL_DESC_HW_SIZE]; /* opaque h/w region */ 224185377Ssam}; 225185377Ssam 226239381Sadrianstruct ath_desc_txedma { 227239381Sadrian uint32_t ds_info; 228239381Sadrian uint32_t ds_link; 229239381Sadrian uint32_t ds_hw[21]; /* includes buf/len */ 230239381Sadrian}; 231239381Sadrian 232185377Ssamstruct ath_desc_status { 233185377Ssam union { 234185377Ssam struct ath_tx_status tx;/* xmit status */ 235185377Ssam struct ath_rx_status rx;/* recv status */ 236185377Ssam } ds_us; 237185377Ssam}; 238185377Ssam 239185377Ssam#define ds_txstat ds_us.tx 240185377Ssam#define ds_rxstat ds_us.rx 241185377Ssam 242185377Ssam/* flags passed to tx descriptor setup methods */ 243237153Sadrian/* This is a uint16_t field in ath_buf, just be warned! */ 244185377Ssam#define HAL_TXDESC_CLRDMASK 0x0001 /* clear destination filter mask */ 245185377Ssam#define HAL_TXDESC_NOACK 0x0002 /* don't wait for ACK */ 246185377Ssam#define HAL_TXDESC_RTSENA 0x0004 /* enable RTS */ 247185377Ssam#define HAL_TXDESC_CTSENA 0x0008 /* enable CTS */ 248185377Ssam#define HAL_TXDESC_INTREQ 0x0010 /* enable per-descriptor interrupt */ 249185377Ssam#define HAL_TXDESC_VEOL 0x0020 /* mark virtual EOL */ 250185377Ssam/* NB: this only affects frame, not any RTS/CTS */ 251185377Ssam#define HAL_TXDESC_DURENA 0x0040 /* enable h/w write of duration field */ 252185377Ssam#define HAL_TXDESC_EXT_ONLY 0x0080 /* send on ext channel only (11n) */ 253185377Ssam#define HAL_TXDESC_EXT_AND_CTL 0x0100 /* send on ext + ctl channels (11n) */ 254185377Ssam#define HAL_TXDESC_VMF 0x0200 /* virtual more frag */ 255238843Sadrian#define HAL_TXDESC_LOWRXCHAIN 0x0400 /* switch to low RX chain */ 256238843Sadrian#define HAL_TXDESC_LDPC 0x1000 257185377Ssam 258185377Ssam/* flags passed to rx descriptor setup methods */ 259185377Ssam#define HAL_RXDESC_INTREQ 0x0020 /* enable per-descriptor interrupt */ 260185377Ssam#endif /* _DEV_ATH_DESC_H */ 261