[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v3 5/8] vhost: introduce vhost_set_vring_ready method
From: |
Cindy Lu |
Subject: |
[RFC v3 5/8] vhost: introduce vhost_set_vring_ready method |
Date: |
Fri, 29 May 2020 22:06:17 +0800 |
From: Jason Wang <jasowang@redhat.com>
Vhost-vdpa introduces VHOST_VDPA_SET_VRING_ENABLE which complies the
semantic of queue_enable defined in virtio spec. This method can be
used for preventing device from executing request for a specific
virtqueue. This patch introduces the vhost_ops for this.
Note that, we've already had vhost_set_vring_enable which has different
semantic which allows to enable or disable a specific virtqueue for
some kinds of vhost backends. E.g vhost-user use this to changes the
number of active queue pairs.
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/net/vhost_net-stub.c | 4 ++++
hw/net/vhost_net.c | 11 ++++++++++-
include/net/vhost_net.h | 1 +
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c
index aac0e98228..43e93e1a9a 100644
--- a/hw/net/vhost_net-stub.c
+++ b/hw/net/vhost_net-stub.c
@@ -86,6 +86,10 @@ int vhost_set_vring_enable(NetClientState *nc, int enable)
return 0;
}
+int vhost_set_vring_ready(NetClientState *nc)
+{
+ return 0;
+}
int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu)
{
return 0;
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index d1d421e3d9..e2bc7de2eb 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -344,7 +344,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
goto err_start;
}
- if (ncs[i].peer->vring_enable) {
+ if (peer->vring_enable) {
/* restore vring enable state */
r = vhost_set_vring_enable(peer, peer->vring_enable);
@@ -455,6 +455,15 @@ int vhost_set_vring_enable(NetClientState *nc, int enable)
return 0;
}
+int vhost_set_vring_ready(NetClientState *nc)
+{
+ VHostNetState *net = get_vhost_net(nc);
+ const VhostOps *vhost_ops = net->dev.vhost_ops;
+ if (vhost_ops && vhost_ops->vhost_set_vring_ready) {
+ return vhost_ops->vhost_set_vring_ready(&net->dev);
+ }
+ return 0;
+}
int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu)
{
const VhostOps *vhost_ops = net->dev.vhost_ops;
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
index 77e47398c4..8a6f208189 100644
--- a/include/net/vhost_net.h
+++ b/include/net/vhost_net.h
@@ -35,6 +35,7 @@ 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_vring_ready(NetClientState *nc);
uint64_t vhost_net_get_acked_features(VHostNetState *net);
--
2.21.1
- [RFC v3 0/8] vDPA support in qemu, Cindy Lu, 2020/05/29
- [RFC v3 1/8] net: introduce qemu_get_peer, Cindy Lu, 2020/05/29
- [RFC v3 2/8] vhost_net: use the function qemu_get_peer, Cindy Lu, 2020/05/29
- [RFC v3 3/8] virtio-bus: introduce queue_enabled method, Cindy Lu, 2020/05/29
- [RFC v3 4/8] virtio-pci: implement queue_enabled method, Cindy Lu, 2020/05/29
- [RFC v3 5/8] vhost: introduce vhost_set_vring_ready method,
Cindy Lu <=
- [RFC v3 6/8] vhost-backend: export the vhost backend helper, Cindy Lu, 2020/05/29
- [RFC v3 7/8] vhost-vdpa: introduce vhost-vdpa backend, Cindy Lu, 2020/05/29
- [RFC v3 8/8] vhost-vdpa: introduce vhost-vdpa net client, Cindy Lu, 2020/05/29
- Re: [RFC v3 0/8] vDPA support in qemu, no-reply, 2020/05/29
- Re: [RFC v3 0/8] vDPA support in qemu, no-reply, 2020/05/29
- Re: [RFC v3 0/8] vDPA support in qemu, no-reply, 2020/05/29