qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] vdpa: Add vhost_vdpa_net_load_offloads


From: Jason Wang
Subject: Re: [PATCH 1/2] vdpa: Add vhost_vdpa_net_load_offloads
Date: Wed, 31 May 2023 09:47:16 +0800

On Mon, May 29, 2023 at 9:18 PM Hawkins Jiawei <yin31149@gmail.com> wrote:
>
> This patch introduces vhost_vdpa_net_load_offloads() to
> restore offloads state at device's startup.
>
> Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
> ---
>  net/vhost-vdpa.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>
> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> index 37cdc84562..682c749b19 100644
> --- a/net/vhost-vdpa.c
> +++ b/net/vhost-vdpa.c
> @@ -680,6 +680,28 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,
>      return *s->status != VIRTIO_NET_OK;
>  }
>
> +static int vhost_vdpa_net_load_offloads(VhostVDPAState *s,
> +                                        const VirtIONet *n)
> +{
> +    uint64_t features, offloads;
> +    ssize_t dev_written;
> +
> +    features = n->parent_obj.guest_features;

Any reason you need to do tricks like this instead of using
virtio_xxx_has_features()?

> +    if (!(features & BIT_ULL(VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))) {
> +        return 0;
> +    }
> +
> +    offloads = cpu_to_le64(n->curr_guest_offloads);
> +    dev_written = vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_GUEST_OFFLOADS,
> +                                          VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET,
> +                                          &offloads, sizeof(offloads));
> +    if (unlikely(dev_written < 0)) {
> +        return dev_written;
> +    }
> +
> +    return *s->status != VIRTIO_NET_OK;
> +}
> +
>  static int vhost_vdpa_net_load(NetClientState *nc)
>  {
>      VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
> @@ -702,6 +724,10 @@ static int vhost_vdpa_net_load(NetClientState *nc)
>      if (unlikely(r)) {
>          return r;
>      }
> +    r = vhost_vdpa_net_load_offloads(s, n);
> +    if (unlikely(r)) {
> +        return r;
> +    }
>
>      return 0;
>  }
> --
> 2.25.1
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]