diff options
Diffstat (limited to 'drivers/net/enic/rq_enet_desc.h')
-rw-r--r-- | drivers/net/enic/rq_enet_desc.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/drivers/net/enic/rq_enet_desc.h b/drivers/net/enic/rq_enet_desc.h new file mode 100644 index 000000000000..a06e649010ce --- /dev/null +++ b/drivers/net/enic/rq_enet_desc.h | |||
@@ -0,0 +1,60 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | * | ||
18 | */ | ||
19 | |||
20 | #ifndef _RQ_ENET_DESC_H_ | ||
21 | #define _RQ_ENET_DESC_H_ | ||
22 | |||
23 | /* Ethernet receive queue descriptor: 16B */ | ||
24 | struct rq_enet_desc { | ||
25 | __le64 address; | ||
26 | __le16 length_type; | ||
27 | u8 reserved[6]; | ||
28 | }; | ||
29 | |||
30 | enum rq_enet_type_types { | ||
31 | RQ_ENET_TYPE_ONLY_SOP = 0, | ||
32 | RQ_ENET_TYPE_NOT_SOP = 1, | ||
33 | RQ_ENET_TYPE_RESV2 = 2, | ||
34 | RQ_ENET_TYPE_RESV3 = 3, | ||
35 | }; | ||
36 | |||
37 | #define RQ_ENET_ADDR_BITS 64 | ||
38 | #define RQ_ENET_LEN_BITS 14 | ||
39 | #define RQ_ENET_LEN_MASK ((1 << RQ_ENET_LEN_BITS) - 1) | ||
40 | #define RQ_ENET_TYPE_BITS 2 | ||
41 | #define RQ_ENET_TYPE_MASK ((1 << RQ_ENET_TYPE_BITS) - 1) | ||
42 | |||
43 | static inline void rq_enet_desc_enc(struct rq_enet_desc *desc, | ||
44 | u64 address, u8 type, u16 length) | ||
45 | { | ||
46 | desc->address = cpu_to_le64(address); | ||
47 | desc->length_type = cpu_to_le16((length & RQ_ENET_LEN_MASK) | | ||
48 | ((type & RQ_ENET_TYPE_MASK) << RQ_ENET_LEN_BITS)); | ||
49 | } | ||
50 | |||
51 | static inline void rq_enet_desc_dec(struct rq_enet_desc *desc, | ||
52 | u64 *address, u8 *type, u16 *length) | ||
53 | { | ||
54 | *address = le64_to_cpu(desc->address); | ||
55 | *length = le16_to_cpu(desc->length_type) & RQ_ENET_LEN_MASK; | ||
56 | *type = (u8)((le16_to_cpu(desc->length_type) >> RQ_ENET_LEN_BITS) & | ||
57 | RQ_ENET_TYPE_MASK); | ||
58 | } | ||
59 | |||
60 | #endif /* _RQ_ENET_DESC_H_ */ | ||