xref: /linux/drivers/net/wireless/ath/wil6210/txrx_edma.h (revision 10590c6a07b6a84cc3224cfda481317deaf31565)
1*10590c6aSGidon Studinski /*
2*10590c6aSGidon Studinski  * Copyright (c) 2012-2016,2018, The Linux Foundation. All rights reserved.
3*10590c6aSGidon Studinski  *
4*10590c6aSGidon Studinski  * Permission to use, copy, modify, and/or distribute this software for any
5*10590c6aSGidon Studinski  * purpose with or without fee is hereby granted, provided that the above
6*10590c6aSGidon Studinski  * copyright notice and this permission notice appear in all copies.
7*10590c6aSGidon Studinski  *
8*10590c6aSGidon Studinski  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9*10590c6aSGidon Studinski  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10*10590c6aSGidon Studinski  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11*10590c6aSGidon Studinski  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12*10590c6aSGidon Studinski  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13*10590c6aSGidon Studinski  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14*10590c6aSGidon Studinski  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*10590c6aSGidon Studinski  */
16*10590c6aSGidon Studinski 
17*10590c6aSGidon Studinski #ifndef WIL6210_TXRX_EDMA_H
18*10590c6aSGidon Studinski #define WIL6210_TXRX_EDMA_H
19*10590c6aSGidon Studinski 
20*10590c6aSGidon Studinski #include "wil6210.h"
21*10590c6aSGidon Studinski 
22*10590c6aSGidon Studinski /* Enhanced Rx descriptor - MAC part
23*10590c6aSGidon Studinski  * [dword 0] : Reserved
24*10590c6aSGidon Studinski  * [dword 1] : Reserved
25*10590c6aSGidon Studinski  * [dword 2] : Reserved
26*10590c6aSGidon Studinski  * [dword 3]
27*10590c6aSGidon Studinski  *	bit  0..15 : Buffer ID
28*10590c6aSGidon Studinski  *	bit 16..31 : Reserved
29*10590c6aSGidon Studinski  */
30*10590c6aSGidon Studinski struct wil_ring_rx_enhanced_mac {
31*10590c6aSGidon Studinski 	u32 d[3];
32*10590c6aSGidon Studinski 	__le16 buff_id;
33*10590c6aSGidon Studinski 	u16 reserved;
34*10590c6aSGidon Studinski } __packed;
35*10590c6aSGidon Studinski 
36*10590c6aSGidon Studinski /* Enhanced Rx descriptor - DMA part
37*10590c6aSGidon Studinski  * [dword 0] - Reserved
38*10590c6aSGidon Studinski  * [dword 1]
39*10590c6aSGidon Studinski  *	bit  0..31 : addr_low:32 The payload buffer address, bits 0-31
40*10590c6aSGidon Studinski  * [dword 2]
41*10590c6aSGidon Studinski  *	bit  0..15 : addr_high_low:16 The payload buffer address, bits 32-47
42*10590c6aSGidon Studinski  *	bit 16..31 : Reserved
43*10590c6aSGidon Studinski  * [dword 3]
44*10590c6aSGidon Studinski  *	bit  0..15 : addr_high_high:16 The payload buffer address, bits 48-63
45*10590c6aSGidon Studinski  *	bit 16..31 : length
46*10590c6aSGidon Studinski  */
47*10590c6aSGidon Studinski struct wil_ring_rx_enhanced_dma {
48*10590c6aSGidon Studinski 	u32 d0;
49*10590c6aSGidon Studinski 	struct wil_ring_dma_addr addr;
50*10590c6aSGidon Studinski 	u16 w5;
51*10590c6aSGidon Studinski 	__le16 addr_high_high;
52*10590c6aSGidon Studinski 	__le16 length;
53*10590c6aSGidon Studinski } __packed;
54*10590c6aSGidon Studinski 
55*10590c6aSGidon Studinski struct wil_rx_enhanced_desc {
56*10590c6aSGidon Studinski 	struct wil_ring_rx_enhanced_mac mac;
57*10590c6aSGidon Studinski 	struct wil_ring_rx_enhanced_dma dma;
58*10590c6aSGidon Studinski } __packed;
59*10590c6aSGidon Studinski 
60*10590c6aSGidon Studinski /* Enhanced Tx descriptor - DMA part
61*10590c6aSGidon Studinski  * [dword 0]
62*10590c6aSGidon Studinski  *	Same as legacy
63*10590c6aSGidon Studinski  * [dword 1]
64*10590c6aSGidon Studinski  * bit  0..31 : addr_low:32 The payload buffer address, bits 0-31
65*10590c6aSGidon Studinski  * [dword 2]
66*10590c6aSGidon Studinski  * bit  0..15 : addr_high_low:16 The payload buffer address, bits 32-47
67*10590c6aSGidon Studinski  * bit 16..23 : ip_length:8 The IP header length for the TX IP checksum
68*10590c6aSGidon Studinski  *		offload feature
69*10590c6aSGidon Studinski  * bit 24..30 : mac_length:7
70*10590c6aSGidon Studinski  * bit     31 : ip_version:1 1 - IPv4, 0 - IPv6
71*10590c6aSGidon Studinski  * [dword 3]
72*10590c6aSGidon Studinski  * bit  0..15 : addr_high_high:16 The payload buffer address, bits 48-63
73*10590c6aSGidon Studinski  * bit 16..31 : length
74*10590c6aSGidon Studinski  */
75*10590c6aSGidon Studinski struct wil_ring_tx_enhanced_dma {
76*10590c6aSGidon Studinski 	u8 l4_hdr_len;
77*10590c6aSGidon Studinski 	u8 cmd;
78*10590c6aSGidon Studinski 	u16 w1;
79*10590c6aSGidon Studinski 	struct wil_ring_dma_addr addr;
80*10590c6aSGidon Studinski 	u8  ip_length;
81*10590c6aSGidon Studinski 	u8  b11;       /* 0..6: mac_length; 7:ip_version */
82*10590c6aSGidon Studinski 	__le16 addr_high_high;
83*10590c6aSGidon Studinski 	__le16 length;
84*10590c6aSGidon Studinski } __packed;
85*10590c6aSGidon Studinski 
86*10590c6aSGidon Studinski /* Enhanced Tx descriptor - MAC part
87*10590c6aSGidon Studinski  * [dword 0]
88*10590c6aSGidon Studinski  * bit  0.. 9 : lifetime_expiry_value:10
89*10590c6aSGidon Studinski  * bit     10 : interrupt_en:1
90*10590c6aSGidon Studinski  * bit     11 : status_en:1
91*10590c6aSGidon Studinski  * bit 12..13 : txss_override:2
92*10590c6aSGidon Studinski  * bit     14 : timestamp_insertion:1
93*10590c6aSGidon Studinski  * bit     15 : duration_preserve:1
94*10590c6aSGidon Studinski  * bit 16..21 : reserved0:6
95*10590c6aSGidon Studinski  * bit 22..26 : mcs_index:5
96*10590c6aSGidon Studinski  * bit     27 : mcs_en:1
97*10590c6aSGidon Studinski  * bit 28..30 : reserved1:3
98*10590c6aSGidon Studinski  * bit     31 : sn_preserved:1
99*10590c6aSGidon Studinski  * [dword 1]
100*10590c6aSGidon Studinski  * bit  0.. 3 : pkt_mode:4
101*10590c6aSGidon Studinski  * bit      4 : pkt_mode_en:1
102*10590c6aSGidon Studinski  * bit  5..14 : reserved0:10
103*10590c6aSGidon Studinski  * bit     15 : ack_policy_en:1
104*10590c6aSGidon Studinski  * bit 16..19 : dst_index:4
105*10590c6aSGidon Studinski  * bit     20 : dst_index_en:1
106*10590c6aSGidon Studinski  * bit 21..22 : ack_policy:2
107*10590c6aSGidon Studinski  * bit     23 : lifetime_en:1
108*10590c6aSGidon Studinski  * bit 24..30 : max_retry:7
109*10590c6aSGidon Studinski  * bit     31 : max_retry_en:1
110*10590c6aSGidon Studinski  * [dword 2]
111*10590c6aSGidon Studinski  * bit  0.. 7 : num_of_descriptors:8
112*10590c6aSGidon Studinski  * bit  8..17 : reserved:10
113*10590c6aSGidon Studinski  * bit 18..19 : l2_translation_type:2 00 - bypass, 01 - 802.3, 10 - 802.11
114*10590c6aSGidon Studinski  * bit     20 : snap_hdr_insertion_en:1
115*10590c6aSGidon Studinski  * bit     21 : vlan_removal_en:1
116*10590c6aSGidon Studinski  * bit 22..23 : reserved0:2
117*10590c6aSGidon Studinski  * bit	   24 : Dest ID extension:1
118*10590c6aSGidon Studinski  * bit 25..31 : reserved0:7
119*10590c6aSGidon Studinski  * [dword 3]
120*10590c6aSGidon Studinski  * bit  0..15 : tso_mss:16
121*10590c6aSGidon Studinski  * bit 16..31 : descriptor_scratchpad:16 - mailbox between driver and ucode
122*10590c6aSGidon Studinski  */
123*10590c6aSGidon Studinski struct wil_ring_tx_enhanced_mac {
124*10590c6aSGidon Studinski 	u32 d[3];
125*10590c6aSGidon Studinski 	__le16 tso_mss;
126*10590c6aSGidon Studinski 	u16 scratchpad;
127*10590c6aSGidon Studinski } __packed;
128*10590c6aSGidon Studinski 
129*10590c6aSGidon Studinski struct wil_tx_enhanced_desc {
130*10590c6aSGidon Studinski 	struct wil_ring_tx_enhanced_mac mac;
131*10590c6aSGidon Studinski 	struct wil_ring_tx_enhanced_dma dma;
132*10590c6aSGidon Studinski } __packed;
133*10590c6aSGidon Studinski 
134*10590c6aSGidon Studinski #define TX_STATUS_DESC_READY_POS 7
135*10590c6aSGidon Studinski 
136*10590c6aSGidon Studinski /* Enhanced TX status message
137*10590c6aSGidon Studinski  * [dword 0]
138*10590c6aSGidon Studinski  *	bit  0.. 7 : Number of Descriptor:8 - The number of descriptors that
139*10590c6aSGidon Studinski  *		     are used to form the packets. It  is needed for WB when
140*10590c6aSGidon Studinski  *		     releasing the packet
141*10590c6aSGidon Studinski  *	bit  8..15 : tx_ring_id:8 The transmission ring ID that is related to
142*10590c6aSGidon Studinski  *		     the message
143*10590c6aSGidon Studinski  *	bit 16..23 : Status:8 - The TX status Code
144*10590c6aSGidon Studinski  *		0x0 - A successful transmission
145*10590c6aSGidon Studinski  *		0x1 - Retry expired
146*10590c6aSGidon Studinski  *		0x2 - Lifetime Expired
147*10590c6aSGidon Studinski  *		0x3 - Released
148*10590c6aSGidon Studinski  *		0x4-0xFF - Reserved
149*10590c6aSGidon Studinski  *	bit 24..30 : Reserved:7
150*10590c6aSGidon Studinski  *	bit     31 : Descriptor Ready bit:1 - It is initiated to
151*10590c6aSGidon Studinski  *		zero by the driver when the ring is created. It is set by the HW
152*10590c6aSGidon Studinski  *		to one for each completed status message. Each wrap around,
153*10590c6aSGidon Studinski  *		the DR bit value is flipped.
154*10590c6aSGidon Studinski  * [dword 1]
155*10590c6aSGidon Studinski  *	bit 0..31  : timestamp:32 - Set when MPDU is transmitted.
156*10590c6aSGidon Studinski  * [dword 2]
157*10590c6aSGidon Studinski  *	bit  0.. 4 : MCS:5 - The transmitted MCS value
158*10590c6aSGidon Studinski  *	bit      5 : Reserved:1
159*10590c6aSGidon Studinski  *	bit  6.. 7 : CB mode:2 - 0-DMG 1-EDMG 2-Wide
160*10590c6aSGidon Studinski  *	bit  8..12 : QID:5 - The QID that was used for the transmission
161*10590c6aSGidon Studinski  *	bit 13..15 : Reserved:3
162*10590c6aSGidon Studinski  *	bit 16..20 : Num of MSDUs:5 - Number of MSDUs in the aggregation
163*10590c6aSGidon Studinski  *	bit 21..22 : Reserved:2
164*10590c6aSGidon Studinski  *	bit     23 : Retry:1 - An indication that the transmission was retried
165*10590c6aSGidon Studinski  *	bit 24..31 : TX-Sector:8 - the antenna sector that was used for
166*10590c6aSGidon Studinski  *		     transmission
167*10590c6aSGidon Studinski  * [dword 3]
168*10590c6aSGidon Studinski  *	bit  0..11 : Sequence number:12 - The Sequence Number that was used
169*10590c6aSGidon Studinski  *		     for the MPDU transmission
170*10590c6aSGidon Studinski  *	bit 12..31 : Reserved:20
171*10590c6aSGidon Studinski  */
172*10590c6aSGidon Studinski struct wil_ring_tx_status {
173*10590c6aSGidon Studinski 	u8 num_descriptors;
174*10590c6aSGidon Studinski 	u8 ring_id;
175*10590c6aSGidon Studinski 	u8 status;
176*10590c6aSGidon Studinski 	u8 desc_ready; /* Only the last bit should be set */
177*10590c6aSGidon Studinski 	u32 timestamp;
178*10590c6aSGidon Studinski 	u32 d2;
179*10590c6aSGidon Studinski 	u16 seq_number; /* Only the first 12 bits */
180*10590c6aSGidon Studinski 	u16 w7;
181*10590c6aSGidon Studinski } __packed;
182*10590c6aSGidon Studinski 
183*10590c6aSGidon Studinski /* Enhanced Rx status message - compressed part
184*10590c6aSGidon Studinski  * [dword 0]
185*10590c6aSGidon Studinski  *	bit  0.. 2 : L2 Rx Status:3 - The L2 packet reception Status
186*10590c6aSGidon Studinski  *		     0-Success, 1-MIC Error, 2-Key Error, 3-Replay Error,
187*10590c6aSGidon Studinski  *		     4-A-MSDU Error, 5-Reserved, 6-Reserved, 7-FCS Error
188*10590c6aSGidon Studinski  *	bit  3.. 4 : L3 Rx Status:2 - Bit0 - L3I - L3 identified and checksum
189*10590c6aSGidon Studinski  *		     calculated, Bit1- L3Err - IPv4 Checksum Error
190*10590c6aSGidon Studinski  *	bit  5.. 6 : L4 Rx Status:2 - Bit0 - L4I - L4 identified and checksum
191*10590c6aSGidon Studinski  *		     calculated, Bit1- L4Err - TCP/UDP Checksum Error
192*10590c6aSGidon Studinski  *	bit      7 : Reserved:1
193*10590c6aSGidon Studinski  *	bit  8..19 : Flow ID:12 - MSDU flow ID
194*10590c6aSGidon Studinski  *	bit 20..21 : MID:2 - The MAC ID
195*10590c6aSGidon Studinski  *	bit     22 : MID_V:1 - The MAC ID field is valid
196*10590c6aSGidon Studinski  *	bit     23 : L3T:1 - IP types: 0-IPv6, 1-IPv4
197*10590c6aSGidon Studinski  *	bit     24 : L4T:1 - Layer 4 Type: 0-UDP, 1-TCP
198*10590c6aSGidon Studinski  *	bit     25 : BC:1 - The received MPDU is broadcast
199*10590c6aSGidon Studinski  *	bit     26 : MC:1 - The received MPDU is multicast
200*10590c6aSGidon Studinski  *	bit     27 : Raw:1 - The MPDU received with no translation
201*10590c6aSGidon Studinski  *	bit     28 : Sec:1 - The FC control (b14) - Frame Protected
202*10590c6aSGidon Studinski  *	bit     29 : Error:1 - An error is set when (L2 status != 0) ||
203*10590c6aSGidon Studinski  *		(L3 status == 3) || (L4 status == 3)
204*10590c6aSGidon Studinski  *	bit     30 : EOP:1 - End of MSDU signaling. It is set to mark the end
205*10590c6aSGidon Studinski  *		     of the transfer, otherwise the status indicates buffer
206*10590c6aSGidon Studinski  *		     only completion.
207*10590c6aSGidon Studinski  *	bit     31 : Descriptor Ready bit:1 - It is initiated to
208*10590c6aSGidon Studinski  *		     zero by the driver when the ring is created. It is set
209*10590c6aSGidon Studinski  *		     by the HW to one for each completed status message.
210*10590c6aSGidon Studinski  *		     Each wrap around, the DR bit value is flipped.
211*10590c6aSGidon Studinski  * [dword 1]
212*10590c6aSGidon Studinski  *	bit  0.. 5 : MAC Len:6 - The number of bytes that are used for L2 header
213*10590c6aSGidon Studinski  *	bit  6..11 : IPLEN:6 - The number of DW that are used for L3 header
214*10590c6aSGidon Studinski  *	bit 12..15 : I4Len:4 - The number of DW that are used for L4 header
215*10590c6aSGidon Studinski  *	bit 16..21 : MCS:6 - The received MCS field from the PLCP Header
216*10590c6aSGidon Studinski  *	bit 22..23 : CB mode:2 - The CB Mode: 0-DMG, 1-EDMG, 2-Wide
217*10590c6aSGidon Studinski  *	bit 24..27 : Data Offset:4 - The data offset, a code that describe the
218*10590c6aSGidon Studinski  *		     payload shift from the beginning of the buffer:
219*10590c6aSGidon Studinski  *		     0 - 0 Bytes, 1 - 2 Bytes, 2 - 6 Bytes
220*10590c6aSGidon Studinski  *	bit     28 : A-MSDU Present:1 - The QoS (b7) A-MSDU present field
221*10590c6aSGidon Studinski  *	bit     29 : A-MSDU Type:1 The QoS (b8) A-MSDU Type field
222*10590c6aSGidon Studinski  *	bit     30 : A-MPDU:1 - Packet is part of aggregated MPDU
223*10590c6aSGidon Studinski  *	bit     31 : Key ID:1 - The extracted Key ID from the encryption header
224*10590c6aSGidon Studinski  * [dword 2]
225*10590c6aSGidon Studinski  *	bit  0..15 : Buffer ID:16 - The Buffer Identifier
226*10590c6aSGidon Studinski  *	bit 16..31 : Length:16 - It indicates the valid bytes that are stored
227*10590c6aSGidon Studinski  *		     in the current descriptor buffer. For multiple buffer
228*10590c6aSGidon Studinski  *		     descriptor, SW need to sum the total descriptor length
229*10590c6aSGidon Studinski  *		     in all buffers to produce the packet length
230*10590c6aSGidon Studinski  * [dword 3]
231*10590c6aSGidon Studinski  *	bit  0..31  : timestamp:32 - The MPDU Timestamp.
232*10590c6aSGidon Studinski  */
233*10590c6aSGidon Studinski struct wil_rx_status_compressed {
234*10590c6aSGidon Studinski 	u32 d0;
235*10590c6aSGidon Studinski 	u32 d1;
236*10590c6aSGidon Studinski 	__le16 buff_id;
237*10590c6aSGidon Studinski 	__le16 length;
238*10590c6aSGidon Studinski 	u32 timestamp;
239*10590c6aSGidon Studinski } __packed;
240*10590c6aSGidon Studinski 
241*10590c6aSGidon Studinski /* Enhanced Rx status message - extension part
242*10590c6aSGidon Studinski  * [dword 0]
243*10590c6aSGidon Studinski  *	bit  0.. 4 : QID:5 - The Queue Identifier that the packet is received
244*10590c6aSGidon Studinski  *		     from
245*10590c6aSGidon Studinski  *	bit  5.. 7 : Reserved:3
246*10590c6aSGidon Studinski  *	bit  8..11 : TID:4 - The QoS (b3-0) TID Field
247*10590c6aSGidon Studinski  *	bit 12..15   Source index:4 - The Source index that was found
248*10590c6aSGidon Studinski 		     during Parsing the TA. This field is used to define the
249*10590c6aSGidon Studinski 		     source of the packet
250*10590c6aSGidon Studinski  *	bit 16..18 : Destination index:3 - The Destination index that
251*10590c6aSGidon Studinski 		     was found during Parsing the RA.
252*10590c6aSGidon Studinski  *	bit 19..20 : DS Type:2 - The FC Control (b9-8) - From / To DS
253*10590c6aSGidon Studinski  *	bit 21..22 : MIC ICR:2 - this signal tells the DMA to assert an
254*10590c6aSGidon Studinski 		     interrupt after it writes the packet
255*10590c6aSGidon Studinski  *	bit     23 : ESOP:1 - The QoS (b4) ESOP field
256*10590c6aSGidon Studinski  *	bit     24 : RDG:1
257*10590c6aSGidon Studinski  *	bit 25..31 : Reserved:7
258*10590c6aSGidon Studinski  * [dword 1]
259*10590c6aSGidon Studinski  *	bit  0.. 1 : Frame Type:2 - The FC Control (b3-2) - MPDU Type
260*10590c6aSGidon Studinski 		     (management, data, control and extension)
261*10590c6aSGidon Studinski  *	bit  2.. 5 : Syb type:4 - The FC Control (b7-4) - Frame Subtype
262*10590c6aSGidon Studinski  *	bit  6..11 : Ext sub type:6 - The FC Control (b11-8) - Frame Extended
263*10590c6aSGidon Studinski  *                   Subtype
264*10590c6aSGidon Studinski  *	bit 12..13 : ACK Policy:2 - The QoS (b6-5) ACK Policy fields
265*10590c6aSGidon Studinski  *	bit 14     : DECRYPT_BYP:1 - The MPDU is bypass by the decryption unit
266*10590c6aSGidon Studinski  *	bit 15..23 : Reserved:9
267*10590c6aSGidon Studinski  *	bit 24..31 : RSSI/SNR:8 - The RSSI / SNR measurement for the received
268*10590c6aSGidon Studinski  *                   MPDU
269*10590c6aSGidon Studinski  * [dword 2]
270*10590c6aSGidon Studinski  *	bit  0..11 : SN:12 - The received Sequence number field
271*10590c6aSGidon Studinski  *	bit 12..15 : Reserved:4
272*10590c6aSGidon Studinski  *	bit 16..31 : PN bits [15:0]:16
273*10590c6aSGidon Studinski  * [dword 3]
274*10590c6aSGidon Studinski  *	bit  0..31 : PN bits [47:16]:32
275*10590c6aSGidon Studinski  */
276*10590c6aSGidon Studinski struct wil_rx_status_extension {
277*10590c6aSGidon Studinski 	u32 d0;
278*10590c6aSGidon Studinski 	u32 d1;
279*10590c6aSGidon Studinski 	__le16 seq_num; /* only lower 12 bits */
280*10590c6aSGidon Studinski 	u16 pn_15_0;
281*10590c6aSGidon Studinski 	u32 pn_47_16;
282*10590c6aSGidon Studinski } __packed;
283*10590c6aSGidon Studinski 
284*10590c6aSGidon Studinski struct wil_rx_status_extended {
285*10590c6aSGidon Studinski 	struct wil_rx_status_compressed comp;
286*10590c6aSGidon Studinski 	struct wil_rx_status_extension ext;
287*10590c6aSGidon Studinski };
288*10590c6aSGidon Studinski 
289*10590c6aSGidon Studinski #endif /* WIL6210_TXRX_EDMA_H */
290*10590c6aSGidon Studinski 
291