DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thierry Herbelot <thierry.herbelot@6wind.com>
To: dev@dpdk.org
Cc: Thibaut Collet <thibaut.collet@6wind.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	stable@dpdk.org, maxime.coquelin@redhat.com, tiwei.bie@intel.com,
	zhihong.wang@intel.com
Subject: [dpdk-dev] [PATCH 1/2] virtio: fix rx stats with vectorized functions
Date: Wed, 11 Sep 2019 18:04:08 +0200	[thread overview]
Message-ID: <cf2cbf6ab9f0f8d1a49960d78b246c01ec8b1375.1568216827.git.thierry.herbelot@6wind.com> (raw)
In-Reply-To: <cover.1568216827.git.thierry.herbelot@6wind.com>

From: Thibaut Collet <thibaut.collet@6wind.com>

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
Cc: maxime.coquelin@redhat.com
Cc: tiwei.bie@intel.com
Cc: zhihong.wang@intel.com

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
---
 drivers/net/virtio/virtio_rxtx.c             | 2 +-
 drivers/net/virtio/virtio_rxtx.h             | 2 ++
 drivers/net/virtio/virtio_rxtx_simple_neon.c | 5 +++++
 drivers/net/virtio/virtio_rxtx_simple_sse.c  | 5 +++++
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 27ead19fbe81..6dd62bf51863 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -1083,7 +1083,7 @@ virtio_discard_rxbuf_inorder(struct virtqueue *vq, struct rte_mbuf *m)
 	}
 }
 
-static inline void
+void
 virtio_update_packet_stats(struct virtnet_stats *stats, struct rte_mbuf *mbuf)
 {
 	uint32_t s = mbuf->pkt_len;
diff --git a/drivers/net/virtio/virtio_rxtx.h b/drivers/net/virtio/virtio_rxtx.h
index 685cc4f8104c..1eb8dae227ee 100644
--- a/drivers/net/virtio/virtio_rxtx.h
+++ b/drivers/net/virtio/virtio_rxtx.h
@@ -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_ */
diff --git a/drivers/net/virtio/virtio_rxtx_simple_neon.c b/drivers/net/virtio/virtio_rxtx_simple_neon.c
index cdc2a4d28ed5..70e89fc428e0 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_neon.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_neon.c
@@ -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;
 }
diff --git a/drivers/net/virtio/virtio_rxtx_simple_sse.c b/drivers/net/virtio/virtio_rxtx_simple_sse.c
index af76708d66ae..cb1610e71563 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_sse.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_sse.c
@@ -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;
 }
-- 
2.20.1


  reply	other threads:[~2019-09-11 16:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-11 16:04 [dpdk-dev] [PATCH 0/2] Fixes in virtio " Thierry Herbelot
2019-09-11 16:04 ` Thierry Herbelot [this message]
2019-09-27  9:08   ` [dpdk-dev] [PATCH 1/2] virtio: fix rx stats with " Maxime Coquelin
2019-09-30 18:04   ` [dpdk-dev] [PATCH] net/virtio: fix Rx stats with altivec " David Christensen
2019-09-11 16:04 ` [dpdk-dev] [PATCH 2/2] virtio: get all pending rx packets with " Thierry Herbelot
2019-09-27  9:09   ` Maxime Coquelin
2019-09-30 18:27   ` [dpdk-dev] [PATCH] net/virtio: fix Rx stats with altivec " David Christensen
2019-10-01 10:00     ` Maxime Coquelin
2019-10-16 11:11     ` Maxime Coquelin
2019-09-30 18:42   ` [dpdk-dev] [PATCH] net/virtio: get all pending Rx packets in altivec vectorized paths David Christensen
2019-10-01 10:06     ` Maxime Coquelin
2019-10-16 11:11     ` Maxime Coquelin
2019-09-27  9:11 ` [dpdk-dev] [PATCH 0/2] Fixes in virtio vectorized functions Maxime Coquelin
2019-09-27  9:50 ` Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cf2cbf6ab9f0f8d1a49960d78b246c01ec8b1375.1568216827.git.thierry.herbelot@6wind.com \
    --to=thierry.herbelot@6wind.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    --cc=thibaut.collet@6wind.com \
    --cc=thomas@monjalon.net \
    --cc=tiwei.bie@intel.com \
    --cc=zhihong.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).