1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2008-2017 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
6 #ifndef _WQ_ENET_DESC_H_
7 #define _WQ_ENET_DESC_H_
9 #include <rte_byteorder.h>
11 /* Ethernet work queue descriptor: 16B */
15 uint16_t mss_loopback;
16 uint16_t header_length_flags;
20 #define WQ_ENET_ADDR_BITS 64
21 #define WQ_ENET_LEN_BITS 14
22 #define WQ_ENET_LEN_MASK ((1 << WQ_ENET_LEN_BITS) - 1)
23 #define WQ_ENET_MSS_BITS 14
24 #define WQ_ENET_MSS_MASK ((1 << WQ_ENET_MSS_BITS) - 1)
25 #define WQ_ENET_MSS_SHIFT 2
26 #define WQ_ENET_LOOPBACK_SHIFT 1
27 #define WQ_ENET_HDRLEN_BITS 10
28 #define WQ_ENET_HDRLEN_MASK ((1 << WQ_ENET_HDRLEN_BITS) - 1)
29 #define WQ_ENET_FLAGS_OM_BITS 2
30 #define WQ_ENET_FLAGS_OM_MASK ((1 << WQ_ENET_FLAGS_OM_BITS) - 1)
31 #define WQ_ENET_FLAGS_EOP_SHIFT 12
32 #define WQ_ENET_FLAGS_CQ_ENTRY_SHIFT 13
33 #define WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT 14
34 #define WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT 15
36 #define WQ_ENET_OFFLOAD_MODE_CSUM 0
37 #define WQ_ENET_OFFLOAD_MODE_RESERVED 1
38 #define WQ_ENET_OFFLOAD_MODE_CSUM_L4 2
39 #define WQ_ENET_OFFLOAD_MODE_TSO 3
41 static inline void wq_enet_desc_enc(struct wq_enet_desc *desc,
42 uint64_t address, uint16_t length, uint16_t mss, uint16_t header_length,
43 uint8_t offload_mode, uint8_t eop, uint8_t cq_entry, uint8_t fcoe_encap,
44 uint8_t vlan_tag_insert, uint16_t vlan_tag, uint8_t loopback)
46 desc->address = rte_cpu_to_le_64(address);
47 desc->length = rte_cpu_to_le_16(length & WQ_ENET_LEN_MASK);
48 desc->mss_loopback = rte_cpu_to_le_16((mss & WQ_ENET_MSS_MASK) <<
49 WQ_ENET_MSS_SHIFT | (loopback & 1) << WQ_ENET_LOOPBACK_SHIFT);
50 desc->header_length_flags = rte_cpu_to_le_16
51 ((header_length & WQ_ENET_HDRLEN_MASK) |
52 (offload_mode & WQ_ENET_FLAGS_OM_MASK) << WQ_ENET_HDRLEN_BITS |
53 (eop & 1) << WQ_ENET_FLAGS_EOP_SHIFT |
54 (cq_entry & 1) << WQ_ENET_FLAGS_CQ_ENTRY_SHIFT |
55 (fcoe_encap & 1) << WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT |
56 (vlan_tag_insert & 1) << WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT);
57 desc->vlan_tag = rte_cpu_to_le_16(vlan_tag);
60 static inline void wq_enet_desc_dec(struct wq_enet_desc *desc,
61 uint64_t *address, uint16_t *length, uint16_t *mss,
62 uint16_t *header_length, uint8_t *offload_mode, uint8_t *eop,
63 uint8_t *cq_entry, uint8_t *fcoe_encap, uint8_t *vlan_tag_insert,
64 uint16_t *vlan_tag, uint8_t *loopback)
66 *address = rte_le_to_cpu_64(desc->address);
67 *length = rte_le_to_cpu_16(desc->length) & WQ_ENET_LEN_MASK;
68 *mss = (rte_le_to_cpu_16(desc->mss_loopback) >> WQ_ENET_MSS_SHIFT) &
70 *loopback = (uint8_t)((rte_le_to_cpu_16(desc->mss_loopback) >>
71 WQ_ENET_LOOPBACK_SHIFT) & 1);
72 *header_length = rte_le_to_cpu_16(desc->header_length_flags) &
75 (uint8_t)((rte_le_to_cpu_16(desc->header_length_flags) >>
76 WQ_ENET_HDRLEN_BITS) & WQ_ENET_FLAGS_OM_MASK);
77 *eop = (uint8_t)((rte_le_to_cpu_16(desc->header_length_flags) >>
78 WQ_ENET_FLAGS_EOP_SHIFT) & 1);
79 *cq_entry = (uint8_t)((rte_le_to_cpu_16(desc->header_length_flags) >>
80 WQ_ENET_FLAGS_CQ_ENTRY_SHIFT) & 1);
81 *fcoe_encap = (uint8_t)((rte_le_to_cpu_16(desc->header_length_flags) >>
82 WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT) & 1);
84 (uint8_t)((rte_le_to_cpu_16(desc->header_length_flags) >>
85 WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT) & 1);
86 *vlan_tag = rte_le_to_cpu_16(desc->vlan_tag);
89 #endif /* _WQ_ENET_DESC_H_ */