DPDK patches and discussions
 help / color / mirror / Atom feed
From: Adrian Moreno <amorenoz@redhat.com>
To: dev@dpdk.org
Cc: yinan.wang@intel.com, patrick.fu@intel.com, chenbo.xia@intel.com,
	zhihong.wang@intel.com, maxime.coquelin@redhat.com,
	Adrian Moreno <amorenoz@redhat.com>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH v3 5/6] net/virtio-user: don't assume vhost status feature
Date: Mon, 26 Oct 2020 17:39:29 +0100
Message-ID: <20201026163930.94032-6-amorenoz@redhat.com> (raw)
In-Reply-To: <20201026163930.94032-1-amorenoz@redhat.com>

There are some status reads and updates that need to happen before the
protocol features are negotiated. Therefore, assuming the backend does
support this feature can lead to failures.

On server mode, do not assume the backend supports
VHOST_USER_PROTOCOL_F_STATUS. Activate it back on reconnection and
cleare it on disconnection.

Fixes: 57912824615f ("net/virtio-user: support vhost status setting")
Cc: maxime.coquelin@redhat.com
Cc: stable@dpdk.org

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 6 ++++++
 drivers/net/virtio/virtio_user_ethdev.c          | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 36e5619df..053f0267c 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -523,6 +523,12 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
 		 * later.
 		 */
 		dev->device_features = VIRTIO_USER_SUPPORTED_FEATURES;
+
+		/* We cannot assume VHOST_USER_PROTOCOL_F_STATUS is supported
+		 * until it's negotiated
+		 */
+		dev->protocol_features &=
+			~(1ULL << VHOST_USER_PROTOCOL_F_STATUS);
 	}
 
 
diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 97ddc5651..142bdc0bd 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -92,6 +92,9 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
 					&protocol_features))
 			return -1;
 
+		/* Offer VHOST_USER_PROTOCOL_F_STATUS */
+		dev->protocol_features |=
+			(1ULL << VHOST_USER_PROTOCOL_F_STATUS);
 		dev->protocol_features &= protocol_features;
 
 		if (dev->ops->send_request(dev,
@@ -168,6 +171,11 @@ virtio_user_delayed_handler(void *param)
 		if (dev->vhostfd >= 0) {
 			close(dev->vhostfd);
 			dev->vhostfd = -1;
+			/* Until the featuers are negotiated again, don't assume
+			 * the backend supports VHOST_USER_PROTOCOL_F_STATUS
+			 */
+			dev->protocol_features &=
+				~(1ULL << VHOST_USER_PROTOCOL_F_STATUS);
 		}
 		eth_dev->intr_handle->fd = dev->listenfd;
 		rte_intr_callback_register(eth_dev->intr_handle,
-- 
2.26.2


  parent reply	other threads:[~2020-10-26 16:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26 16:39 [dpdk-dev] [PATCH v3 0/6] net/virtio-user: fix server mode Adrian Moreno
2020-10-26 16:39 ` [dpdk-dev] [PATCH v3 1/6] net/virtio-user: fix backend selection if stat fails Adrian Moreno
2020-10-26 16:39 ` [dpdk-dev] [PATCH v3 2/6] net/virtio-user: don't set/get_status until FEATURES_OK Adrian Moreno
2020-10-26 16:39 ` [dpdk-dev] [PATCH v3 3/6] net/virtio-user: ignore result if STATUS is unsupported Adrian Moreno
2020-10-28  9:39   ` Maxime Coquelin
2020-10-26 16:39 ` [dpdk-dev] [PATCH v3 4/6] net/virtio-user: lock-protect status updates Adrian Moreno
2020-10-28 10:35   ` Maxime Coquelin
2020-10-26 16:39 ` Adrian Moreno [this message]
2020-10-28 10:37   ` [dpdk-dev] [PATCH v3 5/6] net/virtio-user: don't assume vhost status feature Maxime Coquelin
2020-10-26 16:39 ` [dpdk-dev] [PATCH v3 6/6] net/virtio-user: set status on socket reconnect Adrian Moreno
2020-10-28 11:01   ` Maxime Coquelin
2020-10-27  3:09 ` [dpdk-dev] [PATCH v3 0/6] net/virtio-user: fix server mode Jiang, YuX
2020-10-29  8:27 ` 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=20201026163930.94032-6-amorenoz@redhat.com \
    --to=amorenoz@redhat.com \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=patrick.fu@intel.com \
    --cc=stable@dpdk.org \
    --cc=yinan.wang@intel.com \
    --cc=zhihong.wang@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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git