2 * Copyright 2008 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
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.
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
20 #ifndef _WQ_ENET_DESC_H_
21 #define _WQ_ENET_DESC_H_
23 /* Ethernet work queue descriptor: 16B */
28 __le16 header_length_flags
;
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
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
53 static inline void wq_enet_desc_enc(struct wq_enet_desc
*desc
,
54 u64 address
, u16 length
, u16 mss
, u16 header_length
,
55 u8 offload_mode
, u8 eop
, u8 cq_entry
, u8 fcoe_encap
,
56 u8 vlan_tag_insert
, u16 vlan_tag
, u8 loopback
)
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
);
62 desc
->header_length_flags
= cpu_to_le16(
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
);
72 static inline void wq_enet_desc_dec(struct wq_enet_desc
*desc
,
73 u64
*address
, u16
*length
, u16
*mss
, u16
*header_length
,
74 u8
*offload_mode
, u8
*eop
, u8
*cq_entry
, u8
*fcoe_encap
,
75 u8
*vlan_tag_insert
, u16
*vlan_tag
, u8
*loopback
)
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
) >>
82 WQ_ENET_LOOPBACK_SHIFT
) & 1);
83 *header_length
= le16_to_cpu(desc
->header_length_flags
) &
85 *offload_mode
= (u8
)((le16_to_cpu(desc
->header_length_flags
) >>
86 WQ_ENET_HDRLEN_BITS
) & WQ_ENET_FLAGS_OM_MASK
);
87 *eop
= (u8
)((le16_to_cpu(desc
->header_length_flags
) >>
88 WQ_ENET_FLAGS_EOP_SHIFT
) & 1);
89 *cq_entry
= (u8
)((le16_to_cpu(desc
->header_length_flags
) >>
90 WQ_ENET_FLAGS_CQ_ENTRY_SHIFT
) & 1);
91 *fcoe_encap
= (u8
)((le16_to_cpu(desc
->header_length_flags
) >>
92 WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT
) & 1);
93 *vlan_tag_insert
= (u8
)((le16_to_cpu(desc
->header_length_flags
) >>
94 WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT
) & 1);
95 *vlan_tag
= le16_to_cpu(desc
->vlan_tag
);
98 #endif /* _WQ_ENET_DESC_H_ */