4 * Copyright 2015 6WIND S.A.
5 * Copyright 2015 Mellanox.
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 6WIND S.A. 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.
40 /* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
42 #pragma GCC diagnostic ignored "-pedantic"
44 #include <infiniband/verbs.h>
46 #pragma GCC diagnostic error "-pedantic"
49 /* DPDK headers don't like -pedantic. */
51 #pragma GCC diagnostic ignored "-pedantic"
54 #include <rte_mempool.h>
55 #include <rte_prefetch.h>
56 #include <rte_common.h>
57 #include <rte_branch_prediction.h>
58 #include <rte_memory.h>
60 #pragma GCC diagnostic error "-pedantic"
64 #include "mlx5_utils.h"
65 #include "mlx5_rxtx.h"
66 #include "mlx5_autoconf.h"
67 #include "mlx5_defs.h"
70 * Manage TX completions.
72 * When sending a burst, mlx5_tx_burst() posts several WRs.
73 * To improve performance, a completion event is only required once every
74 * MLX5_PMD_TX_PER_COMP_REQ sends. Doing so discards completion information
75 * for other WRs, but this information would not be used anyway.
78 * Pointer to TX queue structure.
81 * 0 on success, -1 on failure.
84 txq_complete(struct txq *txq)
86 unsigned int elts_comp = txq->elts_comp;
87 unsigned int elts_tail = txq->elts_tail;
88 unsigned int elts_free = txq->elts_tail;
89 const unsigned int elts_n = txq->elts_n;
92 if (unlikely(elts_comp == 0))
95 DEBUG("%p: processing %u work requests completions",
96 (void *)txq, elts_comp);
98 wcs_n = txq->poll_cnt(txq->cq, elts_comp);
99 if (unlikely(wcs_n == 0))
101 if (unlikely(wcs_n < 0)) {
102 DEBUG("%p: ibv_poll_cq() failed (wcs_n=%d)",
107 assert(elts_comp <= txq->elts_comp);
109 * Assume WC status is successful as nothing can be done about it
112 elts_tail += wcs_n * txq->elts_comp_cd_init;
113 if (elts_tail >= elts_n)
116 while (elts_free != elts_tail) {
117 struct txq_elt *elt = &(*txq->elts)[elts_free];
118 unsigned int elts_free_next =
119 (((elts_free + 1) == elts_n) ? 0 : elts_free + 1);
120 struct rte_mbuf *tmp = elt->buf;
121 struct txq_elt *elt_next = &(*txq->elts)[elts_free_next];
125 memset(elt, 0x66, sizeof(*elt));
127 RTE_MBUF_PREFETCH_TO_FREE(elt_next->buf);
128 /* Faster than rte_pktmbuf_free(). */
130 struct rte_mbuf *next = NEXT(tmp);
132 rte_pktmbuf_free_seg(tmp);
134 } while (tmp != NULL);
135 elts_free = elts_free_next;
138 txq->elts_tail = elts_tail;
139 txq->elts_comp = elts_comp;
144 * Get Memory Pool (MP) from mbuf. If mbuf is indirect, the pool from which
145 * the cloned mbuf is allocated is returned instead.
151 * Memory pool where data is located for given mbuf.
153 static struct rte_mempool *
154 txq_mb2mp(struct rte_mbuf *buf)
156 if (unlikely(RTE_MBUF_INDIRECT(buf)))
157 return rte_mbuf_from_indirect(buf)->pool;
161 static inline uint32_t
162 txq_mp2mr(struct txq *txq, struct rte_mempool *mp)
163 __attribute__((always_inline));
166 * Get Memory Region (MR) <-> Memory Pool (MP) association from txq->mp2mr[].
167 * Add MP to txq->mp2mr[] if it's not registered yet. If mp2mr[] is full,
168 * remove an entry first.
171 * Pointer to TX queue structure.
173 * Memory Pool for which a Memory Region lkey must be returned.
176 * mr->lkey on success, (uint32_t)-1 on failure.
178 static inline uint32_t
179 txq_mp2mr(struct txq *txq, struct rte_mempool *mp)
182 uint32_t lkey = (uint32_t)-1;
184 for (i = 0; (i != RTE_DIM(txq->mp2mr)); ++i) {
185 if (unlikely(txq->mp2mr[i].mp == NULL)) {
186 /* Unknown MP, add a new MR for it. */
189 if (txq->mp2mr[i].mp == mp) {
190 assert(txq->mp2mr[i].lkey != (uint32_t)-1);
191 assert(txq->mp2mr[i].mr->lkey == txq->mp2mr[i].lkey);
192 lkey = txq->mp2mr[i].lkey;
196 if (unlikely(lkey == (uint32_t)-1))
197 lkey = txq_mp2mr_reg(txq, mp, i);
202 * Insert VLAN using mbuf headroom space.
205 * Buffer for VLAN insertion.
208 * 0 on success, errno value on failure.
211 insert_vlan_sw(struct rte_mbuf *buf)
215 uint16_t head_room_len = rte_pktmbuf_headroom(buf);
217 if (head_room_len < 4)
220 addr = rte_pktmbuf_mtod(buf, uintptr_t);
221 vlan = htonl(0x81000000 | buf->vlan_tci);
222 memmove((void *)(addr - 4), (void *)addr, 12);
223 memcpy((void *)(addr + 8), &vlan, sizeof(vlan));
225 SET_DATA_OFF(buf, head_room_len - 4);
232 * DPDK callback for TX.
235 * Generic pointer to TX queue structure.
237 * Packets to transmit.
239 * Number of packets in array.
242 * Number of packets successfully transmitted (<= pkts_n).
245 mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
247 struct txq *txq = (struct txq *)dpdk_txq;
248 unsigned int elts_head = txq->elts_head;
249 const unsigned int elts_n = txq->elts_n;
250 unsigned int elts_comp_cd = txq->elts_comp_cd;
251 unsigned int elts_comp = 0;
255 struct rte_mbuf *buf = pkts[0];
257 assert(elts_comp_cd != 0);
258 /* Prefetch first packet cacheline. */
261 max = (elts_n - (elts_head - txq->elts_tail));
265 assert(max <= elts_n);
266 /* Always leave one free entry in the ring. */
272 for (i = 0; (i != max); ++i) {
273 struct rte_mbuf *buf_next = pkts[i + 1];
274 unsigned int elts_head_next =
275 (((elts_head + 1) == elts_n) ? 0 : elts_head + 1);
276 struct txq_elt *elt = &(*txq->elts)[elts_head];
277 uint32_t send_flags = 0;
278 #ifdef HAVE_VERBS_VLAN_INSERTION
280 #endif /* HAVE_VERBS_VLAN_INSERTION */
284 uintptr_t buf_next_addr;
287 rte_prefetch0(buf_next);
288 /* Request TX completion. */
289 if (unlikely(--elts_comp_cd == 0)) {
290 elts_comp_cd = txq->elts_comp_cd_init;
292 send_flags |= IBV_EXP_QP_BURST_SIGNALED;
294 /* Should we enable HW CKSUM offload */
296 (PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM | PKT_TX_UDP_CKSUM)) {
297 send_flags |= IBV_EXP_QP_BURST_IP_CSUM;
298 /* HW does not support checksum offloads at arbitrary
299 * offsets but automatically recognizes the packet
300 * type. For inner L3/L4 checksums, only VXLAN (UDP)
301 * tunnels are currently supported. */
302 if (RTE_ETH_IS_TUNNEL_PKT(buf->packet_type))
303 send_flags |= IBV_EXP_QP_BURST_TUNNEL;
305 if (buf->ol_flags & PKT_TX_VLAN_PKT) {
306 #ifdef HAVE_VERBS_VLAN_INSERTION
310 #endif /* HAVE_VERBS_VLAN_INSERTION */
312 err = insert_vlan_sw(buf);
317 /* Retrieve buffer information. */
318 addr = rte_pktmbuf_mtod(buf, uintptr_t);
319 length = DATA_LEN(buf);
320 /* Update element. */
322 if (txq->priv->sriov)
323 rte_prefetch0((volatile void *)
325 /* Prefetch next buffer data. */
328 rte_pktmbuf_mtod(buf_next, uintptr_t);
329 rte_prefetch0((volatile void *)
330 (uintptr_t)buf_next_addr);
332 /* Put packet into send queue. */
333 #if MLX5_PMD_MAX_INLINE > 0
334 if (length <= txq->max_inline) {
335 #ifdef HAVE_VERBS_VLAN_INSERTION
337 err = txq->send_pending_inline_vlan
344 #endif /* HAVE_VERBS_VLAN_INSERTION */
345 err = txq->send_pending_inline
354 * Retrieve Memory Region key for this
357 lkey = txq_mp2mr(txq, txq_mb2mp(buf));
358 if (unlikely(lkey == (uint32_t)-1)) {
359 /* MR does not exist. */
360 DEBUG("%p: unable to get MP <-> MR"
361 " association", (void *)txq);
362 /* Clean up TX element. */
366 #ifdef HAVE_VERBS_VLAN_INSERTION
368 err = txq->send_pending_vlan
376 #endif /* HAVE_VERBS_VLAN_INSERTION */
377 err = txq->send_pending
386 #ifdef MLX5_PMD_SOFT_COUNTERS
387 /* Increment sent bytes counter. */
388 txq->stats.obytes += length;
391 elts_head = elts_head_next;
394 /* Take a shortcut if nothing must be sent. */
395 if (unlikely(i == 0))
397 #ifdef MLX5_PMD_SOFT_COUNTERS
398 /* Increment sent packets counter. */
399 txq->stats.opackets += i;
401 /* Ring QP doorbell. */
402 err = txq->send_flush(txq->qp);
404 /* A nonzero value is not supposed to be returned.
405 * Nothing can be done about it. */
406 DEBUG("%p: send_flush() failed with error %d",
409 txq->elts_head = elts_head;
410 txq->elts_comp += elts_comp;
411 txq->elts_comp_cd = elts_comp_cd;
416 * Translate RX completion flags to packet type.
419 * RX completion flags returned by poll_length_flags().
421 * @note: fix mlx5_dev_supported_ptypes_get() if any change here.
424 * Packet type for struct rte_mbuf.
426 static inline uint32_t
427 rxq_cq_to_pkt_type(uint32_t flags)
431 if (flags & IBV_EXP_CQ_RX_TUNNEL_PACKET)
434 IBV_EXP_CQ_RX_OUTER_IPV4_PACKET,
437 IBV_EXP_CQ_RX_OUTER_IPV6_PACKET,
440 IBV_EXP_CQ_RX_IPV4_PACKET,
441 RTE_PTYPE_INNER_L3_IPV4) |
443 IBV_EXP_CQ_RX_IPV6_PACKET,
444 RTE_PTYPE_INNER_L3_IPV6);
448 IBV_EXP_CQ_RX_IPV4_PACKET,
451 IBV_EXP_CQ_RX_IPV6_PACKET,
457 * Translate RX completion flags to offload flags.
460 * Pointer to RX queue structure.
462 * RX completion flags returned by poll_length_flags().
465 * Offload flags (ol_flags) for struct rte_mbuf.
467 static inline uint32_t
468 rxq_cq_to_ol_flags(const struct rxq *rxq, uint32_t flags)
470 uint32_t ol_flags = 0;
473 /* Set IP checksum flag only for IPv4/IPv6 packets. */
475 (IBV_EXP_CQ_RX_IPV4_PACKET | IBV_EXP_CQ_RX_IPV6_PACKET))
478 IBV_EXP_CQ_RX_IP_CSUM_OK,
479 PKT_RX_IP_CKSUM_BAD);
480 #ifdef HAVE_EXP_CQ_RX_TCP_PACKET
481 /* Set L4 checksum flag only for TCP/UDP packets. */
483 (IBV_EXP_CQ_RX_TCP_PACKET | IBV_EXP_CQ_RX_UDP_PACKET))
484 #endif /* HAVE_EXP_CQ_RX_TCP_PACKET */
487 IBV_EXP_CQ_RX_TCP_UDP_CSUM_OK,
488 PKT_RX_L4_CKSUM_BAD);
491 * PKT_RX_IP_CKSUM_BAD and PKT_RX_L4_CKSUM_BAD are used in place
492 * of PKT_RX_EIP_CKSUM_BAD because the latter is not functional
495 if ((flags & IBV_EXP_CQ_RX_TUNNEL_PACKET) && (rxq->csum_l2tun))
498 IBV_EXP_CQ_RX_OUTER_IP_CSUM_OK,
499 PKT_RX_IP_CKSUM_BAD) |
501 IBV_EXP_CQ_RX_OUTER_TCP_UDP_CSUM_OK,
502 PKT_RX_L4_CKSUM_BAD);
507 * DPDK callback for RX with scattered packets support.
510 * Generic pointer to RX queue structure.
512 * Array to store received packets.
514 * Maximum number of packets in array.
517 * Number of packets successfully received (<= pkts_n).
520 mlx5_rx_burst_sp(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
522 struct rxq *rxq = (struct rxq *)dpdk_rxq;
523 struct rxq_elt_sp (*elts)[rxq->elts_n] = rxq->elts.sp;
524 const unsigned int elts_n = rxq->elts_n;
525 unsigned int elts_head = rxq->elts_head;
527 unsigned int pkts_ret = 0;
530 if (unlikely(!rxq->sp))
531 return mlx5_rx_burst(dpdk_rxq, pkts, pkts_n);
532 if (unlikely(elts == NULL)) /* See RTE_DEV_CMD_SET_MTU. */
534 for (i = 0; (i != pkts_n); ++i) {
535 struct rxq_elt_sp *elt = &(*elts)[elts_head];
537 unsigned int pkt_buf_len;
538 struct rte_mbuf *pkt_buf = NULL; /* Buffer returned in pkts. */
539 struct rte_mbuf **pkt_buf_next = &pkt_buf;
540 unsigned int seg_headroom = RTE_PKTMBUF_HEADROOM;
546 assert(elts_head < rxq->elts_n);
547 assert(rxq->elts_head < rxq->elts_n);
548 ret = rxq->poll(rxq->cq, NULL, NULL, &flags, &vlan_tci);
549 if (unlikely(ret < 0)) {
553 DEBUG("rxq=%p, poll_length() failed (ret=%d)",
555 /* ibv_poll_cq() must be used in case of failure. */
556 wcs_n = ibv_poll_cq(rxq->cq, 1, &wc);
557 if (unlikely(wcs_n == 0))
559 if (unlikely(wcs_n < 0)) {
560 DEBUG("rxq=%p, ibv_poll_cq() failed (wcs_n=%d)",
565 if (unlikely(wc.status != IBV_WC_SUCCESS)) {
566 /* Whatever, just repost the offending WR. */
567 DEBUG("rxq=%p, wr_id=%" PRIu64 ": bad work"
568 " completion status (%d): %s",
569 (void *)rxq, wc.wr_id, wc.status,
570 ibv_wc_status_str(wc.status));
571 #ifdef MLX5_PMD_SOFT_COUNTERS
572 /* Increment dropped packets counter. */
573 ++rxq->stats.idropped;
581 assert(ret >= (rxq->crc_present << 2));
582 len = ret - (rxq->crc_present << 2);
585 * Replace spent segments with new ones, concatenate and
586 * return them as pkt_buf.
589 struct ibv_sge *sge = &elt->sges[j];
590 struct rte_mbuf *seg = elt->bufs[j];
591 struct rte_mbuf *rep;
592 unsigned int seg_tailroom;
596 * Fetch initial bytes of packet descriptor into a
597 * cacheline while allocating rep.
600 rep = rte_mbuf_raw_alloc(rxq->mp);
601 if (unlikely(rep == NULL)) {
603 * Unable to allocate a replacement mbuf,
606 DEBUG("rxq=%p: can't allocate a new mbuf",
608 if (pkt_buf != NULL) {
609 *pkt_buf_next = NULL;
610 rte_pktmbuf_free(pkt_buf);
612 /* Increment out of memory counters. */
613 ++rxq->stats.rx_nombuf;
614 ++rxq->priv->dev->data->rx_mbuf_alloc_failed;
618 /* Poison user-modifiable fields in rep. */
619 NEXT(rep) = (void *)((uintptr_t)-1);
620 SET_DATA_OFF(rep, 0xdead);
621 DATA_LEN(rep) = 0xd00d;
622 PKT_LEN(rep) = 0xdeadd00d;
627 assert(rep->buf_len == seg->buf_len);
628 /* Reconfigure sge to use rep instead of seg. */
629 assert(sge->lkey == rxq->mr->lkey);
630 sge->addr = ((uintptr_t)rep->buf_addr + seg_headroom);
633 /* Update pkt_buf if it's the first segment, or link
634 * seg to the previous one and update pkt_buf_next. */
636 pkt_buf_next = &NEXT(seg);
637 /* Update seg information. */
638 seg_tailroom = (seg->buf_len - seg_headroom);
639 assert(sge->length == seg_tailroom);
640 SET_DATA_OFF(seg, seg_headroom);
641 if (likely(len <= seg_tailroom)) {
646 assert(rte_pktmbuf_headroom(seg) ==
648 assert(rte_pktmbuf_tailroom(seg) ==
649 (seg_tailroom - len));
652 DATA_LEN(seg) = seg_tailroom;
653 PKT_LEN(seg) = seg_tailroom;
655 assert(rte_pktmbuf_headroom(seg) == seg_headroom);
656 assert(rte_pktmbuf_tailroom(seg) == 0);
657 /* Fix len and clear headroom for next segments. */
661 /* Update head and tail segments. */
662 *pkt_buf_next = NULL;
663 assert(pkt_buf != NULL);
665 NB_SEGS(pkt_buf) = j;
666 PORT(pkt_buf) = rxq->port_id;
667 PKT_LEN(pkt_buf) = pkt_buf_len;
668 if (rxq->csum | rxq->csum_l2tun | rxq->vlan_strip) {
669 pkt_buf->packet_type = rxq_cq_to_pkt_type(flags);
670 pkt_buf->ol_flags = rxq_cq_to_ol_flags(rxq, flags);
671 #ifdef HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS
672 if (flags & IBV_EXP_CQ_RX_CVLAN_STRIPPED_V1) {
673 pkt_buf->ol_flags |= PKT_RX_VLAN_PKT |
674 PKT_RX_VLAN_STRIPPED;
675 pkt_buf->vlan_tci = vlan_tci;
677 #endif /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */
683 #ifdef MLX5_PMD_SOFT_COUNTERS
684 /* Increment bytes counter. */
685 rxq->stats.ibytes += pkt_buf_len;
688 ret = rxq->recv(rxq->wq, elt->sges, RTE_DIM(elt->sges));
690 /* Inability to repost WRs is fatal. */
691 DEBUG("%p: recv_sg_list(): failed (ret=%d)",
696 if (++elts_head >= elts_n)
700 if (unlikely(i == 0))
702 rxq->elts_head = elts_head;
703 #ifdef MLX5_PMD_SOFT_COUNTERS
704 /* Increment packets counter. */
705 rxq->stats.ipackets += pkts_ret;
711 * DPDK callback for RX.
713 * The following function is the same as mlx5_rx_burst_sp(), except it doesn't
714 * manage scattered packets. Improves performance when MRU is lower than the
715 * size of the first segment.
718 * Generic pointer to RX queue structure.
720 * Array to store received packets.
722 * Maximum number of packets in array.
725 * Number of packets successfully received (<= pkts_n).
728 mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
730 struct rxq *rxq = (struct rxq *)dpdk_rxq;
731 struct rxq_elt (*elts)[rxq->elts_n] = rxq->elts.no_sp;
732 const unsigned int elts_n = rxq->elts_n;
733 unsigned int elts_head = rxq->elts_head;
734 struct ibv_sge sges[pkts_n];
736 unsigned int pkts_ret = 0;
739 if (unlikely(rxq->sp))
740 return mlx5_rx_burst_sp(dpdk_rxq, pkts, pkts_n);
741 for (i = 0; (i != pkts_n); ++i) {
742 struct rxq_elt *elt = &(*elts)[elts_head];
744 struct rte_mbuf *seg = elt->buf;
745 struct rte_mbuf *rep;
751 assert(elts_head < rxq->elts_n);
752 assert(rxq->elts_head < rxq->elts_n);
754 * Fetch initial bytes of packet descriptor into a
755 * cacheline while allocating rep.
757 rte_mbuf_prefetch_part1(seg);
758 rte_mbuf_prefetch_part2(seg);
759 ret = rxq->poll(rxq->cq, NULL, NULL, &flags, &vlan_tci);
760 if (unlikely(ret < 0)) {
764 DEBUG("rxq=%p, poll_length() failed (ret=%d)",
766 /* ibv_poll_cq() must be used in case of failure. */
767 wcs_n = ibv_poll_cq(rxq->cq, 1, &wc);
768 if (unlikely(wcs_n == 0))
770 if (unlikely(wcs_n < 0)) {
771 DEBUG("rxq=%p, ibv_poll_cq() failed (wcs_n=%d)",
776 if (unlikely(wc.status != IBV_WC_SUCCESS)) {
777 /* Whatever, just repost the offending WR. */
778 DEBUG("rxq=%p, wr_id=%" PRIu64 ": bad work"
779 " completion status (%d): %s",
780 (void *)rxq, wc.wr_id, wc.status,
781 ibv_wc_status_str(wc.status));
782 #ifdef MLX5_PMD_SOFT_COUNTERS
783 /* Increment dropped packets counter. */
784 ++rxq->stats.idropped;
786 /* Add SGE to array for repost. */
794 assert(ret >= (rxq->crc_present << 2));
795 len = ret - (rxq->crc_present << 2);
796 rep = rte_mbuf_raw_alloc(rxq->mp);
797 if (unlikely(rep == NULL)) {
799 * Unable to allocate a replacement mbuf,
802 DEBUG("rxq=%p: can't allocate a new mbuf",
804 /* Increment out of memory counters. */
805 ++rxq->stats.rx_nombuf;
806 ++rxq->priv->dev->data->rx_mbuf_alloc_failed;
810 /* Reconfigure sge to use rep instead of seg. */
811 elt->sge.addr = (uintptr_t)rep->buf_addr + RTE_PKTMBUF_HEADROOM;
812 assert(elt->sge.lkey == rxq->mr->lkey);
815 /* Add SGE to array for repost. */
818 /* Update seg information. */
819 SET_DATA_OFF(seg, RTE_PKTMBUF_HEADROOM);
821 PORT(seg) = rxq->port_id;
825 if (rxq->csum | rxq->csum_l2tun | rxq->vlan_strip) {
826 seg->packet_type = rxq_cq_to_pkt_type(flags);
827 seg->ol_flags = rxq_cq_to_ol_flags(rxq, flags);
828 #ifdef HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS
829 if (flags & IBV_EXP_CQ_RX_CVLAN_STRIPPED_V1) {
830 seg->ol_flags |= PKT_RX_VLAN_PKT |
831 PKT_RX_VLAN_STRIPPED;
832 seg->vlan_tci = vlan_tci;
834 #endif /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */
839 #ifdef MLX5_PMD_SOFT_COUNTERS
840 /* Increment bytes counter. */
841 rxq->stats.ibytes += len;
844 if (++elts_head >= elts_n)
848 if (unlikely(i == 0))
852 DEBUG("%p: reposting %u WRs", (void *)rxq, i);
854 ret = rxq->recv(rxq->wq, sges, i);
856 /* Inability to repost WRs is fatal. */
857 DEBUG("%p: recv_burst(): failed (ret=%d)",
862 rxq->elts_head = elts_head;
863 #ifdef MLX5_PMD_SOFT_COUNTERS
864 /* Increment packets counter. */
865 rxq->stats.ipackets += pkts_ret;
871 * Dummy DPDK callback for TX.
873 * This function is used to temporarily replace the real callback during
874 * unsafe control operations on the queue, or in case of error.
877 * Generic pointer to TX queue structure.
879 * Packets to transmit.
881 * Number of packets in array.
884 * Number of packets successfully transmitted (<= pkts_n).
887 removed_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
896 * Dummy DPDK callback for RX.
898 * This function is used to temporarily replace the real callback during
899 * unsafe control operations on the queue, or in case of error.
902 * Generic pointer to RX queue structure.
904 * Array to store received packets.
906 * Maximum number of packets in array.
909 * Number of packets successfully received (<= pkts_n).
912 removed_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)