1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
5 #include "ice_rxtx_vec_common.h"
9 #ifndef __INTEL_COMPILER
10 #pragma GCC diagnostic ignored "-Wcast-qual"
13 #define ICE_DESCS_PER_LOOP_AVX 8
15 static __rte_always_inline void
16 ice_rxq_rearm(struct ice_rx_queue *rxq)
20 volatile union ice_rx_flex_desc *rxdp;
21 struct ice_rx_entry *rxep = &rxq->sw_ring[rxq->rxrearm_start];
22 struct rte_mempool_cache *cache = rte_mempool_default_cache(rxq->mp,
25 rxdp = rxq->rx_ring + rxq->rxrearm_start;
28 return ice_rxq_rearm_common(rxq, true);
30 /* We need to pull 'n' more MBUFs into the software ring */
31 if (cache->len < ICE_RXQ_REARM_THRESH) {
32 uint32_t req = ICE_RXQ_REARM_THRESH + (cache->size -
35 int ret = rte_mempool_ops_dequeue_bulk(rxq->mp,
36 &cache->objs[cache->len], req);
40 if (rxq->rxrearm_nb + ICE_RXQ_REARM_THRESH >=
44 dma_addr0 = _mm_setzero_si128();
45 for (i = 0; i < ICE_DESCS_PER_LOOP; i++) {
46 rxep[i].mbuf = &rxq->fake_mbuf;
48 ((__m128i *)&rxdp[i].read,
52 rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
58 const __m512i iova_offsets = _mm512_set1_epi64
59 (offsetof(struct rte_mbuf, buf_iova));
60 const __m512i headroom = _mm512_set1_epi64(RTE_PKTMBUF_HEADROOM);
62 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
63 /* shuffle the iova into correct slots. Values 4-7 will contain
64 * zeros, so use 7 for a zero-value.
66 const __m512i permute_idx = _mm512_set_epi64(7, 7, 3, 1, 7, 7, 2, 0);
68 const __m512i permute_idx = _mm512_set_epi64(7, 3, 6, 2, 5, 1, 4, 0);
71 /* fill up the rxd in vector, process 8 mbufs in one loop */
72 for (i = 0; i < ICE_RXQ_REARM_THRESH / 8; i++) {
73 const __m512i mbuf_ptrs = _mm512_loadu_si512
74 (&cache->objs[cache->len - 8]);
75 _mm512_store_si512(rxep, mbuf_ptrs);
77 /* gather iova of mbuf0-7 into one zmm reg */
78 const __m512i iova_base_addrs = _mm512_i64gather_epi64
79 (_mm512_add_epi64(mbuf_ptrs, iova_offsets),
82 const __m512i iova_addrs = _mm512_add_epi64(iova_base_addrs,
84 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
85 const __m512i iovas0 = _mm512_castsi256_si512
86 (_mm512_extracti64x4_epi64(iova_addrs, 0));
87 const __m512i iovas1 = _mm512_castsi256_si512
88 (_mm512_extracti64x4_epi64(iova_addrs, 1));
90 /* permute leaves iova 2-3 in hdr_addr of desc 0-1
91 * but these are ignored by driver since header split not
92 * enabled. Similarly for desc 4 & 5.
94 const __m512i desc0_1 = _mm512_permutexvar_epi64
95 (permute_idx, iovas0);
96 const __m512i desc2_3 = _mm512_bsrli_epi128(desc0_1, 8);
98 const __m512i desc4_5 = _mm512_permutexvar_epi64
99 (permute_idx, iovas1);
100 const __m512i desc6_7 = _mm512_bsrli_epi128(desc4_5, 8);
102 _mm512_store_si512((void *)rxdp, desc0_1);
103 _mm512_store_si512((void *)(rxdp + 2), desc2_3);
104 _mm512_store_si512((void *)(rxdp + 4), desc4_5);
105 _mm512_store_si512((void *)(rxdp + 6), desc6_7);
107 /* permute leaves iova 4-7 in hdr_addr of desc 0-3
108 * but these are ignored by driver since header split not
111 const __m512i desc0_3 = _mm512_permutexvar_epi64
112 (permute_idx, iova_addrs);
113 const __m512i desc4_7 = _mm512_bsrli_epi128(desc0_3, 8);
115 _mm512_store_si512((void *)rxdp, desc0_3);
116 _mm512_store_si512((void *)(rxdp + 4), desc4_7);
118 rxep += 8, rxdp += 8, cache->len -= 8;
121 rxq->rxrearm_start += ICE_RXQ_REARM_THRESH;
122 if (rxq->rxrearm_start >= rxq->nb_rx_desc)
123 rxq->rxrearm_start = 0;
125 rxq->rxrearm_nb -= ICE_RXQ_REARM_THRESH;
127 rx_id = (uint16_t)((rxq->rxrearm_start == 0) ?
128 (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));
130 /* Update the tail pointer on the NIC */
131 ICE_PCI_REG_WC_WRITE(rxq->qrx_tail, rx_id);
134 static inline __m256i
135 ice_flex_rxd_to_fdir_flags_vec_avx512(const __m256i fdir_id0_7)
137 #define FDID_MIS_MAGIC 0xFFFFFFFF
138 RTE_BUILD_BUG_ON(PKT_RX_FDIR != (1 << 2));
139 RTE_BUILD_BUG_ON(PKT_RX_FDIR_ID != (1 << 13));
140 const __m256i pkt_fdir_bit = _mm256_set1_epi32(PKT_RX_FDIR |
142 /* desc->flow_id field == 0xFFFFFFFF means fdir mismatch */
143 const __m256i fdir_mis_mask = _mm256_set1_epi32(FDID_MIS_MAGIC);
144 __m256i fdir_mask = _mm256_cmpeq_epi32(fdir_id0_7,
146 /* this XOR op results to bit-reverse the fdir_mask */
147 fdir_mask = _mm256_xor_si256(fdir_mask, fdir_mis_mask);
148 const __m256i fdir_flags = _mm256_and_si256(fdir_mask, pkt_fdir_bit);
153 static __rte_always_inline uint16_t
154 _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
155 struct rte_mbuf **rx_pkts,
157 uint8_t *split_packet,
160 const uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
161 const __m256i mbuf_init = _mm256_set_epi64x(0, 0,
162 0, rxq->mbuf_initializer);
163 struct ice_rx_entry *sw_ring = &rxq->sw_ring[rxq->rx_tail];
164 volatile union ice_rx_flex_desc *rxdp = rxq->rx_ring + rxq->rx_tail;
168 /* nb_pkts has to be floor-aligned to ICE_DESCS_PER_LOOP_AVX */
169 nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, ICE_DESCS_PER_LOOP_AVX);
171 /* See if we need to rearm the RX queue - gives the prefetch a bit
174 if (rxq->rxrearm_nb > ICE_RXQ_REARM_THRESH)
177 /* Before we start moving massive data around, check to see if
178 * there is actually a packet available
180 if (!(rxdp->wb.status_error0 &
181 rte_cpu_to_le_32(1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)))
184 /* constants used in processing loop */
185 const __m512i crc_adjust =
187 (0, /* ignore non-length fields */
188 -rxq->crc_len, /* sub crc on data_len */
189 -rxq->crc_len, /* sub crc on pkt_len */
190 0 /* ignore non-length fields */
193 /* 8 packets DD mask, LSB in each 32-bit value */
194 const __m256i dd_check = _mm256_set1_epi32(1);
196 /* 8 packets EOP mask, second-LSB in each 32-bit value */
197 const __m256i eop_check = _mm256_slli_epi32(dd_check,
198 ICE_RX_DESC_STATUS_EOF_S);
200 /* mask to shuffle from desc. to mbuf (4 descriptors)*/
201 const __m512i shuf_msk =
203 (/* rss hash parsed separately */
205 /* octet 10~11, 16 bits vlan_macip */
206 /* octet 4~5, 16 bits data_len */
207 11 << 24 | 10 << 16 | 5 << 8 | 4,
208 /* skip hi 16 bits pkt_len, zero out */
209 /* octet 4~5, 16 bits pkt_len */
210 0xFFFF << 16 | 5 << 8 | 4,
211 /* pkt_type set as unknown */
216 * compile-time check the above crc and shuffle layout is correct.
217 * NOTE: the first field (lowest address) is given last in set_epi
220 RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
221 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
222 RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
223 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
224 RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, vlan_tci) !=
225 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
226 RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
227 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
229 /* following code block is for Rx Checksum Offload */
230 /* Status/Error flag masks */
232 * mask everything except Checksum Reports, RSS indication
233 * and VLAN indication.
234 * bit6:4 for IP/L4 checksum errors.
235 * bit12 is for RSS indication.
236 * bit13 is for VLAN indication.
238 const __m256i flags_mask =
239 _mm256_set1_epi32((0xF << 4) | (1 << 12) | (1 << 13));
241 * data to be shuffled by the result of the flags mask shifted by 4
242 * bits. This gives use the l3_l4 flags.
244 const __m256i l3_l4_flags_shuf =
245 _mm256_set_epi8((PKT_RX_OUTER_L4_CKSUM_BAD >> 20 |
246 PKT_RX_OUTER_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD |
247 PKT_RX_IP_CKSUM_BAD) >> 1,
248 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
249 PKT_RX_L4_CKSUM_BAD | PKT_RX_IP_CKSUM_GOOD) >> 1,
250 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
251 PKT_RX_L4_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD) >> 1,
252 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
253 PKT_RX_L4_CKSUM_GOOD | PKT_RX_IP_CKSUM_GOOD) >> 1,
254 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_L4_CKSUM_BAD |
255 PKT_RX_IP_CKSUM_BAD) >> 1,
256 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_L4_CKSUM_BAD |
257 PKT_RX_IP_CKSUM_GOOD) >> 1,
258 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_L4_CKSUM_GOOD |
259 PKT_RX_IP_CKSUM_BAD) >> 1,
260 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_L4_CKSUM_GOOD |
261 PKT_RX_IP_CKSUM_GOOD) >> 1,
262 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
263 PKT_RX_L4_CKSUM_BAD | PKT_RX_IP_CKSUM_BAD) >> 1,
264 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
265 PKT_RX_L4_CKSUM_BAD | PKT_RX_IP_CKSUM_GOOD) >> 1,
266 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
267 PKT_RX_L4_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD) >> 1,
268 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
269 PKT_RX_L4_CKSUM_GOOD | PKT_RX_IP_CKSUM_GOOD) >> 1,
270 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_L4_CKSUM_BAD |
271 PKT_RX_IP_CKSUM_BAD) >> 1,
272 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_L4_CKSUM_BAD |
273 PKT_RX_IP_CKSUM_GOOD) >> 1,
274 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_L4_CKSUM_GOOD |
275 PKT_RX_IP_CKSUM_BAD) >> 1,
276 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_L4_CKSUM_GOOD |
277 PKT_RX_IP_CKSUM_GOOD) >> 1,
280 * shift right 20 bits to use the low two bits to indicate
281 * outer checksum status
282 * shift right 1 bit to make sure it not exceed 255
284 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
285 PKT_RX_L4_CKSUM_BAD | PKT_RX_IP_CKSUM_BAD) >> 1,
286 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
287 PKT_RX_L4_CKSUM_BAD | PKT_RX_IP_CKSUM_GOOD) >> 1,
288 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
289 PKT_RX_L4_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD) >> 1,
290 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
291 PKT_RX_L4_CKSUM_GOOD | PKT_RX_IP_CKSUM_GOOD) >> 1,
292 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_L4_CKSUM_BAD |
293 PKT_RX_IP_CKSUM_BAD) >> 1,
294 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_L4_CKSUM_BAD |
295 PKT_RX_IP_CKSUM_GOOD) >> 1,
296 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_L4_CKSUM_GOOD |
297 PKT_RX_IP_CKSUM_BAD) >> 1,
298 (PKT_RX_OUTER_L4_CKSUM_BAD >> 20 | PKT_RX_L4_CKSUM_GOOD |
299 PKT_RX_IP_CKSUM_GOOD) >> 1,
300 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
301 PKT_RX_L4_CKSUM_BAD | PKT_RX_IP_CKSUM_BAD) >> 1,
302 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
303 PKT_RX_L4_CKSUM_BAD | PKT_RX_IP_CKSUM_GOOD) >> 1,
304 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
305 PKT_RX_L4_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD) >> 1,
306 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_OUTER_IP_CKSUM_BAD |
307 PKT_RX_L4_CKSUM_GOOD | PKT_RX_IP_CKSUM_GOOD) >> 1,
308 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_L4_CKSUM_BAD |
309 PKT_RX_IP_CKSUM_BAD) >> 1,
310 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_L4_CKSUM_BAD |
311 PKT_RX_IP_CKSUM_GOOD) >> 1,
312 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_L4_CKSUM_GOOD |
313 PKT_RX_IP_CKSUM_BAD) >> 1,
314 (PKT_RX_OUTER_L4_CKSUM_GOOD >> 20 | PKT_RX_L4_CKSUM_GOOD |
315 PKT_RX_IP_CKSUM_GOOD) >> 1);
316 const __m256i cksum_mask =
317 _mm256_set1_epi32(PKT_RX_IP_CKSUM_MASK |
318 PKT_RX_L4_CKSUM_MASK |
319 PKT_RX_OUTER_IP_CKSUM_BAD |
320 PKT_RX_OUTER_L4_CKSUM_MASK);
322 * data to be shuffled by result of flag mask, shifted down 12.
323 * If RSS(bit12)/VLAN(bit13) are set,
324 * shuffle moves appropriate flags in place.
326 const __m256i rss_vlan_flags_shuf = _mm256_set_epi8(0, 0, 0, 0,
329 PKT_RX_RSS_HASH | PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED,
330 PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED,
336 PKT_RX_RSS_HASH | PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED,
337 PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED,
340 uint16_t i, received;
342 for (i = 0, received = 0; i < nb_pkts;
343 i += ICE_DESCS_PER_LOOP_AVX,
344 rxdp += ICE_DESCS_PER_LOOP_AVX) {
345 /* step 1, copy over 8 mbuf pointers to rx_pkts array */
346 _mm256_storeu_si256((void *)&rx_pkts[i],
347 _mm256_loadu_si256((void *)&sw_ring[i]));
348 #ifdef RTE_ARCH_X86_64
350 ((void *)&rx_pkts[i + 4],
351 _mm256_loadu_si256((void *)&sw_ring[i + 4]));
354 __m512i raw_desc0_3, raw_desc4_7;
355 __m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
357 /* load in descriptors, in reverse order */
358 const __m128i raw_desc7 =
359 _mm_load_si128((void *)(rxdp + 7));
360 rte_compiler_barrier();
361 const __m128i raw_desc6 =
362 _mm_load_si128((void *)(rxdp + 6));
363 rte_compiler_barrier();
364 const __m128i raw_desc5 =
365 _mm_load_si128((void *)(rxdp + 5));
366 rte_compiler_barrier();
367 const __m128i raw_desc4 =
368 _mm_load_si128((void *)(rxdp + 4));
369 rte_compiler_barrier();
370 const __m128i raw_desc3 =
371 _mm_load_si128((void *)(rxdp + 3));
372 rte_compiler_barrier();
373 const __m128i raw_desc2 =
374 _mm_load_si128((void *)(rxdp + 2));
375 rte_compiler_barrier();
376 const __m128i raw_desc1 =
377 _mm_load_si128((void *)(rxdp + 1));
378 rte_compiler_barrier();
379 const __m128i raw_desc0 =
380 _mm_load_si128((void *)(rxdp + 0));
383 _mm256_inserti128_si256
384 (_mm256_castsi128_si256(raw_desc6),
387 _mm256_inserti128_si256
388 (_mm256_castsi128_si256(raw_desc4),
391 _mm256_inserti128_si256
392 (_mm256_castsi128_si256(raw_desc2),
395 _mm256_inserti128_si256
396 (_mm256_castsi128_si256(raw_desc0),
401 (_mm512_castsi256_si512(raw_desc4_5),
405 (_mm512_castsi256_si512(raw_desc0_1),
411 for (j = 0; j < ICE_DESCS_PER_LOOP_AVX; j++)
412 rte_mbuf_prefetch_part2(rx_pkts[i + j]);
416 * convert descriptors 0-7 into mbufs, re-arrange fields.
417 * Then write into the mbuf.
419 __m512i mb4_7 = _mm512_shuffle_epi8(raw_desc4_7, shuf_msk);
420 __m512i mb0_3 = _mm512_shuffle_epi8(raw_desc0_3, shuf_msk);
422 mb4_7 = _mm512_add_epi32(mb4_7, crc_adjust);
423 mb0_3 = _mm512_add_epi32(mb0_3, crc_adjust);
426 * to get packet types, ptype is located in bit16-25
429 const __m512i ptype_mask =
430 _mm512_set1_epi16(ICE_RX_FLEX_DESC_PTYPE_M);
433 * to get packet types, ptype is located in bit16-25
436 const __m512i ptypes4_7 =
437 _mm512_and_si512(raw_desc4_7, ptype_mask);
438 const __m512i ptypes0_3 =
439 _mm512_and_si512(raw_desc0_3, ptype_mask);
441 const __m256i ptypes6_7 =
442 _mm512_extracti64x4_epi64(ptypes4_7, 1);
443 const __m256i ptypes4_5 =
444 _mm512_extracti64x4_epi64(ptypes4_7, 0);
445 const __m256i ptypes2_3 =
446 _mm512_extracti64x4_epi64(ptypes0_3, 1);
447 const __m256i ptypes0_1 =
448 _mm512_extracti64x4_epi64(ptypes0_3, 0);
449 const uint16_t ptype7 = _mm256_extract_epi16(ptypes6_7, 9);
450 const uint16_t ptype6 = _mm256_extract_epi16(ptypes6_7, 1);
451 const uint16_t ptype5 = _mm256_extract_epi16(ptypes4_5, 9);
452 const uint16_t ptype4 = _mm256_extract_epi16(ptypes4_5, 1);
453 const uint16_t ptype3 = _mm256_extract_epi16(ptypes2_3, 9);
454 const uint16_t ptype2 = _mm256_extract_epi16(ptypes2_3, 1);
455 const uint16_t ptype1 = _mm256_extract_epi16(ptypes0_1, 9);
456 const uint16_t ptype0 = _mm256_extract_epi16(ptypes0_1, 1);
458 const __m512i ptype4_7 = _mm512_set_epi32
459 (0, 0, 0, ptype_tbl[ptype7],
460 0, 0, 0, ptype_tbl[ptype6],
461 0, 0, 0, ptype_tbl[ptype5],
462 0, 0, 0, ptype_tbl[ptype4]);
463 const __m512i ptype0_3 = _mm512_set_epi32
464 (0, 0, 0, ptype_tbl[ptype3],
465 0, 0, 0, ptype_tbl[ptype2],
466 0, 0, 0, ptype_tbl[ptype1],
467 0, 0, 0, ptype_tbl[ptype0]);
469 mb4_7 = _mm512_mask_blend_epi32(0x1111, mb4_7, ptype4_7);
470 mb0_3 = _mm512_mask_blend_epi32(0x1111, mb0_3, ptype0_3);
472 __m256i mb4_5 = _mm512_extracti64x4_epi64(mb4_7, 0);
473 __m256i mb6_7 = _mm512_extracti64x4_epi64(mb4_7, 1);
474 __m256i mb0_1 = _mm512_extracti64x4_epi64(mb0_3, 0);
475 __m256i mb2_3 = _mm512_extracti64x4_epi64(mb0_3, 1);
478 * use permute/extract to get status content
479 * After the operations, the packets status flags are in the
480 * order (hi->lo): [1, 3, 5, 7, 0, 2, 4, 6]
482 /* merge the status bits into one register */
483 const __m512i status_permute_msk = _mm512_set_epi32
488 const __m512i raw_status0_7 = _mm512_permutex2var_epi32
489 (raw_desc4_7, status_permute_msk, raw_desc0_3);
490 __m256i status0_7 = _mm512_extracti64x4_epi64
493 __m256i mbuf_flags = _mm256_set1_epi32(0);
496 /* now do flag manipulation */
498 /* get only flag/error bits we want */
499 const __m256i flag_bits =
500 _mm256_and_si256(status0_7, flags_mask);
502 * l3_l4_error flags, shuffle, then shift to correct adjustment
503 * of flags in flags_shuf, and finally mask out extra bits
505 __m256i l3_l4_flags = _mm256_shuffle_epi8(l3_l4_flags_shuf,
506 _mm256_srli_epi32(flag_bits, 4));
507 l3_l4_flags = _mm256_slli_epi32(l3_l4_flags, 1);
508 __m256i l4_outer_mask = _mm256_set1_epi32(0x6);
509 __m256i l4_outer_flags =
510 _mm256_and_si256(l3_l4_flags, l4_outer_mask);
511 l4_outer_flags = _mm256_slli_epi32(l4_outer_flags, 20);
513 __m256i l3_l4_mask = _mm256_set1_epi32(~0x6);
515 l3_l4_flags = _mm256_and_si256(l3_l4_flags, l3_l4_mask);
516 l3_l4_flags = _mm256_or_si256(l3_l4_flags, l4_outer_flags);
517 l3_l4_flags = _mm256_and_si256(l3_l4_flags, cksum_mask);
518 /* set rss and vlan flags */
519 const __m256i rss_vlan_flag_bits =
520 _mm256_srli_epi32(flag_bits, 12);
521 const __m256i rss_vlan_flags =
522 _mm256_shuffle_epi8(rss_vlan_flags_shuf,
526 mbuf_flags = _mm256_or_si256(l3_l4_flags,
530 if (rxq->fdir_enabled) {
531 const __m256i fdir_id4_7 =
532 _mm256_unpackhi_epi32(raw_desc6_7, raw_desc4_5);
534 const __m256i fdir_id0_3 =
535 _mm256_unpackhi_epi32(raw_desc2_3, raw_desc0_1);
537 const __m256i fdir_id0_7 =
538 _mm256_unpackhi_epi64(fdir_id4_7, fdir_id0_3);
541 const __m256i fdir_flags =
542 ice_flex_rxd_to_fdir_flags_vec_avx512
545 /* merge with fdir_flags */
546 mbuf_flags = _mm256_or_si256
547 (mbuf_flags, fdir_flags);
550 ice_flex_rxd_to_fdir_flags_vec_avx512
554 /* write to mbuf: have to use scalar store here */
555 rx_pkts[i + 0]->hash.fdir.hi =
556 _mm256_extract_epi32(fdir_id0_7, 3);
558 rx_pkts[i + 1]->hash.fdir.hi =
559 _mm256_extract_epi32(fdir_id0_7, 7);
561 rx_pkts[i + 2]->hash.fdir.hi =
562 _mm256_extract_epi32(fdir_id0_7, 2);
564 rx_pkts[i + 3]->hash.fdir.hi =
565 _mm256_extract_epi32(fdir_id0_7, 6);
567 rx_pkts[i + 4]->hash.fdir.hi =
568 _mm256_extract_epi32(fdir_id0_7, 1);
570 rx_pkts[i + 5]->hash.fdir.hi =
571 _mm256_extract_epi32(fdir_id0_7, 5);
573 rx_pkts[i + 6]->hash.fdir.hi =
574 _mm256_extract_epi32(fdir_id0_7, 0);
576 rx_pkts[i + 7]->hash.fdir.hi =
577 _mm256_extract_epi32(fdir_id0_7, 4);
578 } /* if() on fdir_enabled */
581 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
583 * needs to load 2nd 16B of each desc for RSS hash parsing,
584 * will cause performance drop to get into this context.
586 if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
587 DEV_RX_OFFLOAD_RSS_HASH) {
588 /* load bottom half of every 32B desc */
589 const __m128i raw_desc_bh7 =
591 ((void *)(&rxdp[7].wb.status_error1));
592 rte_compiler_barrier();
593 const __m128i raw_desc_bh6 =
595 ((void *)(&rxdp[6].wb.status_error1));
596 rte_compiler_barrier();
597 const __m128i raw_desc_bh5 =
599 ((void *)(&rxdp[5].wb.status_error1));
600 rte_compiler_barrier();
601 const __m128i raw_desc_bh4 =
603 ((void *)(&rxdp[4].wb.status_error1));
604 rte_compiler_barrier();
605 const __m128i raw_desc_bh3 =
607 ((void *)(&rxdp[3].wb.status_error1));
608 rte_compiler_barrier();
609 const __m128i raw_desc_bh2 =
611 ((void *)(&rxdp[2].wb.status_error1));
612 rte_compiler_barrier();
613 const __m128i raw_desc_bh1 =
615 ((void *)(&rxdp[1].wb.status_error1));
616 rte_compiler_barrier();
617 const __m128i raw_desc_bh0 =
619 ((void *)(&rxdp[0].wb.status_error1));
621 __m256i raw_desc_bh6_7 =
622 _mm256_inserti128_si256
623 (_mm256_castsi128_si256(raw_desc_bh6),
625 __m256i raw_desc_bh4_5 =
626 _mm256_inserti128_si256
627 (_mm256_castsi128_si256(raw_desc_bh4),
629 __m256i raw_desc_bh2_3 =
630 _mm256_inserti128_si256
631 (_mm256_castsi128_si256(raw_desc_bh2),
633 __m256i raw_desc_bh0_1 =
634 _mm256_inserti128_si256
635 (_mm256_castsi128_si256(raw_desc_bh0),
639 * to shift the 32b RSS hash value to the
640 * highest 32b of each 128b before mask
642 __m256i rss_hash6_7 =
643 _mm256_slli_epi64(raw_desc_bh6_7, 32);
644 __m256i rss_hash4_5 =
645 _mm256_slli_epi64(raw_desc_bh4_5, 32);
646 __m256i rss_hash2_3 =
647 _mm256_slli_epi64(raw_desc_bh2_3, 32);
648 __m256i rss_hash0_1 =
649 _mm256_slli_epi64(raw_desc_bh0_1, 32);
651 __m256i rss_hash_msk =
652 _mm256_set_epi32(0xFFFFFFFF, 0, 0, 0,
653 0xFFFFFFFF, 0, 0, 0);
655 rss_hash6_7 = _mm256_and_si256
656 (rss_hash6_7, rss_hash_msk);
657 rss_hash4_5 = _mm256_and_si256
658 (rss_hash4_5, rss_hash_msk);
659 rss_hash2_3 = _mm256_and_si256
660 (rss_hash2_3, rss_hash_msk);
661 rss_hash0_1 = _mm256_and_si256
662 (rss_hash0_1, rss_hash_msk);
664 mb6_7 = _mm256_or_si256(mb6_7, rss_hash6_7);
665 mb4_5 = _mm256_or_si256(mb4_5, rss_hash4_5);
666 mb2_3 = _mm256_or_si256(mb2_3, rss_hash2_3);
667 mb0_1 = _mm256_or_si256(mb0_1, rss_hash0_1);
668 } /* if() on RSS hash parsing */
673 * At this point, we have the 8 sets of flags in the low 16-bits
674 * of each 32-bit value in vlan0.
675 * We want to extract these, and merge them with the mbuf init
676 * data so we can do a single write to the mbuf to set the flags
677 * and all the other initialization fields. Extracting the
678 * appropriate flags means that we have to do a shift and blend
679 * for each mbuf before we do the write. However, we can also
680 * add in the previously computed rx_descriptor fields to
681 * make a single 256-bit write per mbuf
683 /* check the structure matches expectations */
684 RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
685 offsetof(struct rte_mbuf, rearm_data) + 8);
686 RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
687 RTE_ALIGN(offsetof(struct rte_mbuf,
690 /* build up data and do writes */
691 __m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
694 rearm6 = _mm256_blend_epi32(mbuf_init,
695 _mm256_slli_si256(mbuf_flags, 8),
697 rearm4 = _mm256_blend_epi32(mbuf_init,
698 _mm256_slli_si256(mbuf_flags, 4),
700 rearm2 = _mm256_blend_epi32(mbuf_init, mbuf_flags, 0x04);
701 rearm0 = _mm256_blend_epi32(mbuf_init,
702 _mm256_srli_si256(mbuf_flags, 4),
705 /* permute to add in the rx_descriptor e.g. rss fields */
706 rearm6 = _mm256_permute2f128_si256(rearm6, mb6_7, 0x20);
707 rearm4 = _mm256_permute2f128_si256(rearm4, mb4_5, 0x20);
708 rearm2 = _mm256_permute2f128_si256(rearm2, mb2_3, 0x20);
709 rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
712 _mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
714 _mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
716 _mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
718 _mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
721 /* repeat for the odd mbufs */
722 const __m256i odd_flags =
723 _mm256_castsi128_si256
724 (_mm256_extracti128_si256(mbuf_flags, 1));
725 rearm7 = _mm256_blend_epi32(mbuf_init,
726 _mm256_slli_si256(odd_flags, 8),
728 rearm5 = _mm256_blend_epi32(mbuf_init,
729 _mm256_slli_si256(odd_flags, 4),
731 rearm3 = _mm256_blend_epi32(mbuf_init, odd_flags, 0x04);
732 rearm1 = _mm256_blend_epi32(mbuf_init,
733 _mm256_srli_si256(odd_flags, 4),
736 /* since odd mbufs are already in hi 128-bits use blend */
737 rearm7 = _mm256_blend_epi32(rearm7, mb6_7, 0xF0);
738 rearm5 = _mm256_blend_epi32(rearm5, mb4_5, 0xF0);
739 rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
740 rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
741 /* again write to mbufs */
742 _mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
744 _mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
746 _mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
748 _mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
751 /* extract and record EOP bit */
753 const __m128i eop_mask =
754 _mm_set1_epi16(1 << ICE_RX_DESC_STATUS_EOF_S);
755 const __m256i eop_bits256 = _mm256_and_si256(status0_7,
757 /* pack status bits into a single 128-bit register */
758 const __m128i eop_bits =
760 (_mm256_castsi256_si128(eop_bits256),
761 _mm256_extractf128_si256(eop_bits256,
764 * flip bits, and mask out the EOP bit, which is now
765 * a split-packet bit i.e. !EOP, rather than EOP one.
767 __m128i split_bits = _mm_andnot_si128(eop_bits,
770 * eop bits are out of order, so we need to shuffle them
771 * back into order again. In doing so, only use low 8
772 * bits, which acts like another pack instruction
773 * The original order is (hi->lo): 1,3,5,7,0,2,4,6
774 * [Since we use epi8, the 16-bit positions are
775 * multiplied by 2 in the eop_shuffle value.]
777 __m128i eop_shuffle =
778 _mm_set_epi8(/* zero hi 64b */
779 0xFF, 0xFF, 0xFF, 0xFF,
780 0xFF, 0xFF, 0xFF, 0xFF,
781 /* move values to lo 64b */
784 split_bits = _mm_shuffle_epi8(split_bits, eop_shuffle);
785 *(uint64_t *)split_packet =
786 _mm_cvtsi128_si64(split_bits);
787 split_packet += ICE_DESCS_PER_LOOP_AVX;
790 /* perform dd_check */
791 status0_7 = _mm256_and_si256(status0_7, dd_check);
792 status0_7 = _mm256_packs_epi32(status0_7,
793 _mm256_setzero_si256());
795 uint64_t burst = __builtin_popcountll
797 (_mm256_extracti128_si256
799 burst += __builtin_popcountll
801 (_mm256_castsi256_si128(status0_7)));
803 if (burst != ICE_DESCS_PER_LOOP_AVX)
807 /* update tail pointers */
808 rxq->rx_tail += received;
809 rxq->rx_tail &= (rxq->nb_rx_desc - 1);
810 if ((rxq->rx_tail & 1) == 1 && received > 1) { /* keep avx2 aligned */
814 rxq->rxrearm_nb += received;
820 * - nb_pkts < ICE_DESCS_PER_LOOP, just return no packet
823 ice_recv_pkts_vec_avx512(void *rx_queue, struct rte_mbuf **rx_pkts,
826 return _ice_recv_raw_pkts_vec_avx512(rx_queue, rx_pkts, nb_pkts, NULL, false);
831 * - nb_pkts < ICE_DESCS_PER_LOOP, just return no packet
834 ice_recv_pkts_vec_avx512_offload(void *rx_queue, struct rte_mbuf **rx_pkts,
837 return _ice_recv_raw_pkts_vec_avx512(rx_queue, rx_pkts,
838 nb_pkts, NULL, true);
842 * vPMD receive routine that reassembles single burst of 32 scattered packets
844 * - nb_pkts < ICE_DESCS_PER_LOOP, just return no packet
847 ice_recv_scattered_burst_vec_avx512(void *rx_queue, struct rte_mbuf **rx_pkts,
850 struct ice_rx_queue *rxq = rx_queue;
851 uint8_t split_flags[ICE_VPMD_RX_BURST] = {0};
853 /* get some new buffers */
854 uint16_t nb_bufs = _ice_recv_raw_pkts_vec_avx512(rxq, rx_pkts, nb_pkts,
859 /* happy day case, full burst + no packets to be joined */
860 const uint64_t *split_fl64 = (uint64_t *)split_flags;
862 if (!rxq->pkt_first_seg &&
863 split_fl64[0] == 0 && split_fl64[1] == 0 &&
864 split_fl64[2] == 0 && split_fl64[3] == 0)
867 /* reassemble any packets that need reassembly */
870 if (!rxq->pkt_first_seg) {
871 /* find the first split flag, and only reassemble then */
872 while (i < nb_bufs && !split_flags[i])
876 rxq->pkt_first_seg = rx_pkts[i];
878 return i + ice_rx_reassemble_packets(rxq, &rx_pkts[i], nb_bufs - i,
883 * vPMD receive routine that reassembles single burst of 32 scattered packets
885 * - nb_pkts < ICE_DESCS_PER_LOOP, just return no packet
888 ice_recv_scattered_burst_vec_avx512_offload(void *rx_queue,
889 struct rte_mbuf **rx_pkts,
892 struct ice_rx_queue *rxq = rx_queue;
893 uint8_t split_flags[ICE_VPMD_RX_BURST] = {0};
895 /* get some new buffers */
896 uint16_t nb_bufs = _ice_recv_raw_pkts_vec_avx512(rxq,
897 rx_pkts, nb_pkts, split_flags, true);
901 /* happy day case, full burst + no packets to be joined */
902 const uint64_t *split_fl64 = (uint64_t *)split_flags;
904 if (!rxq->pkt_first_seg &&
905 split_fl64[0] == 0 && split_fl64[1] == 0 &&
906 split_fl64[2] == 0 && split_fl64[3] == 0)
909 /* reassemble any packets that need reassembly */
912 if (!rxq->pkt_first_seg) {
913 /* find the first split flag, and only reassemble then */
914 while (i < nb_bufs && !split_flags[i])
918 rxq->pkt_first_seg = rx_pkts[i];
920 return i + ice_rx_reassemble_packets(rxq, &rx_pkts[i], nb_bufs - i,
925 * vPMD receive routine that reassembles scattered packets.
926 * Main receive routine that can handle arbitrary burst sizes
928 * - nb_pkts < ICE_DESCS_PER_LOOP, just return no packet
931 ice_recv_scattered_pkts_vec_avx512(void *rx_queue, struct rte_mbuf **rx_pkts,
936 while (nb_pkts > ICE_VPMD_RX_BURST) {
937 uint16_t burst = ice_recv_scattered_burst_vec_avx512(rx_queue,
938 rx_pkts + retval, ICE_VPMD_RX_BURST);
941 if (burst < ICE_VPMD_RX_BURST)
944 return retval + ice_recv_scattered_burst_vec_avx512(rx_queue,
945 rx_pkts + retval, nb_pkts);
949 * vPMD receive routine that reassembles scattered packets.
950 * Main receive routine that can handle arbitrary burst sizes
952 * - nb_pkts < ICE_DESCS_PER_LOOP, just return no packet
955 ice_recv_scattered_pkts_vec_avx512_offload(void *rx_queue,
956 struct rte_mbuf **rx_pkts,
961 while (nb_pkts > ICE_VPMD_RX_BURST) {
963 ice_recv_scattered_burst_vec_avx512_offload(rx_queue,
964 rx_pkts + retval, ICE_VPMD_RX_BURST);
967 if (burst < ICE_VPMD_RX_BURST)
970 return retval + ice_recv_scattered_burst_vec_avx512_offload(rx_queue,
971 rx_pkts + retval, nb_pkts);
974 static __rte_always_inline int
975 ice_tx_free_bufs_avx512(struct ice_tx_queue *txq)
977 struct ice_vec_tx_entry *txep;
981 struct rte_mbuf *m, *free[ICE_TX_MAX_FREE_BUF_SZ];
983 /* check DD bits on threshold descriptor */
984 if ((txq->tx_ring[txq->tx_next_dd].cmd_type_offset_bsz &
985 rte_cpu_to_le_64(ICE_TXD_QW1_DTYPE_M)) !=
986 rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE))
989 n = txq->tx_rs_thresh;
991 /* first buffer to free from S/W ring is at index
992 * tx_next_dd - (tx_rs_thresh - 1)
994 txep = (void *)txq->sw_ring;
995 txep += txq->tx_next_dd - (n - 1);
997 if (txq->offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE && (n & 31) == 0) {
998 struct rte_mempool *mp = txep[0].mbuf->pool;
1000 struct rte_mempool_cache *cache = rte_mempool_default_cache(mp,
1003 if (!cache || cache->len == 0)
1006 cache_objs = &cache->objs[cache->len];
1008 if (n > RTE_MEMPOOL_CACHE_MAX_SIZE) {
1009 rte_mempool_ops_enqueue_bulk(mp, (void *)txep, n);
1013 /* The cache follows the following algorithm
1014 * 1. Add the objects to the cache
1015 * 2. Anything greater than the cache min value (if it
1016 * crosses the cache flush threshold) is flushed to the ring.
1018 /* Add elements back into the cache */
1019 uint32_t copied = 0;
1020 /* n is multiple of 32 */
1021 while (copied < n) {
1022 const __m512i a = _mm512_loadu_si512(&txep[copied]);
1023 const __m512i b = _mm512_loadu_si512(&txep[copied + 8]);
1024 const __m512i c = _mm512_loadu_si512(&txep[copied + 16]);
1025 const __m512i d = _mm512_loadu_si512(&txep[copied + 24]);
1027 _mm512_storeu_si512(&cache_objs[copied], a);
1028 _mm512_storeu_si512(&cache_objs[copied + 8], b);
1029 _mm512_storeu_si512(&cache_objs[copied + 16], c);
1030 _mm512_storeu_si512(&cache_objs[copied + 24], d);
1035 if (cache->len >= cache->flushthresh) {
1036 rte_mempool_ops_enqueue_bulk
1037 (mp, &cache->objs[cache->size],
1038 cache->len - cache->size);
1039 cache->len = cache->size;
1045 m = rte_pktmbuf_prefree_seg(txep[0].mbuf);
1049 for (i = 1; i < n; i++) {
1050 m = rte_pktmbuf_prefree_seg(txep[i].mbuf);
1052 if (likely(m->pool == free[0]->pool)) {
1053 free[nb_free++] = m;
1055 rte_mempool_put_bulk(free[0]->pool,
1063 rte_mempool_put_bulk(free[0]->pool, (void **)free, nb_free);
1065 for (i = 1; i < n; i++) {
1066 m = rte_pktmbuf_prefree_seg(txep[i].mbuf);
1068 rte_mempool_put(m->pool, m);
1073 /* buffers were freed, update counters */
1074 txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + txq->tx_rs_thresh);
1075 txq->tx_next_dd = (uint16_t)(txq->tx_next_dd + txq->tx_rs_thresh);
1076 if (txq->tx_next_dd >= txq->nb_tx_desc)
1077 txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1);
1079 return txq->tx_rs_thresh;
1082 static __rte_always_inline void
1083 ice_vtx1(volatile struct ice_tx_desc *txdp,
1084 struct rte_mbuf *pkt, uint64_t flags, bool do_offload)
1087 (ICE_TX_DESC_DTYPE_DATA |
1088 ((uint64_t)flags << ICE_TXD_QW1_CMD_S) |
1089 ((uint64_t)pkt->data_len << ICE_TXD_QW1_TX_BUF_SZ_S));
1092 ice_txd_enable_offload(pkt, &high_qw);
1094 __m128i descriptor = _mm_set_epi64x(high_qw,
1095 pkt->buf_iova + pkt->data_off);
1096 _mm_store_si128((__m128i *)txdp, descriptor);
1099 static __rte_always_inline void
1100 ice_vtx(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkt,
1101 uint16_t nb_pkts, uint64_t flags, bool do_offload)
1103 const uint64_t hi_qw_tmpl = (ICE_TX_DESC_DTYPE_DATA |
1104 ((uint64_t)flags << ICE_TXD_QW1_CMD_S));
1106 for (; nb_pkts > 3; txdp += 4, pkt += 4, nb_pkts -= 4) {
1109 ((uint64_t)pkt[3]->data_len <<
1110 ICE_TXD_QW1_TX_BUF_SZ_S);
1112 ice_txd_enable_offload(pkt[3], &hi_qw3);
1115 ((uint64_t)pkt[2]->data_len <<
1116 ICE_TXD_QW1_TX_BUF_SZ_S);
1118 ice_txd_enable_offload(pkt[2], &hi_qw2);
1121 ((uint64_t)pkt[1]->data_len <<
1122 ICE_TXD_QW1_TX_BUF_SZ_S);
1124 ice_txd_enable_offload(pkt[1], &hi_qw1);
1127 ((uint64_t)pkt[0]->data_len <<
1128 ICE_TXD_QW1_TX_BUF_SZ_S);
1130 ice_txd_enable_offload(pkt[0], &hi_qw0);
1135 pkt[3]->buf_iova + pkt[3]->data_off,
1137 pkt[2]->buf_iova + pkt[2]->data_off,
1139 pkt[1]->buf_iova + pkt[1]->data_off,
1141 pkt[0]->buf_iova + pkt[0]->data_off);
1142 _mm512_storeu_si512((void *)txdp, desc0_3);
1145 /* do any last ones */
1147 ice_vtx1(txdp, *pkt, flags, do_offload);
1148 txdp++, pkt++, nb_pkts--;
1152 static __rte_always_inline void
1153 ice_tx_backlog_entry_avx512(struct ice_vec_tx_entry *txep,
1154 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
1158 for (i = 0; i < (int)nb_pkts; ++i)
1159 txep[i].mbuf = tx_pkts[i];
1162 static __rte_always_inline uint16_t
1163 ice_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
1164 uint16_t nb_pkts, bool do_offload)
1166 struct ice_tx_queue *txq = (struct ice_tx_queue *)tx_queue;
1167 volatile struct ice_tx_desc *txdp;
1168 struct ice_vec_tx_entry *txep;
1169 uint16_t n, nb_commit, tx_id;
1170 uint64_t flags = ICE_TD_CMD;
1171 uint64_t rs = ICE_TX_DESC_CMD_RS | ICE_TD_CMD;
1173 /* cross rx_thresh boundary is not allowed */
1174 nb_pkts = RTE_MIN(nb_pkts, txq->tx_rs_thresh);
1176 if (txq->nb_tx_free < txq->tx_free_thresh)
1177 ice_tx_free_bufs_avx512(txq);
1179 nb_commit = nb_pkts = (uint16_t)RTE_MIN(txq->nb_tx_free, nb_pkts);
1180 if (unlikely(nb_pkts == 0))
1183 tx_id = txq->tx_tail;
1184 txdp = &txq->tx_ring[tx_id];
1185 txep = (void *)txq->sw_ring;
1188 txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
1190 n = (uint16_t)(txq->nb_tx_desc - tx_id);
1191 if (nb_commit >= n) {
1192 ice_tx_backlog_entry_avx512(txep, tx_pkts, n);
1194 ice_vtx(txdp, tx_pkts, n - 1, flags, do_offload);
1198 ice_vtx1(txdp, *tx_pkts++, rs, do_offload);
1200 nb_commit = (uint16_t)(nb_commit - n);
1203 txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
1205 /* avoid reach the end of ring */
1206 txdp = txq->tx_ring;
1207 txep = (void *)txq->sw_ring;
1210 ice_tx_backlog_entry_avx512(txep, tx_pkts, nb_commit);
1212 ice_vtx(txdp, tx_pkts, nb_commit, flags, do_offload);
1214 tx_id = (uint16_t)(tx_id + nb_commit);
1215 if (tx_id > txq->tx_next_rs) {
1216 txq->tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
1217 rte_cpu_to_le_64(((uint64_t)ICE_TX_DESC_CMD_RS) <<
1220 (uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh);
1223 txq->tx_tail = tx_id;
1225 ICE_PCI_REG_WC_WRITE(txq->qtx_tail, txq->tx_tail);
1231 ice_xmit_pkts_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
1235 struct ice_tx_queue *txq = (struct ice_tx_queue *)tx_queue;
1240 num = (uint16_t)RTE_MIN(nb_pkts, txq->tx_rs_thresh);
1241 ret = ice_xmit_fixed_burst_vec_avx512(tx_queue,
1242 &tx_pkts[nb_tx], num, false);
1253 ice_xmit_pkts_vec_avx512_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
1257 struct ice_tx_queue *txq = (struct ice_tx_queue *)tx_queue;
1262 num = (uint16_t)RTE_MIN(nb_pkts, txq->tx_rs_thresh);
1263 ret = ice_xmit_fixed_burst_vec_avx512(tx_queue,
1264 &tx_pkts[nb_tx], num, true);