162306a36Sopenharmony_ci/* SPDX-License-Identifier: ISC */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2012-2016 Qualcomm Atheros, Inc. 462306a36Sopenharmony_ci * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#ifndef WIL6210_TXRX_H 862306a36Sopenharmony_ci#define WIL6210_TXRX_H 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include "wil6210.h" 1162306a36Sopenharmony_ci#include "txrx_edma.h" 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#define BUF_SW_OWNED (1) 1462306a36Sopenharmony_ci#define BUF_HW_OWNED (0) 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/* default size of MAC Tx/Rx buffers */ 1762306a36Sopenharmony_ci#define TXRX_BUF_LEN_DEFAULT (2048) 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci/* how many bytes to reserve for rtap header? */ 2062306a36Sopenharmony_ci#define WIL6210_RTAP_SIZE (128) 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci/* Tx/Rx path */ 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_cistatic inline dma_addr_t wil_desc_addr(struct wil_ring_dma_addr *addr) 2562306a36Sopenharmony_ci{ 2662306a36Sopenharmony_ci return le32_to_cpu(addr->addr_low) | 2762306a36Sopenharmony_ci ((u64)le16_to_cpu(addr->addr_high) << 32); 2862306a36Sopenharmony_ci} 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_cistatic inline void wil_desc_addr_set(struct wil_ring_dma_addr *addr, 3162306a36Sopenharmony_ci dma_addr_t pa) 3262306a36Sopenharmony_ci{ 3362306a36Sopenharmony_ci addr->addr_low = cpu_to_le32(lower_32_bits(pa)); 3462306a36Sopenharmony_ci addr->addr_high = cpu_to_le16((u16)upper_32_bits(pa)); 3562306a36Sopenharmony_ci} 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci/* Tx descriptor - MAC part 3862306a36Sopenharmony_ci * [dword 0] 3962306a36Sopenharmony_ci * bit 0.. 9 : lifetime_expiry_value:10 4062306a36Sopenharmony_ci * bit 10 : interrupt_en:1 4162306a36Sopenharmony_ci * bit 11 : status_en:1 4262306a36Sopenharmony_ci * bit 12..13 : txss_override:2 4362306a36Sopenharmony_ci * bit 14 : timestamp_insertion:1 4462306a36Sopenharmony_ci * bit 15 : duration_preserve:1 4562306a36Sopenharmony_ci * bit 16..21 : reserved0:6 4662306a36Sopenharmony_ci * bit 22..26 : mcs_index:5 4762306a36Sopenharmony_ci * bit 27 : mcs_en:1 4862306a36Sopenharmony_ci * bit 28..30 : reserved1:3 4962306a36Sopenharmony_ci * bit 31 : sn_preserved:1 5062306a36Sopenharmony_ci * [dword 1] 5162306a36Sopenharmony_ci * bit 0.. 3 : pkt_mode:4 5262306a36Sopenharmony_ci * bit 4 : pkt_mode_en:1 5362306a36Sopenharmony_ci * bit 5 : mac_id_en:1 5462306a36Sopenharmony_ci * bit 6..7 : mac_id:2 5562306a36Sopenharmony_ci * bit 8..14 : reserved0:7 5662306a36Sopenharmony_ci * bit 15 : ack_policy_en:1 5762306a36Sopenharmony_ci * bit 16..19 : dst_index:4 5862306a36Sopenharmony_ci * bit 20 : dst_index_en:1 5962306a36Sopenharmony_ci * bit 21..22 : ack_policy:2 6062306a36Sopenharmony_ci * bit 23 : lifetime_en:1 6162306a36Sopenharmony_ci * bit 24..30 : max_retry:7 6262306a36Sopenharmony_ci * bit 31 : max_retry_en:1 6362306a36Sopenharmony_ci * [dword 2] 6462306a36Sopenharmony_ci * bit 0.. 7 : num_of_descriptors:8 6562306a36Sopenharmony_ci * bit 8..17 : reserved:10 6662306a36Sopenharmony_ci * bit 18..19 : l2_translation_type:2 00 - bypass, 01 - 802.3, 10 - 802.11 6762306a36Sopenharmony_ci * bit 20 : snap_hdr_insertion_en:1 6862306a36Sopenharmony_ci * bit 21 : vlan_removal_en:1 6962306a36Sopenharmony_ci * bit 22..31 : reserved0:10 7062306a36Sopenharmony_ci * [dword 3] 7162306a36Sopenharmony_ci * bit 0.. 31: ucode_cmd:32 7262306a36Sopenharmony_ci */ 7362306a36Sopenharmony_cistruct vring_tx_mac { 7462306a36Sopenharmony_ci u32 d[3]; 7562306a36Sopenharmony_ci u32 ucode_cmd; 7662306a36Sopenharmony_ci} __packed; 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci/* TX MAC Dword 0 */ 7962306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_LIFETIME_EXPIRY_VALUE_POS 0 8062306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_LIFETIME_EXPIRY_VALUE_LEN 10 8162306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_LIFETIME_EXPIRY_VALUE_MSK 0x3FF 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_INTERRUP_EN_POS 10 8462306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_INTERRUP_EN_LEN 1 8562306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_INTERRUP_EN_MSK 0x400 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_STATUS_EN_POS 11 8862306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_STATUS_EN_LEN 1 8962306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_STATUS_EN_MSK 0x800 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_TXSS_OVERRIDE_POS 12 9262306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_TXSS_OVERRIDE_LEN 2 9362306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_TXSS_OVERRIDE_MSK 0x3000 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_TIMESTAMP_INSERTION_POS 14 9662306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_TIMESTAMP_INSERTION_LEN 1 9762306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_TIMESTAMP_INSERTION_MSK 0x4000 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_DURATION_PRESERVE_POS 15 10062306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_DURATION_PRESERVE_LEN 1 10162306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_DURATION_PRESERVE_MSK 0x8000 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_MCS_INDEX_POS 22 10462306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_MCS_INDEX_LEN 5 10562306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_MCS_INDEX_MSK 0x7C00000 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_MCS_EN_POS 27 10862306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_MCS_EN_LEN 1 10962306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_MCS_EN_MSK 0x8000000 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_SN_PRESERVED_POS 31 11262306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_SN_PRESERVED_LEN 1 11362306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_0_SN_PRESERVED_MSK 0x80000000 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci/* TX MAC Dword 1 */ 11662306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_PKT_MODE_POS 0 11762306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_PKT_MODE_LEN 4 11862306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_PKT_MODE_MSK 0xF 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_PKT_MODE_EN_POS 4 12162306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_PKT_MODE_EN_LEN 1 12262306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_PKT_MODE_EN_MSK 0x10 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_MAC_ID_EN_POS 5 12562306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_MAC_ID_EN_LEN 1 12662306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_MAC_ID_EN_MSK 0x20 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_MAC_ID_POS 6 12962306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_MAC_ID_LEN 2 13062306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_MAC_ID_MSK 0xc0 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_ACK_POLICY_EN_POS 15 13362306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_ACK_POLICY_EN_LEN 1 13462306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_ACK_POLICY_EN_MSK 0x8000 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_DST_INDEX_POS 16 13762306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_DST_INDEX_LEN 4 13862306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_DST_INDEX_MSK 0xF0000 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_DST_INDEX_EN_POS 20 14162306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_DST_INDEX_EN_LEN 1 14262306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_DST_INDEX_EN_MSK 0x100000 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_ACK_POLICY_POS 21 14562306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_ACK_POLICY_LEN 2 14662306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_ACK_POLICY_MSK 0x600000 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_LIFETIME_EN_POS 23 14962306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_LIFETIME_EN_LEN 1 15062306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_LIFETIME_EN_MSK 0x800000 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_MAX_RETRY_POS 24 15362306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_MAX_RETRY_LEN 7 15462306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_MAX_RETRY_MSK 0x7F000000 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_MAX_RETRY_EN_POS 31 15762306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_MAX_RETRY_EN_LEN 1 15862306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_1_MAX_RETRY_EN_MSK 0x80000000 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci/* TX MAC Dword 2 */ 16162306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_NUM_OF_DESCRIPTORS_POS 0 16262306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_NUM_OF_DESCRIPTORS_LEN 8 16362306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_NUM_OF_DESCRIPTORS_MSK 0xFF 16462306a36Sopenharmony_ci 16562306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_RESERVED_POS 8 16662306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_RESERVED_LEN 10 16762306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_RESERVED_MSK 0x3FF00 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_L2_TRANSLATION_TYPE_POS 18 17062306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_L2_TRANSLATION_TYPE_LEN 2 17162306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_L2_TRANSLATION_TYPE_MSK 0xC0000 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_SNAP_HDR_INSERTION_EN_POS 20 17462306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_SNAP_HDR_INSERTION_EN_LEN 1 17562306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_SNAP_HDR_INSERTION_EN_MSK 0x100000 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_VLAN_REMOVAL_EN_POS 21 17862306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_VLAN_REMOVAL_EN_LEN 1 17962306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_2_VLAN_REMOVAL_EN_MSK 0x200000 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci/* TX MAC Dword 3 */ 18262306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_3_UCODE_CMD_POS 0 18362306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_3_UCODE_CMD_LEN 32 18462306a36Sopenharmony_ci#define MAC_CFG_DESC_TX_3_UCODE_CMD_MSK 0xFFFFFFFF 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_ci/* TX DMA Dword 0 */ 18762306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_L4_LENGTH_POS 0 18862306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_L4_LENGTH_LEN 8 18962306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_L4_LENGTH_MSK 0xFF 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_CMD_EOP_POS 8 19262306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_CMD_EOP_LEN 1 19362306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_CMD_EOP_MSK 0x100 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_CMD_MARK_WB_POS 9 19662306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_CMD_MARK_WB_LEN 1 19762306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_CMD_MARK_WB_MSK 0x200 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_CMD_DMA_IT_POS 10 20062306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_CMD_DMA_IT_LEN 1 20162306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_CMD_DMA_IT_MSK 0x400 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_SEGMENT_BUF_DETAILS_POS 11 20462306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_SEGMENT_BUF_DETAILS_LEN 2 20562306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_SEGMENT_BUF_DETAILS_MSK 0x1800 20662306a36Sopenharmony_ci 20762306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_TCP_SEG_EN_POS 13 20862306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_TCP_SEG_EN_LEN 1 20962306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_TCP_SEG_EN_MSK 0x2000 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_IPV4_CHECKSUM_EN_POS 14 21262306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_IPV4_CHECKSUM_EN_LEN 1 21362306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_IPV4_CHECKSUM_EN_MSK 0x4000 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_TCP_UDP_CHECKSUM_EN_POS 15 21662306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_TCP_UDP_CHECKSUM_EN_LEN 1 21762306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_TCP_UDP_CHECKSUM_EN_MSK 0x8000 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_QID_POS 16 22062306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_QID_LEN 5 22162306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_QID_MSK 0x1F0000 22262306a36Sopenharmony_ci 22362306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_PSEUDO_HEADER_CALC_EN_POS 21 22462306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_PSEUDO_HEADER_CALC_EN_LEN 1 22562306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_PSEUDO_HEADER_CALC_EN_MSK 0x200000 22662306a36Sopenharmony_ci 22762306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_L4_TYPE_POS 30 22862306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_L4_TYPE_LEN 2 22962306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_0_L4_TYPE_MSK 0xC0000000 /* L4 type: 0-UDP, 2-TCP */ 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_OFFLOAD_CFG_MAC_LEN_POS 0 23262306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_OFFLOAD_CFG_MAC_LEN_LEN 7 23362306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_OFFLOAD_CFG_MAC_LEN_MSK 0x7F /* MAC hdr len */ 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_OFFLOAD_CFG_L3T_IPV4_POS 7 23662306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_OFFLOAD_CFG_L3T_IPV4_LEN 1 23762306a36Sopenharmony_ci#define DMA_CFG_DESC_TX_OFFLOAD_CFG_L3T_IPV4_MSK 0x80 /* 1-IPv4, 0-IPv6 */ 23862306a36Sopenharmony_ci 23962306a36Sopenharmony_ci#define TX_DMA_STATUS_DU BIT(0) 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_ci/* Tx descriptor - DMA part 24262306a36Sopenharmony_ci * [dword 0] 24362306a36Sopenharmony_ci * bit 0.. 7 : l4_length:8 layer 4 length 24462306a36Sopenharmony_ci * bit 8 : cmd_eop:1 This descriptor is the last one in the packet 24562306a36Sopenharmony_ci * bit 9 : reserved 24662306a36Sopenharmony_ci * bit 10 : cmd_dma_it:1 immediate interrupt 24762306a36Sopenharmony_ci * bit 11..12 : SBD - Segment Buffer Details 24862306a36Sopenharmony_ci * 00 - Header Segment 24962306a36Sopenharmony_ci * 01 - First Data Segment 25062306a36Sopenharmony_ci * 10 - Medium Data Segment 25162306a36Sopenharmony_ci * 11 - Last Data Segment 25262306a36Sopenharmony_ci * bit 13 : TSE - TCP Segmentation Enable 25362306a36Sopenharmony_ci * bit 14 : IIC - Directs the HW to Insert IPv4 Checksum 25462306a36Sopenharmony_ci * bit 15 : ITC - Directs the HW to Insert TCP/UDP Checksum 25562306a36Sopenharmony_ci * bit 16..20 : QID - The target QID that the packet should be stored 25662306a36Sopenharmony_ci * in the MAC. 25762306a36Sopenharmony_ci * bit 21 : PO - Pseudo header Offload: 25862306a36Sopenharmony_ci * 0 - Use the pseudo header value from the TCP checksum field 25962306a36Sopenharmony_ci * 1- Calculate Pseudo header Checksum 26062306a36Sopenharmony_ci * bit 22 : NC - No UDP Checksum 26162306a36Sopenharmony_ci * bit 23..29 : reserved 26262306a36Sopenharmony_ci * bit 30..31 : L4T - Layer 4 Type: 00 - UDP , 10 - TCP , 10, 11 - Reserved 26362306a36Sopenharmony_ci * If L4Len equal 0, no L4 at all 26462306a36Sopenharmony_ci * [dword 1] 26562306a36Sopenharmony_ci * bit 0..31 : addr_low:32 The payload buffer low address 26662306a36Sopenharmony_ci * [dword 2] 26762306a36Sopenharmony_ci * bit 0..15 : addr_high:16 The payload buffer high address 26862306a36Sopenharmony_ci * bit 16..23 : ip_length:8 The IP header length for the TX IP checksum 26962306a36Sopenharmony_ci * offload feature 27062306a36Sopenharmony_ci * bit 24..30 : mac_length:7 27162306a36Sopenharmony_ci * bit 31 : ip_version:1 1 - IPv4, 0 - IPv6 27262306a36Sopenharmony_ci * [dword 3] 27362306a36Sopenharmony_ci * [byte 12] error 27462306a36Sopenharmony_ci * bit 0 2 : mac_status:3 27562306a36Sopenharmony_ci * bit 3 7 : reserved:5 27662306a36Sopenharmony_ci * [byte 13] status 27762306a36Sopenharmony_ci * bit 0 : DU:1 Descriptor Used 27862306a36Sopenharmony_ci * bit 1 7 : reserved:7 27962306a36Sopenharmony_ci * [word 7] length 28062306a36Sopenharmony_ci */ 28162306a36Sopenharmony_cistruct vring_tx_dma { 28262306a36Sopenharmony_ci u32 d0; 28362306a36Sopenharmony_ci struct wil_ring_dma_addr addr; 28462306a36Sopenharmony_ci u8 ip_length; 28562306a36Sopenharmony_ci u8 b11; /* 0..6: mac_length; 7:ip_version */ 28662306a36Sopenharmony_ci u8 error; /* 0..2: err; 3..7: reserved; */ 28762306a36Sopenharmony_ci u8 status; /* 0: used; 1..7; reserved */ 28862306a36Sopenharmony_ci __le16 length; 28962306a36Sopenharmony_ci} __packed; 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci/* TSO type used in dma descriptor d0 bits 11-12 */ 29262306a36Sopenharmony_cienum { 29362306a36Sopenharmony_ci wil_tso_type_hdr = 0, 29462306a36Sopenharmony_ci wil_tso_type_first = 1, 29562306a36Sopenharmony_ci wil_tso_type_mid = 2, 29662306a36Sopenharmony_ci wil_tso_type_lst = 3, 29762306a36Sopenharmony_ci}; 29862306a36Sopenharmony_ci 29962306a36Sopenharmony_ci/* Rx descriptor - MAC part 30062306a36Sopenharmony_ci * [dword 0] 30162306a36Sopenharmony_ci * bit 0.. 3 : tid:4 The QoS (b3-0) TID Field 30262306a36Sopenharmony_ci * bit 4.. 6 : cid:3 The Source index that was found during parsing the TA. 30362306a36Sopenharmony_ci * This field is used to define the source of the packet 30462306a36Sopenharmony_ci * bit 7 : MAC_id_valid:1, 1 if MAC virtual number is valid. 30562306a36Sopenharmony_ci * bit 8.. 9 : mid:2 The MAC virtual number 30662306a36Sopenharmony_ci * bit 10..11 : frame_type:2 : The FC (b3-2) - MPDU Type 30762306a36Sopenharmony_ci * (management, data, control and extension) 30862306a36Sopenharmony_ci * bit 12..15 : frame_subtype:4 : The FC (b7-4) - Frame Subtype 30962306a36Sopenharmony_ci * bit 16..27 : seq_number:12 The received Sequence number field 31062306a36Sopenharmony_ci * bit 28..31 : extended:4 extended subtype 31162306a36Sopenharmony_ci * [dword 1] 31262306a36Sopenharmony_ci * bit 0.. 3 : reserved 31362306a36Sopenharmony_ci * bit 4.. 5 : key_id:2 31462306a36Sopenharmony_ci * bit 6 : decrypt_bypass:1 31562306a36Sopenharmony_ci * bit 7 : security:1 FC (b14) 31662306a36Sopenharmony_ci * bit 8.. 9 : ds_bits:2 FC (b9-8) 31762306a36Sopenharmony_ci * bit 10 : a_msdu_present:1 QoS (b7) 31862306a36Sopenharmony_ci * bit 11 : a_msdu_type:1 QoS (b8) 31962306a36Sopenharmony_ci * bit 12 : a_mpdu:1 part of AMPDU aggregation 32062306a36Sopenharmony_ci * bit 13 : broadcast:1 32162306a36Sopenharmony_ci * bit 14 : mutlicast:1 32262306a36Sopenharmony_ci * bit 15 : reserved:1 32362306a36Sopenharmony_ci * bit 16..20 : rx_mac_qid:5 The Queue Identifier that the packet 32462306a36Sopenharmony_ci * is received from 32562306a36Sopenharmony_ci * bit 21..24 : mcs:4 32662306a36Sopenharmony_ci * bit 25..28 : mic_icr:4 this signal tells the DMA to assert an interrupt 32762306a36Sopenharmony_ci * after it writes the packet 32862306a36Sopenharmony_ci * bit 29..31 : reserved:3 32962306a36Sopenharmony_ci * [dword 2] 33062306a36Sopenharmony_ci * bit 0.. 2 : time_slot:3 The timeslot that the MPDU is received 33162306a36Sopenharmony_ci * bit 3.. 4 : fc_protocol_ver:1 The FC (b1-0) - Protocol Version 33262306a36Sopenharmony_ci * bit 5 : fc_order:1 The FC Control (b15) -Order 33362306a36Sopenharmony_ci * bit 6.. 7 : qos_ack_policy:2 The QoS (b6-5) ack policy Field 33462306a36Sopenharmony_ci * bit 8 : esop:1 The QoS (b4) ESOP field 33562306a36Sopenharmony_ci * bit 9 : qos_rdg_more_ppdu:1 The QoS (b9) RDG field 33662306a36Sopenharmony_ci * bit 10..14 : qos_reserved:5 The QoS (b14-10) Reserved field 33762306a36Sopenharmony_ci * bit 15 : qos_ac_constraint:1 QoS (b15) 33862306a36Sopenharmony_ci * bit 16..31 : pn_15_0:16 low 2 bytes of PN 33962306a36Sopenharmony_ci * [dword 3] 34062306a36Sopenharmony_ci * bit 0..31 : pn_47_16:32 high 4 bytes of PN 34162306a36Sopenharmony_ci */ 34262306a36Sopenharmony_cistruct vring_rx_mac { 34362306a36Sopenharmony_ci u32 d0; 34462306a36Sopenharmony_ci u32 d1; 34562306a36Sopenharmony_ci u16 w4; 34662306a36Sopenharmony_ci struct_group_attr(pn, __packed, 34762306a36Sopenharmony_ci u16 pn_15_0; 34862306a36Sopenharmony_ci u32 pn_47_16; 34962306a36Sopenharmony_ci ); 35062306a36Sopenharmony_ci} __packed; 35162306a36Sopenharmony_ci 35262306a36Sopenharmony_ci/* Rx descriptor - DMA part 35362306a36Sopenharmony_ci * [dword 0] 35462306a36Sopenharmony_ci * bit 0.. 7 : l4_length:8 layer 4 length. The field is only valid if 35562306a36Sopenharmony_ci * L4I bit is set 35662306a36Sopenharmony_ci * bit 8 : cmd_eop:1 set to 1 35762306a36Sopenharmony_ci * bit 9 : cmd_rt:1 set to 1 35862306a36Sopenharmony_ci * bit 10 : cmd_dma_it:1 immediate interrupt 35962306a36Sopenharmony_ci * bit 11..15 : reserved:5 36062306a36Sopenharmony_ci * bit 16..29 : phy_info_length:14 It is valid when the PII is set. 36162306a36Sopenharmony_ci * When the FFM bit is set bits 29-27 are used for 36262306a36Sopenharmony_ci * Flex Filter Match. Matching Index to one of the L2 36362306a36Sopenharmony_ci * EtherType Flex Filter 36462306a36Sopenharmony_ci * bit 30..31 : l4_type:2 valid if the L4I bit is set in the status field 36562306a36Sopenharmony_ci * 00 - UDP, 01 - TCP, 10, 11 - reserved 36662306a36Sopenharmony_ci * [dword 1] 36762306a36Sopenharmony_ci * bit 0..31 : addr_low:32 The payload buffer low address 36862306a36Sopenharmony_ci * [dword 2] 36962306a36Sopenharmony_ci * bit 0..15 : addr_high:16 The payload buffer high address 37062306a36Sopenharmony_ci * bit 16..23 : ip_length:8 The filed is valid only if the L3I bit is set 37162306a36Sopenharmony_ci * bit 24..30 : mac_length:7 37262306a36Sopenharmony_ci * bit 31 : ip_version:1 1 - IPv4, 0 - IPv6 37362306a36Sopenharmony_ci * [dword 3] 37462306a36Sopenharmony_ci * [byte 12] error 37562306a36Sopenharmony_ci * bit 0 : FCS:1 37662306a36Sopenharmony_ci * bit 1 : MIC:1 37762306a36Sopenharmony_ci * bit 2 : Key miss:1 37862306a36Sopenharmony_ci * bit 3 : Replay:1 37962306a36Sopenharmony_ci * bit 4 : L3:1 IPv4 checksum 38062306a36Sopenharmony_ci * bit 5 : L4:1 TCP/UDP checksum 38162306a36Sopenharmony_ci * bit 6 7 : reserved:2 38262306a36Sopenharmony_ci * [byte 13] status 38362306a36Sopenharmony_ci * bit 0 : DU:1 Descriptor Used 38462306a36Sopenharmony_ci * bit 1 : EOP:1 The descriptor indicates the End of Packet 38562306a36Sopenharmony_ci * bit 2 : error:1 38662306a36Sopenharmony_ci * bit 3 : MI:1 MAC Interrupt is asserted (according to parser decision) 38762306a36Sopenharmony_ci * bit 4 : L3I:1 L3 identified and checksum calculated 38862306a36Sopenharmony_ci * bit 5 : L4I:1 L4 identified and checksum calculated 38962306a36Sopenharmony_ci * bit 6 : PII:1 PHY Info Included in the packet 39062306a36Sopenharmony_ci * bit 7 : FFM:1 EtherType Flex Filter Match 39162306a36Sopenharmony_ci * [word 7] length 39262306a36Sopenharmony_ci */ 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_ci#define RX_DMA_D0_CMD_DMA_EOP BIT(8) 39562306a36Sopenharmony_ci#define RX_DMA_D0_CMD_DMA_RT BIT(9) /* always 1 */ 39662306a36Sopenharmony_ci#define RX_DMA_D0_CMD_DMA_IT BIT(10) /* interrupt */ 39762306a36Sopenharmony_ci#define RX_MAC_D0_MAC_ID_VALID BIT(7) 39862306a36Sopenharmony_ci 39962306a36Sopenharmony_ci/* Error field */ 40062306a36Sopenharmony_ci#define RX_DMA_ERROR_FCS BIT(0) 40162306a36Sopenharmony_ci#define RX_DMA_ERROR_MIC BIT(1) 40262306a36Sopenharmony_ci#define RX_DMA_ERROR_KEY BIT(2) /* Key missing */ 40362306a36Sopenharmony_ci#define RX_DMA_ERROR_REPLAY BIT(3) 40462306a36Sopenharmony_ci#define RX_DMA_ERROR_L3_ERR BIT(4) 40562306a36Sopenharmony_ci#define RX_DMA_ERROR_L4_ERR BIT(5) 40662306a36Sopenharmony_ci 40762306a36Sopenharmony_ci/* Status field */ 40862306a36Sopenharmony_ci#define RX_DMA_STATUS_DU BIT(0) 40962306a36Sopenharmony_ci#define RX_DMA_STATUS_EOP BIT(1) 41062306a36Sopenharmony_ci#define RX_DMA_STATUS_ERROR BIT(2) 41162306a36Sopenharmony_ci#define RX_DMA_STATUS_MI BIT(3) /* MAC Interrupt is asserted */ 41262306a36Sopenharmony_ci#define RX_DMA_STATUS_L3I BIT(4) 41362306a36Sopenharmony_ci#define RX_DMA_STATUS_L4I BIT(5) 41462306a36Sopenharmony_ci#define RX_DMA_STATUS_PHY_INFO BIT(6) 41562306a36Sopenharmony_ci#define RX_DMA_STATUS_FFM BIT(7) /* EtherType Flex Filter Match */ 41662306a36Sopenharmony_ci 41762306a36Sopenharmony_ci/* IEEE 802.11, 8.5.2 EAPOL-Key frames */ 41862306a36Sopenharmony_ci#define WIL_KEY_INFO_KEY_TYPE BIT(3) /* val of 1 = Pairwise, 0 = Group key */ 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_ci#define WIL_KEY_INFO_MIC BIT(8) 42162306a36Sopenharmony_ci#define WIL_KEY_INFO_ENCR_KEY_DATA BIT(12) /* for rsn only */ 42262306a36Sopenharmony_ci 42362306a36Sopenharmony_ci#define WIL_EAP_NONCE_LEN 32 42462306a36Sopenharmony_ci#define WIL_EAP_KEY_RSC_LEN 8 42562306a36Sopenharmony_ci#define WIL_EAP_REPLAY_COUNTER_LEN 8 42662306a36Sopenharmony_ci#define WIL_EAP_KEY_IV_LEN 16 42762306a36Sopenharmony_ci#define WIL_EAP_KEY_ID_LEN 8 42862306a36Sopenharmony_ci 42962306a36Sopenharmony_cienum { 43062306a36Sopenharmony_ci WIL_1X_TYPE_EAP_PACKET = 0, 43162306a36Sopenharmony_ci WIL_1X_TYPE_EAPOL_START = 1, 43262306a36Sopenharmony_ci WIL_1X_TYPE_EAPOL_LOGOFF = 2, 43362306a36Sopenharmony_ci WIL_1X_TYPE_EAPOL_KEY = 3, 43462306a36Sopenharmony_ci}; 43562306a36Sopenharmony_ci 43662306a36Sopenharmony_ci#define WIL_EAPOL_KEY_TYPE_RSN 2 43762306a36Sopenharmony_ci#define WIL_EAPOL_KEY_TYPE_WPA 254 43862306a36Sopenharmony_ci 43962306a36Sopenharmony_cistruct wil_1x_hdr { 44062306a36Sopenharmony_ci u8 version; 44162306a36Sopenharmony_ci u8 type; 44262306a36Sopenharmony_ci __be16 length; 44362306a36Sopenharmony_ci /* followed by data */ 44462306a36Sopenharmony_ci} __packed; 44562306a36Sopenharmony_ci 44662306a36Sopenharmony_cistruct wil_eapol_key { 44762306a36Sopenharmony_ci u8 type; 44862306a36Sopenharmony_ci __be16 key_info; 44962306a36Sopenharmony_ci __be16 key_length; 45062306a36Sopenharmony_ci u8 replay_counter[WIL_EAP_REPLAY_COUNTER_LEN]; 45162306a36Sopenharmony_ci u8 key_nonce[WIL_EAP_NONCE_LEN]; 45262306a36Sopenharmony_ci u8 key_iv[WIL_EAP_KEY_IV_LEN]; 45362306a36Sopenharmony_ci u8 key_rsc[WIL_EAP_KEY_RSC_LEN]; 45462306a36Sopenharmony_ci u8 key_id[WIL_EAP_KEY_ID_LEN]; 45562306a36Sopenharmony_ci} __packed; 45662306a36Sopenharmony_ci 45762306a36Sopenharmony_cistruct vring_rx_dma { 45862306a36Sopenharmony_ci u32 d0; 45962306a36Sopenharmony_ci struct wil_ring_dma_addr addr; 46062306a36Sopenharmony_ci u8 ip_length; 46162306a36Sopenharmony_ci u8 b11; 46262306a36Sopenharmony_ci u8 error; 46362306a36Sopenharmony_ci u8 status; 46462306a36Sopenharmony_ci __le16 length; 46562306a36Sopenharmony_ci} __packed; 46662306a36Sopenharmony_ci 46762306a36Sopenharmony_cistruct vring_tx_desc { 46862306a36Sopenharmony_ci struct vring_tx_mac mac; 46962306a36Sopenharmony_ci struct vring_tx_dma dma; 47062306a36Sopenharmony_ci} __packed; 47162306a36Sopenharmony_ci 47262306a36Sopenharmony_ciunion wil_tx_desc { 47362306a36Sopenharmony_ci struct vring_tx_desc legacy; 47462306a36Sopenharmony_ci struct wil_tx_enhanced_desc enhanced; 47562306a36Sopenharmony_ci} __packed; 47662306a36Sopenharmony_ci 47762306a36Sopenharmony_cistruct vring_rx_desc { 47862306a36Sopenharmony_ci struct vring_rx_mac mac; 47962306a36Sopenharmony_ci struct vring_rx_dma dma; 48062306a36Sopenharmony_ci} __packed; 48162306a36Sopenharmony_ci 48262306a36Sopenharmony_ciunion wil_rx_desc { 48362306a36Sopenharmony_ci struct vring_rx_desc legacy; 48462306a36Sopenharmony_ci struct wil_rx_enhanced_desc enhanced; 48562306a36Sopenharmony_ci} __packed; 48662306a36Sopenharmony_ci 48762306a36Sopenharmony_ciunion wil_ring_desc { 48862306a36Sopenharmony_ci union wil_tx_desc tx; 48962306a36Sopenharmony_ci union wil_rx_desc rx; 49062306a36Sopenharmony_ci} __packed; 49162306a36Sopenharmony_ci 49262306a36Sopenharmony_cistruct packet_rx_info { 49362306a36Sopenharmony_ci u8 cid; 49462306a36Sopenharmony_ci}; 49562306a36Sopenharmony_ci 49662306a36Sopenharmony_ci/* this struct will be stored in the skb cb buffer 49762306a36Sopenharmony_ci * max length of the struct is limited to 48 bytes 49862306a36Sopenharmony_ci */ 49962306a36Sopenharmony_cistruct skb_rx_info { 50062306a36Sopenharmony_ci struct vring_rx_desc rx_desc; 50162306a36Sopenharmony_ci struct packet_rx_info rx_info; 50262306a36Sopenharmony_ci}; 50362306a36Sopenharmony_ci 50462306a36Sopenharmony_cistatic inline int wil_rxdesc_tid(struct vring_rx_desc *d) 50562306a36Sopenharmony_ci{ 50662306a36Sopenharmony_ci return WIL_GET_BITS(d->mac.d0, 0, 3); 50762306a36Sopenharmony_ci} 50862306a36Sopenharmony_ci 50962306a36Sopenharmony_cistatic inline int wil_rxdesc_cid(struct vring_rx_desc *d) 51062306a36Sopenharmony_ci{ 51162306a36Sopenharmony_ci return WIL_GET_BITS(d->mac.d0, 4, 6); 51262306a36Sopenharmony_ci} 51362306a36Sopenharmony_ci 51462306a36Sopenharmony_cistatic inline int wil_rxdesc_mid(struct vring_rx_desc *d) 51562306a36Sopenharmony_ci{ 51662306a36Sopenharmony_ci return (d->mac.d0 & RX_MAC_D0_MAC_ID_VALID) ? 51762306a36Sopenharmony_ci WIL_GET_BITS(d->mac.d0, 8, 9) : 0; 51862306a36Sopenharmony_ci} 51962306a36Sopenharmony_ci 52062306a36Sopenharmony_cistatic inline int wil_rxdesc_ftype(struct vring_rx_desc *d) 52162306a36Sopenharmony_ci{ 52262306a36Sopenharmony_ci return WIL_GET_BITS(d->mac.d0, 10, 11); 52362306a36Sopenharmony_ci} 52462306a36Sopenharmony_ci 52562306a36Sopenharmony_cistatic inline int wil_rxdesc_subtype(struct vring_rx_desc *d) 52662306a36Sopenharmony_ci{ 52762306a36Sopenharmony_ci return WIL_GET_BITS(d->mac.d0, 12, 15); 52862306a36Sopenharmony_ci} 52962306a36Sopenharmony_ci 53062306a36Sopenharmony_ci/* 1-st byte (with frame type/subtype) of FC field */ 53162306a36Sopenharmony_cistatic inline u8 wil_rxdesc_fc1(struct vring_rx_desc *d) 53262306a36Sopenharmony_ci{ 53362306a36Sopenharmony_ci return (u8)(WIL_GET_BITS(d->mac.d0, 10, 15) << 2); 53462306a36Sopenharmony_ci} 53562306a36Sopenharmony_ci 53662306a36Sopenharmony_cistatic inline int wil_rxdesc_seq(struct vring_rx_desc *d) 53762306a36Sopenharmony_ci{ 53862306a36Sopenharmony_ci return WIL_GET_BITS(d->mac.d0, 16, 27); 53962306a36Sopenharmony_ci} 54062306a36Sopenharmony_ci 54162306a36Sopenharmony_cistatic inline int wil_rxdesc_ext_subtype(struct vring_rx_desc *d) 54262306a36Sopenharmony_ci{ 54362306a36Sopenharmony_ci return WIL_GET_BITS(d->mac.d0, 28, 31); 54462306a36Sopenharmony_ci} 54562306a36Sopenharmony_ci 54662306a36Sopenharmony_cistatic inline int wil_rxdesc_retry(struct vring_rx_desc *d) 54762306a36Sopenharmony_ci{ 54862306a36Sopenharmony_ci return WIL_GET_BITS(d->mac.d0, 31, 31); 54962306a36Sopenharmony_ci} 55062306a36Sopenharmony_ci 55162306a36Sopenharmony_cistatic inline int wil_rxdesc_key_id(struct vring_rx_desc *d) 55262306a36Sopenharmony_ci{ 55362306a36Sopenharmony_ci return WIL_GET_BITS(d->mac.d1, 4, 5); 55462306a36Sopenharmony_ci} 55562306a36Sopenharmony_ci 55662306a36Sopenharmony_cistatic inline int wil_rxdesc_security(struct vring_rx_desc *d) 55762306a36Sopenharmony_ci{ 55862306a36Sopenharmony_ci return WIL_GET_BITS(d->mac.d1, 7, 7); 55962306a36Sopenharmony_ci} 56062306a36Sopenharmony_ci 56162306a36Sopenharmony_cistatic inline int wil_rxdesc_ds_bits(struct vring_rx_desc *d) 56262306a36Sopenharmony_ci{ 56362306a36Sopenharmony_ci return WIL_GET_BITS(d->mac.d1, 8, 9); 56462306a36Sopenharmony_ci} 56562306a36Sopenharmony_ci 56662306a36Sopenharmony_cistatic inline int wil_rxdesc_mcs(struct vring_rx_desc *d) 56762306a36Sopenharmony_ci{ 56862306a36Sopenharmony_ci return WIL_GET_BITS(d->mac.d1, 21, 24); 56962306a36Sopenharmony_ci} 57062306a36Sopenharmony_ci 57162306a36Sopenharmony_cistatic inline int wil_rxdesc_mcast(struct vring_rx_desc *d) 57262306a36Sopenharmony_ci{ 57362306a36Sopenharmony_ci return WIL_GET_BITS(d->mac.d1, 13, 14); 57462306a36Sopenharmony_ci} 57562306a36Sopenharmony_ci 57662306a36Sopenharmony_cistatic inline struct vring_rx_desc *wil_skb_rxdesc(struct sk_buff *skb) 57762306a36Sopenharmony_ci{ 57862306a36Sopenharmony_ci return (void *)skb->cb; 57962306a36Sopenharmony_ci} 58062306a36Sopenharmony_ci 58162306a36Sopenharmony_cistatic inline int wil_ring_is_empty(struct wil_ring *ring) 58262306a36Sopenharmony_ci{ 58362306a36Sopenharmony_ci return ring->swhead == ring->swtail; 58462306a36Sopenharmony_ci} 58562306a36Sopenharmony_ci 58662306a36Sopenharmony_cistatic inline u32 wil_ring_next_tail(struct wil_ring *ring) 58762306a36Sopenharmony_ci{ 58862306a36Sopenharmony_ci return (ring->swtail + 1) % ring->size; 58962306a36Sopenharmony_ci} 59062306a36Sopenharmony_ci 59162306a36Sopenharmony_cistatic inline void wil_ring_advance_head(struct wil_ring *ring, int n) 59262306a36Sopenharmony_ci{ 59362306a36Sopenharmony_ci ring->swhead = (ring->swhead + n) % ring->size; 59462306a36Sopenharmony_ci} 59562306a36Sopenharmony_ci 59662306a36Sopenharmony_cistatic inline int wil_ring_is_full(struct wil_ring *ring) 59762306a36Sopenharmony_ci{ 59862306a36Sopenharmony_ci return wil_ring_next_tail(ring) == ring->swhead; 59962306a36Sopenharmony_ci} 60062306a36Sopenharmony_ci 60162306a36Sopenharmony_cistatic inline u8 *wil_skb_get_da(struct sk_buff *skb) 60262306a36Sopenharmony_ci{ 60362306a36Sopenharmony_ci struct ethhdr *eth = (void *)skb->data; 60462306a36Sopenharmony_ci 60562306a36Sopenharmony_ci return eth->h_dest; 60662306a36Sopenharmony_ci} 60762306a36Sopenharmony_ci 60862306a36Sopenharmony_cistatic inline u8 *wil_skb_get_sa(struct sk_buff *skb) 60962306a36Sopenharmony_ci{ 61062306a36Sopenharmony_ci struct ethhdr *eth = (void *)skb->data; 61162306a36Sopenharmony_ci 61262306a36Sopenharmony_ci return eth->h_source; 61362306a36Sopenharmony_ci} 61462306a36Sopenharmony_ci 61562306a36Sopenharmony_cistatic inline bool wil_need_txstat(struct sk_buff *skb) 61662306a36Sopenharmony_ci{ 61762306a36Sopenharmony_ci const u8 *da = wil_skb_get_da(skb); 61862306a36Sopenharmony_ci 61962306a36Sopenharmony_ci return is_unicast_ether_addr(da) && skb->sk && 62062306a36Sopenharmony_ci (skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS); 62162306a36Sopenharmony_ci} 62262306a36Sopenharmony_ci 62362306a36Sopenharmony_cistatic inline void wil_consume_skb(struct sk_buff *skb, bool acked) 62462306a36Sopenharmony_ci{ 62562306a36Sopenharmony_ci if (unlikely(wil_need_txstat(skb))) 62662306a36Sopenharmony_ci skb_complete_wifi_ack(skb, acked); 62762306a36Sopenharmony_ci else 62862306a36Sopenharmony_ci acked ? dev_consume_skb_any(skb) : dev_kfree_skb_any(skb); 62962306a36Sopenharmony_ci} 63062306a36Sopenharmony_ci 63162306a36Sopenharmony_ci/* Used space in Tx ring */ 63262306a36Sopenharmony_cistatic inline int wil_ring_used_tx(struct wil_ring *ring) 63362306a36Sopenharmony_ci{ 63462306a36Sopenharmony_ci u32 swhead = ring->swhead; 63562306a36Sopenharmony_ci u32 swtail = ring->swtail; 63662306a36Sopenharmony_ci 63762306a36Sopenharmony_ci return (ring->size + swhead - swtail) % ring->size; 63862306a36Sopenharmony_ci} 63962306a36Sopenharmony_ci 64062306a36Sopenharmony_ci/* Available space in Tx ring */ 64162306a36Sopenharmony_cistatic inline int wil_ring_avail_tx(struct wil_ring *ring) 64262306a36Sopenharmony_ci{ 64362306a36Sopenharmony_ci return ring->size - wil_ring_used_tx(ring) - 1; 64462306a36Sopenharmony_ci} 64562306a36Sopenharmony_ci 64662306a36Sopenharmony_cistatic inline int wil_get_min_tx_ring_id(struct wil6210_priv *wil) 64762306a36Sopenharmony_ci{ 64862306a36Sopenharmony_ci /* In Enhanced DMA ring 0 is reserved for RX */ 64962306a36Sopenharmony_ci return wil->use_enhanced_dma_hw ? 1 : 0; 65062306a36Sopenharmony_ci} 65162306a36Sopenharmony_ci 65262306a36Sopenharmony_ci/* similar to ieee80211_ version, but FC contain only 1-st byte */ 65362306a36Sopenharmony_cistatic inline int wil_is_back_req(u8 fc) 65462306a36Sopenharmony_ci{ 65562306a36Sopenharmony_ci return (fc & (IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 65662306a36Sopenharmony_ci (IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ); 65762306a36Sopenharmony_ci} 65862306a36Sopenharmony_ci 65962306a36Sopenharmony_ci/* wil_val_in_range - check if value in [min,max) */ 66062306a36Sopenharmony_cistatic inline bool wil_val_in_range(int val, int min, int max) 66162306a36Sopenharmony_ci{ 66262306a36Sopenharmony_ci return val >= min && val < max; 66362306a36Sopenharmony_ci} 66462306a36Sopenharmony_ci 66562306a36Sopenharmony_cistatic inline u8 wil_skb_get_cid(struct sk_buff *skb) 66662306a36Sopenharmony_ci{ 66762306a36Sopenharmony_ci struct skb_rx_info *skb_rx_info = (void *)skb->cb; 66862306a36Sopenharmony_ci 66962306a36Sopenharmony_ci return skb_rx_info->rx_info.cid; 67062306a36Sopenharmony_ci} 67162306a36Sopenharmony_ci 67262306a36Sopenharmony_cistatic inline void wil_skb_set_cid(struct sk_buff *skb, u8 cid) 67362306a36Sopenharmony_ci{ 67462306a36Sopenharmony_ci struct skb_rx_info *skb_rx_info = (void *)skb->cb; 67562306a36Sopenharmony_ci 67662306a36Sopenharmony_ci skb_rx_info->rx_info.cid = cid; 67762306a36Sopenharmony_ci} 67862306a36Sopenharmony_ci 67962306a36Sopenharmony_civoid wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev); 68062306a36Sopenharmony_civoid wil_netif_rx(struct sk_buff *skb, struct net_device *ndev, int cid, 68162306a36Sopenharmony_ci struct wil_net_stats *stats, bool gro); 68262306a36Sopenharmony_civoid wil_rx_reorder(struct wil6210_priv *wil, struct sk_buff *skb); 68362306a36Sopenharmony_civoid wil_rx_bar(struct wil6210_priv *wil, struct wil6210_vif *vif, 68462306a36Sopenharmony_ci u8 cid, u8 tid, u16 seq); 68562306a36Sopenharmony_cistruct wil_tid_ampdu_rx *wil_tid_ampdu_rx_alloc(struct wil6210_priv *wil, 68662306a36Sopenharmony_ci int size, u16 ssn); 68762306a36Sopenharmony_civoid wil_tid_ampdu_rx_free(struct wil6210_priv *wil, 68862306a36Sopenharmony_ci struct wil_tid_ampdu_rx *r); 68962306a36Sopenharmony_civoid wil_tx_data_init(struct wil_ring_tx_data *txdata); 69062306a36Sopenharmony_civoid wil_init_txrx_ops_legacy_dma(struct wil6210_priv *wil); 69162306a36Sopenharmony_civoid wil_tx_latency_calc(struct wil6210_priv *wil, struct sk_buff *skb, 69262306a36Sopenharmony_ci struct wil_sta_info *sta); 69362306a36Sopenharmony_ci 69462306a36Sopenharmony_ci#endif /* WIL6210_TXRX_H */ 695