Skip to contentSkip to conversation

vhost: support VIRTIO_F_RING_RESET for vhost-user

PATCH Superseded Kangjie Xu 3 participants 6 messages Sep 5, 2022 – Sep 26, 2022

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Kangjie Xu

author
#0 lore raw

v2 cover vhost: support VIRTIO_F_RING_RESET for vhost-user

Add VIRTIO_F_RING_RESET, which indicates that the driver can reset a virtqueue individually.

VIRTIO_F_RING_RESET feature is added to virtio-spec 1.2. The relevant information is in

    https://github.com/oasis-tcs/virtio-spec/issues/124
    https://github.com/oasis-tcs/virtio-spec/issues/139

The implementation only adds the feature bit in supported features. It also adds a new vhost-user message VHOST_USER_RESET_VRING. The related definition is defined in the related QEMU patch set:
https://lore.kernel.org/qemu-devel/[email protected]/T/#t

The virtqueue reset process can be concluded as two parts:
1. The driver can reset a virtqueue. It will send VHOST_USER_RESET_VRING to DPDK. After received the message, DPDK will reset the virtqueue. The new message VHOST_USER_RESET_VRING has been acked by the QEMU virtio maintainer:

    https://lore.kernel.org/qemu-devel/[email protected]/

2. After the virtqueue is disabled, the driver may optionally re-enable it. To avoid confusion with VHOST_USER_SET_VRING_ENABLE, we call this part as "restart". The virtqueue's information may be changed when restarting it. Thus, the information of the reset virtqueue should be updated. This part is basically similar to when the virtqueue is started for the first time, except that the restart process does not need to set features and set mem table since they do not change. QEMU will send messages containing size, base, addr, kickfd and callfd of the virtqueue in order. Specifically, the DPDK will receive these messages in order:
a. VHOST_USER_SET_VRING_NUM
b. VHOST_USER_SET_VRING_BASE
c. VHOST_USER_SET_VRING_ADDR
d. VHOST_USER_SET_VRING_KICK
e. VHOST_USER_SET_VRING_CALL
f. VHOST_USER_SET_VRING_ENABLE
The last VHOST_USER_SET_VRING_ENABLE message with "payload.state.num" set to 1, will be sent to enable the virtqueue and the restart process is finished.

Test environment:

    Host: 5.4.189
    Qemu: QEMU emulator version 7.0.50 (With vq reset support)
    Guest: 5.19.0-rc3 (With vq reset support)
    DPDK: 22.07-rc1
    Test Cmd: ethtool -g eth1; ethtool -G eth1 rx $1 tx $2;
            ethtool -g eth1;

    The driver can resize the virtio queue, then virtio queue reset
    function should be triggered.

Guest Kernel Patch:

    https://lore.kernel.org/bpf/[email protected]/

QEMU Patch:

    https://lore.kernel.org/qemu-devel/[email protected]/T/
    https://lore.kernel.org/qemu-devel/[email protected]/T/

Looking forward to your review and comments.

Kangjie Xu (2):
vhost: support VIRTIO_F_RING_RESET for vhost-user
vhost: introduce VHOST_USER_RESET_VRING

 lib/vhost/vhost.c      |  2 +-
 lib/vhost/vhost.h      |  9 ++++++++-
 lib/vhost/vhost_user.c | 27 ++++++++++++++++++++++++++-
 lib/vhost/vhost_user.h |  1 +
 4 files changed, 36 insertions(+), 3 deletions(-)
Signature · 1 line
2.32.0
author
#1 lore raw

PATCH v2 1/2 vhost: support VIRTIO_F_RING_RESET for vhost-user

Add VIRTIO_F_RING_RESET, which indicates that the driver can reset a queue individually.

The feature is added to virtio-spec 1.2. The relevant information is in https://github.com/oasis-tcs/virtio-spec/issues/124

---
 lib/vhost/vhost.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
lib/vhost/vhost.h +7 -1
index 40fac3b7c6..76461a3406 100644
@@ -376,6 +376,11 @@ struct vhost_msg {
  #define VIRTIO_F_VERSION_1 32
 #endif
 
+/* This feature indicates that the driver can reset a queue individually. */
+#ifndef VIRTIO_F_RING_RESET
+#define VIRTIO_F_RING_RESET 40
+#endif
+
 /* Declare packed ring related bits for older kernels */
 #ifndef VIRTIO_F_RING_PACKED
 
@@ -438,7 +443,8 @@ struct vring_packed_desc_event {
 				(1ULL << VIRTIO_NET_F_MTU)  | \
 				(1ULL << VIRTIO_F_IN_ORDER) | \
 				(1ULL << VIRTIO_F_IOMMU_PLATFORM) | \
-				(1ULL << VIRTIO_F_RING_PACKED))
+				(1ULL << VIRTIO_F_RING_PACKED)	| \
+				(1ULL << VIRTIO_F_RING_RESET))
 
 
 struct guest_page {
Signature · 1 line
2.32.0
author
#2 lore raw

PATCH v2 2/2 vhost: introduce VHOST_USER_RESET_VRING

In reply to Kangjie Xu

To support the reset operation for an individual virtqueue, we introduce a new message VHOST_USER_RESET_VRING. When the feature VIRTIO_F_RING_RESET feature has been successfully negotiated, This message is submitted by the front-end to reset an individual virtqueue to initial states in the back-end. The reply is needed to ensure that the reset operation is complete.

---
 lib/vhost/vhost.c      |  2 +-
 lib/vhost/vhost.h      |  1 +
 lib/vhost/vhost_user.c | 27 ++++++++++++++++++++++++++-
 lib/vhost/vhost_user.h |  1 +
 4 files changed, 29 insertions(+), 2 deletions(-)
lib/vhost/vhost.c +1 -1
index 60cb05a0ff..215a1ca355 100644
@@ -610,7 +610,7 @@ init_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
 	vhost_user_iotlb_init(dev, vring_idx);
 }
 
-static void
+void
 reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
 {
 	struct vhost_virtqueue *vq;
lib/vhost/vhost.h +1 -0
index 76461a3406..eccb52842d 100644
@@ -791,6 +791,7 @@ get_device(int vid)
 
 int vhost_new_device(void);
 void cleanup_device(struct virtio_net *dev, int destroy);
+void reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx);
 void reset_device(struct virtio_net *dev);
 void vhost_destroy_device(int);
 void vhost_destroy_device_notify(struct virtio_net *dev);
lib/vhost/vhost_user.c +26 -1
index 4ad28bac45..5f7743d9d9 100644
@@ -2771,6 +2771,30 @@ vhost_user_set_status(struct virtio_net **pdev,
 	return RTE_VHOST_MSG_RESULT_OK;
 }
 
+static int
+vhost_user_reset_vring(struct virtio_net **pdev,
+			struct vhu_msg_context *ctx __rte_unused,
+			int main_fd __rte_unused)
+{
+	struct virtio_net *dev = *pdev;
+	int index = (int)ctx->msg.payload.state.index;
+
+	VHOST_LOG_CONFIG(dev->ifname, INFO, "reset queue: queue idx: %d\n", index);
+
+	if (!(dev->features & (1ULL << VIRTIO_F_RING_RESET))) {
+		return RTE_VHOST_MSG_RESULT_ERR;
+	}
+
+	dev->virtqueue[index]->enabled = false;
+	reset_vring_queue(dev, index);
+
+	ctx->msg.payload.state.num = 0;
+	ctx->msg.size = sizeof(ctx->msg.payload.u64);
+	ctx->fd_num = 0;
+
+	return RTE_VHOST_MSG_RESULT_REPLY;
+}
+
 #define VHOST_MESSAGE_HANDLERS \
 VHOST_MESSAGE_HANDLER(VHOST_USER_NONE, NULL, false) \
 VHOST_MESSAGE_HANDLER(VHOST_USER_GET_FEATURES, vhost_user_get_features, false) \
@@ -2803,7 +2827,8 @@ VHOST_MESSAGE_HANDLER(VHOST_USER_POSTCOPY_END, vhost_user_postcopy_end, false) \
 VHOST_MESSAGE_HANDLER(VHOST_USER_GET_INFLIGHT_FD, vhost_user_get_inflight_fd, false) \
 VHOST_MESSAGE_HANDLER(VHOST_USER_SET_INFLIGHT_FD, vhost_user_set_inflight_fd, true) \
 VHOST_MESSAGE_HANDLER(VHOST_USER_SET_STATUS, vhost_user_set_status, false) \
-VHOST_MESSAGE_HANDLER(VHOST_USER_GET_STATUS, vhost_user_get_status, false)
+VHOST_MESSAGE_HANDLER(VHOST_USER_GET_STATUS, vhost_user_get_status, false) \
+VHOST_MESSAGE_HANDLER(VHOST_USER_RESET_VRING, vhost_user_reset_vring, false)
 
 #define VHOST_MESSAGE_HANDLER(id, handler, accepts_fd) \
 	[id] = { #id, handler, accepts_fd },
lib/vhost/vhost_user.h +1 -0
index 8ecca68597..51cb2fc74a 100644
@@ -60,6 +60,7 @@ typedef enum VhostUserRequest {
 	VHOST_USER_SET_INFLIGHT_FD = 32,
 	VHOST_USER_SET_STATUS = 39,
 	VHOST_USER_GET_STATUS = 40,
+	VHOST_USER_RESET_VRING = 41
 } VhostUserRequest;
 
 typedef enum VhostUserSlaveRequest {
Signature · 1 line
2.32.0
#3 lore raw

RE: [PATCH v2 2/2] vhost: introduce VHOST_USER_RESET_VRING

Quoted 8 lines

-----Original Message-----
From: Kangjie Xu <[email protected]>
Sent: Monday, September 5, 2022 11:48 AM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v2 2/2] vhost: introduce VHOST_USER_RESET_VRING

Quoted 6 lines

To support the reset operation for an individual virtqueue, we introduce a new message VHOST_USER_RESET_VRING. When the feature VIRTIO_F_RING_RESET feature has been successfully negotiated, This message is submitted by the front-end to reset an individual virtqueue to initial states in the back-end. The reply is needed to ensure that the reset operation is complete.

completed

Quoted 41 lines
---
 lib/vhost/vhost.c      |  2 +-
 lib/vhost/vhost.h      |  1 +
 lib/vhost/vhost_user.c | 27 ++++++++++++++++++++++++++-
 lib/vhost/vhost_user.h |  1 +
 4 files changed, 29 insertions(+), 2 deletions(-)
lib/vhost/vhost.c +1 -1
index 60cb05a0ff..215a1ca355 100644
@@ -610,7 +610,7 @@ init_vring_queue(struct virtio_net *dev, uint32_t
 vring_idx)
 	vhost_user_iotlb_init(dev, vring_idx);
 }
 
-static void
+void
 reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
 {
lib/vhost/vhost.c +0 -0
 	struct vhost_virtqueue *vq;
lib/vhost/vhost.h +1 -0
index 76461a3406..eccb52842d 100644
@@ -791,6 +791,7 @@ get_device(int vid)
 
 int vhost_new_device(void);
 void cleanup_device(struct virtio_net *dev, int destroy);
+void reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx);
 void reset_device(struct virtio_net *dev);
 void vhost_destroy_device(int);
 void vhost_destroy_device_notify(struct virtio_net *dev);
lib/vhost/vhost_user.c +0 -0
index 4ad28bac45..5f7743d9d9 100644

lib/vhost/vhost_user.c vhost_user_set_status(struct virtio_net **pdev, · line 2780

Quoted 10 lines
lib/vhost/vhost_user.c +7 -0
@@ -2771,6 +2771,30 @@ vhost_user_set_status(struct virtio_net **pdev,
 	return RTE_VHOST_MSG_RESULT_OK;
 }
 
+static int
+vhost_user_reset_vring(struct virtio_net **pdev,
+			struct vhu_msg_context *ctx __rte_unused,
+			int main_fd __rte_unused)
+{
+	struct virtio_net *dev = *pdev;
+	int index = (int)ctx->msg.payload.state.index;

Why not just use unsigned int?

lib/vhost/vhost_user.c vhost_user_set_status(struct virtio_net **pdev, · line 2786

Quoted 7 lines
lib/vhost/vhost_user.c +6 -0
+
+	VHOST_LOG_CONFIG(dev->ifname, INFO, "reset queue: queue idx: %d\n",
 index);
+
+	if (!(dev->features & (1ULL << VIRTIO_F_RING_RESET))) {
+		return RTE_VHOST_MSG_RESULT_ERR;
+	}

braces {} are not necessary for single statement blocks

lib/vhost/vhost_user.c vhost_user_set_status(struct virtio_net **pdev, · line 2796

Quoted 10 lines
lib/vhost/vhost_user.c +10 -0
+
+	dev->virtqueue[index]->enabled = false;
+	reset_vring_queue(dev, index);
+
+	ctx->msg.payload.state.num = 0;
+	ctx->msg.size = sizeof(ctx->msg.payload.u64);
+	ctx->fd_num = 0;
+
+	return RTE_VHOST_MSG_RESULT_REPLY;
+}

IIUC, before this handler, we need to lock the queue? Using vhost_user_lock_all_queue_pairs

BTW, is this support merged in QEMU now? I remember for similar cases, we wait for QEMU to merge first and then merge in DPDK.

Maxime, do I remember this correctly?

Thanks,
Chenbo

Quoted 35 lines
lib/vhost/vhost_user.c +1 -0
+
 #define VHOST_MESSAGE_HANDLERS \
 VHOST_MESSAGE_HANDLER(VHOST_USER_NONE, NULL, false) \

VHOST_MESSAGE_HANDLER(VHOST_USER_GET_FEATURES, vhost_user_get_features,
false) \

lib/vhost/vhost_user.c +1 -1
@@ -2803,7 +2827,8 @@ VHOST_MESSAGE_HANDLER(VHOST_USER_POSTCOPY_END,
 vhost_user_postcopy_end, false) \
 VHOST_MESSAGE_HANDLER(VHOST_USER_GET_INFLIGHT_FD,
 vhost_user_get_inflight_fd, false) \
 VHOST_MESSAGE_HANDLER(VHOST_USER_SET_INFLIGHT_FD,
 vhost_user_set_inflight_fd, true) \
 VHOST_MESSAGE_HANDLER(VHOST_USER_SET_STATUS, vhost_user_set_status, false)
 \
-VHOST_MESSAGE_HANDLER(VHOST_USER_GET_STATUS, vhost_user_get_status, false)
+VHOST_MESSAGE_HANDLER(VHOST_USER_GET_STATUS, vhost_user_get_status, false)

\
+VHOST_MESSAGE_HANDLER(VHOST_USER_RESET_VRING, vhost_user_reset_vring, false)

#define VHOST_MESSAGE_HANDLER(id, handler, accepts_fd) \

lib/vhost/vhost_user.c +0 -0
 	[id] = { #id, handler, accepts_fd },
lib/vhost/vhost_user.h +1 -1
index 8ecca68597..51cb2fc74a 100644
@@ -60,6 +60,7 @@ typedef enum VhostUserRequest {
 	VHOST_USER_SET_INFLIGHT_FD = 32,
 	VHOST_USER_SET_STATUS = 39,
 	VHOST_USER_GET_STATUS = 40,
+	VHOST_USER_RESET_VRING = 41
 } VhostUserRequest;
 
 typedef enum VhostUserSlaveRequest {
--

2.32.0

#4 lore raw

Re: RE: [PATCH v2 2/2] vhost: introduce VHOST_USER_RESET_VRING

Quoted 94 lines · Chenbo
Quoted 8 lines

-----Original Message-----
From: Kangjie Xu <[email protected]>
Sent: Monday, September 5, 2022 11:48 AM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v2 2/2] vhost: introduce VHOST_USER_RESET_VRING

Quoted 6 lines

To support the reset operation for an individual virtqueue, we introduce a new message VHOST_USER_RESET_VRING. When the feature VIRTIO_F_RING_RESET feature has been successfully negotiated, This message is submitted by the front-end to reset an individual virtqueue to initial states in the back-end. The reply is needed to ensure that the reset operation is complete.

completed

Quoted 41 lines
---
 lib/vhost/vhost.c      |  2 +-
 lib/vhost/vhost.h      |  1 +
 lib/vhost/vhost_user.c | 27 ++++++++++++++++++++++++++-
 lib/vhost/vhost_user.h |  1 +
 4 files changed, 29 insertions(+), 2 deletions(-)
lib/vhost/vhost.c +1 -1
index 60cb05a0ff..215a1ca355 100644
@@ -610,7 +610,7 @@ init_vring_queue(struct virtio_net *dev, uint32_t
 vring_idx)
 	vhost_user_iotlb_init(dev, vring_idx);
 }
 
-static void
+void
 reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
 {
lib/vhost/vhost.c +0 -0
 	struct vhost_virtqueue *vq;
lib/vhost/vhost.h +1 -0
index 76461a3406..eccb52842d 100644
@@ -791,6 +791,7 @@ get_device(int vid)
 
 int vhost_new_device(void);
 void cleanup_device(struct virtio_net *dev, int destroy);
+void reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx);
 void reset_device(struct virtio_net *dev);
 void vhost_destroy_device(int);
 void vhost_destroy_device_notify(struct virtio_net *dev);
lib/vhost/vhost_user.c +0 -0
index 4ad28bac45..5f7743d9d9 100644

lib/vhost/vhost_user.c vhost_user_set_status(struct virtio_net **pdev, · line 2780

Quoted 10 lines
lib/vhost/vhost_user.c +7 -0
@@ -2771,6 +2771,30 @@ vhost_user_set_status(struct virtio_net **pdev,
 	return RTE_VHOST_MSG_RESULT_OK;
 }
 
+static int
+vhost_user_reset_vring(struct virtio_net **pdev,
+			struct vhu_msg_context *ctx __rte_unused,
+			int main_fd __rte_unused)
+{
+	struct virtio_net *dev = *pdev;
+	int index = (int)ctx->msg.payload.state.index;

Why not just use unsigned int?

lib/vhost/vhost_user.c vhost_user_set_status(struct virtio_net **pdev, · line 2786

Quoted 7 lines
lib/vhost/vhost_user.c +6 -0
+
+	VHOST_LOG_CONFIG(dev->ifname, INFO, "reset queue: queue idx: %d\n",
 index);
+
+	if (!(dev->features & (1ULL << VIRTIO_F_RING_RESET))) {
+		return RTE_VHOST_MSG_RESULT_ERR;
+	}

braces {} are not necessary for single statement blocks

lib/vhost/vhost_user.c vhost_user_set_status(struct virtio_net **pdev, · line 2796

Quoted 10 lines
lib/vhost/vhost_user.c +10 -0
+
+	dev->virtqueue[index]->enabled = false;
+	reset_vring_queue(dev, index);
+
+	ctx->msg.payload.state.num = 0;
+	ctx->msg.size = sizeof(ctx->msg.payload.u64);
+	ctx->fd_num = 0;
+
+	return RTE_VHOST_MSG_RESULT_REPLY;
+}

IIUC, before this handler, we need to lock the queue? Using vhost_user_lock_all_queue_pairs

Quoted 4 lines

BTW, is this support merged in QEMU now? I remember for similar cases, we wait for QEMU to merge first and then merge in DPDK.

Maxime, do I remember this correctly?

Yes, we are simultaneously pushing this feature to QEMU.

We have a patch for v3, maybe you missed it.

Thanks.

Quoted 40 lines

Thanks,
Chenbo

Quoted 35 lines
lib/vhost/vhost_user.c +1 -0
+
 #define VHOST_MESSAGE_HANDLERS \
 VHOST_MESSAGE_HANDLER(VHOST_USER_NONE, NULL, false) \

VHOST_MESSAGE_HANDLER(VHOST_USER_GET_FEATURES, vhost_user_get_features,
false) \

lib/vhost/vhost_user.c +1 -1
@@ -2803,7 +2827,8 @@ VHOST_MESSAGE_HANDLER(VHOST_USER_POSTCOPY_END,
 vhost_user_postcopy_end, false) \
 VHOST_MESSAGE_HANDLER(VHOST_USER_GET_INFLIGHT_FD,
 vhost_user_get_inflight_fd, false) \
 VHOST_MESSAGE_HANDLER(VHOST_USER_SET_INFLIGHT_FD,
 vhost_user_set_inflight_fd, true) \
 VHOST_MESSAGE_HANDLER(VHOST_USER_SET_STATUS, vhost_user_set_status, false)
 \
-VHOST_MESSAGE_HANDLER(VHOST_USER_GET_STATUS, vhost_user_get_status, false)
+VHOST_MESSAGE_HANDLER(VHOST_USER_GET_STATUS, vhost_user_get_status, false)

\
+VHOST_MESSAGE_HANDLER(VHOST_USER_RESET_VRING, vhost_user_reset_vring, false)

#define VHOST_MESSAGE_HANDLER(id, handler, accepts_fd) \

lib/vhost/vhost_user.c +0 -0
 	[id] = { #id, handler, accepts_fd },
lib/vhost/vhost_user.h +1 -1
index 8ecca68597..51cb2fc74a 100644
@@ -60,6 +60,7 @@ typedef enum VhostUserRequest {
 	VHOST_USER_SET_INFLIGHT_FD = 32,
 	VHOST_USER_SET_STATUS = 39,
 	VHOST_USER_GET_STATUS = 40,
+	VHOST_USER_RESET_VRING = 41
 } VhostUserRequest;
 
 typedef enum VhostUserSlaveRequest {
--

2.32.0

#5 lore raw

RE: RE: [PATCH v2 2/2] vhost: introduce VHOST_USER_RESET_VRING

Quoted 109 lines

-----Original Message-----
From: Xuan Zhuo <[email protected]>
Sent: Friday, September 23, 2022 9:42 AM
To: Xia, Chenbo <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Kangjie Xu <[email protected]>; [email protected]
Subject: Re: RE: [PATCH v2 2/2] vhost: introduce VHOST_USER_RESET_VRING

Quoted 81 lines · Chenbo
Quoted 8 lines

-----Original Message-----
From: Kangjie Xu <[email protected]>
Sent: Monday, September 5, 2022 11:48 AM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v2 2/2] vhost: introduce VHOST_USER_RESET_VRING

Quoted 6 lines

To support the reset operation for an individual virtqueue, we introduce a new message VHOST_USER_RESET_VRING. When the feature VIRTIO_F_RING_RESET feature has been successfully negotiated, This message is submitted by the front-end to reset an individual virtqueue to initial states in the back-end. The reply is needed to ensure that the reset operation is complete.

completed

Quoted 41 lines
---
 lib/vhost/vhost.c      |  2 +-
 lib/vhost/vhost.h      |  1 +
 lib/vhost/vhost_user.c | 27 ++++++++++++++++++++++++++-
 lib/vhost/vhost_user.h |  1 +
 4 files changed, 29 insertions(+), 2 deletions(-)
lib/vhost/vhost.c +1 -1
index 60cb05a0ff..215a1ca355 100644
@@ -610,7 +610,7 @@ init_vring_queue(struct virtio_net *dev, uint32_t
 vring_idx)
 	vhost_user_iotlb_init(dev, vring_idx);
 }
 
-static void
+void
 reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
 {
lib/vhost/vhost.c +0 -0
 	struct vhost_virtqueue *vq;
lib/vhost/vhost.h +1 -0
index 76461a3406..eccb52842d 100644
@@ -791,6 +791,7 @@ get_device(int vid)
 
 int vhost_new_device(void);
 void cleanup_device(struct virtio_net *dev, int destroy);
+void reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx);
 void reset_device(struct virtio_net *dev);
 void vhost_destroy_device(int);
 void vhost_destroy_device_notify(struct virtio_net *dev);
lib/vhost/vhost_user.c +0 -0
index 4ad28bac45..5f7743d9d9 100644

lib/vhost/vhost_user.c vhost_user_set_status(struct virtio_net **pdev, · line 2780

Quoted 10 lines
lib/vhost/vhost_user.c +7 -0
@@ -2771,6 +2771,30 @@ vhost_user_set_status(struct virtio_net **pdev,
 	return RTE_VHOST_MSG_RESULT_OK;
 }
 
+static int
+vhost_user_reset_vring(struct virtio_net **pdev,
+			struct vhu_msg_context *ctx __rte_unused,
+			int main_fd __rte_unused)
+{
+	struct virtio_net *dev = *pdev;
+	int index = (int)ctx->msg.payload.state.index;

Why not just use unsigned int?

lib/vhost/vhost_user.c vhost_user_set_status(struct virtio_net **pdev, · line 2786

Quoted 7 lines
lib/vhost/vhost_user.c +6 -0
+
+	VHOST_LOG_CONFIG(dev->ifname, INFO, "reset queue: queue idx: %d\n",
 index);
+
+	if (!(dev->features & (1ULL << VIRTIO_F_RING_RESET))) {
+		return RTE_VHOST_MSG_RESULT_ERR;
+	}

braces {} are not necessary for single statement blocks

Quoted 12 lines

lib/vhost/vhost_user.c vhost_user_set_status(struct virtio_net **pdev, · line 2796

Quoted 10 lines
lib/vhost/vhost_user.c +10 -0
+
+	dev->virtqueue[index]->enabled = false;
+	reset_vring_queue(dev, index);
+
+	ctx->msg.payload.state.num = 0;
+	ctx->msg.size = sizeof(ctx->msg.payload.u64);
+	ctx->fd_num = 0;
+
+	return RTE_VHOST_MSG_RESULT_REPLY;
+}

IIUC, before this handler, we need to lock the queue? Using

vhost_user_lock_all_queue_pairs

Quoted 4 lines

BTW, is this support merged in QEMU now? I remember for similar cases, we wait for QEMU to merge first and then merge in DPDK.

Quoted 8 lines
Quoted 1 line

Maxime, do I remember this correctly?

Yes, we are simultaneously pushing this feature to QEMU.

We have a patch for v3, maybe you missed it.

Thanks.

Oops, sorry. I did miss that. And please ping when the QEMU side is merged.

Thanks,
Chenbo

Quoted 46 lines
Quoted 10 lines

Thanks,
Chenbo

Quoted 4 lines
lib/vhost/vhost_user.c +1 -0
+
 #define VHOST_MESSAGE_HANDLERS \
 VHOST_MESSAGE_HANDLER(VHOST_USER_NONE, NULL, false) \

VHOST_MESSAGE_HANDLER(VHOST_USER_GET_FEATURES,

vhost_user_get_features,

Quoted 8 lines

lib/vhost/vhost_user.c VHOST_MESSAGE_HANDLER(VHOST_USER_POSTCOPY_END, · line 2832

Quoted 8 lines

false) \

lib/vhost/vhost_user.c +0 -0
@@ -2803,7 +2827,8 @@ VHOST_MESSAGE_HANDLER(VHOST_USER_POSTCOPY_END,
 vhost_user_postcopy_end, false) \
 VHOST_MESSAGE_HANDLER(VHOST_USER_GET_INFLIGHT_FD,
 vhost_user_get_inflight_fd, false) \
 VHOST_MESSAGE_HANDLER(VHOST_USER_SET_INFLIGHT_FD,
 vhost_user_set_inflight_fd, true) \
 VHOST_MESSAGE_HANDLER(VHOST_USER_SET_STATUS, vhost_user_set_status,

false)

Quoted 2 lines

lib/vhost/vhost_user.c VHOST_MESSAGE_HANDLER(VHOST_USER_POSTCOPY_END,

Quoted 2 lines
lib/vhost/vhost_user.c +0 -1
 \
-VHOST_MESSAGE_HANDLER(VHOST_USER_GET_STATUS, vhost_user_get_status,

false)

Quoted 1 line
Quoted 1 line

+VHOST_MESSAGE_HANDLER(VHOST_USER_GET_STATUS, vhost_user_get_status,

false)

Quoted 21 lines
Quoted 20 lines

\
+VHOST_MESSAGE_HANDLER(VHOST_USER_RESET_VRING, vhost_user_reset_vring, false)

#define VHOST_MESSAGE_HANDLER(id, handler, accepts_fd) \

lib/vhost/vhost_user.c +0 -0
 	[id] = { #id, handler, accepts_fd },
lib/vhost/vhost_user.h +1 -1
index 8ecca68597..51cb2fc74a 100644
@@ -60,6 +60,7 @@ typedef enum VhostUserRequest {
 	VHOST_USER_SET_INFLIGHT_FD = 32,
 	VHOST_USER_SET_STATUS = 39,
 	VHOST_USER_GET_STATUS = 40,
+	VHOST_USER_RESET_VRING = 41
 } VhostUserRequest;
 
 typedef enum VhostUserSlaveRequest {
--

2.32.0