net/mlx5: switch Rx timestamp to dynamic mbuf field
[dpdk.git] / drivers / net / mlx5 / mlx5_rxtx_vec_altivec.h
index d55642e..171d7bb 100644 (file)
@@ -10,7 +10,7 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include <altivec.h>
+#include <rte_altivec.h>
 
 #include <rte_mbuf.h>
 #include <rte_mempool.h>
@@ -155,9 +155,9 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
                const vector unsigned long shmax = {64, 64};
 #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));
                /* A.1 load mCQEs into a 128bit register. */
                mcqe1 = (vector unsigned char)vec_vsx_ld(0,
                        (signed int const *)&mcq[pos % 8]);
@@ -263,23 +263,31 @@ 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);
+               if (rxq->dynf_meta) {
+                       int32_t offs = rxq->flow_meta_offset;
+                       const uint32_t meta =
+                               *RTE_MBUF_DYNFIELD(t_pkt, offs, uint32_t *);
 
                        /* 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;
+                                           rxq->flow_meta_mask);
+                               *RTE_MBUF_DYNFIELD(elts[pos], offs,
+                                                       uint32_t *) = meta;
+                               *RTE_MBUF_DYNFIELD(elts[pos + 1], offs,
+                                                       uint32_t *) = meta;
+                               *RTE_MBUF_DYNFIELD(elts[pos + 2], offs,
+                                                       uint32_t *) = meta;
+                               *RTE_MBUF_DYNFIELD(elts[pos + 3], offs,
+                                                       uint32_t *) = meta;
                        }
                }
 
                pos += MLX5_VPMD_DESCS_PER_LOOP;
                /* Move to next CQE and invalidate consumed CQEs. */
                if (!(pos & 0x7) && pos < mcqe_n) {
+                       if (pos + 8 < mcqe_n)
+                               rte_prefetch0((void *)(cq + pos + 8));
                        mcq = (void *)&(cq + pos)->pkt_info;
                        for (i = 0; i < 8; ++i)
                                cq[inv++].op_own = MLX5_CQE_INVALIDATE;
@@ -322,13 +330,13 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq,
        vector unsigned char ol_flags = (vector unsigned char)
                (vector unsigned int){
                        rxq->rss_hash * PKT_RX_RSS_HASH |
-                               rxq->hw_timestamp * PKT_RX_TIMESTAMP,
+                               rxq->hw_timestamp * rxq->timestamp_rx_flag,
                        rxq->rss_hash * PKT_RX_RSS_HASH |
-                               rxq->hw_timestamp * PKT_RX_TIMESTAMP,
+                               rxq->hw_timestamp * rxq->timestamp_rx_flag,
                        rxq->rss_hash * PKT_RX_RSS_HASH |
-                               rxq->hw_timestamp * PKT_RX_TIMESTAMP,
+                               rxq->hw_timestamp * rxq->timestamp_rx_flag,
                        rxq->rss_hash * PKT_RX_RSS_HASH |
-                               rxq->hw_timestamp * PKT_RX_TIMESTAMP};
+                               rxq->hw_timestamp * rxq->timestamp_rx_flag};
        vector unsigned char cv_flags;
        const vector unsigned char zero = (vector unsigned char){0};
        const vector unsigned char ptype_mask =
@@ -557,13 +565,15 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq,
  * @param[out] err
  *   Pointer to a flag. Set non-zero value if pkts array has at least one error
  *   packet to handle.
+ * @param[out] no_cq
+ *  Pointer to a boolean. Set true if no new CQE seen.
  *
  * @return
  *   Number of packets received including errors (<= pkts_n).
  */
 static inline uint16_t
 rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,
-           uint64_t *err)
+           uint64_t *err, bool *no_cq)
 {
        const uint16_t q_n = 1 << rxq->cqe_n;
        const uint16_t q_mask = q_n - 1;
@@ -656,8 +666,10 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,
        /* Not to cross queue end. */
        pkts_n = RTE_MIN(pkts_n, q_n - elts_idx);
        pkts_n = RTE_MIN(pkts_n, q_n - cq_idx);
-       if (!pkts_n)
+       if (!pkts_n) {
+               *no_cq = !rcvd_pkt;
                return rcvd_pkt;
+       }
        /* At this point, there shouldn't be any remaining packets. */
        MLX5_ASSERT(rxq->decompressed == 0);
 
@@ -776,7 +788,7 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,
                /* B.2 copy mbuf pointers. */
                *(vector unsigned char *)&pkts[pos] = mbp1;
                *(vector unsigned char *)&pkts[pos + 2] = mbp2;
-               rte_cio_rmb();
+               rte_io_rmb();
 
                /* C.1 load remaining CQE data and extract necessary fields. */
                cqe_tmp2 = *(vector unsigned char *)
@@ -1013,18 +1025,37 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,
                /* D.5 fill in mbuf - rearm_data and packet_type. */
                rxq_cq_to_ptype_oflags_v(rxq, cqes, opcode, &pkts[pos]);
                if (rxq->hw_timestamp) {
-                       pkts[pos]->timestamp =
-                               rte_be_to_cpu_64(cq[pos].timestamp);
-                       pkts[pos + 1]->timestamp =
-                               rte_be_to_cpu_64(cq[pos + p1].timestamp);
-                       pkts[pos + 2]->timestamp =
-                               rte_be_to_cpu_64(cq[pos + p2].timestamp);
-                       pkts[pos + 3]->timestamp =
-                               rte_be_to_cpu_64(cq[pos + p3].timestamp);
+                       int offset = rxq->timestamp_offset;
+                       if (rxq->rt_timestamp) {
+                               struct mlx5_dev_ctx_shared *sh = rxq->sh;
+                               uint64_t ts;
+
+                               ts = rte_be_to_cpu_64(cq[pos].timestamp);
+                               mlx5_timestamp_set(pkts[pos], offset,
+                                       mlx5_txpp_convert_rx_ts(sh, ts));
+                               ts = rte_be_to_cpu_64(cq[pos + p1].timestamp);
+                               mlx5_timestamp_set(pkts[pos + 1], offset,
+                                       mlx5_txpp_convert_rx_ts(sh, ts));
+                               ts = rte_be_to_cpu_64(cq[pos + p2].timestamp);
+                               mlx5_timestamp_set(pkts[pos + 2], offset,
+                                       mlx5_txpp_convert_rx_ts(sh, ts));
+                               ts = rte_be_to_cpu_64(cq[pos + p3].timestamp);
+                               mlx5_timestamp_set(pkts[pos + 3], offset,
+                                       mlx5_txpp_convert_rx_ts(sh, ts));
+                       } else {
+                               mlx5_timestamp_set(pkts[pos], offset,
+                                       rte_be_to_cpu_64(cq[pos].timestamp));
+                               mlx5_timestamp_set(pkts[pos + 1], offset,
+                                       rte_be_to_cpu_64(cq[pos + p1].timestamp));
+                               mlx5_timestamp_set(pkts[pos + 2], offset,
+                                       rte_be_to_cpu_64(cq[pos + p2].timestamp));
+                               mlx5_timestamp_set(pkts[pos + 3], offset,
+                                       rte_be_to_cpu_64(cq[pos + p3].timestamp));
+                       }
                }
-               if (rte_flow_dynf_metadata_avail()) {
-                       uint64_t flag = rte_flow_dynf_metadata_mask;
-                       int offs = rte_flow_dynf_metadata_offs;
+               if (rxq->dynf_meta) {
+                       uint64_t flag = rxq->flow_meta_mask;
+                       int32_t offs = rxq->flow_meta_offset;
                        uint32_t metadata;
 
                        /* This code is subject for futher optimization. */
@@ -1072,8 +1103,10 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,
                        break;
        }
        /* If no new CQE seen, return without updating cq_db. */
-       if (unlikely(!nocmp_n && comp_idx == MLX5_VPMD_DESCS_PER_LOOP))
+       if (unlikely(!nocmp_n && comp_idx == MLX5_VPMD_DESCS_PER_LOOP)) {
+               *no_cq = true;
                return rcvd_pkt;
+       }
        /* Update the consumer indexes for non-compressed CQEs. */
        MLX5_ASSERT(nocmp_n <= pkts_n);
        rxq->cq_ci += nocmp_n;
@@ -1101,6 +1134,7 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,
        }
        rte_compiler_barrier();
        *rxq->cq_db = rte_cpu_to_be_32(rxq->cq_ci);
+       *no_cq = !rcvd_pkt;
        return rcvd_pkt;
 }