From: "Xia, Chenbo" <chenbo.xia@intel.com>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
"hengqi@linux.alibaba.com" <hengqi@linux.alibaba.com>,
"jasonwang@redhat.com" <jasonwang@redhat.com>,
"mst@redhat.com" <mst@redhat.com>,
Kangjie Xu <kangjie.xu@linux.alibaba.com>,
"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>
Subject: RE: RE: [PATCH v2 2/2] vhost: introduce VHOST_USER_RESET_VRING
Date: Mon, 26 Sep 2022 07:28:33 +0000 [thread overview]
Message-ID: <SN6PR11MB3504DEEBF55085A079F91F879C529@SN6PR11MB3504.namprd11.prod.outlook.com> (raw)
In-Reply-To: <1663897297.0251951-1-xuanzhuo@linux.alibaba.com>
> -----Original Message-----
> From: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> Sent: Friday, September 23, 2022 9:42 AM
> To: Xia, Chenbo <chenbo.xia@intel.com>
> Cc: dev@dpdk.org; hengqi@linux.alibaba.com; jasonwang@redhat.com;
> mst@redhat.com; Kangjie Xu <kangjie.xu@linux.alibaba.com>;
> maxime.coquelin@redhat.com
> Subject: Re: RE: [PATCH v2 2/2] vhost: introduce VHOST_USER_RESET_VRING
>
> On Thu, 22 Sep 2022 09:35:35 +0000, "Xia, Chenbo" <chenbo.xia@intel.com>
> wrote:
> > > -----Original Message-----
> > > From: Kangjie Xu <kangjie.xu@linux.alibaba.com>
> > > Sent: Monday, September 5, 2022 11:48 AM
> > > To: maxime.coquelin@redhat.com; Xia, Chenbo <chenbo.xia@intel.com>
> > > Cc: dev@dpdk.org; xuanzhuo@linux.alibaba.com; hengqi@linux.alibaba.com;
> > > jasonwang@redhat.com; mst@redhat.com
> > > Subject: [PATCH v2 2/2] vhost: introduce VHOST_USER_RESET_VRING
> > >
> > > To support the reset operation for an individual virtqueue, we
> > > introduce a new message VHOST_USER_RESET_VRING. When the feature
> > > VIRTIO_F_RING_RESET feature has been successfully negotiated, This
> > > message is submitted by the front-end to reset an individual
> > > virtqueue to initial states in the back-end. The reply is needed
> > > to ensure that the reset operation is complete.
> >
> > completed
> >
> > >
> > > Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
> > > Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> > > ---
> > > lib/vhost/vhost.c | 2 +-
> > > lib/vhost/vhost.h | 1 +
> > > lib/vhost/vhost_user.c | 27 ++++++++++++++++++++++++++-
> > > lib/vhost/vhost_user.h | 1 +
> > > 4 files changed, 29 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
> > > index 60cb05a0ff..215a1ca355 100644
> > > --- a/lib/vhost/vhost.c
> > > +++ b/lib/vhost/vhost.c
> > > @@ -610,7 +610,7 @@ init_vring_queue(struct virtio_net *dev, uint32_t
> > > vring_idx)
> > > vhost_user_iotlb_init(dev, vring_idx);
> > > }
> > >
> > > -static void
> > > +void
> > > reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
> > > {
> > > struct vhost_virtqueue *vq;
> > > diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
> > > index 76461a3406..eccb52842d 100644
> > > --- a/lib/vhost/vhost.h
> > > +++ b/lib/vhost/vhost.h
> > > @@ -791,6 +791,7 @@ get_device(int vid)
> > >
> > > int vhost_new_device(void);
> > > void cleanup_device(struct virtio_net *dev, int destroy);
> > > +void reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx);
> > > void reset_device(struct virtio_net *dev);
> > > void vhost_destroy_device(int);
> > > void vhost_destroy_device_notify(struct virtio_net *dev);
> > > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> > > index 4ad28bac45..5f7743d9d9 100644
> > > --- a/lib/vhost/vhost_user.c
> > > +++ b/lib/vhost/vhost_user.c
> > > @@ -2771,6 +2771,30 @@ vhost_user_set_status(struct virtio_net **pdev,
> > > return RTE_VHOST_MSG_RESULT_OK;
> > > }
> > >
> > > +static int
> > > +vhost_user_reset_vring(struct virtio_net **pdev,
> > > + struct vhu_msg_context *ctx __rte_unused,
> > > + int main_fd __rte_unused)
> > > +{
> > > + struct virtio_net *dev = *pdev;
> > > + int index = (int)ctx->msg.payload.state.index;
> >
> > Why not just use unsigned int?
> >
> > > +
> > > + VHOST_LOG_CONFIG(dev->ifname, INFO, "reset queue: queue idx: %d\n",
> > > index);
> > > +
> > > + if (!(dev->features & (1ULL << VIRTIO_F_RING_RESET))) {
> > > + return RTE_VHOST_MSG_RESULT_ERR;
> > > + }
> >
> > braces {} are not necessary for single statement blocks
> >
> > > +
> > > + dev->virtqueue[index]->enabled = false;
> > > + reset_vring_queue(dev, index);
> > > +
> > > + ctx->msg.payload.state.num = 0;
> > > + ctx->msg.size = sizeof(ctx->msg.payload.u64);
> > > + ctx->fd_num = 0;
> > > +
> > > + return RTE_VHOST_MSG_RESULT_REPLY;
> > > +}
> >
> > IIUC, before this handler, we need to lock the queue? Using
> vhost_user_lock_all_queue_pairs
> >
> > BTW, is this support merged in QEMU now? I remember for similar cases,
> > we wait for QEMU to merge first and then merge in DPDK.
> >
> > Maxime, do I remember this correctly?
>
>
> Yes, we are simultaneously pushing this feature to QEMU.
>
> We have a patch for v3, maybe you missed it.
>
> Thanks.
Oops, sorry. I did miss that. And please ping when the QEMU side
is merged.
Thanks,
Chenbo
>
>
> >
> > Thanks,
> > Chenbo
> >
> > > +
> > > #define VHOST_MESSAGE_HANDLERS \
> > > VHOST_MESSAGE_HANDLER(VHOST_USER_NONE, NULL, false) \
> > > VHOST_MESSAGE_HANDLER(VHOST_USER_GET_FEATURES,
> vhost_user_get_features,
> > > false) \
> > > @@ -2803,7 +2827,8 @@ VHOST_MESSAGE_HANDLER(VHOST_USER_POSTCOPY_END,
> > > vhost_user_postcopy_end, false) \
> > > VHOST_MESSAGE_HANDLER(VHOST_USER_GET_INFLIGHT_FD,
> > > vhost_user_get_inflight_fd, false) \
> > > VHOST_MESSAGE_HANDLER(VHOST_USER_SET_INFLIGHT_FD,
> > > vhost_user_set_inflight_fd, true) \
> > > VHOST_MESSAGE_HANDLER(VHOST_USER_SET_STATUS, vhost_user_set_status,
> false)
> > > \
> > > -VHOST_MESSAGE_HANDLER(VHOST_USER_GET_STATUS, vhost_user_get_status,
> false)
> > > +VHOST_MESSAGE_HANDLER(VHOST_USER_GET_STATUS, vhost_user_get_status,
> false)
> > > \
> > > +VHOST_MESSAGE_HANDLER(VHOST_USER_RESET_VRING, vhost_user_reset_vring,
> > > false)
> > >
> > > #define VHOST_MESSAGE_HANDLER(id, handler, accepts_fd) \
> > > [id] = { #id, handler, accepts_fd },
> > > diff --git a/lib/vhost/vhost_user.h b/lib/vhost/vhost_user.h
> > > index 8ecca68597..51cb2fc74a 100644
> > > --- a/lib/vhost/vhost_user.h
> > > +++ b/lib/vhost/vhost_user.h
> > > @@ -60,6 +60,7 @@ typedef enum VhostUserRequest {
> > > VHOST_USER_SET_INFLIGHT_FD = 32,
> > > VHOST_USER_SET_STATUS = 39,
> > > VHOST_USER_GET_STATUS = 40,
> > > + VHOST_USER_RESET_VRING = 41
> > > } VhostUserRequest;
> > >
> > > typedef enum VhostUserSlaveRequest {
> > > --
> > > 2.32.0
> >
prev parent reply other threads:[~2022-09-26 7:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-05 3:48 [PATCH v2 0/2] vhost: support VIRTIO_F_RING_RESET for vhost-user Kangjie Xu
2022-09-05 3:48 ` [PATCH v2 1/2] " Kangjie Xu
2022-09-05 3:48 ` [PATCH v2 2/2] vhost: introduce VHOST_USER_RESET_VRING Kangjie Xu
2022-09-22 9:35 ` Xia, Chenbo
2022-09-23 1:41 ` Xuan Zhuo
2022-09-26 7:28 ` Xia, Chenbo [this message]
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=SN6PR11MB3504DEEBF55085A079F91F879C529@SN6PR11MB3504.namprd11.prod.outlook.com \
--to=chenbo.xia@intel.com \
--cc=dev@dpdk.org \
--cc=hengqi@linux.alibaba.com \
--cc=jasonwang@redhat.com \
--cc=kangjie.xu@linux.alibaba.com \
--cc=maxime.coquelin@redhat.com \
--cc=mst@redhat.com \
--cc=xuanzhuo@linux.alibaba.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).