]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | /* SPDX-License-Identifier: BSD-3-Clause |
2 | * Copyright 2008-2017 Cisco Systems, Inc. All rights reserved. | |
7c673cae | 3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. |
7c673cae FG |
4 | */ |
5 | ||
6 | #ifndef _RQ_ENET_DESC_H_ | |
7 | #define _RQ_ENET_DESC_H_ | |
8 | ||
9 | /* Ethernet receive queue descriptor: 16B */ | |
10 | struct rq_enet_desc { | |
11 | __le64 address; | |
12 | __le16 length_type; | |
13 | u8 reserved[6]; | |
14 | }; | |
15 | ||
16 | enum rq_enet_type_types { | |
17 | RQ_ENET_TYPE_ONLY_SOP = 0, | |
18 | RQ_ENET_TYPE_NOT_SOP = 1, | |
19 | RQ_ENET_TYPE_RESV2 = 2, | |
20 | RQ_ENET_TYPE_RESV3 = 3, | |
21 | }; | |
22 | ||
23 | #define RQ_ENET_ADDR_BITS 64 | |
24 | #define RQ_ENET_LEN_BITS 14 | |
25 | #define RQ_ENET_LEN_MASK ((1 << RQ_ENET_LEN_BITS) - 1) | |
26 | #define RQ_ENET_TYPE_BITS 2 | |
27 | #define RQ_ENET_TYPE_MASK ((1 << RQ_ENET_TYPE_BITS) - 1) | |
28 | ||
29 | static inline void rq_enet_desc_enc(volatile struct rq_enet_desc *desc, | |
30 | u64 address, u8 type, u16 length) | |
31 | { | |
32 | desc->address = cpu_to_le64(address); | |
33 | desc->length_type = cpu_to_le16((length & RQ_ENET_LEN_MASK) | | |
34 | ((type & RQ_ENET_TYPE_MASK) << RQ_ENET_LEN_BITS)); | |
35 | } | |
36 | ||
37 | static inline void rq_enet_desc_dec(struct rq_enet_desc *desc, | |
38 | u64 *address, u8 *type, u16 *length) | |
39 | { | |
40 | *address = le64_to_cpu(desc->address); | |
41 | *length = le16_to_cpu(desc->length_type) & RQ_ENET_LEN_MASK; | |
42 | *type = (u8)((le16_to_cpu(desc->length_type) >> RQ_ENET_LEN_BITS) & | |
43 | RQ_ENET_TYPE_MASK); | |
44 | } | |
45 | ||
46 | #endif /* _RQ_ENET_DESC_H_ */ |