* [PATCH v3 1/4] virtio_net: Modify virtio_net_get_config to early return
2022-12-21 11:50 [PATCH v3 0/4] Guest announce feature emulation using Shadow VirtQueue Eugenio Pérez
@ 2022-12-21 11:50 ` Eugenio Pérez
2022-12-21 11:50 ` [PATCH v3 2/4] virtio_net: copy VIRTIO_NET_S_ANNOUNCE if device model has it Eugenio Pérez
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Eugenio Pérez @ 2022-12-21 11:50 UTC (permalink / raw)
To: qemu-devel
Cc: Stefano Garzarella, Lei Yang, Zhu Lingshan, Eli Cohen,
Michael S. Tsirkin, Gautam Dawar, Jason Wang, Parav Pandit,
Laurent Vivier, Si-Wei Liu, Harpreet Singh Anand, Liuxiangdong,
Cindy Lu
Next patches introduce more code on vhost-vdpa branch, with already have
too much indentation.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
---
hw/net/virtio-net.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 9cbdfa5547..b30038d130 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -168,20 +168,22 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
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);
- if (ret != -1) {
- /*
- * Some NIC/kernel combinations present 0 as the mac address. As
- * that is not a legal address, try to proceed with the
- * address from the QEMU command line in the hope that the
- * address has been configured correctly elsewhere - just not
- * reported by the device.
- */
- if (memcmp(&netcfg.mac, &zero, sizeof(zero)) == 0) {
- info_report("Zero hardware mac address detected. Ignoring.");
- memcpy(netcfg.mac, n->mac, ETH_ALEN);
- }
- memcpy(config, &netcfg, n->config_size);
+ if (ret == -1) {
+ return;
}
+
+ /*
+ * Some NIC/kernel combinations present 0 as the mac address. As that
+ * is not a legal address, try to proceed with the address from the
+ * QEMU command line in the hope that the address has been configured
+ * correctly elsewhere - just not reported by the device.
+ */
+ if (memcmp(&netcfg.mac, &zero, sizeof(zero)) == 0) {
+ info_report("Zero hardware mac address detected. Ignoring.");
+ memcpy(netcfg.mac, n->mac, ETH_ALEN);
+ }
+
+ memcpy(config, &netcfg, n->config_size);
}
}
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/4] virtio_net: copy VIRTIO_NET_S_ANNOUNCE if device model has it
2022-12-21 11:50 [PATCH v3 0/4] Guest announce feature emulation using Shadow VirtQueue Eugenio Pérez
2022-12-21 11:50 ` [PATCH v3 1/4] virtio_net: Modify virtio_net_get_config to early return Eugenio Pérez
@ 2022-12-21 11:50 ` Eugenio Pérez
2022-12-22 5:14 ` Jason Wang
2022-12-21 11:50 ` [PATCH v3 3/4] vdpa: handle VIRTIO_NET_CTRL_ANNOUNCE in vhost_vdpa_net_handle_ctrl_avail Eugenio Pérez
2022-12-21 11:50 ` [PATCH v3 4/4] vdpa: do not handle VIRTIO_NET_F_GUEST_ANNOUNCE in vhost-vdpa Eugenio Pérez
3 siblings, 1 reply; 7+ messages in thread
From: Eugenio Pérez @ 2022-12-21 11:50 UTC (permalink / raw)
To: qemu-devel
Cc: Stefano Garzarella, Lei Yang, Zhu Lingshan, Eli Cohen,
Michael S. Tsirkin, Gautam Dawar, Jason Wang, Parav Pandit,
Laurent Vivier, Si-Wei Liu, Harpreet Singh Anand, Liuxiangdong,
Cindy Lu
Status part of the emulated feature. It will follow device model, so we
must copy it as long as NIC device model has it set.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
v3: Add virtio byte swapping writing net config status.
---
hw/net/virtio-net.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index b30038d130..122eac25ee 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -183,6 +183,8 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
memcpy(netcfg.mac, n->mac, ETH_ALEN);
}
+ netcfg.status |= virtio_tswap16(vdev,
+ n->status & VIRTIO_NET_S_ANNOUNCE);
memcpy(config, &netcfg, n->config_size);
}
}
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 2/4] virtio_net: copy VIRTIO_NET_S_ANNOUNCE if device model has it
2022-12-21 11:50 ` [PATCH v3 2/4] virtio_net: copy VIRTIO_NET_S_ANNOUNCE if device model has it Eugenio Pérez
@ 2022-12-22 5:14 ` Jason Wang
0 siblings, 0 replies; 7+ messages in thread
From: Jason Wang @ 2022-12-22 5:14 UTC (permalink / raw)
To: Eugenio Pérez
Cc: qemu-devel, Stefano Garzarella, Lei Yang, Zhu Lingshan, Eli Cohen,
Michael S. Tsirkin, Gautam Dawar, Parav Pandit, Laurent Vivier,
Si-Wei Liu, Harpreet Singh Anand, Liuxiangdong, Cindy Lu
On Wed, Dec 21, 2022 at 7:50 PM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> Status part of the emulated feature. It will follow device model, so we
> must copy it as long as NIC device model has it set.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Thanks
> ---
> v3: Add virtio byte swapping writing net config status.
> ---
> hw/net/virtio-net.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index b30038d130..122eac25ee 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -183,6 +183,8 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
> memcpy(netcfg.mac, n->mac, ETH_ALEN);
> }
>
> + netcfg.status |= virtio_tswap16(vdev,
> + n->status & VIRTIO_NET_S_ANNOUNCE);
> memcpy(config, &netcfg, n->config_size);
> }
> }
> --
> 2.31.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 3/4] vdpa: handle VIRTIO_NET_CTRL_ANNOUNCE in vhost_vdpa_net_handle_ctrl_avail
2022-12-21 11:50 [PATCH v3 0/4] Guest announce feature emulation using Shadow VirtQueue Eugenio Pérez
2022-12-21 11:50 ` [PATCH v3 1/4] virtio_net: Modify virtio_net_get_config to early return Eugenio Pérez
2022-12-21 11:50 ` [PATCH v3 2/4] virtio_net: copy VIRTIO_NET_S_ANNOUNCE if device model has it Eugenio Pérez
@ 2022-12-21 11:50 ` Eugenio Pérez
2022-12-22 5:16 ` Jason Wang
2022-12-21 11:50 ` [PATCH v3 4/4] vdpa: do not handle VIRTIO_NET_F_GUEST_ANNOUNCE in vhost-vdpa Eugenio Pérez
3 siblings, 1 reply; 7+ messages in thread
From: Eugenio Pérez @ 2022-12-21 11:50 UTC (permalink / raw)
To: qemu-devel
Cc: Stefano Garzarella, Lei Yang, Zhu Lingshan, Eli Cohen,
Michael S. Tsirkin, Gautam Dawar, Jason Wang, Parav Pandit,
Laurent Vivier, Si-Wei Liu, Harpreet Singh Anand, Liuxiangdong,
Cindy Lu
Since this capability is emulated by qemu shadowed CVQ cannot forward it
to the device. Process all that command within qemu.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
net/vhost-vdpa.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 260e474863..0b0712cd8a 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -489,9 +489,18 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq,
out.iov_len = iov_to_buf(elem->out_sg, elem->out_num, 0,
s->cvq_cmd_out_buffer,
vhost_vdpa_net_cvq_cmd_len());
- dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status));
- if (unlikely(dev_written < 0)) {
- goto out;
+ if (*(uint8_t *)s->cvq_cmd_out_buffer == VIRTIO_NET_CTRL_ANNOUNCE) {
+ /*
+ * Guest announce capability is emulated by qemu, so don't forward to
+ * the device.
+ */
+ dev_written = sizeof(status);
+ *s->status = VIRTIO_NET_OK;
+ } else {
+ dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status));
+ if (unlikely(dev_written < 0)) {
+ goto out;
+ }
}
if (unlikely(dev_written < sizeof(status))) {
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 3/4] vdpa: handle VIRTIO_NET_CTRL_ANNOUNCE in vhost_vdpa_net_handle_ctrl_avail
2022-12-21 11:50 ` [PATCH v3 3/4] vdpa: handle VIRTIO_NET_CTRL_ANNOUNCE in vhost_vdpa_net_handle_ctrl_avail Eugenio Pérez
@ 2022-12-22 5:16 ` Jason Wang
0 siblings, 0 replies; 7+ messages in thread
From: Jason Wang @ 2022-12-22 5:16 UTC (permalink / raw)
To: Eugenio Pérez
Cc: qemu-devel, Stefano Garzarella, Lei Yang, Zhu Lingshan, Eli Cohen,
Michael S. Tsirkin, Gautam Dawar, Parav Pandit, Laurent Vivier,
Si-Wei Liu, Harpreet Singh Anand, Liuxiangdong, Cindy Lu
On Wed, Dec 21, 2022 at 7:50 PM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> Since this capability is emulated by qemu shadowed CVQ cannot forward it
> to the device. Process all that command within qemu.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Thanks
> ---
> net/vhost-vdpa.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> index 260e474863..0b0712cd8a 100644
> --- a/net/vhost-vdpa.c
> +++ b/net/vhost-vdpa.c
> @@ -489,9 +489,18 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq,
> out.iov_len = iov_to_buf(elem->out_sg, elem->out_num, 0,
> s->cvq_cmd_out_buffer,
> vhost_vdpa_net_cvq_cmd_len());
> - dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status));
> - if (unlikely(dev_written < 0)) {
> - goto out;
> + if (*(uint8_t *)s->cvq_cmd_out_buffer == VIRTIO_NET_CTRL_ANNOUNCE) {
> + /*
> + * Guest announce capability is emulated by qemu, so don't forward to
> + * the device.
> + */
> + dev_written = sizeof(status);
> + *s->status = VIRTIO_NET_OK;
> + } else {
> + dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status));
> + if (unlikely(dev_written < 0)) {
> + goto out;
> + }
> }
>
> if (unlikely(dev_written < sizeof(status))) {
> --
> 2.31.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 4/4] vdpa: do not handle VIRTIO_NET_F_GUEST_ANNOUNCE in vhost-vdpa
2022-12-21 11:50 [PATCH v3 0/4] Guest announce feature emulation using Shadow VirtQueue Eugenio Pérez
` (2 preceding siblings ...)
2022-12-21 11:50 ` [PATCH v3 3/4] vdpa: handle VIRTIO_NET_CTRL_ANNOUNCE in vhost_vdpa_net_handle_ctrl_avail Eugenio Pérez
@ 2022-12-21 11:50 ` Eugenio Pérez
3 siblings, 0 replies; 7+ messages in thread
From: Eugenio Pérez @ 2022-12-21 11:50 UTC (permalink / raw)
To: qemu-devel
Cc: Stefano Garzarella, Lei Yang, Zhu Lingshan, Eli Cohen,
Michael S. Tsirkin, Gautam Dawar, Jason Wang, Parav Pandit,
Laurent Vivier, Si-Wei Liu, Harpreet Singh Anand, Liuxiangdong,
Cindy Lu
So qemu emulates it even in case the device does not support it.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
---
net/vhost-vdpa.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 0b0712cd8a..6e71c74da2 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -72,7 +72,6 @@ const int vdpa_feature_bits[] = {
VIRTIO_F_RING_RESET,
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
^ permalink raw reply related [flat|nested] 7+ messages in thread