All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
To: Jason Wang <jasowang@redhat.com>
Cc: mst <mst@redhat.com>, "Gonglei (Arei)" <arei.gonglei@huawei.com>,
	Heng Qi <hengqi@linux.alibaba.com>,
	Kangjie Xu <kangjie.xu@linux.alibaba.com>,
	"qemu-devel" <qemu-devel@nongnu.org>
Subject: Re: [PATCH v2 3/6] vhost-net: vhost-user: update vhost_net_virtqueue_reset()
Date: Thu, 15 Sep 2022 19:17:30 +0800	[thread overview]
Message-ID: <1663240650.2765737-1-xuanzhuo@linux.alibaba.com> (raw)
In-Reply-To: <CACGkMEvSt0etgoVyPVTk1axV+mx30CigR6bhbNYt8oYTTC2=Dw@mail.gmail.com>

On Thu, 15 Sep 2022 10:12:11 +0800, Jason Wang <jasowang@redhat.com> wrote:
> On Wed, Sep 14, 2022 at 2:21 PM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
> >
> > On Wed, 14 Sep 2022 11:13:29 +0800, Jason Wang <jasowang@redhat.com> wrote:
> > >
> > > 在 2022/9/12 11:10, Kangjie Xu 写道:
> > > > Update vhost_net_virtqueue_reset() for vhost-user scenario.
> > > >
> > > > In order to reuse some functions, we process the idx for
> > > > vhost-user scenario because vhost_get_vq_index behave
> > > > differently for vhost-user.
> > > >
> > > > Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
> > > > Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> > > > ---
> > > >   hw/net/vhost_net.c | 3 +++
> > > >   1 file changed, 3 insertions(+)
> > > >
> > > > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> > > > index ea896ea75b..25e5665489 100644
> > > > --- a/hw/net/vhost_net.c
> > > > +++ b/hw/net/vhost_net.c
> > > > @@ -545,6 +545,9 @@ void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetClientState *nc,
> > > >       assert(vhost_ops);
> > > >
> > > >       idx = vhost_ops->vhost_get_vq_index(&net->dev, vq_index);
> > > > +    if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
> > > > +        idx -= net->dev.vq_index;
> > > > +    }
> > >
> > >
> > > This looks tricky. Any reason we can't simply use vq_index for both
> > > vhost-user and vhost-net?
> >
> >
> > static int vhost_user_get_vq_index(struct vhost_dev *dev, int idx)
> > {
> >     assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs);
> >
> >     return idx;
> > }
> >
> >
> > static int vhost_kernel_get_vq_index(struct vhost_dev *dev, int idx)
> > {
> >     assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs);
> >
> >     return idx - dev->vq_index;
> > }
> >
> > The implementation of these two callbacks is different. The structure of the two
> > scenarios is different. We may need to do some optimizations in the future.
>
> Yes, but what I meant is, you do
>
> idx -= net->dev.vq_index;
>
> and then
>
> net->dev.vq_index + idx
>
> This is a hint that we should have a better organization of the code.

I see.

Will fix this.

Thanks.


>
> Thanks
>
> >
> > Thanks.
> >
> >
> > >
> > > Thanks
> > >
> > >
> > > >
> > > >       if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
> > > >           file.index = idx;
> > >
> >
>


  reply	other threads:[~2022-09-15 11:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12  3:10 [PATCH v2 0/6] Support VIRTIO_F_RING_RESET for vhost-user in virtio pci-modern Kangjie Xu
2022-09-12  3:10 ` [PATCH v2 1/6] net: virtio: rename vhost_set_vring_enable to vhost_set_dev_enable Kangjie Xu
2022-09-14  3:06   ` Jason Wang
2022-09-12  3:10 ` [PATCH v2 2/6] vhost-user: add op to enable or disable a single vring Kangjie Xu
2022-09-14  3:07   ` Jason Wang
2022-09-12  3:10 ` [PATCH v2 3/6] vhost-net: vhost-user: update vhost_net_virtqueue_reset() Kangjie Xu
2022-09-14  3:13   ` Jason Wang
2022-09-14  6:18     ` Xuan Zhuo
2022-09-15  2:12       ` Jason Wang
2022-09-15 11:17         ` Xuan Zhuo [this message]
2022-09-26  7:51         ` Xuan Zhuo
2022-09-12  3:10 ` [PATCH v2 4/6] vhost-net: vhost-user: update vhost_net_virtqueue_restart() Kangjie Xu
2022-09-12  3:10 ` [PATCH v2 5/6] virtio-net: vhost-user: update queue_reset and queue_enable Kangjie Xu
2022-09-14  3:14   ` Jason Wang
2022-09-12  3:10 ` [PATCH v2 6/6] vhost: vhost-user: enable vq reset feature Kangjie Xu
2022-09-14  3:15   ` 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=1663240650.2765737-1-xuanzhuo@linux.alibaba.com \
    --to=xuanzhuo@linux.alibaba.com \
    --cc=arei.gonglei@huawei.com \
    --cc=hengqi@linux.alibaba.com \
    --cc=jasowang@redhat.com \
    --cc=kangjie.xu@linux.alibaba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.