Skip to contentSkip to conversation

net/virtio-user: fix advertising of protocol features

PATCH Superseded Olivier Matz 2 participants 4 messages Dec 18, 2020 – Jan 8, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/virtio-user: fix advertising of protocol features

When connected to a vhost-user backend, the flag VHOST_USER_F_PROTOCOL_FEATURES is not advertised, preventing to do multiqueue (the VHOST_USER_PROTOCOL_F_MQ protocol feature is ignored by some backends if the VHOST_USER_F_PROTOCOL_FEATURES feature is not set).

When setting vhost-user features, advertise this flag if it was advertised by our peer.

Fixes 8e7561054ac7 ("net/virtio: support vhost-user protocol features")
---
 drivers/net/virtio/virtio_user/vhost_user.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/virtio/virtio_user/vhost_user.c +4 -0
index b93e65c60b..5e8a5c293e 100644
@@ -298,6 +298,10 @@ vhost_user_sock(struct virtio_user_dev *dev,
 			msg.flags |= VHOST_USER_NEED_REPLY_MASK;
 		/* Fallthrough */
 	case VHOST_USER_SET_FEATURES:
+		msg.payload.u64 = *((__u64 *)arg) | (dev->device_features &
+			(1ULL << VHOST_USER_F_PROTOCOL_FEATURES));
+		msg.size = sizeof(m.payload.u64);
+		break;
 	case VHOST_USER_SET_PROTOCOL_FEATURES:
 	case VHOST_USER_SET_LOG_BASE:
 		msg.payload.u64 = *((__u64 *)arg);
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/1 net/virtio-user: fix advertising of protocol features

When connected to a vhost-user backend, the flag VHOST_USER_F_PROTOCOL_FEATURES is not advertised, preventing to do multiqueue (the VHOST_USER_PROTOCOL_F_MQ protocol feature is ignored by some backends if the VHOST_USER_F_PROTOCOL_FEATURES feature is not set).

When setting vhost-user features, advertise this flag if it was advertised by our peer.

Fixes 8e7561054ac7 ("net/virtio: support vhost-user protocol features")

---

v2
* fix obvious fallthrough case, sorry for the noise

 drivers/net/virtio/virtio_user/vhost_user.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_user/vhost_user.c +6 -1
index b93e65c60b..350eed4182 100644
@@ -297,13 +297,18 @@ vhost_user_sock(struct virtio_user_dev *dev,
 		if (has_reply_ack)
 			msg.flags |= VHOST_USER_NEED_REPLY_MASK;
 		/* Fallthrough */
-	case VHOST_USER_SET_FEATURES:
 	case VHOST_USER_SET_PROTOCOL_FEATURES:
 	case VHOST_USER_SET_LOG_BASE:
 		msg.payload.u64 = *((__u64 *)arg);
 		msg.size = sizeof(m.payload.u64);
 		break;
 
+	case VHOST_USER_SET_FEATURES:
+		msg.payload.u64 = *((__u64 *)arg) | (dev->device_features &
+			(1ULL << VHOST_USER_F_PROTOCOL_FEATURES));
+		msg.size = sizeof(m.payload.u64);
+		break;
+
 	case VHOST_USER_SET_OWNER:
 	case VHOST_USER_RESET_OWNER:
 		break;
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#2 lore raw
Quoted 36 lines · Olivier Matz

When connected to a vhost-user backend, the flag VHOST_USER_F_PROTOCOL_FEATURES is not advertised, preventing to do multiqueue (the VHOST_USER_PROTOCOL_F_MQ protocol feature is ignored by some backends if the VHOST_USER_F_PROTOCOL_FEATURES feature is not set).

When setting vhost-user features, advertise this flag if it was advertised by our peer.

Fixes 8e7561054ac7 ("net/virtio: support vhost-user protocol features")

---

v2
* fix obvious fallthrough case, sorry for the noise

 drivers/net/virtio/virtio_user/vhost_user.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_user/vhost_user.c +0 -1
index b93e65c60b..350eed4182 100644
@@ -297,13 +297,18 @@ vhost_user_sock(struct virtio_user_dev *dev,
 		if (has_reply_ack)
 			msg.flags |= VHOST_USER_NEED_REPLY_MASK;
 		/* Fallthrough */
-	case VHOST_USER_SET_FEATURES:
 	case VHOST_USER_SET_PROTOCOL_FEATURES:
 	case VHOST_USER_SET_LOG_BASE:
 		msg.payload.u64 = *((__u64 *)arg);
 		msg.size = sizeof(m.payload.u64);
 		break;

drivers/net/virtio/virtio_user/vhost_user.c vhost_user_sock(struct virtio_user_dev *dev, · line 314

Quoted 10 lines
drivers/net/virtio/virtio_user/vhost_user.c +6 -0
 
+	case VHOST_USER_SET_FEATURES:
+		msg.payload.u64 = *((__u64 *)arg) | (dev->device_features &
+			(1ULL << VHOST_USER_F_PROTOCOL_FEATURES));
+		msg.size = sizeof(m.payload.u64);
+		break;
+
 	case VHOST_USER_SET_OWNER:
 	case VHOST_USER_RESET_OWNER:
 		break;

Thanks!
Maxime

#3 lore raw
In reply to Olivier Matz
Quoted 13 lines · Olivier Matz

When connected to a vhost-user backend, the flag VHOST_USER_F_PROTOCOL_FEATURES is not advertised, preventing to do multiqueue (the VHOST_USER_PROTOCOL_F_MQ protocol feature is ignored by some backends if the VHOST_USER_F_PROTOCOL_FEATURES feature is not set).

When setting vhost-user features, advertise this flag if it was advertised by our peer.

Fixes 8e7561054ac7 ("net/virtio: support vhost-user protocol features")
Quoted 7 lines

---

v2
* fix obvious fallthrough case, sorry for the noise

 drivers/net/virtio/virtio_user/vhost_user.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Series applied to dpdk-next-virtio/main.

Thanks,
Maxime