ah_desc.h revision 1.1.1.1 1 1.1 alc /*
2 1.1 alc * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
3 1.1 alc * Copyright (c) 2002-2008 Atheros Communications, Inc.
4 1.1 alc *
5 1.1 alc * Permission to use, copy, modify, and/or distribute this software for any
6 1.1 alc * purpose with or without fee is hereby granted, provided that the above
7 1.1 alc * copyright notice and this permission notice appear in all copies.
8 1.1 alc *
9 1.1 alc * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 1.1 alc * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 1.1 alc * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 1.1 alc * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 1.1 alc * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 1.1 alc * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 1.1 alc * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 1.1 alc *
17 1.1 alc * $Id: ah_desc.h,v 1.1.1.1 2008/12/11 04:46:23 alc Exp $
18 1.1 alc */
19 1.1 alc
20 1.1 alc #ifndef _DEV_ATH_DESC_H
21 1.1 alc #define _DEV_ATH_DESC_H
22 1.1 alc
23 1.1 alc #include "opt_ah.h" /* NB: required for AH_SUPPORT_AR5416 */
24 1.1 alc
25 1.1 alc /*
26 1.1 alc * Transmit descriptor status. This structure is filled
27 1.1 alc * in only after the tx descriptor process method finds a
28 1.1 alc * ``done'' descriptor; at which point it returns something
29 1.1 alc * other than HAL_EINPROGRESS.
30 1.1 alc *
31 1.1 alc * Note that ts_antenna may not be valid for all h/w. It
32 1.1 alc * should be used only if non-zero.
33 1.1 alc */
34 1.1 alc struct ath_tx_status {
35 1.1 alc uint16_t ts_seqnum; /* h/w assigned sequence number */
36 1.1 alc uint16_t ts_tstamp; /* h/w assigned timestamp */
37 1.1 alc uint8_t ts_status; /* frame status, 0 => xmit ok */
38 1.1 alc uint8_t ts_rate; /* h/w transmit rate index */
39 1.1 alc #define HAL_TXSTAT_ALTRATE 0x80 /* alternate xmit rate used */
40 1.1 alc int8_t ts_rssi; /* tx ack RSSI */
41 1.1 alc uint8_t ts_shortretry; /* # short retries */
42 1.1 alc uint8_t ts_longretry; /* # long retries */
43 1.1 alc uint8_t ts_virtcol; /* virtual collision count */
44 1.1 alc uint8_t ts_antenna; /* antenna information */
45 1.1 alc uint8_t ts_finaltsi; /* final transmit series index */
46 1.1 alc #ifdef AH_SUPPORT_AR5416
47 1.1 alc /* 802.11n status */
48 1.1 alc uint8_t ts_flags; /* misc flags */
49 1.1 alc int8_t ts_rssi_ctl[3]; /* tx ack RSSI [ctl, chain 0-2] */
50 1.1 alc int8_t ts_rssi_ext[3]; /* tx ack RSSI [ext, chain 0-2] */
51 1.1 alc /* #define ts_rssi ts_rssi_combined */
52 1.1 alc uint32_t ts_ba_low; /* blockack bitmap low */
53 1.1 alc uint32_t ts_ba_high; /* blockack bitmap high */
54 1.1 alc uint32_t ts_evm0; /* evm bytes */
55 1.1 alc uint32_t ts_evm1;
56 1.1 alc uint32_t ts_evm2;
57 1.1 alc #endif /* AH_SUPPORT_AR5416 */
58 1.1 alc };
59 1.1 alc
60 1.1 alc /* bits found in ts_status */
61 1.1 alc #define HAL_TXERR_XRETRY 0x01 /* excessive retries */
62 1.1 alc #define HAL_TXERR_FILT 0x02 /* blocked by tx filtering */
63 1.1 alc #define HAL_TXERR_FIFO 0x04 /* fifo underrun */
64 1.1 alc #define HAL_TXERR_XTXOP 0x08 /* txop exceeded */
65 1.1 alc #define HAL_TXERR_TIMER_EXPIRED 0x10 /* Tx timer expired */
66 1.1 alc
67 1.1 alc /* bits found in ts_flags */
68 1.1 alc #define HAL_TX_BA 0x01 /* Block Ack seen */
69 1.1 alc #define HAL_TX_AGGR 0x02 /* Aggregate */
70 1.1 alc #define HAL_TX_DESC_CFG_ERR 0x10 /* Error in 20/40 desc config */
71 1.1 alc #define HAL_TX_DATA_UNDERRUN 0x20 /* Tx buffer underrun */
72 1.1 alc #define HAL_TX_DELIM_UNDERRUN 0x40 /* Tx delimiter underrun */
73 1.1 alc
74 1.1 alc /*
75 1.1 alc * Receive descriptor status. This structure is filled
76 1.1 alc * in only after the rx descriptor process method finds a
77 1.1 alc * ``done'' descriptor; at which point it returns something
78 1.1 alc * other than HAL_EINPROGRESS.
79 1.1 alc *
80 1.1 alc * If rx_status is zero, then the frame was received ok;
81 1.1 alc * otherwise the error information is indicated and rs_phyerr
82 1.1 alc * contains a phy error code if HAL_RXERR_PHY is set. In general
83 1.1 alc * the frame contents is undefined when an error occurred thought
84 1.1 alc * for some errors (e.g. a decryption error), it may be meaningful.
85 1.1 alc *
86 1.1 alc * Note that the receive timestamp is expanded using the TSF to
87 1.1 alc * at least 15 bits (regardless of what the h/w provides directly).
88 1.1 alc * Newer hardware supports a full 32-bits; use HAL_CAP_32TSTAMP to
89 1.1 alc * find out if the hardware is capable.
90 1.1 alc *
91 1.1 alc * rx_rssi is in units of dbm above the noise floor. This value
92 1.1 alc * is measured during the preamble and PLCP; i.e. with the initial
93 1.1 alc * 4us of detection. The noise floor is typically a consistent
94 1.1 alc * -96dBm absolute power in a 20MHz channel.
95 1.1 alc */
96 1.1 alc struct ath_rx_status {
97 1.1 alc uint16_t rs_datalen; /* rx frame length */
98 1.1 alc uint8_t rs_status; /* rx status, 0 => recv ok */
99 1.1 alc uint8_t rs_phyerr; /* phy error code */
100 1.1 alc int8_t rs_rssi; /* rx frame RSSI (combined for 11n) */
101 1.1 alc uint8_t rs_keyix; /* key cache index */
102 1.1 alc uint8_t rs_rate; /* h/w receive rate index */
103 1.1 alc uint8_t rs_more; /* more descriptors follow */
104 1.1 alc uint32_t rs_tstamp; /* h/w assigned timestamp */
105 1.1 alc uint32_t rs_antenna; /* antenna information */
106 1.1 alc #ifdef AH_SUPPORT_AR5416
107 1.1 alc /* 802.11n status */
108 1.1 alc int8_t rs_rssi_ctl[3]; /* rx frame RSSI [ctl, chain 0-2] */
109 1.1 alc int8_t rs_rssi_ext[3]; /* rx frame RSSI [ext, chain 0-2] */
110 1.1 alc uint8_t rs_isaggr; /* is part of the aggregate */
111 1.1 alc uint8_t rs_moreaggr; /* more frames in aggr to follow */
112 1.1 alc uint8_t rs_num_delims; /* number of delims in aggr */
113 1.1 alc uint8_t rs_flags; /* misc flags */
114 1.1 alc uint32_t rs_evm0; /* evm bytes */
115 1.1 alc uint32_t rs_evm1;
116 1.1 alc uint32_t rs_evm2;
117 1.1 alc #endif /* AH_SUPPORT_AR5416 */
118 1.1 alc };
119 1.1 alc
120 1.1 alc /* bits found in rs_status */
121 1.1 alc #define HAL_RXERR_CRC 0x01 /* CRC error on frame */
122 1.1 alc #define HAL_RXERR_PHY 0x02 /* PHY error, rs_phyerr is valid */
123 1.1 alc #define HAL_RXERR_FIFO 0x04 /* fifo overrun */
124 1.1 alc #define HAL_RXERR_DECRYPT 0x08 /* non-Michael decrypt error */
125 1.1 alc #define HAL_RXERR_MIC 0x10 /* Michael MIC decrypt error */
126 1.1 alc
127 1.1 alc /* bits found in rs_flags */
128 1.1 alc #define HAL_RX_MORE 0x01 /* more descriptors follow */
129 1.1 alc #define HAL_RX_MORE_AGGR 0x02 /* more frames in aggr */
130 1.1 alc #define HAL_RX_GI 0x04 /* full gi */
131 1.1 alc #define HAL_RX_2040 0x08 /* 40 Mhz */
132 1.1 alc #define HAL_RX_DELIM_CRC_PRE 0x10 /* crc error in delimiter pre */
133 1.1 alc #define HAL_RX_DELIM_CRC_POST 0x20 /* crc error in delim after */
134 1.1 alc #define HAL_RX_DECRYPT_BUSY 0x40 /* decrypt was too slow */
135 1.1 alc #define HAL_RX_HI_RX_CHAIN 0x80 /* SM power save: hi Rx chain control */
136 1.1 alc
137 1.1 alc enum {
138 1.1 alc HAL_PHYERR_UNDERRUN = 0, /* Transmit underrun */
139 1.1 alc HAL_PHYERR_TIMING = 1, /* Timing error */
140 1.1 alc HAL_PHYERR_PARITY = 2, /* Illegal parity */
141 1.1 alc HAL_PHYERR_RATE = 3, /* Illegal rate */
142 1.1 alc HAL_PHYERR_LENGTH = 4, /* Illegal length */
143 1.1 alc HAL_PHYERR_RADAR = 5, /* Radar detect */
144 1.1 alc HAL_PHYERR_SERVICE = 6, /* Illegal service */
145 1.1 alc HAL_PHYERR_TOR = 7, /* Transmit override receive */
146 1.1 alc /* NB: these are specific to the 5212 */
147 1.1 alc HAL_PHYERR_OFDM_TIMING = 17, /* */
148 1.1 alc HAL_PHYERR_OFDM_SIGNAL_PARITY = 18, /* */
149 1.1 alc HAL_PHYERR_OFDM_RATE_ILLEGAL = 19, /* */
150 1.1 alc HAL_PHYERR_OFDM_LENGTH_ILLEGAL = 20, /* */
151 1.1 alc HAL_PHYERR_OFDM_POWER_DROP = 21, /* */
152 1.1 alc HAL_PHYERR_OFDM_SERVICE = 22, /* */
153 1.1 alc HAL_PHYERR_OFDM_RESTART = 23, /* */
154 1.1 alc HAL_PHYERR_CCK_TIMING = 25, /* */
155 1.1 alc HAL_PHYERR_CCK_HEADER_CRC = 26, /* */
156 1.1 alc HAL_PHYERR_CCK_RATE_ILLEGAL = 27, /* */
157 1.1 alc HAL_PHYERR_CCK_SERVICE = 30, /* */
158 1.1 alc HAL_PHYERR_CCK_RESTART = 31, /* */
159 1.1 alc };
160 1.1 alc
161 1.1 alc /* value found in rs_keyix to mark invalid entries */
162 1.1 alc #define HAL_RXKEYIX_INVALID ((uint8_t) -1)
163 1.1 alc /* value used to specify no encryption key for xmit */
164 1.1 alc #define HAL_TXKEYIX_INVALID ((u_int) -1)
165 1.1 alc
166 1.1 alc /* XXX rs_antenna definitions */
167 1.1 alc
168 1.1 alc /*
169 1.1 alc * Definitions for the software frame/packet descriptors used by
170 1.1 alc * the Atheros HAL. This definition obscures hardware-specific
171 1.1 alc * details from the driver. Drivers are expected to fillin the
172 1.1 alc * portions of a descriptor that are not opaque then use HAL calls
173 1.1 alc * to complete the work. Status for completed frames is returned
174 1.1 alc * in a device-independent format.
175 1.1 alc */
176 1.1 alc #ifdef AH_SUPPORT_AR5416
177 1.1 alc #define HAL_DESC_HW_SIZE 20
178 1.1 alc #else
179 1.1 alc #define HAL_DESC_HW_SIZE 4
180 1.1 alc #endif /* AH_SUPPORT_AR5416 */
181 1.1 alc
182 1.1 alc struct ath_desc {
183 1.1 alc /*
184 1.1 alc * The following definitions are passed directly
185 1.1 alc * the hardware and managed by the HAL. Drivers
186 1.1 alc * should not touch those elements marked opaque.
187 1.1 alc */
188 1.1 alc uint32_t ds_link; /* phys address of next descriptor */
189 1.1 alc uint32_t ds_data; /* phys address of data buffer */
190 1.1 alc uint32_t ds_ctl0; /* opaque DMA control 0 */
191 1.1 alc uint32_t ds_ctl1; /* opaque DMA control 1 */
192 1.1 alc uint32_t ds_hw[HAL_DESC_HW_SIZE]; /* opaque h/w region */
193 1.1 alc };
194 1.1 alc
195 1.1 alc struct ath_desc_status {
196 1.1 alc union {
197 1.1 alc struct ath_tx_status tx;/* xmit status */
198 1.1 alc struct ath_rx_status rx;/* recv status */
199 1.1 alc } ds_us;
200 1.1 alc };
201 1.1 alc
202 1.1 alc #define ds_txstat ds_us.tx
203 1.1 alc #define ds_rxstat ds_us.rx
204 1.1 alc
205 1.1 alc /* flags passed to tx descriptor setup methods */
206 1.1 alc #define HAL_TXDESC_CLRDMASK 0x0001 /* clear destination filter mask */
207 1.1 alc #define HAL_TXDESC_NOACK 0x0002 /* don't wait for ACK */
208 1.1 alc #define HAL_TXDESC_RTSENA 0x0004 /* enable RTS */
209 1.1 alc #define HAL_TXDESC_CTSENA 0x0008 /* enable CTS */
210 1.1 alc #define HAL_TXDESC_INTREQ 0x0010 /* enable per-descriptor interrupt */
211 1.1 alc #define HAL_TXDESC_VEOL 0x0020 /* mark virtual EOL */
212 1.1 alc /* NB: this only affects frame, not any RTS/CTS */
213 1.1 alc #define HAL_TXDESC_DURENA 0x0040 /* enable h/w write of duration field */
214 1.1 alc #define HAL_TXDESC_EXT_ONLY 0x0080 /* send on ext channel only (11n) */
215 1.1 alc #define HAL_TXDESC_EXT_AND_CTL 0x0100 /* send on ext + ctl channels (11n) */
216 1.1 alc #define HAL_TXDESC_VMF 0x0200 /* virtual more frag */
217 1.1 alc
218 1.1 alc /* flags passed to rx descriptor setup methods */
219 1.1 alc #define HAL_RXDESC_INTREQ 0x0020 /* enable per-descriptor interrupt */
220 1.1 alc #endif /* _DEV_ATH_DESC_H */
221