qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eugenio Perez Martin <eperezma@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: qemu-devel@nongnu.org, Zhu Lingshan <lingshan.zhu@intel.com>,
	 Harpreet Singh Anand <hanand@xilinx.com>,
	Stefano Garzarella <sgarzare@redhat.com>,
	 Si-Wei Liu <si-wei.liu@oracle.com>,
	"Michael S. Tsirkin" <mst@redhat.com>, Cindy Lu <lulu@redhat.com>,
	 Laurent Vivier <lvivier@redhat.com>,
	Eli Cohen <eli@mellanox.com>,
	 Liuxiangdong <liuxiangdong5@huawei.com>,
	Parav Pandit <parav@mellanox.com>,
	 Gautam Dawar <gdawar@xilinx.com>
Subject: Re: [RFC PATCH v2 3/8] vhost_net: Emulate link state up if backend doesn't expose it
Date: Thu, 20 Oct 2022 08:35:23 +0200	[thread overview]
Message-ID: <CAJaqyWfOADNwUXCLcqr0MpJSdndXheni60vMH3PVc1C9qQt8Ug@mail.gmail.com> (raw)
In-Reply-To: <CACGkMEtTG1YnqtTWs_1feAfdL=m9tiJxGX118fDCTUd2onPnPg@mail.gmail.com>

On Thu, Oct 20, 2022 at 6:30 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Wed, Oct 19, 2022 at 8:52 PM Eugenio Pérez <eperezma@redhat.com> wrote:
> >
> > At this moment this code path is not reached, but vdpa devices can offer
> > VIRTIO_NET_F_STATUS unconditionally.
>
> So I guess what you mean is that, for the parent that doesn't support
> VIRTIO_NET_F_STATUS, emulate one for making sure the ANNOUCNE to work.
> This is safe since the spec said the driver will assume the link is
> always up if without this feature.
>

Right.

> > While the guest must assume that
> > link is always up by the standard, qemu will set the status bit to 1
> > always in this case.
> >
> > This makes little use by itself, but VIRTIO_NET_F_STATUS is needed for
> > the guest to read status bit VIRTIO_NET_F_GUEST_ANNOUNCE, used by feature
> > VIRTIO_NET_F_GUEST_ANNOUNCE. So qemu must emulate status feature in case
> > it needs to emulate the guest announce feature.
> >
> > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > ---
> >  hw/net/vhost_net.c | 27 ++++++++++++++++++++++++++-
> >  1 file changed, 26 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> > index d28f8b974b..5660606c1d 100644
> > --- a/hw/net/vhost_net.c
> > +++ b/hw/net/vhost_net.c
> > @@ -117,7 +117,32 @@ uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features)
> >  int vhost_net_get_config(struct vhost_net *net,  uint8_t *config,
> >                           uint32_t config_len)
> >  {
> > -    return vhost_dev_get_config(&net->dev, config, config_len, NULL);
> > +    VirtIODevice *vdev;
> > +    int r = vhost_dev_get_config(&net->dev, config, config_len, NULL);
> > +
> > +    if (unlikely(r != 0)) {
> > +        return r;
> > +    }
> > +
> > +    if (config_len < endof(struct virtio_net_config, status)) {
> > +        return 0;
> > +    }
> > +
> > +    /*
> > +     * TODO: Perform this only if vhost_vdpa.
> > +     */
>
> Cindy adds some mediation codes for vhost-vDPA in
> virtio_net_get_config(), so I believe it can be done there?
>

Sure, let me take a look.

Thanks!


> Thanks
>
> > +    vdev = net->dev.vdev;
> > +    if (!vdev) {
> > +        /* Device is starting */
> > +        return 0;
> > +    }
> > +
> > +    if ((net->dev.acked_features & BIT_ULL(VIRTIO_NET_F_STATUS)) &&
> > +        !(net->dev.features & BIT_ULL(VIRTIO_NET_F_STATUS))) {
> > +        ((struct virtio_net_config *)config)->status |= VIRTIO_NET_S_LINK_UP;
> > +    }
> > +
> > +    return 0;
> >  }
> >  int vhost_net_set_config(struct vhost_net *net, const uint8_t *data,
> >                           uint32_t offset, uint32_t size, uint32_t flags)
> > --
> > 2.31.1
> >
>



  reply	other threads:[~2022-10-20  6:59 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19 12:52 [RFC PATCH v2 0/8] Guest announce feature emulation using Shadow VirtQueue Eugenio Pérez
2022-10-19 12:52 ` [RFC PATCH v2 1/8] vdpa: Delete duplicated vdpa_feature_bits entry Eugenio Pérez
2022-10-20  4:12   ` Jason Wang
2022-10-19 12:52 ` [RFC PATCH v2 2/8] vdpa: Save emulated features list in vhost_vdpa Eugenio Pérez
2022-10-20  4:22   ` Jason Wang
2022-10-20  6:34     ` Eugenio Perez Martin
2022-10-21  2:57       ` Jason Wang
2022-10-21  8:56         ` Eugenio Perez Martin
2022-10-24  2:14           ` Jason Wang
2022-10-24  9:25             ` Eugenio Perez Martin
2022-10-25  2:45               ` Jason Wang
2022-10-25  6:54                 ` Eugenio Perez Martin
2022-10-19 12:52 ` [RFC PATCH v2 3/8] vhost_net: Emulate link state up if backend doesn't expose it Eugenio Pérez
2022-10-20  4:29   ` Jason Wang
2022-10-20  6:35     ` Eugenio Perez Martin [this message]
2022-10-19 12:52 ` [RFC PATCH v2 4/8] vdpa: Expose VIRTIO_NET_F_STATUS unconditionally Eugenio Pérez
2022-10-19 12:52 ` [RFC PATCH v2 5/8] vdpa: Remove shadow CVQ command check Eugenio Pérez
2022-10-20  4:31   ` Jason Wang
2022-10-19 12:52 ` [RFC PATCH v2 6/8] vdpa: handle VIRTIO_NET_CTRL_ANNOUNCE in vhost_vdpa_net_handle_ctrl_avail Eugenio Pérez
2022-10-20  4:35   ` Jason Wang
2022-10-20  7:00     ` Eugenio Perez Martin
2022-10-21  3:01       ` Jason Wang
2022-10-21  9:05         ` Eugenio Perez Martin
2022-10-24  2:15           ` Jason Wang
2022-10-19 12:52 ` [RFC PATCH v2 7/8] vhost_net: return VIRTIO_NET_S_ANNOUNCE is device model has it set Eugenio Pérez
2022-10-20  4:35   ` Jason Wang
2022-10-19 12:52 ` [RFC PATCH v2 8/8] vdpa: Offer VIRTIO_NET_F_GUEST_ANNOUNCE feature if SVQ is enabled Eugenio Pérez
2022-10-20  4:24 ` [RFC PATCH v2 0/8] Guest announce feature emulation using Shadow VirtQueue Jason Wang
2022-10-20  8:38   ` Eugenio Perez Martin

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=CAJaqyWfOADNwUXCLcqr0MpJSdndXheni60vMH3PVc1C9qQt8Ug@mail.gmail.com \
    --to=eperezma@redhat.com \
    --cc=eli@mellanox.com \
    --cc=gdawar@xilinx.com \
    --cc=hanand@xilinx.com \
    --cc=jasowang@redhat.com \
    --cc=lingshan.zhu@intel.com \
    --cc=liuxiangdong5@huawei.com \
    --cc=lulu@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=parav@mellanox.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=si-wei.liu@oracle.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).