From: Hawkins Jiawei <yin31149@gmail.com>
To: Eugenio Perez Martin <eperezma@redhat.com>
Cc: jasowang@redhat.com, mst@redhat.com, qemu-devel@nongnu.org,
18801353760@163.com
Subject: Re: [PATCH v3 5/6] vdpa: Add vhost_vdpa_net_load_offloads()
Date: Fri, 2 Jun 2023 15:30:23 +0800 [thread overview]
Message-ID: <CAKrof1OSb=0rQJeWgvhiND3jszwYu2X8cNe5o88q7eX61vNehg@mail.gmail.com> (raw)
In-Reply-To: <CAJaqyWcS6enrAxwcGsi2qVt+7pHOkZg4E+t-=rmvsdPFbN-S6w@mail.gmail.com>
On 2023/6/1 22:12, Eugenio Perez Martin wrote:
> On Thu, Jun 1, 2023 at 3:49 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 | 38 ++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 38 insertions(+)
>>
>> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
>> index e907a3c792..0e647886d1 100644
>> --- a/net/vhost-vdpa.c
>> +++ b/net/vhost-vdpa.c
>> @@ -678,6 +678,40 @@ 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 offloads;
>> + ssize_t dev_written;
>> +
>> + if (!virtio_vdev_has_feature(&n->parent_obj,
>> + VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
>> + return 0;
>> + }
>> +
>> + offloads = cpu_to_le64(n->curr_guest_offloads);
>
> n->curr_guest_offloads is already stored in CPU order, we should only
> byte-swap it by the time of sending.
Yes, you are right.
I will correct it in the v4 patch.
Thanks!
>
> Thanks!
>
>> +
>> + if (offloads == virtio_net_supported_guest_offloads(n)) {
>> + /*
>> + * According to VirtIO standard, "Upon feature negotiation
>> + * corresponding offload gets enabled to preserve
>> + * backward compatibility."
>> + * So we do not need to send this CVQ command if the guest
>> + * also enables all supported offloads.
>> + */
>> + return 0;
>> + }
>> +
>> + 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);
>> @@ -700,6 +734,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-06-02 7:31 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-01 13:48 [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
2023-06-01 13:48 ` [PATCH v3 1/6] include/hw/virtio: make some VirtIODevice const Hawkins Jiawei
2023-06-01 14:14 ` Eugenio Perez Martin
2023-06-01 13:48 ` [PATCH v3 2/6] vdpa: reuse virtio_vdev_has_feature() Hawkins Jiawei
2023-06-01 14:14 ` Eugenio Perez Martin
2023-06-01 13:48 ` [PATCH v3 3/6] hw/net/virtio-net: make some VirtIONet const Hawkins Jiawei
2023-06-01 14:15 ` Eugenio Perez Martin
2023-06-01 13:48 ` [PATCH v3 4/6] virtio-net: expose virtio_net_supported_guest_offloads() Hawkins Jiawei
2023-06-01 14:37 ` Eugenio Perez Martin
2023-06-02 5:59 ` Hawkins Jiawei
2023-06-01 13:48 ` [PATCH v3 5/6] vdpa: Add vhost_vdpa_net_load_offloads() Hawkins Jiawei
2023-06-01 14:12 ` Eugenio Perez Martin
2023-06-02 7:30 ` Hawkins Jiawei [this message]
2023-06-01 13:48 ` [PATCH v3 6/6] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ Hawkins Jiawei
2023-06-01 14:18 ` Eugenio Perez Martin
2023-06-02 11:25 ` [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Lei Yang
2023-06-02 12:05 ` 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='CAKrof1OSb=0rQJeWgvhiND3jszwYu2X8cNe5o88q7eX61vNehg@mail.gmail.com' \
--to=yin31149@gmail.com \
--cc=18801353760@163.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).