e1000: move to drivers/net/
[dpdk.git] / lib / librte_pmd_enic / vnic / rq_enet_desc.h
1 /*
2  * Copyright 2008-2010 Cisco Systems, Inc.  All rights reserved.
3  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
4  *
5  * Copyright (c) 2014, Cisco Systems, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  */
34 #ident "$Id: rq_enet_desc.h 59839 2010-09-27 20:36:31Z roprabhu $"
35
36 #ifndef _RQ_ENET_DESC_H_
37 #define _RQ_ENET_DESC_H_
38
39 /* Ethernet receive queue descriptor: 16B */
40 struct rq_enet_desc {
41         __le64 address;
42         __le16 length_type;
43         u8 reserved[6];
44 };
45
46 enum rq_enet_type_types {
47         RQ_ENET_TYPE_ONLY_SOP = 0,
48         RQ_ENET_TYPE_NOT_SOP = 1,
49         RQ_ENET_TYPE_RESV2 = 2,
50         RQ_ENET_TYPE_RESV3 = 3,
51 };
52
53 #define RQ_ENET_ADDR_BITS               64
54 #define RQ_ENET_LEN_BITS                14
55 #define RQ_ENET_LEN_MASK                ((1 << RQ_ENET_LEN_BITS) - 1)
56 #define RQ_ENET_TYPE_BITS               2
57 #define RQ_ENET_TYPE_MASK               ((1 << RQ_ENET_TYPE_BITS) - 1)
58
59 static inline void rq_enet_desc_enc(struct rq_enet_desc *desc,
60         u64 address, u8 type, u16 length)
61 {
62         desc->address = cpu_to_le64(address);
63         desc->length_type = cpu_to_le16((length & RQ_ENET_LEN_MASK) |
64                 ((type & RQ_ENET_TYPE_MASK) << RQ_ENET_LEN_BITS));
65 }
66
67 static inline void rq_enet_desc_dec(struct rq_enet_desc *desc,
68         u64 *address, u8 *type, u16 *length)
69 {
70         *address = le64_to_cpu(desc->address);
71         *length = le16_to_cpu(desc->length_type) & RQ_ENET_LEN_MASK;
72         *type = (u8)((le16_to_cpu(desc->length_type) >> RQ_ENET_LEN_BITS) &
73                 RQ_ENET_TYPE_MASK);
74 }
75
76 #endif /* _RQ_ENET_DESC_H_ */