4 * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include <rte_ethdev.h>
36 #include <rte_malloc.h>
38 #include "base/i40e_prototype.h"
39 #include "base/i40e_type.h"
40 #include "i40e_ethdev.h"
41 #include "i40e_rxtx.h"
42 #include "i40e_rxtx_vec_common.h"
44 #include <tmmintrin.h>
46 #ifndef __INTEL_COMPILER
47 #pragma GCC diagnostic ignored "-Wcast-qual"
51 i40e_rxq_rearm(struct i40e_rx_queue *rxq)
55 volatile union i40e_rx_desc *rxdp;
56 struct i40e_rx_entry *rxep = &rxq->sw_ring[rxq->rxrearm_start];
57 struct rte_mbuf *mb0, *mb1;
58 __m128i hdr_room = _mm_set_epi64x(RTE_PKTMBUF_HEADROOM,
59 RTE_PKTMBUF_HEADROOM);
60 __m128i dma_addr0, dma_addr1;
62 rxdp = rxq->rx_ring + rxq->rxrearm_start;
64 /* Pull 'n' more MBUFs into the software ring */
65 if (rte_mempool_get_bulk(rxq->mp,
67 RTE_I40E_RXQ_REARM_THRESH) < 0) {
68 if (rxq->rxrearm_nb + RTE_I40E_RXQ_REARM_THRESH >=
70 dma_addr0 = _mm_setzero_si128();
71 for (i = 0; i < RTE_I40E_DESCS_PER_LOOP; i++) {
72 rxep[i].mbuf = &rxq->fake_mbuf;
73 _mm_store_si128((__m128i *)&rxdp[i].read,
77 rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
78 RTE_I40E_RXQ_REARM_THRESH;
82 /* Initialize the mbufs in vector, process 2 mbufs in one loop */
83 for (i = 0; i < RTE_I40E_RXQ_REARM_THRESH; i += 2, rxep += 2) {
84 __m128i vaddr0, vaddr1;
89 /* load buf_addr(lo 64bit) and buf_physaddr(hi 64bit) */
90 vaddr0 = _mm_loadu_si128((__m128i *)&mb0->buf_addr);
91 vaddr1 = _mm_loadu_si128((__m128i *)&mb1->buf_addr);
93 /* convert pa to dma_addr hdr/data */
94 dma_addr0 = _mm_unpackhi_epi64(vaddr0, vaddr0);
95 dma_addr1 = _mm_unpackhi_epi64(vaddr1, vaddr1);
97 /* add headroom to pa values */
98 dma_addr0 = _mm_add_epi64(dma_addr0, hdr_room);
99 dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
101 /* flush desc with pa dma_addr */
102 _mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
103 _mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
106 rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
107 if (rxq->rxrearm_start >= rxq->nb_rx_desc)
108 rxq->rxrearm_start = 0;
110 rxq->rxrearm_nb -= RTE_I40E_RXQ_REARM_THRESH;
112 rx_id = (uint16_t)((rxq->rxrearm_start == 0) ?
113 (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));
115 /* Update the tail pointer on the NIC */
116 I40E_PCI_REG_WRITE(rxq->qrx_tail, rx_id);
120 desc_to_olflags_v(struct i40e_rx_queue *rxq, __m128i descs[4] __rte_unused,
121 struct rte_mbuf **rx_pkts)
123 const __m128i mbuf_init = _mm_set_epi64x(0, rxq->mbuf_initializer);
124 __m128i rearm0, rearm1, rearm2, rearm3;
126 __m128i vlan0, vlan1, rss, l3_l4e;
128 /* mask everything except RSS, flow director and VLAN flags
129 * bit2 is for VLAN tag, bit11 for flow director indication
130 * bit13:12 for RSS indication.
132 const __m128i rss_vlan_msk = _mm_set_epi32(
133 0x1c03804, 0x1c03804, 0x1c03804, 0x1c03804);
135 const __m128i cksum_mask = _mm_set_epi32(
136 PKT_RX_IP_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD |
137 PKT_RX_L4_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD |
138 PKT_RX_EIP_CKSUM_BAD,
139 PKT_RX_IP_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD |
140 PKT_RX_L4_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD |
141 PKT_RX_EIP_CKSUM_BAD,
142 PKT_RX_IP_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD |
143 PKT_RX_L4_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD |
144 PKT_RX_EIP_CKSUM_BAD,
145 PKT_RX_IP_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD |
146 PKT_RX_L4_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD |
147 PKT_RX_EIP_CKSUM_BAD);
149 /* map rss and vlan type to rss hash and vlan flag */
150 const __m128i vlan_flags = _mm_set_epi8(0, 0, 0, 0,
152 0, 0, 0, PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED,
155 const __m128i rss_flags = _mm_set_epi8(0, 0, 0, 0,
157 PKT_RX_RSS_HASH | PKT_RX_FDIR, PKT_RX_RSS_HASH, 0, 0,
158 0, 0, PKT_RX_FDIR, 0);
160 const __m128i l3_l4e_flags = _mm_set_epi8(0, 0, 0, 0, 0, 0, 0, 0,
161 /* shift right 1 bit to make sure it not exceed 255 */
162 (PKT_RX_EIP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD |
163 PKT_RX_IP_CKSUM_BAD) >> 1,
164 (PKT_RX_IP_CKSUM_GOOD | PKT_RX_EIP_CKSUM_BAD |
165 PKT_RX_L4_CKSUM_BAD) >> 1,
166 (PKT_RX_EIP_CKSUM_BAD | PKT_RX_IP_CKSUM_BAD) >> 1,
167 (PKT_RX_IP_CKSUM_GOOD | PKT_RX_EIP_CKSUM_BAD) >> 1,
168 (PKT_RX_L4_CKSUM_BAD | PKT_RX_IP_CKSUM_BAD) >> 1,
169 (PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD) >> 1,
170 PKT_RX_IP_CKSUM_BAD >> 1,
171 (PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD) >> 1);
173 vlan0 = _mm_unpackhi_epi32(descs[0], descs[1]);
174 vlan1 = _mm_unpackhi_epi32(descs[2], descs[3]);
175 vlan0 = _mm_unpacklo_epi64(vlan0, vlan1);
177 vlan1 = _mm_and_si128(vlan0, rss_vlan_msk);
178 vlan0 = _mm_shuffle_epi8(vlan_flags, vlan1);
180 rss = _mm_srli_epi32(vlan1, 11);
181 rss = _mm_shuffle_epi8(rss_flags, rss);
183 l3_l4e = _mm_srli_epi32(vlan1, 22);
184 l3_l4e = _mm_shuffle_epi8(l3_l4e_flags, l3_l4e);
185 /* then we shift left 1 bit */
186 l3_l4e = _mm_slli_epi32(l3_l4e, 1);
187 /* we need to mask out the reduntant bits */
188 l3_l4e = _mm_and_si128(l3_l4e, cksum_mask);
190 vlan0 = _mm_or_si128(vlan0, rss);
191 vlan0 = _mm_or_si128(vlan0, l3_l4e);
194 * At this point, we have the 4 sets of flags in the low 16-bits
195 * of each 32-bit value in vlan0.
196 * We want to extract these, and merge them with the mbuf init data
197 * so we can do a single 16-byte write to the mbuf to set the flags
198 * and all the other initialization fields. Extracting the
199 * appropriate flags means that we have to do a shift and blend for
200 * each mbuf before we do the write.
202 rearm0 = _mm_blend_epi16(mbuf_init, _mm_slli_si128(vlan0, 8), 0x10);
203 rearm1 = _mm_blend_epi16(mbuf_init, _mm_slli_si128(vlan0, 4), 0x10);
204 rearm2 = _mm_blend_epi16(mbuf_init, vlan0, 0x10);
205 rearm3 = _mm_blend_epi16(mbuf_init, _mm_srli_si128(vlan0, 4), 0x10);
206 _mm_store_si128((__m128i *)&rx_pkts[0]->rearm_data, rearm0);
207 _mm_store_si128((__m128i *)&rx_pkts[1]->rearm_data, rearm1);
208 _mm_store_si128((__m128i *)&rx_pkts[2]->rearm_data, rearm2);
209 _mm_store_si128((__m128i *)&rx_pkts[3]->rearm_data, rearm3);
212 #define PKTLEN_SHIFT 10
215 desc_to_ptype_v(__m128i descs[4], struct rte_mbuf **rx_pkts,
218 __m128i ptype0 = _mm_unpackhi_epi64(descs[0], descs[1]);
219 __m128i ptype1 = _mm_unpackhi_epi64(descs[2], descs[3]);
221 ptype0 = _mm_srli_epi64(ptype0, 30);
222 ptype1 = _mm_srli_epi64(ptype1, 30);
224 rx_pkts[0]->packet_type = ptype_tbl[_mm_extract_epi8(ptype0, 0)];
225 rx_pkts[1]->packet_type = ptype_tbl[_mm_extract_epi8(ptype0, 8)];
226 rx_pkts[2]->packet_type = ptype_tbl[_mm_extract_epi8(ptype1, 0)];
227 rx_pkts[3]->packet_type = ptype_tbl[_mm_extract_epi8(ptype1, 8)];
232 * - nb_pkts < RTE_I40E_DESCS_PER_LOOP, just return no packet
233 * - nb_pkts > RTE_I40E_VPMD_RX_BURST, only scan RTE_I40E_VPMD_RX_BURST
236 static inline uint16_t
237 _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
238 uint16_t nb_pkts, uint8_t *split_packet)
240 volatile union i40e_rx_desc *rxdp;
241 struct i40e_rx_entry *sw_ring;
242 uint16_t nb_pkts_recd;
246 uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
248 __m128i crc_adjust = _mm_set_epi16(
249 0, 0, 0, /* ignore non-length fields */
250 -rxq->crc_len, /* sub crc on data_len */
251 0, /* ignore high-16bits of pkt_len */
252 -rxq->crc_len, /* sub crc on pkt_len */
253 0, 0 /* ignore pkt_type field */
255 __m128i dd_check, eop_check;
257 /* nb_pkts shall be less equal than RTE_I40E_MAX_RX_BURST */
258 nb_pkts = RTE_MIN(nb_pkts, RTE_I40E_MAX_RX_BURST);
260 /* nb_pkts has to be floor-aligned to RTE_I40E_DESCS_PER_LOOP */
261 nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, RTE_I40E_DESCS_PER_LOOP);
263 /* Just the act of getting into the function from the application is
264 * going to cost about 7 cycles
266 rxdp = rxq->rx_ring + rxq->rx_tail;
270 /* See if we need to rearm the RX queue - gives the prefetch a bit
273 if (rxq->rxrearm_nb > RTE_I40E_RXQ_REARM_THRESH)
276 /* Before we start moving massive data around, check to see if
277 * there is actually a packet available
279 if (!(rxdp->wb.qword1.status_error_len &
280 rte_cpu_to_le_32(1 << I40E_RX_DESC_STATUS_DD_SHIFT)))
283 /* 4 packets DD mask */
284 dd_check = _mm_set_epi64x(0x0000000100000001LL, 0x0000000100000001LL);
286 /* 4 packets EOP mask */
287 eop_check = _mm_set_epi64x(0x0000000200000002LL, 0x0000000200000002LL);
289 /* mask to shuffle from desc. to mbuf */
290 shuf_msk = _mm_set_epi8(
291 7, 6, 5, 4, /* octet 4~7, 32bits rss */
292 3, 2, /* octet 2~3, low 16 bits vlan_macip */
293 15, 14, /* octet 15~14, 16 bits data_len */
294 0xFF, 0xFF, /* skip high 16 bits pkt_len, zero out */
295 15, 14, /* octet 15~14, low 16 bits pkt_len */
296 0xFF, 0xFF, /* pkt_type set as unknown */
297 0xFF, 0xFF /*pkt_type set as unknown */
300 /* Cache is empty -> need to scan the buffer rings, but first move
301 * the next 'n' mbufs into the cache
303 sw_ring = &rxq->sw_ring[rxq->rx_tail];
305 /* A. load 4 packet in one loop
306 * [A*. mask out 4 unused dirty field in desc]
307 * B. copy 4 mbuf point from swring to rx_pkts
308 * C. calc the number of DD bits among the 4 packets
309 * [C*. extract the end-of-packet bit, if requested]
310 * D. fill info. from desc to mbuf
313 for (pos = 0, nb_pkts_recd = 0; pos < nb_pkts;
314 pos += RTE_I40E_DESCS_PER_LOOP,
315 rxdp += RTE_I40E_DESCS_PER_LOOP) {
316 __m128i descs[RTE_I40E_DESCS_PER_LOOP];
317 __m128i pkt_mb1, pkt_mb2, pkt_mb3, pkt_mb4;
318 __m128i zero, staterr, sterr_tmp1, sterr_tmp2;
319 __m128i mbp1, mbp2; /* two mbuf pointer in one XMM reg. */
321 /* B.1 load 1 mbuf point */
322 mbp1 = _mm_loadu_si128((__m128i *)&sw_ring[pos]);
323 /* Read desc statuses backwards to avoid race condition */
324 /* A.1 load 4 pkts desc */
325 descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
326 rte_compiler_barrier();
328 /* B.2 copy 2 mbuf point into rx_pkts */
329 _mm_storeu_si128((__m128i *)&rx_pkts[pos], mbp1);
331 /* B.1 load 1 mbuf point */
332 mbp2 = _mm_loadu_si128((__m128i *)&sw_ring[pos+2]);
334 descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
335 rte_compiler_barrier();
336 /* B.1 load 2 mbuf point */
337 descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
338 rte_compiler_barrier();
339 descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
341 /* B.2 copy 2 mbuf point into rx_pkts */
342 _mm_storeu_si128((__m128i *)&rx_pkts[pos+2], mbp2);
345 rte_mbuf_prefetch_part2(rx_pkts[pos]);
346 rte_mbuf_prefetch_part2(rx_pkts[pos + 1]);
347 rte_mbuf_prefetch_part2(rx_pkts[pos + 2]);
348 rte_mbuf_prefetch_part2(rx_pkts[pos + 3]);
351 /* avoid compiler reorder optimization */
352 rte_compiler_barrier();
354 /* pkt 3,4 shift the pktlen field to be 16-bit aligned*/
355 const __m128i len3 = _mm_slli_epi32(descs[3], PKTLEN_SHIFT);
356 const __m128i len2 = _mm_slli_epi32(descs[2], PKTLEN_SHIFT);
358 /* merge the now-aligned packet length fields back in */
359 descs[3] = _mm_blend_epi16(descs[3], len3, 0x80);
360 descs[2] = _mm_blend_epi16(descs[2], len2, 0x80);
362 /* D.1 pkt 3,4 convert format from desc to pktmbuf */
363 pkt_mb4 = _mm_shuffle_epi8(descs[3], shuf_msk);
364 pkt_mb3 = _mm_shuffle_epi8(descs[2], shuf_msk);
366 /* C.1 4=>2 filter staterr info only */
367 sterr_tmp2 = _mm_unpackhi_epi32(descs[3], descs[2]);
368 /* C.1 4=>2 filter staterr info only */
369 sterr_tmp1 = _mm_unpackhi_epi32(descs[1], descs[0]);
371 desc_to_olflags_v(rxq, descs, &rx_pkts[pos]);
373 /* D.2 pkt 3,4 set in_port/nb_seg and remove crc */
374 pkt_mb4 = _mm_add_epi16(pkt_mb4, crc_adjust);
375 pkt_mb3 = _mm_add_epi16(pkt_mb3, crc_adjust);
377 /* pkt 1,2 shift the pktlen field to be 16-bit aligned*/
378 const __m128i len1 = _mm_slli_epi32(descs[1], PKTLEN_SHIFT);
379 const __m128i len0 = _mm_slli_epi32(descs[0], PKTLEN_SHIFT);
381 /* merge the now-aligned packet length fields back in */
382 descs[1] = _mm_blend_epi16(descs[1], len1, 0x80);
383 descs[0] = _mm_blend_epi16(descs[0], len0, 0x80);
385 /* D.1 pkt 1,2 convert format from desc to pktmbuf */
386 pkt_mb2 = _mm_shuffle_epi8(descs[1], shuf_msk);
387 pkt_mb1 = _mm_shuffle_epi8(descs[0], shuf_msk);
389 /* C.2 get 4 pkts staterr value */
390 zero = _mm_xor_si128(dd_check, dd_check);
391 staterr = _mm_unpacklo_epi32(sterr_tmp1, sterr_tmp2);
393 /* D.3 copy final 3,4 data to rx_pkts */
394 _mm_storeu_si128((void *)&rx_pkts[pos+3]->rx_descriptor_fields1,
396 _mm_storeu_si128((void *)&rx_pkts[pos+2]->rx_descriptor_fields1,
399 /* D.2 pkt 1,2 set in_port/nb_seg and remove crc */
400 pkt_mb2 = _mm_add_epi16(pkt_mb2, crc_adjust);
401 pkt_mb1 = _mm_add_epi16(pkt_mb1, crc_adjust);
403 /* C* extract and record EOP bit */
405 __m128i eop_shuf_mask = _mm_set_epi8(
406 0xFF, 0xFF, 0xFF, 0xFF,
407 0xFF, 0xFF, 0xFF, 0xFF,
408 0xFF, 0xFF, 0xFF, 0xFF,
409 0x04, 0x0C, 0x00, 0x08
412 /* and with mask to extract bits, flipping 1-0 */
413 __m128i eop_bits = _mm_andnot_si128(staterr, eop_check);
414 /* the staterr values are not in order, as the count
415 * count of dd bits doesn't care. However, for end of
416 * packet tracking, we do care, so shuffle. This also
417 * compresses the 32-bit values to 8-bit
419 eop_bits = _mm_shuffle_epi8(eop_bits, eop_shuf_mask);
420 /* store the resulting 32-bit value */
421 *(int *)split_packet = _mm_cvtsi128_si32(eop_bits);
422 split_packet += RTE_I40E_DESCS_PER_LOOP;
425 /* C.3 calc available number of desc */
426 staterr = _mm_and_si128(staterr, dd_check);
427 staterr = _mm_packs_epi32(staterr, zero);
429 /* D.3 copy final 1,2 data to rx_pkts */
430 _mm_storeu_si128((void *)&rx_pkts[pos+1]->rx_descriptor_fields1,
432 _mm_storeu_si128((void *)&rx_pkts[pos]->rx_descriptor_fields1,
434 desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
435 /* C.4 calc avaialbe number of desc */
436 var = __builtin_popcountll(_mm_cvtsi128_si64(staterr));
438 if (likely(var != RTE_I40E_DESCS_PER_LOOP))
442 /* Update our internal tail pointer */
443 rxq->rx_tail = (uint16_t)(rxq->rx_tail + nb_pkts_recd);
444 rxq->rx_tail = (uint16_t)(rxq->rx_tail & (rxq->nb_rx_desc - 1));
445 rxq->rxrearm_nb = (uint16_t)(rxq->rxrearm_nb + nb_pkts_recd);
452 * - nb_pkts < RTE_I40E_DESCS_PER_LOOP, just return no packet
453 * - nb_pkts > RTE_I40E_VPMD_RX_BURST, only scan RTE_I40E_VPMD_RX_BURST
457 i40e_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
460 return _recv_raw_pkts_vec(rx_queue, rx_pkts, nb_pkts, NULL);
463 /* vPMD receive routine that reassembles scattered packets
465 * - nb_pkts < RTE_I40E_DESCS_PER_LOOP, just return no packet
466 * - nb_pkts > RTE_I40E_VPMD_RX_BURST, only scan RTE_I40E_VPMD_RX_BURST
470 i40e_recv_scattered_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
474 struct i40e_rx_queue *rxq = rx_queue;
475 uint8_t split_flags[RTE_I40E_VPMD_RX_BURST] = {0};
477 /* get some new buffers */
478 uint16_t nb_bufs = _recv_raw_pkts_vec(rxq, rx_pkts, nb_pkts,
483 /* happy day case, full burst + no packets to be joined */
484 const uint64_t *split_fl64 = (uint64_t *)split_flags;
486 if (rxq->pkt_first_seg == NULL &&
487 split_fl64[0] == 0 && split_fl64[1] == 0 &&
488 split_fl64[2] == 0 && split_fl64[3] == 0)
491 /* reassemble any packets that need reassembly*/
494 if (rxq->pkt_first_seg == NULL) {
495 /* find the first split flag, and only reassemble then*/
496 while (i < nb_bufs && !split_flags[i])
501 return i + reassemble_packets(rxq, &rx_pkts[i], nb_bufs - i,
506 vtx1(volatile struct i40e_tx_desc *txdp,
507 struct rte_mbuf *pkt, uint64_t flags)
509 uint64_t high_qw = (I40E_TX_DESC_DTYPE_DATA |
510 ((uint64_t)flags << I40E_TXD_QW1_CMD_SHIFT) |
511 ((uint64_t)pkt->data_len << I40E_TXD_QW1_TX_BUF_SZ_SHIFT));
513 __m128i descriptor = _mm_set_epi64x(high_qw,
514 pkt->buf_physaddr + pkt->data_off);
515 _mm_store_si128((__m128i *)txdp, descriptor);
519 vtx(volatile struct i40e_tx_desc *txdp,
520 struct rte_mbuf **pkt, uint16_t nb_pkts, uint64_t flags)
524 for (i = 0; i < nb_pkts; ++i, ++txdp, ++pkt)
525 vtx1(txdp, *pkt, flags);
529 i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
532 struct i40e_tx_queue *txq = (struct i40e_tx_queue *)tx_queue;
533 volatile struct i40e_tx_desc *txdp;
534 struct i40e_tx_entry *txep;
535 uint16_t n, nb_commit, tx_id;
536 uint64_t flags = I40E_TD_CMD;
537 uint64_t rs = I40E_TX_DESC_CMD_RS | I40E_TD_CMD;
540 /* cross rx_thresh boundary is not allowed */
541 nb_pkts = RTE_MIN(nb_pkts, txq->tx_rs_thresh);
543 if (txq->nb_tx_free < txq->tx_free_thresh)
544 i40e_tx_free_bufs(txq);
546 nb_commit = nb_pkts = (uint16_t)RTE_MIN(txq->nb_tx_free, nb_pkts);
547 if (unlikely(nb_pkts == 0))
550 tx_id = txq->tx_tail;
551 txdp = &txq->tx_ring[tx_id];
552 txep = &txq->sw_ring[tx_id];
554 txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
556 n = (uint16_t)(txq->nb_tx_desc - tx_id);
557 if (nb_commit >= n) {
558 tx_backlog_entry(txep, tx_pkts, n);
560 for (i = 0; i < n - 1; ++i, ++tx_pkts, ++txdp)
561 vtx1(txdp, *tx_pkts, flags);
563 vtx1(txdp, *tx_pkts++, rs);
565 nb_commit = (uint16_t)(nb_commit - n);
568 txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
570 /* avoid reach the end of ring */
571 txdp = &txq->tx_ring[tx_id];
572 txep = &txq->sw_ring[tx_id];
575 tx_backlog_entry(txep, tx_pkts, nb_commit);
577 vtx(txdp, tx_pkts, nb_commit, flags);
579 tx_id = (uint16_t)(tx_id + nb_commit);
580 if (tx_id > txq->tx_next_rs) {
581 txq->tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
582 rte_cpu_to_le_64(((uint64_t)I40E_TX_DESC_CMD_RS) <<
583 I40E_TXD_QW1_CMD_SHIFT);
585 (uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh);
588 txq->tx_tail = tx_id;
590 I40E_PCI_REG_WRITE(txq->qtx_tail, txq->tx_tail);
595 void __attribute__((cold))
596 i40e_rx_queue_release_mbufs_vec(struct i40e_rx_queue *rxq)
598 _i40e_rx_queue_release_mbufs_vec(rxq);
601 int __attribute__((cold))
602 i40e_rxq_vec_setup(struct i40e_rx_queue *rxq)
604 return i40e_rxq_vec_setup_default(rxq);
607 int __attribute__((cold))
608 i40e_txq_vec_setup(struct i40e_tx_queue __rte_unused *txq)
613 int __attribute__((cold))
614 i40e_rx_vec_dev_conf_condition_check(struct rte_eth_dev *dev)
616 #ifndef RTE_LIBRTE_IEEE1588
617 /* need SSE4.1 support */
618 if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_1))
622 return i40e_rx_vec_dev_conf_condition_check_default(dev);