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 v2 2/3] vhost: call vDPA callback at the end of vring enable handler
Date: Tue, 17 Sep 2019 17:09:47 +0800	[thread overview]
Message-ID: <1568711388-257817-2-git-send-email-andy.pei@intel.com> (raw)
In-Reply-To: <1568711388-257817-1-git-send-email-andy.pei@intel.com>

vDPA's set_vring_state callback would need to know the virtqueues'
enable status to configure the hardware.

Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
Signed-off-by: Andy Pei <andy.pei@intel.com>
---
v2:
 add nr_active_vring as a parameter to ops function set_vring_state in
 case of callback in set_vring_state() and avoid exposing new API.

 lib/librte_vhost/rte_vdpa.h   |  4 ++--
 lib/librte_vhost/vhost_user.c | 27 +++++++++++++++++++++++++--
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/lib/librte_vhost/rte_vdpa.h b/lib/librte_vhost/rte_vdpa.h
index 9a3deb3..6e55d4d 100644
--- a/lib/librte_vhost/rte_vdpa.h
+++ b/lib/librte_vhost/rte_vdpa.h
@@ -54,8 +54,8 @@ struct rte_vdpa_dev_ops {
 	int (*dev_conf)(int vid);
 	int (*dev_close)(int vid);
 
-	/** Enable/disable this vring */
-	int (*set_vring_state)(int vid, int vring, int state);
+	/** Enable/disable vring queue pairs */
+	int (*set_vring_state)(int vid, int nr_active_vring);
 
 	/** Set features when changed */
 	int (*set_features)(int vid);
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 0b72648..4d7de44 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1325,6 +1325,25 @@ static int vhost_user_set_vring_err(struct virtio_net **pdev __rte_unused,
 	return RTE_VHOST_MSG_RESULT_REPLY;
 }
 
+static uint16_t
+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;
+}
+
 /*
  * when virtio queues are ready to work, qemu will send us to
  * enable the virtio queue pair.
@@ -1339,6 +1358,7 @@ static int vhost_user_set_vring_err(struct virtio_net **pdev __rte_unused,
 	int index = (int)msg->payload.state.index;
 	struct rte_vdpa_device *vdpa_dev;
 	int did = -1;
+	int nr_active_vring;
 
 	RTE_LOG(INFO, VHOST_CONFIG,
 		"set queue enable: %d to qp idx: %d\n",
@@ -1346,8 +1366,6 @@ static int vhost_user_set_vring_err(struct virtio_net **pdev __rte_unused,
 
 	did = dev->vdpa_dev_id;
 	vdpa_dev = rte_vdpa_get_device(did);
-	if (vdpa_dev && vdpa_dev->ops->set_vring_state)
-		vdpa_dev->ops->set_vring_state(dev->vid, index, enable);
 
 	if (dev->notify_ops->vring_state_changed)
 		dev->notify_ops->vring_state_changed(dev->vid,
@@ -1359,6 +1377,11 @@ static int vhost_user_set_vring_err(struct virtio_net **pdev __rte_unused,
 
 	dev->virtqueue[index]->enabled = enable;
 
+	if (vdpa_dev && vdpa_dev->ops->set_vring_state) {
+		nr_active_vring = vhost_get_active_vring_num(dev->vid);
+		vdpa_dev->ops->set_vring_state(dev->vid, nr_active_vring);
+	}
+
 	return RTE_VHOST_MSG_RESULT_OK;
 }
 
-- 
1.8.3.1


  reply	other threads:[~2019-09-17  9:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-17  9:09 [dpdk-dev] [PATCH v2 1/3] net/ifcvf: add multiqueue configuration Andy Pei
2019-09-17  9:09 ` Andy Pei [this message]
2019-09-23  8:12   ` [dpdk-dev] [PATCH v2 2/3] vhost: call vDPA callback at the end of vring enable handler Tiwei Bie
2019-10-18 16:54     ` Ferruh Yigit
2019-09-17  9:09 ` [dpdk-dev] [PATCH v2 3/3] net/ifcvf: enable mutliqueue support Andy Pei

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=1568711388-257817-2-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).