> -----Original Message----- > From: Maxime Coquelin <maxime.coque...@redhat.com> > Sent: Wednesday, May 11, 2022 4:17 AM > To: dev@dpdk.org; Xia, Chenbo <chenbo....@intel.com>; > david.march...@redhat.com; i.maxim...@ovn.org > Cc: Maxime Coquelin <maxime.coque...@redhat.com> > Subject: [PATCH 5/5] vhost: add statistics for in-flight packets > > This patch adds statistics for packets in-flight submission > and completion, when Vhost async mode is used. > > Signed-off-by: Maxime Coquelin <maxime.coque...@redhat.com> > --- > lib/vhost/vhost.c | 2 ++ > lib/vhost/vhost.h | 2 ++ > lib/vhost/virtio_net.c | 6 ++++++ > 3 files changed, 10 insertions(+) > > diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c > index 721b3a3247..d9d31b2d03 100644 > --- a/lib/vhost/vhost.c > +++ b/lib/vhost/vhost.c > @@ -45,6 +45,8 @@ static const struct vhost_vq_stats_name_off > vhost_vq_stat_strings[] = { > {"guest_notifications", offsetof(struct vhost_virtqueue, > stats.guest_notifications)}, > {"iotlb_hits", offsetof(struct vhost_virtqueue, > stats.iotlb_hits)}, > {"iotlb_misses", offsetof(struct vhost_virtqueue, > stats.iotlb_misses)}, > + {"inflight_submitted", offsetof(struct vhost_virtqueue, > stats.inflight_submitted)}, > + {"inflight_completed", offsetof(struct vhost_virtqueue, > stats.inflight_completed)}, > }; > > #define VHOST_NB_VQ_STATS RTE_DIM(vhost_vq_stat_strings) > diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h > index 872675207e..1573d0afe9 100644 > --- a/lib/vhost/vhost.h > +++ b/lib/vhost/vhost.h > @@ -136,6 +136,8 @@ struct virtqueue_stats { > uint64_t guest_notifications; > uint64_t iotlb_hits; > uint64_t iotlb_misses; > + uint64_t inflight_submitted; > + uint64_t inflight_completed; > }; > > /** > diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c > index b1ea9fa4a5..c8905c770a 100644 > --- a/lib/vhost/virtio_net.c > +++ b/lib/vhost/virtio_net.c > @@ -2115,6 +2115,7 @@ rte_vhost_poll_enqueue_completed(int vid, uint16_t > queue_id, > n_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id, pkts, count, > dma_id, vchan_id); > > vhost_queue_stats_update(dev, vq, pkts, n_pkts_cpl); > + vq->stats.inflight_completed += n_pkts_cpl; > > out: > rte_spinlock_unlock(&vq->access_lock); > @@ -2158,6 +2159,9 @@ rte_vhost_clear_queue_thread_unsafe(int vid, > uint16_t queue_id, > > n_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id, pkts, count, > dma_id, vchan_id); > > + vhost_queue_stats_update(dev, vq, pkts, n_pkts_cpl); > + vq->stats.inflight_completed += n_pkts_cpl; > + > return n_pkts_cpl; > } > > @@ -2207,6 +2211,8 @@ virtio_dev_rx_async_submit(struct virtio_net *dev, > uint16_t queue_id, > nb_tx = virtio_dev_rx_async_submit_split(dev, vq, queue_id, > pkts, count, dma_id, vchan_id); > > + vq->stats.inflight_submitted += nb_tx; > + > out: > if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) > vhost_user_iotlb_rd_unlock(vq); > -- > 2.35.1
Reviewed-by: Chenbo Xia <chenbo....@intel.com>