4 * Copyright 2017 6WIND S.A.
5 * Copyright 2017 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.
36 * Data plane functions for mlx4 driver.
43 /* Verbs headers do not support -pedantic. */
45 #pragma GCC diagnostic ignored "-Wpedantic"
47 #include <infiniband/verbs.h>
49 #pragma GCC diagnostic error "-Wpedantic"
52 #include <rte_branch_prediction.h>
53 #include <rte_common.h>
56 #include <rte_mempool.h>
57 #include <rte_prefetch.h>
61 #include "mlx4_rxtx.h"
62 #include "mlx4_utils.h"
64 #define WQE_ONE_DATA_SEG_SIZE \
65 (sizeof(struct mlx4_wqe_ctrl_seg) + sizeof(struct mlx4_wqe_data_seg))
68 * Pointer-value pair structure used in tx_post_send for saving the first
69 * DWORD (32 byte) of a TXBB.
72 volatile struct mlx4_wqe_data_seg *dseg;
77 * Stamp a WQE so it won't be reused by the HW.
79 * Routine is used when freeing WQE used by the chip or when failing
80 * building an WQ entry has failed leaving partial information on the queue.
83 * Pointer to the SQ structure.
85 * Index of the freed WQE.
87 * Number of blocks to stamp.
88 * If < 0 the routine will use the size written in the WQ entry.
90 * The value of the WQE owner bit to use in the stamp.
93 * The number of Tx basic blocs (TXBB) the WQE contained.
96 mlx4_txq_stamp_freed_wqe(struct mlx4_sq *sq, uint16_t index, uint8_t owner)
98 uint32_t stamp = rte_cpu_to_be_32(MLX4_SQ_STAMP_VAL |
99 (!!owner << MLX4_SQ_STAMP_SHIFT));
100 volatile uint8_t *wqe = mlx4_get_send_wqe(sq,
101 (index & sq->txbb_cnt_mask));
102 volatile uint32_t *ptr = (volatile uint32_t *)wqe;
107 /* Extract the size from the control segment of the WQE. */
108 num_txbbs = MLX4_SIZE_TO_TXBBS((((volatile struct mlx4_wqe_ctrl_seg *)
109 wqe)->fence_size & 0x3f) << 4);
110 txbbs_size = num_txbbs * MLX4_TXBB_SIZE;
111 /* Optimize the common case when there is no wrap-around. */
112 if (wqe + txbbs_size <= sq->eob) {
113 /* Stamp the freed descriptor. */
114 for (i = 0; i < txbbs_size; i += MLX4_SQ_STAMP_STRIDE) {
116 ptr += MLX4_SQ_STAMP_DWORDS;
119 /* Stamp the freed descriptor. */
120 for (i = 0; i < txbbs_size; i += MLX4_SQ_STAMP_STRIDE) {
122 ptr += MLX4_SQ_STAMP_DWORDS;
123 if ((volatile uint8_t *)ptr >= sq->eob) {
124 ptr = (volatile uint32_t *)sq->buf;
125 stamp ^= RTE_BE32(0x80000000);
133 * Manage Tx completions.
135 * When sending a burst, mlx4_tx_burst() posts several WRs.
136 * To improve performance, a completion event is only required once every
137 * MLX4_PMD_TX_PER_COMP_REQ sends. Doing so discards completion information
138 * for other WRs, but this information would not be used anyway.
141 * Pointer to Tx queue structure.
144 * 0 on success, -1 on failure.
147 mlx4_txq_complete(struct txq *txq, const unsigned int elts_n,
150 unsigned int elts_comp = txq->elts_comp;
151 unsigned int elts_tail = txq->elts_tail;
152 struct mlx4_cq *cq = &txq->mcq;
153 volatile struct mlx4_cqe *cqe;
154 uint32_t cons_index = cq->cons_index;
156 uint16_t nr_txbbs = 0;
160 * Traverse over all CQ entries reported and handle each WQ entry
164 cqe = (volatile struct mlx4_cqe *)mlx4_get_cqe(cq, cons_index);
165 if (unlikely(!!(cqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK) ^
166 !!(cons_index & cq->cqe_cnt)))
169 * Make sure we read the CQE after we read the ownership bit.
173 if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) ==
174 MLX4_CQE_OPCODE_ERROR)) {
175 volatile struct mlx4_err_cqe *cqe_err =
176 (volatile struct mlx4_err_cqe *)cqe;
177 ERROR("%p CQE error - vendor syndrome: 0x%x"
179 (void *)txq, cqe_err->vendor_err,
183 /* Get WQE index reported in the CQE. */
185 rte_be_to_cpu_16(cqe->wqe_index) & sq->txbb_cnt_mask;
187 /* Free next descriptor. */
189 mlx4_txq_stamp_freed_wqe(sq,
190 (sq->tail + nr_txbbs) & sq->txbb_cnt_mask,
191 !!((sq->tail + nr_txbbs) & sq->txbb_cnt));
193 } while (((sq->tail + nr_txbbs) & sq->txbb_cnt_mask) !=
197 if (unlikely(pkts == 0))
201 * To prevent CQ overflow we first update CQ consumer and only then
204 cq->cons_index = cons_index;
205 *cq->set_ci_db = rte_cpu_to_be_32(cq->cons_index & MLX4_CQ_DB_CI_MASK);
207 sq->tail = sq->tail + nr_txbbs;
208 /* Update the list of packets posted for transmission. */
210 assert(elts_comp <= txq->elts_comp);
212 * Assume completion status is successful as nothing can be done about
216 if (elts_tail >= elts_n)
218 txq->elts_tail = elts_tail;
219 txq->elts_comp = elts_comp;
224 * Get memory pool (MP) from mbuf. If mbuf is indirect, the pool from which
225 * the cloned mbuf is allocated is returned instead.
231 * Memory pool where data is located for given mbuf.
233 static struct rte_mempool *
234 mlx4_txq_mb2mp(struct rte_mbuf *buf)
236 if (unlikely(RTE_MBUF_INDIRECT(buf)))
237 return rte_mbuf_from_indirect(buf)->pool;
242 mlx4_tx_burst_segs(struct rte_mbuf *buf, struct txq *txq,
243 volatile struct mlx4_wqe_ctrl_seg **pctrl)
247 struct pv *pv = (struct pv *)txq->bounce_buf;
248 struct mlx4_sq *sq = &txq->msq;
249 uint32_t head_idx = sq->head & sq->txbb_cnt_mask;
250 volatile struct mlx4_wqe_ctrl_seg *ctrl;
251 volatile struct mlx4_wqe_data_seg *dseg;
252 struct rte_mbuf *sbuf;
258 /* Calculate the needed work queue entry size for this packet. */
259 wqe_real_size = sizeof(volatile struct mlx4_wqe_ctrl_seg) +
260 buf->nb_segs * sizeof(volatile struct mlx4_wqe_data_seg);
261 nr_txbbs = MLX4_SIZE_TO_TXBBS(wqe_real_size);
263 * Check that there is room for this WQE in the send queue and that
264 * the WQE size is legal.
266 if (((sq->head - sq->tail) + nr_txbbs +
267 sq->headroom_txbbs) >= sq->txbb_cnt ||
268 nr_txbbs > MLX4_MAX_WQE_TXBBS) {
271 /* Get the control and data entries of the WQE. */
272 ctrl = (volatile struct mlx4_wqe_ctrl_seg *)
273 mlx4_get_send_wqe(sq, head_idx);
274 dseg = (volatile struct mlx4_wqe_data_seg *)
275 ((uintptr_t)ctrl + sizeof(struct mlx4_wqe_ctrl_seg));
277 /* Fill the data segments with buffer information. */
278 for (sbuf = buf; sbuf != NULL; sbuf = sbuf->next, dseg++) {
279 addr = rte_pktmbuf_mtod(sbuf, uintptr_t);
280 rte_prefetch0((volatile void *)addr);
281 /* Handle WQE wraparound. */
282 if (dseg >= (volatile struct mlx4_wqe_data_seg *)sq->eob)
283 dseg = (volatile struct mlx4_wqe_data_seg *)sq->buf;
284 dseg->addr = rte_cpu_to_be_64(addr);
285 /* Memory region key (big endian) for this memory pool. */
286 lkey = mlx4_txq_mp2mr(txq, mlx4_txq_mb2mp(sbuf));
287 dseg->lkey = rte_cpu_to_be_32(lkey);
289 /* Calculate the needed work queue entry size for this packet */
290 if (unlikely(dseg->lkey == rte_cpu_to_be_32((uint32_t)-1))) {
291 /* MR does not exist. */
292 DEBUG("%p: unable to get MP <-> MR association",
295 * Restamp entry in case of failure.
296 * Make sure that size is written correctly
297 * Note that we give ownership to the SW, not the HW.
299 wqe_real_size = sizeof(struct mlx4_wqe_ctrl_seg) +
300 buf->nb_segs * sizeof(struct mlx4_wqe_data_seg);
301 ctrl->fence_size = (wqe_real_size >> 4) & 0x3f;
302 mlx4_txq_stamp_freed_wqe(sq, head_idx,
303 (sq->head & sq->txbb_cnt) ? 0 : 1);
307 if (likely(sbuf->data_len)) {
308 byte_count = rte_cpu_to_be_32(sbuf->data_len);
311 * Zero length segment is treated as inline segment
314 byte_count = RTE_BE32(0x80000000);
317 * If the data segment is not at the beginning of a
318 * Tx basic block (TXBB) then write the byte count,
319 * else postpone the writing to just before updating the
322 if ((uintptr_t)dseg & (uintptr_t)(MLX4_TXBB_SIZE - 1)) {
324 * Need a barrier here before writing the byte_count
325 * fields to make sure that all the data is visible
326 * before the byte_count field is set.
327 * Otherwise, if the segment begins a new cacheline,
328 * the HCA prefetcher could grab the 64-byte chunk and
329 * get a valid (!= 0xffffffff) byte count but stale
330 * data, and end up sending the wrong data.
333 dseg->byte_count = byte_count;
336 * This data segment starts at the beginning of a new
337 * TXBB, so we need to postpone its byte_count writing
340 pv[pv_counter].dseg = dseg;
341 pv[pv_counter++].val = byte_count;
344 /* Write the first DWORD of each TXBB save earlier. */
346 /* Need a barrier here before writing the byte_count. */
348 for (--pv_counter; pv_counter >= 0; pv_counter--)
349 pv[pv_counter].dseg->byte_count = pv[pv_counter].val;
351 /* Fill the control parameters for this packet. */
352 ctrl->fence_size = (wqe_real_size >> 4) & 0x3f;
357 * DPDK callback for Tx.
360 * Generic pointer to Tx queue structure.
362 * Packets to transmit.
364 * Number of packets in array.
367 * Number of packets successfully transmitted (<= pkts_n).
370 mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
372 struct txq *txq = (struct txq *)dpdk_txq;
373 unsigned int elts_head = txq->elts_head;
374 const unsigned int elts_n = txq->elts_n;
375 unsigned int bytes_sent = 0;
378 struct mlx4_sq *sq = &txq->msq;
381 assert(txq->elts_comp_cd != 0);
382 if (likely(txq->elts_comp != 0))
383 mlx4_txq_complete(txq, elts_n, sq);
384 max = (elts_n - (elts_head - txq->elts_tail));
388 assert(max <= elts_n);
389 /* Always leave one free entry in the ring. */
393 for (i = 0; (i != max); ++i) {
394 struct rte_mbuf *buf = pkts[i];
395 unsigned int elts_head_next =
396 (((elts_head + 1) == elts_n) ? 0 : elts_head + 1);
397 struct txq_elt *elt_next = &(*txq->elts)[elts_head_next];
398 struct txq_elt *elt = &(*txq->elts)[elts_head];
399 uint32_t owner_opcode = MLX4_OPCODE_SEND;
400 volatile struct mlx4_wqe_ctrl_seg *ctrl;
401 volatile struct mlx4_wqe_data_seg *dseg;
406 uint32_t head_idx = sq->head & sq->txbb_cnt_mask;
410 /* Clean up old buffer. */
411 if (likely(elt->buf != NULL)) {
412 struct rte_mbuf *tmp = elt->buf;
416 memset(elt, 0x66, sizeof(*elt));
418 /* Faster than rte_pktmbuf_free(). */
420 struct rte_mbuf *next = tmp->next;
422 rte_pktmbuf_free_seg(tmp);
424 } while (tmp != NULL);
426 RTE_MBUF_PREFETCH_TO_FREE(elt_next->buf);
427 if (buf->nb_segs == 1) {
429 * Check that there is room for this WQE in the send
430 * queue and that the WQE size is legal
432 if (((sq->head - sq->tail) + 1 + sq->headroom_txbbs) >=
433 sq->txbb_cnt || 1 > MLX4_MAX_WQE_TXBBS) {
437 /* Get the control and data entries of the WQE. */
438 ctrl = (volatile struct mlx4_wqe_ctrl_seg *)
439 mlx4_get_send_wqe(sq, head_idx);
440 dseg = (volatile struct mlx4_wqe_data_seg *)
442 sizeof(struct mlx4_wqe_ctrl_seg));
443 addr = rte_pktmbuf_mtod(buf, uintptr_t);
444 rte_prefetch0((volatile void *)addr);
445 /* Handle WQE wraparound. */
447 (volatile struct mlx4_wqe_data_seg *)sq->eob)
448 dseg = (volatile struct mlx4_wqe_data_seg *)
450 dseg->addr = rte_cpu_to_be_64(addr);
451 /* Memory region key (big endian). */
452 lkey = mlx4_txq_mp2mr(txq, mlx4_txq_mb2mp(buf));
453 dseg->lkey = rte_cpu_to_be_32(lkey);
455 if (unlikely(dseg->lkey ==
456 rte_cpu_to_be_32((uint32_t)-1))) {
457 /* MR does not exist. */
458 DEBUG("%p: unable to get MP <-> MR association",
461 * Restamp entry in case of failure.
462 * Make sure that size is written correctly
463 * Note that we give ownership to the SW,
467 (WQE_ONE_DATA_SEG_SIZE >> 4) & 0x3f;
468 mlx4_txq_stamp_freed_wqe(sq, head_idx,
469 (sq->head & sq->txbb_cnt) ? 0 : 1);
474 /* Need a barrier here before byte count store. */
476 dseg->byte_count = rte_cpu_to_be_32(buf->data_len);
477 /* Fill the control parameters for this packet. */
478 ctrl->fence_size = (WQE_ONE_DATA_SEG_SIZE >> 4) & 0x3f;
481 nr_txbbs = mlx4_tx_burst_segs(buf, txq, &ctrl);
488 * For raw Ethernet, the SOLICIT flag is used to indicate
489 * that no ICRC should be calculated.
491 txq->elts_comp_cd -= nr_txbbs;
492 if (unlikely(txq->elts_comp_cd <= 0)) {
493 txq->elts_comp_cd = txq->elts_comp_cd_init;
494 srcrb.flags = RTE_BE32(MLX4_WQE_CTRL_SOLICIT |
495 MLX4_WQE_CTRL_CQ_UPDATE);
497 srcrb.flags = RTE_BE32(MLX4_WQE_CTRL_SOLICIT);
499 /* Enable HW checksum offload if requested */
502 (PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM | PKT_TX_UDP_CKSUM))) {
503 const uint64_t is_tunneled = (buf->ol_flags &
505 PKT_TX_TUNNEL_VXLAN));
507 if (is_tunneled && txq->csum_l2tun) {
508 owner_opcode |= MLX4_WQE_CTRL_IIP_HDR_CSUM |
509 MLX4_WQE_CTRL_IL4_HDR_CSUM;
510 if (buf->ol_flags & PKT_TX_OUTER_IP_CKSUM)
512 RTE_BE32(MLX4_WQE_CTRL_IP_HDR_CSUM);
515 RTE_BE32(MLX4_WQE_CTRL_IP_HDR_CSUM |
516 MLX4_WQE_CTRL_TCP_UDP_CSUM);
521 * Copy destination MAC address to the WQE, this allows
522 * loopback in eSwitch, so that VFs and PF can
523 * communicate with each other.
525 srcrb.flags16[0] = *(rte_pktmbuf_mtod(buf, uint16_t *));
526 ctrl->imm = *(rte_pktmbuf_mtod_offset(buf, uint32_t *,
531 ctrl->srcrb_flags = srcrb.flags;
533 * Make sure descriptor is fully written before
534 * setting ownership bit (because HW can start
535 * executing as soon as we do).
538 ctrl->owner_opcode = rte_cpu_to_be_32(owner_opcode |
539 ((sq->head & sq->txbb_cnt) ?
540 MLX4_BIT_WQE_OWN : 0));
541 sq->head += nr_txbbs;
543 bytes_sent += buf->pkt_len;
544 elts_head = elts_head_next;
546 /* Take a shortcut if nothing must be sent. */
547 if (unlikely(i == 0))
549 /* Increment send statistics counters. */
550 txq->stats.opackets += i;
551 txq->stats.obytes += bytes_sent;
552 /* Make sure that descriptors are written before doorbell record. */
554 /* Ring QP doorbell. */
555 rte_write32(txq->msq.doorbell_qpn, txq->msq.db);
556 txq->elts_head = elts_head;
562 * Translate Rx completion flags to packet type.
565 * Rx completion flags returned by mlx4_cqe_flags().
568 * Packet type in mbuf format.
570 static inline uint32_t
571 rxq_cq_to_pkt_type(uint32_t flags)
575 if (flags & MLX4_CQE_L2_TUNNEL)
577 mlx4_transpose(flags,
578 MLX4_CQE_L2_TUNNEL_IPV4,
579 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN) |
580 mlx4_transpose(flags,
581 MLX4_CQE_STATUS_IPV4_PKT,
582 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN);
584 pkt_type = mlx4_transpose(flags,
585 MLX4_CQE_STATUS_IPV4_PKT,
586 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN);
591 * Translate Rx completion flags to offload flags.
594 * Rx completion flags returned by mlx4_cqe_flags().
596 * Whether Rx checksums are enabled.
598 * Whether Rx L2 tunnel checksums are enabled.
601 * Offload flags (ol_flags) in mbuf format.
603 static inline uint32_t
604 rxq_cq_to_ol_flags(uint32_t flags, int csum, int csum_l2tun)
606 uint32_t ol_flags = 0;
610 mlx4_transpose(flags,
611 MLX4_CQE_STATUS_IP_HDR_CSUM_OK,
612 PKT_RX_IP_CKSUM_GOOD) |
613 mlx4_transpose(flags,
614 MLX4_CQE_STATUS_TCP_UDP_CSUM_OK,
615 PKT_RX_L4_CKSUM_GOOD);
616 if ((flags & MLX4_CQE_L2_TUNNEL) && csum_l2tun)
618 mlx4_transpose(flags,
619 MLX4_CQE_L2_TUNNEL_IPOK,
620 PKT_RX_IP_CKSUM_GOOD) |
621 mlx4_transpose(flags,
622 MLX4_CQE_L2_TUNNEL_L4_CSUM,
623 PKT_RX_L4_CKSUM_GOOD);
628 * Extract checksum information from CQE flags.
631 * Pointer to CQE structure.
633 * Whether Rx checksums are enabled.
635 * Whether Rx L2 tunnel checksums are enabled.
638 * CQE checksum information.
640 static inline uint32_t
641 mlx4_cqe_flags(volatile struct mlx4_cqe *cqe, int csum, int csum_l2tun)
646 * The relevant bits are in different locations on their
647 * CQE fields therefore we can join them in one 32bit
651 flags = (rte_be_to_cpu_32(cqe->status) &
652 MLX4_CQE_STATUS_IPV4_CSUM_OK);
654 flags |= (rte_be_to_cpu_32(cqe->vlan_my_qpn) &
655 (MLX4_CQE_L2_TUNNEL |
656 MLX4_CQE_L2_TUNNEL_IPOK |
657 MLX4_CQE_L2_TUNNEL_L4_CSUM |
658 MLX4_CQE_L2_TUNNEL_IPV4));
663 * Poll one CQE from CQ.
666 * Pointer to the receive queue structure.
671 * Number of bytes of the CQE, 0 in case there is no completion.
674 mlx4_cq_poll_one(struct rxq *rxq, volatile struct mlx4_cqe **out)
677 volatile struct mlx4_cqe *cqe = NULL;
678 struct mlx4_cq *cq = &rxq->mcq;
680 cqe = (volatile struct mlx4_cqe *)mlx4_get_cqe(cq, cq->cons_index);
681 if (!!(cqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK) ^
682 !!(cq->cons_index & cq->cqe_cnt))
685 * Make sure we read CQ entry contents after we've checked the
689 assert(!(cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK));
690 assert((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) !=
691 MLX4_CQE_OPCODE_ERROR);
692 ret = rte_be_to_cpu_32(cqe->byte_cnt);
700 * DPDK callback for Rx with scattered packets support.
703 * Generic pointer to Rx queue structure.
705 * Array to store received packets.
707 * Maximum number of packets in array.
710 * Number of packets successfully received (<= pkts_n).
713 mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
715 struct rxq *rxq = dpdk_rxq;
716 const uint32_t wr_cnt = (1 << rxq->elts_n) - 1;
717 const uint16_t sges_n = rxq->sges_n;
718 struct rte_mbuf *pkt = NULL;
719 struct rte_mbuf *seg = NULL;
721 uint32_t rq_ci = rxq->rq_ci << sges_n;
725 volatile struct mlx4_cqe *cqe;
726 uint32_t idx = rq_ci & wr_cnt;
727 struct rte_mbuf *rep = (*rxq->elts)[idx];
728 volatile struct mlx4_wqe_data_seg *scat = &(*rxq->wqes)[idx];
730 /* Update the 'next' pointer of the previous segment. */
736 rep = rte_mbuf_raw_alloc(rxq->mp);
737 if (unlikely(rep == NULL)) {
738 ++rxq->stats.rx_nombuf;
741 * No buffers before we even started,
747 assert(pkt != (*rxq->elts)[idx]);
751 rte_mbuf_raw_free(pkt);
757 /* Looking for the new packet. */
758 len = mlx4_cq_poll_one(rxq, &cqe);
760 rte_mbuf_raw_free(rep);
763 if (unlikely(len < 0)) {
764 /* Rx error, packet is likely too large. */
765 rte_mbuf_raw_free(rep);
766 ++rxq->stats.idropped;
770 if (rxq->csum | rxq->csum_l2tun) {
777 rxq_cq_to_ol_flags(flags,
780 pkt->packet_type = rxq_cq_to_pkt_type(flags);
782 pkt->packet_type = 0;
788 rep->port = rxq->port_id;
789 rep->data_len = seg->data_len;
790 rep->data_off = seg->data_off;
791 (*rxq->elts)[idx] = rep;
793 * Fill NIC descriptor with the new buffer. The lkey and size
794 * of the buffers are already known, only the buffer address
797 scat->addr = rte_cpu_to_be_64(rte_pktmbuf_mtod(rep, uintptr_t));
798 if (len > seg->data_len) {
799 len -= seg->data_len;
804 /* The last segment. */
806 /* Increment bytes counter. */
807 rxq->stats.ibytes += pkt->pkt_len;
814 /* Align consumer index to the next stride. */
819 if (unlikely(i == 0 && (rq_ci >> sges_n) == rxq->rq_ci))
821 /* Update the consumer index. */
822 rxq->rq_ci = rq_ci >> sges_n;
824 *rxq->rq_db = rte_cpu_to_be_32(rxq->rq_ci);
825 *rxq->mcq.set_ci_db =
826 rte_cpu_to_be_32(rxq->mcq.cons_index & MLX4_CQ_DB_CI_MASK);
827 /* Increment packets counter. */
828 rxq->stats.ipackets += i;
833 * Dummy DPDK callback for Tx.
835 * This function is used to temporarily replace the real callback during
836 * unsafe control operations on the queue, or in case of error.
839 * Generic pointer to Tx queue structure.
841 * Packets to transmit.
843 * Number of packets in array.
846 * Number of packets successfully transmitted (<= pkts_n).
849 mlx4_tx_burst_removed(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
858 * Dummy DPDK callback for Rx.
860 * This function is used to temporarily replace the real callback during
861 * unsafe control operations on the queue, or in case of error.
864 * Generic pointer to Rx queue structure.
866 * Array to store received packets.
868 * Maximum number of packets in array.
871 * Number of packets successfully received (<= pkts_n).
874 mlx4_rx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)