1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright 2008-2010 Cisco Systems, Inc. All rights reserved. 4 * Copyright 2007 Nuova Systems, Inc. All rights reserved. 5 */ 6 7 #ifndef _WQ_ENET_DESC_H_ 8 #define _WQ_ENET_DESC_H_ 9 10 /* Ethernet work queue descriptor: 16B */ 11 struct wq_enet_desc { 12 __le64 address; 13 __le16 length; 14 __le16 mss_loopback; 15 __le16 header_length_flags; 16 __le16 vlan_tag; 17 }; 18 19 #define WQ_ENET_ADDR_BITS 64 20 #define WQ_ENET_LEN_BITS 14 21 #define WQ_ENET_LEN_MASK ((1 << WQ_ENET_LEN_BITS) - 1) 22 #define WQ_ENET_MSS_BITS 14 23 #define WQ_ENET_MSS_MASK ((1 << WQ_ENET_MSS_BITS) - 1) 24 #define WQ_ENET_MSS_SHIFT 2 25 #define WQ_ENET_LOOPBACK_SHIFT 1 26 #define WQ_ENET_HDRLEN_BITS 10 27 #define WQ_ENET_HDRLEN_MASK ((1 << WQ_ENET_HDRLEN_BITS) - 1) 28 #define WQ_ENET_FLAGS_OM_BITS 2 29 #define WQ_ENET_FLAGS_OM_MASK ((1 << WQ_ENET_FLAGS_OM_BITS) - 1) 30 #define WQ_ENET_FLAGS_EOP_SHIFT 12 31 #define WQ_ENET_FLAGS_CQ_ENTRY_SHIFT 13 32 #define WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT 14 33 #define WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT 15 34 35 #define WQ_ENET_OFFLOAD_MODE_CSUM 0 36 #define WQ_ENET_OFFLOAD_MODE_RESERVED 1 37 #define WQ_ENET_OFFLOAD_MODE_CSUM_L4 2 38 #define WQ_ENET_OFFLOAD_MODE_TSO 3 39 40 static inline void wq_enet_desc_enc(struct wq_enet_desc *desc, 41 u64 address, u16 length, u16 mss, u16 header_length, 42 u8 offload_mode, u8 eop, u8 cq_entry, u8 fcoe_encap, 43 u8 vlan_tag_insert, u16 vlan_tag, u8 loopback) 44 { 45 desc->address = cpu_to_le64(address); 46 desc->length = cpu_to_le16(length & WQ_ENET_LEN_MASK); 47 desc->mss_loopback = cpu_to_le16((mss & WQ_ENET_MSS_MASK) << 48 WQ_ENET_MSS_SHIFT | (loopback & 1) << WQ_ENET_LOOPBACK_SHIFT); 49 desc->header_length_flags = cpu_to_le16( 50 (header_length & WQ_ENET_HDRLEN_MASK) | 51 (offload_mode & WQ_ENET_FLAGS_OM_MASK) << WQ_ENET_HDRLEN_BITS | 52 (eop & 1) << WQ_ENET_FLAGS_EOP_SHIFT | 53 (cq_entry & 1) << WQ_ENET_FLAGS_CQ_ENTRY_SHIFT | 54 (fcoe_encap & 1) << WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT | 55 (vlan_tag_insert & 1) << WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT); 56 desc->vlan_tag = cpu_to_le16(vlan_tag); 57 } 58 59 static inline void wq_enet_desc_dec(struct wq_enet_desc *desc, 60 u64 *address, u16 *length, u16 *mss, u16 *header_length, 61 u8 *offload_mode, u8 *eop, u8 *cq_entry, u8 *fcoe_encap, 62 u8 *vlan_tag_insert, u16 *vlan_tag, u8 *loopback) 63 { 64 *address = le64_to_cpu(desc->address); 65 *length = le16_to_cpu(desc->length) & WQ_ENET_LEN_MASK; 66 *mss = (le16_to_cpu(desc->mss_loopback) >> WQ_ENET_MSS_SHIFT) & 67 WQ_ENET_MSS_MASK; 68 *loopback = (u8)((le16_to_cpu(desc->mss_loopback) >> 69 WQ_ENET_LOOPBACK_SHIFT) & 1); 70 *header_length = le16_to_cpu(desc->header_length_flags) & 71 WQ_ENET_HDRLEN_MASK; 72 *offload_mode = (u8)((le16_to_cpu(desc->header_length_flags) >> 73 WQ_ENET_HDRLEN_BITS) & WQ_ENET_FLAGS_OM_MASK); 74 *eop = (u8)((le16_to_cpu(desc->header_length_flags) >> 75 WQ_ENET_FLAGS_EOP_SHIFT) & 1); 76 *cq_entry = (u8)((le16_to_cpu(desc->header_length_flags) >> 77 WQ_ENET_FLAGS_CQ_ENTRY_SHIFT) & 1); 78 *fcoe_encap = (u8)((le16_to_cpu(desc->header_length_flags) >> 79 WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT) & 1); 80 *vlan_tag_insert = (u8)((le16_to_cpu(desc->header_length_flags) >> 81 WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT) & 1); 82 *vlan_tag = le16_to_cpu(desc->vlan_tag); 83 } 84 85 #endif /* _WQ_ENET_DESC_H_ */ 86