* [PATCH 1/8] docs: vhost-user: add VHOST_USER_RESET_VRING message
2022-08-26 10:56 [PATCH 0/8] Support VIRTIO_F_RING_RESET for vhost-user in virtio pci-modern Kangjie Xu
@ 2022-08-26 10:56 ` Kangjie Xu
2022-08-26 10:56 ` [PATCH 2/8] net: virtio: rename vhost_set_vring_enable to vhost_set_dev_enable Kangjie Xu
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Kangjie Xu @ 2022-08-26 10:56 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, jasowang, arei.gonglei, hengqi, xuanzhuo
To support the reset operation for an individual virtqueue,
we introduce a new message VHOST_USER_RESET_VRING. 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.
Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
docs/interop/vhost-user.rst | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst
index 3f18ab424e..ce7991b9d3 100644
--- a/docs/interop/vhost-user.rst
+++ b/docs/interop/vhost-user.rst
@@ -1422,6 +1422,16 @@ Front-end message types
query the back-end for its device status as defined in the Virtio
specification.
+``VHOST_USER_RESET_VRING``
+ :id: 41
+ :equivalent ioctl: N/A
+ :request payload: vring state description
+ :reply payload: ``u64``
+
+ 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. It will ask
+ for a reply to ensure the virtqueue is successfully reset in the back-end.
Back-end message types
----------------------
--
2.32.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 2/8] net: virtio: rename vhost_set_vring_enable to vhost_set_dev_enable
2022-08-26 10:56 [PATCH 0/8] Support VIRTIO_F_RING_RESET for vhost-user in virtio pci-modern Kangjie Xu
2022-08-26 10:56 ` [PATCH 1/8] docs: vhost-user: add VHOST_USER_RESET_VRING message Kangjie Xu
@ 2022-08-26 10:56 ` Kangjie Xu
2022-08-26 10:56 ` [PATCH 3/8] vhost-user: add op to enable or disable a single vring Kangjie Xu
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Kangjie Xu @ 2022-08-26 10:56 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, jasowang, arei.gonglei, hengqi, xuanzhuo
Previously, vhost_set_vring_enable will enable/disable all vrings
in a device, which causes ambiguity. So we rename it to
vhost_set_dev_enable.
Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
backends/cryptodev-vhost.c | 12 ++++++------
hw/net/vhost_net-stub.c | 2 +-
hw/net/vhost_net.c | 8 ++++----
hw/net/virtio-net.c | 4 ++--
hw/virtio/vhost-user.c | 4 ++--
include/hw/virtio/vhost-backend.h | 6 +++---
include/net/vhost_net.h | 2 +-
7 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c
index bc13e466b4..b83e939760 100644
--- a/backends/cryptodev-vhost.c
+++ b/backends/cryptodev-vhost.c
@@ -147,9 +147,9 @@ cryptodev_vhost_set_vq_index(CryptoDevBackendVhost *crypto,
}
static int
-vhost_set_vring_enable(CryptoDevBackendClient *cc,
- CryptoDevBackend *b,
- uint16_t queue, int enable)
+vhost_set_dev_enable(CryptoDevBackendClient *cc,
+ CryptoDevBackend *b,
+ uint16_t queue, int enable)
{
CryptoDevBackendVhost *crypto =
cryptodev_get_vhost(cc, b, queue);
@@ -162,8 +162,8 @@ vhost_set_vring_enable(CryptoDevBackendClient *cc,
}
vhost_ops = crypto->dev.vhost_ops;
- if (vhost_ops->vhost_set_vring_enable) {
- return vhost_ops->vhost_set_vring_enable(&crypto->dev, enable);
+ if (vhost_ops->vhost_set_dev_enable) {
+ return vhost_ops->vhost_set_dev_enable(&crypto->dev, enable);
}
return 0;
@@ -219,7 +219,7 @@ int cryptodev_vhost_start(VirtIODevice *dev, int total_queues)
if (cc->vring_enable) {
/* restore vring enable state */
- r = vhost_set_vring_enable(cc, b, i, cc->vring_enable);
+ r = vhost_set_dev_enable(cc, b, i, cc->vring_enable);
if (r < 0) {
goto err_start;
diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c
index 89d71cfb8e..ac5f217dc1 100644
--- a/hw/net/vhost_net-stub.c
+++ b/hw/net/vhost_net-stub.c
@@ -92,7 +92,7 @@ VHostNetState *get_vhost_net(NetClientState *nc)
return 0;
}
-int vhost_set_vring_enable(NetClientState *nc, int enable)
+int vhost_set_dev_enable(NetClientState *nc, int enable)
{
return 0;
}
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 74c5147d6e..c0c1456172 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -379,7 +379,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
if (peer->vring_enable) {
/* restore vring enable state */
- r = vhost_set_vring_enable(peer, peer->vring_enable);
+ r = vhost_set_dev_enable(peer, peer->vring_enable);
if (r < 0) {
vhost_net_stop_one(get_vhost_net(peer), dev);
@@ -491,15 +491,15 @@ VHostNetState *get_vhost_net(NetClientState *nc)
return vhost_net;
}
-int vhost_set_vring_enable(NetClientState *nc, int enable)
+int vhost_set_dev_enable(NetClientState *nc, int enable)
{
VHostNetState *net = get_vhost_net(nc);
const VhostOps *vhost_ops = net->dev.vhost_ops;
nc->vring_enable = enable;
- if (vhost_ops && vhost_ops->vhost_set_vring_enable) {
- return vhost_ops->vhost_set_vring_enable(&net->dev, enable);
+ if (vhost_ops && vhost_ops->vhost_set_dev_enable) {
+ return vhost_ops->vhost_set_dev_enable(&net->dev, enable);
}
return 0;
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 7817206596..6ab796b399 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -696,7 +696,7 @@ static int peer_attach(VirtIONet *n, int index)
}
if (nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
- vhost_set_vring_enable(nc->peer, 1);
+ vhost_set_dev_enable(nc->peer, 1);
}
if (nc->peer->info->type != NET_CLIENT_DRIVER_TAP) {
@@ -719,7 +719,7 @@ static int peer_detach(VirtIONet *n, int index)
}
if (nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
- vhost_set_vring_enable(nc->peer, 0);
+ vhost_set_dev_enable(nc->peer, 0);
}
if (nc->peer->info->type != NET_CLIENT_DRIVER_TAP) {
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index bd24741be8..794519359b 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1198,7 +1198,7 @@ static int vhost_user_set_vring_base(struct vhost_dev *dev,
return vhost_set_vring(dev, VHOST_USER_SET_VRING_BASE, ring);
}
-static int vhost_user_set_vring_enable(struct vhost_dev *dev, int enable)
+static int vhost_user_set_dev_enable(struct vhost_dev *dev, int enable)
{
int i;
@@ -2627,7 +2627,7 @@ const VhostOps user_ops = {
.vhost_set_owner = vhost_user_set_owner,
.vhost_reset_device = vhost_user_reset_device,
.vhost_get_vq_index = vhost_user_get_vq_index,
- .vhost_set_vring_enable = vhost_user_set_vring_enable,
+ .vhost_set_dev_enable = vhost_user_set_dev_enable,
.vhost_requires_shm_log = vhost_user_requires_shm_log,
.vhost_migration_done = vhost_user_migration_done,
.vhost_backend_can_merge = vhost_user_can_merge,
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
index eab46d7f0b..b49432045f 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -81,8 +81,8 @@ typedef int (*vhost_set_backend_cap_op)(struct vhost_dev *dev);
typedef int (*vhost_set_owner_op)(struct vhost_dev *dev);
typedef int (*vhost_reset_device_op)(struct vhost_dev *dev);
typedef int (*vhost_get_vq_index_op)(struct vhost_dev *dev, int idx);
-typedef int (*vhost_set_vring_enable_op)(struct vhost_dev *dev,
- int enable);
+typedef int (*vhost_set_dev_enable_op)(struct vhost_dev *dev,
+ int enable);
typedef bool (*vhost_requires_shm_log_op)(struct vhost_dev *dev);
typedef int (*vhost_migration_done_op)(struct vhost_dev *dev,
char *mac_addr);
@@ -155,7 +155,7 @@ typedef struct VhostOps {
vhost_set_owner_op vhost_set_owner;
vhost_reset_device_op vhost_reset_device;
vhost_get_vq_index_op vhost_get_vq_index;
- vhost_set_vring_enable_op vhost_set_vring_enable;
+ vhost_set_dev_enable_op vhost_set_dev_enable;
vhost_requires_shm_log_op vhost_requires_shm_log;
vhost_migration_done_op vhost_migration_done;
vhost_backend_can_merge_op vhost_backend_can_merge;
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
index 40b9a40074..22a1fcd39e 100644
--- a/include/net/vhost_net.h
+++ b/include/net/vhost_net.h
@@ -42,7 +42,7 @@ void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
int vhost_net_notify_migration_done(VHostNetState *net, char* mac_addr);
VHostNetState *get_vhost_net(NetClientState *nc);
-int vhost_set_vring_enable(NetClientState * nc, int enable);
+int vhost_set_dev_enable(NetClientState *nc, int enable);
uint64_t vhost_net_get_acked_features(VHostNetState *net);
--
2.32.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 3/8] vhost-user: add op to enable or disable a single vring
2022-08-26 10:56 [PATCH 0/8] Support VIRTIO_F_RING_RESET for vhost-user in virtio pci-modern Kangjie Xu
2022-08-26 10:56 ` [PATCH 1/8] docs: vhost-user: add VHOST_USER_RESET_VRING message Kangjie Xu
2022-08-26 10:56 ` [PATCH 2/8] net: virtio: rename vhost_set_vring_enable to vhost_set_dev_enable Kangjie Xu
@ 2022-08-26 10:56 ` Kangjie Xu
2022-08-26 10:56 ` [PATCH 4/8] vhost-user: introduce vhost_reset_vring() interface Kangjie Xu
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Kangjie Xu @ 2022-08-26 10:56 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, jasowang, arei.gonglei, hengqi, xuanzhuo
There is only vhost_set_dev_enable op in VhostOps. Thus, we introduce
the interface vhost_set_vring_enable to set the enable status for a
single vring.
Resetting a single vq will rely on this interface.
Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
hw/virtio/vhost-user.c | 25 ++++++++++++++++++-------
include/hw/virtio/vhost-backend.h | 3 +++
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 794519359b..3f140d5085 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1198,6 +1198,22 @@ static int vhost_user_set_vring_base(struct vhost_dev *dev,
return vhost_set_vring(dev, VHOST_USER_SET_VRING_BASE, ring);
}
+static int vhost_user_set_vring_enable(struct vhost_dev *dev,
+ int index,
+ int enable)
+{
+ if (index < dev->vq_index || index >= dev->vq_index + dev->nvqs) {
+ return -EINVAL;
+ }
+
+ struct vhost_vring_state state = {
+ .index = index,
+ .num = enable,
+ };
+
+ return vhost_set_vring(dev, VHOST_USER_SET_VRING_ENABLE, &state);
+}
+
static int vhost_user_set_dev_enable(struct vhost_dev *dev, int enable)
{
int i;
@@ -1207,13 +1223,7 @@ static int vhost_user_set_dev_enable(struct vhost_dev *dev, int enable)
}
for (i = 0; i < dev->nvqs; ++i) {
- int ret;
- struct vhost_vring_state state = {
- .index = dev->vq_index + i,
- .num = enable,
- };
-
- ret = vhost_set_vring(dev, VHOST_USER_SET_VRING_ENABLE, &state);
+ int ret = vhost_user_set_vring_enable(dev, dev->vq_index + i, enable);
if (ret < 0) {
/*
* Restoring the previous state is likely infeasible, as well as
@@ -2627,6 +2637,7 @@ const VhostOps user_ops = {
.vhost_set_owner = vhost_user_set_owner,
.vhost_reset_device = vhost_user_reset_device,
.vhost_get_vq_index = vhost_user_get_vq_index,
+ .vhost_set_vring_enable = vhost_user_set_vring_enable,
.vhost_set_dev_enable = vhost_user_set_dev_enable,
.vhost_requires_shm_log = vhost_user_requires_shm_log,
.vhost_migration_done = vhost_user_migration_done,
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
index b49432045f..dad7191bac 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -81,6 +81,8 @@ typedef int (*vhost_set_backend_cap_op)(struct vhost_dev *dev);
typedef int (*vhost_set_owner_op)(struct vhost_dev *dev);
typedef int (*vhost_reset_device_op)(struct vhost_dev *dev);
typedef int (*vhost_get_vq_index_op)(struct vhost_dev *dev, int idx);
+typedef int (*vhost_set_vring_enable_op)(struct vhost_dev *dev,
+ int index, int enable);
typedef int (*vhost_set_dev_enable_op)(struct vhost_dev *dev,
int enable);
typedef bool (*vhost_requires_shm_log_op)(struct vhost_dev *dev);
@@ -155,6 +157,7 @@ typedef struct VhostOps {
vhost_set_owner_op vhost_set_owner;
vhost_reset_device_op vhost_reset_device;
vhost_get_vq_index_op vhost_get_vq_index;
+ vhost_set_vring_enable_op vhost_set_vring_enable;
vhost_set_dev_enable_op vhost_set_dev_enable;
vhost_requires_shm_log_op vhost_requires_shm_log;
vhost_migration_done_op vhost_migration_done;
--
2.32.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 4/8] vhost-user: introduce vhost_reset_vring() interface
2022-08-26 10:56 [PATCH 0/8] Support VIRTIO_F_RING_RESET for vhost-user in virtio pci-modern Kangjie Xu
` (2 preceding siblings ...)
2022-08-26 10:56 ` [PATCH 3/8] vhost-user: add op to enable or disable a single vring Kangjie Xu
@ 2022-08-26 10:56 ` Kangjie Xu
2022-08-26 10:56 ` [PATCH 5/8] vhost-net: vhost-user: update vhost_net_virtqueue_reset() Kangjie Xu
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Kangjie Xu @ 2022-08-26 10:56 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, jasowang, arei.gonglei, hengqi, xuanzhuo
Introduce the interface vhost_reset_vring(). The interface is a wrapper
to send a VHOST_USER_RESET_VRING message to the back-end. It will reset
an individual vring in the back-end. Meanwhile, it will wait for a reply
to ensure the reset has been completed.
Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
hw/virtio/vhost-user.c | 41 +++++++++++++++++++++++++++++++
include/hw/virtio/vhost-backend.h | 3 +++
2 files changed, 44 insertions(+)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 3f140d5085..b49076fdc4 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -126,6 +126,7 @@ typedef enum VhostUserRequest {
VHOST_USER_GET_MAX_MEM_SLOTS = 36,
VHOST_USER_ADD_MEM_REG = 37,
VHOST_USER_REM_MEM_REG = 38,
+ VHOST_USER_RESET_VRING = 41,
VHOST_USER_MAX
} VhostUserRequest;
@@ -1508,6 +1509,45 @@ static int vhost_user_get_max_memslots(struct vhost_dev *dev,
return 0;
}
+static int vhost_user_reset_vring(struct vhost_dev *dev,
+ struct vhost_vring_state *ring)
+{
+ int ret;
+ VhostUserMsg msg = {
+ .hdr.request = VHOST_USER_RESET_VRING,
+ .hdr.flags = VHOST_USER_VERSION,
+ .payload.state = *ring,
+ .hdr.size = sizeof(msg.payload.state),
+ };
+
+ if (!virtio_has_feature(dev->acked_features, VIRTIO_F_RING_RESET)) {
+ return -ENOTSUP;
+ }
+
+ ret = vhost_user_write(dev, &msg, NULL, 0);
+ if (ret < 0) {
+ return ret;
+ }
+
+ ret = vhost_user_read(dev, &msg);
+ if (ret < 0) {
+ return ret;
+ }
+
+ if (msg.hdr.request != VHOST_USER_RESET_VRING) {
+ error_report("Received unexpected msg type. Expected %d received %d",
+ VHOST_USER_RESET_VRING, msg.hdr.request);
+ return -EPROTO;
+ }
+
+ if (msg.hdr.size != sizeof(msg.payload.state)) {
+ error_report("Received bad msg size.");
+ return -EPROTO;
+ }
+
+ return 0;
+}
+
static int vhost_user_reset_device(struct vhost_dev *dev)
{
VhostUserMsg msg = {
@@ -2635,6 +2675,7 @@ const VhostOps user_ops = {
.vhost_set_features = vhost_user_set_features,
.vhost_get_features = vhost_user_get_features,
.vhost_set_owner = vhost_user_set_owner,
+ .vhost_reset_vring = vhost_user_reset_vring,
.vhost_reset_device = vhost_user_reset_device,
.vhost_get_vq_index = vhost_user_get_vq_index,
.vhost_set_vring_enable = vhost_user_set_vring_enable,
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
index dad7191bac..ec65a55a77 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -79,6 +79,8 @@ typedef int (*vhost_get_features_op)(struct vhost_dev *dev,
uint64_t *features);
typedef int (*vhost_set_backend_cap_op)(struct vhost_dev *dev);
typedef int (*vhost_set_owner_op)(struct vhost_dev *dev);
+typedef int (*vhost_reset_vring_op)(struct vhost_dev *dev,
+ struct vhost_vring_state *ring);
typedef int (*vhost_reset_device_op)(struct vhost_dev *dev);
typedef int (*vhost_get_vq_index_op)(struct vhost_dev *dev, int idx);
typedef int (*vhost_set_vring_enable_op)(struct vhost_dev *dev,
@@ -156,6 +158,7 @@ typedef struct VhostOps {
vhost_set_backend_cap_op vhost_set_backend_cap;
vhost_set_owner_op vhost_set_owner;
vhost_reset_device_op vhost_reset_device;
+ vhost_reset_vring_op vhost_reset_vring;
vhost_get_vq_index_op vhost_get_vq_index;
vhost_set_vring_enable_op vhost_set_vring_enable;
vhost_set_dev_enable_op vhost_set_dev_enable;
--
2.32.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 5/8] vhost-net: vhost-user: update vhost_net_virtqueue_reset()
2022-08-26 10:56 [PATCH 0/8] Support VIRTIO_F_RING_RESET for vhost-user in virtio pci-modern Kangjie Xu
` (3 preceding siblings ...)
2022-08-26 10:56 ` [PATCH 4/8] vhost-user: introduce vhost_reset_vring() interface Kangjie Xu
@ 2022-08-26 10:56 ` Kangjie Xu
2022-08-26 10:56 ` [PATCH 6/8] vhost-net: vhost-user: update vhost_net_virtqueue_restart() Kangjie Xu
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Kangjie Xu @ 2022-08-26 10:56 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, jasowang, arei.gonglei, hengqi, xuanzhuo
Update vhost_net_virtqueue_reset() for vhost-user scenario.
In order to reuse some functions, we process the idx for
vhost-user scenario because vhost_get_vq_index behave
differently for vhost-user.
Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
hw/net/vhost_net.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index c0c1456172..8ad5743f7c 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -522,19 +522,28 @@ void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetClientState *nc,
VHostNetState *net = get_vhost_net(nc->peer);
const VhostOps *vhost_ops = net->dev.vhost_ops;
struct vhost_vring_file file = { .fd = -1 };
- int idx;
+ struct vhost_vring_state state;
+ int idx, r;
/* should only be called after backend is connected */
assert(vhost_ops);
idx = vhost_ops->vhost_get_vq_index(&net->dev, vq_index);
+ if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
+ idx -= net->dev.vq_index;
+ }
if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
file.index = idx;
- int r = vhost_net_set_backend(&net->dev, &file);
+ r = vhost_net_set_backend(&net->dev, &file);
assert(r >= 0);
}
+ if (vhost_ops->vhost_reset_vring) {
+ state.index = net->dev.vq_index + idx;
+ r = vhost_ops->vhost_reset_vring(&net->dev, &state);
+ }
+
vhost_virtqueue_unmap(&net->dev, vdev, net->dev.vqs + idx, idx);
}
--
2.32.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 6/8] vhost-net: vhost-user: update vhost_net_virtqueue_restart()
2022-08-26 10:56 [PATCH 0/8] Support VIRTIO_F_RING_RESET for vhost-user in virtio pci-modern Kangjie Xu
` (4 preceding siblings ...)
2022-08-26 10:56 ` [PATCH 5/8] vhost-net: vhost-user: update vhost_net_virtqueue_reset() Kangjie Xu
@ 2022-08-26 10:56 ` Kangjie Xu
2022-08-26 10:56 ` [PATCH 7/8] virtio-net: vhost-user: update queue_reset and queue_enable Kangjie Xu
2022-08-26 10:56 ` [PATCH 8/8] vhost: vhost-user: enable vq reset feature Kangjie Xu
7 siblings, 0 replies; 9+ messages in thread
From: Kangjie Xu @ 2022-08-26 10:56 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, jasowang, arei.gonglei, hengqi, xuanzhuo
Update vhost_net_virtqueue_restart() for vhost-user scenario.
In order to reuse some functions, we process the idx for
vhost-user case. It is because vhost_get_vq_index behave
differently in vhost-user.
Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
hw/net/vhost_net.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 8ad5743f7c..13b9c11e68 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -563,6 +563,9 @@ int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc,
assert(vhost_ops);
idx = vhost_ops->vhost_get_vq_index(&net->dev, vq_index);
+ if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
+ idx -= net->dev.vq_index;
+ }
r = vhost_virtqueue_start(&net->dev,
vdev,
@@ -572,6 +575,15 @@ int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc,
goto err_start;
}
+ if (vhost_ops->vhost_set_vring_enable) {
+ r = vhost_ops->vhost_set_vring_enable(&net->dev,
+ net->dev.vq_index + idx,
+ 1);
+ if (r < 0) {
+ goto err_start;
+ }
+ }
+
if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
file.index = idx;
file.fd = net->backend;
--
2.32.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 7/8] virtio-net: vhost-user: update queue_reset and queue_enable
2022-08-26 10:56 [PATCH 0/8] Support VIRTIO_F_RING_RESET for vhost-user in virtio pci-modern Kangjie Xu
` (5 preceding siblings ...)
2022-08-26 10:56 ` [PATCH 6/8] vhost-net: vhost-user: update vhost_net_virtqueue_restart() Kangjie Xu
@ 2022-08-26 10:56 ` Kangjie Xu
2022-08-26 10:56 ` [PATCH 8/8] vhost: vhost-user: enable vq reset feature Kangjie Xu
7 siblings, 0 replies; 9+ messages in thread
From: Kangjie Xu @ 2022-08-26 10:56 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, jasowang, arei.gonglei, hengqi, xuanzhuo
Update virtio_net_queue_reset() and virtio_net_queue_enable()
for vhost-user scenario.
Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
hw/net/virtio-net.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 6ab796b399..19a2132180 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -550,7 +550,8 @@ static void virtio_net_queue_reset(VirtIODevice *vdev, uint32_t queue_index)
}
if (get_vhost_net(nc->peer) &&
- nc->peer->info->type == NET_CLIENT_DRIVER_TAP) {
+ (nc->peer->info->type == NET_CLIENT_DRIVER_TAP ||
+ nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_USER)) {
vhost_net_virtqueue_reset(vdev, nc, queue_index);
}
@@ -568,7 +569,8 @@ static void virtio_net_queue_enable(VirtIODevice *vdev, uint32_t queue_index)
}
if (get_vhost_net(nc->peer) &&
- nc->peer->info->type == NET_CLIENT_DRIVER_TAP) {
+ (nc->peer->info->type == NET_CLIENT_DRIVER_TAP ||
+ nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_USER)) {
r = vhost_net_virtqueue_restart(vdev, nc, queue_index);
if (r < 0) {
error_report("unable to restart vhost net virtqueue: %d, "
--
2.32.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 8/8] vhost: vhost-user: enable vq reset feature
2022-08-26 10:56 [PATCH 0/8] Support VIRTIO_F_RING_RESET for vhost-user in virtio pci-modern Kangjie Xu
` (6 preceding siblings ...)
2022-08-26 10:56 ` [PATCH 7/8] virtio-net: vhost-user: update queue_reset and queue_enable Kangjie Xu
@ 2022-08-26 10:56 ` Kangjie Xu
7 siblings, 0 replies; 9+ messages in thread
From: Kangjie Xu @ 2022-08-26 10:56 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, jasowang, arei.gonglei, hengqi, xuanzhuo
Add virtqueue reset feature for vhost-user.
Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
hw/net/vhost_net.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 13b9c11e68..745cb4375b 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -74,6 +74,7 @@ static const int user_feature_bits[] = {
VIRTIO_NET_F_MTU,
VIRTIO_F_IOMMU_PLATFORM,
VIRTIO_F_RING_PACKED,
+ VIRTIO_F_RING_RESET,
VIRTIO_NET_F_RSS,
VIRTIO_NET_F_HASH_REPORT,
--
2.32.0
^ permalink raw reply related [flat|nested] 9+ messages in thread