From: Marvin Liu <yong.liu@intel.com>
To: tiwei.bie@intel.com, maxime.coquelin@redhat.com, dev@dpdk.org
Cc: Marvin Liu <yong.liu@intel.com>
Subject: [dpdk-dev] [RFC PATCH 12/13] support inorder in vhost dequeue path
Date: Tue, 9 Jul 2019 01:13:19 +0800 [thread overview]
Message-ID: <20190708171320.38802-13-yong.liu@intel.com> (raw)
In-Reply-To: <20190708171320.38802-1-yong.liu@intel.com>
When inorder feature bit is negotiated, just update first used
descriptor with last descriptor index. It can reflect all used
descriptors.
Signed-off-by: Marvin Liu <yong.liu@intel.com>
diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 0f9292eb0..6bcf565f0 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -31,6 +31,12 @@ rxvq_is_mergeable(struct virtio_net *dev)
return dev->features & (1ULL << VIRTIO_NET_F_MRG_RXBUF);
}
+static __rte_always_inline bool
+virtio_net_is_inorder(struct virtio_net *dev)
+{
+ return dev->features & (1ULL << VIRTIO_F_IN_ORDER);
+}
+
static bool
is_valid_virt_queue_idx(uint32_t idx, int is_tx, uint32_t nr_vring)
{
@@ -158,6 +164,35 @@ flush_shadow_used_ring_packed(struct virtio_net *dev,
vhost_log_cache_sync(dev, vq);
}
+static __rte_always_inline void
+flush_dequeue_shadow_used_packed_inorder(struct virtio_net *dev,
+ struct vhost_virtqueue *vq)
+{
+ uint16_t head_idx = vq->dequeue_shadow_head;
+ uint16_t head_flags = 0;
+ struct vring_used_elem_packed *last_elem;
+
+ last_elem = &vq->shadow_used_packed[vq->shadow_used_idx - 1];
+ vq->desc_packed[head_idx].id = last_elem->id + last_elem->count - 1;
+
+ if (vq->shadow_used_packed[0].used_wrap_counter)
+ head_flags = VIRTIO_TX_FLAG_PACKED;
+ else
+ head_flags = VIRTIO_TX_WRAP_FLAG_PACKED;
+
+ rte_smp_wmb();
+
+ vq->desc_packed[head_idx].flags = head_flags;
+
+ vhost_log_cache_used_vring(dev, vq,
+ head_idx *
+ sizeof(struct vring_packed_desc),
+ sizeof(struct vring_packed_desc));
+
+ vq->shadow_used_idx = 0;
+ vhost_log_cache_sync(dev, vq);
+}
+
static __rte_always_inline void
flush_enqueue_used_packed(struct virtio_net *dev,
struct vhost_virtqueue *vq)
@@ -269,6 +304,34 @@ flush_dequeue_shadow_used_packed(struct virtio_net *dev,
vhost_log_cache_sync(dev, vq);
}
+static __rte_always_inline void
+flush_used_fast_packed_inorder(struct virtio_net *dev,
+ struct vhost_virtqueue *vq, uint64_t len,
+ uint64_t len1, uint64_t len2, uint64_t len3,
+ uint16_t id, uint16_t flags)
+{
+ vq->desc_packed[vq->last_used_idx].id = id;
+ vq->desc_packed[vq->last_used_idx].len = len;
+ vq->desc_packed[vq->last_used_idx + 1].len = len1;
+ vq->desc_packed[vq->last_used_idx + 2].len = len2;
+ vq->desc_packed[vq->last_used_idx + 3].len = len3;
+
+ rte_smp_wmb();
+ vq->desc_packed[vq->last_used_idx].flags = flags;
+
+ vhost_log_cache_used_vring(dev, vq,
+ vq->last_used_idx *
+ sizeof(struct vring_packed_desc),
+ RTE_CACHE_LINE_SIZE);
+ vhost_log_cache_sync(dev, vq);
+
+ vq->last_used_idx += PACKED_DESC_PER_CACHELINE;
+ if (vq->last_used_idx >= vq->size) {
+ vq->used_wrap_counter ^= 1;
+ vq->last_used_idx -= vq->size;
+ }
+}
+
/* flags are same when flushing used ring in fast path */
static __rte_always_inline void
flush_used_fast_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,
@@ -320,8 +383,12 @@ flush_dequeue_fast_used_packed(struct virtio_net *dev,
flags = VIRTIO_TX_FLAG_PACKED;
else
flags = VIRTIO_TX_WRAP_FLAG_PACKED;
-
- flush_used_fast_packed(dev, vq, 0, 0, 0, 0, id, id1, id2, id3, flags);
+ if (virtio_net_is_inorder(dev))
+ flush_used_fast_packed_inorder(dev, vq, 0, 0, 0, 0, id3,
+ flags);
+ else
+ flush_used_fast_packed(dev, vq, 0, 0, 0, 0, id, id1, id2, id3,
+ flags);
}
static __rte_always_inline void
@@ -451,7 +518,10 @@ flush_dequeue_shadow_used(struct virtio_net *dev, struct vhost_virtqueue *vq)
shadow_count += vq->last_used_idx & 0x3;
if ((uint16_t)shadow_count >= (vq->size >> 1)) {
do_data_copy_dequeue(vq);
- flush_dequeue_shadow_used_packed(dev, vq);
+ if (virtio_net_is_inorder(dev))
+ flush_dequeue_shadow_used_packed_inorder(dev, vq);
+ else
+ flush_dequeue_shadow_used_packed(dev, vq);
vhost_vring_call_packed(dev, vq);
}
}
--
2.17.1
next prev parent reply other threads:[~2019-07-08 9:31 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-08 17:13 [dpdk-dev] [RFC] vhost packed ring performance optimization Marvin Liu
2019-07-08 17:13 ` [dpdk-dev] [RFC PATCH 01/13] add vhost normal enqueue function Marvin Liu
2019-07-08 17:13 ` [dpdk-dev] [RFC PATCH 02/13] add vhost packed ring fast " Marvin Liu
[not found] ` <CGME20190708113801eucas1p25d89717d8b298790326077852c9933c8@eucas1p2.samsung.com>
2019-07-08 11:37 ` Ilya Maximets
2019-07-09 1:15 ` Liu, Yong
2019-07-10 4:28 ` Jason Wang
2019-07-10 7:30 ` Liu, Yong
2019-07-11 4:11 ` Jason Wang
2019-07-11 9:49 ` Liu, Yong
2019-07-11 9:54 ` Jason Wang
2019-08-13 9:02 ` Liu, Yong
2019-07-11 8:35 ` Jason Wang
2019-07-11 9:37 ` Liu, Yong
2019-07-11 9:44 ` Jason Wang
2019-07-08 17:13 ` [dpdk-dev] [RFC PATCH 03/13] add vhost packed ring normal dequeue function Marvin Liu
2019-07-08 17:13 ` [dpdk-dev] [RFC PATCH 04/13] add vhost packed ring fast " Marvin Liu
2019-07-08 17:13 ` [dpdk-dev] [RFC PATCH 05/13] add enqueue shadow used descs update and flush functions Marvin Liu
2019-07-08 17:13 ` [dpdk-dev] [RFC PATCH 06/13] add vhost fast enqueue flush function Marvin Liu
2019-07-08 17:13 ` [dpdk-dev] [RFC PATCH 07/13] add vhost dequeue shadow descs update function Marvin Liu
2019-07-08 17:13 ` [dpdk-dev] [RFC PATCH 08/13] add vhost fast dequeue flush function Marvin Liu
2019-07-08 17:13 ` [dpdk-dev] [RFC PATCH 09/13] replace vhost enqueue packed ring function Marvin Liu
2019-07-08 17:13 ` [dpdk-dev] [RFC PATCH 10/13] add vhost fast zero copy dequeue " Marvin Liu
2019-07-08 17:13 ` [dpdk-dev] [RFC PATCH 11/13] replace vhost " Marvin Liu
2019-07-08 17:13 ` Marvin Liu [this message]
2019-07-08 17:13 ` [dpdk-dev] [RFC PATCH 13/13] remove useless vhost functions Marvin Liu
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=20190708171320.38802-13-yong.liu@intel.com \
--to=yong.liu@intel.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=tiwei.bie@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).