1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2017 6WIND S.A.
3 * Copyright 2017 Mellanox Technologies, Ltd
11 #include <rte_mempool.h>
12 #include <rte_prefetch.h>
15 #include <mlx5_glue.h>
18 #include "mlx5_defs.h"
20 #include "mlx5_utils.h"
21 #include "mlx5_rxtx.h"
22 #include "mlx5_rxtx_vec.h"
23 #include "mlx5_autoconf.h"
25 #if defined RTE_ARCH_X86_64
26 #include "mlx5_rxtx_vec_sse.h"
27 #elif defined RTE_ARCH_ARM64
28 #include "mlx5_rxtx_vec_neon.h"
29 #elif defined RTE_ARCH_PPC_64
30 #include "mlx5_rxtx_vec_altivec.h"
32 #error "This should not be compiled if SIMD instructions are not supported."
39 * Pointer to RX queue structure.
41 * Array to store received packets.
43 * Maximum number of packets in array.
46 * Number of packets successfully received (<= pkts_n).
49 rxq_handle_pending_error(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts,
54 #ifdef MLX5_PMD_SOFT_COUNTERS
55 uint32_t err_bytes = 0;
58 for (i = 0; i < pkts_n; ++i) {
59 struct rte_mbuf *pkt = pkts[i];
61 if (pkt->packet_type == RTE_PTYPE_ALL_MASK || rxq->err_state) {
62 #ifdef MLX5_PMD_SOFT_COUNTERS
63 err_bytes += PKT_LEN(pkt);
65 rte_pktmbuf_free_seg(pkt);
70 rxq->stats.idropped += (pkts_n - n);
71 #ifdef MLX5_PMD_SOFT_COUNTERS
72 /* Correct counters of errored completions. */
73 rxq->stats.ipackets -= (pkts_n - n);
74 rxq->stats.ibytes -= err_bytes;
76 mlx5_rx_err_handle(rxq, 1);
81 * DPDK callback for vectorized RX.
84 * Generic pointer to RX queue structure.
86 * Array to store received packets.
88 * Maximum number of packets in array.
91 * Number of packets successfully received (<= pkts_n).
94 mlx5_rx_burst_vec(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
96 struct mlx5_rxq_data *rxq = dpdk_rxq;
103 nb_rx = rxq_burst_v(rxq, pkts + tn, pkts_n - tn, &err, &no_cq);
104 if (unlikely(err | rxq->err_state))
105 nb_rx = rxq_handle_pending_error(rxq, pkts + tn, nb_rx);
109 } while (tn != pkts_n);
114 * Check a RX queue can support vectorized RX.
117 * Pointer to RX queue.
120 * 1 if supported, negative errno value if not.
123 mlx5_rxq_check_vec_support(struct mlx5_rxq_data *rxq)
125 struct mlx5_rxq_ctrl *ctrl =
126 container_of(rxq, struct mlx5_rxq_ctrl, rxq);
128 if (mlx5_mprq_enabled(ETH_DEV(ctrl->priv)))
130 if (!ctrl->priv->config.rx_vec_en || rxq->sges_n != 0)
138 * Check a device can support vectorized RX.
141 * Pointer to Ethernet device.
144 * 1 if supported, negative errno value if not.
147 mlx5_check_vec_rx_support(struct rte_eth_dev *dev)
149 struct mlx5_priv *priv = dev->data->dev_private;
152 if (rte_vect_get_max_simd_bitwidth() < RTE_VECT_SIMD_128)
154 if (!priv->config.rx_vec_en)
156 if (mlx5_mprq_enabled(dev))
158 /* All the configured queues should support. */
159 for (i = 0; i < priv->rxqs_n; ++i) {
160 struct mlx5_rxq_data *rxq = (*priv->rxqs)[i];
164 if (mlx5_rxq_check_vec_support(rxq) < 0)
167 if (i != priv->rxqs_n)