162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
362306a36Sopenharmony_ci * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Permission to use, copy, modify, and distribute this software for any
662306a36Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above
762306a36Sopenharmony_ci * copyright notice and this permission notice appear in all copies.
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1062306a36Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1162306a36Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1262306a36Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1362306a36Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1462306a36Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1562306a36Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1662306a36Sopenharmony_ci *
1762306a36Sopenharmony_ci */
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci/*
2062306a36Sopenharmony_ci * RX/TX descriptor structures
2162306a36Sopenharmony_ci */
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci/**
2462306a36Sopenharmony_ci * struct ath5k_hw_rx_ctl - Common hardware RX control descriptor
2562306a36Sopenharmony_ci * @rx_control_0: RX control word 0
2662306a36Sopenharmony_ci * @rx_control_1: RX control word 1
2762306a36Sopenharmony_ci */
2862306a36Sopenharmony_cistruct ath5k_hw_rx_ctl {
2962306a36Sopenharmony_ci	u32	rx_control_0;
3062306a36Sopenharmony_ci	u32	rx_control_1;
3162306a36Sopenharmony_ci} __packed __aligned(4);
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/* RX control word 1 fields/flags */
3462306a36Sopenharmony_ci#define AR5K_DESC_RX_CTL1_BUF_LEN		0x00000fff /* data buffer length */
3562306a36Sopenharmony_ci#define AR5K_DESC_RX_CTL1_INTREQ		0x00002000 /* RX interrupt request */
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci/**
3862306a36Sopenharmony_ci * struct ath5k_hw_rx_status - Common hardware RX status descriptor
3962306a36Sopenharmony_ci * @rx_status_0: RX status word 0
4062306a36Sopenharmony_ci * @rx_status_1: RX status word 1
4162306a36Sopenharmony_ci *
4262306a36Sopenharmony_ci * 5210, 5211 and 5212 differ only in the fields and flags defined below
4362306a36Sopenharmony_ci */
4462306a36Sopenharmony_cistruct ath5k_hw_rx_status {
4562306a36Sopenharmony_ci	u32	rx_status_0;
4662306a36Sopenharmony_ci	u32	rx_status_1;
4762306a36Sopenharmony_ci} __packed __aligned(4);
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci/* 5210/5211 */
5062306a36Sopenharmony_ci/* RX status word 0 fields/flags */
5162306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS0_DATA_LEN		0x00000fff /* RX data length */
5262306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS0_MORE			0x00001000 /* more desc for this frame */
5362306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS0_RECEIVE_ANT_5210	0x00004000 /* [5210] receive on ant 1 */
5462306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS0_RECEIVE_RATE		0x00078000 /* reception rate */
5562306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS0_RECEIVE_RATE_S	15
5662306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS0_RECEIVE_SIGNAL	0x07f80000 /* rssi */
5762306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS0_RECEIVE_SIGNAL_S	19
5862306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS0_RECEIVE_ANT_5211	0x38000000 /* [5211] receive antenna */
5962306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS0_RECEIVE_ANT_5211_S	27
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci/* RX status word 1 fields/flags */
6262306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS1_DONE			0x00000001 /* descriptor complete */
6362306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS1_FRAME_RECEIVE_OK	0x00000002 /* reception success */
6462306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS1_CRC_ERROR		0x00000004 /* CRC error */
6562306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS1_FIFO_OVERRUN_5210	0x00000008 /* [5210] FIFO overrun */
6662306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS1_DECRYPT_CRC_ERROR	0x00000010 /* decryption CRC failure */
6762306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS1_PHY_ERROR		0x000000e0 /* PHY error */
6862306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS1_PHY_ERROR_S		5
6962306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS1_KEY_INDEX_VALID	0x00000100 /* key index valid */
7062306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS1_KEY_INDEX		0x00007e00 /* decryption key index */
7162306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS1_KEY_INDEX_S		9
7262306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS1_RECEIVE_TIMESTAMP	0x0fff8000 /* 13 bit of TSF */
7362306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS1_RECEIVE_TIMESTAMP_S	15
7462306a36Sopenharmony_ci#define AR5K_5210_RX_DESC_STATUS1_KEY_CACHE_MISS	0x10000000 /* key cache miss */
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/* 5212 */
7762306a36Sopenharmony_ci/* RX status word 0 fields/flags */
7862306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS0_DATA_LEN		0x00000fff /* RX data length */
7962306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS0_MORE			0x00001000 /* more desc for this frame */
8062306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS0_DECOMP_CRC_ERROR	0x00002000 /* decompression CRC error */
8162306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS0_RECEIVE_RATE		0x000f8000 /* reception rate */
8262306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS0_RECEIVE_RATE_S	15
8362306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS0_RECEIVE_SIGNAL	0x0ff00000 /* rssi */
8462306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS0_RECEIVE_SIGNAL_S	20
8562306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS0_RECEIVE_ANTENNA	0xf0000000 /* receive antenna */
8662306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS0_RECEIVE_ANTENNA_S	28
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci/* RX status word 1 fields/flags */
8962306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS1_DONE			0x00000001 /* descriptor complete */
9062306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS1_FRAME_RECEIVE_OK	0x00000002 /* frame reception success */
9162306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS1_CRC_ERROR		0x00000004 /* CRC error */
9262306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS1_DECRYPT_CRC_ERROR	0x00000008 /* decryption CRC failure */
9362306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS1_PHY_ERROR		0x00000010 /* PHY error */
9462306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS1_MIC_ERROR		0x00000020 /* MIC decrypt error */
9562306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS1_KEY_INDEX_VALID	0x00000100 /* key index valid */
9662306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS1_KEY_INDEX		0x0000fe00 /* decryption key index */
9762306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS1_KEY_INDEX_S		9
9862306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS1_RECEIVE_TIMESTAMP	0x7fff0000 /* first 15bit of the TSF */
9962306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS1_RECEIVE_TIMESTAMP_S	16
10062306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS1_KEY_CACHE_MISS	0x80000000 /* key cache miss */
10162306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS1_PHY_ERROR_CODE	0x0000ff00 /* phy error code overlays key index and valid fields */
10262306a36Sopenharmony_ci#define AR5K_5212_RX_DESC_STATUS1_PHY_ERROR_CODE_S	8
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci/**
10562306a36Sopenharmony_ci * enum ath5k_phy_error_code - PHY Error codes
10662306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_UNDERRUN: Transmit underrun, [5210] No error
10762306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_TIMING: Timing error
10862306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_PARITY: Illegal parity
10962306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_RATE: Illegal rate
11062306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_LENGTH: Illegal length
11162306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_RADAR: Radar detect, [5210] 64 QAM rate
11262306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_SERVICE: Illegal service
11362306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_TOR: Transmit override receive
11462306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_OFDM_TIMING: OFDM Timing error [5212+]
11562306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_OFDM_SIGNAL_PARITY: OFDM Signal parity error [5212+]
11662306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_OFDM_RATE_ILLEGAL: OFDM Illegal rate [5212+]
11762306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_OFDM_LENGTH_ILLEGAL: OFDM Illegal length [5212+]
11862306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_OFDM_POWER_DROP: OFDM Power drop [5212+]
11962306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_OFDM_SERVICE: OFDM Service (?) [5212+]
12062306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_OFDM_RESTART: OFDM Restart (?) [5212+]
12162306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_CCK_TIMING: CCK Timing error [5212+]
12262306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_CCK_HEADER_CRC: Header CRC error [5212+]
12362306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_CCK_RATE_ILLEGAL: Illegal rate [5212+]
12462306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_CCK_SERVICE: CCK Service (?) [5212+]
12562306a36Sopenharmony_ci * @AR5K_RX_PHY_ERROR_CCK_RESTART: CCK Restart (?) [5212+]
12662306a36Sopenharmony_ci */
12762306a36Sopenharmony_cienum ath5k_phy_error_code {
12862306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_UNDERRUN		= 0,
12962306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_TIMING		= 1,
13062306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_PARITY		= 2,
13162306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_RATE			= 3,
13262306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_LENGTH		= 4,
13362306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_RADAR			= 5,
13462306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_SERVICE		= 6,
13562306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_TOR			= 7,
13662306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_OFDM_TIMING		= 17,
13762306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_OFDM_SIGNAL_PARITY	= 18,
13862306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_OFDM_RATE_ILLEGAL	= 19,
13962306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_OFDM_LENGTH_ILLEGAL	= 20,
14062306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_OFDM_POWER_DROP	= 21,
14162306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_OFDM_SERVICE		= 22,
14262306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_OFDM_RESTART		= 23,
14362306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_CCK_TIMING		= 25,
14462306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_CCK_HEADER_CRC	= 26,
14562306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_CCK_RATE_ILLEGAL	= 27,
14662306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_CCK_SERVICE		= 30,
14762306a36Sopenharmony_ci	AR5K_RX_PHY_ERROR_CCK_RESTART		= 31,
14862306a36Sopenharmony_ci};
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci/**
15162306a36Sopenharmony_ci * struct ath5k_hw_2w_tx_ctl  - 5210/5211 hardware 2-word TX control descriptor
15262306a36Sopenharmony_ci * @tx_control_0: TX control word 0
15362306a36Sopenharmony_ci * @tx_control_1: TX control word 1
15462306a36Sopenharmony_ci */
15562306a36Sopenharmony_cistruct ath5k_hw_2w_tx_ctl {
15662306a36Sopenharmony_ci	u32	tx_control_0;
15762306a36Sopenharmony_ci	u32	tx_control_1;
15862306a36Sopenharmony_ci} __packed __aligned(4);
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ci/* TX control word 0 fields/flags */
16162306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_FRAME_LEN		0x00000fff /* frame length */
16262306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_HEADER_LEN_5210	0x0003f000 /* [5210] header length */
16362306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_HEADER_LEN_5210_S	12
16462306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_XMIT_RATE		0x003c0000 /* tx rate */
16562306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_XMIT_RATE_S	18
16662306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_RTSENA		0x00400000 /* RTS/CTS enable */
16762306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_LONG_PACKET_5210	0x00800000 /* [5210] long packet */
16862306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_VEOL_5211		0x00800000 /* [5211] virtual end-of-list */
16962306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_CLRDMASK		0x01000000 /* clear destination mask */
17062306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT_5210	0x02000000 /* [5210] antenna selection */
17162306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT_5211	0x1e000000 /* [5211] antenna selection */
17262306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT			\
17362306a36Sopenharmony_ci		(ah->ah_version == AR5K_AR5210 ?		\
17462306a36Sopenharmony_ci		AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT_5210 :	\
17562306a36Sopenharmony_ci		AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT_5211)
17662306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT_S	25
17762306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_FRAME_TYPE_5210	0x1c000000 /* [5210] frame type */
17862306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_FRAME_TYPE_5210_S	26
17962306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_INTREQ		0x20000000 /* TX interrupt request */
18062306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL0_ENCRYPT_KEY_VALID	0x40000000 /* key is valid */
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci/* TX control word 1 fields/flags */
18362306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL1_BUF_LEN		0x00000fff /* data buffer length */
18462306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL1_MORE		0x00001000 /* more desc for this frame */
18562306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL1_ENC_KEY_IDX_5210	0x0007e000 /* [5210] key table index */
18662306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL1_ENC_KEY_IDX_5211	0x000fe000 /* [5211] key table index */
18762306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL1_ENC_KEY_IDX				\
18862306a36Sopenharmony_ci			(ah->ah_version == AR5K_AR5210 ?		\
18962306a36Sopenharmony_ci			AR5K_2W_TX_DESC_CTL1_ENC_KEY_IDX_5210 :		\
19062306a36Sopenharmony_ci			AR5K_2W_TX_DESC_CTL1_ENC_KEY_IDX_5211)
19162306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL1_ENC_KEY_IDX_S	13
19262306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL1_FRAME_TYPE_5211	0x00700000 /* [5211] frame type */
19362306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL1_FRAME_TYPE_5211_S	20
19462306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL1_NOACK_5211		0x00800000 /* [5211] no ACK */
19562306a36Sopenharmony_ci#define AR5K_2W_TX_DESC_CTL1_RTS_DURATION_5210	0xfff80000 /* [5210] lower 13 bit of duration */
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_ci/* Frame types */
19862306a36Sopenharmony_ci#define AR5K_AR5210_TX_DESC_FRAME_TYPE_NORMAL	0
19962306a36Sopenharmony_ci#define AR5K_AR5210_TX_DESC_FRAME_TYPE_ATIM	1
20062306a36Sopenharmony_ci#define AR5K_AR5210_TX_DESC_FRAME_TYPE_PSPOLL	2
20162306a36Sopenharmony_ci#define AR5K_AR5210_TX_DESC_FRAME_TYPE_NO_DELAY	3
20262306a36Sopenharmony_ci#define AR5K_AR5211_TX_DESC_FRAME_TYPE_BEACON	3
20362306a36Sopenharmony_ci#define AR5K_AR5210_TX_DESC_FRAME_TYPE_PIFS	4
20462306a36Sopenharmony_ci#define AR5K_AR5211_TX_DESC_FRAME_TYPE_PRESP	4
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_ci/**
20762306a36Sopenharmony_ci * struct ath5k_hw_4w_tx_ctl - 5212 hardware 4-word TX control descriptor
20862306a36Sopenharmony_ci * @tx_control_0: TX control word 0
20962306a36Sopenharmony_ci * @tx_control_1: TX control word 1
21062306a36Sopenharmony_ci * @tx_control_2: TX control word 2
21162306a36Sopenharmony_ci * @tx_control_3: TX control word 3
21262306a36Sopenharmony_ci */
21362306a36Sopenharmony_cistruct ath5k_hw_4w_tx_ctl {
21462306a36Sopenharmony_ci	u32	tx_control_0;
21562306a36Sopenharmony_ci	u32	tx_control_1;
21662306a36Sopenharmony_ci	u32	tx_control_2;
21762306a36Sopenharmony_ci	u32	tx_control_3;
21862306a36Sopenharmony_ci} __packed __aligned(4);
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_ci/* TX control word 0 fields/flags */
22162306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL0_FRAME_LEN		0x00000fff /* frame length */
22262306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL0_XMIT_POWER		0x003f0000 /* transmit power */
22362306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL0_XMIT_POWER_S	16
22462306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL0_RTSENA		0x00400000 /* RTS/CTS enable */
22562306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL0_VEOL		0x00800000 /* virtual end-of-list */
22662306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL0_CLRDMASK		0x01000000 /* clear destination mask */
22762306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL0_ANT_MODE_XMIT	0x1e000000 /* TX antenna selection */
22862306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL0_ANT_MODE_XMIT_S	25
22962306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL0_INTREQ		0x20000000 /* TX interrupt request */
23062306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL0_ENCRYPT_KEY_VALID	0x40000000 /* destination index valid */
23162306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL0_CTSENA		0x80000000 /* precede frame with CTS */
23262306a36Sopenharmony_ci
23362306a36Sopenharmony_ci/* TX control word 1 fields/flags */
23462306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL1_BUF_LEN		0x00000fff /* data buffer length */
23562306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL1_MORE		0x00001000 /* more desc for this frame */
23662306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL1_ENCRYPT_KEY_IDX	0x000fe000 /* destination table index */
23762306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL1_ENCRYPT_KEY_IDX_S	13
23862306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL1_FRAME_TYPE		0x00f00000 /* frame type */
23962306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL1_FRAME_TYPE_S	20
24062306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL1_NOACK		0x01000000 /* no ACK */
24162306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL1_COMP_PROC		0x06000000 /* compression processing */
24262306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL1_COMP_PROC_S	25
24362306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL1_COMP_IV_LEN	0x18000000 /* length of frame IV */
24462306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL1_COMP_IV_LEN_S	27
24562306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL1_COMP_ICV_LEN	0x60000000 /* length of frame ICV */
24662306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL1_COMP_ICV_LEN_S	29
24762306a36Sopenharmony_ci
24862306a36Sopenharmony_ci/* TX control word 2 fields/flags */
24962306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL2_RTS_DURATION	0x00007fff /* RTS/CTS duration */
25062306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL2_DURATION_UPD_EN	0x00008000 /* frame duration update */
25162306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES0	0x000f0000 /* series 0 max attempts */
25262306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES0_S	16
25362306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES1	0x00f00000 /* series 1 max attempts */
25462306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES1_S	20
25562306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES2	0x0f000000 /* series 2 max attempts */
25662306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES2_S	24
25762306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES3	0xf0000000 /* series 3 max attempts */
25862306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES3_S	28
25962306a36Sopenharmony_ci
26062306a36Sopenharmony_ci/* TX control word 3 fields/flags */
26162306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL3_XMIT_RATE0		0x0000001f /* series 0 tx rate */
26262306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL3_XMIT_RATE1		0x000003e0 /* series 1 tx rate */
26362306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL3_XMIT_RATE1_S	5
26462306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL3_XMIT_RATE2		0x00007c00 /* series 2 tx rate */
26562306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL3_XMIT_RATE2_S	10
26662306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL3_XMIT_RATE3		0x000f8000 /* series 3 tx rate */
26762306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL3_XMIT_RATE3_S	15
26862306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL3_RTS_CTS_RATE	0x01f00000 /* RTS or CTS rate */
26962306a36Sopenharmony_ci#define AR5K_4W_TX_DESC_CTL3_RTS_CTS_RATE_S	20
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ci/**
27262306a36Sopenharmony_ci * struct ath5k_hw_tx_status - Common TX status descriptor
27362306a36Sopenharmony_ci * @tx_status_0: TX status word 0
27462306a36Sopenharmony_ci * @tx_status_1: TX status word 1
27562306a36Sopenharmony_ci */
27662306a36Sopenharmony_cistruct ath5k_hw_tx_status {
27762306a36Sopenharmony_ci	u32	tx_status_0;
27862306a36Sopenharmony_ci	u32	tx_status_1;
27962306a36Sopenharmony_ci} __packed __aligned(4);
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_ci/* TX status word 0 fields/flags */
28262306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS0_FRAME_XMIT_OK	0x00000001 /* TX success */
28362306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS0_EXCESSIVE_RETRIES	0x00000002 /* excessive retries */
28462306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS0_FIFO_UNDERRUN	0x00000004 /* FIFO underrun */
28562306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS0_FILTERED		0x00000008 /* TX filter indication */
28662306a36Sopenharmony_ci/* according to the HAL sources the spec has short/long retry counts reversed.
28762306a36Sopenharmony_ci * we have it reversed to the HAL sources as well, for 5210 and 5211.
28862306a36Sopenharmony_ci * For 5212 these fields are defined as RTS_FAIL_COUNT and DATA_FAIL_COUNT,
28962306a36Sopenharmony_ci * but used respectively as SHORT and LONG retry count in the code later. This
29062306a36Sopenharmony_ci * is consistent with the definitions here... TODO: check */
29162306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS0_SHORT_RETRY_COUNT	0x000000f0 /* short retry count */
29262306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS0_SHORT_RETRY_COUNT_S	4
29362306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS0_LONG_RETRY_COUNT	0x00000f00 /* long retry count */
29462306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS0_LONG_RETRY_COUNT_S	8
29562306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS0_VIRTCOLL_CT_5211	0x0000f000 /* [5211+] virtual collision count */
29662306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS0_VIRTCOLL_CT_5212_S	12
29762306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS0_SEND_TIMESTAMP	0xffff0000 /* TX timestamp */
29862306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS0_SEND_TIMESTAMP_S	16
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_ci/* TX status word 1 fields/flags */
30162306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS1_DONE		0x00000001 /* descriptor complete */
30262306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS1_SEQ_NUM		0x00001ffe /* TX sequence number */
30362306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS1_SEQ_NUM_S		1
30462306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH	0x001fe000 /* signal strength of ACK */
30562306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH_S	13
30662306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS1_FINAL_TS_IX_5212	0x00600000 /* [5212] final TX attempt series ix */
30762306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS1_FINAL_TS_IX_5212_S	21
30862306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS1_COMP_SUCCESS_5212	0x00800000 /* [5212] compression status */
30962306a36Sopenharmony_ci#define AR5K_DESC_TX_STATUS1_XMIT_ANTENNA_5212	0x01000000 /* [5212] transmit antenna */
31062306a36Sopenharmony_ci
31162306a36Sopenharmony_ci/**
31262306a36Sopenharmony_ci * struct ath5k_hw_5210_tx_desc - 5210/5211 hardware TX descriptor
31362306a36Sopenharmony_ci * @tx_ctl: The &struct ath5k_hw_2w_tx_ctl
31462306a36Sopenharmony_ci * @tx_stat: The &struct ath5k_hw_tx_status
31562306a36Sopenharmony_ci */
31662306a36Sopenharmony_cistruct ath5k_hw_5210_tx_desc {
31762306a36Sopenharmony_ci	struct ath5k_hw_2w_tx_ctl	tx_ctl;
31862306a36Sopenharmony_ci	struct ath5k_hw_tx_status	tx_stat;
31962306a36Sopenharmony_ci} __packed __aligned(4);
32062306a36Sopenharmony_ci
32162306a36Sopenharmony_ci/**
32262306a36Sopenharmony_ci * struct ath5k_hw_5212_tx_desc - 5212 hardware TX descriptor
32362306a36Sopenharmony_ci * @tx_ctl: The &struct ath5k_hw_4w_tx_ctl
32462306a36Sopenharmony_ci * @tx_stat: The &struct ath5k_hw_tx_status
32562306a36Sopenharmony_ci */
32662306a36Sopenharmony_cistruct ath5k_hw_5212_tx_desc {
32762306a36Sopenharmony_ci	struct ath5k_hw_4w_tx_ctl	tx_ctl;
32862306a36Sopenharmony_ci	struct ath5k_hw_tx_status	tx_stat;
32962306a36Sopenharmony_ci} __packed __aligned(4);
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_ci/**
33262306a36Sopenharmony_ci * struct ath5k_hw_all_rx_desc - Common hardware RX descriptor
33362306a36Sopenharmony_ci * @rx_ctl: The &struct ath5k_hw_rx_ctl
33462306a36Sopenharmony_ci * @rx_stat: The &struct ath5k_hw_rx_status
33562306a36Sopenharmony_ci */
33662306a36Sopenharmony_cistruct ath5k_hw_all_rx_desc {
33762306a36Sopenharmony_ci	struct ath5k_hw_rx_ctl		rx_ctl;
33862306a36Sopenharmony_ci	struct ath5k_hw_rx_status	rx_stat;
33962306a36Sopenharmony_ci} __packed __aligned(4);
34062306a36Sopenharmony_ci
34162306a36Sopenharmony_ci/**
34262306a36Sopenharmony_ci * struct ath5k_desc - Atheros hardware DMA descriptor
34362306a36Sopenharmony_ci * @ds_link: Physical address of the next descriptor
34462306a36Sopenharmony_ci * @ds_data: Physical address of data buffer (skb)
34562306a36Sopenharmony_ci * @ud: Union containing hw_5xxx_tx_desc structs and hw_all_rx_desc
34662306a36Sopenharmony_ci *
34762306a36Sopenharmony_ci * This is read and written to by the hardware
34862306a36Sopenharmony_ci */
34962306a36Sopenharmony_cistruct ath5k_desc {
35062306a36Sopenharmony_ci	u32	ds_link;
35162306a36Sopenharmony_ci	u32	ds_data;
35262306a36Sopenharmony_ci
35362306a36Sopenharmony_ci	union {
35462306a36Sopenharmony_ci		struct ath5k_hw_5210_tx_desc	ds_tx5210;
35562306a36Sopenharmony_ci		struct ath5k_hw_5212_tx_desc	ds_tx5212;
35662306a36Sopenharmony_ci		struct ath5k_hw_all_rx_desc	ds_rx;
35762306a36Sopenharmony_ci	} ud;
35862306a36Sopenharmony_ci} __packed __aligned(4);
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ci#define AR5K_RXDESC_INTREQ	0x0020
36162306a36Sopenharmony_ci
36262306a36Sopenharmony_ci#define AR5K_TXDESC_CLRDMASK	0x0001
36362306a36Sopenharmony_ci#define AR5K_TXDESC_NOACK	0x0002	/*[5211+]*/
36462306a36Sopenharmony_ci#define AR5K_TXDESC_RTSENA	0x0004
36562306a36Sopenharmony_ci#define AR5K_TXDESC_CTSENA	0x0008
36662306a36Sopenharmony_ci#define AR5K_TXDESC_INTREQ	0x0010
36762306a36Sopenharmony_ci#define AR5K_TXDESC_VEOL	0x0020	/*[5211+]*/
368