net/bnxt: fix FW version query
[dpdk.git] / drivers / net / i40e / i40e_rxtx_vec_neon.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2015 Intel Corporation.
3  * Copyright(c) 2016-2018, Linaro Limited.
4  */
5
6 #include <stdint.h>
7 #include <rte_ethdev_driver.h>
8 #include <rte_malloc.h>
9
10 #include "base/i40e_prototype.h"
11 #include "base/i40e_type.h"
12 #include "i40e_ethdev.h"
13 #include "i40e_rxtx.h"
14 #include "i40e_rxtx_vec_common.h"
15
16 #include <arm_neon.h>
17
18 #pragma GCC diagnostic ignored "-Wcast-qual"
19
20 static inline void
21 i40e_rxq_rearm(struct i40e_rx_queue *rxq)
22 {
23         int i;
24         uint16_t rx_id;
25         volatile union i40e_rx_desc *rxdp;
26         struct i40e_rx_entry *rxep = &rxq->sw_ring[rxq->rxrearm_start];
27         struct rte_mbuf *mb0, *mb1;
28         uint64x2_t dma_addr0, dma_addr1;
29         uint64x2_t zero = vdupq_n_u64(0);
30         uint64_t paddr;
31
32         rxdp = rxq->rx_ring + rxq->rxrearm_start;
33
34         /* Pull 'n' more MBUFs into the software ring */
35         if (unlikely(rte_mempool_get_bulk(rxq->mp,
36                                           (void *)rxep,
37                                           RTE_I40E_RXQ_REARM_THRESH) < 0)) {
38                 if (rxq->rxrearm_nb + RTE_I40E_RXQ_REARM_THRESH >=
39                     rxq->nb_rx_desc) {
40                         for (i = 0; i < RTE_I40E_DESCS_PER_LOOP; i++) {
41                                 rxep[i].mbuf = &rxq->fake_mbuf;
42                                 vst1q_u64((uint64_t *)&rxdp[i].read, zero);
43                         }
44                 }
45                 rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
46                         RTE_I40E_RXQ_REARM_THRESH;
47                 return;
48         }
49
50         /* Initialize the mbufs in vector, process 2 mbufs in one loop */
51         for (i = 0; i < RTE_I40E_RXQ_REARM_THRESH; i += 2, rxep += 2) {
52                 mb0 = rxep[0].mbuf;
53                 mb1 = rxep[1].mbuf;
54
55                 paddr = mb0->buf_iova + RTE_PKTMBUF_HEADROOM;
56                 dma_addr0 = vdupq_n_u64(paddr);
57
58                 /* flush desc with pa dma_addr */
59                 vst1q_u64((uint64_t *)&rxdp++->read, dma_addr0);
60
61                 paddr = mb1->buf_iova + RTE_PKTMBUF_HEADROOM;
62                 dma_addr1 = vdupq_n_u64(paddr);
63                 vst1q_u64((uint64_t *)&rxdp++->read, dma_addr1);
64         }
65
66         rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
67         if (rxq->rxrearm_start >= rxq->nb_rx_desc)
68                 rxq->rxrearm_start = 0;
69
70         rxq->rxrearm_nb -= RTE_I40E_RXQ_REARM_THRESH;
71
72         rx_id = (uint16_t)((rxq->rxrearm_start == 0) ?
73                              (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));
74
75         rte_cio_wmb();
76         /* Update the tail pointer on the NIC */
77         I40E_PCI_REG_WRITE_RELAXED(rxq->qrx_tail, rx_id);
78 }
79
80 static inline void
81 desc_to_olflags_v(struct i40e_rx_queue *rxq, uint64x2_t descs[4],
82                   struct rte_mbuf **rx_pkts)
83 {
84         uint32x4_t vlan0, vlan1, rss, l3_l4e;
85         const uint64x2_t mbuf_init = {rxq->mbuf_initializer, 0};
86         uint64x2_t rearm0, rearm1, rearm2, rearm3;
87
88         /* mask everything except RSS, flow director and VLAN flags
89          * bit2 is for VLAN tag, bit11 for flow director indication
90          * bit13:12 for RSS indication.
91          */
92         const uint32x4_t rss_vlan_msk = {
93                         0x1c03804, 0x1c03804, 0x1c03804, 0x1c03804};
94
95         const uint32x4_t cksum_mask = {
96                         PKT_RX_IP_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD |
97                         PKT_RX_L4_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD |
98                         PKT_RX_EIP_CKSUM_BAD,
99                         PKT_RX_IP_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD |
100                         PKT_RX_L4_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD |
101                         PKT_RX_EIP_CKSUM_BAD,
102                         PKT_RX_IP_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD |
103                         PKT_RX_L4_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD |
104                         PKT_RX_EIP_CKSUM_BAD,
105                         PKT_RX_IP_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD |
106                         PKT_RX_L4_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD |
107                         PKT_RX_EIP_CKSUM_BAD};
108
109         /* map rss and vlan type to rss hash and vlan flag */
110         const uint8x16_t vlan_flags = {
111                         0, 0, 0, 0,
112                         PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED, 0, 0, 0,
113                         0, 0, 0, 0,
114                         0, 0, 0, 0};
115
116         const uint8x16_t rss_flags = {
117                         0, PKT_RX_FDIR, 0, 0,
118                         0, 0, PKT_RX_RSS_HASH, PKT_RX_RSS_HASH | PKT_RX_FDIR,
119                         0, 0, 0, 0,
120                         0, 0, 0, 0};
121
122         const uint8x16_t l3_l4e_flags = {
123                         (PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD) >> 1,
124                         PKT_RX_IP_CKSUM_BAD >> 1,
125                         (PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD) >> 1,
126                         (PKT_RX_L4_CKSUM_BAD | PKT_RX_IP_CKSUM_BAD) >> 1,
127                         (PKT_RX_IP_CKSUM_GOOD | PKT_RX_EIP_CKSUM_BAD) >> 1,
128                         (PKT_RX_EIP_CKSUM_BAD | PKT_RX_IP_CKSUM_BAD) >> 1,
129                         (PKT_RX_IP_CKSUM_GOOD | PKT_RX_EIP_CKSUM_BAD |
130                          PKT_RX_L4_CKSUM_BAD) >> 1,
131                         (PKT_RX_EIP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD |
132                          PKT_RX_IP_CKSUM_BAD) >> 1,
133                         0, 0, 0, 0, 0, 0, 0, 0};
134
135         vlan0 = vzipq_u32(vreinterpretq_u32_u64(descs[0]),
136                           vreinterpretq_u32_u64(descs[2])).val[1];
137         vlan1 = vzipq_u32(vreinterpretq_u32_u64(descs[1]),
138                           vreinterpretq_u32_u64(descs[3])).val[1];
139         vlan0 = vzipq_u32(vlan0, vlan1).val[0];
140
141         vlan1 = vandq_u32(vlan0, rss_vlan_msk);
142         vlan0 = vreinterpretq_u32_u8(vqtbl1q_u8(vlan_flags,
143                                                 vreinterpretq_u8_u32(vlan1)));
144
145         rss = vshrq_n_u32(vlan1, 11);
146         rss = vreinterpretq_u32_u8(vqtbl1q_u8(rss_flags,
147                                               vreinterpretq_u8_u32(rss)));
148
149         l3_l4e = vshrq_n_u32(vlan1, 22);
150         l3_l4e = vreinterpretq_u32_u8(vqtbl1q_u8(l3_l4e_flags,
151                                               vreinterpretq_u8_u32(l3_l4e)));
152         /* then we shift left 1 bit */
153         l3_l4e = vshlq_n_u32(l3_l4e, 1);
154         /* we need to mask out the reduntant bits */
155         l3_l4e = vandq_u32(l3_l4e, cksum_mask);
156
157         vlan0 = vorrq_u32(vlan0, rss);
158         vlan0 = vorrq_u32(vlan0, l3_l4e);
159
160         rearm0 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 0), mbuf_init, 1);
161         rearm1 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 1), mbuf_init, 1);
162         rearm2 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 2), mbuf_init, 1);
163         rearm3 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 3), mbuf_init, 1);
164
165         vst1q_u64((uint64_t *)&rx_pkts[0]->rearm_data, rearm0);
166         vst1q_u64((uint64_t *)&rx_pkts[1]->rearm_data, rearm1);
167         vst1q_u64((uint64_t *)&rx_pkts[2]->rearm_data, rearm2);
168         vst1q_u64((uint64_t *)&rx_pkts[3]->rearm_data, rearm3);
169 }
170
171 #define PKTLEN_SHIFT     10
172 #define I40E_UINT16_BIT (CHAR_BIT * sizeof(uint16_t))
173
174 static inline void
175 desc_to_ptype_v(uint64x2_t descs[4], struct rte_mbuf **__restrict rx_pkts,
176                 uint32_t *__restrict ptype_tbl)
177 {
178         int i;
179         uint8_t ptype;
180         uint8x16_t tmp;
181
182         for (i = 0; i < 4; i++) {
183                 tmp = vreinterpretq_u8_u64(vshrq_n_u64(descs[i], 30));
184                 ptype = vgetq_lane_u8(tmp, 8);
185                 rx_pkts[i]->packet_type = ptype_tbl[ptype];
186         }
187
188 }
189
190  /*
191  * Notice:
192  * - nb_pkts < RTE_I40E_DESCS_PER_LOOP, just return no packet
193  * - nb_pkts > RTE_I40E_VPMD_RX_BURST, only scan RTE_I40E_VPMD_RX_BURST
194  *   numbers of DD bits
195  */
196 static inline uint16_t
197 _recv_raw_pkts_vec(struct i40e_rx_queue *__restrict rxq, struct rte_mbuf
198         **__restrict rx_pkts, uint16_t nb_pkts, uint8_t *split_packet)
199 {
200         volatile union i40e_rx_desc *rxdp;
201         struct i40e_rx_entry *sw_ring;
202         uint16_t nb_pkts_recd;
203         int pos;
204         uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
205
206         /* mask to shuffle from desc. to mbuf */
207         uint8x16_t shuf_msk = {
208                 0xFF, 0xFF,   /* pkt_type set as unknown */
209                 0xFF, 0xFF,   /* pkt_type set as unknown */
210                 14, 15,       /* octet 15~14, low 16 bits pkt_len */
211                 0xFF, 0xFF,   /* skip high 16 bits pkt_len, zero out */
212                 14, 15,       /* octet 15~14, 16 bits data_len */
213                 2, 3,         /* octet 2~3, low 16 bits vlan_macip */
214                 4, 5, 6, 7    /* octet 4~7, 32bits rss */
215                 };
216
217         uint8x16_t eop_check = {
218                 0x02, 0x00, 0x02, 0x00,
219                 0x02, 0x00, 0x02, 0x00,
220                 0x00, 0x00, 0x00, 0x00,
221                 0x00, 0x00, 0x00, 0x00
222                 };
223
224         uint16x8_t crc_adjust = {
225                 0, 0,         /* ignore pkt_type field */
226                 rxq->crc_len, /* sub crc on pkt_len */
227                 0,            /* ignore high-16bits of pkt_len */
228                 rxq->crc_len, /* sub crc on data_len */
229                 0, 0, 0       /* ignore non-length fields */
230                 };
231
232         /* nb_pkts shall be less equal than RTE_I40E_MAX_RX_BURST */
233         nb_pkts = RTE_MIN(nb_pkts, RTE_I40E_MAX_RX_BURST);
234
235         /* nb_pkts has to be floor-aligned to RTE_I40E_DESCS_PER_LOOP */
236         nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, RTE_I40E_DESCS_PER_LOOP);
237
238         /* Just the act of getting into the function from the application is
239          * going to cost about 7 cycles
240          */
241         rxdp = rxq->rx_ring + rxq->rx_tail;
242
243         rte_prefetch_non_temporal(rxdp);
244
245         /* See if we need to rearm the RX queue - gives the prefetch a bit
246          * of time to act
247          */
248         if (rxq->rxrearm_nb > RTE_I40E_RXQ_REARM_THRESH)
249                 i40e_rxq_rearm(rxq);
250
251         /* Before we start moving massive data around, check to see if
252          * there is actually a packet available
253          */
254         if (!(rxdp->wb.qword1.status_error_len &
255                         rte_cpu_to_le_32(1 << I40E_RX_DESC_STATUS_DD_SHIFT)))
256                 return 0;
257
258         /* Cache is empty -> need to scan the buffer rings, but first move
259          * the next 'n' mbufs into the cache
260          */
261         sw_ring = &rxq->sw_ring[rxq->rx_tail];
262
263         /* A. load 4 packet in one loop
264          * [A*. mask out 4 unused dirty field in desc]
265          * B. copy 4 mbuf point from swring to rx_pkts
266          * C. calc the number of DD bits among the 4 packets
267          * [C*. extract the end-of-packet bit, if requested]
268          * D. fill info. from desc to mbuf
269          */
270
271         for (pos = 0, nb_pkts_recd = 0; pos < nb_pkts;
272                         pos += RTE_I40E_DESCS_PER_LOOP,
273                         rxdp += RTE_I40E_DESCS_PER_LOOP) {
274                 uint64x2_t descs[RTE_I40E_DESCS_PER_LOOP];
275                 uint8x16_t pkt_mb1, pkt_mb2, pkt_mb3, pkt_mb4;
276                 uint16x8x2_t sterr_tmp1, sterr_tmp2;
277                 uint64x2_t mbp1, mbp2;
278                 uint16x8_t staterr;
279                 uint16x8_t tmp;
280                 uint64_t stat;
281
282                 int32x4_t len_shl = {0, 0, 0, PKTLEN_SHIFT};
283
284                 /* B.1 load 1 mbuf point */
285                 mbp1 = vld1q_u64((uint64_t *)&sw_ring[pos]);
286                 /* Read desc statuses backwards to avoid race condition */
287                 /* A.1 load 4 pkts desc */
288                 descs[3] =  vld1q_u64((uint64_t *)(rxdp + 3));
289
290                 /* B.2 copy 2 mbuf point into rx_pkts  */
291                 vst1q_u64((uint64_t *)&rx_pkts[pos], mbp1);
292
293                 /* B.1 load 1 mbuf point */
294                 mbp2 = vld1q_u64((uint64_t *)&sw_ring[pos + 2]);
295
296                 descs[2] =  vld1q_u64((uint64_t *)(rxdp + 2));
297                 /* B.1 load 2 mbuf point */
298                 descs[1] =  vld1q_u64((uint64_t *)(rxdp + 1));
299                 descs[0] =  vld1q_u64((uint64_t *)(rxdp));
300
301                 /* B.2 copy 2 mbuf point into rx_pkts  */
302                 vst1q_u64((uint64_t *)&rx_pkts[pos + 2], mbp2);
303
304                 if (split_packet) {
305                         rte_mbuf_prefetch_part2(rx_pkts[pos]);
306                         rte_mbuf_prefetch_part2(rx_pkts[pos + 1]);
307                         rte_mbuf_prefetch_part2(rx_pkts[pos + 2]);
308                         rte_mbuf_prefetch_part2(rx_pkts[pos + 3]);
309                 }
310
311                 /* pkt 3,4 shift the pktlen field to be 16-bit aligned*/
312                 uint32x4_t len3 = vshlq_u32(vreinterpretq_u32_u64(descs[3]),
313                                             len_shl);
314                 descs[3] = vreinterpretq_u64_u32(len3);
315                 uint32x4_t len2 = vshlq_u32(vreinterpretq_u32_u64(descs[2]),
316                                             len_shl);
317                 descs[2] = vreinterpretq_u64_u32(len2);
318
319                 /* D.1 pkt 3,4 convert format from desc to pktmbuf */
320                 pkt_mb4 = vqtbl1q_u8(vreinterpretq_u8_u64(descs[3]), shuf_msk);
321                 pkt_mb3 = vqtbl1q_u8(vreinterpretq_u8_u64(descs[2]), shuf_msk);
322
323                 /* C.1 4=>2 filter staterr info only */
324                 sterr_tmp2 = vzipq_u16(vreinterpretq_u16_u64(descs[1]),
325                                        vreinterpretq_u16_u64(descs[3]));
326                 /* C.1 4=>2 filter staterr info only */
327                 sterr_tmp1 = vzipq_u16(vreinterpretq_u16_u64(descs[0]),
328                                        vreinterpretq_u16_u64(descs[2]));
329
330                 /* C.2 get 4 pkts staterr value  */
331                 staterr = vzipq_u16(sterr_tmp1.val[1],
332                                     sterr_tmp2.val[1]).val[0];
333
334                 desc_to_olflags_v(rxq, descs, &rx_pkts[pos]);
335
336                 /* D.2 pkt 3,4 set in_port/nb_seg and remove crc */
337                 tmp = vsubq_u16(vreinterpretq_u16_u8(pkt_mb4), crc_adjust);
338                 pkt_mb4 = vreinterpretq_u8_u16(tmp);
339                 tmp = vsubq_u16(vreinterpretq_u16_u8(pkt_mb3), crc_adjust);
340                 pkt_mb3 = vreinterpretq_u8_u16(tmp);
341
342                 /* pkt 1,2 shift the pktlen field to be 16-bit aligned*/
343                 uint32x4_t len1 = vshlq_u32(vreinterpretq_u32_u64(descs[1]),
344                                             len_shl);
345                 descs[1] = vreinterpretq_u64_u32(len1);
346                 uint32x4_t len0 = vshlq_u32(vreinterpretq_u32_u64(descs[0]),
347                                             len_shl);
348                 descs[0] = vreinterpretq_u64_u32(len0);
349
350                 /* D.1 pkt 1,2 convert format from desc to pktmbuf */
351                 pkt_mb2 = vqtbl1q_u8(vreinterpretq_u8_u64(descs[1]), shuf_msk);
352                 pkt_mb1 = vqtbl1q_u8(vreinterpretq_u8_u64(descs[0]), shuf_msk);
353
354                 /* D.3 copy final 3,4 data to rx_pkts */
355                 vst1q_u8((void *)&rx_pkts[pos + 3]->rx_descriptor_fields1,
356                                  pkt_mb4);
357                 vst1q_u8((void *)&rx_pkts[pos + 2]->rx_descriptor_fields1,
358                                  pkt_mb3);
359
360                 /* D.2 pkt 1,2 set in_port/nb_seg and remove crc */
361                 tmp = vsubq_u16(vreinterpretq_u16_u8(pkt_mb2), crc_adjust);
362                 pkt_mb2 = vreinterpretq_u8_u16(tmp);
363                 tmp = vsubq_u16(vreinterpretq_u16_u8(pkt_mb1), crc_adjust);
364                 pkt_mb1 = vreinterpretq_u8_u16(tmp);
365
366                 /* C* extract and record EOP bit */
367                 if (split_packet) {
368                         uint8x16_t eop_shuf_mask = {
369                                         0x00, 0x02, 0x04, 0x06,
370                                         0xFF, 0xFF, 0xFF, 0xFF,
371                                         0xFF, 0xFF, 0xFF, 0xFF,
372                                         0xFF, 0xFF, 0xFF, 0xFF};
373                         uint8x16_t eop_bits;
374
375                         /* and with mask to extract bits, flipping 1-0 */
376                         eop_bits = vmvnq_u8(vreinterpretq_u8_u16(staterr));
377                         eop_bits = vandq_u8(eop_bits, eop_check);
378                         /* the staterr values are not in order, as the count
379                          * count of dd bits doesn't care. However, for end of
380                          * packet tracking, we do care, so shuffle. This also
381                          * compresses the 32-bit values to 8-bit
382                          */
383                         eop_bits = vqtbl1q_u8(eop_bits, eop_shuf_mask);
384
385                         /* store the resulting 32-bit value */
386                         vst1q_lane_u32((uint32_t *)split_packet,
387                                        vreinterpretq_u32_u8(eop_bits), 0);
388                         split_packet += RTE_I40E_DESCS_PER_LOOP;
389
390                         /* zero-out next pointers */
391                         rx_pkts[pos]->next = NULL;
392                         rx_pkts[pos + 1]->next = NULL;
393                         rx_pkts[pos + 2]->next = NULL;
394                         rx_pkts[pos + 3]->next = NULL;
395                 }
396
397                 staterr = vshlq_n_u16(staterr, I40E_UINT16_BIT - 1);
398                 staterr = vreinterpretq_u16_s16(
399                                 vshrq_n_s16(vreinterpretq_s16_u16(staterr),
400                                             I40E_UINT16_BIT - 1));
401                 stat = ~vgetq_lane_u64(vreinterpretq_u64_u16(staterr), 0);
402
403                 rte_prefetch_non_temporal(rxdp + RTE_I40E_DESCS_PER_LOOP);
404
405                 /* D.3 copy final 1,2 data to rx_pkts */
406                 vst1q_u8((void *)&rx_pkts[pos + 1]->rx_descriptor_fields1,
407                          pkt_mb2);
408                 vst1q_u8((void *)&rx_pkts[pos]->rx_descriptor_fields1,
409                          pkt_mb1);
410                 desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
411                 /* C.4 calc avaialbe number of desc */
412                 if (unlikely(stat == 0)) {
413                         nb_pkts_recd += RTE_I40E_DESCS_PER_LOOP;
414                 } else {
415                         nb_pkts_recd += __builtin_ctzl(stat) / I40E_UINT16_BIT;
416                         break;
417                 }
418         }
419
420         /* Update our internal tail pointer */
421         rxq->rx_tail = (uint16_t)(rxq->rx_tail + nb_pkts_recd);
422         rxq->rx_tail = (uint16_t)(rxq->rx_tail & (rxq->nb_rx_desc - 1));
423         rxq->rxrearm_nb = (uint16_t)(rxq->rxrearm_nb + nb_pkts_recd);
424
425         return nb_pkts_recd;
426 }
427
428  /*
429  * Notice:
430  * - nb_pkts < RTE_I40E_DESCS_PER_LOOP, just return no packet
431  * - nb_pkts > RTE_I40E_VPMD_RX_BURST, only scan RTE_I40E_VPMD_RX_BURST
432  *   numbers of DD bits
433  */
434 uint16_t
435 i40e_recv_pkts_vec(void *__restrict rx_queue,
436                 struct rte_mbuf **__restrict rx_pkts, uint16_t nb_pkts)
437 {
438         return _recv_raw_pkts_vec(rx_queue, rx_pkts, nb_pkts, NULL);
439 }
440
441  /* vPMD receive routine that reassembles scattered packets
442  * Notice:
443  * - nb_pkts < RTE_I40E_DESCS_PER_LOOP, just return no packet
444  * - nb_pkts > RTE_I40E_VPMD_RX_BURST, only scan RTE_I40E_VPMD_RX_BURST
445  *   numbers of DD bits
446  */
447 uint16_t
448 i40e_recv_scattered_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
449                              uint16_t nb_pkts)
450 {
451
452         struct i40e_rx_queue *rxq = rx_queue;
453         uint8_t split_flags[RTE_I40E_VPMD_RX_BURST] = {0};
454
455         /* get some new buffers */
456         uint16_t nb_bufs = _recv_raw_pkts_vec(rxq, rx_pkts, nb_pkts,
457                         split_flags);
458         if (nb_bufs == 0)
459                 return 0;
460
461         /* happy day case, full burst + no packets to be joined */
462         const uint64_t *split_fl64 = (uint64_t *)split_flags;
463
464         if (rxq->pkt_first_seg == NULL &&
465                         split_fl64[0] == 0 && split_fl64[1] == 0 &&
466                         split_fl64[2] == 0 && split_fl64[3] == 0)
467                 return nb_bufs;
468
469         /* reassemble any packets that need reassembly*/
470         unsigned i = 0;
471
472         if (rxq->pkt_first_seg == NULL) {
473                 /* find the first split flag, and only reassemble then*/
474                 while (i < nb_bufs && !split_flags[i])
475                         i++;
476                 if (i == nb_bufs)
477                         return nb_bufs;
478                 rxq->pkt_first_seg = rx_pkts[i];
479         }
480         return i + reassemble_packets(rxq, &rx_pkts[i], nb_bufs - i,
481                 &split_flags[i]);
482 }
483
484 static inline void
485 vtx1(volatile struct i40e_tx_desc *txdp,
486                 struct rte_mbuf *pkt, uint64_t flags)
487 {
488         uint64_t high_qw = (I40E_TX_DESC_DTYPE_DATA |
489                         ((uint64_t)flags  << I40E_TXD_QW1_CMD_SHIFT) |
490                         ((uint64_t)pkt->data_len << I40E_TXD_QW1_TX_BUF_SZ_SHIFT));
491
492         uint64x2_t descriptor = {pkt->buf_iova + pkt->data_off, high_qw};
493         vst1q_u64((uint64_t *)txdp, descriptor);
494 }
495
496 static inline void
497 vtx(volatile struct i40e_tx_desc *txdp, struct rte_mbuf **pkt,
498                 uint16_t nb_pkts,  uint64_t flags)
499 {
500         int i;
501
502         for (i = 0; i < nb_pkts; ++i, ++txdp, ++pkt)
503                 vtx1(txdp, *pkt, flags);
504 }
505
506 uint16_t
507 i40e_xmit_fixed_burst_vec(void *__restrict tx_queue,
508         struct rte_mbuf **__restrict tx_pkts, uint16_t nb_pkts)
509 {
510         struct i40e_tx_queue *txq = (struct i40e_tx_queue *)tx_queue;
511         volatile struct i40e_tx_desc *txdp;
512         struct i40e_tx_entry *txep;
513         uint16_t n, nb_commit, tx_id;
514         uint64_t flags = I40E_TD_CMD;
515         uint64_t rs = I40E_TX_DESC_CMD_RS | I40E_TD_CMD;
516         int i;
517
518         /* cross rx_thresh boundary is not allowed */
519         nb_pkts = RTE_MIN(nb_pkts, txq->tx_rs_thresh);
520
521         if (txq->nb_tx_free < txq->tx_free_thresh)
522                 i40e_tx_free_bufs(txq);
523
524         nb_commit = nb_pkts = (uint16_t)RTE_MIN(txq->nb_tx_free, nb_pkts);
525         if (unlikely(nb_pkts == 0))
526                 return 0;
527
528         tx_id = txq->tx_tail;
529         txdp = &txq->tx_ring[tx_id];
530         txep = &txq->sw_ring[tx_id];
531
532         txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
533
534         n = (uint16_t)(txq->nb_tx_desc - tx_id);
535         if (nb_commit >= n) {
536                 tx_backlog_entry(txep, tx_pkts, n);
537
538                 for (i = 0; i < n - 1; ++i, ++tx_pkts, ++txdp)
539                         vtx1(txdp, *tx_pkts, flags);
540
541                 vtx1(txdp, *tx_pkts++, rs);
542
543                 nb_commit = (uint16_t)(nb_commit - n);
544
545                 tx_id = 0;
546                 txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
547
548                 /* avoid reach the end of ring */
549                 txdp = &txq->tx_ring[tx_id];
550                 txep = &txq->sw_ring[tx_id];
551         }
552
553         tx_backlog_entry(txep, tx_pkts, nb_commit);
554
555         vtx(txdp, tx_pkts, nb_commit, flags);
556
557         tx_id = (uint16_t)(tx_id + nb_commit);
558         if (tx_id > txq->tx_next_rs) {
559                 txq->tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
560                         rte_cpu_to_le_64(((uint64_t)I40E_TX_DESC_CMD_RS) <<
561                                                 I40E_TXD_QW1_CMD_SHIFT);
562                 txq->tx_next_rs =
563                         (uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh);
564         }
565
566         txq->tx_tail = tx_id;
567
568         rte_cio_wmb();
569         I40E_PCI_REG_WRITE_RELAXED(txq->qtx_tail, tx_id);
570
571         return nb_pkts;
572 }
573
574 void __rte_cold
575 i40e_rx_queue_release_mbufs_vec(struct i40e_rx_queue *rxq)
576 {
577         _i40e_rx_queue_release_mbufs_vec(rxq);
578 }
579
580 int __rte_cold
581 i40e_rxq_vec_setup(struct i40e_rx_queue *rxq)
582 {
583         return i40e_rxq_vec_setup_default(rxq);
584 }
585
586 int __rte_cold
587 i40e_txq_vec_setup(struct i40e_tx_queue __rte_unused *txq)
588 {
589         return 0;
590 }
591
592 int __rte_cold
593 i40e_rx_vec_dev_conf_condition_check(struct rte_eth_dev *dev)
594 {
595         return i40e_rx_vec_dev_conf_condition_check_default(dev);
596 }