net/mlx5: prefetch CQEs for a faster decompression
[dpdk.git] / drivers / net / mlx5 / mlx5_rxtx_vec_neon.h
index 5b846c1..7b6c5db 100644 (file)
@@ -6,7 +6,6 @@
 #ifndef RTE_PMD_MLX5_RXTX_VEC_NEON_H_
 #define RTE_PMD_MLX5_RXTX_VEC_NEON_H_
 
-#include <assert.h>
 #include <stdint.h>
 #include <string.h>
 #include <stdlib.h>
@@ -146,9 +145,9 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
                                    -1UL << ((mcqe_n - pos) *
                                             sizeof(uint16_t) * 8) : 0);
 #endif
-
-               if (!(pos & 0x7) && pos + 8 < mcqe_n)
-                       rte_prefetch0((void *)(cq + pos + 8));
+               for (i = 0; i < MLX5_VPMD_DESCS_PER_LOOP; ++i)
+                       if (likely(pos + i < mcqe_n))
+                               rte_prefetch0((void *)(cq + pos + i));
                __asm__ volatile (
                /* A.1 load mCQEs into a 128bit register. */
                "ld1 {v16.16b - v17.16b}, [%[mcq]] \n\t"
@@ -206,6 +205,19 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
                        elts[pos + 2]->hash.fdir.hi = flow_tag;
                        elts[pos + 3]->hash.fdir.hi = flow_tag;
                }
+               if (rte_flow_dynf_metadata_avail()) {
+                       const uint32_t meta = *RTE_FLOW_DYNF_METADATA(t_pkt);
+
+                       /* Check if title packet has valid metadata. */
+                       if (meta) {
+                               MLX5_ASSERT(t_pkt->ol_flags &
+                                           PKT_RX_DYNF_METADATA);
+                               *RTE_FLOW_DYNF_METADATA(elts[pos]) = meta;
+                               *RTE_FLOW_DYNF_METADATA(elts[pos + 1]) = meta;
+                               *RTE_FLOW_DYNF_METADATA(elts[pos + 2]) = meta;
+                               *RTE_FLOW_DYNF_METADATA(elts[pos + 3]) = meta;
+                       }
+               }
                pos += MLX5_VPMD_DESCS_PER_LOOP;
                /* Move to next CQE and invalidate consumed CQEs. */
                if (!(pos & 0x7) && pos < mcqe_n) {
@@ -440,8 +452,8 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,
        };
        const uint32x4_t flow_mark_adj = { 0, 0, 0, rxq->mark * (-1) };
 
-       assert(rxq->sges_n == 0);
-       assert(rxq->cqe_n == rxq->elts_n);
+       MLX5_ASSERT(rxq->sges_n == 0);
+       MLX5_ASSERT(rxq->cqe_n == rxq->elts_n);
        cq = &(*rxq->cqes)[cq_idx];
        rte_prefetch_non_temporal(cq);
        rte_prefetch_non_temporal(cq + 1);
@@ -470,7 +482,7 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,
        if (!pkts_n)
                return rcvd_pkt;
        /* At this point, there shouldn't be any remained packets. */
-       assert(rxq->decompressed == 0);
+       MLX5_ASSERT(rxq->decompressed == 0);
        /*
         * Note that vectors have reverse order - {v3, v2, v1, v0}, because
         * there's no instruction to count trailing zeros. __builtin_clzl() is
@@ -728,7 +740,7 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,
        if (unlikely(!nocmp_n && comp_idx == MLX5_VPMD_DESCS_PER_LOOP))
                return rcvd_pkt;
        /* Update the consumer indexes for non-compressed CQEs. */
-       assert(nocmp_n <= pkts_n);
+       MLX5_ASSERT(nocmp_n <= pkts_n);
        rxq->cq_ci += nocmp_n;
        rxq->rq_pi += nocmp_n;
        rcvd_pkt += nocmp_n;
@@ -738,7 +750,7 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,
 #endif
        /* Decompress the last CQE if compressed. */
        if (comp_idx < MLX5_VPMD_DESCS_PER_LOOP && comp_idx == n) {
-               assert(comp_idx == (nocmp_n % MLX5_VPMD_DESCS_PER_LOOP));
+               MLX5_ASSERT(comp_idx == (nocmp_n % MLX5_VPMD_DESCS_PER_LOOP));
                rxq->decompressed = rxq_cq_decompress_v(rxq, &cq[nocmp_n],
                                                        &elts[nocmp_n]);
                /* Return more packets if needed. */