qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Viktor Prutyanov <viktor@daynix.com>
Cc: mst@redhat.com, peterx@redhat.com, marcel.apfelbaum@gmail.com,
	 qemu-devel@nongnu.org, yan@daynix.com,
	yuri.benditovich@daynix.com
Subject: Re: [RFC PATCH v2 4/4] virtio-net: pass Device-TLB enable/disable events to vhost
Date: Mon, 8 May 2023 13:26:10 +0800	[thread overview]
Message-ID: <CACGkMEvpy0YPy_qr4C=RPA_vUALJi0kMNZzwXNC8AXZbxWVyRw@mail.gmail.com> (raw)
In-Reply-To: <20230501020221.188376-5-viktor@daynix.com>

On Mon, May 1, 2023 at 10:02 AM Viktor Prutyanov <viktor@daynix.com> wrote:
>
> If vhost is enabled for virtio-net, Device-TLB enable/disable events
> must be passed to vhost for proper IOMMU unmap flag selection.

The patch looks good, just wonder if you have tested it with vhost-user?

(It looks to me like it should work there).

Thanks

>
> Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
> ---
>  hw/net/vhost_net.c      | 11 +++++++++++
>  hw/net/virtio-net.c     |  8 ++++++++
>  include/net/vhost_net.h |  2 ++
>  3 files changed, 21 insertions(+)
>
> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> index c4eecc6f36..2364c8de99 100644
> --- a/hw/net/vhost_net.c
> +++ b/hw/net/vhost_net.c
> @@ -552,6 +552,17 @@ int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu)
>      return vhost_ops->vhost_net_set_mtu(&net->dev, mtu);
>  }
>
> +void vhost_net_toggle_device_iotlb(struct vhost_dev *dev, bool enable)
> +{
> +    const VhostOps *vhost_ops = dev->vhost_ops;
> +
> +    if (!vhost_ops->vhost_toggle_device_iotlb) {
> +        return;
> +    }
> +
> +    vhost_ops->vhost_toggle_device_iotlb(dev, enable);
> +}
> +
>  void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetClientState *nc,
>                                 int vq_index)
>  {
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 53e1c32643..e6851b885c 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -3843,6 +3843,13 @@ static struct vhost_dev *virtio_net_get_vhost(VirtIODevice *vdev)
>      return &net->dev;
>  }
>
> +static void virtio_net_toggle_device_iotlb(VirtIODevice *vdev,
> +                                           bool enable)
> +{
> +    if (vdev->vhost_started)
> +        vhost_net_toggle_device_iotlb(virtio_net_get_vhost(vdev), enable);
> +}
> +
>  static const VMStateDescription vmstate_virtio_net = {
>      .name = "virtio-net",
>      .minimum_version_id = VIRTIO_NET_VM_VERSION,
> @@ -3948,6 +3955,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data)
>      vdc->vmsd = &vmstate_virtio_net_device;
>      vdc->primary_unplug_pending = primary_unplug_pending;
>      vdc->get_vhost = virtio_net_get_vhost;
> +    vdc->toggle_device_iotlb = virtio_net_toggle_device_iotlb;
>  }
>
>  static const TypeInfo virtio_net_info = {
> diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
> index c37aba35e6..36d527f321 100644
> --- a/include/net/vhost_net.h
> +++ b/include/net/vhost_net.h
> @@ -56,4 +56,6 @@ int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc,
>                                  int vq_index);
>
>  void vhost_net_save_acked_features(NetClientState *nc);
> +
> +void vhost_net_toggle_device_iotlb(struct vhost_dev *dev, bool enable);
>  #endif
> --
> 2.35.1
>



  reply	other threads:[~2023-05-08  5:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-01  2:02 [RFC PATCH v2 0/4] vhost: register and change IOMMU flag depending on ATS state Viktor Prutyanov
2023-05-01  2:02 ` [RFC PATCH v2 1/4] pci: add handling of Enable bit in ATS Control Register Viktor Prutyanov
2023-05-01  2:02 ` [RFC PATCH v2 2/4] virtio-pci: add handling of ATS and Device-TLB enable Viktor Prutyanov
2023-05-08  4:14   ` Jason Wang
2023-05-01  2:02 ` [RFC PATCH v2 3/4] vhost: register and change IOMMU flag depending on Device-TLB state Viktor Prutyanov
2023-05-08  5:25   ` Jason Wang
2023-05-08  5:28     ` Jason Wang
2023-05-12 14:13       ` Viktor Prutyanov
2023-05-01  2:02 ` [RFC PATCH v2 4/4] virtio-net: pass Device-TLB enable/disable events to vhost Viktor Prutyanov
2023-05-08  5:26   ` Jason Wang [this message]
2023-05-12 14:06     ` Viktor Prutyanov
2023-05-08  4:09 ` [RFC PATCH v2 0/4] vhost: register and change IOMMU flag depending on ATS state Jason Wang

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='CACGkMEvpy0YPy_qr4C=RPA_vUALJi0kMNZzwXNC8AXZbxWVyRw@mail.gmail.com' \
    --to=jasowang@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=viktor@daynix.com \
    --cc=yan@daynix.com \
    --cc=yuri.benditovich@daynix.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).