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