Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
wq_enet_desc.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2010 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 _WQ_ENET_DESC_H_
21 #define _WQ_ENET_DESC_H_
22 
23 /* Ethernet work queue descriptor: 16B */
24 struct wq_enet_desc {
30 };
31 
32 #define WQ_ENET_ADDR_BITS 64
33 #define WQ_ENET_LEN_BITS 14
34 #define WQ_ENET_LEN_MASK ((1 << WQ_ENET_LEN_BITS) - 1)
35 #define WQ_ENET_MSS_BITS 14
36 #define WQ_ENET_MSS_MASK ((1 << WQ_ENET_MSS_BITS) - 1)
37 #define WQ_ENET_MSS_SHIFT 2
38 #define WQ_ENET_LOOPBACK_SHIFT 1
39 #define WQ_ENET_HDRLEN_BITS 10
40 #define WQ_ENET_HDRLEN_MASK ((1 << WQ_ENET_HDRLEN_BITS) - 1)
41 #define WQ_ENET_FLAGS_OM_BITS 2
42 #define WQ_ENET_FLAGS_OM_MASK ((1 << WQ_ENET_FLAGS_OM_BITS) - 1)
43 #define WQ_ENET_FLAGS_EOP_SHIFT 12
44 #define WQ_ENET_FLAGS_CQ_ENTRY_SHIFT 13
45 #define WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT 14
46 #define WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT 15
47 
48 #define WQ_ENET_OFFLOAD_MODE_CSUM 0
49 #define WQ_ENET_OFFLOAD_MODE_RESERVED 1
50 #define WQ_ENET_OFFLOAD_MODE_CSUM_L4 2
51 #define WQ_ENET_OFFLOAD_MODE_TSO 3
52 
53 static inline void wq_enet_desc_enc(struct wq_enet_desc *desc,
55  u8 offload_mode, u8 eop, u8 cq_entry, u8 fcoe_encap,
56  u8 vlan_tag_insert, u16 vlan_tag, u8 loopback)
57 {
58  desc->address = cpu_to_le64(address);
59  desc->length = cpu_to_le16(length & WQ_ENET_LEN_MASK);
60  desc->mss_loopback = cpu_to_le16((mss & WQ_ENET_MSS_MASK) <<
61  WQ_ENET_MSS_SHIFT | (loopback & 1) << WQ_ENET_LOOPBACK_SHIFT);
63  (header_length & WQ_ENET_HDRLEN_MASK) |
64  (offload_mode & WQ_ENET_FLAGS_OM_MASK) << WQ_ENET_HDRLEN_BITS |
65  (eop & 1) << WQ_ENET_FLAGS_EOP_SHIFT |
66  (cq_entry & 1) << WQ_ENET_FLAGS_CQ_ENTRY_SHIFT |
67  (fcoe_encap & 1) << WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT |
68  (vlan_tag_insert & 1) << WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT);
69  desc->vlan_tag = cpu_to_le16(vlan_tag);
70 }
71 
72 static inline void wq_enet_desc_dec(struct wq_enet_desc *desc,
74  u8 *offload_mode, u8 *eop, u8 *cq_entry, u8 *fcoe_encap,
75  u8 *vlan_tag_insert, u16 *vlan_tag, u8 *loopback)
76 {
77  *address = le64_to_cpu(desc->address);
78  *length = le16_to_cpu(desc->length) & WQ_ENET_LEN_MASK;
79  *mss = (le16_to_cpu(desc->mss_loopback) >> WQ_ENET_MSS_SHIFT) &
81  *loopback = (u8)((le16_to_cpu(desc->mss_loopback) >>
83  *header_length = le16_to_cpu(desc->header_length_flags) &
85  *offload_mode = (u8)((le16_to_cpu(desc->header_length_flags) >>
87  *eop = (u8)((le16_to_cpu(desc->header_length_flags) >>
89  *cq_entry = (u8)((le16_to_cpu(desc->header_length_flags) >>
91  *fcoe_encap = (u8)((le16_to_cpu(desc->header_length_flags) >>
93  *vlan_tag_insert = (u8)((le16_to_cpu(desc->header_length_flags) >>
95  *vlan_tag = le16_to_cpu(desc->vlan_tag);
96 }
97 
98 #endif /* _WQ_ENET_DESC_H_ */