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