mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-03 00:54:09 +08:00
e6550b3ee1
Based on the normalized pattern: this program is free software you may redistribute it and/or modify it under the terms of the gnu general public license as published by the free software foundation version 2 of the license the software is provided as is without warranty of any kind express or implied including but not limited to the warranties of merchantability fitness for a particular purpose and noninfringement in no event shall the authors or copyright holders be liable for any claim damages or other liability whether in an action of contract tort or otherwise arising from out of or in connection with the software or the use or other dealings in the software extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
85 lines
3.1 KiB
C
85 lines
3.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright 2008 Cisco Systems, Inc. All rights reserved.
|
|
* Copyright 2007 Nuova Systems, Inc. All rights reserved.
|
|
*/
|
|
#ifndef _WQ_ENET_DESC_H_
|
|
#define _WQ_ENET_DESC_H_
|
|
|
|
/* Ethernet work queue descriptor: 16B */
|
|
struct wq_enet_desc {
|
|
__le64 address;
|
|
__le16 length;
|
|
__le16 mss_loopback;
|
|
__le16 header_length_flags;
|
|
__le16 vlan_tag;
|
|
};
|
|
|
|
#define WQ_ENET_ADDR_BITS 64
|
|
#define WQ_ENET_LEN_BITS 14
|
|
#define WQ_ENET_LEN_MASK ((1 << WQ_ENET_LEN_BITS) - 1)
|
|
#define WQ_ENET_MSS_BITS 14
|
|
#define WQ_ENET_MSS_MASK ((1 << WQ_ENET_MSS_BITS) - 1)
|
|
#define WQ_ENET_MSS_SHIFT 2
|
|
#define WQ_ENET_LOOPBACK_SHIFT 1
|
|
#define WQ_ENET_HDRLEN_BITS 10
|
|
#define WQ_ENET_HDRLEN_MASK ((1 << WQ_ENET_HDRLEN_BITS) - 1)
|
|
#define WQ_ENET_FLAGS_OM_BITS 2
|
|
#define WQ_ENET_FLAGS_OM_MASK ((1 << WQ_ENET_FLAGS_OM_BITS) - 1)
|
|
#define WQ_ENET_FLAGS_EOP_SHIFT 12
|
|
#define WQ_ENET_FLAGS_CQ_ENTRY_SHIFT 13
|
|
#define WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT 14
|
|
#define WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT 15
|
|
|
|
#define WQ_ENET_OFFLOAD_MODE_CSUM 0
|
|
#define WQ_ENET_OFFLOAD_MODE_RESERVED 1
|
|
#define WQ_ENET_OFFLOAD_MODE_CSUM_L4 2
|
|
#define WQ_ENET_OFFLOAD_MODE_TSO 3
|
|
|
|
static inline void wq_enet_desc_enc(struct wq_enet_desc *desc,
|
|
u64 address, u16 length, u16 mss, u16 header_length,
|
|
u8 offload_mode, u8 eop, u8 cq_entry, u8 fcoe_encap,
|
|
u8 vlan_tag_insert, u16 vlan_tag, u8 loopback)
|
|
{
|
|
desc->address = cpu_to_le64(address);
|
|
desc->length = cpu_to_le16(length & WQ_ENET_LEN_MASK);
|
|
desc->mss_loopback = cpu_to_le16((mss & WQ_ENET_MSS_MASK) <<
|
|
WQ_ENET_MSS_SHIFT | (loopback & 1) << WQ_ENET_LOOPBACK_SHIFT);
|
|
desc->header_length_flags = cpu_to_le16(
|
|
(header_length & WQ_ENET_HDRLEN_MASK) |
|
|
(offload_mode & WQ_ENET_FLAGS_OM_MASK) << WQ_ENET_HDRLEN_BITS |
|
|
(eop & 1) << WQ_ENET_FLAGS_EOP_SHIFT |
|
|
(cq_entry & 1) << WQ_ENET_FLAGS_CQ_ENTRY_SHIFT |
|
|
(fcoe_encap & 1) << WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT |
|
|
(vlan_tag_insert & 1) << WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT);
|
|
desc->vlan_tag = cpu_to_le16(vlan_tag);
|
|
}
|
|
|
|
static inline void wq_enet_desc_dec(struct wq_enet_desc *desc,
|
|
u64 *address, u16 *length, u16 *mss, u16 *header_length,
|
|
u8 *offload_mode, u8 *eop, u8 *cq_entry, u8 *fcoe_encap,
|
|
u8 *vlan_tag_insert, u16 *vlan_tag, u8 *loopback)
|
|
{
|
|
*address = le64_to_cpu(desc->address);
|
|
*length = le16_to_cpu(desc->length) & WQ_ENET_LEN_MASK;
|
|
*mss = (le16_to_cpu(desc->mss_loopback) >> WQ_ENET_MSS_SHIFT) &
|
|
WQ_ENET_MSS_MASK;
|
|
*loopback = (u8)((le16_to_cpu(desc->mss_loopback) >>
|
|
WQ_ENET_LOOPBACK_SHIFT) & 1);
|
|
*header_length = le16_to_cpu(desc->header_length_flags) &
|
|
WQ_ENET_HDRLEN_MASK;
|
|
*offload_mode = (u8)((le16_to_cpu(desc->header_length_flags) >>
|
|
WQ_ENET_HDRLEN_BITS) & WQ_ENET_FLAGS_OM_MASK);
|
|
*eop = (u8)((le16_to_cpu(desc->header_length_flags) >>
|
|
WQ_ENET_FLAGS_EOP_SHIFT) & 1);
|
|
*cq_entry = (u8)((le16_to_cpu(desc->header_length_flags) >>
|
|
WQ_ENET_FLAGS_CQ_ENTRY_SHIFT) & 1);
|
|
*fcoe_encap = (u8)((le16_to_cpu(desc->header_length_flags) >>
|
|
WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT) & 1);
|
|
*vlan_tag_insert = (u8)((le16_to_cpu(desc->header_length_flags) >>
|
|
WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT) & 1);
|
|
*vlan_tag = le16_to_cpu(desc->vlan_tag);
|
|
}
|
|
|
|
#endif /* _WQ_ENET_DESC_H_ */
|