[v2,5/8] net/virtio: check protocol feature in user backend
diff mbox series

Message ID 20200925123113.68916-6-maxime.coquelin@redhat.com
State Superseded
Delegated to: Maxime Coquelin
Headers show
Series
  • virtio-user: introduce vhost-vdpa backend
Related show

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Maxime Coquelin Sept. 25, 2020, 12:31 p.m. UTC
When sending set status message, move protocol feature check
to vhost_user to be compatible with different backend types.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 drivers/net/virtio/virtio_user/vhost_user.c      | 6 +++++-
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 6 ------
 2 files changed, 5 insertions(+), 7 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
index 12b6c7dbcf..ef290c357b 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -277,9 +277,13 @@  vhost_user_sock(struct virtio_user_dev *dev,
 	msg.size = 0;
 
 	switch (req) {
+	case VHOST_USER_GET_STATUS:
+		if (!(dev->protocol_features &
+				(1ULL << VHOST_USER_PROTOCOL_F_STATUS)))
+			return 0;
+		/* Fallthrough */
 	case VHOST_USER_GET_FEATURES:
 	case VHOST_USER_GET_PROTOCOL_FEATURES:
-	case VHOST_USER_GET_STATUS:
 		need_reply = 1;
 		break;
 
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 7cb93b1b33..0128a5fefb 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -788,9 +788,6 @@  virtio_user_send_status_update(struct virtio_user_dev *dev, uint8_t status)
 	if (dev->backend_type != VIRTIO_USER_BACKEND_VHOST_USER)
 		return 0;
 
-	if (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_STATUS)))
-		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,
@@ -811,9 +808,6 @@  virtio_user_update_status(struct virtio_user_dev *dev)
 	if (dev->backend_type != VIRTIO_USER_BACKEND_VHOST_USER)
 		return 0;
 
-	if (!(dev->protocol_features & (1UL << VHOST_USER_PROTOCOL_F_STATUS)))
-		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,