net/virtio: fix Rx stats with vectorized functions
authorThibaut Collet <thibaut.collet@6wind.com>
Wed, 11 Sep 2019 16:04:08 +0000 (18:04 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 7 Oct 2019 13:00:57 +0000 (15:00 +0200)
With vectorized functions, only the rx stats for number of packets is
incremented.
Update also the other statistics.
Performance impact is about 2%

Fixes: fc3d66212fed ("virtio: add vector Rx")
Cc: stable@dpdk.org
Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/net/virtio/virtio_rxtx.c
drivers/net/virtio/virtio_rxtx.h
drivers/net/virtio/virtio_rxtx_simple_neon.c
drivers/net/virtio/virtio_rxtx_simple_sse.c

index e1c0e28..42f2beb 100644 (file)
@@ -106,7 +106,7 @@ vq_ring_free_id_packed(struct virtqueue *vq, uint16_t id)
        dxp->next = VQ_RING_DESC_CHAIN_END;
 }
 
-static inline void
+void
 virtio_update_packet_stats(struct virtnet_stats *stats, struct rte_mbuf *mbuf)
 {
        uint32_t s = mbuf->pkt_len;
index 685cc4f..1eb8dae 100644 (file)
@@ -59,5 +59,7 @@ struct virtnet_ctl {
 };
 
 int virtio_rxq_vec_setup(struct virtnet_rx *rxvq);
+void virtio_update_packet_stats(struct virtnet_stats *stats,
+                               struct rte_mbuf *mbuf);
 
 #endif /* _VIRTIO_RXTX_H_ */
index cdc2a4d..70e89fc 100644 (file)
@@ -47,6 +47,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
        struct vring_used_elem *rused;
        struct rte_mbuf **sw_ring;
        struct rte_mbuf **sw_ring_end;
+       struct rte_mbuf **ref_rx_pkts;
        uint16_t nb_pkts_received = 0;
 
        uint8x16_t shuf_msk1 = {
@@ -105,6 +106,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
                        virtqueue_notify(vq);
        }
 
+       ref_rx_pkts = rx_pkts;
        for (nb_pkts_received = 0;
                nb_pkts_received < nb_used;) {
                uint64x2_t desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
@@ -204,5 +206,8 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
        vq->vq_used_cons_idx += nb_pkts_received;
        vq->vq_free_cnt += nb_pkts_received;
        rxvq->stats.packets += nb_pkts_received;
+       for (nb_used = 0; nb_used < nb_pkts_received; nb_used++)
+               virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
+
        return nb_pkts_received;
 }
index af76708..cb1610e 100644 (file)
@@ -48,6 +48,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
        struct vring_used_elem *rused;
        struct rte_mbuf **sw_ring;
        struct rte_mbuf **sw_ring_end;
+       struct rte_mbuf **ref_rx_pkts;
        uint16_t nb_pkts_received = 0;
        __m128i shuf_msk1, shuf_msk2, len_adjust;
 
@@ -107,6 +108,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
                        virtqueue_notify(vq);
        }
 
+       ref_rx_pkts = rx_pkts;
        for (nb_pkts_received = 0;
                nb_pkts_received < nb_used;) {
                __m128i desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
@@ -190,5 +192,8 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
        vq->vq_used_cons_idx += nb_pkts_received;
        vq->vq_free_cnt += nb_pkts_received;
        rxvq->stats.packets += nb_pkts_received;
+       for (nb_used = 0; nb_used < nb_pkts_received; nb_used++)
+               virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
+
        return nb_pkts_received;
 }