DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: dev@dpdk.org, chenbo.xia@intel.com, patrick.fu@intel.com,
	amorenoz@redhat.com
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [dpdk-dev] [PATCH v3 6/8] net/virtio: adapt Virtio-user status size
Date: Tue, 29 Sep 2020 18:14:02 +0200	[thread overview]
Message-ID: <20200929161404.124580-7-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20200929161404.124580-1-maxime.coquelin@redhat.com>

Set proper payload size for set/get status message. The payload
size varies according to backend types.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Signed-off-by: Patrick Fu <patrick.fu@intel.com>
---
 .../net/virtio/virtio_user/virtio_user_dev.c  | 34 +++++++++++++------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index d7cd6b0346..ded44bf32b 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -784,11 +784,15 @@ virtio_user_send_status_update(struct virtio_user_dev *dev, uint8_t status)
 	int ret;
 	uint64_t arg = status;
 
-	/* Vhost-user only for now */
-	if (dev->backend_type != VIRTIO_USER_BACKEND_VHOST_USER)
+	if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER)
+		ret = dev->ops->send_request(dev,
+				VHOST_USER_SET_STATUS, &arg);
+	else if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_VDPA)
+		ret = dev->ops->send_request(dev,
+				VHOST_USER_SET_STATUS, &status);
+	else
 		return 0;
 
-	ret = dev->ops->send_request(dev, VHOST_USER_SET_STATUS, &arg);
 	if (ret) {
 		PMD_INIT_LOG(ERR, "VHOST_USER_SET_STATUS failed (%d): %s", ret,
 			     strerror(errno));
@@ -802,24 +806,32 @@ int
 virtio_user_update_status(struct virtio_user_dev *dev)
 {
 	uint64_t ret;
+	uint8_t status;
 	int err;
 
-	/* Vhost-user only for now */
-	if (dev->backend_type != VIRTIO_USER_BACKEND_VHOST_USER)
+	if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER) {
+		err = dev->ops->send_request(dev, VHOST_USER_GET_STATUS, &ret);
+		if (!err && ret > UINT8_MAX) {
+			PMD_INIT_LOG(ERR, "Invalid VHOST_USER_GET_STATUS "
+					"response 0x%" PRIx64 "\n", ret);
+			return -1;
+		}
+
+		status = ret;
+	} else if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_VDPA) {
+		err = dev->ops->send_request(dev, VHOST_USER_GET_STATUS,
+				&status);
+	} else {
 		return 0;
+	}
 
-	err = dev->ops->send_request(dev, VHOST_USER_GET_STATUS, &ret);
 	if (err) {
 		PMD_INIT_LOG(ERR, "VHOST_USER_GET_STATUS failed (%d): %s", err,
 			     strerror(errno));
 		return -1;
 	}
-	if (ret > UINT8_MAX) {
-		PMD_INIT_LOG(ERR, "Invalid VHOST_USER_GET_STATUS response 0x%" PRIx64 "\n", ret);
-		return -1;
-	}
 
-	dev->status = ret;
+	dev->status = status;
 	PMD_INIT_LOG(DEBUG, "Updated Device Status(0x%08x):\n"
 			"\t-RESET: %u\n"
 			"\t-ACKNOWLEDGE: %u\n"
-- 
2.26.2


  parent reply	other threads:[~2020-09-29 16:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 16:13 [dpdk-dev] [PATCH v3 0/8] virtio-user: introduce vhost-vdpa backend Maxime Coquelin
2020-09-29 16:13 ` [dpdk-dev] [PATCH v3 1/8] bus/vdev: add DMA mapping ops Maxime Coquelin
2020-09-30  5:47   ` Xia, Chenbo
2020-09-29 16:13 ` [dpdk-dev] [PATCH v3 2/8] net/virtio: introduce DMA ops Maxime Coquelin
2020-09-30  5:47   ` Xia, Chenbo
2020-09-29 16:13 ` [dpdk-dev] [PATCH v3 3/8] net/virtio: move backend type selection to ethdev Maxime Coquelin
2020-09-30  5:49   ` Xia, Chenbo
2020-10-16  5:42   ` Wang, Yinan
2020-10-16  5:58     ` Wang, Yinan
2020-10-20  1:52     ` Wang, Yinan
2020-10-20  7:11       ` Maxime Coquelin
2020-10-20  7:20         ` Adrian Moreno
2020-09-29 16:14 ` [dpdk-dev] [PATCH v3 4/8] net/virtio: introduce Vhost-vDPA backend type Maxime Coquelin
2020-09-30  5:49   ` Xia, Chenbo
2020-09-29 16:14 ` [dpdk-dev] [PATCH v3 5/8] net/virtio: check protocol feature in user backend Maxime Coquelin
2020-09-30  5:49   ` Xia, Chenbo
2020-09-29 16:14 ` Maxime Coquelin [this message]
2020-09-30  5:49   ` [dpdk-dev] [PATCH v3 6/8] net/virtio: adapt Virtio-user status size Xia, Chenbo
2020-09-29 16:14 ` [dpdk-dev] [PATCH v3 7/8] net/virtio: split virtio-user start Maxime Coquelin
2020-09-30  5:49   ` Xia, Chenbo
2020-09-29 16:14 ` [dpdk-dev] [PATCH v3 8/8] net/virtio: introduce Vhost-vDPA backend Maxime Coquelin
2020-09-30  5:49   ` Xia, Chenbo
2020-09-30 16:22 ` [dpdk-dev] [PATCH v3 0/8] virtio-user: introduce vhost-vdpa backend 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=20200929161404.124580-7-maxime.coquelin@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=amorenoz@redhat.com \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    --cc=patrick.fu@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).