Message ID | 20230912030008.3599514-4-lulu@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp875083vqx; Tue, 12 Sep 2023 22:57:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqb0YUt8AKv6OkebzEjFCdo165Glshn/b1x1BYEL6V/e7v8wWAO6MNVwnIAa8BetSjxlSc X-Received: by 2002:a05:6a21:78a6:b0:14d:8624:b14f with SMTP id bf38-20020a056a2178a600b0014d8624b14fmr1536623pzc.56.1694584678381; Tue, 12 Sep 2023 22:57:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694584678; cv=none; d=google.com; s=arc-20160816; b=lgKj9poGazaavoEVu/101LC4uJiyIqC3cN2PPAcnKmZsSFlvqC3uFlgtYIG5Q0lxwa xpg/CdbndF/X3J0fIBv3MOnLMQQyK7jAtlItcuX3Ede7NudomgurROarnGK/YQWyaS0/ 5b+7EkqTzwyq7WMbKwt9IoMzF9AoVbn/BXuRpBb/SXjIboTs3V0v8may1VIByiB41PnN S8b7kZt7sbUuePTcQVuw5/mRcUtpEuXuf1iT8aAFgG1YEQ4pm8gaCpI7sDd3XbGDiptf +rRP9cyqIqYbjfvPZU+LUtfzfBg303zXkBNjn73WKiTzQsNh1hJN7lS5497eiNlSa2Xj d7rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GC7kin1JeAsa+JwSskswsZ+EfkakP69SisNc/3XqZfo=; fh=E8uCy2UoKRrKjgDakfUdRLlW20LdfkTjtJs3toefLrk=; b=ipU3nBETK37hVGqhiqK5uxS5d4wJvHjcwLIeAIsGMj+mf/rMqVf4jEer2nQVOjUFyT Kplt2djsMNgYAIvoHbQIGyzdVDIhpxpxOKOnGKFhUHWGCqZyD0SM1JkYPLrCBVCkcld7 oWA6/j91bGaDM6thp3r3WMHD6jugZ5iIsnRg6llbyz5/EgDVMW3FrsqvGONITYplnxbI fhRS4Mw/2g1I5mZ/Y5w1/wpQSgPr0LQuXuxhI7yqo1rideP+mj2UPss3ajDe5wXYSjNN 6kbNVgw0YqALguuJKK5nfzKxWM7PBlCkTMbwMxexlPTXyN5DLV/N6li6iPNg0bz6cbw/ D0SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LZO+cJYr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ip8-20020a17090b314800b0026d55291b15si898592pjb.0.2023.09.12.22.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 22:57:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LZO+cJYr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id E4360823CC7F; Mon, 11 Sep 2023 21:33:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233105AbjILDYz (ORCPT <rfc822;ruipengqi7@gmail.com> + 40 others); Mon, 11 Sep 2023 23:24:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236363AbjILDYd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 11 Sep 2023 23:24:33 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A30A2296D6 for <linux-kernel@vger.kernel.org>; Mon, 11 Sep 2023 20:00:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694487636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GC7kin1JeAsa+JwSskswsZ+EfkakP69SisNc/3XqZfo=; b=LZO+cJYrHpuC/7dW4i2kwvJynoFNsAT1z4PrJRWS3Pqixw9OlbesQhUVdDobrzNNof8NJb gwTpcWAbfgJpjEBTA++Ac7/2olrgg8tU8mlXpwpUgPhuCxRjjB1q9+Ad2Jhw5OhYflp7Al U2Z7ALlFHwq2UMXJTJtCwm1R7yxnFHQ= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-696-iLfAFYcYN1yjSWG1J-LD9A-1; Mon, 11 Sep 2023 23:00:33 -0400 X-MC-Unique: iLfAFYcYN1yjSWG1J-LD9A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4A7A93801BC2; Tue, 12 Sep 2023 03:00:33 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EC5440C6EA8; Tue, 12 Sep 2023 03:00:29 +0000 (UTC) From: Cindy Lu <lulu@redhat.com> To: lulu@redhat.com, jasowang@redhat.com, mst@redhat.com, maxime.coquelin@redhat.com, xieyongji@bytedance.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org Cc: stable@vger.kernel.org Subject: [RFC v2 3/4] vduse: update the vq_info in ioctl Date: Tue, 12 Sep 2023 11:00:07 +0800 Message-Id: <20230912030008.3599514-4-lulu@redhat.com> In-Reply-To: <20230912030008.3599514-1-lulu@redhat.com> References: <20230912030008.3599514-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 11 Sep 2023 21:33:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776887133373786195 X-GMAIL-MSGID: 1776900823345074739 |
Series | Support reconnection in vduse | |
Commit Message
Cindy Lu
Sept. 12, 2023, 3 a.m. UTC
In VDUSE_VQ_GET_INFO, the driver will sync the last_avail_idx
with reconnect info, After mapping the reconnect pages to userspace
The userspace App will update the reconnect_time in
struct vhost_reconnect_vring, If this is not 0 then it means this
vq is reconnected and will update the last_avail_idx
Signed-off-by: Cindy Lu <lulu@redhat.com>
---
drivers/vdpa/vdpa_user/vduse_dev.c | 13 +++++++++++++
include/uapi/linux/vduse.h | 6 ++++++
2 files changed, 19 insertions(+)
Comments
On Tue, Sep 12, 2023 at 3:39 PM Jason Wang <jasowang@redhat.com> wrote: > > On Tue, Sep 12, 2023 at 11:00 AM Cindy Lu <lulu@redhat.com> wrote: > > > > In VDUSE_VQ_GET_INFO, the driver will sync the last_avail_idx > > with reconnect info, After mapping the reconnect pages to userspace > > The userspace App will update the reconnect_time in > > struct vhost_reconnect_vring, If this is not 0 then it means this > > vq is reconnected and will update the last_avail_idx > > > > Signed-off-by: Cindy Lu <lulu@redhat.com> > > --- > > drivers/vdpa/vdpa_user/vduse_dev.c | 13 +++++++++++++ > > include/uapi/linux/vduse.h | 6 ++++++ > > 2 files changed, 19 insertions(+) > > > > diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c > > index 2c69f4004a6e..680b23dbdde2 100644 > > --- a/drivers/vdpa/vdpa_user/vduse_dev.c > > +++ b/drivers/vdpa/vdpa_user/vduse_dev.c > > @@ -1221,6 +1221,8 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, > > struct vduse_vq_info vq_info; > > struct vduse_virtqueue *vq; > > u32 index; > > + struct vdpa_reconnect_info *area; > > + struct vhost_reconnect_vring *vq_reconnect; > > > > ret = -EFAULT; > > if (copy_from_user(&vq_info, argp, sizeof(vq_info))) > > @@ -1252,6 +1254,17 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, > > > > vq_info.ready = vq->ready; > > > > + area = &vq->reconnect_info; > > + > > + vq_reconnect = (struct vhost_reconnect_vring *)area->vaddr; > > + /*check if the vq is reconnect, if yes then update the last_avail_idx*/ > > + if ((vq_reconnect->last_avail_idx != > > + vq_info.split.avail_index) && > > + (vq_reconnect->reconnect_time != 0)) { > > + vq_info.split.avail_index = > > + vq_reconnect->last_avail_idx; > > + } > > + > > ret = -EFAULT; > > if (copy_to_user(argp, &vq_info, sizeof(vq_info))) > > break; > > diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h > > index 11bd48c72c6c..d585425803fd 100644 > > --- a/include/uapi/linux/vduse.h > > +++ b/include/uapi/linux/vduse.h > > @@ -350,4 +350,10 @@ struct vduse_dev_response { > > }; > > }; > > > > +struct vhost_reconnect_vring { > > + __u16 reconnect_time; > > + __u16 last_avail_idx; > > + _Bool avail_wrap_counter; > > Please add a comment for each field. > Sure will do > And I never saw _Bool is used in uapi before, maybe it's better to > pack it with last_avail_idx into a __u32. > Thanks will fix this > Btw, do we need to track inflight descriptors as well? > I will check this Thanks cindy > Thanks > > > +}; > > + > > #endif /* _UAPI_VDUSE_H_ */ > > -- > > 2.34.3 > > >
On 9/25/23 06:15, Cindy Lu wrote: > On Tue, Sep 12, 2023 at 3:39 PM Jason Wang <jasowang@redhat.com> wrote: >> >> On Tue, Sep 12, 2023 at 11:00 AM Cindy Lu <lulu@redhat.com> wrote: >>> >>> In VDUSE_VQ_GET_INFO, the driver will sync the last_avail_idx >>> with reconnect info, After mapping the reconnect pages to userspace >>> The userspace App will update the reconnect_time in >>> struct vhost_reconnect_vring, If this is not 0 then it means this >>> vq is reconnected and will update the last_avail_idx >>> >>> Signed-off-by: Cindy Lu <lulu@redhat.com> >>> --- >>> drivers/vdpa/vdpa_user/vduse_dev.c | 13 +++++++++++++ >>> include/uapi/linux/vduse.h | 6 ++++++ >>> 2 files changed, 19 insertions(+) >>> >>> diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c >>> index 2c69f4004a6e..680b23dbdde2 100644 >>> --- a/drivers/vdpa/vdpa_user/vduse_dev.c >>> +++ b/drivers/vdpa/vdpa_user/vduse_dev.c >>> @@ -1221,6 +1221,8 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, >>> struct vduse_vq_info vq_info; >>> struct vduse_virtqueue *vq; >>> u32 index; >>> + struct vdpa_reconnect_info *area; >>> + struct vhost_reconnect_vring *vq_reconnect; >>> >>> ret = -EFAULT; >>> if (copy_from_user(&vq_info, argp, sizeof(vq_info))) >>> @@ -1252,6 +1254,17 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, >>> >>> vq_info.ready = vq->ready; >>> >>> + area = &vq->reconnect_info; >>> + >>> + vq_reconnect = (struct vhost_reconnect_vring *)area->vaddr; >>> + /*check if the vq is reconnect, if yes then update the last_avail_idx*/ >>> + if ((vq_reconnect->last_avail_idx != >>> + vq_info.split.avail_index) && >>> + (vq_reconnect->reconnect_time != 0)) { >>> + vq_info.split.avail_index = >>> + vq_reconnect->last_avail_idx; >>> + } >>> + >>> ret = -EFAULT; >>> if (copy_to_user(argp, &vq_info, sizeof(vq_info))) >>> break; >>> diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h >>> index 11bd48c72c6c..d585425803fd 100644 >>> --- a/include/uapi/linux/vduse.h >>> +++ b/include/uapi/linux/vduse.h >>> @@ -350,4 +350,10 @@ struct vduse_dev_response { >>> }; >>> }; >>> >>> +struct vhost_reconnect_vring { >>> + __u16 reconnect_time; >>> + __u16 last_avail_idx; >>> + _Bool avail_wrap_counter; >> >> Please add a comment for each field. >> > Sure will do > >> And I never saw _Bool is used in uapi before, maybe it's better to >> pack it with last_avail_idx into a __u32. >> > Thanks will fix this >> Btw, do we need to track inflight descriptors as well? >> > I will check this For existing networking implemenation, this is not necessary. But it should be for block devices. Maxime > Thanks > > cindy >> Thanks >> >>> +}; >>> + >>> #endif /* _UAPI_VDUSE_H_ */ >>> -- >>> 2.34.3 >>> >> >
On 9/12/23 09:39, Jason Wang wrote: > On Tue, Sep 12, 2023 at 11:00 AM Cindy Lu <lulu@redhat.com> wrote: >> >> In VDUSE_VQ_GET_INFO, the driver will sync the last_avail_idx >> with reconnect info, After mapping the reconnect pages to userspace >> The userspace App will update the reconnect_time in >> struct vhost_reconnect_vring, If this is not 0 then it means this >> vq is reconnected and will update the last_avail_idx >> >> Signed-off-by: Cindy Lu <lulu@redhat.com> >> --- >> drivers/vdpa/vdpa_user/vduse_dev.c | 13 +++++++++++++ >> include/uapi/linux/vduse.h | 6 ++++++ >> 2 files changed, 19 insertions(+) >> >> diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c >> index 2c69f4004a6e..680b23dbdde2 100644 >> --- a/drivers/vdpa/vdpa_user/vduse_dev.c >> +++ b/drivers/vdpa/vdpa_user/vduse_dev.c >> @@ -1221,6 +1221,8 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, >> struct vduse_vq_info vq_info; >> struct vduse_virtqueue *vq; >> u32 index; >> + struct vdpa_reconnect_info *area; >> + struct vhost_reconnect_vring *vq_reconnect; >> >> ret = -EFAULT; >> if (copy_from_user(&vq_info, argp, sizeof(vq_info))) >> @@ -1252,6 +1254,17 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, >> >> vq_info.ready = vq->ready; >> >> + area = &vq->reconnect_info; >> + >> + vq_reconnect = (struct vhost_reconnect_vring *)area->vaddr; >> + /*check if the vq is reconnect, if yes then update the last_avail_idx*/ >> + if ((vq_reconnect->last_avail_idx != >> + vq_info.split.avail_index) && >> + (vq_reconnect->reconnect_time != 0)) { >> + vq_info.split.avail_index = >> + vq_reconnect->last_avail_idx; >> + } >> + >> ret = -EFAULT; >> if (copy_to_user(argp, &vq_info, sizeof(vq_info))) >> break; >> diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h >> index 11bd48c72c6c..d585425803fd 100644 >> --- a/include/uapi/linux/vduse.h >> +++ b/include/uapi/linux/vduse.h >> @@ -350,4 +350,10 @@ struct vduse_dev_response { >> }; >> }; >> >> +struct vhost_reconnect_vring { >> + __u16 reconnect_time; >> + __u16 last_avail_idx; >> + _Bool avail_wrap_counter; > > Please add a comment for each field. > > And I never saw _Bool is used in uapi before, maybe it's better to > pack it with last_avail_idx into a __u32. Better as two distincts __u16 IMHO. Thanks, Maxime > > Btw, do we need to track inflight descriptors as well? > > Thanks > >> +}; >> + >> #endif /* _UAPI_VDUSE_H_ */ >> -- >> 2.34.3 >> >
On Fri, Sep 29, 2023 at 5:12 PM Maxime Coquelin <maxime.coquelin@redhat.com> wrote: > > > > On 9/12/23 09:39, Jason Wang wrote: > > On Tue, Sep 12, 2023 at 11:00 AM Cindy Lu <lulu@redhat.com> wrote: > >> > >> In VDUSE_VQ_GET_INFO, the driver will sync the last_avail_idx > >> with reconnect info, After mapping the reconnect pages to userspace > >> The userspace App will update the reconnect_time in > >> struct vhost_reconnect_vring, If this is not 0 then it means this > >> vq is reconnected and will update the last_avail_idx > >> > >> Signed-off-by: Cindy Lu <lulu@redhat.com> > >> --- > >> drivers/vdpa/vdpa_user/vduse_dev.c | 13 +++++++++++++ > >> include/uapi/linux/vduse.h | 6 ++++++ > >> 2 files changed, 19 insertions(+) > >> > >> diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c > >> index 2c69f4004a6e..680b23dbdde2 100644 > >> --- a/drivers/vdpa/vdpa_user/vduse_dev.c > >> +++ b/drivers/vdpa/vdpa_user/vduse_dev.c > >> @@ -1221,6 +1221,8 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, > >> struct vduse_vq_info vq_info; > >> struct vduse_virtqueue *vq; > >> u32 index; > >> + struct vdpa_reconnect_info *area; > >> + struct vhost_reconnect_vring *vq_reconnect; > >> > >> ret = -EFAULT; > >> if (copy_from_user(&vq_info, argp, sizeof(vq_info))) > >> @@ -1252,6 +1254,17 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, > >> > >> vq_info.ready = vq->ready; > >> > >> + area = &vq->reconnect_info; > >> + > >> + vq_reconnect = (struct vhost_reconnect_vring *)area->vaddr; > >> + /*check if the vq is reconnect, if yes then update the last_avail_idx*/ > >> + if ((vq_reconnect->last_avail_idx != > >> + vq_info.split.avail_index) && > >> + (vq_reconnect->reconnect_time != 0)) { > >> + vq_info.split.avail_index = > >> + vq_reconnect->last_avail_idx; > >> + } > >> + > >> ret = -EFAULT; > >> if (copy_to_user(argp, &vq_info, sizeof(vq_info))) > >> break; > >> diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h > >> index 11bd48c72c6c..d585425803fd 100644 > >> --- a/include/uapi/linux/vduse.h > >> +++ b/include/uapi/linux/vduse.h > >> @@ -350,4 +350,10 @@ struct vduse_dev_response { > >> }; > >> }; > >> > >> +struct vhost_reconnect_vring { > >> + __u16 reconnect_time; > >> + __u16 last_avail_idx; > >> + _Bool avail_wrap_counter; > > > > Please add a comment for each field. > > > > And I never saw _Bool is used in uapi before, maybe it's better to > > pack it with last_avail_idx into a __u32. > > Better as two distincts __u16 IMHO. Fine with me. Thanks > > Thanks, > Maxime > > > > > Btw, do we need to track inflight descriptors as well? > > > > Thanks > > > >> +}; > >> + > >> #endif /* _UAPI_VDUSE_H_ */ > >> -- > >> 2.34.3 > >> > > >
On Sun, Oct 8, 2023 at 1:17 PM Jason Wang <jasowang@redhat.com> wrote: > > On Fri, Sep 29, 2023 at 5:12 PM Maxime Coquelin > <maxime.coquelin@redhat.com> wrote: > > > > > > > > On 9/12/23 09:39, Jason Wang wrote: > > > On Tue, Sep 12, 2023 at 11:00 AM Cindy Lu <lulu@redhat.com> wrote: > > >> > > >> In VDUSE_VQ_GET_INFO, the driver will sync the last_avail_idx > > >> with reconnect info, After mapping the reconnect pages to userspace > > >> The userspace App will update the reconnect_time in > > >> struct vhost_reconnect_vring, If this is not 0 then it means this > > >> vq is reconnected and will update the last_avail_idx > > >> > > >> Signed-off-by: Cindy Lu <lulu@redhat.com> > > >> --- > > >> drivers/vdpa/vdpa_user/vduse_dev.c | 13 +++++++++++++ > > >> include/uapi/linux/vduse.h | 6 ++++++ > > >> 2 files changed, 19 insertions(+) > > >> > > >> diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c > > >> index 2c69f4004a6e..680b23dbdde2 100644 > > >> --- a/drivers/vdpa/vdpa_user/vduse_dev.c > > >> +++ b/drivers/vdpa/vdpa_user/vduse_dev.c > > >> @@ -1221,6 +1221,8 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, > > >> struct vduse_vq_info vq_info; > > >> struct vduse_virtqueue *vq; > > >> u32 index; > > >> + struct vdpa_reconnect_info *area; > > >> + struct vhost_reconnect_vring *vq_reconnect; > > >> > > >> ret = -EFAULT; > > >> if (copy_from_user(&vq_info, argp, sizeof(vq_info))) > > >> @@ -1252,6 +1254,17 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, > > >> > > >> vq_info.ready = vq->ready; > > >> > > >> + area = &vq->reconnect_info; > > >> + > > >> + vq_reconnect = (struct vhost_reconnect_vring *)area->vaddr; > > >> + /*check if the vq is reconnect, if yes then update the last_avail_idx*/ > > >> + if ((vq_reconnect->last_avail_idx != > > >> + vq_info.split.avail_index) && > > >> + (vq_reconnect->reconnect_time != 0)) { > > >> + vq_info.split.avail_index = > > >> + vq_reconnect->last_avail_idx; > > >> + } > > >> + > > >> ret = -EFAULT; > > >> if (copy_to_user(argp, &vq_info, sizeof(vq_info))) > > >> break; > > >> diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h > > >> index 11bd48c72c6c..d585425803fd 100644 > > >> --- a/include/uapi/linux/vduse.h > > >> +++ b/include/uapi/linux/vduse.h > > >> @@ -350,4 +350,10 @@ struct vduse_dev_response { > > >> }; > > >> }; > > >> > > >> +struct vhost_reconnect_vring { > > >> + __u16 reconnect_time; > > >> + __u16 last_avail_idx; > > >> + _Bool avail_wrap_counter; > > > > > > Please add a comment for each field. > > > > > > And I never saw _Bool is used in uapi before, maybe it's better to > > > pack it with last_avail_idx into a __u32. > > > > Better as two distincts __u16 IMHO. > > Fine with me. > > Thanks > sure will fix this Thanks Cindy > > > > Thanks, > > Maxime > > > > > > > > Btw, do we need to track inflight descriptors as well? > > > > > > Thanks > > > > > >> +}; > > >> + > > >> #endif /* _UAPI_VDUSE_H_ */ > > >> -- > > >> 2.34.3 > > >> > > > > > >
diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 2c69f4004a6e..680b23dbdde2 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1221,6 +1221,8 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, struct vduse_vq_info vq_info; struct vduse_virtqueue *vq; u32 index; + struct vdpa_reconnect_info *area; + struct vhost_reconnect_vring *vq_reconnect; ret = -EFAULT; if (copy_from_user(&vq_info, argp, sizeof(vq_info))) @@ -1252,6 +1254,17 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, vq_info.ready = vq->ready; + area = &vq->reconnect_info; + + vq_reconnect = (struct vhost_reconnect_vring *)area->vaddr; + /*check if the vq is reconnect, if yes then update the last_avail_idx*/ + if ((vq_reconnect->last_avail_idx != + vq_info.split.avail_index) && + (vq_reconnect->reconnect_time != 0)) { + vq_info.split.avail_index = + vq_reconnect->last_avail_idx; + } + ret = -EFAULT; if (copy_to_user(argp, &vq_info, sizeof(vq_info))) break; diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h index 11bd48c72c6c..d585425803fd 100644 --- a/include/uapi/linux/vduse.h +++ b/include/uapi/linux/vduse.h @@ -350,4 +350,10 @@ struct vduse_dev_response { }; }; +struct vhost_reconnect_vring { + __u16 reconnect_time; + __u16 last_avail_idx; + _Bool avail_wrap_counter; +}; + #endif /* _UAPI_VDUSE_H_ */