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