185630469SLior David /* SPDX-License-Identifier: ISC */
210590c6aSGidon Studinski /*
34bf01986SAhmad Masri * Copyright (c) 2012-2016,2018-2019, The Linux Foundation. All rights reserved.
410590c6aSGidon Studinski */
510590c6aSGidon Studinski
610590c6aSGidon Studinski #ifndef WIL6210_TXRX_EDMA_H
710590c6aSGidon Studinski #define WIL6210_TXRX_EDMA_H
810590c6aSGidon Studinski
910590c6aSGidon Studinski #include "wil6210.h"
1010590c6aSGidon Studinski
1196c93589SGidon Studinski /* limit status ring size in range [ring size..max ring size] */
1296c93589SGidon Studinski #define WIL_SRING_SIZE_ORDER_MIN (WIL_RING_SIZE_ORDER_MIN)
1396c93589SGidon Studinski #define WIL_SRING_SIZE_ORDER_MAX (WIL_RING_SIZE_ORDER_MAX)
1496c93589SGidon Studinski /* RX sring order should be bigger than RX ring order */
15cbebe277SMaya Erez #define WIL_RX_SRING_SIZE_ORDER_DEFAULT (12)
16c903ece5SAhmad Masri #define WIL_TX_SRING_SIZE_ORDER_DEFAULT (14)
17cbebe277SMaya Erez #define WIL_RX_BUFF_ARR_SIZE_DEFAULT (2600)
1896c93589SGidon Studinski
1996c93589SGidon Studinski #define WIL_DEFAULT_RX_STATUS_RING_ID 0
2096c93589SGidon Studinski #define WIL_RX_DESC_RING_ID 0
2196c93589SGidon Studinski #define WIL_RX_STATUS_IRQ_IDX 0
2296c93589SGidon Studinski #define WIL_TX_STATUS_IRQ_IDX 1
2396c93589SGidon Studinski
2496c93589SGidon Studinski #define WIL_EDMA_AGG_WATERMARK (0xffff)
2596c93589SGidon Studinski #define WIL_EDMA_AGG_WATERMARK_POS (16)
2696c93589SGidon Studinski
2796c93589SGidon Studinski #define WIL_EDMA_IDLE_TIME_LIMIT_USEC (50)
2896c93589SGidon Studinski #define WIL_EDMA_TIME_UNIT_CLK_CYCLES (330) /* fits 1 usec */
2996c93589SGidon Studinski
307be13fc3SGidon Studinski /* Error field */
317be13fc3SGidon Studinski #define WIL_RX_EDMA_ERROR_MIC (1)
327be13fc3SGidon Studinski #define WIL_RX_EDMA_ERROR_KEY (2) /* Key missing */
337be13fc3SGidon Studinski #define WIL_RX_EDMA_ERROR_REPLAY (3)
347be13fc3SGidon Studinski #define WIL_RX_EDMA_ERROR_AMSDU (4)
357be13fc3SGidon Studinski #define WIL_RX_EDMA_ERROR_FCS (7)
367be13fc3SGidon Studinski
377be13fc3SGidon Studinski #define WIL_RX_EDMA_ERROR_L3_ERR (BIT(0) | BIT(1))
387be13fc3SGidon Studinski #define WIL_RX_EDMA_ERROR_L4_ERR (BIT(0) | BIT(1))
397be13fc3SGidon Studinski
407be13fc3SGidon Studinski #define WIL_RX_EDMA_DLPF_LU_MISS_BIT BIT(11)
417be13fc3SGidon Studinski #define WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK 0x7
427be13fc3SGidon Studinski #define WIL_RX_EDMA_DLPF_LU_HIT_CID_TID_MASK 0xf
437be13fc3SGidon Studinski
447be13fc3SGidon Studinski #define WIL_RX_EDMA_DLPF_LU_MISS_CID_POS 2
457be13fc3SGidon Studinski #define WIL_RX_EDMA_DLPF_LU_HIT_CID_POS 4
467be13fc3SGidon Studinski
477be13fc3SGidon Studinski #define WIL_RX_EDMA_DLPF_LU_MISS_TID_POS 5
487be13fc3SGidon Studinski
4918beb61dSDedy Lansky #define WIL_RX_EDMA_MID_VALID_BIT BIT(20)
507be13fc3SGidon Studinski
519202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_MAC_CFG_0_QID_POS 16
529202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_MAC_CFG_0_QID_LEN 6
539202d7b6SMaya Erez
549202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_CFG_EOP_POS 0
559202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_CFG_EOP_LEN 1
569202d7b6SMaya Erez
579202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_CFG_TSO_DESC_TYPE_POS 3
589202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_CFG_TSO_DESC_TYPE_LEN 2
599202d7b6SMaya Erez
609202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_CFG_SEG_EN_POS 5
619202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_CFG_SEG_EN_LEN 1
629202d7b6SMaya Erez
639202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_CFG_INSERT_IP_CHKSUM_POS 6
649202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_CFG_INSERT_IP_CHKSUM_LEN 1
659202d7b6SMaya Erez
669202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_CFG_INSERT_TCP_CHKSUM_POS 7
679202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_CFG_INSERT_TCP_CHKSUM_LEN 1
689202d7b6SMaya Erez
699202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_CFG_L4_TYPE_POS 15
709202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_CFG_L4_TYPE_LEN 1
719202d7b6SMaya Erez
729202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_CFG_PSEUDO_HEADER_CALC_EN_POS 5
739202d7b6SMaya Erez #define WIL_EDMA_DESC_TX_CFG_PSEUDO_HEADER_CALC_EN_LEN 1
749202d7b6SMaya Erez
7510590c6aSGidon Studinski /* Enhanced Rx descriptor - MAC part
7610590c6aSGidon Studinski * [dword 0] : Reserved
7710590c6aSGidon Studinski * [dword 1] : Reserved
7810590c6aSGidon Studinski * [dword 2] : Reserved
7910590c6aSGidon Studinski * [dword 3]
8010590c6aSGidon Studinski * bit 0..15 : Buffer ID
8110590c6aSGidon Studinski * bit 16..31 : Reserved
8210590c6aSGidon Studinski */
8310590c6aSGidon Studinski struct wil_ring_rx_enhanced_mac {
8410590c6aSGidon Studinski u32 d[3];
8510590c6aSGidon Studinski __le16 buff_id;
8610590c6aSGidon Studinski u16 reserved;
8710590c6aSGidon Studinski } __packed;
8810590c6aSGidon Studinski
8910590c6aSGidon Studinski /* Enhanced Rx descriptor - DMA part
9010590c6aSGidon Studinski * [dword 0] - Reserved
9110590c6aSGidon Studinski * [dword 1]
9210590c6aSGidon Studinski * bit 0..31 : addr_low:32 The payload buffer address, bits 0-31
9310590c6aSGidon Studinski * [dword 2]
9410590c6aSGidon Studinski * bit 0..15 : addr_high_low:16 The payload buffer address, bits 32-47
9510590c6aSGidon Studinski * bit 16..31 : Reserved
9610590c6aSGidon Studinski * [dword 3]
9710590c6aSGidon Studinski * bit 0..15 : addr_high_high:16 The payload buffer address, bits 48-63
9810590c6aSGidon Studinski * bit 16..31 : length
9910590c6aSGidon Studinski */
10010590c6aSGidon Studinski struct wil_ring_rx_enhanced_dma {
10110590c6aSGidon Studinski u32 d0;
10210590c6aSGidon Studinski struct wil_ring_dma_addr addr;
10310590c6aSGidon Studinski u16 w5;
10410590c6aSGidon Studinski __le16 addr_high_high;
10510590c6aSGidon Studinski __le16 length;
10610590c6aSGidon Studinski } __packed;
10710590c6aSGidon Studinski
10810590c6aSGidon Studinski struct wil_rx_enhanced_desc {
10910590c6aSGidon Studinski struct wil_ring_rx_enhanced_mac mac;
11010590c6aSGidon Studinski struct wil_ring_rx_enhanced_dma dma;
11110590c6aSGidon Studinski } __packed;
11210590c6aSGidon Studinski
11310590c6aSGidon Studinski /* Enhanced Tx descriptor - DMA part
11410590c6aSGidon Studinski * [dword 0]
11510590c6aSGidon Studinski * Same as legacy
11610590c6aSGidon Studinski * [dword 1]
11710590c6aSGidon Studinski * bit 0..31 : addr_low:32 The payload buffer address, bits 0-31
11810590c6aSGidon Studinski * [dword 2]
11910590c6aSGidon Studinski * bit 0..15 : addr_high_low:16 The payload buffer address, bits 32-47
12010590c6aSGidon Studinski * bit 16..23 : ip_length:8 The IP header length for the TX IP checksum
12110590c6aSGidon Studinski * offload feature
12210590c6aSGidon Studinski * bit 24..30 : mac_length:7
12310590c6aSGidon Studinski * bit 31 : ip_version:1 1 - IPv4, 0 - IPv6
12410590c6aSGidon Studinski * [dword 3]
12510590c6aSGidon Studinski * bit 0..15 : addr_high_high:16 The payload buffer address, bits 48-63
12610590c6aSGidon Studinski * bit 16..31 : length
12710590c6aSGidon Studinski */
12810590c6aSGidon Studinski struct wil_ring_tx_enhanced_dma {
12910590c6aSGidon Studinski u8 l4_hdr_len;
13010590c6aSGidon Studinski u8 cmd;
13110590c6aSGidon Studinski u16 w1;
13210590c6aSGidon Studinski struct wil_ring_dma_addr addr;
13310590c6aSGidon Studinski u8 ip_length;
13410590c6aSGidon Studinski u8 b11; /* 0..6: mac_length; 7:ip_version */
13510590c6aSGidon Studinski __le16 addr_high_high;
13610590c6aSGidon Studinski __le16 length;
13710590c6aSGidon Studinski } __packed;
13810590c6aSGidon Studinski
13910590c6aSGidon Studinski /* Enhanced Tx descriptor - MAC part
14010590c6aSGidon Studinski * [dword 0]
14110590c6aSGidon Studinski * bit 0.. 9 : lifetime_expiry_value:10
14210590c6aSGidon Studinski * bit 10 : interrupt_en:1
14310590c6aSGidon Studinski * bit 11 : status_en:1
14410590c6aSGidon Studinski * bit 12..13 : txss_override:2
14510590c6aSGidon Studinski * bit 14 : timestamp_insertion:1
14610590c6aSGidon Studinski * bit 15 : duration_preserve:1
14710590c6aSGidon Studinski * bit 16..21 : reserved0:6
14810590c6aSGidon Studinski * bit 22..26 : mcs_index:5
14910590c6aSGidon Studinski * bit 27 : mcs_en:1
15010590c6aSGidon Studinski * bit 28..30 : reserved1:3
15110590c6aSGidon Studinski * bit 31 : sn_preserved:1
15210590c6aSGidon Studinski * [dword 1]
15310590c6aSGidon Studinski * bit 0.. 3 : pkt_mode:4
15410590c6aSGidon Studinski * bit 4 : pkt_mode_en:1
15510590c6aSGidon Studinski * bit 5..14 : reserved0:10
15610590c6aSGidon Studinski * bit 15 : ack_policy_en:1
15710590c6aSGidon Studinski * bit 16..19 : dst_index:4
15810590c6aSGidon Studinski * bit 20 : dst_index_en:1
15910590c6aSGidon Studinski * bit 21..22 : ack_policy:2
16010590c6aSGidon Studinski * bit 23 : lifetime_en:1
16110590c6aSGidon Studinski * bit 24..30 : max_retry:7
16210590c6aSGidon Studinski * bit 31 : max_retry_en:1
16310590c6aSGidon Studinski * [dword 2]
16410590c6aSGidon Studinski * bit 0.. 7 : num_of_descriptors:8
16510590c6aSGidon Studinski * bit 8..17 : reserved:10
16610590c6aSGidon Studinski * bit 18..19 : l2_translation_type:2 00 - bypass, 01 - 802.3, 10 - 802.11
16710590c6aSGidon Studinski * bit 20 : snap_hdr_insertion_en:1
16810590c6aSGidon Studinski * bit 21 : vlan_removal_en:1
16910590c6aSGidon Studinski * bit 22..23 : reserved0:2
17010590c6aSGidon Studinski * bit 24 : Dest ID extension:1
17110590c6aSGidon Studinski * bit 25..31 : reserved0:7
17210590c6aSGidon Studinski * [dword 3]
17310590c6aSGidon Studinski * bit 0..15 : tso_mss:16
17410590c6aSGidon Studinski * bit 16..31 : descriptor_scratchpad:16 - mailbox between driver and ucode
17510590c6aSGidon Studinski */
17610590c6aSGidon Studinski struct wil_ring_tx_enhanced_mac {
17710590c6aSGidon Studinski u32 d[3];
17810590c6aSGidon Studinski __le16 tso_mss;
17910590c6aSGidon Studinski u16 scratchpad;
18010590c6aSGidon Studinski } __packed;
18110590c6aSGidon Studinski
18210590c6aSGidon Studinski struct wil_tx_enhanced_desc {
18310590c6aSGidon Studinski struct wil_ring_tx_enhanced_mac mac;
18410590c6aSGidon Studinski struct wil_ring_tx_enhanced_dma dma;
18510590c6aSGidon Studinski } __packed;
18610590c6aSGidon Studinski
18710590c6aSGidon Studinski #define TX_STATUS_DESC_READY_POS 7
18810590c6aSGidon Studinski
18910590c6aSGidon Studinski /* Enhanced TX status message
19010590c6aSGidon Studinski * [dword 0]
19110590c6aSGidon Studinski * bit 0.. 7 : Number of Descriptor:8 - The number of descriptors that
19210590c6aSGidon Studinski * are used to form the packets. It is needed for WB when
19310590c6aSGidon Studinski * releasing the packet
19410590c6aSGidon Studinski * bit 8..15 : tx_ring_id:8 The transmission ring ID that is related to
19510590c6aSGidon Studinski * the message
19610590c6aSGidon Studinski * bit 16..23 : Status:8 - The TX status Code
19710590c6aSGidon Studinski * 0x0 - A successful transmission
19810590c6aSGidon Studinski * 0x1 - Retry expired
19910590c6aSGidon Studinski * 0x2 - Lifetime Expired
20010590c6aSGidon Studinski * 0x3 - Released
20110590c6aSGidon Studinski * 0x4-0xFF - Reserved
20210590c6aSGidon Studinski * bit 24..30 : Reserved:7
20310590c6aSGidon Studinski * bit 31 : Descriptor Ready bit:1 - It is initiated to
20410590c6aSGidon Studinski * zero by the driver when the ring is created. It is set by the HW
20510590c6aSGidon Studinski * to one for each completed status message. Each wrap around,
20610590c6aSGidon Studinski * the DR bit value is flipped.
20710590c6aSGidon Studinski * [dword 1]
20810590c6aSGidon Studinski * bit 0..31 : timestamp:32 - Set when MPDU is transmitted.
20910590c6aSGidon Studinski * [dword 2]
21010590c6aSGidon Studinski * bit 0.. 4 : MCS:5 - The transmitted MCS value
21110590c6aSGidon Studinski * bit 5 : Reserved:1
21210590c6aSGidon Studinski * bit 6.. 7 : CB mode:2 - 0-DMG 1-EDMG 2-Wide
21310590c6aSGidon Studinski * bit 8..12 : QID:5 - The QID that was used for the transmission
21410590c6aSGidon Studinski * bit 13..15 : Reserved:3
21510590c6aSGidon Studinski * bit 16..20 : Num of MSDUs:5 - Number of MSDUs in the aggregation
21610590c6aSGidon Studinski * bit 21..22 : Reserved:2
21710590c6aSGidon Studinski * bit 23 : Retry:1 - An indication that the transmission was retried
21810590c6aSGidon Studinski * bit 24..31 : TX-Sector:8 - the antenna sector that was used for
21910590c6aSGidon Studinski * transmission
22010590c6aSGidon Studinski * [dword 3]
22110590c6aSGidon Studinski * bit 0..11 : Sequence number:12 - The Sequence Number that was used
22210590c6aSGidon Studinski * for the MPDU transmission
22310590c6aSGidon Studinski * bit 12..31 : Reserved:20
22410590c6aSGidon Studinski */
22510590c6aSGidon Studinski struct wil_ring_tx_status {
22610590c6aSGidon Studinski u8 num_descriptors;
22710590c6aSGidon Studinski u8 ring_id;
22810590c6aSGidon Studinski u8 status;
22910590c6aSGidon Studinski u8 desc_ready; /* Only the last bit should be set */
23010590c6aSGidon Studinski u32 timestamp;
23110590c6aSGidon Studinski u32 d2;
23210590c6aSGidon Studinski u16 seq_number; /* Only the first 12 bits */
23310590c6aSGidon Studinski u16 w7;
23410590c6aSGidon Studinski } __packed;
23510590c6aSGidon Studinski
23610590c6aSGidon Studinski /* Enhanced Rx status message - compressed part
23710590c6aSGidon Studinski * [dword 0]
23810590c6aSGidon Studinski * bit 0.. 2 : L2 Rx Status:3 - The L2 packet reception Status
23910590c6aSGidon Studinski * 0-Success, 1-MIC Error, 2-Key Error, 3-Replay Error,
24010590c6aSGidon Studinski * 4-A-MSDU Error, 5-Reserved, 6-Reserved, 7-FCS Error
24110590c6aSGidon Studinski * bit 3.. 4 : L3 Rx Status:2 - Bit0 - L3I - L3 identified and checksum
24210590c6aSGidon Studinski * calculated, Bit1- L3Err - IPv4 Checksum Error
24310590c6aSGidon Studinski * bit 5.. 6 : L4 Rx Status:2 - Bit0 - L4I - L4 identified and checksum
24410590c6aSGidon Studinski * calculated, Bit1- L4Err - TCP/UDP Checksum Error
24510590c6aSGidon Studinski * bit 7 : Reserved:1
24610590c6aSGidon Studinski * bit 8..19 : Flow ID:12 - MSDU flow ID
24718beb61dSDedy Lansky * bit 20 : MID_V:1 - The MAC ID field is valid
24818beb61dSDedy Lansky * bit 21..22 : MID:2 - The MAC ID
24910590c6aSGidon Studinski * bit 23 : L3T:1 - IP types: 0-IPv6, 1-IPv4
25010590c6aSGidon Studinski * bit 24 : L4T:1 - Layer 4 Type: 0-UDP, 1-TCP
25110590c6aSGidon Studinski * bit 25 : BC:1 - The received MPDU is broadcast
25210590c6aSGidon Studinski * bit 26 : MC:1 - The received MPDU is multicast
25310590c6aSGidon Studinski * bit 27 : Raw:1 - The MPDU received with no translation
25410590c6aSGidon Studinski * bit 28 : Sec:1 - The FC control (b14) - Frame Protected
25510590c6aSGidon Studinski * bit 29 : Error:1 - An error is set when (L2 status != 0) ||
25610590c6aSGidon Studinski * (L3 status == 3) || (L4 status == 3)
25710590c6aSGidon Studinski * bit 30 : EOP:1 - End of MSDU signaling. It is set to mark the end
25810590c6aSGidon Studinski * of the transfer, otherwise the status indicates buffer
25910590c6aSGidon Studinski * only completion.
26010590c6aSGidon Studinski * bit 31 : Descriptor Ready bit:1 - It is initiated to
26110590c6aSGidon Studinski * zero by the driver when the ring is created. It is set
26210590c6aSGidon Studinski * by the HW to one for each completed status message.
26310590c6aSGidon Studinski * Each wrap around, the DR bit value is flipped.
26410590c6aSGidon Studinski * [dword 1]
26510590c6aSGidon Studinski * bit 0.. 5 : MAC Len:6 - The number of bytes that are used for L2 header
26610590c6aSGidon Studinski * bit 6..11 : IPLEN:6 - The number of DW that are used for L3 header
26710590c6aSGidon Studinski * bit 12..15 : I4Len:4 - The number of DW that are used for L4 header
26810590c6aSGidon Studinski * bit 16..21 : MCS:6 - The received MCS field from the PLCP Header
26910590c6aSGidon Studinski * bit 22..23 : CB mode:2 - The CB Mode: 0-DMG, 1-EDMG, 2-Wide
27010590c6aSGidon Studinski * bit 24..27 : Data Offset:4 - The data offset, a code that describe the
27110590c6aSGidon Studinski * payload shift from the beginning of the buffer:
27296c93589SGidon Studinski * 0 - 0 Bytes, 3 - 2 Bytes
27310590c6aSGidon Studinski * bit 28 : A-MSDU Present:1 - The QoS (b7) A-MSDU present field
27410590c6aSGidon Studinski * bit 29 : A-MSDU Type:1 The QoS (b8) A-MSDU Type field
27510590c6aSGidon Studinski * bit 30 : A-MPDU:1 - Packet is part of aggregated MPDU
27610590c6aSGidon Studinski * bit 31 : Key ID:1 - The extracted Key ID from the encryption header
27710590c6aSGidon Studinski * [dword 2]
27810590c6aSGidon Studinski * bit 0..15 : Buffer ID:16 - The Buffer Identifier
27910590c6aSGidon Studinski * bit 16..31 : Length:16 - It indicates the valid bytes that are stored
28010590c6aSGidon Studinski * in the current descriptor buffer. For multiple buffer
28110590c6aSGidon Studinski * descriptor, SW need to sum the total descriptor length
28210590c6aSGidon Studinski * in all buffers to produce the packet length
28310590c6aSGidon Studinski * [dword 3]
28410590c6aSGidon Studinski * bit 0..31 : timestamp:32 - The MPDU Timestamp.
28510590c6aSGidon Studinski */
28610590c6aSGidon Studinski struct wil_rx_status_compressed {
28710590c6aSGidon Studinski u32 d0;
28810590c6aSGidon Studinski u32 d1;
28910590c6aSGidon Studinski __le16 buff_id;
29010590c6aSGidon Studinski __le16 length;
29110590c6aSGidon Studinski u32 timestamp;
29210590c6aSGidon Studinski } __packed;
29310590c6aSGidon Studinski
29410590c6aSGidon Studinski /* Enhanced Rx status message - extension part
29510590c6aSGidon Studinski * [dword 0]
29610590c6aSGidon Studinski * bit 0.. 4 : QID:5 - The Queue Identifier that the packet is received
29710590c6aSGidon Studinski * from
29810590c6aSGidon Studinski * bit 5.. 7 : Reserved:3
29910590c6aSGidon Studinski * bit 8..11 : TID:4 - The QoS (b3-0) TID Field
30010590c6aSGidon Studinski * bit 12..15 Source index:4 - The Source index that was found
30110590c6aSGidon Studinski during Parsing the TA. This field is used to define the
30210590c6aSGidon Studinski source of the packet
30310590c6aSGidon Studinski * bit 16..18 : Destination index:3 - The Destination index that
30410590c6aSGidon Studinski was found during Parsing the RA.
30510590c6aSGidon Studinski * bit 19..20 : DS Type:2 - The FC Control (b9-8) - From / To DS
30610590c6aSGidon Studinski * bit 21..22 : MIC ICR:2 - this signal tells the DMA to assert an
30710590c6aSGidon Studinski interrupt after it writes the packet
30810590c6aSGidon Studinski * bit 23 : ESOP:1 - The QoS (b4) ESOP field
30910590c6aSGidon Studinski * bit 24 : RDG:1
31010590c6aSGidon Studinski * bit 25..31 : Reserved:7
31110590c6aSGidon Studinski * [dword 1]
31210590c6aSGidon Studinski * bit 0.. 1 : Frame Type:2 - The FC Control (b3-2) - MPDU Type
31310590c6aSGidon Studinski (management, data, control and extension)
31410590c6aSGidon Studinski * bit 2.. 5 : Syb type:4 - The FC Control (b7-4) - Frame Subtype
31510590c6aSGidon Studinski * bit 6..11 : Ext sub type:6 - The FC Control (b11-8) - Frame Extended
31610590c6aSGidon Studinski * Subtype
31710590c6aSGidon Studinski * bit 12..13 : ACK Policy:2 - The QoS (b6-5) ACK Policy fields
31810590c6aSGidon Studinski * bit 14 : DECRYPT_BYP:1 - The MPDU is bypass by the decryption unit
31910590c6aSGidon Studinski * bit 15..23 : Reserved:9
32010590c6aSGidon Studinski * bit 24..31 : RSSI/SNR:8 - The RSSI / SNR measurement for the received
32110590c6aSGidon Studinski * MPDU
32210590c6aSGidon Studinski * [dword 2]
32310590c6aSGidon Studinski * bit 0..11 : SN:12 - The received Sequence number field
32410590c6aSGidon Studinski * bit 12..15 : Reserved:4
32510590c6aSGidon Studinski * bit 16..31 : PN bits [15:0]:16
32610590c6aSGidon Studinski * [dword 3]
32710590c6aSGidon Studinski * bit 0..31 : PN bits [47:16]:32
32810590c6aSGidon Studinski */
32910590c6aSGidon Studinski struct wil_rx_status_extension {
33010590c6aSGidon Studinski u32 d0;
33110590c6aSGidon Studinski u32 d1;
33210590c6aSGidon Studinski __le16 seq_num; /* only lower 12 bits */
333*1ad8237eSDmitry Antipov struct_group_attr(pn, __packed,
33410590c6aSGidon Studinski u16 pn_15_0;
33510590c6aSGidon Studinski u32 pn_47_16;
336*1ad8237eSDmitry Antipov );
33710590c6aSGidon Studinski } __packed;
33810590c6aSGidon Studinski
33910590c6aSGidon Studinski struct wil_rx_status_extended {
34010590c6aSGidon Studinski struct wil_rx_status_compressed comp;
34110590c6aSGidon Studinski struct wil_rx_status_extension ext;
3429202d7b6SMaya Erez } __packed;
3439202d7b6SMaya Erez
wil_skb_rxstatus(struct sk_buff * skb)3447be13fc3SGidon Studinski static inline void *wil_skb_rxstatus(struct sk_buff *skb)
3457be13fc3SGidon Studinski {
3467be13fc3SGidon Studinski return (void *)skb->cb;
3477be13fc3SGidon Studinski }
3487be13fc3SGidon Studinski
wil_rx_status_get_length(void * msg)3497be13fc3SGidon Studinski static inline __le16 wil_rx_status_get_length(void *msg)
3507be13fc3SGidon Studinski {
3517be13fc3SGidon Studinski return ((struct wil_rx_status_compressed *)msg)->length;
3527be13fc3SGidon Studinski }
3537be13fc3SGidon Studinski
wil_rx_status_get_mcs(void * msg)3547be13fc3SGidon Studinski static inline u8 wil_rx_status_get_mcs(void *msg)
3557be13fc3SGidon Studinski {
3567be13fc3SGidon Studinski return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
3577be13fc3SGidon Studinski 16, 21);
3587be13fc3SGidon Studinski }
3597be13fc3SGidon Studinski
wil_rx_status_get_cb_mode(void * msg)3609abe3e30SAlexei Avshalom Lazar static inline u8 wil_rx_status_get_cb_mode(void *msg)
3619abe3e30SAlexei Avshalom Lazar {
3629abe3e30SAlexei Avshalom Lazar return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
3639abe3e30SAlexei Avshalom Lazar 22, 23);
3649abe3e30SAlexei Avshalom Lazar }
3659abe3e30SAlexei Avshalom Lazar
wil_rx_status_get_flow_id(void * msg)3667be13fc3SGidon Studinski static inline u16 wil_rx_status_get_flow_id(void *msg)
3677be13fc3SGidon Studinski {
3687be13fc3SGidon Studinski return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
3697be13fc3SGidon Studinski 8, 19);
3707be13fc3SGidon Studinski }
3717be13fc3SGidon Studinski
wil_rx_status_get_mcast(void * msg)3727be13fc3SGidon Studinski static inline u8 wil_rx_status_get_mcast(void *msg)
3737be13fc3SGidon Studinski {
3747be13fc3SGidon Studinski return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
3757be13fc3SGidon Studinski 26, 26);
3767be13fc3SGidon Studinski }
3777be13fc3SGidon Studinski
3787be13fc3SGidon Studinski /**
3797be13fc3SGidon Studinski * In case of DLPF miss the parsing of flow Id should be as follows:
3807be13fc3SGidon Studinski * dest_id:2
3817be13fc3SGidon Studinski * src_id :3 - cid
3827be13fc3SGidon Studinski * tid:3
3837be13fc3SGidon Studinski * Otherwise:
3847be13fc3SGidon Studinski * tid:4
3857be13fc3SGidon Studinski * cid:4
3867be13fc3SGidon Studinski */
3877be13fc3SGidon Studinski
wil_rx_status_get_cid(void * msg)3887be13fc3SGidon Studinski static inline u8 wil_rx_status_get_cid(void *msg)
3897be13fc3SGidon Studinski {
3907be13fc3SGidon Studinski u16 val = wil_rx_status_get_flow_id(msg);
3917be13fc3SGidon Studinski
3927be13fc3SGidon Studinski if (val & WIL_RX_EDMA_DLPF_LU_MISS_BIT)
3937be13fc3SGidon Studinski /* CID is in bits 2..4 */
3947be13fc3SGidon Studinski return (val >> WIL_RX_EDMA_DLPF_LU_MISS_CID_POS) &
3957be13fc3SGidon Studinski WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK;
3967be13fc3SGidon Studinski else
3977be13fc3SGidon Studinski /* CID is in bits 4..7 */
3987be13fc3SGidon Studinski return (val >> WIL_RX_EDMA_DLPF_LU_HIT_CID_POS) &
3997be13fc3SGidon Studinski WIL_RX_EDMA_DLPF_LU_HIT_CID_TID_MASK;
4007be13fc3SGidon Studinski }
4017be13fc3SGidon Studinski
wil_rx_status_get_tid(void * msg)4027be13fc3SGidon Studinski static inline u8 wil_rx_status_get_tid(void *msg)
4037be13fc3SGidon Studinski {
4047be13fc3SGidon Studinski u16 val = wil_rx_status_get_flow_id(msg);
4057be13fc3SGidon Studinski
4067be13fc3SGidon Studinski if (val & WIL_RX_EDMA_DLPF_LU_MISS_BIT)
4077be13fc3SGidon Studinski /* TID is in bits 5..7 */
4087be13fc3SGidon Studinski return (val >> WIL_RX_EDMA_DLPF_LU_MISS_TID_POS) &
4097be13fc3SGidon Studinski WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK;
4107be13fc3SGidon Studinski else
4117be13fc3SGidon Studinski /* TID is in bits 0..3 */
4127be13fc3SGidon Studinski return val & WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK;
4137be13fc3SGidon Studinski }
4147be13fc3SGidon Studinski
wil_rx_status_get_eop(void * msg)4157be13fc3SGidon Studinski static inline int wil_rx_status_get_eop(void *msg) /* EoP = End of Packet */
4167be13fc3SGidon Studinski {
4177be13fc3SGidon Studinski return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
4187be13fc3SGidon Studinski 30, 30);
4197be13fc3SGidon Studinski }
4207be13fc3SGidon Studinski
wil_rx_status_reset_buff_id(struct wil_status_ring * s)421b4a967b7SMaya Erez static inline void wil_rx_status_reset_buff_id(struct wil_status_ring *s)
422b4a967b7SMaya Erez {
423b4a967b7SMaya Erez ((struct wil_rx_status_compressed *)
424b4a967b7SMaya Erez (s->va + (s->elem_size * s->swhead)))->buff_id = 0;
425b4a967b7SMaya Erez }
426b4a967b7SMaya Erez
wil_rx_status_get_buff_id(void * msg)4277be13fc3SGidon Studinski static inline __le16 wil_rx_status_get_buff_id(void *msg)
4287be13fc3SGidon Studinski {
4297be13fc3SGidon Studinski return ((struct wil_rx_status_compressed *)msg)->buff_id;
4307be13fc3SGidon Studinski }
4317be13fc3SGidon Studinski
wil_rx_status_get_data_offset(void * msg)4327be13fc3SGidon Studinski static inline u8 wil_rx_status_get_data_offset(void *msg)
4337be13fc3SGidon Studinski {
4347be13fc3SGidon Studinski u8 val = WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
4357be13fc3SGidon Studinski 24, 27);
4367be13fc3SGidon Studinski
4377be13fc3SGidon Studinski switch (val) {
4387be13fc3SGidon Studinski case 0: return 0;
4397be13fc3SGidon Studinski case 3: return 2;
4407be13fc3SGidon Studinski default: return 0xFF;
4417be13fc3SGidon Studinski }
4427be13fc3SGidon Studinski }
4437be13fc3SGidon Studinski
wil_rx_status_get_frame_type(struct wil6210_priv * wil,void * msg)4447be13fc3SGidon Studinski static inline int wil_rx_status_get_frame_type(struct wil6210_priv *wil,
4457be13fc3SGidon Studinski void *msg)
4467be13fc3SGidon Studinski {
4477be13fc3SGidon Studinski if (wil->use_compressed_rx_status)
4487be13fc3SGidon Studinski return IEEE80211_FTYPE_DATA;
4497be13fc3SGidon Studinski
4507be13fc3SGidon Studinski return WIL_GET_BITS(((struct wil_rx_status_extended *)msg)->ext.d1,
4517be13fc3SGidon Studinski 0, 1) << 2;
4527be13fc3SGidon Studinski }
4537be13fc3SGidon Studinski
wil_rx_status_get_fc1(struct wil6210_priv * wil,void * msg)4547be13fc3SGidon Studinski static inline int wil_rx_status_get_fc1(struct wil6210_priv *wil, void *msg)
4557be13fc3SGidon Studinski {
4567be13fc3SGidon Studinski if (wil->use_compressed_rx_status)
4577be13fc3SGidon Studinski return 0;
4587be13fc3SGidon Studinski
4597be13fc3SGidon Studinski return WIL_GET_BITS(((struct wil_rx_status_extended *)msg)->ext.d1,
4607be13fc3SGidon Studinski 0, 5) << 2;
4617be13fc3SGidon Studinski }
4627be13fc3SGidon Studinski
wil_rx_status_get_seq(struct wil6210_priv * wil,void * msg)4637be13fc3SGidon Studinski static inline __le16 wil_rx_status_get_seq(struct wil6210_priv *wil, void *msg)
4647be13fc3SGidon Studinski {
4657be13fc3SGidon Studinski if (wil->use_compressed_rx_status)
4667be13fc3SGidon Studinski return 0;
4677be13fc3SGidon Studinski
4687be13fc3SGidon Studinski return ((struct wil_rx_status_extended *)msg)->ext.seq_num;
4697be13fc3SGidon Studinski }
4707be13fc3SGidon Studinski
wil_rx_status_get_retry(void * msg)4711bd82ee0SDedy Lansky static inline u8 wil_rx_status_get_retry(void *msg)
4721bd82ee0SDedy Lansky {
4731bd82ee0SDedy Lansky /* retry bit is missing in EDMA HW. return 1 to be on the safe side */
4741bd82ee0SDedy Lansky return 1;
4751bd82ee0SDedy Lansky }
4761bd82ee0SDedy Lansky
wil_rx_status_get_mid(void * msg)4777be13fc3SGidon Studinski static inline int wil_rx_status_get_mid(void *msg)
4787be13fc3SGidon Studinski {
4797be13fc3SGidon Studinski if (!(((struct wil_rx_status_compressed *)msg)->d0 &
4807be13fc3SGidon Studinski WIL_RX_EDMA_MID_VALID_BIT))
4817be13fc3SGidon Studinski return 0; /* use the default MID */
4827be13fc3SGidon Studinski
4837be13fc3SGidon Studinski return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
48418beb61dSDedy Lansky 21, 22);
4857be13fc3SGidon Studinski }
4867be13fc3SGidon Studinski
wil_rx_status_get_error(void * msg)4877be13fc3SGidon Studinski static inline int wil_rx_status_get_error(void *msg)
4887be13fc3SGidon Studinski {
4897be13fc3SGidon Studinski return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
4907be13fc3SGidon Studinski 29, 29);
4917be13fc3SGidon Studinski }
4927be13fc3SGidon Studinski
wil_rx_status_get_l2_rx_status(void * msg)4937be13fc3SGidon Studinski static inline int wil_rx_status_get_l2_rx_status(void *msg)
4947be13fc3SGidon Studinski {
4957be13fc3SGidon Studinski return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
4967be13fc3SGidon Studinski 0, 2);
4977be13fc3SGidon Studinski }
4987be13fc3SGidon Studinski
wil_rx_status_get_l3_rx_status(void * msg)4997be13fc3SGidon Studinski static inline int wil_rx_status_get_l3_rx_status(void *msg)
5007be13fc3SGidon Studinski {
5017be13fc3SGidon Studinski return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
5027be13fc3SGidon Studinski 3, 4);
5037be13fc3SGidon Studinski }
5047be13fc3SGidon Studinski
wil_rx_status_get_l4_rx_status(void * msg)5057be13fc3SGidon Studinski static inline int wil_rx_status_get_l4_rx_status(void *msg)
5067be13fc3SGidon Studinski {
5077be13fc3SGidon Studinski return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
5087be13fc3SGidon Studinski 5, 6);
5097be13fc3SGidon Studinski }
5107be13fc3SGidon Studinski
5114bf01986SAhmad Masri /* L4 L3 Expected result
5124bf01986SAhmad Masri * 0 0 Ok. No L3 and no L4 known protocols found.
5134bf01986SAhmad Masri * Treated as L2 packet. (no offloads on this packet)
5144bf01986SAhmad Masri * 0 1 Ok. It means that L3 was found, and checksum check passed.
5154bf01986SAhmad Masri * No known L4 protocol was found.
5164bf01986SAhmad Masri * 0 2 It means that L3 protocol was found, and checksum check failed.
5174bf01986SAhmad Masri * No L4 known protocol was found.
5184bf01986SAhmad Masri * 1 any Ok. It means that L4 was found, and checksum check passed.
5194bf01986SAhmad Masri * 3 0 Not a possible scenario.
5204bf01986SAhmad Masri * 3 1 Recalculate. It means that L3 protocol was found, and checksum
5214bf01986SAhmad Masri * passed. But L4 checksum failed. Need to see if really failed,
5224bf01986SAhmad Masri * or due to fragmentation.
5234bf01986SAhmad Masri * 3 2 Both L3 and L4 checksum check failed.
5244bf01986SAhmad Masri */
wil_rx_status_get_checksum(void * msg,struct wil_net_stats * stats)5254bf01986SAhmad Masri static inline int wil_rx_status_get_checksum(void *msg,
5264bf01986SAhmad Masri struct wil_net_stats *stats)
5274bf01986SAhmad Masri {
5284bf01986SAhmad Masri int l3_rx_status = wil_rx_status_get_l3_rx_status(msg);
5294bf01986SAhmad Masri int l4_rx_status = wil_rx_status_get_l4_rx_status(msg);
5304bf01986SAhmad Masri
5314bf01986SAhmad Masri if (l4_rx_status == 1)
5324bf01986SAhmad Masri return CHECKSUM_UNNECESSARY;
5334bf01986SAhmad Masri
5344bf01986SAhmad Masri if (l4_rx_status == 0 && l3_rx_status == 1)
5354bf01986SAhmad Masri return CHECKSUM_UNNECESSARY;
5364bf01986SAhmad Masri
5374bf01986SAhmad Masri if (l3_rx_status == 0 && l4_rx_status == 0)
5384bf01986SAhmad Masri /* L2 packet */
5394bf01986SAhmad Masri return CHECKSUM_NONE;
5404bf01986SAhmad Masri
5414bf01986SAhmad Masri /* If HW reports bad checksum, let IP stack re-check it
5424bf01986SAhmad Masri * For example, HW doesn't understand Microsoft IP stack that
5434bf01986SAhmad Masri * mis-calculates TCP checksum - if it should be 0x0,
5444bf01986SAhmad Masri * it writes 0xffff in violation of RFC 1624
5454bf01986SAhmad Masri */
5464bf01986SAhmad Masri stats->rx_csum_err++;
5474bf01986SAhmad Masri return CHECKSUM_NONE;
5484bf01986SAhmad Masri }
5494bf01986SAhmad Masri
wil_rx_status_get_security(void * msg)5507be13fc3SGidon Studinski static inline int wil_rx_status_get_security(void *msg)
5517be13fc3SGidon Studinski {
5527be13fc3SGidon Studinski return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
5537be13fc3SGidon Studinski 28, 28);
5547be13fc3SGidon Studinski }
5557be13fc3SGidon Studinski
wil_rx_status_get_key_id(void * msg)5567be13fc3SGidon Studinski static inline u8 wil_rx_status_get_key_id(void *msg)
5577be13fc3SGidon Studinski {
5587be13fc3SGidon Studinski return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
5597be13fc3SGidon Studinski 31, 31);
5607be13fc3SGidon Studinski }
5617be13fc3SGidon Studinski
wil_tx_status_get_mcs(struct wil_ring_tx_status * msg)5629202d7b6SMaya Erez static inline u8 wil_tx_status_get_mcs(struct wil_ring_tx_status *msg)
5639202d7b6SMaya Erez {
5649202d7b6SMaya Erez return WIL_GET_BITS(msg->d2, 0, 4);
5659202d7b6SMaya Erez }
56610590c6aSGidon Studinski
wil_ring_next_head(struct wil_ring * ring)56796c93589SGidon Studinski static inline u32 wil_ring_next_head(struct wil_ring *ring)
56896c93589SGidon Studinski {
56996c93589SGidon Studinski return (ring->swhead + 1) % ring->size;
57096c93589SGidon Studinski }
57196c93589SGidon Studinski
wil_desc_set_addr_edma(struct wil_ring_dma_addr * addr,__le16 * addr_high_high,dma_addr_t pa)57296c93589SGidon Studinski static inline void wil_desc_set_addr_edma(struct wil_ring_dma_addr *addr,
57396c93589SGidon Studinski __le16 *addr_high_high,
57496c93589SGidon Studinski dma_addr_t pa)
57596c93589SGidon Studinski {
57696c93589SGidon Studinski addr->addr_low = cpu_to_le32(lower_32_bits(pa));
57796c93589SGidon Studinski addr->addr_high = cpu_to_le16((u16)upper_32_bits(pa));
57896c93589SGidon Studinski *addr_high_high = cpu_to_le16((u16)(upper_32_bits(pa) >> 16));
57996c93589SGidon Studinski }
58096c93589SGidon Studinski
58196c93589SGidon Studinski static inline
wil_tx_desc_get_addr_edma(struct wil_ring_tx_enhanced_dma * dma)58296c93589SGidon Studinski dma_addr_t wil_tx_desc_get_addr_edma(struct wil_ring_tx_enhanced_dma *dma)
58396c93589SGidon Studinski {
58496c93589SGidon Studinski return le32_to_cpu(dma->addr.addr_low) |
58596c93589SGidon Studinski ((u64)le16_to_cpu(dma->addr.addr_high) << 32) |
58696c93589SGidon Studinski ((u64)le16_to_cpu(dma->addr_high_high) << 48);
58796c93589SGidon Studinski }
58896c93589SGidon Studinski
58996c93589SGidon Studinski static inline
wil_rx_desc_get_addr_edma(struct wil_ring_rx_enhanced_dma * dma)59096c93589SGidon Studinski dma_addr_t wil_rx_desc_get_addr_edma(struct wil_ring_rx_enhanced_dma *dma)
59196c93589SGidon Studinski {
59296c93589SGidon Studinski return le32_to_cpu(dma->addr.addr_low) |
59396c93589SGidon Studinski ((u64)le16_to_cpu(dma->addr.addr_high) << 32) |
59496c93589SGidon Studinski ((u64)le16_to_cpu(dma->addr_high_high) << 48);
59596c93589SGidon Studinski }
59696c93589SGidon Studinski
59796c93589SGidon Studinski void wil_configure_interrupt_moderation_edma(struct wil6210_priv *wil);
5989202d7b6SMaya Erez int wil_tx_sring_handler(struct wil6210_priv *wil,
5999202d7b6SMaya Erez struct wil_status_ring *sring);
6007be13fc3SGidon Studinski void wil_rx_handle_edma(struct wil6210_priv *wil, int *quota);
60196c93589SGidon Studinski void wil_init_txrx_ops_edma(struct wil6210_priv *wil);
60296c93589SGidon Studinski
60310590c6aSGidon Studinski #endif /* WIL6210_TXRX_EDMA_H */
60410590c6aSGidon Studinski
605