[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/8] vhost-net: vhost-user: update vhost_net_virtqueue_reset()
From: |
Kangjie Xu |
Subject: |
[PATCH 5/8] vhost-net: vhost-user: update vhost_net_virtqueue_reset() |
Date: |
Fri, 26 Aug 2022 18:56:17 +0800 |
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
- [PATCH 0/8] Support VIRTIO_F_RING_RESET for vhost-user in virtio pci-modern, Kangjie Xu, 2022/08/26
- [PATCH 2/8] net: virtio: rename vhost_set_vring_enable to vhost_set_dev_enable, Kangjie Xu, 2022/08/26
- [PATCH 7/8] virtio-net: vhost-user: update queue_reset and queue_enable, Kangjie Xu, 2022/08/26
- [PATCH 4/8] vhost-user: introduce vhost_reset_vring() interface, Kangjie Xu, 2022/08/26
- [PATCH 3/8] vhost-user: add op to enable or disable a single vring, Kangjie Xu, 2022/08/26
- [PATCH 1/8] docs: vhost-user: add VHOST_USER_RESET_VRING message, Kangjie Xu, 2022/08/26
- [PATCH 8/8] vhost: vhost-user: enable vq reset feature, Kangjie Xu, 2022/08/26
- [PATCH 5/8] vhost-net: vhost-user: update vhost_net_virtqueue_reset(),
Kangjie Xu <=
- [PATCH 6/8] vhost-net: vhost-user: update vhost_net_virtqueue_restart(), Kangjie Xu, 2022/08/26