All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: dev@dpdk.org, patrick.fu@intel.com, amorenoz@redhat.com
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [dpdk-dev] [PATCH 4/7] net/virtio: adapt Virtio-user status size
Date: Fri, 11 Sep 2020 17:08:02 +0200	[thread overview]
Message-ID: <20200911150805.79901-5-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20200911150805.79901-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  | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 93274b2a94..753611ef42 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -838,14 +838,18 @@ virtio_user_send_status_update(struct virtio_user_dev *dev, uint8_t status)
 	enum virtio_user_backend_type backend_type =
 				virtio_user_backend_type(dev->path);
 
-	/* Vhost-user only for now */
-	if (backend_type != VIRTIO_USER_BACKEND_VHOST_USER)
+	if (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_STATUS)))
 		return 0;
 
-	if (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_STATUS)))
+	if (backend_type == VIRTIO_USER_BACKEND_VHOST_USER)
+		ret = dev->ops->send_request(dev,
+				VHOST_USER_SET_STATUS, &arg);
+	else if (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));
@@ -858,7 +862,7 @@ virtio_user_send_status_update(struct virtio_user_dev *dev, uint8_t status)
 int
 virtio_user_update_status(struct virtio_user_dev *dev)
 {
-	uint64_t ret;
+	uint8_t ret;
 	int err;
 	enum virtio_user_backend_type backend_type =
 				virtio_user_backend_type(dev->path);
@@ -876,11 +880,6 @@ virtio_user_update_status(struct virtio_user_dev *dev)
 			     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;
 	PMD_INIT_LOG(DEBUG, "Updated Device Status(0x%08x):\n"
-- 
2.26.2


  parent reply	other threads:[~2020-09-11 15:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-11 15:07 [dpdk-dev] [PATCH 0/7]virtio-user: introduce vhost-vdpa backend Maxime Coquelin
2020-09-11 15:07 ` [dpdk-dev] [PATCH 1/7] bus/vdev: add DMA mapping ops Maxime Coquelin
2020-09-24  5:25   ` Xia, Chenbo
2020-09-24  7:40     ` Maxime Coquelin
2020-09-11 15:08 ` [dpdk-dev] [PATCH 2/7] net/virtio: introduce DMA ops Maxime Coquelin
2020-09-11 15:08 ` [dpdk-dev] [PATCH 3/7] net/virtio: introduce Vhost-vDPA backend type Maxime Coquelin
2020-09-11 15:08 ` Maxime Coquelin [this message]
2020-09-24  5:25   ` [dpdk-dev] [PATCH 4/7] net/virtio: adapt Virtio-user status size Xia, Chenbo
2020-09-24  8:05     ` Maxime Coquelin
2020-09-11 15:08 ` [dpdk-dev] [PATCH 5/7] net/virtio: check protocol feature in user backend Maxime Coquelin
2020-09-11 15:08 ` [dpdk-dev] [PATCH 6/7] net/virtio: split virtio-user start Maxime Coquelin
2020-09-11 15:08 ` [dpdk-dev] [PATCH 7/7] net/virtio: introduce Vhost-vDPA backend Maxime Coquelin
2020-09-24  5:25   ` Xia, Chenbo
2020-09-24  5:43     ` Fu, Patrick
2020-09-24  5:52       ` Xia, Chenbo
2020-09-24  8:07     ` 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=20200911150805.79901-5-maxime.coquelin@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=amorenoz@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.