From: Eugenio Perez Martin <eperezma@redhat.com>
To: Hawkins Jiawei <yin31149@gmail.com>
Cc: Jason Wang <jasowang@redhat.com>,
18801353760@163.com, qemu-devel@nongnu.org
Subject: Re: [PATCH 1/2] vdpa: Add vhost_vdpa_net_load_offloads
Date: Mon, 29 May 2023 18:19:00 +0200 [thread overview]
Message-ID: <CAJaqyWcURXY7GxM2goKHp55pfb-pCjOSYfDwzjsXbtSP1SnSkg@mail.gmail.com> (raw)
In-Reply-To: <ab861a8237c5e337bb0f969e1e8e761bc73901d5.1685359572.git.yin31149@gmail.com>
On Mon, May 29, 2023 at 3: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;
> + if (!(features & BIT_ULL(VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))) {
> + return 0;
> + }
> +
Maybe we can avoid sending this CVQ command if the guest already uses
the default values?
By default all features are enabled if I'm not wrong. I think the best
way is to expose virtio_net_supported_guest_offloads or
virtio_net_guest_offloads_by_features and then check if
n->curr_guest_offloads is the same.
We should do the same with vhost_vdpa_net_load_mq, but that is out of
the scope of this series.
Thanks!
> + 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
>
next prev parent reply other threads:[~2023-05-29 16:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-29 13:18 [PATCH 0/2] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
2023-05-29 13:18 ` [PATCH 1/2] vdpa: Add vhost_vdpa_net_load_offloads Hawkins Jiawei
2023-05-29 16:19 ` Eugenio Perez Martin [this message]
2023-05-31 8:23 ` Hawkins Jiawei
2023-05-31 8:35 ` Eugenio Perez Martin
2023-05-31 1:47 ` Jason Wang
2023-05-31 6:37 ` Eugenio Perez Martin
2023-05-31 8:27 ` Hawkins Jiawei
2023-05-29 13:18 ` [PATCH 2/2] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ Hawkins Jiawei
2023-05-31 1:47 ` Jason Wang
2023-05-29 16:55 ` [PATCH 0/2] Vhost-vdpa Shadow Virtqueue Offloads support Eugenio Perez Martin
2023-05-30 7:20 ` Hawkins Jiawei
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=CAJaqyWcURXY7GxM2goKHp55pfb-pCjOSYfDwzjsXbtSP1SnSkg@mail.gmail.com \
--to=eperezma@redhat.com \
--cc=18801353760@163.com \
--cc=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yin31149@gmail.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).