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 _RQ_ENET_DESC_H_
7 #define _RQ_ENET_DESC_H_
9 #include <rte_byteorder.h>
11 /* Ethernet receive queue descriptor: 16B */
18 enum rq_enet_type_types {
19 RQ_ENET_TYPE_ONLY_SOP = 0,
20 RQ_ENET_TYPE_NOT_SOP = 1,
21 RQ_ENET_TYPE_RESV2 = 2,
22 RQ_ENET_TYPE_RESV3 = 3,
25 #define RQ_ENET_ADDR_BITS 64
26 #define RQ_ENET_LEN_BITS 14
27 #define RQ_ENET_LEN_MASK ((1 << RQ_ENET_LEN_BITS) - 1)
28 #define RQ_ENET_TYPE_BITS 2
29 #define RQ_ENET_TYPE_MASK ((1 << RQ_ENET_TYPE_BITS) - 1)
31 static inline void rq_enet_desc_enc(volatile struct rq_enet_desc *desc,
32 uint64_t address, uint8_t type, uint16_t length)
34 desc->address = rte_cpu_to_le_64(address);
35 desc->length_type = rte_cpu_to_le_16((length & RQ_ENET_LEN_MASK) |
36 ((type & RQ_ENET_TYPE_MASK) << RQ_ENET_LEN_BITS));
39 static inline void rq_enet_desc_dec(struct rq_enet_desc *desc,
40 uint64_t *address, uint8_t *type, uint16_t *length)
42 *address = rte_le_to_cpu_64(desc->address);
43 *length = rte_le_to_cpu_16(desc->length_type) & RQ_ENET_LEN_MASK;
44 *type = (uint8_t)((rte_le_to_cpu_16(desc->length_type) >>
45 RQ_ENET_LEN_BITS) & RQ_ENET_TYPE_MASK);
48 #endif /* _RQ_ENET_DESC_H_ */