DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andy Pei <andy.pei@intel.com>
To: dev@dpdk.org
Cc: rosen.xu@intel.com, xiaolong.ye@intel.com, tiwei.bie@intel.com,
	xiao.w.wang@intel.com
Subject: [dpdk-dev] [PATCH 1/4] vhost: introduce new API to get the active vring number
Date: Fri,  6 Sep 2019 11:20:48 +0800	[thread overview]
Message-ID: <1567740051-367172-1-git-send-email-andy.pei@intel.com> (raw)

It's useful for hardware vhost backend (like vDPA devices) to set
multiqueue configuration accordingly.

Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
Signed-off-by: Andy Pei <andy.pei@intel.com>
---
 lib/librte_vhost/rte_vhost.h | 12 ++++++++++++
 lib/librte_vhost/vhost.c     | 19 +++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
index 7fb1729..28811b0 100644
--- a/lib/librte_vhost/rte_vhost.h
+++ b/lib/librte_vhost/rte_vhost.h
@@ -525,6 +525,18 @@ int rte_vhost_driver_callback_register(const char *path,
 uint16_t rte_vhost_get_vring_num(int vid);
 
 /**
+ * Get the number of active vrings of the device.
+ *
+ * @param vid
+ *  vhost device ID
+ *
+ * @return
+ *  The number of active vrings, 0 on failure
+ */
+uint16_t
+rte_vhost_get_active_vring_num(int vid);
+
+/**
  * Get the virtio net device's ifname, which is the vhost-user socket
  * file path.
  *
diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index 981837b..c714818 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -674,6 +674,25 @@
 	return dev->nr_vring;
 }
 
+uint16_t
+rte_vhost_get_active_vring_num(int vid)
+{
+	struct virtio_net *dev = get_device(vid);
+	struct vhost_virtqueue *vq;
+	uint16_t qid;
+
+	if (dev == NULL)
+		return 0;
+
+	for (qid = 0; qid < dev->nr_vring; qid++) {
+		vq = dev->virtqueue[qid];
+		if (!vq->enabled)
+			break;
+	}
+
+	return qid;
+}
+
 int
 rte_vhost_get_ifname(int vid, char *buf, size_t len)
 {
-- 
1.8.3.1


             reply	other threads:[~2019-09-06  3:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-06  3:20 Andy Pei [this message]
2019-09-06  3:20 ` [dpdk-dev] [PATCH 2/4] net/ifcvf: add multiqueue configuration Andy Pei
2019-09-06  3:20 ` [dpdk-dev] [PATCH 3/4] vhost: call vDPA callback at the end of vring enable handler Andy Pei
2019-09-12  7:41   ` Wang, Xiao W
2019-09-17  7:29     ` Pei, Andy
2019-09-06  3:20 ` [dpdk-dev] [PATCH 4/4] net/ifcvf: enable mutliqueue support Andy Pei
2019-09-12  7:41   ` Wang, Xiao W
2019-09-06 13:25 ` [dpdk-dev] [PATCH 1/4] vhost: introduce new API to get the active vring number Aaron Conole
2019-09-17  9:25   ` Pei, Andy

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=1567740051-367172-1-git-send-email-andy.pei@intel.com \
    --to=andy.pei@intel.com \
    --cc=dev@dpdk.org \
    --cc=rosen.xu@intel.com \
    --cc=tiwei.bie@intel.com \
    --cc=xiao.w.wang@intel.com \
    --cc=xiaolong.ye@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).