]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/drivers/net/enic/base/cq_enet_desc.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / dpdk / drivers / net / enic / base / cq_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 _CQ_ENET_DESC_H_
7 #define _CQ_ENET_DESC_H_
8
9 #include "cq_desc.h"
10
11 /* Ethernet completion queue descriptor: 16B */
12 struct cq_enet_wq_desc {
13 __le16 completed_index;
14 __le16 q_number;
15 u8 reserved[11];
16 u8 type_color;
17 };
18
19 static inline void cq_enet_wq_desc_enc(struct cq_enet_wq_desc *desc,
20 u8 type, u8 color, u16 q_number, u16 completed_index)
21 {
22 cq_desc_enc((struct cq_desc *)desc, type,
23 color, q_number, completed_index);
24 }
25
26 static inline void cq_enet_wq_desc_dec(struct cq_enet_wq_desc *desc,
27 u8 *type, u8 *color, u16 *q_number, u16 *completed_index)
28 {
29 cq_desc_dec((struct cq_desc *)desc, type,
30 color, q_number, completed_index);
31 }
32
33 /* Completion queue descriptor: Ethernet receive queue, 16B */
34 struct cq_enet_rq_desc {
35 __le16 completed_index_flags;
36 __le16 q_number_rss_type_flags;
37 __le32 rss_hash;
38 __le16 bytes_written_flags;
39 __le16 vlan;
40 __le16 checksum_fcoe;
41 u8 flags;
42 u8 type_color;
43 };
44
45 /* Completion queue descriptor: Ethernet receive queue, 16B */
46 struct cq_enet_rq_clsf_desc {
47 __le16 completed_index_flags;
48 __le16 q_number_rss_type_flags;
49 __le16 filter_id;
50 __le16 lif;
51 __le16 bytes_written_flags;
52 __le16 vlan;
53 __le16 checksum_fcoe;
54 u8 flags;
55 u8 type_color;
56 };
57
58 #define CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT (0x1 << 12)
59 #define CQ_ENET_RQ_DESC_FLAGS_FCOE (0x1 << 13)
60 #define CQ_ENET_RQ_DESC_FLAGS_EOP (0x1 << 14)
61 #define CQ_ENET_RQ_DESC_FLAGS_SOP (0x1 << 15)
62
63 #define CQ_ENET_RQ_DESC_RSS_TYPE_BITS 4
64 #define CQ_ENET_RQ_DESC_RSS_TYPE_MASK \
65 ((1 << CQ_ENET_RQ_DESC_RSS_TYPE_BITS) - 1)
66 #define CQ_ENET_RQ_DESC_RSS_TYPE_NONE 0
67 #define CQ_ENET_RQ_DESC_RSS_TYPE_IPv4 1
68 #define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv4 2
69 #define CQ_ENET_RQ_DESC_RSS_TYPE_IPv6 3
70 #define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6 4
71 #define CQ_ENET_RQ_DESC_RSS_TYPE_IPv6_EX 5
72 #define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6_EX 6
73
74 #define CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC (0x1 << 14)
75
76 #define CQ_ENET_RQ_DESC_BYTES_WRITTEN_BITS 14
77 #define CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK \
78 ((1 << CQ_ENET_RQ_DESC_BYTES_WRITTEN_BITS) - 1)
79 #define CQ_ENET_RQ_DESC_FLAGS_TRUNCATED (0x1 << 14)
80 #define CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED (0x1 << 15)
81
82 #define CQ_ENET_RQ_DESC_VLAN_TCI_VLAN_BITS 12
83 #define CQ_ENET_RQ_DESC_VLAN_TCI_VLAN_MASK \
84 ((1 << CQ_ENET_RQ_DESC_VLAN_TCI_VLAN_BITS) - 1)
85 #define CQ_ENET_RQ_DESC_VLAN_TCI_CFI_MASK (0x1 << 12)
86 #define CQ_ENET_RQ_DESC_VLAN_TCI_USER_PRIO_BITS 3
87 #define CQ_ENET_RQ_DESC_VLAN_TCI_USER_PRIO_MASK \
88 ((1 << CQ_ENET_RQ_DESC_VLAN_TCI_USER_PRIO_BITS) - 1)
89 #define CQ_ENET_RQ_DESC_VLAN_TCI_USER_PRIO_SHIFT 13
90
91 #define CQ_ENET_RQ_DESC_FCOE_SOF_BITS 8
92 #define CQ_ENET_RQ_DESC_FCOE_SOF_MASK \
93 ((1 << CQ_ENET_RQ_DESC_FCOE_SOF_BITS) - 1)
94 #define CQ_ENET_RQ_DESC_FCOE_EOF_BITS 8
95 #define CQ_ENET_RQ_DESC_FCOE_EOF_MASK \
96 ((1 << CQ_ENET_RQ_DESC_FCOE_EOF_BITS) - 1)
97 #define CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT 8
98
99 #define CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK (0x1 << 0)
100 #define CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK (0x1 << 0)
101 #define CQ_ENET_RQ_DESC_FLAGS_UDP (0x1 << 1)
102 #define CQ_ENET_RQ_DESC_FCOE_ENC_ERROR (0x1 << 1)
103 #define CQ_ENET_RQ_DESC_FLAGS_TCP (0x1 << 2)
104 #define CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK (0x1 << 3)
105 #define CQ_ENET_RQ_DESC_FLAGS_IPV6 (0x1 << 4)
106 #define CQ_ENET_RQ_DESC_FLAGS_IPV4 (0x1 << 5)
107 #define CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT (0x1 << 6)
108 #define CQ_ENET_RQ_DESC_FLAGS_FCS_OK (0x1 << 7)
109
110 static inline void cq_enet_rq_desc_enc(struct cq_enet_rq_desc *desc,
111 u8 type, u8 color, u16 q_number, u16 completed_index,
112 u8 ingress_port, u8 fcoe, u8 eop, u8 sop, u8 rss_type, u8 csum_not_calc,
113 u32 rss_hash, u16 bytes_written, u8 packet_error, u8 vlan_stripped,
114 u16 vlan, u16 checksum, u8 fcoe_sof, u8 fcoe_fc_crc_ok,
115 u8 fcoe_enc_error, u8 fcoe_eof, u8 tcp_udp_csum_ok, u8 udp, u8 tcp,
116 u8 ipv4_csum_ok, u8 ipv6, u8 ipv4, u8 ipv4_fragment, u8 fcs_ok)
117 {
118 cq_desc_enc((struct cq_desc *)desc, type,
119 color, q_number, completed_index);
120
121 desc->completed_index_flags |= cpu_to_le16(
122 (ingress_port ? CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT : 0) |
123 (fcoe ? CQ_ENET_RQ_DESC_FLAGS_FCOE : 0) |
124 (eop ? CQ_ENET_RQ_DESC_FLAGS_EOP : 0) |
125 (sop ? CQ_ENET_RQ_DESC_FLAGS_SOP : 0));
126
127 desc->q_number_rss_type_flags |= cpu_to_le16(
128 ((rss_type & CQ_ENET_RQ_DESC_RSS_TYPE_MASK) <<
129 CQ_DESC_Q_NUM_BITS) |
130 (csum_not_calc ? CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC : 0));
131
132 desc->rss_hash = cpu_to_le32(rss_hash);
133
134 desc->bytes_written_flags = cpu_to_le16(
135 (bytes_written & CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK) |
136 (packet_error ? CQ_ENET_RQ_DESC_FLAGS_TRUNCATED : 0) |
137 (vlan_stripped ? CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED : 0));
138
139 desc->vlan = cpu_to_le16(vlan);
140
141 if (fcoe) {
142 desc->checksum_fcoe = cpu_to_le16(
143 (fcoe_sof & CQ_ENET_RQ_DESC_FCOE_SOF_MASK) |
144 ((fcoe_eof & CQ_ENET_RQ_DESC_FCOE_EOF_MASK) <<
145 CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT));
146 } else {
147 desc->checksum_fcoe = cpu_to_le16(checksum);
148 }
149
150 desc->flags =
151 (tcp_udp_csum_ok ? CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK : 0) |
152 (udp ? CQ_ENET_RQ_DESC_FLAGS_UDP : 0) |
153 (tcp ? CQ_ENET_RQ_DESC_FLAGS_TCP : 0) |
154 (ipv4_csum_ok ? CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK : 0) |
155 (ipv6 ? CQ_ENET_RQ_DESC_FLAGS_IPV6 : 0) |
156 (ipv4 ? CQ_ENET_RQ_DESC_FLAGS_IPV4 : 0) |
157 (ipv4_fragment ? CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT : 0) |
158 (fcs_ok ? CQ_ENET_RQ_DESC_FLAGS_FCS_OK : 0) |
159 (fcoe_fc_crc_ok ? CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK : 0) |
160 (fcoe_enc_error ? CQ_ENET_RQ_DESC_FCOE_ENC_ERROR : 0);
161 }
162
163 static inline void cq_enet_rq_desc_dec(struct cq_enet_rq_desc *desc,
164 u8 *type, u8 *color, u16 *q_number, u16 *completed_index,
165 u8 *ingress_port, u8 *fcoe, u8 *eop, u8 *sop, u8 *rss_type,
166 u8 *csum_not_calc, u32 *rss_hash, u16 *bytes_written, u8 *packet_error,
167 u8 *vlan_stripped, u16 *vlan_tci, u16 *checksum, u8 *fcoe_sof,
168 u8 *fcoe_fc_crc_ok, u8 *fcoe_enc_error, u8 *fcoe_eof,
169 u8 *tcp_udp_csum_ok, u8 *udp, u8 *tcp, u8 *ipv4_csum_ok,
170 u8 *ipv6, u8 *ipv4, u8 *ipv4_fragment, u8 *fcs_ok)
171 {
172 u16 completed_index_flags;
173 u16 q_number_rss_type_flags;
174 u16 bytes_written_flags;
175
176 cq_desc_dec((struct cq_desc *)desc, type,
177 color, q_number, completed_index);
178
179 completed_index_flags = le16_to_cpu(desc->completed_index_flags);
180 q_number_rss_type_flags =
181 le16_to_cpu(desc->q_number_rss_type_flags);
182 bytes_written_flags = le16_to_cpu(desc->bytes_written_flags);
183
184 *ingress_port = (completed_index_flags &
185 CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT) ? 1 : 0;
186 *fcoe = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_FCOE) ?
187 1 : 0;
188 *eop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_EOP) ?
189 1 : 0;
190 *sop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_SOP) ?
191 1 : 0;
192
193 *rss_type = (u8)((q_number_rss_type_flags >> CQ_DESC_Q_NUM_BITS) &
194 CQ_ENET_RQ_DESC_RSS_TYPE_MASK);
195 *csum_not_calc = (q_number_rss_type_flags &
196 CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC) ? 1 : 0;
197
198 *rss_hash = le32_to_cpu(desc->rss_hash);
199
200 *bytes_written = bytes_written_flags &
201 CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK;
202 *packet_error = (bytes_written_flags &
203 CQ_ENET_RQ_DESC_FLAGS_TRUNCATED) ? 1 : 0;
204 *vlan_stripped = (bytes_written_flags &
205 CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED) ? 1 : 0;
206
207 /*
208 * Tag Control Information(16) = user_priority(3) + cfi(1) + vlan(12)
209 */
210 *vlan_tci = le16_to_cpu(desc->vlan);
211
212 if (*fcoe) {
213 *fcoe_sof = (u8)(le16_to_cpu(desc->checksum_fcoe) &
214 CQ_ENET_RQ_DESC_FCOE_SOF_MASK);
215 *fcoe_fc_crc_ok = (desc->flags &
216 CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK) ? 1 : 0;
217 *fcoe_enc_error = (desc->flags &
218 CQ_ENET_RQ_DESC_FCOE_ENC_ERROR) ? 1 : 0;
219 *fcoe_eof = (u8)((le16_to_cpu(desc->checksum_fcoe) >>
220 CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT) &
221 CQ_ENET_RQ_DESC_FCOE_EOF_MASK);
222 *checksum = 0;
223 } else {
224 *fcoe_sof = 0;
225 *fcoe_fc_crc_ok = 0;
226 *fcoe_enc_error = 0;
227 *fcoe_eof = 0;
228 *checksum = le16_to_cpu(desc->checksum_fcoe);
229 }
230
231 *tcp_udp_csum_ok =
232 (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK) ? 1 : 0;
233 *udp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_UDP) ? 1 : 0;
234 *tcp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP) ? 1 : 0;
235 *ipv4_csum_ok =
236 (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK) ? 1 : 0;
237 *ipv6 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV6) ? 1 : 0;
238 *ipv4 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4) ? 1 : 0;
239 *ipv4_fragment =
240 (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT) ? 1 : 0;
241 *fcs_ok = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_FCS_OK) ? 1 : 0;
242 }
243
244 #endif /* _CQ_ENET_DESC_H_ */