Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2018 Intel Corporation
3 : : */
4 : :
5 : : #include <ethdev_driver.h>
6 : : #include <rte_net.h>
7 : : #include <rte_vect.h>
8 : : #include <rte_bitops.h>
9 : :
10 : : #include "ice_rxtx.h"
11 : : #include "ice_rxtx_vec_common.h"
12 : :
13 : : #ifdef RTE_ARCH_X86
14 : : #include "../common/rx_vec_x86.h"
15 : : #endif
16 : :
17 : : /**
18 : : * The mbuf dynamic field pointer for protocol extraction metadata.
19 : : */
20 : : #define ICE_DYNF_PROTO_XTR_METADATA(m, n) \
21 : : RTE_MBUF_DYNFIELD((m), (n), uint32_t *)
22 : :
23 : : static int
24 : 0 : ice_monitor_callback(const uint64_t value,
25 : : const uint64_t arg[RTE_POWER_MONITOR_OPAQUE_SZ] __rte_unused)
26 : : {
27 : : const uint64_t m = rte_cpu_to_le_16(1 << ICE_RX_FLEX_DESC_STATUS0_DD_S);
28 : : /*
29 : : * we expect the DD bit to be set to 1 if this descriptor was already
30 : : * written to.
31 : : */
32 [ # # ]: 0 : return (value & m) == m ? -1 : 0;
33 : : }
34 : :
35 : : int
36 : 0 : ice_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc)
37 : : {
38 : : volatile union ci_rx_flex_desc *rxdp;
39 : : struct ci_rx_queue *rxq = rx_queue;
40 : : uint16_t desc;
41 : :
42 : 0 : desc = rxq->rx_tail;
43 : 0 : rxdp = &rxq->rx_flex_ring[desc];
44 : : /* watch for changes in status bit */
45 : 0 : pmc->addr = &rxdp->wb.status_error0;
46 : :
47 : : /* comparison callback */
48 : 0 : pmc->fn = ice_monitor_callback;
49 : :
50 : : /* register is 16-bit */
51 : 0 : pmc->size = sizeof(uint16_t);
52 : :
53 : 0 : return 0;
54 : : }
55 : :
56 : :
57 : : static inline uint8_t
58 : : ice_proto_xtr_type_to_rxdid(uint8_t xtr_type)
59 : : {
60 : : static uint8_t rxdid_map[] = {
61 : : [PROTO_XTR_NONE] = ICE_RXDID_COMMS_OVS,
62 : : [PROTO_XTR_VLAN] = ICE_RXDID_COMMS_AUX_VLAN,
63 : : [PROTO_XTR_IPV4] = ICE_RXDID_COMMS_AUX_IPV4,
64 : : [PROTO_XTR_IPV6] = ICE_RXDID_COMMS_AUX_IPV6,
65 : : [PROTO_XTR_IPV6_FLOW] = ICE_RXDID_COMMS_AUX_IPV6_FLOW,
66 : : [PROTO_XTR_TCP] = ICE_RXDID_COMMS_AUX_TCP,
67 : : [PROTO_XTR_IP_OFFSET] = ICE_RXDID_COMMS_AUX_IP_OFFSET,
68 : : };
69 : :
70 : : return xtr_type < RTE_DIM(rxdid_map) ?
71 : 0 : rxdid_map[xtr_type] : ICE_RXDID_COMMS_OVS;
72 : : }
73 : :
74 : : static inline void
75 : 0 : ice_rxd_to_pkt_fields_by_comms_generic(__rte_unused struct ci_rx_queue *rxq,
76 : : struct rte_mbuf *mb,
77 : : volatile union ci_rx_flex_desc *rxdp)
78 : : {
79 : : volatile struct ice_32b_rx_flex_desc_comms *desc =
80 : : (volatile struct ice_32b_rx_flex_desc_comms *)rxdp;
81 : 0 : uint16_t stat_err = rte_le_to_cpu_16(desc->status_error0);
82 : :
83 [ # # ]: 0 : if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
84 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
85 : 0 : mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
86 : : }
87 : :
88 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
89 [ # # ]: 0 : if (desc->flow_id != 0xFFFFFFFF) {
90 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
91 : 0 : mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
92 : : }
93 : : #endif
94 : 0 : }
95 : :
96 : : static inline void
97 : 0 : ice_rxd_to_pkt_fields_by_comms_ovs(__rte_unused struct ci_rx_queue *rxq,
98 : : struct rte_mbuf *mb,
99 : : volatile union ci_rx_flex_desc *rxdp)
100 : : {
101 : : volatile struct ice_32b_rx_flex_desc_comms_ovs *desc =
102 : : (volatile struct ice_32b_rx_flex_desc_comms_ovs *)rxdp;
103 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
104 : : uint16_t stat_err;
105 : : #endif
106 : :
107 [ # # ]: 0 : if (desc->flow_id != 0xFFFFFFFF) {
108 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
109 : 0 : mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
110 : : }
111 : :
112 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
113 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error0);
114 [ # # ]: 0 : if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
115 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
116 : 0 : mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
117 : : }
118 : : #endif
119 : 0 : }
120 : :
121 : : static inline void
122 : 0 : ice_rxd_to_pkt_fields_by_comms_aux_v1(struct ci_rx_queue *rxq,
123 : : struct rte_mbuf *mb,
124 : : volatile union ci_rx_flex_desc *rxdp)
125 : : {
126 : : volatile struct ice_32b_rx_flex_desc_comms *desc =
127 : : (volatile struct ice_32b_rx_flex_desc_comms *)rxdp;
128 : : uint16_t stat_err;
129 : :
130 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error0);
131 [ # # ]: 0 : if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
132 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
133 : 0 : mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
134 : : }
135 : :
136 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
137 [ # # ]: 0 : if (desc->flow_id != 0xFFFFFFFF) {
138 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
139 : 0 : mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
140 : : }
141 : :
142 [ # # ]: 0 : if (rxq->xtr_ol_flag) {
143 : : uint32_t metadata = 0;
144 : :
145 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error1);
146 : :
147 [ # # ]: 0 : if (stat_err & (1 << ICE_RX_FLEX_DESC_STATUS1_XTRMD4_VALID_S))
148 : 0 : metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux0);
149 : :
150 [ # # ]: 0 : if (stat_err & (1 << ICE_RX_FLEX_DESC_STATUS1_XTRMD5_VALID_S))
151 : 0 : metadata |=
152 : 0 : rte_le_to_cpu_16(desc->flex_ts.flex.aux1) << 16;
153 : :
154 [ # # ]: 0 : if (metadata) {
155 : 0 : mb->ol_flags |= rxq->xtr_ol_flag;
156 : :
157 : 0 : *ICE_DYNF_PROTO_XTR_METADATA(mb, rxq->xtr_field_offs) = metadata;
158 : : }
159 : : }
160 : : #else
161 : : RTE_SET_USED(rxq);
162 : : #endif
163 : 0 : }
164 : :
165 : : static inline void
166 : 0 : ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ci_rx_queue *rxq,
167 : : struct rte_mbuf *mb,
168 : : volatile union ci_rx_flex_desc *rxdp)
169 : : {
170 : : volatile struct ice_32b_rx_flex_desc_comms *desc =
171 : : (volatile struct ice_32b_rx_flex_desc_comms *)rxdp;
172 : : uint16_t stat_err;
173 : :
174 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error0);
175 [ # # ]: 0 : if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
176 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
177 : 0 : mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
178 : : }
179 : :
180 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
181 [ # # ]: 0 : if (desc->flow_id != 0xFFFFFFFF) {
182 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
183 : 0 : mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
184 : : }
185 : :
186 [ # # ]: 0 : if (rxq->xtr_ol_flag) {
187 : : uint32_t metadata = 0;
188 : :
189 [ # # ]: 0 : if (desc->flex_ts.flex.aux0 != 0xFFFF)
190 : 0 : metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux0);
191 [ # # ]: 0 : else if (desc->flex_ts.flex.aux1 != 0xFFFF)
192 : 0 : metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux1);
193 : :
194 [ # # ]: 0 : if (metadata) {
195 : 0 : mb->ol_flags |= rxq->xtr_ol_flag;
196 : :
197 : 0 : *ICE_DYNF_PROTO_XTR_METADATA(mb, rxq->xtr_field_offs) = metadata;
198 : : }
199 : : }
200 : : #else
201 : : RTE_SET_USED(rxq);
202 : : #endif
203 : 0 : }
204 : :
205 : : static const ice_rxd_to_pkt_fields_t rxd_to_pkt_fields_ops[] = {
206 : : [ICE_RXDID_COMMS_AUX_VLAN] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
207 : : [ICE_RXDID_COMMS_AUX_IPV4] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
208 : : [ICE_RXDID_COMMS_AUX_IPV6] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
209 : : [ICE_RXDID_COMMS_AUX_IPV6_FLOW] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
210 : : [ICE_RXDID_COMMS_AUX_TCP] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
211 : : [ICE_RXDID_COMMS_AUX_IP_OFFSET] = ice_rxd_to_pkt_fields_by_comms_aux_v2,
212 : : [ICE_RXDID_COMMS_GENERIC] = ice_rxd_to_pkt_fields_by_comms_generic,
213 : : [ICE_RXDID_COMMS_OVS] = ice_rxd_to_pkt_fields_by_comms_ovs,
214 : : };
215 : :
216 : : void
217 : 0 : ice_select_rxd_to_pkt_fields_handler(struct ci_rx_queue *rxq, uint32_t rxdid)
218 : : {
219 : 0 : rxq->rxdid = rxdid;
220 : :
221 [ # # ]: 0 : switch (rxdid) {
222 : : case ICE_RXDID_COMMS_AUX_VLAN:
223 : : case ICE_RXDID_COMMS_AUX_IPV4:
224 : : case ICE_RXDID_COMMS_AUX_IPV6:
225 : : case ICE_RXDID_COMMS_AUX_IPV6_FLOW:
226 : : case ICE_RXDID_COMMS_AUX_TCP:
227 : : case ICE_RXDID_COMMS_AUX_IP_OFFSET:
228 : : break;
229 : : case ICE_RXDID_COMMS_GENERIC:
230 : : /* fallthrough */
231 : : case ICE_RXDID_COMMS_OVS:
232 : : break;
233 : :
234 : 0 : default:
235 : : /* update this according to the RXDID for PROTO_XTR_NONE */
236 : 0 : rxq->rxdid = ICE_RXDID_COMMS_OVS;
237 : 0 : break;
238 : : }
239 : :
240 [ # # ]: 0 : if (rxq->xtr_field_offs == -1)
241 : 0 : rxq->xtr_ol_flag = 0;
242 : 0 : }
243 : :
244 : : static int
245 : 0 : ice_program_hw_rx_queue(struct ci_rx_queue *rxq)
246 : : {
247 : 0 : struct ice_vsi *vsi = rxq->ice_vsi;
248 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
249 : : struct ice_pf *pf = ICE_VSI_TO_PF(vsi);
250 : 0 : struct rte_eth_dev_data *dev_data = rxq->ice_vsi->adapter->pf.dev_data;
251 : : struct ice_rlan_ctx rx_ctx;
252 : : uint16_t buf_size;
253 : : uint32_t rxdid = ICE_RXDID_COMMS_OVS;
254 : : uint32_t regval;
255 : : struct ice_adapter *ad = rxq->ice_vsi->adapter;
256 : 0 : uint32_t frame_size = dev_data->mtu + ICE_ETH_OVERHEAD;
257 : : int err;
258 : :
259 : : /* Set buffer size as the head split is disabled. */
260 [ # # ]: 0 : buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mp) -
261 : : RTE_PKTMBUF_HEADROOM);
262 : 0 : rxq->rx_buf_len = RTE_ALIGN_FLOOR(buf_size, (1 << ICE_RLAN_CTX_DBUF_S));
263 : 0 : rxq->rx_buf_len = RTE_MIN(rxq->rx_buf_len, ICE_RX_MAX_DATA_BUF_SIZE);
264 : 0 : rxq->max_pkt_len =
265 : 0 : RTE_MIN((uint32_t)ICE_SUPPORT_CHAIN_NUM * rxq->rx_buf_len,
266 : : frame_size);
267 : :
268 [ # # ]: 0 : if (rxq->max_pkt_len <= RTE_ETHER_MIN_LEN ||
269 : : rxq->max_pkt_len > ICE_FRAME_SIZE_MAX) {
270 : 0 : PMD_DRV_LOG(ERR, "maximum packet length must "
271 : : "be larger than %u and smaller than %u",
272 : : (uint32_t)RTE_ETHER_MIN_LEN,
273 : : (uint32_t)ICE_FRAME_SIZE_MAX);
274 : 0 : return -EINVAL;
275 : : }
276 : :
277 [ # # # # ]: 0 : if (rxq->ts_flag == 0 && (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
278 : : /* Register mbuf field and flag for Rx timestamp */
279 : 0 : err = rte_mbuf_dyn_rx_timestamp_register(
280 : : &rxq->ts_offset,
281 : : &rxq->ts_flag);
282 [ # # ]: 0 : if (err) {
283 : 0 : PMD_DRV_LOG(ERR,
284 : : "Cannot register mbuf field/flag for timestamp");
285 : 0 : return -EINVAL;
286 : : }
287 : : }
288 : :
289 : : memset(&rx_ctx, 0, sizeof(rx_ctx));
290 : :
291 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
292 : : uint32_t proto_hdr;
293 : 0 : proto_hdr = rxq->rxseg[0].proto_hdr;
294 : :
295 [ # # ]: 0 : if (proto_hdr == RTE_PTYPE_UNKNOWN) {
296 : 0 : PMD_DRV_LOG(ERR, "Buffer split protocol must be configured");
297 : 0 : return -EINVAL;
298 : : }
299 : :
300 [ # # # ]: 0 : switch (proto_hdr & RTE_PTYPE_L4_MASK) {
301 : 0 : case RTE_PTYPE_L4_TCP:
302 : : case RTE_PTYPE_L4_UDP:
303 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
304 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_TCP_UDP;
305 : 0 : goto set_hsplit_finish;
306 : 0 : case RTE_PTYPE_L4_SCTP:
307 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
308 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_SCTP;
309 : 0 : goto set_hsplit_finish;
310 : : }
311 : :
312 [ # # ]: 0 : switch (proto_hdr & RTE_PTYPE_L3_MASK) {
313 : 0 : case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
314 : : case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
315 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
316 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_IP;
317 : 0 : goto set_hsplit_finish;
318 : : }
319 : :
320 [ # # ]: 0 : switch (proto_hdr & RTE_PTYPE_L2_MASK) {
321 : 0 : case RTE_PTYPE_L2_ETHER:
322 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
323 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_L2;
324 : 0 : rx_ctx.hsplit_1 = ICE_RLAN_RX_HSPLIT_1_SPLIT_L2;
325 : 0 : goto set_hsplit_finish;
326 : : }
327 : :
328 [ # # # ]: 0 : switch (proto_hdr & RTE_PTYPE_INNER_L4_MASK) {
329 : 0 : case RTE_PTYPE_INNER_L4_TCP:
330 : : case RTE_PTYPE_INNER_L4_UDP:
331 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
332 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_TCP_UDP;
333 : 0 : goto set_hsplit_finish;
334 : 0 : case RTE_PTYPE_INNER_L4_SCTP:
335 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
336 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_SCTP;
337 : 0 : goto set_hsplit_finish;
338 : : }
339 : :
340 [ # # ]: 0 : switch (proto_hdr & RTE_PTYPE_INNER_L3_MASK) {
341 : 0 : case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN:
342 : : case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN:
343 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
344 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_IP;
345 : 0 : goto set_hsplit_finish;
346 : : }
347 : :
348 [ # # ]: 0 : switch (proto_hdr & RTE_PTYPE_INNER_L2_MASK) {
349 : 0 : case RTE_PTYPE_INNER_L2_ETHER:
350 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
351 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_L2;
352 : 0 : goto set_hsplit_finish;
353 : : }
354 : :
355 [ # # ]: 0 : switch (proto_hdr & RTE_PTYPE_TUNNEL_MASK) {
356 : 0 : case RTE_PTYPE_TUNNEL_GRENAT:
357 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
358 : 0 : rx_ctx.hsplit_1 = ICE_RLAN_RX_HSPLIT_1_SPLIT_ALWAYS;
359 : 0 : goto set_hsplit_finish;
360 : : }
361 : :
362 : 0 : PMD_DRV_LOG(ERR, "Buffer split protocol is not supported");
363 : 0 : return -EINVAL;
364 : :
365 : 0 : set_hsplit_finish:
366 : 0 : rxq->rx_hdr_len = ICE_RX_HDR_BUF_SIZE;
367 : : } else {
368 : 0 : rxq->rx_hdr_len = 0;
369 : : rx_ctx.dtype = 0; /* No Protocol Based Buffer Split mode */
370 : : }
371 : :
372 : 0 : rx_ctx.base = rxq->rx_ring_phys_addr / ICE_QUEUE_BASE_ADDR_UNIT;
373 : 0 : rx_ctx.qlen = rxq->nb_rx_desc;
374 : 0 : rx_ctx.dbuf = rxq->rx_buf_len >> ICE_RLAN_CTX_DBUF_S;
375 : 0 : rx_ctx.hbuf = rxq->rx_hdr_len >> ICE_RLAN_CTX_HBUF_S;
376 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
377 : 0 : rx_ctx.dsize = 1; /* 32B descriptors */
378 : : #endif
379 : 0 : rx_ctx.rxmax = rxq->max_pkt_len;
380 : : /* TPH: Transaction Layer Packet (TLP) processing hints */
381 : 0 : rx_ctx.tphrdesc_ena = 1;
382 : 0 : rx_ctx.tphwdesc_ena = 1;
383 : 0 : rx_ctx.tphdata_ena = 1;
384 : 0 : rx_ctx.tphhead_ena = 1;
385 : : /* Low Receive Queue Threshold defined in 64 descriptors units.
386 : : * When the number of free descriptors goes below the lrxqthresh,
387 : : * an immediate interrupt is triggered.
388 : : */
389 : 0 : rx_ctx.lrxqthresh = 2;
390 : : /*default use 32 byte descriptor, vlan tag extract to L2TAG2(1st)*/
391 : 0 : rx_ctx.l2tsel = 1;
392 : : rx_ctx.showiv = 0;
393 : 0 : rx_ctx.crcstrip = (rxq->crc_len == 0) ? 1 : 0;
394 : :
395 [ # # ]: 0 : rxdid = ice_proto_xtr_type_to_rxdid(rxq->proto_xtr);
396 : :
397 : 0 : PMD_DRV_LOG(DEBUG, "Port (%u) - Rx queue (%u) is set with RXDID : %u",
398 : : rxq->port_id, rxq->queue_id, rxdid);
399 : :
400 [ # # ]: 0 : if (!(pf->supported_rxdid & RTE_BIT64(rxdid))) {
401 : 0 : PMD_DRV_LOG(ERR, "currently package doesn't support RXDID (%u)",
402 : : rxdid);
403 : 0 : return -EINVAL;
404 : : }
405 : :
406 : 0 : rxq->rxdid = rxdid;
407 : :
408 : : /* Enable Flexible Descriptors in the queue context which
409 : : * allows this driver to select a specific receive descriptor format
410 : : */
411 : 0 : regval = (rxdid << QRXFLXP_CNTXT_RXDID_IDX_S) &
412 : : QRXFLXP_CNTXT_RXDID_IDX_M;
413 : :
414 : : /* increasing context priority to pick up profile ID;
415 : : * default is 0x01; setting to 0x03 to ensure profile
416 : : * is programming if prev context is of same priority
417 : : */
418 : 0 : regval |= (0x03 << QRXFLXP_CNTXT_RXDID_PRIO_S) &
419 : : QRXFLXP_CNTXT_RXDID_PRIO_M;
420 : :
421 [ # # # # ]: 0 : if (ad->ptp_ena || rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
422 : 0 : regval |= QRXFLXP_CNTXT_TS_M;
423 : :
424 : 0 : ICE_WRITE_REG(hw, QRXFLXP_CNTXT(rxq->reg_idx), regval);
425 : :
426 : 0 : err = ice_clear_rxq_ctx(hw, rxq->reg_idx);
427 [ # # ]: 0 : if (err) {
428 : 0 : PMD_DRV_LOG(ERR, "Failed to clear Lan Rx queue (%u) context",
429 : : rxq->queue_id);
430 : 0 : return -EINVAL;
431 : : }
432 : 0 : err = ice_write_rxq_ctx(hw, &rx_ctx, rxq->reg_idx);
433 [ # # ]: 0 : if (err) {
434 : 0 : PMD_DRV_LOG(ERR, "Failed to write Lan Rx queue (%u) context",
435 : : rxq->queue_id);
436 : 0 : return -EINVAL;
437 : : }
438 : :
439 : : /* Check if scattered RX needs to be used. */
440 [ # # ]: 0 : if (frame_size > buf_size)
441 : 0 : dev_data->scattered_rx = 1;
442 : :
443 : 0 : rxq->qrx_tail = hw->hw_addr + QRX_TAIL(rxq->reg_idx);
444 : :
445 : : /* Init the Rx tail register*/
446 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
447 : :
448 : 0 : return 0;
449 : : }
450 : :
451 : : /* Allocate mbufs for all descriptors in rx queue */
452 : : static int
453 : 0 : ice_alloc_rx_queue_mbufs(struct ci_rx_queue *rxq)
454 : : {
455 : 0 : struct ci_rx_entry *rxe = rxq->sw_ring;
456 : : uint64_t dma_addr;
457 : : uint16_t i;
458 : :
459 [ # # ]: 0 : for (i = 0; i < rxq->nb_rx_desc; i++) {
460 : : volatile union ci_rx_flex_desc *rxd;
461 : 0 : rxd = &rxq->rx_flex_ring[i];
462 : 0 : struct rte_mbuf *mbuf = rte_mbuf_raw_alloc(rxq->mp);
463 : :
464 [ # # ]: 0 : if (unlikely(!mbuf)) {
465 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate mbuf for RX");
466 : 0 : return -ENOMEM;
467 : : }
468 : :
469 : 0 : mbuf->data_off = RTE_PKTMBUF_HEADROOM;
470 : 0 : mbuf->nb_segs = 1;
471 [ # # ]: 0 : mbuf->port = rxq->port_id;
472 : :
473 : : dma_addr =
474 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
475 : :
476 [ # # ]: 0 : if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
477 : : rte_mbuf_refcnt_set(mbuf, 1);
478 : 0 : mbuf->next = NULL;
479 : 0 : rxd->read.hdr_addr = 0;
480 : 0 : rxd->read.pkt_addr = dma_addr;
481 : : } else {
482 : : struct rte_mbuf *mbuf_pay;
483 : 0 : mbuf_pay = rte_mbuf_raw_alloc(rxq->rxseg[1].mp);
484 [ # # ]: 0 : if (unlikely(!mbuf_pay)) {
485 : 0 : rte_pktmbuf_free(mbuf);
486 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate payload mbuf for RX");
487 : 0 : return -ENOMEM;
488 : : }
489 : :
490 : 0 : mbuf_pay->next = NULL;
491 : 0 : mbuf_pay->data_off = RTE_PKTMBUF_HEADROOM;
492 : 0 : mbuf_pay->nb_segs = 1;
493 : 0 : mbuf_pay->port = rxq->port_id;
494 : 0 : mbuf->next = mbuf_pay;
495 : :
496 : 0 : rxd->read.hdr_addr = dma_addr;
497 : : /* The LS bit should be set to zero regardless of
498 : : * buffer split enablement.
499 : : */
500 : 0 : rxd->read.pkt_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf_pay));
501 : : }
502 : :
503 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
504 : 0 : rxd->read.rsvd1 = 0;
505 : 0 : rxd->read.rsvd2 = 0;
506 : : #endif
507 : 0 : rxe[i].mbuf = mbuf;
508 : : }
509 : :
510 : : return 0;
511 : : }
512 : :
513 : : /* Free all mbufs for descriptors in rx queue */
514 : : static void
515 : 0 : _ice_rx_queue_release_mbufs(struct ci_rx_queue *rxq)
516 : : {
517 : : uint16_t i;
518 : :
519 [ # # # # ]: 0 : if (!rxq || !rxq->sw_ring) {
520 : 0 : PMD_DRV_LOG(DEBUG, "Pointer to sw_ring is NULL");
521 : 0 : return;
522 : : }
523 : :
524 [ # # ]: 0 : for (i = 0; i < rxq->nb_rx_desc; i++) {
525 [ # # ]: 0 : if (rxq->sw_ring[i].mbuf) {
526 : 0 : rte_pktmbuf_free(rxq->sw_ring[i].mbuf);
527 : 0 : rxq->sw_ring[i].mbuf = NULL;
528 : : }
529 : : }
530 [ # # ]: 0 : if (rxq->rx_nb_avail == 0)
531 : : return;
532 [ # # ]: 0 : for (i = 0; i < rxq->rx_nb_avail; i++)
533 : 0 : rte_pktmbuf_free(rxq->rx_stage[rxq->rx_next_avail + i]);
534 : :
535 : 0 : rxq->rx_nb_avail = 0;
536 : : }
537 : :
538 : : /* turn on or off rx queue
539 : : * @q_idx: queue index in pf scope
540 : : * @on: turn on or off the queue
541 : : */
542 : : static int
543 : 0 : ice_switch_rx_queue(struct ice_hw *hw, uint16_t q_idx, bool on)
544 : : {
545 : : uint32_t reg;
546 : : uint16_t j;
547 : :
548 : : /* QRX_CTRL = QRX_ENA */
549 : 0 : reg = ICE_READ_REG(hw, QRX_CTRL(q_idx));
550 : :
551 [ # # ]: 0 : if (on) {
552 [ # # ]: 0 : if (reg & QRX_CTRL_QENA_STAT_M)
553 : : return 0; /* Already on, skip */
554 : 0 : reg |= QRX_CTRL_QENA_REQ_M;
555 : : } else {
556 [ # # ]: 0 : if (!(reg & QRX_CTRL_QENA_STAT_M))
557 : : return 0; /* Already off, skip */
558 : 0 : reg &= ~QRX_CTRL_QENA_REQ_M;
559 : : }
560 : :
561 : : /* Write the register */
562 : 0 : ICE_WRITE_REG(hw, QRX_CTRL(q_idx), reg);
563 : : /* Check the result. It is said that QENA_STAT
564 : : * follows the QENA_REQ not more than 10 use.
565 : : * TODO: need to change the wait counter later
566 : : */
567 [ # # ]: 0 : for (j = 0; j < ICE_CHK_Q_ENA_COUNT; j++) {
568 : 0 : rte_delay_us(ICE_CHK_Q_ENA_INTERVAL_US);
569 : 0 : reg = ICE_READ_REG(hw, QRX_CTRL(q_idx));
570 [ # # ]: 0 : if (on) {
571 [ # # ]: 0 : if ((reg & QRX_CTRL_QENA_REQ_M) &&
572 : : (reg & QRX_CTRL_QENA_STAT_M))
573 : : break;
574 : : } else {
575 [ # # ]: 0 : if (!(reg & QRX_CTRL_QENA_REQ_M) &&
576 : : !(reg & QRX_CTRL_QENA_STAT_M))
577 : : break;
578 : : }
579 : : }
580 : :
581 : : /* Check if it is timeout */
582 [ # # ]: 0 : if (j >= ICE_CHK_Q_ENA_COUNT) {
583 [ # # ]: 0 : PMD_DRV_LOG(ERR, "Failed to %s rx queue[%u]",
584 : : (on ? "enable" : "disable"), q_idx);
585 : 0 : return -ETIMEDOUT;
586 : : }
587 : :
588 : : return 0;
589 : : }
590 : :
591 : : static inline int
592 : 0 : ice_check_rx_burst_bulk_alloc_preconditions(struct ci_rx_queue *rxq)
593 : : {
594 : : int ret = 0;
595 : :
596 [ # # ]: 0 : if (!(rxq->rx_free_thresh >= ICE_RX_MAX_BURST)) {
597 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
598 : : "rxq->rx_free_thresh=%d, "
599 : : "ICE_RX_MAX_BURST=%d",
600 : : rxq->rx_free_thresh, ICE_RX_MAX_BURST);
601 : : ret = -EINVAL;
602 [ # # ]: 0 : } else if (!(rxq->rx_free_thresh < rxq->nb_rx_desc)) {
603 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
604 : : "rxq->rx_free_thresh=%d, "
605 : : "rxq->nb_rx_desc=%d",
606 : : rxq->rx_free_thresh, rxq->nb_rx_desc);
607 : : ret = -EINVAL;
608 [ # # ]: 0 : } else if (rxq->nb_rx_desc % rxq->rx_free_thresh != 0) {
609 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
610 : : "rxq->nb_rx_desc=%d, "
611 : : "rxq->rx_free_thresh=%d",
612 : : rxq->nb_rx_desc, rxq->rx_free_thresh);
613 : : ret = -EINVAL;
614 : : }
615 : :
616 : 0 : return ret;
617 : : }
618 : :
619 : : /* reset fields in ci_rx_queue back to default */
620 : : static void
621 : 0 : ice_reset_rx_queue(struct ci_rx_queue *rxq)
622 : : {
623 : : unsigned int i;
624 : : uint16_t len;
625 : :
626 [ # # ]: 0 : if (!rxq) {
627 : 0 : PMD_DRV_LOG(DEBUG, "Pointer to rxq is NULL");
628 : 0 : return;
629 : : }
630 : :
631 : 0 : len = (uint16_t)(rxq->nb_rx_desc + ICE_RX_MAX_BURST);
632 : :
633 [ # # ]: 0 : for (i = 0; i < len * sizeof(union ci_rx_flex_desc); i++)
634 : 0 : ((volatile char *)rxq->rx_flex_ring)[i] = 0;
635 : :
636 : 0 : memset(&rxq->fake_mbuf, 0x0, sizeof(rxq->fake_mbuf));
637 [ # # ]: 0 : for (i = 0; i < ICE_RX_MAX_BURST; ++i)
638 : 0 : rxq->sw_ring[rxq->nb_rx_desc + i].mbuf = &rxq->fake_mbuf;
639 : :
640 : 0 : rxq->rx_nb_avail = 0;
641 : 0 : rxq->rx_next_avail = 0;
642 : 0 : rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
643 : :
644 : 0 : rxq->rx_tail = 0;
645 : 0 : rxq->nb_rx_hold = 0;
646 : 0 : rxq->pkt_first_seg = NULL;
647 : 0 : rxq->pkt_last_seg = NULL;
648 : :
649 : 0 : rxq->rxrearm_start = 0;
650 : 0 : rxq->rxrearm_nb = 0;
651 : : }
652 : :
653 : : int
654 : 0 : ice_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
655 : : {
656 : : struct ci_rx_queue *rxq;
657 : : int err;
658 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
659 : :
660 : 0 : PMD_INIT_FUNC_TRACE();
661 : :
662 [ # # ]: 0 : if (rx_queue_id >= dev->data->nb_rx_queues) {
663 : 0 : PMD_DRV_LOG(ERR, "RX queue %u is out of range %u",
664 : : rx_queue_id, dev->data->nb_rx_queues);
665 : 0 : return -EINVAL;
666 : : }
667 : :
668 : 0 : rxq = dev->data->rx_queues[rx_queue_id];
669 [ # # # # ]: 0 : if (!rxq || !rxq->q_set) {
670 : 0 : PMD_DRV_LOG(ERR, "RX queue %u not available or setup",
671 : : rx_queue_id);
672 : 0 : return -EINVAL;
673 : : }
674 : :
675 [ # # ]: 0 : if (dev->data->rx_queue_state[rx_queue_id] ==
676 : : RTE_ETH_QUEUE_STATE_STARTED)
677 : : return 0;
678 : :
679 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
680 : 0 : rxq->offloads |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
681 : 0 : err = ice_program_hw_rx_queue(rxq);
682 [ # # ]: 0 : if (err) {
683 : 0 : PMD_DRV_LOG(ERR, "fail to program RX queue %u",
684 : : rx_queue_id);
685 : 0 : return -EIO;
686 : : }
687 : :
688 : 0 : err = ice_alloc_rx_queue_mbufs(rxq);
689 [ # # ]: 0 : if (err) {
690 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
691 : 0 : return -ENOMEM;
692 : : }
693 : :
694 : : /* Init the RX tail register. */
695 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
696 : :
697 : 0 : err = ice_switch_rx_queue(hw, rxq->reg_idx, true);
698 [ # # ]: 0 : if (err) {
699 : 0 : PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
700 : : rx_queue_id);
701 : :
702 : 0 : rxq->rx_rel_mbufs(rxq);
703 : 0 : ice_reset_rx_queue(rxq);
704 : 0 : return -EINVAL;
705 : : }
706 : :
707 : 0 : dev->data->rx_queue_state[rx_queue_id] =
708 : : RTE_ETH_QUEUE_STATE_STARTED;
709 : :
710 : 0 : return 0;
711 : : }
712 : :
713 : : int
714 : 0 : ice_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
715 : : {
716 : : struct ci_rx_queue *rxq;
717 : : int err;
718 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
719 : :
720 [ # # ]: 0 : if (rx_queue_id < dev->data->nb_rx_queues) {
721 : 0 : rxq = dev->data->rx_queues[rx_queue_id];
722 : :
723 [ # # ]: 0 : if (dev->data->rx_queue_state[rx_queue_id] ==
724 : : RTE_ETH_QUEUE_STATE_STOPPED)
725 : : return 0;
726 : :
727 : 0 : err = ice_switch_rx_queue(hw, rxq->reg_idx, false);
728 [ # # ]: 0 : if (err) {
729 : 0 : PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
730 : : rx_queue_id);
731 : 0 : return -EINVAL;
732 : : }
733 : 0 : rxq->rx_rel_mbufs(rxq);
734 : 0 : ice_reset_rx_queue(rxq);
735 : 0 : dev->data->rx_queue_state[rx_queue_id] =
736 : : RTE_ETH_QUEUE_STATE_STOPPED;
737 : : }
738 : :
739 : : return 0;
740 : : }
741 : :
742 : : /**
743 : : * ice_setup_txtime_ctx - setup a struct ice_txtime_ctx instance
744 : : * @txq: The queue on which tstamp ring to configure
745 : : * @txtime_ctx: Pointer to the Tx time queue context structure to be initialized
746 : : * @txtime_ena: Tx time enable flag, set to true if Tx time should be enabled
747 : : */
748 : : static int
749 : 0 : ice_setup_txtime_ctx(struct ci_tx_queue *txq,
750 : : struct ice_txtime_ctx *txtime_ctx, bool txtime_ena)
751 : : {
752 : 0 : struct ice_vsi *vsi = txq->ice_vsi;
753 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
754 : :
755 : 0 : txtime_ctx->base = txq->tsq->ts_mz->iova >> ICE_TX_CMPLTNQ_CTX_BASE_S;
756 : :
757 : : /* Tx time Queue Length */
758 : 0 : txtime_ctx->qlen = txq->tsq->nb_ts_desc;
759 : :
760 [ # # ]: 0 : if (txtime_ena)
761 : 0 : txtime_ctx->txtime_ena_q = 1;
762 : :
763 : : /* PF number */
764 : 0 : txtime_ctx->pf_num = hw->pf_id;
765 : :
766 [ # # ]: 0 : switch (vsi->type) {
767 : 0 : case ICE_VSI_PF:
768 : 0 : txtime_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_PF;
769 : : break;
770 : 0 : default:
771 : 0 : PMD_DRV_LOG(ERR, "Unable to set VMVF type for VSI type %d", vsi->type);
772 : 0 : return -EINVAL;
773 : : }
774 : :
775 : : /* make sure the context is associated with the right VSI */
776 : 0 : txtime_ctx->src_vsi = vsi->vsi_id;
777 : :
778 : 0 : txtime_ctx->ts_res = ICE_TXTIME_CTX_RESOLUTION_128NS;
779 : 0 : txtime_ctx->drbell_mode_32 = ICE_TXTIME_CTX_DRBELL_MODE_32;
780 : 0 : txtime_ctx->ts_fetch_prof_id = ICE_TXTIME_CTX_FETCH_PROF_ID_0;
781 : :
782 : 0 : return 0;
783 : : }
784 : :
785 : : int
786 : 0 : ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
787 : : {
788 : : struct ci_tx_queue *txq;
789 : : int err;
790 : : struct ice_vsi *vsi;
791 : : struct ice_hw *hw;
792 : : struct ice_pf *pf;
793 : : struct ice_aqc_add_tx_qgrp *txq_elem;
794 : : struct ice_tlan_ctx tx_ctx;
795 : : int buf_len;
796 : 0 : struct ice_adapter *ad = ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
797 : : u16 q_base, q_range, cgd_idx = 0;
798 : :
799 : 0 : PMD_INIT_FUNC_TRACE();
800 : :
801 [ # # ]: 0 : if (tx_queue_id >= dev->data->nb_tx_queues) {
802 : 0 : PMD_DRV_LOG(ERR, "TX queue %u is out of range %u",
803 : : tx_queue_id, dev->data->nb_tx_queues);
804 : 0 : return -EINVAL;
805 : : }
806 : :
807 : 0 : txq = dev->data->tx_queues[tx_queue_id];
808 [ # # # # ]: 0 : if (!txq || !txq->q_set) {
809 : 0 : PMD_DRV_LOG(ERR, "TX queue %u is not available or setup",
810 : : tx_queue_id);
811 : 0 : return -EINVAL;
812 : : }
813 : :
814 [ # # ]: 0 : if (dev->data->tx_queue_state[tx_queue_id] ==
815 : : RTE_ETH_QUEUE_STATE_STARTED)
816 : : return 0;
817 : :
818 : : buf_len = ice_struct_size(txq_elem, txqs, 1);
819 : 0 : txq_elem = ice_malloc(hw, buf_len);
820 [ # # ]: 0 : if (!txq_elem)
821 : : return -ENOMEM;
822 : :
823 : 0 : vsi = txq->ice_vsi;
824 : 0 : hw = ICE_VSI_TO_HW(vsi);
825 : 0 : pf = ICE_VSI_TO_PF(vsi);
826 : :
827 : : memset(&tx_ctx, 0, sizeof(tx_ctx));
828 : 0 : txq_elem->num_txqs = 1;
829 : 0 : txq_elem->txqs[0].txq_id = rte_cpu_to_le_16(txq->reg_idx);
830 : :
831 : 0 : tx_ctx.base = txq->tx_ring_dma / ICE_QUEUE_BASE_ADDR_UNIT;
832 : 0 : tx_ctx.qlen = txq->nb_tx_desc;
833 : 0 : tx_ctx.pf_num = hw->pf_id;
834 : 0 : tx_ctx.vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_PF;
835 : 0 : tx_ctx.src_vsi = vsi->vsi_id;
836 : 0 : tx_ctx.port_num = hw->port_info->lport;
837 : 0 : tx_ctx.tso_ena = 1; /* tso enable */
838 : 0 : tx_ctx.tso_qnum = txq->reg_idx; /* index for tso state structure */
839 : 0 : tx_ctx.legacy_int = 1; /* Legacy or Advanced Host Interface */
840 : 0 : tx_ctx.tsyn_ena = 1;
841 : :
842 : : /* Mirror RXQ<->CGD association to TXQ<->CGD */
843 [ # # ]: 0 : for (int i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {
844 : 0 : q_base = rte_le_to_cpu_16(vsi->info.tc_mapping[i]) & ICE_AQ_VSI_TC_Q_OFFSET_M;
845 : 0 : q_range = 1 << ((rte_le_to_cpu_16(vsi->info.tc_mapping[i]) &
846 : 0 : ICE_AQ_VSI_TC_Q_NUM_M) >> ICE_AQ_VSI_TC_Q_NUM_S);
847 : :
848 [ # # # # ]: 0 : if (q_base <= tx_queue_id && tx_queue_id < q_base + q_range)
849 : : break;
850 : :
851 : 0 : cgd_idx++;
852 : : }
853 : :
854 [ # # ]: 0 : if (cgd_idx >= ICE_MAX_TRAFFIC_CLASS) {
855 : 0 : PMD_DRV_LOG(ERR, "Bad queue mapping configuration");
856 : 0 : rte_free(txq_elem);
857 : 0 : return -EINVAL;
858 : : }
859 : :
860 : 0 : tx_ctx.cgd_num = cgd_idx;
861 : :
862 : 0 : ice_set_ctx(hw, (uint8_t *)&tx_ctx, txq_elem->txqs[0].txq_ctx,
863 : : ice_tlan_ctx_info);
864 : :
865 : : /* Fix me, we assume TC always 0 here */
866 : 0 : err = ice_ena_vsi_txq(hw->port_info, vsi->idx, 0, tx_queue_id, 1,
867 : : txq_elem, buf_len, NULL);
868 [ # # ]: 0 : if (err) {
869 : 0 : PMD_DRV_LOG(ERR, "Failed to add lan txq");
870 : 0 : rte_free(txq_elem);
871 : 0 : return -EIO;
872 : : }
873 : : /* store the schedule node id */
874 : 0 : txq->q_teid = txq_elem->txqs[0].q_teid;
875 : :
876 : : /* move the queue to correct position in hierarchy, if explicit hierarchy configured */
877 [ # # ]: 0 : if (pf->tm_conf.committed)
878 [ # # ]: 0 : if (ice_tm_setup_txq_node(pf, hw, tx_queue_id, txq->q_teid) != 0) {
879 : 0 : PMD_DRV_LOG(ERR, "Failed to set up txq traffic management node");
880 : 0 : rte_free(txq_elem);
881 : 0 : return -EIO;
882 : : }
883 : :
884 : : /* record what kind of descriptor cleanup we need on teardown */
885 : 0 : txq->use_vec_entry = ad->tx_vec_allowed || ad->tx_simple_allowed;
886 : :
887 [ # # # # ]: 0 : if (txq->tsq != NULL && txq->tsq->ts_flag > 0) {
888 : : struct ice_aqc_set_txtime_qgrp *ts_elem;
889 : 0 : struct ice_txtime_ctx txtime_ctx = { 0 };
890 : : u8 ts_buf_len = ice_struct_size(ts_elem, txtimeqs, 1);
891 : :
892 : 0 : ts_elem = ice_malloc(hw, ts_buf_len);
893 : 0 : ice_setup_txtime_ctx(txq, &txtime_ctx, true);
894 : 0 : ice_set_ctx(hw, (u8 *)&txtime_ctx,
895 : 0 : ts_elem->txtimeqs[0].txtime_ctx,
896 : : ice_txtime_ctx_info);
897 : :
898 : 0 : txq->qtx_tail = hw->hw_addr + E830_GLQTX_TXTIME_DBELL_LSB(txq->reg_idx);
899 : :
900 : : /* Init the Tx time tail register*/
901 : : ICE_PCI_REG_WRITE(txq->qtx_tail, 0);
902 : :
903 : 0 : err = ice_aq_set_txtimeq(hw, txq->reg_idx, 1, ts_elem, ts_buf_len, NULL);
904 : 0 : rte_free(ts_elem);
905 [ # # ]: 0 : if (err) {
906 : 0 : PMD_DRV_LOG(ERR, "Failed to set Tx Time queue context, error: %d", err);
907 : 0 : rte_free(txq_elem);
908 : 0 : return err;
909 : : }
910 : : } else {
911 : 0 : txq->qtx_tail = hw->hw_addr + QTX_COMM_DBELL(txq->reg_idx);
912 : :
913 : : /* Init the Tx tail register*/
914 : : ICE_PCI_REG_WRITE(txq->qtx_tail, 0);
915 : : }
916 : :
917 : 0 : dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
918 : :
919 : 0 : rte_free(txq_elem);
920 : 0 : return 0;
921 : : }
922 : :
923 : : static int
924 : 0 : ice_fdir_program_hw_rx_queue(struct ci_rx_queue *rxq)
925 : : {
926 : 0 : struct ice_vsi *vsi = rxq->ice_vsi;
927 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
928 : : uint32_t rxdid = ICE_RXDID_LEGACY_1;
929 : : struct ice_rlan_ctx rx_ctx;
930 : : uint32_t regval;
931 : : int err;
932 : :
933 : 0 : rxq->rx_hdr_len = 0;
934 : 0 : rxq->rx_buf_len = 1024;
935 : :
936 : : memset(&rx_ctx, 0, sizeof(rx_ctx));
937 : :
938 : 0 : rx_ctx.base = rxq->rx_ring_phys_addr / ICE_QUEUE_BASE_ADDR_UNIT;
939 : 0 : rx_ctx.qlen = rxq->nb_rx_desc;
940 : 0 : rx_ctx.dbuf = rxq->rx_buf_len >> ICE_RLAN_CTX_DBUF_S;
941 : : rx_ctx.hbuf = rxq->rx_hdr_len >> ICE_RLAN_CTX_HBUF_S;
942 : : rx_ctx.dtype = 0; /* No Buffer Split mode */
943 : 0 : rx_ctx.dsize = 1; /* 32B descriptors */
944 : 0 : rx_ctx.rxmax = ICE_ETH_MAX_LEN;
945 : : /* TPH: Transaction Layer Packet (TLP) processing hints */
946 : 0 : rx_ctx.tphrdesc_ena = 1;
947 : 0 : rx_ctx.tphwdesc_ena = 1;
948 : 0 : rx_ctx.tphdata_ena = 1;
949 : 0 : rx_ctx.tphhead_ena = 1;
950 : : /* Low Receive Queue Threshold defined in 64 descriptors units.
951 : : * When the number of free descriptors goes below the lrxqthresh,
952 : : * an immediate interrupt is triggered.
953 : : */
954 : 0 : rx_ctx.lrxqthresh = 2;
955 : : /*default use 32 byte descriptor, vlan tag extract to L2TAG2(1st)*/
956 : 0 : rx_ctx.l2tsel = 1;
957 : : rx_ctx.showiv = 0;
958 : 0 : rx_ctx.crcstrip = (rxq->crc_len == 0) ? 1 : 0;
959 : :
960 : : /* Enable Flexible Descriptors in the queue context which
961 : : * allows this driver to select a specific receive descriptor format
962 : : */
963 : : regval = (rxdid << QRXFLXP_CNTXT_RXDID_IDX_S) &
964 : : QRXFLXP_CNTXT_RXDID_IDX_M;
965 : :
966 : : /* increasing context priority to pick up profile ID;
967 : : * default is 0x01; setting to 0x03 to ensure profile
968 : : * is programming if prev context is of same priority
969 : : */
970 : : regval |= (0x03 << QRXFLXP_CNTXT_RXDID_PRIO_S) &
971 : : QRXFLXP_CNTXT_RXDID_PRIO_M;
972 : :
973 : 0 : ICE_WRITE_REG(hw, QRXFLXP_CNTXT(rxq->reg_idx), regval);
974 : :
975 : 0 : err = ice_clear_rxq_ctx(hw, rxq->reg_idx);
976 [ # # ]: 0 : if (err) {
977 : 0 : PMD_DRV_LOG(ERR, "Failed to clear Lan Rx queue (%u) context",
978 : : rxq->queue_id);
979 : 0 : return -EINVAL;
980 : : }
981 : 0 : err = ice_write_rxq_ctx(hw, &rx_ctx, rxq->reg_idx);
982 [ # # ]: 0 : if (err) {
983 : 0 : PMD_DRV_LOG(ERR, "Failed to write Lan Rx queue (%u) context",
984 : : rxq->queue_id);
985 : 0 : return -EINVAL;
986 : : }
987 : :
988 : 0 : rxq->qrx_tail = hw->hw_addr + QRX_TAIL(rxq->reg_idx);
989 : :
990 : : /* Init the Rx tail register*/
991 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
992 : :
993 : 0 : return 0;
994 : : }
995 : :
996 : : int
997 : 0 : ice_fdir_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
998 : : {
999 : : struct ci_rx_queue *rxq;
1000 : : int err;
1001 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1002 : : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1003 : :
1004 : 0 : PMD_INIT_FUNC_TRACE();
1005 : :
1006 : 0 : rxq = pf->fdir.rxq;
1007 [ # # # # ]: 0 : if (!rxq || !rxq->q_set) {
1008 : 0 : PMD_DRV_LOG(ERR, "FDIR RX queue %u not available or setup",
1009 : : rx_queue_id);
1010 : 0 : return -EINVAL;
1011 : : }
1012 : :
1013 : 0 : err = ice_fdir_program_hw_rx_queue(rxq);
1014 [ # # ]: 0 : if (err) {
1015 : 0 : PMD_DRV_LOG(ERR, "fail to program FDIR RX queue %u",
1016 : : rx_queue_id);
1017 : 0 : return -EIO;
1018 : : }
1019 : :
1020 : : /* Init the RX tail register. */
1021 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
1022 : :
1023 : 0 : err = ice_switch_rx_queue(hw, rxq->reg_idx, true);
1024 [ # # ]: 0 : if (err) {
1025 : 0 : PMD_DRV_LOG(ERR, "Failed to switch FDIR RX queue %u on",
1026 : : rx_queue_id);
1027 : :
1028 : 0 : ice_reset_rx_queue(rxq);
1029 : 0 : return -EINVAL;
1030 : : }
1031 : :
1032 : : return 0;
1033 : : }
1034 : :
1035 : : int
1036 : 0 : ice_fdir_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
1037 : : {
1038 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1039 : : struct ci_tx_queue *txq;
1040 : : int err;
1041 : : struct ice_vsi *vsi;
1042 : : struct ice_hw *hw;
1043 : : struct ice_aqc_add_tx_qgrp *txq_elem;
1044 : : struct ice_tlan_ctx tx_ctx;
1045 : : int buf_len;
1046 : :
1047 : 0 : PMD_INIT_FUNC_TRACE();
1048 : :
1049 : 0 : txq = pf->fdir.txq;
1050 [ # # # # ]: 0 : if (!txq || !txq->q_set) {
1051 : 0 : PMD_DRV_LOG(ERR, "FDIR TX queue %u is not available or setup",
1052 : : tx_queue_id);
1053 : 0 : return -EINVAL;
1054 : : }
1055 : :
1056 : : buf_len = ice_struct_size(txq_elem, txqs, 1);
1057 : 0 : txq_elem = ice_malloc(hw, buf_len);
1058 [ # # ]: 0 : if (!txq_elem)
1059 : : return -ENOMEM;
1060 : :
1061 : 0 : vsi = txq->ice_vsi;
1062 : 0 : hw = ICE_VSI_TO_HW(vsi);
1063 : :
1064 : : memset(&tx_ctx, 0, sizeof(tx_ctx));
1065 : 0 : txq_elem->num_txqs = 1;
1066 : 0 : txq_elem->txqs[0].txq_id = rte_cpu_to_le_16(txq->reg_idx);
1067 : :
1068 : 0 : tx_ctx.base = txq->tx_ring_dma / ICE_QUEUE_BASE_ADDR_UNIT;
1069 : 0 : tx_ctx.qlen = txq->nb_tx_desc;
1070 : 0 : tx_ctx.pf_num = hw->pf_id;
1071 : 0 : tx_ctx.vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_PF;
1072 : 0 : tx_ctx.src_vsi = vsi->vsi_id;
1073 : 0 : tx_ctx.port_num = hw->port_info->lport;
1074 : 0 : tx_ctx.tso_ena = 1; /* tso enable */
1075 : 0 : tx_ctx.tso_qnum = txq->reg_idx; /* index for tso state structure */
1076 : 0 : tx_ctx.legacy_int = 1; /* Legacy or Advanced Host Interface */
1077 : :
1078 : 0 : ice_set_ctx(hw, (uint8_t *)&tx_ctx, txq_elem->txqs[0].txq_ctx,
1079 : : ice_tlan_ctx_info);
1080 : :
1081 : 0 : txq->qtx_tail = hw->hw_addr + QTX_COMM_DBELL(txq->reg_idx);
1082 : :
1083 : : /* Init the Tx tail register*/
1084 : : ICE_PCI_REG_WRITE(txq->qtx_tail, 0);
1085 : :
1086 : : /* Fix me, we assume TC always 0 here */
1087 : 0 : err = ice_ena_vsi_txq(hw->port_info, vsi->idx, 0, tx_queue_id, 1,
1088 : : txq_elem, buf_len, NULL);
1089 [ # # ]: 0 : if (err) {
1090 : 0 : PMD_DRV_LOG(ERR, "Failed to add FDIR txq");
1091 : 0 : rte_free(txq_elem);
1092 : 0 : return -EIO;
1093 : : }
1094 : : /* store the schedule node id */
1095 : 0 : txq->q_teid = txq_elem->txqs[0].q_teid;
1096 : :
1097 : 0 : rte_free(txq_elem);
1098 : 0 : return 0;
1099 : : }
1100 : :
1101 : : static void
1102 : 0 : ice_reset_tx_queue(struct ci_tx_queue *txq)
1103 : : {
1104 : : struct ci_tx_entry *txe;
1105 : : uint16_t i, prev, size;
1106 : :
1107 [ # # ]: 0 : if (!txq) {
1108 : 0 : PMD_DRV_LOG(DEBUG, "Pointer to txq is NULL");
1109 : 0 : return;
1110 : : }
1111 : :
1112 : 0 : txe = txq->sw_ring;
1113 : 0 : size = sizeof(struct ci_tx_desc) * txq->nb_tx_desc;
1114 [ # # ]: 0 : for (i = 0; i < size; i++)
1115 : 0 : ((volatile char *)txq->ci_tx_ring)[i] = 0;
1116 : :
1117 : 0 : prev = (uint16_t)(txq->nb_tx_desc - 1);
1118 [ # # ]: 0 : for (i = 0; i < txq->nb_tx_desc; i++) {
1119 : 0 : volatile struct ci_tx_desc *txd = &txq->ci_tx_ring[i];
1120 : :
1121 : 0 : txd->cmd_type_offset_bsz =
1122 : : rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
1123 : 0 : txe[i].mbuf = NULL;
1124 : 0 : txe[prev].next_id = i;
1125 : : prev = i;
1126 : : }
1127 : :
1128 : 0 : txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1);
1129 : 0 : txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
1130 : :
1131 : 0 : txq->tx_tail = 0;
1132 : :
1133 : 0 : txq->last_desc_cleaned = (uint16_t)(txq->nb_tx_desc - 1);
1134 : 0 : txq->nb_tx_free = (uint16_t)(txq->nb_tx_desc - 1);
1135 : :
1136 [ # # # # ]: 0 : if (txq->tsq != NULL && txq->tsq->ts_flag > 0) {
1137 [ # # ]: 0 : for (i = 0; i < txq->tsq->nb_ts_desc; i++) {
1138 : 0 : volatile struct ice_ts_desc *tsd = &txq->tsq->ice_ts_ring[i];
1139 : 0 : tsd->tx_desc_idx_tstamp = 0;
1140 : : }
1141 : :
1142 : 0 : txq->tsq->ts_tail = 0;
1143 : : }
1144 : : }
1145 : :
1146 : : int
1147 : 0 : ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
1148 : : {
1149 : : struct ci_tx_queue *txq;
1150 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1151 : : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1152 : 0 : struct ice_vsi *vsi = pf->main_vsi;
1153 : : uint16_t q_ids[1];
1154 : : uint32_t q_teids[1];
1155 : 0 : uint16_t q_handle = tx_queue_id;
1156 : : int status;
1157 : :
1158 [ # # ]: 0 : if (tx_queue_id >= dev->data->nb_tx_queues) {
1159 : 0 : PMD_DRV_LOG(ERR, "TX queue %u is out of range %u",
1160 : : tx_queue_id, dev->data->nb_tx_queues);
1161 : 0 : return -EINVAL;
1162 : : }
1163 : :
1164 : 0 : txq = dev->data->tx_queues[tx_queue_id];
1165 [ # # ]: 0 : if (!txq) {
1166 : 0 : PMD_DRV_LOG(ERR, "TX queue %u is not available",
1167 : : tx_queue_id);
1168 : 0 : return -EINVAL;
1169 : : }
1170 : :
1171 [ # # ]: 0 : if (dev->data->tx_queue_state[tx_queue_id] ==
1172 : : RTE_ETH_QUEUE_STATE_STOPPED)
1173 : : return 0;
1174 : :
1175 : 0 : q_ids[0] = txq->reg_idx;
1176 : 0 : q_teids[0] = txq->q_teid;
1177 : :
1178 [ # # # # ]: 0 : if (txq->tsq != NULL && txq->tsq->ts_flag > 0) {
1179 : : struct ice_aqc_ena_dis_txtime_qgrp txtime_pg;
1180 : :
1181 : 0 : status = ice_aq_ena_dis_txtimeq(hw, q_ids[0], 1, 0, &txtime_pg, NULL);
1182 [ # # ]: 0 : if (status != ICE_SUCCESS) {
1183 : 0 : PMD_DRV_LOG(DEBUG, "Failed to disable Tx time queue");
1184 : 0 : return -EINVAL;
1185 : : }
1186 : : }
1187 : :
1188 : : /* Fix me, we assume TC always 0 here */
1189 : 0 : status = ice_dis_vsi_txq(hw->port_info, vsi->idx, 0, 1, &q_handle,
1190 : : q_ids, q_teids, ICE_NO_RESET, 0, NULL);
1191 [ # # ]: 0 : if (status != ICE_SUCCESS) {
1192 : 0 : PMD_DRV_LOG(DEBUG, "Failed to disable Lan Tx queue");
1193 : 0 : return -EINVAL;
1194 : : }
1195 : :
1196 : 0 : ci_txq_release_all_mbufs(txq, false);
1197 : 0 : ice_reset_tx_queue(txq);
1198 : 0 : dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
1199 : :
1200 : 0 : return 0;
1201 : : }
1202 : :
1203 : : int
1204 : 0 : ice_fdir_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
1205 : : {
1206 : : struct ci_rx_queue *rxq;
1207 : : int err;
1208 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1209 : : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1210 : :
1211 : 0 : rxq = pf->fdir.rxq;
1212 : :
1213 : 0 : err = ice_switch_rx_queue(hw, rxq->reg_idx, false);
1214 [ # # ]: 0 : if (err) {
1215 : 0 : PMD_DRV_LOG(ERR, "Failed to switch FDIR RX queue %u off",
1216 : : rx_queue_id);
1217 : 0 : return -EINVAL;
1218 : : }
1219 : 0 : rxq->rx_rel_mbufs(rxq);
1220 : :
1221 : 0 : return 0;
1222 : : }
1223 : :
1224 : : int
1225 : 0 : ice_fdir_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
1226 : : {
1227 : : struct ci_tx_queue *txq;
1228 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1229 : : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1230 : : struct ice_vsi *vsi = pf->main_vsi;
1231 : : uint16_t q_ids[1];
1232 : : uint32_t q_teids[1];
1233 : 0 : uint16_t q_handle = tx_queue_id;
1234 : : int status;
1235 : :
1236 : 0 : txq = pf->fdir.txq;
1237 [ # # ]: 0 : if (!txq) {
1238 : 0 : PMD_DRV_LOG(ERR, "TX queue %u is not available",
1239 : : tx_queue_id);
1240 : 0 : return -EINVAL;
1241 : : }
1242 [ # # ]: 0 : if (txq->qtx_tail == NULL) {
1243 : 0 : PMD_DRV_LOG(INFO, "TX queue %u not started", tx_queue_id);
1244 : 0 : return 0;
1245 : : }
1246 : 0 : vsi = txq->ice_vsi;
1247 : :
1248 : 0 : q_ids[0] = txq->reg_idx;
1249 : 0 : q_teids[0] = txq->q_teid;
1250 : :
1251 : : /* Fix me, we assume TC always 0 here */
1252 : 0 : status = ice_dis_vsi_txq(hw->port_info, vsi->idx, 0, 1, &q_handle,
1253 : : q_ids, q_teids, ICE_NO_RESET, 0, NULL);
1254 [ # # ]: 0 : if (status != ICE_SUCCESS) {
1255 : 0 : PMD_DRV_LOG(DEBUG, "Failed to disable Lan Tx queue");
1256 : 0 : return -EINVAL;
1257 : : }
1258 : :
1259 : 0 : ci_txq_release_all_mbufs(txq, false);
1260 : 0 : txq->qtx_tail = NULL;
1261 : :
1262 : 0 : return 0;
1263 : : }
1264 : :
1265 : : int
1266 : 0 : ice_rx_queue_setup(struct rte_eth_dev *dev,
1267 : : uint16_t queue_idx,
1268 : : uint16_t nb_desc,
1269 : : unsigned int socket_id,
1270 : : const struct rte_eth_rxconf *rx_conf,
1271 : : struct rte_mempool *mp)
1272 : : {
1273 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1274 : : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1275 : : struct ice_adapter *ad =
1276 : : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
1277 : 0 : struct ice_vsi *vsi = pf->main_vsi;
1278 : : struct ci_rx_queue *rxq;
1279 : : const struct rte_memzone *rz;
1280 : : uint32_t ring_size, tlen;
1281 : : uint16_t len;
1282 : : int use_def_burst_func = 1;
1283 : : uint64_t offloads;
1284 : 0 : uint16_t n_seg = rx_conf->rx_nseg;
1285 : : uint16_t i;
1286 : :
1287 [ # # ]: 0 : if (nb_desc % ICE_ALIGN_RING_DESC != 0 ||
1288 [ # # ]: 0 : nb_desc > ICE_MAX_RING_DESC ||
1289 : : nb_desc < ICE_MIN_RING_DESC) {
1290 : 0 : PMD_INIT_LOG(ERR, "Number (%u) of receive descriptors is "
1291 : : "invalid", nb_desc);
1292 : 0 : return -EINVAL;
1293 : : }
1294 : :
1295 : : /* Check that ring size is > 2 * rx_free_thresh */
1296 [ # # ]: 0 : if (nb_desc <= 2 * rx_conf->rx_free_thresh) {
1297 : 0 : PMD_INIT_LOG(ERR, "rx ring size (%u) must be > 2 * rx_free_thresh (%u)",
1298 : : nb_desc, rx_conf->rx_free_thresh);
1299 [ # # ]: 0 : if (nb_desc == ICE_MIN_RING_DESC)
1300 : 0 : PMD_INIT_LOG(ERR, "To use the minimum ring size (%u), reduce rx_free_thresh to a lower value (recommended %u)",
1301 : : ICE_MIN_RING_DESC, ICE_MIN_RING_DESC / 4);
1302 : 0 : return -EINVAL;
1303 : : }
1304 : :
1305 : 0 : offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
1306 : :
1307 [ # # ]: 0 : if (mp)
1308 : : n_seg = 1;
1309 : :
1310 [ # # # # ]: 0 : if (n_seg > 1 && !(offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
1311 : 0 : PMD_INIT_LOG(ERR, "port %u queue index %u split offload not configured",
1312 : : dev->data->port_id, queue_idx);
1313 : 0 : return -EINVAL;
1314 : : }
1315 : :
1316 : : /* Free memory if needed */
1317 [ # # ]: 0 : if (dev->data->rx_queues[queue_idx]) {
1318 : 0 : ice_rx_queue_release(dev->data->rx_queues[queue_idx]);
1319 : 0 : dev->data->rx_queues[queue_idx] = NULL;
1320 : : }
1321 : :
1322 : : /* Allocate the rx queue data structure */
1323 : 0 : rxq = rte_zmalloc_socket(NULL,
1324 : : sizeof(struct ci_rx_queue),
1325 : : RTE_CACHE_LINE_SIZE,
1326 : : socket_id);
1327 : :
1328 [ # # ]: 0 : if (!rxq) {
1329 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for "
1330 : : "rx queue data structure");
1331 : 0 : return -ENOMEM;
1332 : : }
1333 : :
1334 : 0 : rxq->rxseg_nb = n_seg;
1335 [ # # ]: 0 : if (n_seg > 1) {
1336 [ # # ]: 0 : for (i = 0; i < n_seg; i++)
1337 : 0 : memcpy(&rxq->rxseg[i], &rx_conf->rx_seg[i].split,
1338 : : sizeof(struct rte_eth_rxseg_split));
1339 : :
1340 : 0 : rxq->mp = rxq->rxseg[0].mp;
1341 : : } else {
1342 : 0 : rxq->mp = mp;
1343 : : }
1344 : :
1345 : 0 : rxq->nb_rx_desc = nb_desc;
1346 : 0 : rxq->rx_free_thresh = rx_conf->rx_free_thresh;
1347 : 0 : rxq->queue_id = queue_idx;
1348 : 0 : rxq->offloads = offloads;
1349 : :
1350 : 0 : rxq->reg_idx = vsi->base_queue + queue_idx;
1351 : 0 : rxq->port_id = dev->data->port_id;
1352 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
1353 : 0 : rxq->crc_len = RTE_ETHER_CRC_LEN;
1354 : : else
1355 : 0 : rxq->crc_len = 0;
1356 : :
1357 : 0 : rxq->drop_en = rx_conf->rx_drop_en;
1358 : 0 : rxq->ice_vsi = vsi;
1359 : 0 : rxq->rx_deferred_start = rx_conf->rx_deferred_start;
1360 : 0 : rxq->proto_xtr = pf->proto_xtr != NULL ?
1361 [ # # ]: 0 : pf->proto_xtr[queue_idx] : PROTO_XTR_NONE;
1362 [ # # ]: 0 : if (rxq->proto_xtr != PROTO_XTR_NONE &&
1363 [ # # ]: 0 : ad->devargs.xtr_flag_offs[rxq->proto_xtr] != 0xff)
1364 : 0 : rxq->xtr_ol_flag = 1ULL << ad->devargs.xtr_flag_offs[rxq->proto_xtr];
1365 : 0 : rxq->xtr_field_offs = ad->devargs.xtr_field_offs;
1366 : :
1367 : : /* Allocate the maximum number of RX ring hardware descriptor. */
1368 : : len = ICE_MAX_NUM_DESC_BY_MAC(hw);
1369 : :
1370 : : /**
1371 : : * Allocating a little more memory because vectorized/bulk_alloc Rx
1372 : : * functions doesn't check boundaries each time.
1373 : : */
1374 : : len += ICE_RX_MAX_BURST;
1375 : :
1376 : : /* Allocate the maximum number of RX ring hardware descriptor. */
1377 : : ring_size = sizeof(union ci_rx_flex_desc) * len;
1378 : : ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
1379 : 0 : rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx,
1380 : : ring_size, ICE_RING_BASE_ALIGN,
1381 : : socket_id);
1382 [ # # ]: 0 : if (!rz) {
1383 : 0 : ice_rx_queue_release(rxq);
1384 : 0 : PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for RX");
1385 : 0 : return -ENOMEM;
1386 : : }
1387 : :
1388 : 0 : rxq->mz = rz;
1389 : : /* Zero all the descriptors in the ring. */
1390 [ # # ]: 0 : memset(rz->addr, 0, ring_size);
1391 : :
1392 : 0 : rxq->rx_ring_phys_addr = rz->iova;
1393 : 0 : rxq->rx_flex_ring = rz->addr;
1394 : :
1395 : : /* always reserve more for bulk alloc */
1396 : 0 : len = (uint16_t)(nb_desc + ICE_RX_MAX_BURST);
1397 : :
1398 : : /* allocate extra entries for SW split buffer */
1399 : 0 : tlen = ((rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) != 0) ?
1400 [ # # ]: 0 : rxq->rx_free_thresh : 0;
1401 : 0 : tlen += len;
1402 : :
1403 : : /* Allocate the software ring. */
1404 : 0 : rxq->sw_ring = rte_zmalloc_socket(NULL,
1405 : : sizeof(struct ci_rx_entry) * tlen,
1406 : : RTE_CACHE_LINE_SIZE,
1407 : : socket_id);
1408 [ # # ]: 0 : if (!rxq->sw_ring) {
1409 : 0 : ice_rx_queue_release(rxq);
1410 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for SW ring");
1411 : 0 : return -ENOMEM;
1412 : : }
1413 : :
1414 [ # # ]: 0 : rxq->sw_split_buf = (tlen == len) ? NULL : rxq->sw_ring + len;
1415 : :
1416 : 0 : ice_reset_rx_queue(rxq);
1417 : 0 : rxq->q_set = true;
1418 : 0 : dev->data->rx_queues[queue_idx] = rxq;
1419 : 0 : rxq->rx_rel_mbufs = _ice_rx_queue_release_mbufs;
1420 : :
1421 : 0 : use_def_burst_func = ice_check_rx_burst_bulk_alloc_preconditions(rxq);
1422 : :
1423 [ # # ]: 0 : if (!use_def_burst_func) {
1424 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
1425 : : "satisfied. Rx Burst Bulk Alloc function will be "
1426 : : "used on port=%d, queue=%d.",
1427 : : rxq->port_id, rxq->queue_id);
1428 : : } else {
1429 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
1430 : : "not satisfied, Scattered Rx is requested. "
1431 : : "on port=%d, queue=%d.",
1432 : : rxq->port_id, rxq->queue_id);
1433 : 0 : ad->rx_bulk_alloc_allowed = false;
1434 : : }
1435 : :
1436 : : return 0;
1437 : : }
1438 : :
1439 : : void
1440 : 0 : ice_rx_queue_release(void *rxq)
1441 : : {
1442 : : struct ci_rx_queue *q = (struct ci_rx_queue *)rxq;
1443 : :
1444 [ # # ]: 0 : if (!q) {
1445 : 0 : PMD_DRV_LOG(DEBUG, "Pointer to rxq is NULL");
1446 : 0 : return;
1447 : : }
1448 : :
1449 [ # # ]: 0 : if (q->rx_rel_mbufs != NULL)
1450 : 0 : q->rx_rel_mbufs(q);
1451 : 0 : rte_free(q->sw_ring);
1452 : 0 : rte_memzone_free(q->mz);
1453 : 0 : rte_free(q);
1454 : : }
1455 : :
1456 : : /**
1457 : : * ice_calc_ts_ring_count - Calculate the number of timestamp descriptors
1458 : : * @hw: pointer to the hardware structure
1459 : : * @tx_desc_count: number of Tx descriptors in the ring
1460 : : *
1461 : : * Return: the number of timestamp descriptors
1462 : : */
1463 : : static uint16_t
1464 : : ice_calc_ts_ring_count(struct ice_hw *hw, u16 tx_desc_count)
1465 : : {
1466 : : u16 prof = ICE_TXTIME_CTX_FETCH_PROF_ID_0;
1467 : : u16 max_fetch_desc = 0;
1468 : : u16 fetch;
1469 : : u32 reg;
1470 : : u16 i;
1471 : :
1472 [ # # ]: 0 : for (i = 0; i < ICE_TXTIME_FETCH_PROFILE_CNT; i++) {
1473 : 0 : reg = rd32(hw, E830_GLTXTIME_FETCH_PROFILE(prof, 0));
1474 : 0 : fetch = FIELD_GET(E830_GLTXTIME_FETCH_PROFILE_FETCH_TS_DESC_M, reg);
1475 : 0 : max_fetch_desc = max(fetch, max_fetch_desc);
1476 : : }
1477 : :
1478 [ # # ]: 0 : if (!max_fetch_desc)
1479 : : max_fetch_desc = ICE_TXTIME_FETCH_TS_DESC_DFLT;
1480 : :
1481 : 0 : max_fetch_desc = RTE_ALIGN(max_fetch_desc, ICE_REQ_DESC_MULTIPLE);
1482 : :
1483 : 0 : return tx_desc_count + max_fetch_desc;
1484 : : }
1485 : :
1486 : : int
1487 : 0 : ice_tx_queue_setup(struct rte_eth_dev *dev,
1488 : : uint16_t queue_idx,
1489 : : uint16_t nb_desc,
1490 : : unsigned int socket_id,
1491 : : const struct rte_eth_txconf *tx_conf)
1492 : : {
1493 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1494 : : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1495 : 0 : struct ice_vsi *vsi = pf->main_vsi;
1496 : : struct ci_tx_queue *txq;
1497 : : const struct rte_memzone *tz;
1498 : : uint32_t ring_size;
1499 : : uint16_t tx_rs_thresh, tx_free_thresh;
1500 : : uint64_t offloads;
1501 : :
1502 : 0 : offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
1503 : :
1504 [ # # ]: 0 : if (nb_desc % ICE_ALIGN_RING_DESC != 0 ||
1505 [ # # ]: 0 : nb_desc > ICE_MAX_RING_DESC ||
1506 : : nb_desc < ICE_MIN_RING_DESC) {
1507 : 0 : PMD_INIT_LOG(ERR, "Number (%u) of transmit descriptors is "
1508 : : "invalid", nb_desc);
1509 : 0 : return -EINVAL;
1510 : : }
1511 : :
1512 : : /**
1513 : : * The following two parameters control the setting of the RS bit on
1514 : : * transmit descriptors. TX descriptors will have their RS bit set
1515 : : * after txq->tx_rs_thresh descriptors have been used. The TX
1516 : : * descriptor ring will be cleaned after txq->tx_free_thresh
1517 : : * descriptors are used or if the number of descriptors required to
1518 : : * transmit a packet is greater than the number of free TX descriptors.
1519 : : *
1520 : : * The following constraints must be satisfied:
1521 : : * - tx_rs_thresh must be greater than 0.
1522 : : * - tx_rs_thresh must be less than the size of the ring minus 2.
1523 : : * - tx_rs_thresh must be less than or equal to tx_free_thresh.
1524 : : * - tx_rs_thresh must be a divisor of the ring size.
1525 : : * - tx_free_thresh must be greater than 0.
1526 : : * - tx_free_thresh must be less than the size of the ring minus 3.
1527 : : * - tx_free_thresh + tx_rs_thresh must not exceed nb_desc.
1528 : : *
1529 : : * One descriptor in the TX ring is used as a sentinel to avoid a H/W
1530 : : * race condition, hence the maximum threshold constraints. When set
1531 : : * to zero use default values.
1532 : : */
1533 [ # # ]: 0 : tx_free_thresh = (uint16_t)(tx_conf->tx_free_thresh ?
1534 : : tx_conf->tx_free_thresh :
1535 : : ICE_DEFAULT_TX_FREE_THRESH);
1536 : : /* force tx_rs_thresh to adapt an aggressive tx_free_thresh */
1537 : 0 : tx_rs_thresh =
1538 [ # # ]: 0 : (ICE_DEFAULT_TX_RSBIT_THRESH + tx_free_thresh > nb_desc) ?
1539 : : nb_desc - tx_free_thresh : ICE_DEFAULT_TX_RSBIT_THRESH;
1540 [ # # ]: 0 : if (tx_conf->tx_rs_thresh)
1541 : : tx_rs_thresh = tx_conf->tx_rs_thresh;
1542 [ # # ]: 0 : if (tx_rs_thresh + tx_free_thresh > nb_desc) {
1543 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh + tx_free_thresh must not "
1544 : : "exceed nb_desc. (tx_rs_thresh=%u "
1545 : : "tx_free_thresh=%u nb_desc=%u port = %d queue=%d)",
1546 : : (unsigned int)tx_rs_thresh,
1547 : : (unsigned int)tx_free_thresh,
1548 : : (unsigned int)nb_desc,
1549 : : (int)dev->data->port_id,
1550 : : (int)queue_idx);
1551 : 0 : return -EINVAL;
1552 : : }
1553 [ # # ]: 0 : if (tx_rs_thresh >= (nb_desc - 2)) {
1554 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than the "
1555 : : "number of TX descriptors minus 2. "
1556 : : "(tx_rs_thresh=%u port=%d queue=%d)",
1557 : : (unsigned int)tx_rs_thresh,
1558 : : (int)dev->data->port_id,
1559 : : (int)queue_idx);
1560 : 0 : return -EINVAL;
1561 : : }
1562 [ # # ]: 0 : if (tx_free_thresh >= (nb_desc - 3)) {
1563 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than the "
1564 : : "tx_free_thresh must be less than the "
1565 : : "number of TX descriptors minus 3. "
1566 : : "(tx_free_thresh=%u port=%d queue=%d)",
1567 : : (unsigned int)tx_free_thresh,
1568 : : (int)dev->data->port_id,
1569 : : (int)queue_idx);
1570 : 0 : return -EINVAL;
1571 : : }
1572 [ # # ]: 0 : if (tx_rs_thresh > tx_free_thresh) {
1573 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than or "
1574 : : "equal to tx_free_thresh. (tx_free_thresh=%u"
1575 : : " tx_rs_thresh=%u port=%d queue=%d)",
1576 : : (unsigned int)tx_free_thresh,
1577 : : (unsigned int)tx_rs_thresh,
1578 : : (int)dev->data->port_id,
1579 : : (int)queue_idx);
1580 : 0 : return -EINVAL;
1581 : : }
1582 [ # # ]: 0 : if ((nb_desc % tx_rs_thresh) != 0) {
1583 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be a divisor of the "
1584 : : "number of TX descriptors. (tx_rs_thresh=%u"
1585 : : " port=%d queue=%d)",
1586 : : (unsigned int)tx_rs_thresh,
1587 : : (int)dev->data->port_id,
1588 : : (int)queue_idx);
1589 : 0 : return -EINVAL;
1590 : : }
1591 [ # # ]: 0 : if (!rte_is_power_of_2(tx_rs_thresh)) {
1592 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be a power of 2. (tx_rs_thresh=%u port=%d queue=%d)",
1593 : : (unsigned int)tx_rs_thresh,
1594 : : (int)dev->data->port_id,
1595 : : (int)queue_idx);
1596 : 0 : return -EINVAL;
1597 : : }
1598 [ # # # # ]: 0 : if (tx_rs_thresh > 1 && tx_conf->tx_thresh.wthresh != 0) {
1599 : 0 : PMD_INIT_LOG(ERR, "TX WTHRESH must be set to 0 if "
1600 : : "tx_rs_thresh is greater than 1. "
1601 : : "(tx_rs_thresh=%u port=%d queue=%d)",
1602 : : (unsigned int)tx_rs_thresh,
1603 : : (int)dev->data->port_id,
1604 : : (int)queue_idx);
1605 : 0 : return -EINVAL;
1606 : : }
1607 : :
1608 : : /* Free memory if needed. */
1609 [ # # ]: 0 : if (dev->data->tx_queues[queue_idx]) {
1610 : 0 : ice_tx_queue_release(dev->data->tx_queues[queue_idx]);
1611 : 0 : dev->data->tx_queues[queue_idx] = NULL;
1612 : : }
1613 : :
1614 : : /* Allocate the TX queue data structure. */
1615 : 0 : txq = rte_zmalloc_socket(NULL,
1616 : : sizeof(struct ci_tx_queue),
1617 : : RTE_CACHE_LINE_SIZE,
1618 : : socket_id);
1619 [ # # ]: 0 : if (!txq) {
1620 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for "
1621 : : "tx queue structure");
1622 : 0 : return -ENOMEM;
1623 : : }
1624 : :
1625 : : /* Allocate TX hardware ring descriptors. */
1626 : : ring_size = sizeof(struct ci_tx_desc) * ICE_MAX_NUM_DESC_BY_MAC(hw);
1627 : : ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
1628 : 0 : tz = rte_eth_dma_zone_reserve(dev, "ci_tx_ring", queue_idx,
1629 : : ring_size, ICE_RING_BASE_ALIGN,
1630 : : socket_id);
1631 [ # # ]: 0 : if (!tz) {
1632 : 0 : ice_tx_queue_release(txq);
1633 : 0 : PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for TX");
1634 : 0 : return -ENOMEM;
1635 : : }
1636 : :
1637 : 0 : txq->mz = tz;
1638 : 0 : txq->nb_tx_desc = nb_desc;
1639 [ # # ]: 0 : txq->tx_rs_thresh = tx_rs_thresh;
1640 : 0 : txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
1641 : 0 : txq->tx_free_thresh = tx_free_thresh;
1642 : 0 : txq->queue_id = queue_idx;
1643 : :
1644 : 0 : txq->reg_idx = vsi->base_queue + queue_idx;
1645 : 0 : txq->port_id = dev->data->port_id;
1646 : 0 : txq->fast_free_mp = offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE ?
1647 [ # # ]: 0 : (void *)UINTPTR_MAX : NULL;
1648 : 0 : txq->offloads = offloads;
1649 : 0 : txq->ice_vsi = vsi;
1650 : 0 : txq->tx_deferred_start = tx_conf->tx_deferred_start;
1651 : :
1652 : 0 : txq->tx_ring_dma = tz->iova;
1653 : 0 : txq->ci_tx_ring = tz->addr;
1654 : :
1655 : : /* Allocate software ring */
1656 : 0 : txq->sw_ring =
1657 : 0 : rte_zmalloc_socket(NULL,
1658 : : sizeof(struct ci_tx_entry) * nb_desc,
1659 : : RTE_CACHE_LINE_SIZE,
1660 : : socket_id);
1661 [ # # ]: 0 : if (!txq->sw_ring) {
1662 : 0 : ice_tx_queue_release(txq);
1663 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for SW TX ring");
1664 : 0 : return -ENOMEM;
1665 : : }
1666 : :
1667 : : /* Allocate RS last_id tracking array */
1668 : 0 : uint16_t num_rs_buckets = nb_desc / tx_rs_thresh;
1669 : 0 : txq->rs_last_id = rte_zmalloc_socket(NULL, sizeof(txq->rs_last_id[0]) * num_rs_buckets,
1670 : : RTE_CACHE_LINE_SIZE, socket_id);
1671 [ # # ]: 0 : if (txq->rs_last_id == NULL) {
1672 : 0 : ice_tx_queue_release(txq);
1673 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for RS last_id array");
1674 : 0 : return -ENOMEM;
1675 : : }
1676 : :
1677 [ # # # # ]: 0 : if (vsi->type == ICE_VSI_PF && (offloads & RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP)) {
1678 [ # # ]: 0 : if (hw->phy_model != ICE_PHY_E830) {
1679 : 0 : ice_tx_queue_release(txq);
1680 : 0 : PMD_INIT_LOG(ERR, "Tx Time Queue is not supported on this device");
1681 : 0 : return -EINVAL;
1682 : : }
1683 : :
1684 : 0 : txq->tsq = rte_zmalloc_socket(NULL, sizeof(struct ice_txtime),
1685 : : RTE_CACHE_LINE_SIZE, socket_id);
1686 [ # # ]: 0 : if (!txq->tsq) {
1687 : 0 : ice_tx_queue_release(txq);
1688 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for tx time queue structure");
1689 : 0 : return -ENOMEM;
1690 : : }
1691 : :
1692 : : int ret =
1693 : 0 : rte_mbuf_dyn_tx_timestamp_register(&txq->tsq->ts_offset,
1694 : : &txq->tsq->ts_flag);
1695 [ # # ]: 0 : if (ret) {
1696 : 0 : ice_tx_queue_release(txq);
1697 : 0 : PMD_INIT_LOG(ERR, "Cannot register Tx mbuf field/flag for timestamp");
1698 : 0 : return -EINVAL;
1699 : : }
1700 : :
1701 : 0 : txq->tsq->nb_ts_desc = ice_calc_ts_ring_count(ICE_VSI_TO_HW(vsi), txq->nb_tx_desc);
1702 : 0 : ring_size = sizeof(struct ice_ts_desc) * txq->tsq->nb_ts_desc;
1703 : 0 : ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
1704 : 0 : const struct rte_memzone *ts_z = rte_eth_dma_zone_reserve(dev, "ice_tstamp_ring",
1705 : : queue_idx, ring_size, ICE_RING_BASE_ALIGN, socket_id);
1706 [ # # ]: 0 : if (!ts_z) {
1707 : 0 : ice_tx_queue_release(txq);
1708 : 0 : PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for TX timestamp");
1709 : 0 : return -ENOMEM;
1710 : : }
1711 : 0 : txq->tsq->ts_mz = ts_z;
1712 : 0 : txq->tsq->ice_ts_ring = ts_z->addr;
1713 : : } else {
1714 : 0 : txq->tsq = NULL;
1715 : : }
1716 : :
1717 : 0 : ice_reset_tx_queue(txq);
1718 : 0 : txq->q_set = true;
1719 : 0 : dev->data->tx_queues[queue_idx] = txq;
1720 : 0 : ice_set_tx_function_flag(dev, txq);
1721 : :
1722 : 0 : return 0;
1723 : : }
1724 : :
1725 : : void
1726 : 0 : ice_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
1727 : : {
1728 : 0 : ice_rx_queue_release(dev->data->rx_queues[qid]);
1729 : 0 : }
1730 : :
1731 : : void
1732 : 0 : ice_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
1733 : : {
1734 : 0 : ice_tx_queue_release(dev->data->tx_queues[qid]);
1735 : 0 : }
1736 : :
1737 : : void
1738 : 0 : ice_tx_queue_release(void *txq)
1739 : : {
1740 : : struct ci_tx_queue *q = (struct ci_tx_queue *)txq;
1741 : :
1742 [ # # ]: 0 : if (!q) {
1743 : 0 : PMD_DRV_LOG(DEBUG, "Pointer to TX queue is NULL");
1744 : 0 : return;
1745 : : }
1746 : :
1747 : 0 : ci_txq_release_all_mbufs(q, false);
1748 : 0 : rte_free(q->sw_ring);
1749 : 0 : rte_free(q->rs_last_id);
1750 [ # # ]: 0 : if (q->tsq) {
1751 : 0 : rte_memzone_free(q->tsq->ts_mz);
1752 : 0 : rte_free(q->tsq);
1753 : : }
1754 : 0 : rte_memzone_free(q->mz);
1755 : 0 : rte_free(q);
1756 : : }
1757 : :
1758 : : void
1759 : 0 : ice_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
1760 : : struct rte_eth_rxq_info *qinfo)
1761 : : {
1762 : : struct ci_rx_queue *rxq;
1763 : :
1764 : 0 : rxq = dev->data->rx_queues[queue_id];
1765 : :
1766 : 0 : qinfo->mp = rxq->mp;
1767 : 0 : qinfo->scattered_rx = dev->data->scattered_rx;
1768 : 0 : qinfo->nb_desc = rxq->nb_rx_desc;
1769 : :
1770 : 0 : qinfo->conf.rx_free_thresh = rxq->rx_free_thresh;
1771 : 0 : qinfo->conf.rx_drop_en = rxq->drop_en;
1772 : 0 : qinfo->conf.rx_deferred_start = rxq->rx_deferred_start;
1773 : 0 : }
1774 : :
1775 : : void
1776 : 0 : ice_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
1777 : : struct rte_eth_txq_info *qinfo)
1778 : : {
1779 : : struct ci_tx_queue *txq;
1780 : :
1781 : 0 : txq = dev->data->tx_queues[queue_id];
1782 : :
1783 : 0 : qinfo->nb_desc = txq->nb_tx_desc;
1784 : :
1785 : 0 : qinfo->conf.tx_thresh.pthresh = ICE_DEFAULT_TX_PTHRESH;
1786 : 0 : qinfo->conf.tx_thresh.hthresh = ICE_DEFAULT_TX_HTHRESH;
1787 : 0 : qinfo->conf.tx_thresh.wthresh = ICE_DEFAULT_TX_WTHRESH;
1788 : :
1789 : 0 : qinfo->conf.tx_free_thresh = txq->tx_free_thresh;
1790 : 0 : qinfo->conf.tx_rs_thresh = txq->tx_rs_thresh;
1791 : 0 : qinfo->conf.offloads = txq->offloads;
1792 : 0 : qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
1793 : 0 : }
1794 : :
1795 : : int
1796 : 0 : ice_rx_queue_count(void *rx_queue)
1797 : : {
1798 : : #define ICE_RXQ_SCAN_INTERVAL 4
1799 : : volatile union ci_rx_flex_desc *rxdp;
1800 : : struct ci_rx_queue *rxq;
1801 : : uint16_t desc = 0;
1802 : :
1803 : : rxq = rx_queue;
1804 : 0 : rxdp = &rxq->rx_flex_ring[rxq->rx_tail];
1805 [ # # ]: 0 : while ((desc < rxq->nb_rx_desc) &&
1806 [ # # ]: 0 : rte_le_to_cpu_16(rxdp->wb.status_error0) &
1807 : : (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)) {
1808 : : /**
1809 : : * Check the DD bit of a rx descriptor of each 4 in a group,
1810 : : * to avoid checking too frequently and downgrading performance
1811 : : * too much.
1812 : : */
1813 : 0 : desc += ICE_RXQ_SCAN_INTERVAL;
1814 : 0 : rxdp += ICE_RXQ_SCAN_INTERVAL;
1815 [ # # ]: 0 : if (rxq->rx_tail + desc >= rxq->nb_rx_desc)
1816 : 0 : rxdp = &rxq->rx_flex_ring[rxq->rx_tail + desc - rxq->nb_rx_desc];
1817 : : }
1818 : :
1819 : 0 : return desc;
1820 : : }
1821 : :
1822 : : #define ICE_RX_FLEX_ERR0_BITS \
1823 : : ((1 << ICE_RX_FLEX_DESC_STATUS0_HBO_S) | \
1824 : : (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S) | \
1825 : : (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S) | \
1826 : : (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S) | \
1827 : : (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S) | \
1828 : : (1 << ICE_RX_FLEX_DESC_STATUS0_RXE_S))
1829 : :
1830 : : /* Rx L3/L4 checksum */
1831 : : static inline uint64_t
1832 : 0 : ice_rxd_error_to_pkt_flags(uint16_t stat_err0)
1833 : : {
1834 : : uint64_t flags = 0;
1835 : :
1836 : : /* check if HW has decoded the packet and checksum */
1837 [ # # ]: 0 : if (unlikely(!(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_L3L4P_S))))
1838 : : return 0;
1839 : :
1840 [ # # ]: 0 : if (likely(!(stat_err0 & ICE_RX_FLEX_ERR0_BITS))) {
1841 : : flags |= (RTE_MBUF_F_RX_IP_CKSUM_GOOD |
1842 : : RTE_MBUF_F_RX_L4_CKSUM_GOOD |
1843 : : RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD);
1844 : : return flags;
1845 : : }
1846 : :
1847 [ # # ]: 0 : if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S)))
1848 : : flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
1849 : : else
1850 : : flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
1851 : :
1852 [ # # ]: 0 : if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S)))
1853 : 0 : flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
1854 : : else
1855 : 0 : flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
1856 : :
1857 [ # # ]: 0 : if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S)))
1858 : 0 : flags |= RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD;
1859 : :
1860 [ # # ]: 0 : if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S)))
1861 : 0 : flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD;
1862 : : else
1863 : 0 : flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD;
1864 : :
1865 : : return flags;
1866 : : }
1867 : :
1868 : : static inline void
1869 : 0 : ice_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union ci_rx_flex_desc *rxdp)
1870 : : {
1871 [ # # ]: 0 : if (rte_le_to_cpu_16(rxdp->wb.status_error0) &
1872 : : (1 << ICE_RX_FLEX_DESC_STATUS0_L2TAG1P_S)) {
1873 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
1874 : 0 : mb->vlan_tci =
1875 : 0 : rte_le_to_cpu_16(rxdp->wb.l2tag1);
1876 : : PMD_RX_LOG(DEBUG, "Descriptor l2tag1: %u",
1877 : : rte_le_to_cpu_16(rxdp->wb.l2tag1));
1878 : : } else {
1879 : 0 : mb->vlan_tci = 0;
1880 : : }
1881 : :
1882 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
1883 [ # # ]: 0 : if (rte_le_to_cpu_16(rxdp->wb.status_error1) &
1884 : : (1 << ICE_RX_FLEX_DESC_STATUS1_L2TAG2P_S)) {
1885 [ # # ]: 0 : if ((mb->ol_flags & RTE_MBUF_F_RX_VLAN_STRIPPED) == 0) {
1886 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
1887 : : } else {
1888 : : /* if two tags, move Tag1 to outer tag field */
1889 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_QINQ_STRIPPED | RTE_MBUF_F_RX_QINQ;
1890 : 0 : mb->vlan_tci_outer = mb->vlan_tci;
1891 : : }
1892 : 0 : mb->vlan_tci = rte_le_to_cpu_16(rxdp->wb.l2tag2_2nd);
1893 : : PMD_RX_LOG(DEBUG, "Descriptor l2tag2_1: %u, l2tag2_2: %u",
1894 : : rte_le_to_cpu_16(rxdp->wb.l2tag2_1st),
1895 : : rte_le_to_cpu_16(rxdp->wb.l2tag2_2nd));
1896 : : } else {
1897 : 0 : mb->vlan_tci_outer = 0;
1898 : : }
1899 : : #endif
1900 : : PMD_RX_LOG(DEBUG, "Mbuf vlan_tci: %u, vlan_tci_outer: %u",
1901 : : mb->vlan_tci, mb->vlan_tci_outer);
1902 : 0 : }
1903 : :
1904 : : #define ICE_LOOK_AHEAD 8
1905 : : #if (ICE_LOOK_AHEAD != 8)
1906 : : #error "PMD ICE: ICE_LOOK_AHEAD must be 8\n"
1907 : : #endif
1908 : :
1909 : : #define ICE_PTP_TS_VALID 0x1
1910 : :
1911 : : static inline int
1912 : 0 : ice_rx_scan_hw_ring(struct ci_rx_queue *rxq)
1913 : : {
1914 : : volatile union ci_rx_flex_desc *rxdp;
1915 : : struct ci_rx_entry *rxep;
1916 : : struct rte_mbuf *mb;
1917 : : uint16_t stat_err0;
1918 : : uint16_t pkt_len, hdr_len;
1919 : : int32_t s[ICE_LOOK_AHEAD], nb_dd;
1920 : : int32_t i, j, nb_rx = 0;
1921 : : uint64_t pkt_flags = 0;
1922 : 0 : uint32_t *ptype_tbl = rxq->ice_vsi->adapter->ptype_tbl;
1923 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
1924 : : bool is_tsinit = false;
1925 : : uint64_t ts_ns;
1926 : : struct ice_vsi *vsi = rxq->ice_vsi;
1927 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
1928 : : struct ice_adapter *ad = rxq->ice_vsi->adapter;
1929 : : #endif
1930 : 0 : rxdp = &rxq->rx_flex_ring[rxq->rx_tail];
1931 : 0 : rxep = &rxq->sw_ring[rxq->rx_tail];
1932 : :
1933 : 0 : stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
1934 : :
1935 : : /* Make sure there is at least 1 packet to receive */
1936 [ # # ]: 0 : if (!(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)))
1937 : : return 0;
1938 : :
1939 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
1940 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
1941 : 0 : uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
1942 : :
1943 [ # # ]: 0 : if (unlikely(sw_cur_time - rxq->hw_time_update > 4))
1944 : : is_tsinit = 1;
1945 : : }
1946 : : #endif
1947 : :
1948 : : /**
1949 : : * Scan LOOK_AHEAD descriptors at a time to determine which
1950 : : * descriptors reference packets that are ready to be received.
1951 : : */
1952 [ # # ]: 0 : for (i = 0; i < ICE_RX_MAX_BURST; i += ICE_LOOK_AHEAD,
1953 : 0 : rxdp += ICE_LOOK_AHEAD, rxep += ICE_LOOK_AHEAD) {
1954 : : /* Read desc statuses backwards to avoid race condition */
1955 [ # # ]: 0 : for (j = ICE_LOOK_AHEAD - 1; j >= 0; j--)
1956 : 0 : s[j] = rte_le_to_cpu_16(rxdp[j].wb.status_error0);
1957 : :
1958 : 0 : rte_smp_rmb();
1959 : :
1960 : : /* Compute how many status bits were set */
1961 [ # # ]: 0 : for (j = 0, nb_dd = 0; j < ICE_LOOK_AHEAD; j++)
1962 : 0 : nb_dd += s[j] & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S);
1963 : :
1964 : 0 : nb_rx += nb_dd;
1965 : :
1966 : : /* Translate descriptor info to mbuf parameters */
1967 [ # # ]: 0 : for (j = 0; j < nb_dd; j++) {
1968 : 0 : mb = rxep[j].mbuf;
1969 : 0 : pkt_len = (rte_le_to_cpu_16(rxdp[j].wb.pkt_len) &
1970 : 0 : ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
1971 : : mb->data_len = pkt_len;
1972 : 0 : mb->pkt_len = pkt_len;
1973 : :
1974 [ # # ]: 0 : if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
1975 : 0 : pkt_len = (rte_le_to_cpu_16(rxdp[j].wb.pkt_len) &
1976 : : ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
1977 : 0 : mb->data_len = pkt_len;
1978 : 0 : mb->pkt_len = pkt_len;
1979 : : } else {
1980 : 0 : mb->nb_segs = (uint16_t)(mb->nb_segs + mb->next->nb_segs);
1981 : 0 : mb->next->next = NULL;
1982 : 0 : hdr_len = rte_le_to_cpu_16(rxdp[j].wb.hdr_len_sph_flex_flags1) &
1983 : : ICE_RX_FLEX_DESC_HEADER_LEN_M;
1984 : 0 : pkt_len = (rte_le_to_cpu_16(rxdp[j].wb.pkt_len) &
1985 : : ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
1986 : 0 : mb->data_len = hdr_len;
1987 : 0 : mb->pkt_len = hdr_len + pkt_len;
1988 : 0 : mb->next->data_len = pkt_len;
1989 : : #ifdef RTE_ETHDEV_DEBUG_RX
1990 : : rte_pktmbuf_dump(stdout, mb, rte_pktmbuf_pkt_len(mb));
1991 : : #endif
1992 : : }
1993 : :
1994 : 0 : mb->ol_flags = 0;
1995 : 0 : stat_err0 = rte_le_to_cpu_16(rxdp[j].wb.status_error0);
1996 : 0 : pkt_flags = ice_rxd_error_to_pkt_flags(stat_err0);
1997 : 0 : mb->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &
1998 : 0 : rte_le_to_cpu_16(rxdp[j].wb.ptype_flex_flags0)];
1999 : 0 : ice_rxd_to_vlan_tci(mb, &rxdp[j]);
2000 : 0 : rxd_to_pkt_fields_ops[rxq->rxdid](rxq, mb, &rxdp[j]);
2001 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
2002 [ # # ]: 0 : if (rxq->ts_flag > 0 &&
2003 [ # # ]: 0 : (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
2004 : 0 : rxq->time_high =
2005 : 0 : rte_le_to_cpu_32(rxdp[j].wb.flex_ts.ts_high);
2006 [ # # ]: 0 : if (unlikely(is_tsinit)) {
2007 : 0 : ts_ns = ice_tstamp_convert_32b_64b(hw, ad, 1,
2008 : : rxq->time_high);
2009 : 0 : rxq->hw_time_low = (uint32_t)ts_ns;
2010 : 0 : rxq->hw_time_high = (uint32_t)(ts_ns >> 32);
2011 : : is_tsinit = false;
2012 : : } else {
2013 [ # # ]: 0 : if (rxq->time_high < rxq->hw_time_low)
2014 : 0 : rxq->hw_time_high += 1;
2015 : 0 : ts_ns = (uint64_t)rxq->hw_time_high << 32 | rxq->time_high;
2016 : 0 : rxq->hw_time_low = rxq->time_high;
2017 : : }
2018 : 0 : rxq->hw_time_update = rte_get_timer_cycles() /
2019 : 0 : (rte_get_timer_hz() / 1000);
2020 : 0 : *RTE_MBUF_DYNFIELD(mb,
2021 : : rxq->ts_offset,
2022 : 0 : rte_mbuf_timestamp_t *) = ts_ns;
2023 : 0 : pkt_flags |= rxq->ts_flag;
2024 : : }
2025 : :
2026 [ # # # # ]: 0 : if (ad->ptp_ena && ((mb->packet_type &
2027 : : RTE_PTYPE_L2_MASK) == RTE_PTYPE_L2_ETHER_TIMESYNC)) {
2028 : 0 : rxq->time_high =
2029 : 0 : rte_le_to_cpu_32(rxdp[j].wb.flex_ts.ts_high);
2030 : 0 : mb->timesync = rxq->queue_id;
2031 : 0 : pkt_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
2032 [ # # ]: 0 : if (rxdp[j].wb.time_stamp_low &
2033 : : ICE_PTP_TS_VALID)
2034 : 0 : pkt_flags |=
2035 : : RTE_MBUF_F_RX_IEEE1588_TMST;
2036 : : }
2037 : : #endif
2038 : 0 : mb->ol_flags |= pkt_flags;
2039 : : }
2040 : :
2041 [ # # ]: 0 : for (j = 0; j < ICE_LOOK_AHEAD; j++)
2042 : 0 : rxq->rx_stage[i + j] = rxep[j].mbuf;
2043 : :
2044 [ # # ]: 0 : if (nb_dd != ICE_LOOK_AHEAD)
2045 : : break;
2046 : : }
2047 : :
2048 : : /* Clear software ring entries */
2049 [ # # ]: 0 : for (i = 0; i < nb_rx; i++)
2050 : 0 : rxq->sw_ring[rxq->rx_tail + i].mbuf = NULL;
2051 : :
2052 : : PMD_RX_LOG(DEBUG, "ice_rx_scan_hw_ring: "
2053 : : "port_id=%u, queue_id=%u, nb_rx=%d",
2054 : : rxq->port_id, rxq->queue_id, nb_rx);
2055 : :
2056 : : return nb_rx;
2057 : : }
2058 : :
2059 : : static inline uint16_t
2060 : : ice_rx_fill_from_stage(struct ci_rx_queue *rxq,
2061 : : struct rte_mbuf **rx_pkts,
2062 : : uint16_t nb_pkts)
2063 : : {
2064 : : uint16_t i;
2065 : 0 : struct rte_mbuf **stage = &rxq->rx_stage[rxq->rx_next_avail];
2066 : :
2067 : 0 : nb_pkts = (uint16_t)RTE_MIN(nb_pkts, rxq->rx_nb_avail);
2068 : :
2069 [ # # # # ]: 0 : for (i = 0; i < nb_pkts; i++)
2070 : 0 : rx_pkts[i] = stage[i];
2071 : :
2072 : 0 : rxq->rx_nb_avail = (uint16_t)(rxq->rx_nb_avail - nb_pkts);
2073 : 0 : rxq->rx_next_avail = (uint16_t)(rxq->rx_next_avail + nb_pkts);
2074 : :
2075 : : return nb_pkts;
2076 : : }
2077 : :
2078 : : static inline int
2079 : 0 : ice_rx_alloc_bufs(struct ci_rx_queue *rxq)
2080 : : {
2081 : : volatile union ci_rx_flex_desc *rxdp;
2082 : : struct ci_rx_entry *rxep;
2083 : : struct rte_mbuf *mb;
2084 : : uint16_t alloc_idx, i;
2085 : : uint64_t dma_addr;
2086 : : int diag, diag_pay;
2087 : : uint64_t pay_addr;
2088 : :
2089 : : /* Allocate buffers in bulk */
2090 : 0 : alloc_idx = (uint16_t)(rxq->rx_free_trigger -
2091 : 0 : (rxq->rx_free_thresh - 1));
2092 : 0 : rxep = &rxq->sw_ring[alloc_idx];
2093 [ # # ]: 0 : diag = rte_mbuf_raw_alloc_bulk(rxq->mp, (void *)rxep,
2094 : : rxq->rx_free_thresh);
2095 [ # # ]: 0 : if (unlikely(diag != 0)) {
2096 : : PMD_RX_LOG(ERR, "Failed to get mbufs in bulk");
2097 : : return -ENOMEM;
2098 : : }
2099 : :
2100 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
2101 : 0 : diag_pay = rte_mbuf_raw_alloc_bulk(rxq->rxseg[1].mp,
2102 [ # # ]: 0 : (void *)rxq->sw_split_buf, rxq->rx_free_thresh);
2103 [ # # ]: 0 : if (unlikely(diag_pay != 0)) {
2104 : 0 : rte_mbuf_raw_free_bulk(rxq->mp, (void *)rxep,
2105 [ # # ]: 0 : rxq->rx_free_thresh);
2106 : : PMD_RX_LOG(ERR, "Failed to get payload mbufs in bulk");
2107 : 0 : return -ENOMEM;
2108 : : }
2109 : : }
2110 : :
2111 : 0 : rxdp = &rxq->rx_flex_ring[alloc_idx];
2112 [ # # ]: 0 : for (i = 0; i < rxq->rx_free_thresh; i++) {
2113 [ # # ]: 0 : if (likely(i < (rxq->rx_free_thresh - 1)))
2114 : : /* Prefetch next mbuf */
2115 : 0 : rte_prefetch0(rxep[i + 1].mbuf);
2116 : :
2117 [ # # ]: 0 : mb = rxep[i].mbuf;
2118 : : rte_mbuf_refcnt_set(mb, 1);
2119 : 0 : mb->data_off = RTE_PKTMBUF_HEADROOM;
2120 : 0 : mb->nb_segs = 1;
2121 [ # # ]: 0 : mb->port = rxq->port_id;
2122 : : dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mb));
2123 : :
2124 [ # # ]: 0 : if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
2125 : 0 : mb->next = NULL;
2126 : 0 : rxdp[i].read.hdr_addr = 0;
2127 : 0 : rxdp[i].read.pkt_addr = dma_addr;
2128 : : } else {
2129 : 0 : mb->next = rxq->sw_split_buf[i].mbuf;
2130 : : pay_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mb->next));
2131 : 0 : rxdp[i].read.hdr_addr = dma_addr;
2132 : 0 : rxdp[i].read.pkt_addr = pay_addr;
2133 : : }
2134 : : }
2135 : :
2136 : : /* Update Rx tail register */
2137 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_free_trigger);
2138 : :
2139 : 0 : rxq->rx_free_trigger =
2140 : 0 : (uint16_t)(rxq->rx_free_trigger + rxq->rx_free_thresh);
2141 [ # # ]: 0 : if (rxq->rx_free_trigger >= rxq->nb_rx_desc)
2142 : 0 : rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
2143 : :
2144 : : return 0;
2145 : : }
2146 : :
2147 : : static inline uint16_t
2148 : 0 : rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
2149 : : {
2150 : : struct ci_rx_queue *rxq = (struct ci_rx_queue *)rx_queue;
2151 : : uint16_t nb_rx = 0;
2152 : :
2153 [ # # ]: 0 : if (!nb_pkts)
2154 : : return 0;
2155 : :
2156 [ # # ]: 0 : if (rxq->rx_nb_avail)
2157 : 0 : return ice_rx_fill_from_stage(rxq, rx_pkts, nb_pkts);
2158 : :
2159 : 0 : nb_rx = (uint16_t)ice_rx_scan_hw_ring(rxq);
2160 : 0 : rxq->rx_next_avail = 0;
2161 : 0 : rxq->rx_nb_avail = nb_rx;
2162 : 0 : rxq->rx_tail = (uint16_t)(rxq->rx_tail + nb_rx);
2163 : :
2164 [ # # ]: 0 : if (rxq->rx_tail > rxq->rx_free_trigger) {
2165 [ # # ]: 0 : if (ice_rx_alloc_bufs(rxq) != 0) {
2166 : : uint16_t i, j;
2167 : :
2168 : 0 : rxq->ice_vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed +=
2169 : 0 : rxq->rx_free_thresh;
2170 : : PMD_RX_LOG(DEBUG, "Rx mbuf alloc failed for "
2171 : : "port_id=%u, queue_id=%u",
2172 : : rxq->port_id, rxq->queue_id);
2173 : 0 : rxq->rx_nb_avail = 0;
2174 : 0 : rxq->rx_tail = (uint16_t)(rxq->rx_tail - nb_rx);
2175 [ # # ]: 0 : for (i = 0, j = rxq->rx_tail; i < nb_rx; i++, j++)
2176 : 0 : rxq->sw_ring[j].mbuf = rxq->rx_stage[i];
2177 : :
2178 : : return 0;
2179 : : }
2180 : : }
2181 : :
2182 [ # # ]: 0 : if (rxq->rx_tail >= rxq->nb_rx_desc)
2183 : 0 : rxq->rx_tail = 0;
2184 : :
2185 [ # # ]: 0 : if (rxq->rx_nb_avail)
2186 : 0 : return ice_rx_fill_from_stage(rxq, rx_pkts, nb_pkts);
2187 : :
2188 : : return 0;
2189 : : }
2190 : :
2191 : : static uint16_t
2192 : 0 : ice_recv_pkts_bulk_alloc(void *rx_queue,
2193 : : struct rte_mbuf **rx_pkts,
2194 : : uint16_t nb_pkts)
2195 : : {
2196 : : uint16_t nb_rx = 0;
2197 : : uint16_t n;
2198 : : uint16_t count;
2199 : :
2200 [ # # ]: 0 : if (unlikely(nb_pkts == 0))
2201 : : return nb_rx;
2202 : :
2203 [ # # ]: 0 : if (likely(nb_pkts <= ICE_RX_MAX_BURST))
2204 : 0 : return rx_recv_pkts(rx_queue, rx_pkts, nb_pkts);
2205 : :
2206 [ # # ]: 0 : while (nb_pkts) {
2207 : 0 : n = RTE_MIN(nb_pkts, ICE_RX_MAX_BURST);
2208 : 0 : count = rx_recv_pkts(rx_queue, &rx_pkts[nb_rx], n);
2209 : 0 : nb_rx = (uint16_t)(nb_rx + count);
2210 : 0 : nb_pkts = (uint16_t)(nb_pkts - count);
2211 [ # # ]: 0 : if (count < n)
2212 : : break;
2213 : : }
2214 : :
2215 : : return nb_rx;
2216 : : }
2217 : :
2218 : : static uint16_t
2219 : 0 : ice_recv_scattered_pkts(void *rx_queue,
2220 : : struct rte_mbuf **rx_pkts,
2221 : : uint16_t nb_pkts)
2222 : : {
2223 : : struct ci_rx_queue *rxq = rx_queue;
2224 : 0 : volatile union ci_rx_flex_desc *rx_ring = rxq->rx_flex_ring;
2225 : : volatile union ci_rx_flex_desc *rxdp;
2226 : : union ci_rx_flex_desc rxd;
2227 : 0 : struct ci_rx_entry *sw_ring = rxq->sw_ring;
2228 : : struct ci_rx_entry *rxe;
2229 : 0 : struct rte_mbuf *first_seg = rxq->pkt_first_seg;
2230 : 0 : struct rte_mbuf *last_seg = rxq->pkt_last_seg;
2231 : : struct rte_mbuf *nmb; /* new allocated mbuf */
2232 : : struct rte_mbuf *rxm; /* pointer to store old mbuf in SW ring */
2233 : 0 : uint16_t rx_id = rxq->rx_tail;
2234 : : uint16_t nb_rx = 0;
2235 : : uint16_t nb_hold = 0;
2236 : : uint16_t rx_packet_len;
2237 : : uint16_t rx_stat_err0;
2238 : : uint64_t dma_addr;
2239 : : uint64_t pkt_flags;
2240 : 0 : uint32_t *ptype_tbl = rxq->ice_vsi->adapter->ptype_tbl;
2241 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
2242 : : bool is_tsinit = false;
2243 : : uint64_t ts_ns;
2244 : : struct ice_vsi *vsi = rxq->ice_vsi;
2245 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
2246 : : struct ice_adapter *ad = rxq->ice_vsi->adapter;
2247 : :
2248 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
2249 : 0 : uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
2250 : :
2251 [ # # ]: 0 : if (unlikely(sw_cur_time - rxq->hw_time_update > 4))
2252 : : is_tsinit = true;
2253 : : }
2254 : : #endif
2255 : :
2256 [ # # ]: 0 : while (nb_rx < nb_pkts) {
2257 : 0 : rxdp = &rx_ring[rx_id];
2258 : 0 : rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
2259 : :
2260 : : /* Check the DD bit first */
2261 [ # # ]: 0 : if (!(rx_stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)))
2262 : : break;
2263 : :
2264 : : /* allocate mbuf */
2265 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mp);
2266 [ # # ]: 0 : if (unlikely(!nmb)) {
2267 : 0 : rxq->ice_vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++;
2268 : 0 : break;
2269 : : }
2270 : 0 : rxd = *rxdp; /* copy descriptor in ring to temp variable*/
2271 : :
2272 : 0 : nb_hold++;
2273 : 0 : rxe = &sw_ring[rx_id]; /* get corresponding mbuf in SW ring */
2274 : 0 : rx_id++;
2275 [ # # ]: 0 : if (unlikely(rx_id == rxq->nb_rx_desc))
2276 : : rx_id = 0;
2277 : :
2278 : : /* Prefetch next mbuf */
2279 : 0 : rte_prefetch0(sw_ring[rx_id].mbuf);
2280 : :
2281 : : /**
2282 : : * When next RX descriptor is on a cache line boundary,
2283 : : * prefetch the next 4 RX descriptors and next 8 pointers
2284 : : * to mbufs.
2285 : : */
2286 [ # # ]: 0 : if ((rx_id & 0x3) == 0) {
2287 : 0 : rte_prefetch0(&rx_ring[rx_id]);
2288 : : rte_prefetch0(&sw_ring[rx_id]);
2289 : : }
2290 : :
2291 : 0 : rxm = rxe->mbuf;
2292 [ # # ]: 0 : rxe->mbuf = nmb;
2293 : : dma_addr =
2294 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
2295 : :
2296 : : /* Set data buffer address and data length of the mbuf */
2297 : 0 : rxdp->read.hdr_addr = 0;
2298 : 0 : rxdp->read.pkt_addr = dma_addr;
2299 : 0 : rx_packet_len = rte_le_to_cpu_16(rxd.wb.pkt_len) &
2300 : : ICE_RX_FLX_DESC_PKT_LEN_M;
2301 : 0 : rxm->data_len = rx_packet_len;
2302 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
2303 : :
2304 : : /**
2305 : : * If this is the first buffer of the received packet, set the
2306 : : * pointer to the first mbuf of the packet and initialize its
2307 : : * context. Otherwise, update the total length and the number
2308 : : * of segments of the current scattered packet, and update the
2309 : : * pointer to the last mbuf of the current packet.
2310 : : */
2311 [ # # ]: 0 : if (!first_seg) {
2312 : : first_seg = rxm;
2313 : 0 : first_seg->nb_segs = 1;
2314 : 0 : first_seg->pkt_len = rx_packet_len;
2315 : : } else {
2316 : 0 : first_seg->pkt_len =
2317 : 0 : (uint16_t)(first_seg->pkt_len +
2318 : : rx_packet_len);
2319 : 0 : first_seg->nb_segs++;
2320 : 0 : last_seg->next = rxm;
2321 : : }
2322 : :
2323 : : /**
2324 : : * If this is not the last buffer of the received packet,
2325 : : * update the pointer to the last mbuf of the current scattered
2326 : : * packet and continue to parse the RX ring.
2327 : : */
2328 [ # # ]: 0 : if (!(rx_stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_EOF_S))) {
2329 : : last_seg = rxm;
2330 : 0 : continue;
2331 : : }
2332 : :
2333 : : /**
2334 : : * This is the last buffer of the received packet. If the CRC
2335 : : * is not stripped by the hardware:
2336 : : * - Subtract the CRC length from the total packet length.
2337 : : * - If the last buffer only contains the whole CRC or a part
2338 : : * of it, free the mbuf associated to the last buffer. If part
2339 : : * of the CRC is also contained in the previous mbuf, subtract
2340 : : * the length of that CRC part from the data length of the
2341 : : * previous mbuf.
2342 : : */
2343 : 0 : rxm->next = NULL;
2344 [ # # ]: 0 : if (unlikely(rxq->crc_len > 0)) {
2345 : 0 : first_seg->pkt_len -= RTE_ETHER_CRC_LEN;
2346 [ # # ]: 0 : if (rx_packet_len <= RTE_ETHER_CRC_LEN) {
2347 : : rte_pktmbuf_free_seg(rxm);
2348 : 0 : first_seg->nb_segs--;
2349 : 0 : last_seg->data_len =
2350 : 0 : (uint16_t)(last_seg->data_len -
2351 : : (RTE_ETHER_CRC_LEN - rx_packet_len));
2352 : 0 : last_seg->next = NULL;
2353 : : } else
2354 : 0 : rxm->data_len = (uint16_t)(rx_packet_len -
2355 : : RTE_ETHER_CRC_LEN);
2356 [ # # ]: 0 : } else if (rx_packet_len == 0) {
2357 : : rte_pktmbuf_free_seg(rxm);
2358 : 0 : first_seg->nb_segs--;
2359 : 0 : last_seg->next = NULL;
2360 : : }
2361 : :
2362 : 0 : first_seg->port = rxq->port_id;
2363 : 0 : first_seg->ol_flags = 0;
2364 : 0 : first_seg->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &
2365 : 0 : rte_le_to_cpu_16(rxd.wb.ptype_flex_flags0)];
2366 : 0 : ice_rxd_to_vlan_tci(first_seg, &rxd);
2367 : 0 : rxd_to_pkt_fields_ops[rxq->rxdid](rxq, first_seg, &rxd);
2368 : 0 : pkt_flags = ice_rxd_error_to_pkt_flags(rx_stat_err0);
2369 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
2370 [ # # ]: 0 : if (rxq->ts_flag > 0 &&
2371 [ # # ]: 0 : (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
2372 : 0 : rxq->time_high =
2373 : 0 : rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
2374 [ # # ]: 0 : if (unlikely(is_tsinit)) {
2375 : 0 : ts_ns = ice_tstamp_convert_32b_64b(hw, ad, 1, rxq->time_high);
2376 : 0 : rxq->hw_time_low = (uint32_t)ts_ns;
2377 : 0 : rxq->hw_time_high = (uint32_t)(ts_ns >> 32);
2378 : : is_tsinit = false;
2379 : : } else {
2380 [ # # ]: 0 : if (rxq->time_high < rxq->hw_time_low)
2381 : 0 : rxq->hw_time_high += 1;
2382 : 0 : ts_ns = (uint64_t)rxq->hw_time_high << 32 | rxq->time_high;
2383 : 0 : rxq->hw_time_low = rxq->time_high;
2384 : : }
2385 : 0 : rxq->hw_time_update = rte_get_timer_cycles() /
2386 : 0 : (rte_get_timer_hz() / 1000);
2387 : 0 : *RTE_MBUF_DYNFIELD(first_seg,
2388 : : (rxq->ts_offset),
2389 : 0 : rte_mbuf_timestamp_t *) = ts_ns;
2390 : 0 : pkt_flags |= rxq->ts_flag;
2391 : : }
2392 : :
2393 [ # # # # ]: 0 : if (ad->ptp_ena && ((first_seg->packet_type & RTE_PTYPE_L2_MASK)
2394 : : == RTE_PTYPE_L2_ETHER_TIMESYNC)) {
2395 : 0 : rxq->time_high =
2396 : 0 : rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
2397 : 0 : first_seg->timesync = rxq->queue_id;
2398 : 0 : pkt_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
2399 : : }
2400 : : #endif
2401 : 0 : first_seg->ol_flags |= pkt_flags;
2402 : : /* Prefetch data of first segment, if configured to do so. */
2403 : 0 : rte_prefetch0(RTE_PTR_ADD(first_seg->buf_addr,
2404 : : first_seg->data_off));
2405 : 0 : rx_pkts[nb_rx++] = first_seg;
2406 : : first_seg = NULL;
2407 : : }
2408 : :
2409 : : /* Record index of the next RX descriptor to probe. */
2410 : 0 : rxq->rx_tail = rx_id;
2411 : 0 : rxq->pkt_first_seg = first_seg;
2412 : 0 : rxq->pkt_last_seg = last_seg;
2413 : :
2414 : : /**
2415 : : * If the number of free RX descriptors is greater than the RX free
2416 : : * threshold of the queue, advance the Receive Descriptor Tail (RDT)
2417 : : * register. Update the RDT with the value of the last processed RX
2418 : : * descriptor minus 1, to guarantee that the RDT register is never
2419 : : * equal to the RDH register, which creates a "full" ring situation
2420 : : * from the hardware point of view.
2421 : : */
2422 : 0 : nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold);
2423 [ # # ]: 0 : if (nb_hold > rxq->rx_free_thresh) {
2424 [ # # ]: 0 : rx_id = (uint16_t)(rx_id == 0 ?
2425 : 0 : (rxq->nb_rx_desc - 1) : (rx_id - 1));
2426 : : /* write TAIL register */
2427 : 0 : ICE_PCI_REG_WC_WRITE(rxq->qrx_tail, rx_id);
2428 : : nb_hold = 0;
2429 : : }
2430 : 0 : rxq->nb_rx_hold = nb_hold;
2431 : :
2432 : : /* return received packet in the burst */
2433 : 0 : return nb_rx;
2434 : : }
2435 : :
2436 : : const uint32_t *
2437 : 0 : ice_dev_supported_ptypes_get(struct rte_eth_dev *dev, size_t *no_of_elements)
2438 : : {
2439 : 0 : struct ice_adapter *ad =
2440 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2441 : : const uint32_t *ptypes;
2442 : :
2443 : : static const uint32_t ptypes_os[] = {
2444 : : /* refers to ice_get_default_pkt_type() */
2445 : : RTE_PTYPE_L2_ETHER,
2446 : : RTE_PTYPE_L2_ETHER_TIMESYNC,
2447 : : RTE_PTYPE_L2_ETHER_LLDP,
2448 : : RTE_PTYPE_L2_ETHER_ARP,
2449 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
2450 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
2451 : : RTE_PTYPE_L4_FRAG,
2452 : : RTE_PTYPE_L4_ICMP,
2453 : : RTE_PTYPE_L4_NONFRAG,
2454 : : RTE_PTYPE_L4_SCTP,
2455 : : RTE_PTYPE_L4_TCP,
2456 : : RTE_PTYPE_L4_UDP,
2457 : : RTE_PTYPE_TUNNEL_GRENAT,
2458 : : RTE_PTYPE_TUNNEL_IP,
2459 : : RTE_PTYPE_INNER_L2_ETHER,
2460 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN,
2461 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN,
2462 : : RTE_PTYPE_INNER_L4_FRAG,
2463 : : RTE_PTYPE_INNER_L4_ICMP,
2464 : : RTE_PTYPE_INNER_L4_NONFRAG,
2465 : : RTE_PTYPE_INNER_L4_SCTP,
2466 : : RTE_PTYPE_INNER_L4_TCP,
2467 : : RTE_PTYPE_INNER_L4_UDP,
2468 : : };
2469 : :
2470 : : static const uint32_t ptypes_comms[] = {
2471 : : /* refers to ice_get_default_pkt_type() */
2472 : : RTE_PTYPE_L2_ETHER,
2473 : : RTE_PTYPE_L2_ETHER_TIMESYNC,
2474 : : RTE_PTYPE_L2_ETHER_LLDP,
2475 : : RTE_PTYPE_L2_ETHER_ARP,
2476 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
2477 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
2478 : : RTE_PTYPE_L4_FRAG,
2479 : : RTE_PTYPE_L4_ICMP,
2480 : : RTE_PTYPE_L4_NONFRAG,
2481 : : RTE_PTYPE_L4_SCTP,
2482 : : RTE_PTYPE_L4_TCP,
2483 : : RTE_PTYPE_L4_UDP,
2484 : : RTE_PTYPE_TUNNEL_GRENAT,
2485 : : RTE_PTYPE_TUNNEL_IP,
2486 : : RTE_PTYPE_INNER_L2_ETHER,
2487 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN,
2488 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN,
2489 : : RTE_PTYPE_INNER_L4_FRAG,
2490 : : RTE_PTYPE_INNER_L4_ICMP,
2491 : : RTE_PTYPE_INNER_L4_NONFRAG,
2492 : : RTE_PTYPE_INNER_L4_SCTP,
2493 : : RTE_PTYPE_INNER_L4_TCP,
2494 : : RTE_PTYPE_INNER_L4_UDP,
2495 : : RTE_PTYPE_TUNNEL_GTPC,
2496 : : RTE_PTYPE_TUNNEL_GTPU,
2497 : : RTE_PTYPE_L2_ETHER_PPPOE,
2498 : : };
2499 : :
2500 [ # # ]: 0 : if (ad->active_pkg_type == ICE_PKG_TYPE_COMMS) {
2501 : 0 : *no_of_elements = RTE_DIM(ptypes_comms);
2502 : : ptypes = ptypes_comms;
2503 : : } else {
2504 : 0 : *no_of_elements = RTE_DIM(ptypes_os);
2505 : : ptypes = ptypes_os;
2506 : : }
2507 : :
2508 [ # # ]: 0 : if (ad->rx_func_type == ICE_RX_DEFAULT ||
2509 [ # # ]: 0 : ad->rx_func_type == ICE_RX_BULK_ALLOC ||
2510 [ # # ]: 0 : ad->rx_func_type == ICE_RX_SCATTERED ||
2511 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX2 ||
2512 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX2_OFFLOAD ||
2513 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX2_SCATTERED ||
2514 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX2_SCATTERED_OFFLOAD ||
2515 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX512 ||
2516 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX512_SCATTERED ||
2517 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX512_OFFLOAD ||
2518 : : ad->rx_func_type == ICE_RX_AVX512_SCATTERED_OFFLOAD)
2519 : 0 : return ptypes;
2520 : :
2521 : : return NULL;
2522 : : }
2523 : :
2524 : : int
2525 : 0 : ice_rx_descriptor_status(void *rx_queue, uint16_t offset)
2526 : : {
2527 : : volatile union ci_rx_flex_desc *rxdp;
2528 : : struct ci_rx_queue *rxq = rx_queue;
2529 : : uint32_t desc;
2530 : :
2531 [ # # ]: 0 : if (unlikely(offset >= rxq->nb_rx_desc))
2532 : : return -EINVAL;
2533 : :
2534 [ # # ]: 0 : if (offset >= rxq->nb_rx_desc - rxq->nb_rx_hold)
2535 : : return RTE_ETH_RX_DESC_UNAVAIL;
2536 : :
2537 : 0 : desc = rxq->rx_tail + offset;
2538 [ # # ]: 0 : if (desc >= rxq->nb_rx_desc)
2539 : 0 : desc -= rxq->nb_rx_desc;
2540 : :
2541 : 0 : rxdp = &rxq->rx_flex_ring[desc];
2542 [ # # ]: 0 : if (rte_le_to_cpu_16(rxdp->wb.status_error0) &
2543 : : (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S))
2544 : 0 : return RTE_ETH_RX_DESC_DONE;
2545 : :
2546 : : return RTE_ETH_RX_DESC_AVAIL;
2547 : : }
2548 : :
2549 : : int
2550 : 0 : ice_tx_descriptor_status(void *tx_queue, uint16_t offset)
2551 : : {
2552 : : struct ci_tx_queue *txq = tx_queue;
2553 : : volatile uint64_t *status;
2554 : : uint64_t mask, expect;
2555 : : uint32_t desc;
2556 : :
2557 [ # # ]: 0 : if (unlikely(offset >= txq->nb_tx_desc))
2558 : : return -EINVAL;
2559 : :
2560 : 0 : desc = txq->tx_tail + offset;
2561 : : /* go to next desc that has the RS bit */
2562 : 0 : desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
2563 : : txq->tx_rs_thresh;
2564 [ # # ]: 0 : if (desc >= txq->nb_tx_desc) {
2565 : 0 : desc -= txq->nb_tx_desc;
2566 [ # # ]: 0 : if (desc >= txq->nb_tx_desc)
2567 : 0 : desc -= txq->nb_tx_desc;
2568 : : }
2569 : :
2570 : 0 : status = &txq->ci_tx_ring[desc].cmd_type_offset_bsz;
2571 : : mask = rte_cpu_to_le_64(CI_TXD_QW1_DTYPE_M);
2572 : : expect = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE << CI_TXD_QW1_DTYPE_S);
2573 [ # # ]: 0 : if ((*status & mask) == expect)
2574 : 0 : return RTE_ETH_TX_DESC_DONE;
2575 : :
2576 : : return RTE_ETH_TX_DESC_FULL;
2577 : : }
2578 : :
2579 : : void
2580 : 0 : ice_free_queues(struct rte_eth_dev *dev)
2581 : : {
2582 : : uint16_t i;
2583 : :
2584 : 0 : PMD_INIT_FUNC_TRACE();
2585 : :
2586 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
2587 [ # # ]: 0 : if (!dev->data->rx_queues[i])
2588 : 0 : continue;
2589 : 0 : ice_rx_queue_release(dev->data->rx_queues[i]);
2590 : 0 : dev->data->rx_queues[i] = NULL;
2591 : : }
2592 : 0 : dev->data->nb_rx_queues = 0;
2593 : :
2594 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
2595 [ # # ]: 0 : if (!dev->data->tx_queues[i])
2596 : 0 : continue;
2597 : 0 : ice_tx_queue_release(dev->data->tx_queues[i]);
2598 : 0 : dev->data->tx_queues[i] = NULL;
2599 : : }
2600 : 0 : dev->data->nb_tx_queues = 0;
2601 : 0 : }
2602 : :
2603 : : #define ICE_FDIR_NUM_TX_DESC ICE_MIN_RING_DESC
2604 : : #define ICE_FDIR_NUM_RX_DESC ICE_MIN_RING_DESC
2605 : :
2606 : : int
2607 : 0 : ice_fdir_setup_tx_resources(struct ice_pf *pf)
2608 : : {
2609 : : struct ci_tx_queue *txq;
2610 : : const struct rte_memzone *tz = NULL;
2611 : : uint32_t ring_size;
2612 : : struct rte_eth_dev *dev;
2613 : :
2614 [ # # ]: 0 : if (!pf) {
2615 : 0 : PMD_DRV_LOG(ERR, "PF is not available");
2616 : 0 : return -EINVAL;
2617 : : }
2618 : :
2619 : 0 : dev = &rte_eth_devices[pf->adapter->pf.dev_data->port_id];
2620 : :
2621 : : /* Allocate the TX queue data structure. */
2622 : 0 : txq = rte_zmalloc_socket("ice fdir tx queue",
2623 : : sizeof(struct ci_tx_queue),
2624 : : RTE_CACHE_LINE_SIZE,
2625 : : SOCKET_ID_ANY);
2626 [ # # ]: 0 : if (!txq) {
2627 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate memory for "
2628 : : "tx queue structure.");
2629 : 0 : return -ENOMEM;
2630 : : }
2631 : :
2632 : : /* Allocate TX hardware ring descriptors. */
2633 : : ring_size = sizeof(struct ci_tx_desc) * ICE_FDIR_NUM_TX_DESC;
2634 : : ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
2635 : :
2636 : 0 : tz = rte_eth_dma_zone_reserve(dev, "fdir_tx_ring",
2637 : : ICE_FDIR_QUEUE_ID, ring_size,
2638 : : ICE_RING_BASE_ALIGN, SOCKET_ID_ANY);
2639 [ # # ]: 0 : if (!tz) {
2640 : 0 : ice_tx_queue_release(txq);
2641 : 0 : PMD_DRV_LOG(ERR, "Failed to reserve DMA memory for TX.");
2642 : 0 : return -ENOMEM;
2643 : : }
2644 : :
2645 : 0 : txq->mz = tz;
2646 : 0 : txq->nb_tx_desc = ICE_FDIR_NUM_TX_DESC;
2647 : 0 : txq->queue_id = ICE_FDIR_QUEUE_ID;
2648 : 0 : txq->reg_idx = pf->fdir.fdir_vsi->base_queue;
2649 : 0 : txq->ice_vsi = pf->fdir.fdir_vsi;
2650 : :
2651 : 0 : txq->tx_ring_dma = tz->iova;
2652 : 0 : txq->ci_tx_ring = (struct ci_tx_desc *)tz->addr;
2653 : : /*
2654 : : * don't need to allocate software ring and reset for the fdir
2655 : : * program queue just set the queue has been configured.
2656 : : */
2657 : 0 : txq->q_set = true;
2658 : 0 : pf->fdir.txq = txq;
2659 : :
2660 : :
2661 : 0 : return ICE_SUCCESS;
2662 : : }
2663 : :
2664 : : int
2665 : 0 : ice_fdir_setup_rx_resources(struct ice_pf *pf)
2666 : : {
2667 : : struct ci_rx_queue *rxq;
2668 : : const struct rte_memzone *rz = NULL;
2669 : : uint32_t ring_size;
2670 : : struct rte_eth_dev *dev;
2671 : :
2672 [ # # ]: 0 : if (!pf) {
2673 : 0 : PMD_DRV_LOG(ERR, "PF is not available");
2674 : 0 : return -EINVAL;
2675 : : }
2676 : :
2677 : 0 : dev = &rte_eth_devices[pf->adapter->pf.dev_data->port_id];
2678 : :
2679 : : /* Allocate the RX queue data structure. */
2680 : 0 : rxq = rte_zmalloc_socket("ice fdir rx queue",
2681 : : sizeof(struct ci_rx_queue),
2682 : : RTE_CACHE_LINE_SIZE,
2683 : : SOCKET_ID_ANY);
2684 [ # # ]: 0 : if (!rxq) {
2685 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate memory for "
2686 : : "rx queue structure.");
2687 : 0 : return -ENOMEM;
2688 : : }
2689 : :
2690 : : /* Allocate RX hardware ring descriptors. */
2691 : : ring_size = sizeof(union ice_32byte_rx_desc) * ICE_FDIR_NUM_RX_DESC;
2692 : : ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
2693 : :
2694 : 0 : rz = rte_eth_dma_zone_reserve(dev, "fdir_rx_ring",
2695 : : ICE_FDIR_QUEUE_ID, ring_size,
2696 : : ICE_RING_BASE_ALIGN, SOCKET_ID_ANY);
2697 [ # # ]: 0 : if (!rz) {
2698 : 0 : ice_rx_queue_release(rxq);
2699 : 0 : PMD_DRV_LOG(ERR, "Failed to reserve DMA memory for RX.");
2700 : 0 : return -ENOMEM;
2701 : : }
2702 : :
2703 : 0 : rxq->mz = rz;
2704 : 0 : rxq->nb_rx_desc = ICE_FDIR_NUM_RX_DESC;
2705 : 0 : rxq->queue_id = ICE_FDIR_QUEUE_ID;
2706 : 0 : rxq->reg_idx = pf->fdir.fdir_vsi->base_queue;
2707 : 0 : rxq->ice_vsi = pf->fdir.fdir_vsi;
2708 : :
2709 : 0 : rxq->rx_ring_phys_addr = rz->iova;
2710 : 0 : memset(rz->addr, 0, ICE_FDIR_NUM_RX_DESC *
2711 : : sizeof(union ice_32byte_rx_desc));
2712 : 0 : rxq->rx_flex_ring = (union ci_rx_flex_desc *)rz->addr;
2713 : :
2714 : : /*
2715 : : * Don't need to allocate software ring and reset for the fdir
2716 : : * rx queue, just set the queue has been configured.
2717 : : */
2718 : 0 : rxq->q_set = true;
2719 : 0 : pf->fdir.rxq = rxq;
2720 : :
2721 : 0 : rxq->rx_rel_mbufs = _ice_rx_queue_release_mbufs;
2722 : :
2723 : 0 : return ICE_SUCCESS;
2724 : : }
2725 : :
2726 : : uint16_t
2727 : 0 : ice_recv_pkts(void *rx_queue,
2728 : : struct rte_mbuf **rx_pkts,
2729 : : uint16_t nb_pkts)
2730 : : {
2731 : : struct ci_rx_queue *rxq = rx_queue;
2732 : 0 : volatile union ci_rx_flex_desc *rx_ring = rxq->rx_flex_ring;
2733 : : volatile union ci_rx_flex_desc *rxdp;
2734 : : union ci_rx_flex_desc rxd;
2735 : 0 : struct ci_rx_entry *sw_ring = rxq->sw_ring;
2736 : : struct ci_rx_entry *rxe;
2737 : : struct rte_mbuf *nmb; /* new allocated mbuf */
2738 : : struct rte_mbuf *nmb_pay; /* new allocated payload mbuf */
2739 : : struct rte_mbuf *rxm; /* pointer to store old mbuf in SW ring */
2740 : 0 : uint16_t rx_id = rxq->rx_tail;
2741 : : uint16_t nb_rx = 0;
2742 : : uint16_t nb_hold = 0;
2743 : : uint16_t rx_packet_len;
2744 : : uint16_t rx_header_len;
2745 : : uint16_t rx_stat_err0;
2746 : : uint64_t dma_addr;
2747 : : uint64_t pkt_flags;
2748 : 0 : uint32_t *ptype_tbl = rxq->ice_vsi->adapter->ptype_tbl;
2749 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
2750 : : bool is_tsinit = false;
2751 : : uint64_t ts_ns;
2752 : : struct ice_vsi *vsi = rxq->ice_vsi;
2753 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
2754 : : struct ice_adapter *ad = rxq->ice_vsi->adapter;
2755 : :
2756 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
2757 : 0 : uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
2758 : :
2759 [ # # ]: 0 : if (unlikely(sw_cur_time - rxq->hw_time_update > 4))
2760 : : is_tsinit = 1;
2761 : : }
2762 : : #endif
2763 : :
2764 [ # # ]: 0 : while (nb_rx < nb_pkts) {
2765 : 0 : rxdp = &rx_ring[rx_id];
2766 : 0 : rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
2767 : :
2768 : : /* Check the DD bit first */
2769 [ # # ]: 0 : if (!(rx_stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)))
2770 : : break;
2771 : :
2772 : : /* allocate header mbuf */
2773 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mp);
2774 [ # # ]: 0 : if (unlikely(!nmb)) {
2775 : 0 : rxq->ice_vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++;
2776 : 0 : break;
2777 : : }
2778 : :
2779 : 0 : rxd = *rxdp; /* copy descriptor in ring to temp variable*/
2780 : :
2781 : 0 : nb_hold++;
2782 : 0 : rxe = &sw_ring[rx_id]; /* get corresponding mbuf in SW ring */
2783 : 0 : rx_id++;
2784 [ # # ]: 0 : if (unlikely(rx_id == rxq->nb_rx_desc))
2785 : : rx_id = 0;
2786 : 0 : rxm = rxe->mbuf;
2787 [ # # ]: 0 : rxe->mbuf = nmb;
2788 : : dma_addr =
2789 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
2790 : :
2791 [ # # ]: 0 : if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
2792 : : /**
2793 : : * fill the read format of descriptor with physic address in
2794 : : * new allocated mbuf: nmb
2795 : : */
2796 : 0 : rxdp->read.hdr_addr = 0;
2797 : 0 : rxdp->read.pkt_addr = dma_addr;
2798 : : } else {
2799 : : /* allocate payload mbuf */
2800 : 0 : nmb_pay = rte_mbuf_raw_alloc(rxq->rxseg[1].mp);
2801 [ # # ]: 0 : if (unlikely(!nmb_pay)) {
2802 : 0 : rxq->ice_vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++;
2803 : 0 : rxe->mbuf = NULL;
2804 : : nb_hold--;
2805 [ # # ]: 0 : if (unlikely(rx_id == 0))
2806 : 0 : rx_id = rxq->nb_rx_desc;
2807 : :
2808 : 0 : rx_id--;
2809 : 0 : rte_pktmbuf_free(nmb);
2810 : 0 : break;
2811 : : }
2812 : :
2813 : 0 : nmb->next = nmb_pay;
2814 : 0 : nmb_pay->next = NULL;
2815 : :
2816 : : /**
2817 : : * fill the read format of descriptor with physic address in
2818 : : * new allocated mbuf: nmb
2819 : : */
2820 : 0 : rxdp->read.hdr_addr = dma_addr;
2821 : 0 : rxdp->read.pkt_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb_pay));
2822 : : }
2823 : :
2824 : : /* fill old mbuf with received descriptor: rxd */
2825 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
2826 : 0 : rte_prefetch0(RTE_PTR_ADD(rxm->buf_addr, RTE_PKTMBUF_HEADROOM));
2827 [ # # ]: 0 : if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
2828 : 0 : rxm->nb_segs = 1;
2829 : 0 : rxm->next = NULL;
2830 : : /* calculate rx_packet_len of the received pkt */
2831 : 0 : rx_packet_len = (rte_le_to_cpu_16(rxd.wb.pkt_len) &
2832 : 0 : ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
2833 : 0 : rxm->data_len = rx_packet_len;
2834 : 0 : rxm->pkt_len = rx_packet_len;
2835 : : } else {
2836 : 0 : rxm->nb_segs = (uint16_t)(rxm->nb_segs + rxm->next->nb_segs);
2837 : 0 : rxm->next->next = NULL;
2838 : : /* calculate rx_packet_len of the received pkt */
2839 : 0 : rx_header_len = rte_le_to_cpu_16(rxd.wb.hdr_len_sph_flex_flags1) &
2840 : : ICE_RX_FLEX_DESC_HEADER_LEN_M;
2841 : 0 : rx_packet_len = (rte_le_to_cpu_16(rxd.wb.pkt_len) &
2842 : 0 : ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
2843 : 0 : rxm->data_len = rx_header_len;
2844 : 0 : rxm->pkt_len = rx_header_len + rx_packet_len;
2845 : 0 : rxm->next->data_len = rx_packet_len;
2846 : :
2847 : : #ifdef RTE_ETHDEV_DEBUG_RX
2848 : : rte_pktmbuf_dump(stdout, rxm, rte_pktmbuf_pkt_len(rxm));
2849 : : #endif
2850 : : }
2851 : :
2852 : 0 : rxm->port = rxq->port_id;
2853 : 0 : rxm->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &
2854 : 0 : rte_le_to_cpu_16(rxd.wb.ptype_flex_flags0)];
2855 : 0 : ice_rxd_to_vlan_tci(rxm, &rxd);
2856 : 0 : rxd_to_pkt_fields_ops[rxq->rxdid](rxq, rxm, &rxd);
2857 : 0 : pkt_flags = ice_rxd_error_to_pkt_flags(rx_stat_err0);
2858 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
2859 [ # # ]: 0 : if (rxq->ts_flag > 0 &&
2860 [ # # ]: 0 : (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
2861 : 0 : rxq->time_high =
2862 : 0 : rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
2863 [ # # ]: 0 : if (unlikely(is_tsinit)) {
2864 : 0 : ts_ns = ice_tstamp_convert_32b_64b(hw, ad, 1, rxq->time_high);
2865 : 0 : rxq->hw_time_low = (uint32_t)ts_ns;
2866 : 0 : rxq->hw_time_high = (uint32_t)(ts_ns >> 32);
2867 : : is_tsinit = false;
2868 : : } else {
2869 [ # # ]: 0 : if (rxq->time_high < rxq->hw_time_low)
2870 : 0 : rxq->hw_time_high += 1;
2871 : 0 : ts_ns = (uint64_t)rxq->hw_time_high << 32 | rxq->time_high;
2872 : 0 : rxq->hw_time_low = rxq->time_high;
2873 : : }
2874 : 0 : rxq->hw_time_update = rte_get_timer_cycles() /
2875 : 0 : (rte_get_timer_hz() / 1000);
2876 : 0 : *RTE_MBUF_DYNFIELD(rxm,
2877 : : (rxq->ts_offset),
2878 : 0 : rte_mbuf_timestamp_t *) = ts_ns;
2879 : 0 : pkt_flags |= rxq->ts_flag;
2880 : : }
2881 : :
2882 [ # # # # ]: 0 : if (ad->ptp_ena && ((rxm->packet_type & RTE_PTYPE_L2_MASK) ==
2883 : : RTE_PTYPE_L2_ETHER_TIMESYNC)) {
2884 : 0 : rxq->time_high =
2885 : 0 : rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
2886 : 0 : rxm->timesync = rxq->queue_id;
2887 : 0 : pkt_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
2888 : : }
2889 : : #endif
2890 : 0 : rxm->ol_flags |= pkt_flags;
2891 : : /* copy old mbuf to rx_pkts */
2892 : 0 : rx_pkts[nb_rx++] = rxm;
2893 : : }
2894 : :
2895 : 0 : rxq->rx_tail = rx_id;
2896 : : /**
2897 : : * If the number of free RX descriptors is greater than the RX free
2898 : : * threshold of the queue, advance the receive tail register of queue.
2899 : : * Update that register with the value of the last processed RX
2900 : : * descriptor minus 1.
2901 : : */
2902 : 0 : nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold);
2903 [ # # ]: 0 : if (nb_hold > rxq->rx_free_thresh) {
2904 [ # # ]: 0 : rx_id = (uint16_t)(rx_id == 0 ?
2905 : 0 : (rxq->nb_rx_desc - 1) : (rx_id - 1));
2906 : : /* write TAIL register */
2907 : 0 : ICE_PCI_REG_WC_WRITE(rxq->qrx_tail, rx_id);
2908 : : nb_hold = 0;
2909 : : }
2910 : 0 : rxq->nb_rx_hold = nb_hold;
2911 : :
2912 : : /* return received packet in the burst */
2913 : 0 : return nb_rx;
2914 : : }
2915 : :
2916 : : static inline void
2917 : 0 : ice_parse_tunneling_params(uint64_t ol_flags,
2918 : : union ci_tx_offload tx_offload,
2919 : : uint32_t *cd_tunneling)
2920 : : {
2921 : : /* EIPT: External (outer) IP header type */
2922 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_OUTER_IP_CKSUM)
2923 : 0 : *cd_tunneling |= ICE_TX_CTX_EIPT_IPV4;
2924 [ # # ]: 0 : else if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV4)
2925 : 0 : *cd_tunneling |= ICE_TX_CTX_EIPT_IPV4_NO_CSUM;
2926 [ # # ]: 0 : else if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV6)
2927 : 0 : *cd_tunneling |= ICE_TX_CTX_EIPT_IPV6;
2928 : :
2929 : : /* EIPLEN: External (outer) IP header length, in DWords */
2930 : 0 : *cd_tunneling |= (tx_offload.outer_l3_len >> 2) <<
2931 : : ICE_TXD_CTX_QW0_EIPLEN_S;
2932 : :
2933 : : /* L4TUNT: L4 Tunneling Type */
2934 [ # # # # ]: 0 : switch (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
2935 : : case RTE_MBUF_F_TX_TUNNEL_IPIP:
2936 : : /* for non UDP / GRE tunneling, set to 00b */
2937 : : break;
2938 : 0 : case RTE_MBUF_F_TX_TUNNEL_VXLAN:
2939 : : case RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE:
2940 : : case RTE_MBUF_F_TX_TUNNEL_GTP:
2941 : : case RTE_MBUF_F_TX_TUNNEL_GENEVE:
2942 : 0 : *cd_tunneling |= ICE_TXD_CTX_UDP_TUNNELING;
2943 : 0 : break;
2944 : 0 : case RTE_MBUF_F_TX_TUNNEL_GRE:
2945 : 0 : *cd_tunneling |= ICE_TXD_CTX_GRE_TUNNELING;
2946 : 0 : break;
2947 : : default:
2948 : : PMD_TX_LOG(ERR, "Tunnel type not supported");
2949 : : return;
2950 : : }
2951 : :
2952 : : /* L4TUNLEN: L4 Tunneling Length, in Words
2953 : : *
2954 : : * We depend on app to set rte_mbuf.l2_len correctly.
2955 : : * For IP in GRE it should be set to the length of the GRE
2956 : : * header;
2957 : : * For MAC in GRE or MAC in UDP it should be set to the length
2958 : : * of the GRE or UDP headers plus the inner MAC up to including
2959 : : * its last Ethertype.
2960 : : * If MPLS labels exists, it should include them as well.
2961 : : */
2962 : 0 : *cd_tunneling |= (tx_offload.l2_len >> 1) <<
2963 : : ICE_TXD_CTX_QW0_NATLEN_S;
2964 : :
2965 : : /**
2966 : : * Calculate the tunneling UDP checksum.
2967 : : * Shall be set only if L4TUNT = 01b and EIPT is not zero
2968 : : */
2969 [ # # # # ]: 0 : if ((*cd_tunneling & ICE_TXD_CTX_QW0_EIPT_M) &&
2970 : 0 : (*cd_tunneling & ICE_TXD_CTX_UDP_TUNNELING) &&
2971 [ # # ]: 0 : (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
2972 : 0 : *cd_tunneling |= ICE_TXD_CTX_QW0_L4T_CS_M;
2973 : : }
2974 : :
2975 : : /* Construct the tx flags */
2976 : : static inline uint64_t
2977 : : ice_build_ctob(uint32_t td_cmd,
2978 : : uint32_t td_offset,
2979 : : uint16_t size,
2980 : : uint32_t td_tag)
2981 : : {
2982 : : return rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
2983 : : ((uint64_t)td_cmd << CI_TXD_QW1_CMD_S) |
2984 : : ((uint64_t)td_offset << CI_TXD_QW1_OFFSET_S) |
2985 : : ((uint64_t)size << CI_TXD_QW1_TX_BUF_SZ_S) |
2986 : : ((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S));
2987 : : }
2988 : :
2989 : : /* Check if the context descriptor is needed for TX offloading */
2990 : : static inline uint16_t
2991 : 0 : ice_calc_context_desc(uint64_t flags)
2992 : : {
2993 : : static uint64_t mask = RTE_MBUF_F_TX_TCP_SEG |
2994 : : RTE_MBUF_F_TX_UDP_SEG |
2995 : : RTE_MBUF_F_TX_QINQ |
2996 : : RTE_MBUF_F_TX_OUTER_IP_CKSUM |
2997 : : RTE_MBUF_F_TX_TUNNEL_MASK |
2998 : : RTE_MBUF_F_TX_IEEE1588_TMST;
2999 : :
3000 : 0 : return (flags & mask) ? 1 : 0;
3001 : : }
3002 : :
3003 : : /* set ice TSO context descriptor */
3004 : : static inline uint64_t
3005 : 0 : ice_set_tso_ctx(uint64_t ol_flags, const struct rte_mbuf *mbuf, union ci_tx_offload tx_offload)
3006 : : {
3007 : : uint64_t ctx_desc = 0;
3008 : : uint32_t cd_cmd, hdr_len, cd_tso_len;
3009 : :
3010 [ # # ]: 0 : if (!tx_offload.l4_len) {
3011 : : PMD_TX_LOG(DEBUG, "L4 length set to 0");
3012 : : return ctx_desc;
3013 : : }
3014 : :
3015 : 0 : hdr_len = tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len;
3016 : 0 : hdr_len += (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) ?
3017 [ # # ]: 0 : tx_offload.outer_l2_len + tx_offload.outer_l3_len : 0;
3018 : :
3019 : : cd_cmd = CI_TX_CTX_DESC_TSO;
3020 : 0 : cd_tso_len = mbuf->pkt_len - hdr_len;
3021 : 0 : ctx_desc |= ((uint64_t)cd_cmd << CI_TXD_QW1_CMD_S) |
3022 : 0 : ((uint64_t)cd_tso_len << ICE_TXD_CTX_QW1_TSO_LEN_S) |
3023 : 0 : ((uint64_t)mbuf->tso_segsz << ICE_TXD_CTX_QW1_MSS_S);
3024 : :
3025 : 0 : return ctx_desc;
3026 : : }
3027 : :
3028 : : /* compute a context descriptor if one is necessary based on the ol_flags
3029 : : *
3030 : : * Returns 0 if no descriptor is necessary.
3031 : : * Returns 1 if one is necessary and the contents of the descriptor are returned
3032 : : * in the values pointed to by qw0 and qw1.
3033 : : */
3034 : : static __rte_always_inline uint16_t
3035 : 0 : get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
3036 : : const union ci_tx_offload *tx_offload, const struct ci_tx_queue *txq,
3037 : : uint64_t *qw0, uint64_t *qw1)
3038 : : {
3039 : : uint16_t cd_l2tag2 = 0;
3040 : : uint64_t cd_type_cmd_tso_mss = ICE_TX_DESC_DTYPE_CTX;
3041 : 0 : uint32_t cd_tunneling_params = 0;
3042 : 0 : uint64_t ptp_tx_index = txq->ice_vsi->adapter->ptp_tx_index;
3043 : :
3044 [ # # ]: 0 : if (ice_calc_context_desc(ol_flags) == 0)
3045 : : return 0;
3046 : :
3047 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
3048 : 0 : ice_parse_tunneling_params(ol_flags, *tx_offload, &cd_tunneling_params);
3049 : :
3050 [ # # ]: 0 : if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
3051 : 0 : cd_type_cmd_tso_mss |= ice_set_tso_ctx(ol_flags, tx_pkt, *tx_offload);
3052 [ # # ]: 0 : else if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
3053 : 0 : cd_type_cmd_tso_mss |=
3054 : : ((uint64_t)CI_TX_CTX_DESC_TSYN << CI_TXD_QW1_CMD_S) |
3055 : 0 : ((ptp_tx_index << ICE_TXD_CTX_QW1_TSYN_S) & ICE_TXD_CTX_QW1_TSYN_M);
3056 : :
3057 : :
3058 : : /* TX context descriptor based double VLAN insert */
3059 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_QINQ) {
3060 : 0 : cd_l2tag2 = tx_pkt->vlan_tci_outer;
3061 : 0 : cd_type_cmd_tso_mss |= ((uint64_t)CI_TX_CTX_DESC_IL2TAG2 << CI_TXD_QW1_CMD_S);
3062 : : }
3063 : :
3064 : 0 : *qw0 = rte_cpu_to_le_32(cd_tunneling_params) |
3065 : 0 : ((uint64_t)rte_cpu_to_le_16(cd_l2tag2) << 32);
3066 : 0 : *qw1 = rte_cpu_to_le_64(cd_type_cmd_tso_mss);
3067 : :
3068 : 0 : return 1;
3069 : : }
3070 : :
3071 : : static uint16_t
3072 : 0 : ice_get_ts_tail(struct ci_tx_queue *txq)
3073 : : {
3074 : 0 : return txq->tsq->ts_tail;
3075 : : }
3076 : :
3077 : : static uint16_t
3078 : 0 : ice_write_ts_desc(struct ci_tx_queue *txq,
3079 : : struct rte_mbuf *tx_pkt,
3080 : : uint16_t tx_id,
3081 : : uint16_t ts_id)
3082 : : {
3083 : 0 : uint64_t txtime = *RTE_MBUF_DYNFIELD(tx_pkt, txq->tsq->ts_offset, uint64_t *);
3084 : 0 : uint32_t tstamp = (uint32_t)(txtime % NS_PER_S) >> ICE_TXTIME_CTX_RESOLUTION_128NS;
3085 [ # # ]: 0 : const uint32_t desc_tx_id = (tx_id == 0) ? txq->nb_tx_desc : tx_id;
3086 : 0 : __le32 ts_desc = rte_cpu_to_le_32(FIELD_PREP(ICE_TXTIME_TX_DESC_IDX_M, desc_tx_id) |
3087 : : FIELD_PREP(ICE_TXTIME_STAMP_M, tstamp));
3088 : :
3089 : 0 : txq->tsq->ice_ts_ring[ts_id].tx_desc_idx_tstamp = ts_desc;
3090 : 0 : ts_id++;
3091 : :
3092 : : /* To prevent an MDD, when wrapping the tstamp
3093 : : * ring create additional TS descriptors equal
3094 : : * to the number of the fetch TS descriptors
3095 : : * value. HW will merge the TS descriptors with
3096 : : * the same timestamp value into a single
3097 : : * descriptor.
3098 : : */
3099 [ # # ]: 0 : if (ts_id == txq->tsq->nb_ts_desc) {
3100 : 0 : uint16_t fetch = txq->tsq->nb_ts_desc - txq->nb_tx_desc;
3101 : : ts_id = 0;
3102 [ # # ]: 0 : for (; ts_id < fetch; ts_id++)
3103 : 0 : txq->tsq->ice_ts_ring[ts_id].tx_desc_idx_tstamp = ts_desc;
3104 : : }
3105 : 0 : return ts_id;
3106 : : }
3107 : :
3108 : : static void
3109 : 0 : ice_write_ts_tail(struct ci_tx_queue *txq, uint16_t ts_tail)
3110 : : {
3111 : 0 : ICE_PCI_REG_WRITE(txq->qtx_tail, ts_tail);
3112 : 0 : txq->tsq->ts_tail = ts_tail;
3113 : 0 : }
3114 : :
3115 : : uint16_t
3116 : 0 : ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
3117 : : {
3118 : 0 : const struct ci_timestamp_queue_fns ts_fns = {
3119 : : .get_ts_tail = ice_get_ts_tail,
3120 : : .write_ts_desc = ice_write_ts_desc,
3121 : : .write_ts_tail = ice_write_ts_tail,
3122 : : };
3123 : : struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
3124 : :
3125 [ # # # # ]: 0 : if (txq->tsq != NULL && txq->tsq->ts_flag > 0)
3126 : 0 : return ci_xmit_pkts(txq, tx_pkts, nb_pkts, CI_VLAN_IN_L2TAG1,
3127 : : get_context_desc, NULL, &ts_fns);
3128 : :
3129 : 0 : return ci_xmit_pkts(txq, tx_pkts, nb_pkts, CI_VLAN_IN_L2TAG1, get_context_desc, NULL, NULL);
3130 : : }
3131 : :
3132 : : static int
3133 : 0 : ice_tx_done_cleanup_full(struct ci_tx_queue *txq,
3134 : : uint32_t free_cnt)
3135 : : {
3136 : 0 : struct ci_tx_entry *swr_ring = txq->sw_ring;
3137 : : uint16_t i, tx_last, tx_id;
3138 : : uint16_t nb_tx_free_last;
3139 : : uint16_t nb_tx_to_clean;
3140 : : uint32_t pkt_cnt;
3141 : :
3142 : : /* Start free mbuf from the next of tx_tail */
3143 : 0 : tx_last = txq->tx_tail;
3144 : 0 : tx_id = swr_ring[tx_last].next_id;
3145 : :
3146 [ # # ]: 0 : if (txq->nb_tx_free == 0 && ci_tx_xmit_cleanup(txq))
3147 : : return 0;
3148 : :
3149 : 0 : nb_tx_to_clean = txq->nb_tx_free;
3150 : : nb_tx_free_last = txq->nb_tx_free;
3151 [ # # ]: 0 : if (!free_cnt)
3152 : 0 : free_cnt = txq->nb_tx_desc;
3153 : :
3154 : : /* Loop through swr_ring to count the amount of
3155 : : * freeable mubfs and packets.
3156 : : */
3157 [ # # ]: 0 : for (pkt_cnt = 0; pkt_cnt < free_cnt; ) {
3158 : 0 : for (i = 0; i < nb_tx_to_clean &&
3159 [ # # # # ]: 0 : pkt_cnt < free_cnt &&
3160 : 0 : tx_id != tx_last; i++) {
3161 [ # # ]: 0 : if (swr_ring[tx_id].mbuf != NULL) {
3162 : : /*
3163 : : * last segment in the packet,
3164 : : * increment packet count
3165 : : */
3166 [ # # ]: 0 : pkt_cnt += swr_ring[tx_id].mbuf->next == NULL ? 1 : 0;
3167 : : rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
3168 : 0 : swr_ring[tx_id].mbuf = NULL;
3169 : :
3170 : : }
3171 : :
3172 : 0 : tx_id = swr_ring[tx_id].next_id;
3173 : : }
3174 : :
3175 : 0 : if (txq->tx_rs_thresh > txq->nb_tx_desc -
3176 [ # # # # ]: 0 : txq->nb_tx_free || tx_id == tx_last)
3177 : : break;
3178 : :
3179 [ # # ]: 0 : if (pkt_cnt < free_cnt) {
3180 : : if (ci_tx_xmit_cleanup(txq))
3181 : : break;
3182 : :
3183 : 0 : nb_tx_to_clean = txq->nb_tx_free - nb_tx_free_last;
3184 : : nb_tx_free_last = txq->nb_tx_free;
3185 : : }
3186 : : }
3187 : :
3188 : 0 : return (int)pkt_cnt;
3189 : : }
3190 : :
3191 : : #ifdef RTE_ARCH_X86
3192 : : static int
3193 : : ice_tx_done_cleanup_vec(struct ci_tx_queue *txq __rte_unused,
3194 : : uint32_t free_cnt __rte_unused)
3195 : : {
3196 : : return -ENOTSUP;
3197 : : }
3198 : :
3199 : : enum rte_vect_max_simd
3200 : 0 : ice_get_max_simd_bitwidth(void)
3201 : : {
3202 : 0 : return ci_get_x86_max_simd_bitwidth();
3203 : : }
3204 : : #endif
3205 : :
3206 : : static int
3207 : 0 : ice_tx_done_cleanup_simple(struct ci_tx_queue *txq,
3208 : : uint32_t free_cnt)
3209 : : {
3210 : : int i, n, cnt;
3211 : :
3212 [ # # # # ]: 0 : if (free_cnt == 0 || free_cnt > txq->nb_tx_desc)
3213 : 0 : free_cnt = txq->nb_tx_desc;
3214 : :
3215 : 0 : cnt = free_cnt - free_cnt % txq->tx_rs_thresh;
3216 : :
3217 [ # # ]: 0 : for (i = 0; i < cnt; i += n) {
3218 [ # # ]: 0 : if (txq->nb_tx_desc - txq->nb_tx_free < txq->tx_rs_thresh)
3219 : : break;
3220 : :
3221 : : n = ci_tx_free_bufs_simple(txq);
3222 : :
3223 [ # # ]: 0 : if (n == 0)
3224 : : break;
3225 : : }
3226 : :
3227 : 0 : return i;
3228 : : }
3229 : :
3230 : : int
3231 : 0 : ice_tx_done_cleanup(void *txq, uint32_t free_cnt)
3232 : : {
3233 : : struct ci_tx_queue *q = (struct ci_tx_queue *)txq;
3234 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[q->port_id];
3235 : 0 : struct ice_adapter *ad =
3236 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3237 : :
3238 : : #ifdef RTE_ARCH_X86
3239 [ # # ]: 0 : if (ad->tx_vec_allowed)
3240 : : return ice_tx_done_cleanup_vec(q, free_cnt);
3241 : : #endif
3242 [ # # ]: 0 : if (ad->tx_simple_allowed)
3243 : 0 : return ice_tx_done_cleanup_simple(q, free_cnt);
3244 : : else
3245 : 0 : return ice_tx_done_cleanup_full(q, free_cnt);
3246 : : }
3247 : :
3248 : : static uint16_t
3249 : 0 : ice_xmit_pkts_simple(void *tx_queue,
3250 : : struct rte_mbuf **tx_pkts,
3251 : : uint16_t nb_pkts)
3252 : : {
3253 [ # # ]: 0 : return ci_xmit_pkts_simple(tx_queue, tx_pkts, nb_pkts);
3254 : : }
3255 : :
3256 : : static const struct ci_rx_path_info ice_rx_path_infos[] = {
3257 : : [ICE_RX_DEFAULT] = {
3258 : : .pkt_burst = ice_recv_pkts,
3259 : : .info = "Scalar",
3260 : : .features = {
3261 : : .rx_offloads = ICE_RX_SCALAR_OFFLOADS
3262 : : }
3263 : : },
3264 : : [ICE_RX_SCATTERED] = {
3265 : : .pkt_burst = ice_recv_scattered_pkts,
3266 : : .info = "Scalar Scattered",
3267 : : .features = {
3268 : : .rx_offloads = ICE_RX_SCALAR_OFFLOADS,
3269 : : .scattered = true
3270 : : }
3271 : : },
3272 : : [ICE_RX_BULK_ALLOC] = {
3273 : : .pkt_burst = ice_recv_pkts_bulk_alloc,
3274 : : .info = "Scalar Bulk Alloc",
3275 : : .features = {
3276 : : .rx_offloads = ICE_RX_SCALAR_OFFLOADS,
3277 : : .bulk_alloc = true
3278 : : }
3279 : : },
3280 : : #ifdef RTE_ARCH_X86
3281 : : [ICE_RX_AVX2] = {
3282 : : .pkt_burst = ice_recv_pkts_vec_avx2,
3283 : : .info = "Vector AVX2",
3284 : : .features = {
3285 : : .rx_offloads = ICE_RX_VECTOR_OFFLOADS,
3286 : : .simd_width = RTE_VECT_SIMD_256,
3287 : : .bulk_alloc = true
3288 : : }
3289 : : },
3290 : : [ICE_RX_AVX2_SCATTERED] = {
3291 : : .pkt_burst = ice_recv_scattered_pkts_vec_avx2,
3292 : : .info = "Vector AVX2 Scattered",
3293 : : .features = {
3294 : : .rx_offloads = ICE_RX_VECTOR_OFFLOADS,
3295 : : .simd_width = RTE_VECT_SIMD_256,
3296 : : .scattered = true,
3297 : : .bulk_alloc = true
3298 : : }
3299 : : },
3300 : : [ICE_RX_AVX2_OFFLOAD] = {
3301 : : .pkt_burst = ice_recv_pkts_vec_avx2_offload,
3302 : : .info = "Offload Vector AVX2",
3303 : : .features = {
3304 : : .rx_offloads = ICE_RX_VECTOR_OFFLOAD_OFFLOADS,
3305 : : .simd_width = RTE_VECT_SIMD_256,
3306 : : .bulk_alloc = true
3307 : : }
3308 : : },
3309 : : [ICE_RX_AVX2_SCATTERED_OFFLOAD] = {
3310 : : .pkt_burst = ice_recv_scattered_pkts_vec_avx2_offload,
3311 : : .info = "Offload Vector AVX2 Scattered",
3312 : : .features = {
3313 : : .rx_offloads = ICE_RX_VECTOR_OFFLOAD_OFFLOADS,
3314 : : .simd_width = RTE_VECT_SIMD_256,
3315 : : .scattered = true,
3316 : : .bulk_alloc = true
3317 : : }
3318 : : },
3319 : : #ifdef CC_AVX512_SUPPORT
3320 : : [ICE_RX_AVX512] = {
3321 : : .pkt_burst = ice_recv_pkts_vec_avx512,
3322 : : .info = "Vector AVX512",
3323 : : .features = {
3324 : : .rx_offloads = ICE_RX_VECTOR_OFFLOADS,
3325 : : .simd_width = RTE_VECT_SIMD_512,
3326 : : .bulk_alloc = true
3327 : : }
3328 : : },
3329 : : [ICE_RX_AVX512_SCATTERED] = {
3330 : : .pkt_burst = ice_recv_scattered_pkts_vec_avx512,
3331 : : .info = "Vector AVX512 Scattered",
3332 : : .features = {
3333 : : .rx_offloads = ICE_RX_VECTOR_OFFLOADS,
3334 : : .simd_width = RTE_VECT_SIMD_512,
3335 : : .scattered = true,
3336 : : .bulk_alloc = true
3337 : : }
3338 : : },
3339 : : [ICE_RX_AVX512_OFFLOAD] = {
3340 : : .pkt_burst = ice_recv_pkts_vec_avx512_offload,
3341 : : .info = "Offload Vector AVX512",
3342 : : .features = {
3343 : : .rx_offloads = ICE_RX_VECTOR_OFFLOAD_OFFLOADS,
3344 : : .simd_width = RTE_VECT_SIMD_512,
3345 : : .bulk_alloc = true
3346 : : }
3347 : : },
3348 : : [ICE_RX_AVX512_SCATTERED_OFFLOAD] = {
3349 : : .pkt_burst = ice_recv_scattered_pkts_vec_avx512_offload,
3350 : : .info = "Offload Vector AVX512 Scattered",
3351 : : .features = {
3352 : : .rx_offloads = ICE_RX_VECTOR_OFFLOAD_OFFLOADS,
3353 : : .simd_width = RTE_VECT_SIMD_512,
3354 : : .scattered = true,
3355 : : .bulk_alloc = true
3356 : : }
3357 : : },
3358 : : #endif
3359 : : #endif
3360 : : };
3361 : :
3362 : : void __rte_cold
3363 : 0 : ice_set_rx_function(struct rte_eth_dev *dev)
3364 : : {
3365 : 0 : PMD_INIT_FUNC_TRACE();
3366 : 0 : struct ice_adapter *ad =
3367 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3368 : : enum rte_vect_max_simd rx_simd_width = RTE_VECT_SIMD_DISABLED;
3369 : 0 : struct ci_rx_path_features req_features = {
3370 : 0 : .rx_offloads = dev->data->dev_conf.rxmode.offloads,
3371 : : .simd_width = RTE_VECT_SIMD_DISABLED,
3372 : : };
3373 : :
3374 : : /* If the device has started the function has already been selected. */
3375 [ # # ]: 0 : if (dev->data->dev_started)
3376 : 0 : goto out;
3377 : :
3378 : : #ifdef RTE_ARCH_X86
3379 [ # # # # ]: 0 : if (ad->ptp_ena || !ad->rx_bulk_alloc_allowed) {
3380 : : rx_simd_width = RTE_VECT_SIMD_DISABLED;
3381 : : } else {
3382 : 0 : rx_simd_width = ice_get_max_simd_bitwidth();
3383 [ # # ]: 0 : if (rx_simd_width >= RTE_VECT_SIMD_256)
3384 [ # # ]: 0 : if (ice_rx_vec_dev_check(dev) == -1)
3385 : : rx_simd_width = RTE_VECT_SIMD_DISABLED;
3386 : : }
3387 : : #endif
3388 : :
3389 : 0 : req_features.simd_width = rx_simd_width;
3390 [ # # ]: 0 : if (dev->data->scattered_rx)
3391 : 0 : req_features.scattered = true;
3392 [ # # ]: 0 : if (ad->rx_bulk_alloc_allowed)
3393 : 0 : req_features.bulk_alloc = true;
3394 : :
3395 : 0 : ad->rx_func_type = ci_rx_path_select(&req_features,
3396 : : &ice_rx_path_infos[0],
3397 : : RTE_DIM(ice_rx_path_infos),
3398 : : ICE_RX_DEFAULT);
3399 : : #ifdef RTE_ARCH_X86
3400 : : int i;
3401 : :
3402 [ # # ]: 0 : if (ice_rx_path_infos[ad->rx_func_type].features.simd_width >= RTE_VECT_SIMD_256)
3403 : : /* Vector function selected. Prepare the rxq accordingly. */
3404 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++)
3405 [ # # ]: 0 : if (dev->data->rx_queues[i])
3406 : 0 : ice_rxq_vec_setup(dev->data->rx_queues[i]);
3407 : : #endif
3408 : :
3409 : 0 : out:
3410 : 0 : dev->rx_pkt_burst = ice_rx_path_infos[ad->rx_func_type].pkt_burst;
3411 : 0 : PMD_DRV_LOG(NOTICE, "Using %s (port %d).",
3412 : : ice_rx_path_infos[ad->rx_func_type].info, dev->data->port_id);
3413 : 0 : }
3414 : :
3415 : : int
3416 : 0 : ice_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
3417 : : struct rte_eth_burst_mode *mode)
3418 : : {
3419 : 0 : eth_rx_burst_t pkt_burst = dev->rx_pkt_burst;
3420 : : int ret = -EINVAL;
3421 : : unsigned int i;
3422 : :
3423 [ # # ]: 0 : for (i = 0; i < RTE_DIM(ice_rx_path_infos); ++i) {
3424 [ # # ]: 0 : if (pkt_burst == ice_rx_path_infos[i].pkt_burst) {
3425 : 0 : snprintf(mode->info, sizeof(mode->info), "%s",
3426 : 0 : ice_rx_path_infos[i].info);
3427 : : ret = 0;
3428 : 0 : break;
3429 : : }
3430 : : }
3431 : :
3432 : 0 : return ret;
3433 : : }
3434 : :
3435 : : void __rte_cold
3436 : 0 : ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ci_tx_queue *txq)
3437 : : {
3438 : 0 : struct ice_adapter *ad =
3439 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3440 : :
3441 : : /* Use a simple Tx queue if possible (only fast free is allowed) */
3442 : 0 : ad->tx_simple_allowed =
3443 : 0 : (txq->offloads ==
3444 [ # # ]: 0 : (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
3445 [ # # ]: 0 : txq->tx_rs_thresh >= ICE_TX_MAX_BURST);
3446 : :
3447 [ # # ]: 0 : if (ad->tx_simple_allowed)
3448 : 0 : PMD_INIT_LOG(DEBUG, "Simple Tx can be enabled on Tx queue %u.",
3449 : : txq->queue_id);
3450 : : else
3451 : 0 : PMD_INIT_LOG(DEBUG,
3452 : : "Simple Tx can NOT be enabled on Tx queue %u.",
3453 : : txq->queue_id);
3454 : 0 : }
3455 : :
3456 : : /*********************************************************************
3457 : : *
3458 : : * TX prep functions
3459 : : *
3460 : : **********************************************************************/
3461 : : /* The default values of TSO MSS */
3462 : : #define ICE_MIN_TSO_MSS 64
3463 : : #define ICE_MAX_TSO_MSS 9728
3464 : : #define ICE_MAX_TSO_FRAME_SIZE 262144
3465 : :
3466 : : /*Check for empty mbuf*/
3467 : : static inline uint16_t
3468 : : ice_check_empty_mbuf(struct rte_mbuf *tx_pkt)
3469 : : {
3470 : : struct rte_mbuf *txd = tx_pkt;
3471 : :
3472 [ # # ]: 0 : while (txd != NULL) {
3473 [ # # ]: 0 : if (txd->data_len == 0)
3474 : : return -1;
3475 : 0 : txd = txd->next;
3476 : : }
3477 : :
3478 : : return 0;
3479 : : }
3480 : :
3481 : : static const struct ci_tx_path_info ice_tx_path_infos[] = {
3482 : : [ICE_TX_DEFAULT] = {
3483 : : .pkt_burst = ice_xmit_pkts,
3484 : : .info = "Scalar",
3485 : : .features = {
3486 : : .tx_offloads = ICE_TX_SCALAR_OFFLOADS
3487 : : },
3488 : : .pkt_prep = ice_prep_pkts
3489 : : },
3490 : : [ICE_TX_SIMPLE] = {
3491 : : .pkt_burst = ice_xmit_pkts_simple,
3492 : : .info = "Scalar Simple",
3493 : : .features = {
3494 : : .tx_offloads = ICE_TX_SCALAR_OFFLOADS,
3495 : : .simple_tx = true
3496 : : },
3497 : : .pkt_prep = rte_eth_tx_pkt_prepare_dummy
3498 : : },
3499 : : #ifdef RTE_ARCH_X86
3500 : : [ICE_TX_AVX2] = {
3501 : : .pkt_burst = ice_xmit_pkts_vec_avx2,
3502 : : .info = "Vector AVX2",
3503 : : .features = {
3504 : : .tx_offloads = ICE_TX_VECTOR_OFFLOADS,
3505 : : .simd_width = RTE_VECT_SIMD_256
3506 : : },
3507 : : .pkt_prep = rte_eth_tx_pkt_prepare_dummy
3508 : : },
3509 : : [ICE_TX_AVX2_OFFLOAD] = {
3510 : : .pkt_burst = ice_xmit_pkts_vec_avx2_offload,
3511 : : .info = "Offload Vector AVX2",
3512 : : .features = {
3513 : : .tx_offloads = ICE_TX_VECTOR_OFFLOAD_OFFLOADS,
3514 : : .simd_width = RTE_VECT_SIMD_256
3515 : : },
3516 : : .pkt_prep = ice_prep_pkts
3517 : : },
3518 : : #ifdef CC_AVX512_SUPPORT
3519 : : [ICE_TX_AVX512] = {
3520 : : .pkt_burst = ice_xmit_pkts_vec_avx512,
3521 : : .info = "Vector AVX512",
3522 : : .features = {
3523 : : .tx_offloads = ICE_TX_VECTOR_OFFLOADS,
3524 : : .simd_width = RTE_VECT_SIMD_512
3525 : : },
3526 : : .pkt_prep = rte_eth_tx_pkt_prepare_dummy
3527 : : },
3528 : : [ICE_TX_AVX512_OFFLOAD] = {
3529 : : .pkt_burst = ice_xmit_pkts_vec_avx512_offload,
3530 : : .info = "Offload Vector AVX512",
3531 : : .features = {
3532 : : .tx_offloads = ICE_TX_VECTOR_OFFLOAD_OFFLOADS,
3533 : : .simd_width = RTE_VECT_SIMD_512
3534 : : },
3535 : : .pkt_prep = ice_prep_pkts
3536 : : },
3537 : : #endif
3538 : : #endif
3539 : : };
3540 : :
3541 : : /* Tx mbuf check */
3542 : : static uint16_t
3543 : 0 : ice_xmit_pkts_check(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
3544 : : {
3545 : : struct ci_tx_queue *txq = tx_queue;
3546 : : uint16_t idx;
3547 : : struct rte_mbuf *mb;
3548 : : bool pkt_error = false;
3549 : : uint16_t good_pkts = nb_pkts;
3550 : 0 : const char *reason = NULL;
3551 : 0 : struct ice_adapter *adapter = txq->ice_vsi->adapter;
3552 : : uint64_t ol_flags;
3553 : 0 : enum ice_tx_func_type tx_func_type = adapter->tx_func_type;
3554 : :
3555 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++) {
3556 : 0 : mb = tx_pkts[idx];
3557 : 0 : ol_flags = mb->ol_flags;
3558 : :
3559 [ # # # # ]: 0 : if ((adapter->devargs.mbuf_check & ICE_MBUF_CHECK_F_TX_MBUF) &&
3560 : 0 : (rte_mbuf_check(mb, 1, &reason) != 0)) {
3561 : : PMD_TX_LOG(ERR, "INVALID mbuf: %s", reason);
3562 : : pkt_error = true;
3563 : : break;
3564 : : }
3565 : :
3566 [ # # ]: 0 : if ((adapter->devargs.mbuf_check & ICE_MBUF_CHECK_F_TX_SIZE) &&
3567 [ # # # # ]: 0 : (mb->data_len > mb->pkt_len ||
3568 [ # # ]: 0 : mb->data_len < ICE_TX_MIN_PKT_LEN ||
3569 : : mb->data_len > ICE_FRAME_SIZE_MAX)) {
3570 : : PMD_TX_LOG(ERR, "INVALID mbuf: data_len (%u) is out of range, reasonable range (%d - %d)",
3571 : : mb->data_len, ICE_TX_MIN_PKT_LEN, ICE_FRAME_SIZE_MAX);
3572 : : pkt_error = true;
3573 : : break;
3574 : : }
3575 : :
3576 [ # # ]: 0 : if (adapter->devargs.mbuf_check & ICE_MBUF_CHECK_F_TX_SEGMENT) {
3577 [ # # ]: 0 : if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG)) {
3578 : : /**
3579 : : * No TSO case: nb->segs, pkt_len to not exceed
3580 : : * the limites.
3581 : : */
3582 [ # # ]: 0 : if (mb->nb_segs > ICE_TX_MTU_SEG_MAX) {
3583 : : PMD_TX_LOG(ERR, "INVALID mbuf: nb_segs (%d) exceeds HW limit, maximum allowed value is %d",
3584 : : mb->nb_segs, ICE_TX_MTU_SEG_MAX);
3585 : : pkt_error = true;
3586 : : break;
3587 : : }
3588 [ # # ]: 0 : if (mb->pkt_len > ICE_FRAME_SIZE_MAX) {
3589 : : PMD_TX_LOG(ERR, "INVALID mbuf: pkt_len (%d) exceeds HW limit, maximum allowed value is %d",
3590 : : mb->nb_segs, ICE_FRAME_SIZE_MAX);
3591 : : pkt_error = true;
3592 : : break;
3593 : : }
3594 : : } else if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
3595 : : /** TSO case: tso_segsz, nb_segs, pkt_len not exceed
3596 : : * the limits.
3597 : : */
3598 [ # # ]: 0 : if (mb->tso_segsz < ICE_MIN_TSO_MSS ||
3599 : : mb->tso_segsz > ICE_MAX_TSO_MSS) {
3600 : : /**
3601 : : * MSS outside the range are considered malicious
3602 : : */
3603 : : PMD_TX_LOG(ERR, "INVALID mbuf: tso_segsz (%u) is out of range, reasonable range (%d - %u)",
3604 : : mb->tso_segsz, ICE_MIN_TSO_MSS, ICE_MAX_TSO_MSS);
3605 : : pkt_error = true;
3606 : : break;
3607 : : }
3608 [ # # ]: 0 : if (mb->nb_segs > ((struct ci_tx_queue *)tx_queue)->nb_tx_desc) {
3609 : : PMD_TX_LOG(ERR, "INVALID mbuf: nb_segs out of ring length");
3610 : : pkt_error = true;
3611 : : break;
3612 : : }
3613 : : }
3614 : : }
3615 : :
3616 [ # # ]: 0 : if (adapter->devargs.mbuf_check & ICE_MBUF_CHECK_F_TX_OFFLOAD) {
3617 [ # # ]: 0 : if (ol_flags & ICE_TX_OFFLOAD_NOTSUP_MASK) {
3618 : : PMD_TX_LOG(ERR, "INVALID mbuf: TX offload is not supported");
3619 : : pkt_error = true;
3620 : : break;
3621 : : }
3622 : :
3623 [ # # ]: 0 : if (!rte_validate_tx_offload(mb)) {
3624 : : PMD_TX_LOG(ERR, "INVALID mbuf: TX offload setup error");
3625 : : pkt_error = true;
3626 : : break;
3627 : : }
3628 : : }
3629 : : }
3630 : :
3631 [ # # ]: 0 : if (pkt_error) {
3632 : 0 : txq->mbuf_errors++;
3633 : : good_pkts = idx;
3634 [ # # ]: 0 : if (good_pkts == 0)
3635 : : return 0;
3636 : : }
3637 : :
3638 : 0 : return ice_tx_path_infos[tx_func_type].pkt_burst(tx_queue, tx_pkts, good_pkts);
3639 : : }
3640 : :
3641 : : uint16_t
3642 : 0 : ice_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
3643 : : uint16_t nb_pkts)
3644 : : {
3645 : : int i, ret;
3646 : : uint64_t ol_flags;
3647 : : struct rte_mbuf *m;
3648 : :
3649 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
3650 : 0 : m = tx_pkts[i];
3651 : 0 : ol_flags = m->ol_flags;
3652 : :
3653 [ # # ]: 0 : if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
3654 : : /**
3655 : : * No TSO case: nb->segs, pkt_len to not exceed
3656 : : * the limites.
3657 : : */
3658 [ # # ]: 0 : (m->nb_segs > ICE_TX_MTU_SEG_MAX ||
3659 [ # # ]: 0 : m->pkt_len > ICE_FRAME_SIZE_MAX)) {
3660 : 0 : rte_errno = EINVAL;
3661 : 0 : return i;
3662 [ # # ]: 0 : } else if (ol_flags & RTE_MBUF_F_TX_TCP_SEG &&
3663 : : /** TSO case: tso_segsz, nb_segs, pkt_len not exceed
3664 : : * the limits.
3665 : : */
3666 [ # # ]: 0 : (m->tso_segsz < ICE_MIN_TSO_MSS ||
3667 : 0 : m->tso_segsz > ICE_MAX_TSO_MSS ||
3668 : 0 : m->nb_segs >
3669 [ # # ]: 0 : ((struct ci_tx_queue *)tx_queue)->nb_tx_desc ||
3670 [ # # ]: 0 : m->pkt_len > ICE_MAX_TSO_FRAME_SIZE)) {
3671 : : /**
3672 : : * MSS outside the range are considered malicious
3673 : : */
3674 : 0 : rte_errno = EINVAL;
3675 : 0 : return i;
3676 : : }
3677 : :
3678 [ # # ]: 0 : if (m->pkt_len < ICE_TX_MIN_PKT_LEN) {
3679 : 0 : rte_errno = EINVAL;
3680 : 0 : return i;
3681 : : }
3682 : :
3683 : : #ifdef RTE_ETHDEV_DEBUG_TX
3684 : : ret = rte_validate_tx_offload(m);
3685 : : if (ret != 0) {
3686 : : rte_errno = -ret;
3687 : : return i;
3688 : : }
3689 : : #endif
3690 : : ret = rte_net_intel_cksum_prepare(m);
3691 [ # # ]: 0 : if (ret != 0) {
3692 : 0 : rte_errno = -ret;
3693 : 0 : return i;
3694 : : }
3695 : :
3696 [ # # ]: 0 : if (ice_check_empty_mbuf(m) != 0) {
3697 : 0 : rte_errno = EINVAL;
3698 : 0 : return i;
3699 : : }
3700 : : }
3701 : 0 : return i;
3702 : : }
3703 : :
3704 : : void __rte_cold
3705 : 0 : ice_set_tx_function(struct rte_eth_dev *dev)
3706 : : {
3707 : 0 : struct ice_adapter *ad =
3708 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3709 : 0 : int mbuf_check = ad->devargs.mbuf_check;
3710 : 0 : struct ci_tx_path_features req_features = {
3711 : 0 : .tx_offloads = dev->data->dev_conf.txmode.offloads,
3712 : : .simd_width = RTE_VECT_SIMD_DISABLED,
3713 : : };
3714 : :
3715 : : /* If the device has started the function has already been selected. */
3716 [ # # ]: 0 : if (dev->data->dev_started)
3717 : 0 : goto out;
3718 : :
3719 : 0 : req_features.simple_tx = ad->tx_simple_allowed;
3720 : :
3721 : : #ifdef RTE_ARCH_X86
3722 [ # # ]: 0 : if (ice_tx_vec_dev_check(dev) != -1)
3723 : 0 : req_features.simd_width = ice_get_max_simd_bitwidth();
3724 : : #endif
3725 : :
3726 : 0 : ad->tx_func_type = ci_tx_path_select(&req_features,
3727 : : &ice_tx_path_infos[0],
3728 : : RTE_DIM(ice_tx_path_infos),
3729 : : ICE_TX_DEFAULT);
3730 : :
3731 : 0 : out:
3732 : 0 : ad->tx_vec_allowed =
3733 : 0 : (ice_tx_path_infos[ad->tx_func_type].features.simd_width >= RTE_VECT_SIMD_256);
3734 : :
3735 [ # # ]: 0 : dev->tx_pkt_burst = mbuf_check ? ice_xmit_pkts_check :
3736 : : ice_tx_path_infos[ad->tx_func_type].pkt_burst;
3737 : 0 : dev->tx_pkt_prepare = ice_tx_path_infos[ad->tx_func_type].pkt_prep;
3738 : 0 : PMD_DRV_LOG(NOTICE, "Using %s (port %d).",
3739 : : ice_tx_path_infos[ad->tx_func_type].info, dev->data->port_id);
3740 : 0 : }
3741 : :
3742 : : int
3743 : 0 : ice_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
3744 : : struct rte_eth_burst_mode *mode)
3745 : : {
3746 : 0 : eth_tx_burst_t pkt_burst = dev->tx_pkt_burst;
3747 : : int ret = -EINVAL;
3748 : : unsigned int i;
3749 : :
3750 [ # # ]: 0 : for (i = 0; i < RTE_DIM(ice_tx_path_infos); ++i) {
3751 [ # # ]: 0 : if (pkt_burst == ice_tx_path_infos[i].pkt_burst) {
3752 : 0 : snprintf(mode->info, sizeof(mode->info), "%s",
3753 : 0 : ice_tx_path_infos[i].info);
3754 : : ret = 0;
3755 : 0 : break;
3756 : : }
3757 : : }
3758 : :
3759 : 0 : return ret;
3760 : : }
3761 : :
3762 : : /* For each value it means, datasheet of hardware can tell more details
3763 : : *
3764 : : * @note: fix ice_dev_supported_ptypes_get() if any change here.
3765 : : */
3766 : : static inline uint32_t
3767 : : ice_get_default_pkt_type(uint16_t ptype)
3768 : : {
3769 : : static const alignas(RTE_CACHE_LINE_SIZE) uint32_t type_table[ICE_MAX_PKT_TYPE] = {
3770 : : /* L2 types */
3771 : : /* [0] reserved */
3772 : : [1] = RTE_PTYPE_L2_ETHER,
3773 : : [2] = RTE_PTYPE_L2_ETHER_TIMESYNC,
3774 : : /* [3] - [5] reserved */
3775 : : [6] = RTE_PTYPE_L2_ETHER_LLDP,
3776 : : /* [7] - [10] reserved */
3777 : : [11] = RTE_PTYPE_L2_ETHER_ARP,
3778 : : /* [12] - [21] reserved */
3779 : :
3780 : : /* Non tunneled IPv4 */
3781 : : [22] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3782 : : RTE_PTYPE_L4_FRAG,
3783 : : [23] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3784 : : RTE_PTYPE_L4_NONFRAG,
3785 : : [24] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3786 : : RTE_PTYPE_L4_UDP,
3787 : : /* [25] reserved */
3788 : : [26] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3789 : : RTE_PTYPE_L4_TCP,
3790 : : [27] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3791 : : RTE_PTYPE_L4_SCTP,
3792 : : [28] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3793 : : RTE_PTYPE_L4_ICMP,
3794 : :
3795 : : /* IPv4 --> IPv4 */
3796 : : [29] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3797 : : RTE_PTYPE_TUNNEL_IP |
3798 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3799 : : RTE_PTYPE_INNER_L4_FRAG,
3800 : : [30] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3801 : : RTE_PTYPE_TUNNEL_IP |
3802 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3803 : : RTE_PTYPE_INNER_L4_NONFRAG,
3804 : : [31] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3805 : : RTE_PTYPE_TUNNEL_IP |
3806 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3807 : : RTE_PTYPE_INNER_L4_UDP,
3808 : : /* [32] reserved */
3809 : : [33] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3810 : : RTE_PTYPE_TUNNEL_IP |
3811 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3812 : : RTE_PTYPE_INNER_L4_TCP,
3813 : : [34] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3814 : : RTE_PTYPE_TUNNEL_IP |
3815 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3816 : : RTE_PTYPE_INNER_L4_SCTP,
3817 : : [35] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3818 : : RTE_PTYPE_TUNNEL_IP |
3819 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3820 : : RTE_PTYPE_INNER_L4_ICMP,
3821 : :
3822 : : /* IPv4 --> IPv6 */
3823 : : [36] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3824 : : RTE_PTYPE_TUNNEL_IP |
3825 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3826 : : RTE_PTYPE_INNER_L4_FRAG,
3827 : : [37] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3828 : : RTE_PTYPE_TUNNEL_IP |
3829 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3830 : : RTE_PTYPE_INNER_L4_NONFRAG,
3831 : : [38] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3832 : : RTE_PTYPE_TUNNEL_IP |
3833 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3834 : : RTE_PTYPE_INNER_L4_UDP,
3835 : : /* [39] reserved */
3836 : : [40] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3837 : : RTE_PTYPE_TUNNEL_IP |
3838 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3839 : : RTE_PTYPE_INNER_L4_TCP,
3840 : : [41] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3841 : : RTE_PTYPE_TUNNEL_IP |
3842 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3843 : : RTE_PTYPE_INNER_L4_SCTP,
3844 : : [42] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3845 : : RTE_PTYPE_TUNNEL_IP |
3846 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3847 : : RTE_PTYPE_INNER_L4_ICMP,
3848 : :
3849 : : /* IPv4 --> GRE/Teredo/VXLAN */
3850 : : [43] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3851 : : RTE_PTYPE_TUNNEL_GRENAT,
3852 : :
3853 : : /* IPv4 --> GRE/Teredo/VXLAN --> IPv4 */
3854 : : [44] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3855 : : RTE_PTYPE_TUNNEL_GRENAT |
3856 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3857 : : RTE_PTYPE_INNER_L4_FRAG,
3858 : : [45] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3859 : : RTE_PTYPE_TUNNEL_GRENAT |
3860 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3861 : : RTE_PTYPE_INNER_L4_NONFRAG,
3862 : : [46] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3863 : : RTE_PTYPE_TUNNEL_GRENAT |
3864 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3865 : : RTE_PTYPE_INNER_L4_UDP,
3866 : : /* [47] reserved */
3867 : : [48] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3868 : : RTE_PTYPE_TUNNEL_GRENAT |
3869 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3870 : : RTE_PTYPE_INNER_L4_TCP,
3871 : : [49] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3872 : : RTE_PTYPE_TUNNEL_GRENAT |
3873 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3874 : : RTE_PTYPE_INNER_L4_SCTP,
3875 : : [50] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3876 : : RTE_PTYPE_TUNNEL_GRENAT |
3877 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3878 : : RTE_PTYPE_INNER_L4_ICMP,
3879 : :
3880 : : /* IPv4 --> GRE/Teredo/VXLAN --> IPv6 */
3881 : : [51] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3882 : : RTE_PTYPE_TUNNEL_GRENAT |
3883 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3884 : : RTE_PTYPE_INNER_L4_FRAG,
3885 : : [52] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3886 : : RTE_PTYPE_TUNNEL_GRENAT |
3887 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3888 : : RTE_PTYPE_INNER_L4_NONFRAG,
3889 : : [53] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3890 : : RTE_PTYPE_TUNNEL_GRENAT |
3891 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3892 : : RTE_PTYPE_INNER_L4_UDP,
3893 : : /* [54] reserved */
3894 : : [55] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3895 : : RTE_PTYPE_TUNNEL_GRENAT |
3896 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3897 : : RTE_PTYPE_INNER_L4_TCP,
3898 : : [56] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3899 : : RTE_PTYPE_TUNNEL_GRENAT |
3900 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3901 : : RTE_PTYPE_INNER_L4_SCTP,
3902 : : [57] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3903 : : RTE_PTYPE_TUNNEL_GRENAT |
3904 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3905 : : RTE_PTYPE_INNER_L4_ICMP,
3906 : :
3907 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC */
3908 : : [58] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3909 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
3910 : :
3911 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
3912 : : [59] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3913 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3914 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3915 : : RTE_PTYPE_INNER_L4_FRAG,
3916 : : [60] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3917 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3918 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3919 : : RTE_PTYPE_INNER_L4_NONFRAG,
3920 : : [61] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3921 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3922 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3923 : : RTE_PTYPE_INNER_L4_UDP,
3924 : : /* [62] reserved */
3925 : : [63] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3926 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3927 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3928 : : RTE_PTYPE_INNER_L4_TCP,
3929 : : [64] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3930 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3931 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3932 : : RTE_PTYPE_INNER_L4_SCTP,
3933 : : [65] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3934 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3935 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3936 : : RTE_PTYPE_INNER_L4_ICMP,
3937 : :
3938 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
3939 : : [66] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3940 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3941 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3942 : : RTE_PTYPE_INNER_L4_FRAG,
3943 : : [67] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3944 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3945 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3946 : : RTE_PTYPE_INNER_L4_NONFRAG,
3947 : : [68] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3948 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3949 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3950 : : RTE_PTYPE_INNER_L4_UDP,
3951 : : /* [69] reserved */
3952 : : [70] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3953 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3954 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3955 : : RTE_PTYPE_INNER_L4_TCP,
3956 : : [71] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3957 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3958 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3959 : : RTE_PTYPE_INNER_L4_SCTP,
3960 : : [72] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3961 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3962 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3963 : : RTE_PTYPE_INNER_L4_ICMP,
3964 : : /* [73] - [87] reserved */
3965 : :
3966 : : /* Non tunneled IPv6 */
3967 : : [88] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3968 : : RTE_PTYPE_L4_FRAG,
3969 : : [89] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3970 : : RTE_PTYPE_L4_NONFRAG,
3971 : : [90] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3972 : : RTE_PTYPE_L4_UDP,
3973 : : /* [91] reserved */
3974 : : [92] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3975 : : RTE_PTYPE_L4_TCP,
3976 : : [93] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3977 : : RTE_PTYPE_L4_SCTP,
3978 : : [94] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3979 : : RTE_PTYPE_L4_ICMP,
3980 : :
3981 : : /* IPv6 --> IPv4 */
3982 : : [95] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3983 : : RTE_PTYPE_TUNNEL_IP |
3984 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3985 : : RTE_PTYPE_INNER_L4_FRAG,
3986 : : [96] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3987 : : RTE_PTYPE_TUNNEL_IP |
3988 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3989 : : RTE_PTYPE_INNER_L4_NONFRAG,
3990 : : [97] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3991 : : RTE_PTYPE_TUNNEL_IP |
3992 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3993 : : RTE_PTYPE_INNER_L4_UDP,
3994 : : /* [98] reserved */
3995 : : [99] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3996 : : RTE_PTYPE_TUNNEL_IP |
3997 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3998 : : RTE_PTYPE_INNER_L4_TCP,
3999 : : [100] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4000 : : RTE_PTYPE_TUNNEL_IP |
4001 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4002 : : RTE_PTYPE_INNER_L4_SCTP,
4003 : : [101] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4004 : : RTE_PTYPE_TUNNEL_IP |
4005 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4006 : : RTE_PTYPE_INNER_L4_ICMP,
4007 : :
4008 : : /* IPv6 --> IPv6 */
4009 : : [102] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4010 : : RTE_PTYPE_TUNNEL_IP |
4011 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4012 : : RTE_PTYPE_INNER_L4_FRAG,
4013 : : [103] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4014 : : RTE_PTYPE_TUNNEL_IP |
4015 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4016 : : RTE_PTYPE_INNER_L4_NONFRAG,
4017 : : [104] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4018 : : RTE_PTYPE_TUNNEL_IP |
4019 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4020 : : RTE_PTYPE_INNER_L4_UDP,
4021 : : /* [105] reserved */
4022 : : [106] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4023 : : RTE_PTYPE_TUNNEL_IP |
4024 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4025 : : RTE_PTYPE_INNER_L4_TCP,
4026 : : [107] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4027 : : RTE_PTYPE_TUNNEL_IP |
4028 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4029 : : RTE_PTYPE_INNER_L4_SCTP,
4030 : : [108] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4031 : : RTE_PTYPE_TUNNEL_IP |
4032 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4033 : : RTE_PTYPE_INNER_L4_ICMP,
4034 : :
4035 : : /* IPv6 --> GRE/Teredo/VXLAN */
4036 : : [109] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4037 : : RTE_PTYPE_TUNNEL_GRENAT,
4038 : :
4039 : : /* IPv6 --> GRE/Teredo/VXLAN --> IPv4 */
4040 : : [110] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4041 : : RTE_PTYPE_TUNNEL_GRENAT |
4042 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4043 : : RTE_PTYPE_INNER_L4_FRAG,
4044 : : [111] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4045 : : RTE_PTYPE_TUNNEL_GRENAT |
4046 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4047 : : RTE_PTYPE_INNER_L4_NONFRAG,
4048 : : [112] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4049 : : RTE_PTYPE_TUNNEL_GRENAT |
4050 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4051 : : RTE_PTYPE_INNER_L4_UDP,
4052 : : /* [113] reserved */
4053 : : [114] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4054 : : RTE_PTYPE_TUNNEL_GRENAT |
4055 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4056 : : RTE_PTYPE_INNER_L4_TCP,
4057 : : [115] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4058 : : RTE_PTYPE_TUNNEL_GRENAT |
4059 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4060 : : RTE_PTYPE_INNER_L4_SCTP,
4061 : : [116] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4062 : : RTE_PTYPE_TUNNEL_GRENAT |
4063 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4064 : : RTE_PTYPE_INNER_L4_ICMP,
4065 : :
4066 : : /* IPv6 --> GRE/Teredo/VXLAN --> IPv6 */
4067 : : [117] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4068 : : RTE_PTYPE_TUNNEL_GRENAT |
4069 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4070 : : RTE_PTYPE_INNER_L4_FRAG,
4071 : : [118] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4072 : : RTE_PTYPE_TUNNEL_GRENAT |
4073 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4074 : : RTE_PTYPE_INNER_L4_NONFRAG,
4075 : : [119] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4076 : : RTE_PTYPE_TUNNEL_GRENAT |
4077 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4078 : : RTE_PTYPE_INNER_L4_UDP,
4079 : : /* [120] reserved */
4080 : : [121] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4081 : : RTE_PTYPE_TUNNEL_GRENAT |
4082 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4083 : : RTE_PTYPE_INNER_L4_TCP,
4084 : : [122] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4085 : : RTE_PTYPE_TUNNEL_GRENAT |
4086 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4087 : : RTE_PTYPE_INNER_L4_SCTP,
4088 : : [123] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4089 : : RTE_PTYPE_TUNNEL_GRENAT |
4090 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4091 : : RTE_PTYPE_INNER_L4_ICMP,
4092 : :
4093 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC */
4094 : : [124] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4095 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
4096 : :
4097 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
4098 : : [125] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4099 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4100 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4101 : : RTE_PTYPE_INNER_L4_FRAG,
4102 : : [126] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4103 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4104 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4105 : : RTE_PTYPE_INNER_L4_NONFRAG,
4106 : : [127] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4107 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4108 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4109 : : RTE_PTYPE_INNER_L4_UDP,
4110 : : /* [128] reserved */
4111 : : [129] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4112 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4113 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4114 : : RTE_PTYPE_INNER_L4_TCP,
4115 : : [130] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4116 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4117 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4118 : : RTE_PTYPE_INNER_L4_SCTP,
4119 : : [131] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4120 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4121 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4122 : : RTE_PTYPE_INNER_L4_ICMP,
4123 : :
4124 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
4125 : : [132] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4126 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4127 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4128 : : RTE_PTYPE_INNER_L4_FRAG,
4129 : : [133] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4130 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4131 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4132 : : RTE_PTYPE_INNER_L4_NONFRAG,
4133 : : [134] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4134 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4135 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4136 : : RTE_PTYPE_INNER_L4_UDP,
4137 : : /* [135] reserved */
4138 : : [136] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4139 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4140 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4141 : : RTE_PTYPE_INNER_L4_TCP,
4142 : : [137] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4143 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4144 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4145 : : RTE_PTYPE_INNER_L4_SCTP,
4146 : : [138] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4147 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4148 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4149 : : RTE_PTYPE_INNER_L4_ICMP,
4150 : : /* [139] - [299] reserved */
4151 : :
4152 : : /* PPPoE */
4153 : : [300] = RTE_PTYPE_L2_ETHER_PPPOE,
4154 : : [301] = RTE_PTYPE_L2_ETHER_PPPOE,
4155 : :
4156 : : /* PPPoE --> IPv4 */
4157 : : [302] = RTE_PTYPE_L2_ETHER_PPPOE |
4158 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4159 : : RTE_PTYPE_L4_FRAG,
4160 : : [303] = RTE_PTYPE_L2_ETHER_PPPOE |
4161 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4162 : : RTE_PTYPE_L4_NONFRAG,
4163 : : [304] = RTE_PTYPE_L2_ETHER_PPPOE |
4164 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4165 : : RTE_PTYPE_L4_UDP,
4166 : : [305] = RTE_PTYPE_L2_ETHER_PPPOE |
4167 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4168 : : RTE_PTYPE_L4_TCP,
4169 : : [306] = RTE_PTYPE_L2_ETHER_PPPOE |
4170 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4171 : : RTE_PTYPE_L4_SCTP,
4172 : : [307] = RTE_PTYPE_L2_ETHER_PPPOE |
4173 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4174 : : RTE_PTYPE_L4_ICMP,
4175 : :
4176 : : /* PPPoE --> IPv6 */
4177 : : [308] = RTE_PTYPE_L2_ETHER_PPPOE |
4178 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4179 : : RTE_PTYPE_L4_FRAG,
4180 : : [309] = RTE_PTYPE_L2_ETHER_PPPOE |
4181 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4182 : : RTE_PTYPE_L4_NONFRAG,
4183 : : [310] = RTE_PTYPE_L2_ETHER_PPPOE |
4184 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4185 : : RTE_PTYPE_L4_UDP,
4186 : : [311] = RTE_PTYPE_L2_ETHER_PPPOE |
4187 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4188 : : RTE_PTYPE_L4_TCP,
4189 : : [312] = RTE_PTYPE_L2_ETHER_PPPOE |
4190 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4191 : : RTE_PTYPE_L4_SCTP,
4192 : : [313] = RTE_PTYPE_L2_ETHER_PPPOE |
4193 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4194 : : RTE_PTYPE_L4_ICMP,
4195 : : /* [314] - [324] reserved */
4196 : :
4197 : : /* IPv4/IPv6 --> GTPC/GTPU */
4198 : : [325] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4199 : : RTE_PTYPE_TUNNEL_GTPC,
4200 : : [326] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4201 : : RTE_PTYPE_TUNNEL_GTPC,
4202 : : [327] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4203 : : RTE_PTYPE_TUNNEL_GTPC,
4204 : : [328] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4205 : : RTE_PTYPE_TUNNEL_GTPC,
4206 : : [329] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4207 : : RTE_PTYPE_TUNNEL_GTPU,
4208 : : [330] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4209 : : RTE_PTYPE_TUNNEL_GTPU,
4210 : :
4211 : : /* IPv4 --> GTPU --> IPv4 */
4212 : : [331] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4213 : : RTE_PTYPE_TUNNEL_GTPU |
4214 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4215 : : RTE_PTYPE_INNER_L4_FRAG,
4216 : : [332] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4217 : : RTE_PTYPE_TUNNEL_GTPU |
4218 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4219 : : RTE_PTYPE_INNER_L4_NONFRAG,
4220 : : [333] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4221 : : RTE_PTYPE_TUNNEL_GTPU |
4222 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4223 : : RTE_PTYPE_INNER_L4_UDP,
4224 : : [334] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4225 : : RTE_PTYPE_TUNNEL_GTPU |
4226 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4227 : : RTE_PTYPE_INNER_L4_TCP,
4228 : : [335] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4229 : : RTE_PTYPE_TUNNEL_GTPU |
4230 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4231 : : RTE_PTYPE_INNER_L4_ICMP,
4232 : :
4233 : : /* IPv6 --> GTPU --> IPv4 */
4234 : : [336] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4235 : : RTE_PTYPE_TUNNEL_GTPU |
4236 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4237 : : RTE_PTYPE_INNER_L4_FRAG,
4238 : : [337] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4239 : : RTE_PTYPE_TUNNEL_GTPU |
4240 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4241 : : RTE_PTYPE_INNER_L4_NONFRAG,
4242 : : [338] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4243 : : RTE_PTYPE_TUNNEL_GTPU |
4244 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4245 : : RTE_PTYPE_INNER_L4_UDP,
4246 : : [339] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4247 : : RTE_PTYPE_TUNNEL_GTPU |
4248 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4249 : : RTE_PTYPE_INNER_L4_TCP,
4250 : : [340] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4251 : : RTE_PTYPE_TUNNEL_GTPU |
4252 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4253 : : RTE_PTYPE_INNER_L4_ICMP,
4254 : :
4255 : : /* IPv4 --> GTPU --> IPv6 */
4256 : : [341] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4257 : : RTE_PTYPE_TUNNEL_GTPU |
4258 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4259 : : RTE_PTYPE_INNER_L4_FRAG,
4260 : : [342] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4261 : : RTE_PTYPE_TUNNEL_GTPU |
4262 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4263 : : RTE_PTYPE_INNER_L4_NONFRAG,
4264 : : [343] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4265 : : RTE_PTYPE_TUNNEL_GTPU |
4266 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4267 : : RTE_PTYPE_INNER_L4_UDP,
4268 : : [344] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4269 : : RTE_PTYPE_TUNNEL_GTPU |
4270 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4271 : : RTE_PTYPE_INNER_L4_TCP,
4272 : : [345] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4273 : : RTE_PTYPE_TUNNEL_GTPU |
4274 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4275 : : RTE_PTYPE_INNER_L4_ICMP,
4276 : :
4277 : : /* IPv6 --> GTPU --> IPv6 */
4278 : : [346] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4279 : : RTE_PTYPE_TUNNEL_GTPU |
4280 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4281 : : RTE_PTYPE_INNER_L4_FRAG,
4282 : : [347] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4283 : : RTE_PTYPE_TUNNEL_GTPU |
4284 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4285 : : RTE_PTYPE_INNER_L4_NONFRAG,
4286 : : [348] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4287 : : RTE_PTYPE_TUNNEL_GTPU |
4288 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4289 : : RTE_PTYPE_INNER_L4_UDP,
4290 : : [349] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4291 : : RTE_PTYPE_TUNNEL_GTPU |
4292 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4293 : : RTE_PTYPE_INNER_L4_TCP,
4294 : : [350] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4295 : : RTE_PTYPE_TUNNEL_GTPU |
4296 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4297 : : RTE_PTYPE_INNER_L4_ICMP,
4298 : :
4299 : : /* IPv4 --> UDP ECPRI */
4300 : : [372] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4301 : : RTE_PTYPE_L4_UDP,
4302 : : [373] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4303 : : RTE_PTYPE_L4_UDP,
4304 : : [374] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4305 : : RTE_PTYPE_L4_UDP,
4306 : : [375] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4307 : : RTE_PTYPE_L4_UDP,
4308 : : [376] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4309 : : RTE_PTYPE_L4_UDP,
4310 : : [377] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4311 : : RTE_PTYPE_L4_UDP,
4312 : : [378] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4313 : : RTE_PTYPE_L4_UDP,
4314 : : [379] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4315 : : RTE_PTYPE_L4_UDP,
4316 : : [380] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4317 : : RTE_PTYPE_L4_UDP,
4318 : : [381] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4319 : : RTE_PTYPE_L4_UDP,
4320 : :
4321 : : /* IPV6 --> UDP ECPRI */
4322 : : [382] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4323 : : RTE_PTYPE_L4_UDP,
4324 : : [383] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4325 : : RTE_PTYPE_L4_UDP,
4326 : : [384] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4327 : : RTE_PTYPE_L4_UDP,
4328 : : [385] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4329 : : RTE_PTYPE_L4_UDP,
4330 : : [386] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4331 : : RTE_PTYPE_L4_UDP,
4332 : : [387] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4333 : : RTE_PTYPE_L4_UDP,
4334 : : [388] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4335 : : RTE_PTYPE_L4_UDP,
4336 : : [389] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4337 : : RTE_PTYPE_L4_UDP,
4338 : : [390] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4339 : : RTE_PTYPE_L4_UDP,
4340 : : [391] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4341 : : RTE_PTYPE_L4_UDP,
4342 : : /* All others reserved */
4343 : : };
4344 : :
4345 : 0 : return type_table[ptype];
4346 : : }
4347 : :
4348 : : void __rte_cold
4349 : 0 : ice_set_default_ptype_table(struct rte_eth_dev *dev)
4350 : : {
4351 : 0 : struct ice_adapter *ad =
4352 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
4353 : : int i;
4354 : :
4355 [ # # ]: 0 : for (i = 0; i < ICE_MAX_PKT_TYPE; i++)
4356 : 0 : ad->ptype_tbl[i] = ice_get_default_pkt_type(i);
4357 : 0 : }
4358 : :
4359 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S 1
4360 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_M \
4361 : : (0x3UL << ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S)
4362 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_ADD 0
4363 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_DEL 0x1
4364 : :
4365 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S 4
4366 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_M \
4367 : : (1 << ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S)
4368 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S 5
4369 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_M \
4370 : : (1 << ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S)
4371 : :
4372 : : /*
4373 : : * check the programming status descriptor in rx queue.
4374 : : * done after Programming Flow Director is programmed on
4375 : : * tx queue
4376 : : */
4377 : : static inline int
4378 : 0 : ice_check_fdir_programming_status(struct ci_rx_queue *rxq)
4379 : : {
4380 : : volatile union ice_32byte_rx_desc *rxdp;
4381 : : uint64_t qword1;
4382 : : uint32_t rx_status;
4383 : : uint32_t error;
4384 : : uint32_t id;
4385 : : int ret = -EAGAIN;
4386 : :
4387 : 0 : rxdp = (volatile union ice_32byte_rx_desc *)&rxq->rx_flex_ring[rxq->rx_tail];
4388 : 0 : qword1 = rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len);
4389 : : rx_status = (qword1 & ICE_RXD_QW1_STATUS_M)
4390 : 0 : >> ICE_RXD_QW1_STATUS_S;
4391 : :
4392 [ # # ]: 0 : if (rx_status & (1 << ICE_RX_DESC_STATUS_DD_S)) {
4393 : : ret = 0;
4394 : 0 : error = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_M) >>
4395 : : ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S;
4396 : 0 : id = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_M) >>
4397 : : ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S;
4398 [ # # ]: 0 : if (error) {
4399 [ # # ]: 0 : if (id == ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_ADD)
4400 : 0 : PMD_DRV_LOG(ERR, "Failed to add FDIR rule.");
4401 [ # # ]: 0 : else if (id == ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_DEL)
4402 : 0 : PMD_DRV_LOG(ERR, "Failed to remove FDIR rule.");
4403 : : ret = -EINVAL;
4404 : 0 : goto err;
4405 : : }
4406 : 0 : error = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_M) >>
4407 : : ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S;
4408 [ # # ]: 0 : if (error) {
4409 : 0 : PMD_DRV_LOG(ERR, "Failed to create FDIR profile.");
4410 : : ret = -EINVAL;
4411 : : }
4412 : 0 : err:
4413 : 0 : rxdp->wb.qword1.status_error_len = 0;
4414 : 0 : rxq->rx_tail++;
4415 [ # # ]: 0 : if (unlikely(rxq->rx_tail == rxq->nb_rx_desc))
4416 : 0 : rxq->rx_tail = 0;
4417 [ # # ]: 0 : if (rxq->rx_tail == 0)
4418 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
4419 : : else
4420 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_tail - 1);
4421 : : }
4422 : :
4423 : 0 : return ret;
4424 : : }
4425 : :
4426 : : #define ICE_FDIR_MAX_WAIT_US 10000
4427 : :
4428 : : int
4429 : 0 : ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc)
4430 : : {
4431 : 0 : struct ci_tx_queue *txq = pf->fdir.txq;
4432 : 0 : struct ci_rx_queue *rxq = pf->fdir.rxq;
4433 : : volatile struct ice_fltr_desc *fdirdp;
4434 : : volatile struct ci_tx_desc *txdp;
4435 : : uint32_t td_cmd;
4436 : : uint16_t i;
4437 : :
4438 : 0 : fdirdp = (volatile struct ice_fltr_desc *)
4439 : 0 : (&txq->ci_tx_ring[txq->tx_tail]);
4440 : 0 : fdirdp->qidx_compq_space_stat = fdir_desc->qidx_compq_space_stat;
4441 : 0 : fdirdp->dtype_cmd_vsi_fdid = fdir_desc->dtype_cmd_vsi_fdid;
4442 : :
4443 : 0 : txdp = &txq->ci_tx_ring[txq->tx_tail + 1];
4444 : 0 : txdp->buffer_addr = rte_cpu_to_le_64(pf->fdir.dma_addr);
4445 : : td_cmd = CI_TX_DESC_CMD_EOP |
4446 : : CI_TX_DESC_CMD_RS |
4447 : : CI_TX_DESC_CMD_DUMMY;
4448 : :
4449 : 0 : txdp->cmd_type_offset_bsz =
4450 : : ice_build_ctob(td_cmd, 0, ICE_FDIR_PKT_LEN, 0);
4451 : :
4452 : 0 : txq->tx_tail += 2;
4453 [ # # ]: 0 : if (txq->tx_tail >= txq->nb_tx_desc)
4454 : 0 : txq->tx_tail = 0;
4455 : : /* Update the tx tail register */
4456 : 0 : ICE_PCI_REG_WRITE(txq->qtx_tail, txq->tx_tail);
4457 [ # # ]: 0 : for (i = 0; i < ICE_FDIR_MAX_WAIT_US; i++) {
4458 [ # # ]: 0 : if ((txdp->cmd_type_offset_bsz & rte_cpu_to_le_64(CI_TXD_QW1_DTYPE_M)) ==
4459 : : rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE))
4460 : : break;
4461 : 0 : rte_delay_us(1);
4462 : : }
4463 [ # # ]: 0 : if (i >= ICE_FDIR_MAX_WAIT_US) {
4464 : 0 : PMD_DRV_LOG(ERR,
4465 : : "Failed to program FDIR filter: time out to get DD on tx queue.");
4466 : 0 : return -ETIMEDOUT;
4467 : : }
4468 : :
4469 [ # # ]: 0 : for (; i < ICE_FDIR_MAX_WAIT_US; i++) {
4470 : : int ret;
4471 : :
4472 : 0 : ret = ice_check_fdir_programming_status(rxq);
4473 [ # # ]: 0 : if (ret == -EAGAIN)
4474 : 0 : rte_delay_us(1);
4475 : : else
4476 : 0 : return ret;
4477 : : }
4478 : :
4479 : 0 : PMD_DRV_LOG(ERR,
4480 : : "Failed to program FDIR filter: programming status reported.");
4481 : 0 : return -ETIMEDOUT;
4482 : :
4483 : :
4484 : : }
|