From: "Eugenio Pérez" <eperezma@redhat.com>
To: qemu-devel@nongnu.org
Cc: Cindy Lu <lulu@redhat.com>,
Harpreet Singh Anand <hanand@xilinx.com>,
Zhu Lingshan <lingshan.zhu@intel.com>,
Stefano Garzarella <sgarzare@redhat.com>,
Gautam Dawar <gdawar@xilinx.com>, Eli Cohen <eli@mellanox.com>,
Parav Pandit <parav@mellanox.com>,
Jason Wang <jasowang@redhat.com>,
Si-Wei Liu <si-wei.liu@oracle.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Liuxiangdong <liuxiangdong5@huawei.com>,
Laurent Vivier <lvivier@redhat.com>
Subject: [PATCH v2 2/3] virtio_net: Handle _F_STATUS emulation in virtio_net_get_config
Date: Fri, 28 Oct 2022 17:19:16 +0200 [thread overview]
Message-ID: <20221028151917.260038-3-eperezma@redhat.com> (raw)
In-Reply-To: <20221028151917.260038-1-eperezma@redhat.com>
At this moment this code path is not reached, but vdpa devices can offer
VIRTIO_NET_F_STATUS unconditionally. While the guest must assume that
link is always up by the standard, qemu will set the status bit to 1
always in this case.
This makes little use by itself, but VIRTIO_NET_F_STATUS is needed for
the guest to read status bit VIRTIO_NET_F_GUEST_ANNOUNCE, used by feature
VIRTIO_NET_F_GUEST_ANNOUNCE. So qemu must emulate status feature in case
it needs to emulate the guest announce feature.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/net/virtio-net.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 56ff219196..6d4d75615b 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -156,8 +156,9 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
* disconnect/reconnect a VDPA peer.
*/
if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
- ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
- n->config_size);
+ struct vhost_net *net = get_vhost_net(nc->peer);
+
+ ret = vhost_net_get_config(net, (uint8_t *)&netcfg, n->config_size);
if (ret == -1) {
return;
}
@@ -173,6 +174,12 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
memcpy(netcfg.mac, n->mac, ETH_ALEN);
}
+ if (vdev->guest_features & BIT_ULL(VIRTIO_NET_F_STATUS) &&
+ !(net->dev.features & BIT_ULL(VIRTIO_NET_F_STATUS))) {
+ /* Emulating link up in qemu */
+ netcfg.status |= virtio_tswap16(vdev, VIRTIO_NET_S_LINK_UP);
+ }
+
memcpy(config, &netcfg, n->config_size);
}
}
--
2.31.1
next prev parent reply other threads:[~2022-10-28 15:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 15:19 [PATCH v2 0/3] Emulate status feature in vhost-vdpa net Eugenio Pérez
2022-10-28 15:19 ` [PATCH v2 1/3] virtio_net: Modify virtio_net_get_config to early return Eugenio Pérez
2022-10-28 15:19 ` Eugenio Pérez [this message]
2022-10-28 15:19 ` [PATCH v2 3/3] vhost_vdpa: move VIRTIO_NET_F_STATUS handling to vhost_net Eugenio Pérez
2022-10-29 8:24 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221028151917.260038-3-eperezma@redhat.com \
--to=eperezma@redhat.com \
--cc=eli@mellanox.com \
--cc=gdawar@xilinx.com \
--cc=hanand@xilinx.com \
--cc=jasowang@redhat.com \
--cc=lingshan.zhu@intel.com \
--cc=liuxiangdong5@huawei.com \
--cc=lulu@redhat.com \
--cc=lvivier@redhat.com \
--cc=mst@redhat.com \
--cc=parav@mellanox.com \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
--cc=si-wei.liu@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).