1*4882a593Smuzhiyun /* SPDX-License-Identifier: ISC */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * Copyright (c) 2012-2016,2018-2019, The Linux Foundation. All rights reserved.
4*4882a593Smuzhiyun */
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun #ifndef WIL6210_TXRX_EDMA_H
7*4882a593Smuzhiyun #define WIL6210_TXRX_EDMA_H
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun #include "wil6210.h"
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun /* limit status ring size in range [ring size..max ring size] */
12*4882a593Smuzhiyun #define WIL_SRING_SIZE_ORDER_MIN (WIL_RING_SIZE_ORDER_MIN)
13*4882a593Smuzhiyun #define WIL_SRING_SIZE_ORDER_MAX (WIL_RING_SIZE_ORDER_MAX)
14*4882a593Smuzhiyun /* RX sring order should be bigger than RX ring order */
15*4882a593Smuzhiyun #define WIL_RX_SRING_SIZE_ORDER_DEFAULT (12)
16*4882a593Smuzhiyun #define WIL_TX_SRING_SIZE_ORDER_DEFAULT (14)
17*4882a593Smuzhiyun #define WIL_RX_BUFF_ARR_SIZE_DEFAULT (2600)
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun #define WIL_DEFAULT_RX_STATUS_RING_ID 0
20*4882a593Smuzhiyun #define WIL_RX_DESC_RING_ID 0
21*4882a593Smuzhiyun #define WIL_RX_STATUS_IRQ_IDX 0
22*4882a593Smuzhiyun #define WIL_TX_STATUS_IRQ_IDX 1
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun #define WIL_EDMA_AGG_WATERMARK (0xffff)
25*4882a593Smuzhiyun #define WIL_EDMA_AGG_WATERMARK_POS (16)
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun #define WIL_EDMA_IDLE_TIME_LIMIT_USEC (50)
28*4882a593Smuzhiyun #define WIL_EDMA_TIME_UNIT_CLK_CYCLES (330) /* fits 1 usec */
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun /* Error field */
31*4882a593Smuzhiyun #define WIL_RX_EDMA_ERROR_MIC (1)
32*4882a593Smuzhiyun #define WIL_RX_EDMA_ERROR_KEY (2) /* Key missing */
33*4882a593Smuzhiyun #define WIL_RX_EDMA_ERROR_REPLAY (3)
34*4882a593Smuzhiyun #define WIL_RX_EDMA_ERROR_AMSDU (4)
35*4882a593Smuzhiyun #define WIL_RX_EDMA_ERROR_FCS (7)
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun #define WIL_RX_EDMA_ERROR_L3_ERR (BIT(0) | BIT(1))
38*4882a593Smuzhiyun #define WIL_RX_EDMA_ERROR_L4_ERR (BIT(0) | BIT(1))
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun #define WIL_RX_EDMA_DLPF_LU_MISS_BIT BIT(11)
41*4882a593Smuzhiyun #define WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK 0x7
42*4882a593Smuzhiyun #define WIL_RX_EDMA_DLPF_LU_HIT_CID_TID_MASK 0xf
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun #define WIL_RX_EDMA_DLPF_LU_MISS_CID_POS 2
45*4882a593Smuzhiyun #define WIL_RX_EDMA_DLPF_LU_HIT_CID_POS 4
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun #define WIL_RX_EDMA_DLPF_LU_MISS_TID_POS 5
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun #define WIL_RX_EDMA_MID_VALID_BIT BIT(20)
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_MAC_CFG_0_QID_POS 16
52*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_MAC_CFG_0_QID_LEN 6
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_CFG_EOP_POS 0
55*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_CFG_EOP_LEN 1
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_CFG_TSO_DESC_TYPE_POS 3
58*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_CFG_TSO_DESC_TYPE_LEN 2
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_CFG_SEG_EN_POS 5
61*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_CFG_SEG_EN_LEN 1
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_CFG_INSERT_IP_CHKSUM_POS 6
64*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_CFG_INSERT_IP_CHKSUM_LEN 1
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_CFG_INSERT_TCP_CHKSUM_POS 7
67*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_CFG_INSERT_TCP_CHKSUM_LEN 1
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_CFG_L4_TYPE_POS 15
70*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_CFG_L4_TYPE_LEN 1
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_CFG_PSEUDO_HEADER_CALC_EN_POS 5
73*4882a593Smuzhiyun #define WIL_EDMA_DESC_TX_CFG_PSEUDO_HEADER_CALC_EN_LEN 1
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun /* Enhanced Rx descriptor - MAC part
76*4882a593Smuzhiyun * [dword 0] : Reserved
77*4882a593Smuzhiyun * [dword 1] : Reserved
78*4882a593Smuzhiyun * [dword 2] : Reserved
79*4882a593Smuzhiyun * [dword 3]
80*4882a593Smuzhiyun * bit 0..15 : Buffer ID
81*4882a593Smuzhiyun * bit 16..31 : Reserved
82*4882a593Smuzhiyun */
83*4882a593Smuzhiyun struct wil_ring_rx_enhanced_mac {
84*4882a593Smuzhiyun u32 d[3];
85*4882a593Smuzhiyun __le16 buff_id;
86*4882a593Smuzhiyun u16 reserved;
87*4882a593Smuzhiyun } __packed;
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun /* Enhanced Rx descriptor - DMA part
90*4882a593Smuzhiyun * [dword 0] - Reserved
91*4882a593Smuzhiyun * [dword 1]
92*4882a593Smuzhiyun * bit 0..31 : addr_low:32 The payload buffer address, bits 0-31
93*4882a593Smuzhiyun * [dword 2]
94*4882a593Smuzhiyun * bit 0..15 : addr_high_low:16 The payload buffer address, bits 32-47
95*4882a593Smuzhiyun * bit 16..31 : Reserved
96*4882a593Smuzhiyun * [dword 3]
97*4882a593Smuzhiyun * bit 0..15 : addr_high_high:16 The payload buffer address, bits 48-63
98*4882a593Smuzhiyun * bit 16..31 : length
99*4882a593Smuzhiyun */
100*4882a593Smuzhiyun struct wil_ring_rx_enhanced_dma {
101*4882a593Smuzhiyun u32 d0;
102*4882a593Smuzhiyun struct wil_ring_dma_addr addr;
103*4882a593Smuzhiyun u16 w5;
104*4882a593Smuzhiyun __le16 addr_high_high;
105*4882a593Smuzhiyun __le16 length;
106*4882a593Smuzhiyun } __packed;
107*4882a593Smuzhiyun
108*4882a593Smuzhiyun struct wil_rx_enhanced_desc {
109*4882a593Smuzhiyun struct wil_ring_rx_enhanced_mac mac;
110*4882a593Smuzhiyun struct wil_ring_rx_enhanced_dma dma;
111*4882a593Smuzhiyun } __packed;
112*4882a593Smuzhiyun
113*4882a593Smuzhiyun /* Enhanced Tx descriptor - DMA part
114*4882a593Smuzhiyun * [dword 0]
115*4882a593Smuzhiyun * Same as legacy
116*4882a593Smuzhiyun * [dword 1]
117*4882a593Smuzhiyun * bit 0..31 : addr_low:32 The payload buffer address, bits 0-31
118*4882a593Smuzhiyun * [dword 2]
119*4882a593Smuzhiyun * bit 0..15 : addr_high_low:16 The payload buffer address, bits 32-47
120*4882a593Smuzhiyun * bit 16..23 : ip_length:8 The IP header length for the TX IP checksum
121*4882a593Smuzhiyun * offload feature
122*4882a593Smuzhiyun * bit 24..30 : mac_length:7
123*4882a593Smuzhiyun * bit 31 : ip_version:1 1 - IPv4, 0 - IPv6
124*4882a593Smuzhiyun * [dword 3]
125*4882a593Smuzhiyun * bit 0..15 : addr_high_high:16 The payload buffer address, bits 48-63
126*4882a593Smuzhiyun * bit 16..31 : length
127*4882a593Smuzhiyun */
128*4882a593Smuzhiyun struct wil_ring_tx_enhanced_dma {
129*4882a593Smuzhiyun u8 l4_hdr_len;
130*4882a593Smuzhiyun u8 cmd;
131*4882a593Smuzhiyun u16 w1;
132*4882a593Smuzhiyun struct wil_ring_dma_addr addr;
133*4882a593Smuzhiyun u8 ip_length;
134*4882a593Smuzhiyun u8 b11; /* 0..6: mac_length; 7:ip_version */
135*4882a593Smuzhiyun __le16 addr_high_high;
136*4882a593Smuzhiyun __le16 length;
137*4882a593Smuzhiyun } __packed;
138*4882a593Smuzhiyun
139*4882a593Smuzhiyun /* Enhanced Tx descriptor - MAC part
140*4882a593Smuzhiyun * [dword 0]
141*4882a593Smuzhiyun * bit 0.. 9 : lifetime_expiry_value:10
142*4882a593Smuzhiyun * bit 10 : interrupt_en:1
143*4882a593Smuzhiyun * bit 11 : status_en:1
144*4882a593Smuzhiyun * bit 12..13 : txss_override:2
145*4882a593Smuzhiyun * bit 14 : timestamp_insertion:1
146*4882a593Smuzhiyun * bit 15 : duration_preserve:1
147*4882a593Smuzhiyun * bit 16..21 : reserved0:6
148*4882a593Smuzhiyun * bit 22..26 : mcs_index:5
149*4882a593Smuzhiyun * bit 27 : mcs_en:1
150*4882a593Smuzhiyun * bit 28..30 : reserved1:3
151*4882a593Smuzhiyun * bit 31 : sn_preserved:1
152*4882a593Smuzhiyun * [dword 1]
153*4882a593Smuzhiyun * bit 0.. 3 : pkt_mode:4
154*4882a593Smuzhiyun * bit 4 : pkt_mode_en:1
155*4882a593Smuzhiyun * bit 5..14 : reserved0:10
156*4882a593Smuzhiyun * bit 15 : ack_policy_en:1
157*4882a593Smuzhiyun * bit 16..19 : dst_index:4
158*4882a593Smuzhiyun * bit 20 : dst_index_en:1
159*4882a593Smuzhiyun * bit 21..22 : ack_policy:2
160*4882a593Smuzhiyun * bit 23 : lifetime_en:1
161*4882a593Smuzhiyun * bit 24..30 : max_retry:7
162*4882a593Smuzhiyun * bit 31 : max_retry_en:1
163*4882a593Smuzhiyun * [dword 2]
164*4882a593Smuzhiyun * bit 0.. 7 : num_of_descriptors:8
165*4882a593Smuzhiyun * bit 8..17 : reserved:10
166*4882a593Smuzhiyun * bit 18..19 : l2_translation_type:2 00 - bypass, 01 - 802.3, 10 - 802.11
167*4882a593Smuzhiyun * bit 20 : snap_hdr_insertion_en:1
168*4882a593Smuzhiyun * bit 21 : vlan_removal_en:1
169*4882a593Smuzhiyun * bit 22..23 : reserved0:2
170*4882a593Smuzhiyun * bit 24 : Dest ID extension:1
171*4882a593Smuzhiyun * bit 25..31 : reserved0:7
172*4882a593Smuzhiyun * [dword 3]
173*4882a593Smuzhiyun * bit 0..15 : tso_mss:16
174*4882a593Smuzhiyun * bit 16..31 : descriptor_scratchpad:16 - mailbox between driver and ucode
175*4882a593Smuzhiyun */
176*4882a593Smuzhiyun struct wil_ring_tx_enhanced_mac {
177*4882a593Smuzhiyun u32 d[3];
178*4882a593Smuzhiyun __le16 tso_mss;
179*4882a593Smuzhiyun u16 scratchpad;
180*4882a593Smuzhiyun } __packed;
181*4882a593Smuzhiyun
182*4882a593Smuzhiyun struct wil_tx_enhanced_desc {
183*4882a593Smuzhiyun struct wil_ring_tx_enhanced_mac mac;
184*4882a593Smuzhiyun struct wil_ring_tx_enhanced_dma dma;
185*4882a593Smuzhiyun } __packed;
186*4882a593Smuzhiyun
187*4882a593Smuzhiyun #define TX_STATUS_DESC_READY_POS 7
188*4882a593Smuzhiyun
189*4882a593Smuzhiyun /* Enhanced TX status message
190*4882a593Smuzhiyun * [dword 0]
191*4882a593Smuzhiyun * bit 0.. 7 : Number of Descriptor:8 - The number of descriptors that
192*4882a593Smuzhiyun * are used to form the packets. It is needed for WB when
193*4882a593Smuzhiyun * releasing the packet
194*4882a593Smuzhiyun * bit 8..15 : tx_ring_id:8 The transmission ring ID that is related to
195*4882a593Smuzhiyun * the message
196*4882a593Smuzhiyun * bit 16..23 : Status:8 - The TX status Code
197*4882a593Smuzhiyun * 0x0 - A successful transmission
198*4882a593Smuzhiyun * 0x1 - Retry expired
199*4882a593Smuzhiyun * 0x2 - Lifetime Expired
200*4882a593Smuzhiyun * 0x3 - Released
201*4882a593Smuzhiyun * 0x4-0xFF - Reserved
202*4882a593Smuzhiyun * bit 24..30 : Reserved:7
203*4882a593Smuzhiyun * bit 31 : Descriptor Ready bit:1 - It is initiated to
204*4882a593Smuzhiyun * zero by the driver when the ring is created. It is set by the HW
205*4882a593Smuzhiyun * to one for each completed status message. Each wrap around,
206*4882a593Smuzhiyun * the DR bit value is flipped.
207*4882a593Smuzhiyun * [dword 1]
208*4882a593Smuzhiyun * bit 0..31 : timestamp:32 - Set when MPDU is transmitted.
209*4882a593Smuzhiyun * [dword 2]
210*4882a593Smuzhiyun * bit 0.. 4 : MCS:5 - The transmitted MCS value
211*4882a593Smuzhiyun * bit 5 : Reserved:1
212*4882a593Smuzhiyun * bit 6.. 7 : CB mode:2 - 0-DMG 1-EDMG 2-Wide
213*4882a593Smuzhiyun * bit 8..12 : QID:5 - The QID that was used for the transmission
214*4882a593Smuzhiyun * bit 13..15 : Reserved:3
215*4882a593Smuzhiyun * bit 16..20 : Num of MSDUs:5 - Number of MSDUs in the aggregation
216*4882a593Smuzhiyun * bit 21..22 : Reserved:2
217*4882a593Smuzhiyun * bit 23 : Retry:1 - An indication that the transmission was retried
218*4882a593Smuzhiyun * bit 24..31 : TX-Sector:8 - the antenna sector that was used for
219*4882a593Smuzhiyun * transmission
220*4882a593Smuzhiyun * [dword 3]
221*4882a593Smuzhiyun * bit 0..11 : Sequence number:12 - The Sequence Number that was used
222*4882a593Smuzhiyun * for the MPDU transmission
223*4882a593Smuzhiyun * bit 12..31 : Reserved:20
224*4882a593Smuzhiyun */
225*4882a593Smuzhiyun struct wil_ring_tx_status {
226*4882a593Smuzhiyun u8 num_descriptors;
227*4882a593Smuzhiyun u8 ring_id;
228*4882a593Smuzhiyun u8 status;
229*4882a593Smuzhiyun u8 desc_ready; /* Only the last bit should be set */
230*4882a593Smuzhiyun u32 timestamp;
231*4882a593Smuzhiyun u32 d2;
232*4882a593Smuzhiyun u16 seq_number; /* Only the first 12 bits */
233*4882a593Smuzhiyun u16 w7;
234*4882a593Smuzhiyun } __packed;
235*4882a593Smuzhiyun
236*4882a593Smuzhiyun /* Enhanced Rx status message - compressed part
237*4882a593Smuzhiyun * [dword 0]
238*4882a593Smuzhiyun * bit 0.. 2 : L2 Rx Status:3 - The L2 packet reception Status
239*4882a593Smuzhiyun * 0-Success, 1-MIC Error, 2-Key Error, 3-Replay Error,
240*4882a593Smuzhiyun * 4-A-MSDU Error, 5-Reserved, 6-Reserved, 7-FCS Error
241*4882a593Smuzhiyun * bit 3.. 4 : L3 Rx Status:2 - Bit0 - L3I - L3 identified and checksum
242*4882a593Smuzhiyun * calculated, Bit1- L3Err - IPv4 Checksum Error
243*4882a593Smuzhiyun * bit 5.. 6 : L4 Rx Status:2 - Bit0 - L4I - L4 identified and checksum
244*4882a593Smuzhiyun * calculated, Bit1- L4Err - TCP/UDP Checksum Error
245*4882a593Smuzhiyun * bit 7 : Reserved:1
246*4882a593Smuzhiyun * bit 8..19 : Flow ID:12 - MSDU flow ID
247*4882a593Smuzhiyun * bit 20 : MID_V:1 - The MAC ID field is valid
248*4882a593Smuzhiyun * bit 21..22 : MID:2 - The MAC ID
249*4882a593Smuzhiyun * bit 23 : L3T:1 - IP types: 0-IPv6, 1-IPv4
250*4882a593Smuzhiyun * bit 24 : L4T:1 - Layer 4 Type: 0-UDP, 1-TCP
251*4882a593Smuzhiyun * bit 25 : BC:1 - The received MPDU is broadcast
252*4882a593Smuzhiyun * bit 26 : MC:1 - The received MPDU is multicast
253*4882a593Smuzhiyun * bit 27 : Raw:1 - The MPDU received with no translation
254*4882a593Smuzhiyun * bit 28 : Sec:1 - The FC control (b14) - Frame Protected
255*4882a593Smuzhiyun * bit 29 : Error:1 - An error is set when (L2 status != 0) ||
256*4882a593Smuzhiyun * (L3 status == 3) || (L4 status == 3)
257*4882a593Smuzhiyun * bit 30 : EOP:1 - End of MSDU signaling. It is set to mark the end
258*4882a593Smuzhiyun * of the transfer, otherwise the status indicates buffer
259*4882a593Smuzhiyun * only completion.
260*4882a593Smuzhiyun * bit 31 : Descriptor Ready bit:1 - It is initiated to
261*4882a593Smuzhiyun * zero by the driver when the ring is created. It is set
262*4882a593Smuzhiyun * by the HW to one for each completed status message.
263*4882a593Smuzhiyun * Each wrap around, the DR bit value is flipped.
264*4882a593Smuzhiyun * [dword 1]
265*4882a593Smuzhiyun * bit 0.. 5 : MAC Len:6 - The number of bytes that are used for L2 header
266*4882a593Smuzhiyun * bit 6..11 : IPLEN:6 - The number of DW that are used for L3 header
267*4882a593Smuzhiyun * bit 12..15 : I4Len:4 - The number of DW that are used for L4 header
268*4882a593Smuzhiyun * bit 16..21 : MCS:6 - The received MCS field from the PLCP Header
269*4882a593Smuzhiyun * bit 22..23 : CB mode:2 - The CB Mode: 0-DMG, 1-EDMG, 2-Wide
270*4882a593Smuzhiyun * bit 24..27 : Data Offset:4 - The data offset, a code that describe the
271*4882a593Smuzhiyun * payload shift from the beginning of the buffer:
272*4882a593Smuzhiyun * 0 - 0 Bytes, 3 - 2 Bytes
273*4882a593Smuzhiyun * bit 28 : A-MSDU Present:1 - The QoS (b7) A-MSDU present field
274*4882a593Smuzhiyun * bit 29 : A-MSDU Type:1 The QoS (b8) A-MSDU Type field
275*4882a593Smuzhiyun * bit 30 : A-MPDU:1 - Packet is part of aggregated MPDU
276*4882a593Smuzhiyun * bit 31 : Key ID:1 - The extracted Key ID from the encryption header
277*4882a593Smuzhiyun * [dword 2]
278*4882a593Smuzhiyun * bit 0..15 : Buffer ID:16 - The Buffer Identifier
279*4882a593Smuzhiyun * bit 16..31 : Length:16 - It indicates the valid bytes that are stored
280*4882a593Smuzhiyun * in the current descriptor buffer. For multiple buffer
281*4882a593Smuzhiyun * descriptor, SW need to sum the total descriptor length
282*4882a593Smuzhiyun * in all buffers to produce the packet length
283*4882a593Smuzhiyun * [dword 3]
284*4882a593Smuzhiyun * bit 0..31 : timestamp:32 - The MPDU Timestamp.
285*4882a593Smuzhiyun */
286*4882a593Smuzhiyun struct wil_rx_status_compressed {
287*4882a593Smuzhiyun u32 d0;
288*4882a593Smuzhiyun u32 d1;
289*4882a593Smuzhiyun __le16 buff_id;
290*4882a593Smuzhiyun __le16 length;
291*4882a593Smuzhiyun u32 timestamp;
292*4882a593Smuzhiyun } __packed;
293*4882a593Smuzhiyun
294*4882a593Smuzhiyun /* Enhanced Rx status message - extension part
295*4882a593Smuzhiyun * [dword 0]
296*4882a593Smuzhiyun * bit 0.. 4 : QID:5 - The Queue Identifier that the packet is received
297*4882a593Smuzhiyun * from
298*4882a593Smuzhiyun * bit 5.. 7 : Reserved:3
299*4882a593Smuzhiyun * bit 8..11 : TID:4 - The QoS (b3-0) TID Field
300*4882a593Smuzhiyun * bit 12..15 Source index:4 - The Source index that was found
301*4882a593Smuzhiyun during Parsing the TA. This field is used to define the
302*4882a593Smuzhiyun source of the packet
303*4882a593Smuzhiyun * bit 16..18 : Destination index:3 - The Destination index that
304*4882a593Smuzhiyun was found during Parsing the RA.
305*4882a593Smuzhiyun * bit 19..20 : DS Type:2 - The FC Control (b9-8) - From / To DS
306*4882a593Smuzhiyun * bit 21..22 : MIC ICR:2 - this signal tells the DMA to assert an
307*4882a593Smuzhiyun interrupt after it writes the packet
308*4882a593Smuzhiyun * bit 23 : ESOP:1 - The QoS (b4) ESOP field
309*4882a593Smuzhiyun * bit 24 : RDG:1
310*4882a593Smuzhiyun * bit 25..31 : Reserved:7
311*4882a593Smuzhiyun * [dword 1]
312*4882a593Smuzhiyun * bit 0.. 1 : Frame Type:2 - The FC Control (b3-2) - MPDU Type
313*4882a593Smuzhiyun (management, data, control and extension)
314*4882a593Smuzhiyun * bit 2.. 5 : Syb type:4 - The FC Control (b7-4) - Frame Subtype
315*4882a593Smuzhiyun * bit 6..11 : Ext sub type:6 - The FC Control (b11-8) - Frame Extended
316*4882a593Smuzhiyun * Subtype
317*4882a593Smuzhiyun * bit 12..13 : ACK Policy:2 - The QoS (b6-5) ACK Policy fields
318*4882a593Smuzhiyun * bit 14 : DECRYPT_BYP:1 - The MPDU is bypass by the decryption unit
319*4882a593Smuzhiyun * bit 15..23 : Reserved:9
320*4882a593Smuzhiyun * bit 24..31 : RSSI/SNR:8 - The RSSI / SNR measurement for the received
321*4882a593Smuzhiyun * MPDU
322*4882a593Smuzhiyun * [dword 2]
323*4882a593Smuzhiyun * bit 0..11 : SN:12 - The received Sequence number field
324*4882a593Smuzhiyun * bit 12..15 : Reserved:4
325*4882a593Smuzhiyun * bit 16..31 : PN bits [15:0]:16
326*4882a593Smuzhiyun * [dword 3]
327*4882a593Smuzhiyun * bit 0..31 : PN bits [47:16]:32
328*4882a593Smuzhiyun */
329*4882a593Smuzhiyun struct wil_rx_status_extension {
330*4882a593Smuzhiyun u32 d0;
331*4882a593Smuzhiyun u32 d1;
332*4882a593Smuzhiyun __le16 seq_num; /* only lower 12 bits */
333*4882a593Smuzhiyun u16 pn_15_0;
334*4882a593Smuzhiyun u32 pn_47_16;
335*4882a593Smuzhiyun } __packed;
336*4882a593Smuzhiyun
337*4882a593Smuzhiyun struct wil_rx_status_extended {
338*4882a593Smuzhiyun struct wil_rx_status_compressed comp;
339*4882a593Smuzhiyun struct wil_rx_status_extension ext;
340*4882a593Smuzhiyun } __packed;
341*4882a593Smuzhiyun
wil_skb_rxstatus(struct sk_buff * skb)342*4882a593Smuzhiyun static inline void *wil_skb_rxstatus(struct sk_buff *skb)
343*4882a593Smuzhiyun {
344*4882a593Smuzhiyun return (void *)skb->cb;
345*4882a593Smuzhiyun }
346*4882a593Smuzhiyun
wil_rx_status_get_length(void * msg)347*4882a593Smuzhiyun static inline __le16 wil_rx_status_get_length(void *msg)
348*4882a593Smuzhiyun {
349*4882a593Smuzhiyun return ((struct wil_rx_status_compressed *)msg)->length;
350*4882a593Smuzhiyun }
351*4882a593Smuzhiyun
wil_rx_status_get_mcs(void * msg)352*4882a593Smuzhiyun static inline u8 wil_rx_status_get_mcs(void *msg)
353*4882a593Smuzhiyun {
354*4882a593Smuzhiyun return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
355*4882a593Smuzhiyun 16, 21);
356*4882a593Smuzhiyun }
357*4882a593Smuzhiyun
wil_rx_status_get_cb_mode(void * msg)358*4882a593Smuzhiyun static inline u8 wil_rx_status_get_cb_mode(void *msg)
359*4882a593Smuzhiyun {
360*4882a593Smuzhiyun return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
361*4882a593Smuzhiyun 22, 23);
362*4882a593Smuzhiyun }
363*4882a593Smuzhiyun
wil_rx_status_get_flow_id(void * msg)364*4882a593Smuzhiyun static inline u16 wil_rx_status_get_flow_id(void *msg)
365*4882a593Smuzhiyun {
366*4882a593Smuzhiyun return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
367*4882a593Smuzhiyun 8, 19);
368*4882a593Smuzhiyun }
369*4882a593Smuzhiyun
wil_rx_status_get_mcast(void * msg)370*4882a593Smuzhiyun static inline u8 wil_rx_status_get_mcast(void *msg)
371*4882a593Smuzhiyun {
372*4882a593Smuzhiyun return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
373*4882a593Smuzhiyun 26, 26);
374*4882a593Smuzhiyun }
375*4882a593Smuzhiyun
376*4882a593Smuzhiyun /**
377*4882a593Smuzhiyun * In case of DLPF miss the parsing of flow Id should be as follows:
378*4882a593Smuzhiyun * dest_id:2
379*4882a593Smuzhiyun * src_id :3 - cid
380*4882a593Smuzhiyun * tid:3
381*4882a593Smuzhiyun * Otherwise:
382*4882a593Smuzhiyun * tid:4
383*4882a593Smuzhiyun * cid:4
384*4882a593Smuzhiyun */
385*4882a593Smuzhiyun
wil_rx_status_get_cid(void * msg)386*4882a593Smuzhiyun static inline u8 wil_rx_status_get_cid(void *msg)
387*4882a593Smuzhiyun {
388*4882a593Smuzhiyun u16 val = wil_rx_status_get_flow_id(msg);
389*4882a593Smuzhiyun
390*4882a593Smuzhiyun if (val & WIL_RX_EDMA_DLPF_LU_MISS_BIT)
391*4882a593Smuzhiyun /* CID is in bits 2..4 */
392*4882a593Smuzhiyun return (val >> WIL_RX_EDMA_DLPF_LU_MISS_CID_POS) &
393*4882a593Smuzhiyun WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK;
394*4882a593Smuzhiyun else
395*4882a593Smuzhiyun /* CID is in bits 4..7 */
396*4882a593Smuzhiyun return (val >> WIL_RX_EDMA_DLPF_LU_HIT_CID_POS) &
397*4882a593Smuzhiyun WIL_RX_EDMA_DLPF_LU_HIT_CID_TID_MASK;
398*4882a593Smuzhiyun }
399*4882a593Smuzhiyun
wil_rx_status_get_tid(void * msg)400*4882a593Smuzhiyun static inline u8 wil_rx_status_get_tid(void *msg)
401*4882a593Smuzhiyun {
402*4882a593Smuzhiyun u16 val = wil_rx_status_get_flow_id(msg);
403*4882a593Smuzhiyun
404*4882a593Smuzhiyun if (val & WIL_RX_EDMA_DLPF_LU_MISS_BIT)
405*4882a593Smuzhiyun /* TID is in bits 5..7 */
406*4882a593Smuzhiyun return (val >> WIL_RX_EDMA_DLPF_LU_MISS_TID_POS) &
407*4882a593Smuzhiyun WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK;
408*4882a593Smuzhiyun else
409*4882a593Smuzhiyun /* TID is in bits 0..3 */
410*4882a593Smuzhiyun return val & WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK;
411*4882a593Smuzhiyun }
412*4882a593Smuzhiyun
wil_rx_status_get_eop(void * msg)413*4882a593Smuzhiyun static inline int wil_rx_status_get_eop(void *msg) /* EoP = End of Packet */
414*4882a593Smuzhiyun {
415*4882a593Smuzhiyun return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
416*4882a593Smuzhiyun 30, 30);
417*4882a593Smuzhiyun }
418*4882a593Smuzhiyun
wil_rx_status_reset_buff_id(struct wil_status_ring * s)419*4882a593Smuzhiyun static inline void wil_rx_status_reset_buff_id(struct wil_status_ring *s)
420*4882a593Smuzhiyun {
421*4882a593Smuzhiyun ((struct wil_rx_status_compressed *)
422*4882a593Smuzhiyun (s->va + (s->elem_size * s->swhead)))->buff_id = 0;
423*4882a593Smuzhiyun }
424*4882a593Smuzhiyun
wil_rx_status_get_buff_id(void * msg)425*4882a593Smuzhiyun static inline __le16 wil_rx_status_get_buff_id(void *msg)
426*4882a593Smuzhiyun {
427*4882a593Smuzhiyun return ((struct wil_rx_status_compressed *)msg)->buff_id;
428*4882a593Smuzhiyun }
429*4882a593Smuzhiyun
wil_rx_status_get_data_offset(void * msg)430*4882a593Smuzhiyun static inline u8 wil_rx_status_get_data_offset(void *msg)
431*4882a593Smuzhiyun {
432*4882a593Smuzhiyun u8 val = WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
433*4882a593Smuzhiyun 24, 27);
434*4882a593Smuzhiyun
435*4882a593Smuzhiyun switch (val) {
436*4882a593Smuzhiyun case 0: return 0;
437*4882a593Smuzhiyun case 3: return 2;
438*4882a593Smuzhiyun default: return 0xFF;
439*4882a593Smuzhiyun }
440*4882a593Smuzhiyun }
441*4882a593Smuzhiyun
wil_rx_status_get_frame_type(struct wil6210_priv * wil,void * msg)442*4882a593Smuzhiyun static inline int wil_rx_status_get_frame_type(struct wil6210_priv *wil,
443*4882a593Smuzhiyun void *msg)
444*4882a593Smuzhiyun {
445*4882a593Smuzhiyun if (wil->use_compressed_rx_status)
446*4882a593Smuzhiyun return IEEE80211_FTYPE_DATA;
447*4882a593Smuzhiyun
448*4882a593Smuzhiyun return WIL_GET_BITS(((struct wil_rx_status_extended *)msg)->ext.d1,
449*4882a593Smuzhiyun 0, 1) << 2;
450*4882a593Smuzhiyun }
451*4882a593Smuzhiyun
wil_rx_status_get_fc1(struct wil6210_priv * wil,void * msg)452*4882a593Smuzhiyun static inline int wil_rx_status_get_fc1(struct wil6210_priv *wil, void *msg)
453*4882a593Smuzhiyun {
454*4882a593Smuzhiyun if (wil->use_compressed_rx_status)
455*4882a593Smuzhiyun return 0;
456*4882a593Smuzhiyun
457*4882a593Smuzhiyun return WIL_GET_BITS(((struct wil_rx_status_extended *)msg)->ext.d1,
458*4882a593Smuzhiyun 0, 5) << 2;
459*4882a593Smuzhiyun }
460*4882a593Smuzhiyun
wil_rx_status_get_seq(struct wil6210_priv * wil,void * msg)461*4882a593Smuzhiyun static inline __le16 wil_rx_status_get_seq(struct wil6210_priv *wil, void *msg)
462*4882a593Smuzhiyun {
463*4882a593Smuzhiyun if (wil->use_compressed_rx_status)
464*4882a593Smuzhiyun return 0;
465*4882a593Smuzhiyun
466*4882a593Smuzhiyun return ((struct wil_rx_status_extended *)msg)->ext.seq_num;
467*4882a593Smuzhiyun }
468*4882a593Smuzhiyun
wil_rx_status_get_retry(void * msg)469*4882a593Smuzhiyun static inline u8 wil_rx_status_get_retry(void *msg)
470*4882a593Smuzhiyun {
471*4882a593Smuzhiyun /* retry bit is missing in EDMA HW. return 1 to be on the safe side */
472*4882a593Smuzhiyun return 1;
473*4882a593Smuzhiyun }
474*4882a593Smuzhiyun
wil_rx_status_get_mid(void * msg)475*4882a593Smuzhiyun static inline int wil_rx_status_get_mid(void *msg)
476*4882a593Smuzhiyun {
477*4882a593Smuzhiyun if (!(((struct wil_rx_status_compressed *)msg)->d0 &
478*4882a593Smuzhiyun WIL_RX_EDMA_MID_VALID_BIT))
479*4882a593Smuzhiyun return 0; /* use the default MID */
480*4882a593Smuzhiyun
481*4882a593Smuzhiyun return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
482*4882a593Smuzhiyun 21, 22);
483*4882a593Smuzhiyun }
484*4882a593Smuzhiyun
wil_rx_status_get_error(void * msg)485*4882a593Smuzhiyun static inline int wil_rx_status_get_error(void *msg)
486*4882a593Smuzhiyun {
487*4882a593Smuzhiyun return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
488*4882a593Smuzhiyun 29, 29);
489*4882a593Smuzhiyun }
490*4882a593Smuzhiyun
wil_rx_status_get_l2_rx_status(void * msg)491*4882a593Smuzhiyun static inline int wil_rx_status_get_l2_rx_status(void *msg)
492*4882a593Smuzhiyun {
493*4882a593Smuzhiyun return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
494*4882a593Smuzhiyun 0, 2);
495*4882a593Smuzhiyun }
496*4882a593Smuzhiyun
wil_rx_status_get_l3_rx_status(void * msg)497*4882a593Smuzhiyun static inline int wil_rx_status_get_l3_rx_status(void *msg)
498*4882a593Smuzhiyun {
499*4882a593Smuzhiyun return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
500*4882a593Smuzhiyun 3, 4);
501*4882a593Smuzhiyun }
502*4882a593Smuzhiyun
wil_rx_status_get_l4_rx_status(void * msg)503*4882a593Smuzhiyun static inline int wil_rx_status_get_l4_rx_status(void *msg)
504*4882a593Smuzhiyun {
505*4882a593Smuzhiyun return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
506*4882a593Smuzhiyun 5, 6);
507*4882a593Smuzhiyun }
508*4882a593Smuzhiyun
509*4882a593Smuzhiyun /* L4 L3 Expected result
510*4882a593Smuzhiyun * 0 0 Ok. No L3 and no L4 known protocols found.
511*4882a593Smuzhiyun * Treated as L2 packet. (no offloads on this packet)
512*4882a593Smuzhiyun * 0 1 Ok. It means that L3 was found, and checksum check passed.
513*4882a593Smuzhiyun * No known L4 protocol was found.
514*4882a593Smuzhiyun * 0 2 It means that L3 protocol was found, and checksum check failed.
515*4882a593Smuzhiyun * No L4 known protocol was found.
516*4882a593Smuzhiyun * 1 any Ok. It means that L4 was found, and checksum check passed.
517*4882a593Smuzhiyun * 3 0 Not a possible scenario.
518*4882a593Smuzhiyun * 3 1 Recalculate. It means that L3 protocol was found, and checksum
519*4882a593Smuzhiyun * passed. But L4 checksum failed. Need to see if really failed,
520*4882a593Smuzhiyun * or due to fragmentation.
521*4882a593Smuzhiyun * 3 2 Both L3 and L4 checksum check failed.
522*4882a593Smuzhiyun */
wil_rx_status_get_checksum(void * msg,struct wil_net_stats * stats)523*4882a593Smuzhiyun static inline int wil_rx_status_get_checksum(void *msg,
524*4882a593Smuzhiyun struct wil_net_stats *stats)
525*4882a593Smuzhiyun {
526*4882a593Smuzhiyun int l3_rx_status = wil_rx_status_get_l3_rx_status(msg);
527*4882a593Smuzhiyun int l4_rx_status = wil_rx_status_get_l4_rx_status(msg);
528*4882a593Smuzhiyun
529*4882a593Smuzhiyun if (l4_rx_status == 1)
530*4882a593Smuzhiyun return CHECKSUM_UNNECESSARY;
531*4882a593Smuzhiyun
532*4882a593Smuzhiyun if (l4_rx_status == 0 && l3_rx_status == 1)
533*4882a593Smuzhiyun return CHECKSUM_UNNECESSARY;
534*4882a593Smuzhiyun
535*4882a593Smuzhiyun if (l3_rx_status == 0 && l4_rx_status == 0)
536*4882a593Smuzhiyun /* L2 packet */
537*4882a593Smuzhiyun return CHECKSUM_NONE;
538*4882a593Smuzhiyun
539*4882a593Smuzhiyun /* If HW reports bad checksum, let IP stack re-check it
540*4882a593Smuzhiyun * For example, HW doesn't understand Microsoft IP stack that
541*4882a593Smuzhiyun * mis-calculates TCP checksum - if it should be 0x0,
542*4882a593Smuzhiyun * it writes 0xffff in violation of RFC 1624
543*4882a593Smuzhiyun */
544*4882a593Smuzhiyun stats->rx_csum_err++;
545*4882a593Smuzhiyun return CHECKSUM_NONE;
546*4882a593Smuzhiyun }
547*4882a593Smuzhiyun
wil_rx_status_get_security(void * msg)548*4882a593Smuzhiyun static inline int wil_rx_status_get_security(void *msg)
549*4882a593Smuzhiyun {
550*4882a593Smuzhiyun return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
551*4882a593Smuzhiyun 28, 28);
552*4882a593Smuzhiyun }
553*4882a593Smuzhiyun
wil_rx_status_get_key_id(void * msg)554*4882a593Smuzhiyun static inline u8 wil_rx_status_get_key_id(void *msg)
555*4882a593Smuzhiyun {
556*4882a593Smuzhiyun return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
557*4882a593Smuzhiyun 31, 31);
558*4882a593Smuzhiyun }
559*4882a593Smuzhiyun
wil_tx_status_get_mcs(struct wil_ring_tx_status * msg)560*4882a593Smuzhiyun static inline u8 wil_tx_status_get_mcs(struct wil_ring_tx_status *msg)
561*4882a593Smuzhiyun {
562*4882a593Smuzhiyun return WIL_GET_BITS(msg->d2, 0, 4);
563*4882a593Smuzhiyun }
564*4882a593Smuzhiyun
wil_ring_next_head(struct wil_ring * ring)565*4882a593Smuzhiyun static inline u32 wil_ring_next_head(struct wil_ring *ring)
566*4882a593Smuzhiyun {
567*4882a593Smuzhiyun return (ring->swhead + 1) % ring->size;
568*4882a593Smuzhiyun }
569*4882a593Smuzhiyun
wil_desc_set_addr_edma(struct wil_ring_dma_addr * addr,__le16 * addr_high_high,dma_addr_t pa)570*4882a593Smuzhiyun static inline void wil_desc_set_addr_edma(struct wil_ring_dma_addr *addr,
571*4882a593Smuzhiyun __le16 *addr_high_high,
572*4882a593Smuzhiyun dma_addr_t pa)
573*4882a593Smuzhiyun {
574*4882a593Smuzhiyun addr->addr_low = cpu_to_le32(lower_32_bits(pa));
575*4882a593Smuzhiyun addr->addr_high = cpu_to_le16((u16)upper_32_bits(pa));
576*4882a593Smuzhiyun *addr_high_high = cpu_to_le16((u16)(upper_32_bits(pa) >> 16));
577*4882a593Smuzhiyun }
578*4882a593Smuzhiyun
579*4882a593Smuzhiyun static inline
wil_tx_desc_get_addr_edma(struct wil_ring_tx_enhanced_dma * dma)580*4882a593Smuzhiyun dma_addr_t wil_tx_desc_get_addr_edma(struct wil_ring_tx_enhanced_dma *dma)
581*4882a593Smuzhiyun {
582*4882a593Smuzhiyun return le32_to_cpu(dma->addr.addr_low) |
583*4882a593Smuzhiyun ((u64)le16_to_cpu(dma->addr.addr_high) << 32) |
584*4882a593Smuzhiyun ((u64)le16_to_cpu(dma->addr_high_high) << 48);
585*4882a593Smuzhiyun }
586*4882a593Smuzhiyun
587*4882a593Smuzhiyun static inline
wil_rx_desc_get_addr_edma(struct wil_ring_rx_enhanced_dma * dma)588*4882a593Smuzhiyun dma_addr_t wil_rx_desc_get_addr_edma(struct wil_ring_rx_enhanced_dma *dma)
589*4882a593Smuzhiyun {
590*4882a593Smuzhiyun return le32_to_cpu(dma->addr.addr_low) |
591*4882a593Smuzhiyun ((u64)le16_to_cpu(dma->addr.addr_high) << 32) |
592*4882a593Smuzhiyun ((u64)le16_to_cpu(dma->addr_high_high) << 48);
593*4882a593Smuzhiyun }
594*4882a593Smuzhiyun
595*4882a593Smuzhiyun void wil_configure_interrupt_moderation_edma(struct wil6210_priv *wil);
596*4882a593Smuzhiyun int wil_tx_sring_handler(struct wil6210_priv *wil,
597*4882a593Smuzhiyun struct wil_status_ring *sring);
598*4882a593Smuzhiyun void wil_rx_handle_edma(struct wil6210_priv *wil, int *quota);
599*4882a593Smuzhiyun void wil_init_txrx_ops_edma(struct wil6210_priv *wil);
600*4882a593Smuzhiyun
601*4882a593Smuzhiyun #endif /* WIL6210_TXRX_EDMA_H */
602*4882a593Smuzhiyun
603