Back to home page

OSCL-LXR

 
 

    


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