Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright 2008 Cisco Systems, Inc.  All rights reserved.
0004  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
0005  */
0006 #ifndef _RQ_ENET_DESC_H_
0007 #define _RQ_ENET_DESC_H_
0008 
0009 /* Ethernet receive queue descriptor: 16B */
0010 struct rq_enet_desc {
0011     __le64 address;
0012     __le16 length_type;
0013     u8 reserved[6];
0014 };
0015 
0016 enum rq_enet_type_types {
0017     RQ_ENET_TYPE_ONLY_SOP = 0,
0018     RQ_ENET_TYPE_NOT_SOP = 1,
0019     RQ_ENET_TYPE_RESV2 = 2,
0020     RQ_ENET_TYPE_RESV3 = 3,
0021 };
0022 
0023 #define RQ_ENET_ADDR_BITS       64
0024 #define RQ_ENET_LEN_BITS        14
0025 #define RQ_ENET_LEN_MASK        ((1 << RQ_ENET_LEN_BITS) - 1)
0026 #define RQ_ENET_TYPE_BITS       2
0027 #define RQ_ENET_TYPE_MASK       ((1 << RQ_ENET_TYPE_BITS) - 1)
0028 
0029 static inline void rq_enet_desc_enc(struct rq_enet_desc *desc,
0030     u64 address, u8 type, u16 length)
0031 {
0032     desc->address = cpu_to_le64(address);
0033     desc->length_type = cpu_to_le16((length & RQ_ENET_LEN_MASK) |
0034         ((type & RQ_ENET_TYPE_MASK) << RQ_ENET_LEN_BITS));
0035 }
0036 
0037 static inline void rq_enet_desc_dec(struct rq_enet_desc *desc,
0038     u64 *address, u8 *type, u16 *length)
0039 {
0040     *address = le64_to_cpu(desc->address);
0041     *length = le16_to_cpu(desc->length_type) & RQ_ENET_LEN_MASK;
0042     *type = (u8)((le16_to_cpu(desc->length_type) >> RQ_ENET_LEN_BITS) &
0043         RQ_ENET_TYPE_MASK);
0044 }
0045 
0046 #endif /* _RQ_ENET_DESC_H_ */