Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5075260rwr; Sun, 23 Apr 2023 20:48:28 -0700 (PDT) X-Google-Smtp-Source: AKy350ZxQrJizmL9E0mmQQYRJWZMxIF11EBwt9E7FyhT44xx2tVoaEL7O6aOqD/qwzLDvDX9oXvm X-Received: by 2002:a05:6a20:7487:b0:f5:6cb8:105 with SMTP id p7-20020a056a20748700b000f56cb80105mr1822030pzd.45.1682308108407; Sun, 23 Apr 2023 20:48:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682308108; cv=none; d=google.com; s=arc-20160816; b=vnE38Gwc0N+SFExb/4mqJMPIDtb4zyqYDThDpAeEGuyYLvLLj+RZDQ4iKhuoKLidbh 31YnymmrjffpUsspkj+/ybofSW+z5UFy+1Jj33r1Yexkjct0w9LwWlgz8eD/SoOUVhbx lt8vpHWgaMFot+gtuJVo/vh7mHzKpwg6x3NqxTM9cPCxJCcujCEGLKdIbJIJZ7PiK771 bC6hX/57FfXt8w+94FhNw71KnFOah3H5r3tfuhIWqD1qld4AtkkJg8UQzabeRXrxsPLC LQzrvy4zqK8flWbk4J5n3PzwmOAYq81ZmjFpk+rqt/vNNABrpbvdndSlXqj+6NQ6J7w1 2yIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=pNCBa7OjCC7JqsI3cEfxVx1YPRoGVy6yo4FMo1YynBA=; b=jHAIBKWzBmVhzI/XlaMAWTG/SvCtI4QcB2l6NadkCj19UjOJ82qthb/Uh/BbrgDzKz RYIyggLRPN/hUMqDGUSnz7fIOtcR1jYO3udPEW3QVABv9R1MrkYxaiYBJPd3hpbPiQ/T Z5fYP9o3sygndSx2TqdAVYPiM1AU9iAsadgb0yT3s7T4TxnFSDW1fB0g01FvCzSDAv3F hKpVatWizgvHJp8yBf3+eXlF7+4EN0gvK37+QQYfE3U3+AgONNBfNGPQIhagkxUWbd/1 gVn9GofYX4vTJBZc3yjb23shuspsoHp30VCHwPyhYvwP8kpHB5ENSa4gLpJxLf80+Xo/ 3nOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H3lDes96; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a621d0b000000b0063b7c4435c0si10135770pfd.54.2023.04.23.20.48.15; Sun, 23 Apr 2023 20:48:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H3lDes96; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230432AbjDXDoc (ORCPT + 99 others); Sun, 23 Apr 2023 23:44:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230348AbjDXDoV (ORCPT ); Sun, 23 Apr 2023 23:44:21 -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 ESMTPS id 07A964686 for ; Sun, 23 Apr 2023 20:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682307755; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pNCBa7OjCC7JqsI3cEfxVx1YPRoGVy6yo4FMo1YynBA=; b=H3lDes96y5insWd3PYTcukwIgF+Nz8VX3cYZuRZdTBLqSGi2YL3GKXCpBgbcqetqEjz3lk qsiV8XjD6Vx2RztKHToUMYpCriiMAz7wDkBd5vCPOwwGgUxQ5HOOhn1v8xkz7sLe04O/Mj Ha97uaLu4zDa0X6z60LF6VjVyF6Tl9I= Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-656-0Rr10zqKOBWmFIJkAVXm7w-1; Sun, 23 Apr 2023 23:42:34 -0400 X-MC-Unique: 0Rr10zqKOBWmFIJkAVXm7w-1 Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-38beee4e26cso2610998b6e.3 for ; Sun, 23 Apr 2023 20:42:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682307753; x=1684899753; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pNCBa7OjCC7JqsI3cEfxVx1YPRoGVy6yo4FMo1YynBA=; b=GbP/ROZd4zzTIiP3yATf8EpjWXCzVTxvuA6zHdcbEI92qOiuS9a87Dg3aTReOhJOSe 6HScz7qfVKisoNqxeEkrJ6+Q9BrO9co7xJQtDSH+aeoltVTg3XFs2uQC48S2nr4FRrv1 zJO/eR1T+LsfR8j6JiyVus331rRB+2wj5Ymd17/xTWxbzjOjCFZ8Uf7x5r6ylz4NcmMk pSpp+LEkXpaXiIkze/zVbkjS/o3outpL3tptrE2XT05oHGItCxVkN5wY+BeGocQHPFPl X1vuhw4D/NgyCl5pc3nCpX/CdYyPmkxxU88Rf5YuuucpWLtJZilgeU14B7Lmr/3Jj33m Fsmw== X-Gm-Message-State: AAQBX9evI5x7HTQiotUj59WjVa+xWKTmCatjq6fjsucb09FqEehSIske 2itEgmjvjUwE29zEQ44MQNS59iJWXhk2qWiiPS6PVDvGdpLAyYAX6JFxtqjQEmZuzWIp/ijJ8fE QPjINIReMBlFINkDBk7x8lNgtAv/uKi3yu/lnhSq9 X-Received: by 2002:a05:6808:196:b0:38e:67c5:50f9 with SMTP id w22-20020a056808019600b0038e67c550f9mr6166229oic.43.1682307753553; Sun, 23 Apr 2023 20:42:33 -0700 (PDT) X-Received: by 2002:a05:6808:196:b0:38e:67c5:50f9 with SMTP id w22-20020a056808019600b0038e67c550f9mr6166217oic.43.1682307753329; Sun, 23 Apr 2023 20:42:33 -0700 (PDT) MIME-Version: 1.0 References: <20230419134329.346825-1-maxime.coquelin@redhat.com> <88a24206-b576-efc6-1bce-7f5075024c63@redhat.com> In-Reply-To: From: Jason Wang Date: Mon, 24 Apr 2023 11:42:22 +0800 Message-ID: Subject: Re: [RFC 0/2] vduse: add support for networking devices To: Yongji Xie Cc: Maxime Coquelin , "Michael S. Tsirkin" , David Marchand , linux-kernel , virtualization , Netdev , xuanzhuo@linux.alibaba.com, Eugenio Perez Martin , Peter Xu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 23, 2023 at 4:22=E2=80=AFPM Yongji Xie wrote: > > On Sun, Apr 23, 2023 at 2:31=E2=80=AFPM Jason Wang = wrote: > > > > On Fri, Apr 21, 2023 at 10:28=E2=80=AFPM Maxime Coquelin > > wrote: > > > > > > > > > > > > On 4/21/23 07:51, Jason Wang wrote: > > > > On Thu, Apr 20, 2023 at 10:16=E2=80=AFPM Maxime Coquelin > > > > wrote: > > > >> > > > >> > > > >> > > > >> On 4/20/23 06:34, Jason Wang wrote: > > > >>> On Wed, Apr 19, 2023 at 9:43=E2=80=AFPM Maxime Coquelin > > > >>> wrote: > > > >>>> > > > >>>> This small series enables virtio-net device type in VDUSE. > > > >>>> With it, basic operation have been tested, both with > > > >>>> virtio-vdpa and vhost-vdpa using DPDK Vhost library series > > > >>>> adding VDUSE support [0] using split rings layout. > > > >>>> > > > >>>> Control queue support (and so multiqueue) has also been > > > >>>> tested, but require a Kernel series from Jason Wang > > > >>>> relaxing control queue polling [1] to function reliably. > > > >>>> > > > >>>> Other than that, we have identified a few gaps: > > > >>>> > > > >>>> 1. Reconnection: > > > >>>> a. VDUSE_VQ_GET_INFO ioctl() returns always 0 for avail > > > >>>> index, even after the virtqueue has already been > > > >>>> processed. Is that expected? I have tried instead to > > > >>>> get the driver's avail index directly from the avail > > > >>>> ring, but it does not seem reliable as I sometimes get > > > >>>> "id %u is not a head!\n" warnings. Also such solution > > > >>>> would not be possible with packed ring, as we need to > > > >>>> know the wrap counters values. > > > >>> > > > >>> Looking at the codes, it only returns the value that is set via > > > >>> set_vq_state(). I think it is expected to be called before the > > > >>> datapath runs. > > > >>> > > > >>> So when bound to virtio-vdpa, it is expected to return 0. But we = need > > > >>> to fix the packed virtqueue case, I wonder if we need to call > > > >>> set_vq_state() explicitly in virtio-vdpa before starting the devi= ce. > > > >>> > > > >>> When bound to vhost-vdpa, Qemu will call VHOST_SET_VRING_BASE whi= ch > > > >>> will end up a call to set_vq_state(). Unfortunately, it doesn't > > > >>> support packed ring which needs some extension. > > > >>> > > > >>>> > > > >>>> b. Missing IOCTLs: it would be handy to have new IOCTLs to > > > >>>> query Virtio device status, > > > >>> > > > >>> What's the use case of this ioctl? It looks to me userspace is > > > >>> notified on each status change now: > > > >>> > > > >>> static int vduse_dev_set_status(struct vduse_dev *dev, u8 status) > > > >>> { > > > >>> struct vduse_dev_msg msg =3D { 0 }; > > > >>> > > > >>> msg.req.type =3D VDUSE_SET_STATUS; > > > >>> msg.req.s.status =3D status; > > > >>> > > > >>> return vduse_dev_msg_sync(dev, &msg); > > > >>> } > > > >> > > > >> The idea was to be able to query the status at reconnect time, and > > > >> neither having to assume its value nor having to store its value i= n a > > > >> file (the status could change while the VDUSE application is stopp= ed, > > > >> but maybe it would receive the notification at reconnect). > > > > > > > > I see. > > > > > > > >> > > > >> I will prototype using a tmpfs file to save needed information, an= d see > > > >> if it works. > > > > > > > > It might work but then the API is not self contained. Maybe it's > > > > better to have a dedicated ioctl. > > > > > > > >> > > > >>>> and retrieve the config > > > >>>> space set at VDUSE_CREATE_DEV time. > > > >>> > > > >>> In order to be safe, VDUSE avoids writable config space. Otherwis= e > > > >>> drivers could block on config writing forever. That's why we don'= t do > > > >>> it now. > > > >> > > > >> The idea was not to make the config space writable, but just to be= able > > > >> to fetch what was filled at VDUSE_CREATE_DEV time. > > > >> > > > >> With the tmpfs file, we can avoid doing that and just save the con= fig > > > >> space there. > > > > > > > > Same as the case for status. > > > > > > I have cooked a DPDK patch to support reconnect with a tmpfs file as > > > suggested by Yongji: > > > > > > https://gitlab.com/mcoquelin/dpdk-next-virtio/-/commit/53913f2b1155b0= 2c44d5d3d298aafd357e7a8c48 > > > > This seems tricky, for example for status: > > > > dev->log->status =3D dev->status; > > > > What if we crash here? > > > > The message will be re-sent by the kernel if it's not replied. But I > think it would be better if we can restore it via some ioctl. Yes, the point is, without a get ioctl, it's very hard to audit the code. Thanks > > Thanks, > Yongji >