net/bnxt: log firmware debug notifications
[dpdk.git] / drivers / net / enic / base / wq_enet_desc.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2008-2017 Cisco Systems, Inc.  All rights reserved.
3  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
4  */
5
6 #ifndef _WQ_ENET_DESC_H_
7 #define _WQ_ENET_DESC_H_
8
9 #include <rte_byteorder.h>
10
11 /* Ethernet work queue descriptor: 16B */
12 struct wq_enet_desc {
13         uint64_t address;
14         uint16_t length;
15         uint16_t mss_loopback;
16         uint16_t header_length_flags;
17         uint16_t vlan_tag;
18 };
19
20 #define WQ_ENET_ADDR_BITS               64
21 #define WQ_ENET_LEN_BITS                14
22 #define WQ_ENET_LEN_MASK                ((1 << WQ_ENET_LEN_BITS) - 1)
23 #define WQ_ENET_MSS_BITS                14
24 #define WQ_ENET_MSS_MASK                ((1 << WQ_ENET_MSS_BITS) - 1)
25 #define WQ_ENET_MSS_SHIFT               2
26 #define WQ_ENET_LOOPBACK_SHIFT          1
27 #define WQ_ENET_HDRLEN_BITS             10
28 #define WQ_ENET_HDRLEN_MASK             ((1 << WQ_ENET_HDRLEN_BITS) - 1)
29 #define WQ_ENET_FLAGS_OM_BITS           2
30 #define WQ_ENET_FLAGS_OM_MASK           ((1 << WQ_ENET_FLAGS_OM_BITS) - 1)
31 #define WQ_ENET_FLAGS_EOP_SHIFT         12
32 #define WQ_ENET_FLAGS_CQ_ENTRY_SHIFT    13
33 #define WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT  14
34 #define WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT     15
35
36 #define WQ_ENET_OFFLOAD_MODE_CSUM       0
37 #define WQ_ENET_OFFLOAD_MODE_RESERVED   1
38 #define WQ_ENET_OFFLOAD_MODE_CSUM_L4    2
39 #define WQ_ENET_OFFLOAD_MODE_TSO        3
40
41 static inline void wq_enet_desc_enc(struct wq_enet_desc *desc,
42         uint64_t address, uint16_t length, uint16_t mss, uint16_t header_length,
43         uint8_t offload_mode, uint8_t eop, uint8_t cq_entry, uint8_t fcoe_encap,
44         uint8_t vlan_tag_insert, uint16_t vlan_tag, uint8_t loopback)
45 {
46         desc->address = rte_cpu_to_le_64(address);
47         desc->length = rte_cpu_to_le_16(length & WQ_ENET_LEN_MASK);
48         desc->mss_loopback = rte_cpu_to_le_16((mss & WQ_ENET_MSS_MASK) <<
49                 WQ_ENET_MSS_SHIFT | (loopback & 1) << WQ_ENET_LOOPBACK_SHIFT);
50         desc->header_length_flags = rte_cpu_to_le_16
51                 ((header_length & WQ_ENET_HDRLEN_MASK) |
52                 (offload_mode & WQ_ENET_FLAGS_OM_MASK) << WQ_ENET_HDRLEN_BITS |
53                 (eop & 1) << WQ_ENET_FLAGS_EOP_SHIFT |
54                 (cq_entry & 1) << WQ_ENET_FLAGS_CQ_ENTRY_SHIFT |
55                 (fcoe_encap & 1) << WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT |
56                 (vlan_tag_insert & 1) << WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT);
57         desc->vlan_tag = rte_cpu_to_le_16(vlan_tag);
58 }
59
60 static inline void wq_enet_desc_dec(struct wq_enet_desc *desc,
61         uint64_t *address, uint16_t *length, uint16_t *mss,
62         uint16_t *header_length, uint8_t *offload_mode, uint8_t *eop,
63         uint8_t *cq_entry, uint8_t *fcoe_encap, uint8_t *vlan_tag_insert,
64         uint16_t *vlan_tag, uint8_t *loopback)
65 {
66         *address = rte_le_to_cpu_64(desc->address);
67         *length = rte_le_to_cpu_16(desc->length) & WQ_ENET_LEN_MASK;
68         *mss = (rte_le_to_cpu_16(desc->mss_loopback) >> WQ_ENET_MSS_SHIFT) &
69                 WQ_ENET_MSS_MASK;
70         *loopback = (uint8_t)((rte_le_to_cpu_16(desc->mss_loopback) >>
71                 WQ_ENET_LOOPBACK_SHIFT) & 1);
72         *header_length = rte_le_to_cpu_16(desc->header_length_flags) &
73                 WQ_ENET_HDRLEN_MASK;
74         *offload_mode =
75                 (uint8_t)((rte_le_to_cpu_16(desc->header_length_flags) >>
76                 WQ_ENET_HDRLEN_BITS) & WQ_ENET_FLAGS_OM_MASK);
77         *eop = (uint8_t)((rte_le_to_cpu_16(desc->header_length_flags) >>
78                 WQ_ENET_FLAGS_EOP_SHIFT) & 1);
79         *cq_entry = (uint8_t)((rte_le_to_cpu_16(desc->header_length_flags) >>
80                 WQ_ENET_FLAGS_CQ_ENTRY_SHIFT) & 1);
81         *fcoe_encap = (uint8_t)((rte_le_to_cpu_16(desc->header_length_flags) >>
82                 WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT) & 1);
83         *vlan_tag_insert =
84                 (uint8_t)((rte_le_to_cpu_16(desc->header_length_flags) >>
85                 WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT) & 1);
86         *vlan_tag = rte_le_to_cpu_16(desc->vlan_tag);
87 }
88
89 #endif /* _WQ_ENET_DESC_H_ */