Message ID | 20221028151917.260038-4-eperezma@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Emulate status feature in vhost-vdpa net | expand |
On Fri, Oct 28, 2022 at 05:19:17PM +0200, Eugenio Pérez wrote: > Since it is emulated on all vhost backends it makes sense to move it. > > Although this feature can be emulated by qemu it benefits from > information from the device. Ack it as long as the guest ack it. > > Signed-off-by: Eugenio Pérez <eperezma@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> So I assume Jason's tree too? > --- > hw/net/vhost_net.c | 13 +++++++++++++ > net/vhost-vdpa.c | 1 - > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c > index d28f8b974b..b533744211 100644 > --- a/hw/net/vhost_net.c > +++ b/hw/net/vhost_net.c > @@ -127,8 +127,21 @@ int vhost_net_set_config(struct vhost_net *net, const uint8_t *data, > > void vhost_net_ack_features(struct vhost_net *net, uint64_t features) > { > + static const int status_feature_bit[] = { > + VIRTIO_NET_F_STATUS, > + VHOST_INVALID_FEATURE_BIT, > + }; > + > net->dev.acked_features = net->dev.backend_features; > vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), features); > + if (net->dev.features & BIT_ULL(VIRTIO_NET_F_STATUS)) { > + /* > + * If device support _F_STATUS qemu should ack it so it reports link > + * status changes. If not supported qemu emulates it reporting an > + * always up link. > + */ > + vhost_ack_features(&net->dev, status_feature_bit, features); > + } > } > > uint64_t vhost_net_get_max_queues(VHostNetState *net) > diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c > index 6d64000202..854b27186c 100644 > --- a/net/vhost-vdpa.c > +++ b/net/vhost-vdpa.c > @@ -72,7 +72,6 @@ const int vdpa_feature_bits[] = { > VIRTIO_NET_F_RSS, > VIRTIO_NET_F_HASH_REPORT, > VIRTIO_NET_F_GUEST_ANNOUNCE, > - VIRTIO_NET_F_STATUS, > VHOST_INVALID_FEATURE_BIT > }; > > -- > 2.31.1
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index d28f8b974b..b533744211 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -127,8 +127,21 @@ int vhost_net_set_config(struct vhost_net *net, const uint8_t *data, void vhost_net_ack_features(struct vhost_net *net, uint64_t features) { + static const int status_feature_bit[] = { + VIRTIO_NET_F_STATUS, + VHOST_INVALID_FEATURE_BIT, + }; + net->dev.acked_features = net->dev.backend_features; vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), features); + if (net->dev.features & BIT_ULL(VIRTIO_NET_F_STATUS)) { + /* + * If device support _F_STATUS qemu should ack it so it reports link + * status changes. If not supported qemu emulates it reporting an + * always up link. + */ + vhost_ack_features(&net->dev, status_feature_bit, features); + } } uint64_t vhost_net_get_max_queues(VHostNetState *net) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 6d64000202..854b27186c 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -72,7 +72,6 @@ const int vdpa_feature_bits[] = { VIRTIO_NET_F_RSS, VIRTIO_NET_F_HASH_REPORT, VIRTIO_NET_F_GUEST_ANNOUNCE, - VIRTIO_NET_F_STATUS, VHOST_INVALID_FEATURE_BIT };
Since it is emulated on all vhost backends it makes sense to move it. Although this feature can be emulated by qemu it benefits from information from the device. Ack it as long as the guest ack it. Signed-off-by: Eugenio Pérez <eperezma@redhat.com> --- hw/net/vhost_net.c | 13 +++++++++++++ net/vhost-vdpa.c | 1 - 2 files changed, 13 insertions(+), 1 deletion(-)