Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4252217rwr; Sun, 23 Apr 2023 01:27:30 -0700 (PDT) X-Google-Smtp-Source: AKy350YPTETiilnhbQIl7OHdY+2wBgRTxEhxDETpoZFw+HDvPXudLOeix3WBJe8Z+yYOZNChdEEA X-Received: by 2002:a05:6a20:728a:b0:f1:c0a1:8035 with SMTP id o10-20020a056a20728a00b000f1c0a18035mr14483800pzk.0.1682238449751; Sun, 23 Apr 2023 01:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682238449; cv=none; d=google.com; s=arc-20160816; b=xwbvO1m7IemTnD+n9geITJvw7pyzUEn6frudYT62tJ9O8TyNifcmcPZBbZ3xK9drPI IYHA4CHRDDZgeuLSMZYh5+BSEPbqxcDM8HlH58a9wyj1ywuVHeB9zccv2mrweF7Q49zT Va1f0RiuuCc3uuPkgfHgGBE9GBOmkeERw61yW7FSVM+NSrGLrklcgP6Vbk1Qf7aCaPJL yI+GN2SFP1IpSUgVZX9m2OLLQuvitE3NJe8c8abFUecysKC8cOoFrecpPjUl7PB5Q/az 0RVYZnv5gfJ4JR6alUPtiuuXev2L9wwDiVpG4Lc30KXLPF2AfYH1KYpkWjVC/dFb1WtT zGyA== 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=AsVqFxCnqnJj6X0Ne966CP4b3PoHHtGOf7X6eWIUjQM=; b=bx7dX6Utw000zvmm4rpJJL27kvhZMyd0XuVMA2dsITm7nsMC03GnkV15Gf4Fi2p99e ChuhZDRqqez4SS8fcqeqa/8fg1UvVV0WYh7Ir73Igrv90k/5J68w2O3h+loi5/dGEenV F8TXIS1fj+XpDZ2sS7bNaBhtKHKI49G+tzSqRfvI7rYZ9amn3lrJYokbTV/sRtWVPHwp 1sCwVTcTEwZ+SwmJwZv6ViqpLzxukIC+NozSHv0okmkXeG31G9RVrJCBDdWAWN/UvEaD rZnbohZYS3tTvnLhJVrVxd6PMQYV3hkOgZYgP+zf3W5cc2mYEvwdHXjRPMw0xZz6Q8Cq +DXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="Tb/B346e"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l63-20020a638842000000b00513f15fed4fsi8643061pgd.590.2023.04.23.01.27.18; Sun, 23 Apr 2023 01:27:29 -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=@bytedance.com header.s=google header.b="Tb/B346e"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229617AbjDWIWp (ORCPT + 99 others); Sun, 23 Apr 2023 04:22:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbjDWIWn (ORCPT ); Sun, 23 Apr 2023 04:22:43 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCF7410D2 for ; Sun, 23 Apr 2023 01:22:15 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-52091c58109so3291734a12.2 for ; Sun, 23 Apr 2023 01:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1682238135; x=1684830135; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=AsVqFxCnqnJj6X0Ne966CP4b3PoHHtGOf7X6eWIUjQM=; b=Tb/B346e9/yJe3ib/AD+cCfT8dBiYza4ku/jwFqGwo74dVP1bpMIoBGZynuvEOKG4S pQcCoPGJTostQastCdpOR3UmE251+CdP0QlPb885nFLmdHjZ+OpA20MIvTI8Yo9LZTlh DgZU2E4PAlupns0wf7CTY9QGnwA5G3ehQ2Is4AVq9aiK7BrvTVaARL7m6oqGrS0Cs//k OS070RKMfh6MqXo1w7Xo3Jo+b21Q71z97y3ijLzmdX7mH1PWWzufUnMcBpe6apy+Mrgy iBRpzgQ+JdZO95o4IA9hHsuH5QgyJ0qWiTxyp412sXis3Npzvp+n2epKUwutOQkLC5XH wUNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682238135; x=1684830135; 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=AsVqFxCnqnJj6X0Ne966CP4b3PoHHtGOf7X6eWIUjQM=; b=e3ZAO5q7VzmhfBeoI+ur6srJRk+Szr5rF5vrwx1xQxh3loIRtpd43TvyDIpmVZGMKZ oHPFoYhHCkDoOU/Z3wgGaLkfciyY14wsXamYewlbUPnNAj4jTYPAz2bsi+zdJ0uee5bZ XNyuZ8iTZ+lMazHrAWPDJNX+C5XBKZYlBrGzd/lwlI/hIClTZJfzsz6FJgH1v6YqX7s3 OtdOh/QHbLvgO8I1XY7mNolf62XYvPp2a/HyL0VYro0gbKZRZjOpZSzeVci2Woz6AMYU immyKuf5yYe8iJkoDDiu5qyaXq+xiXjW4EJVHmfm8yM3wkBm2ygUf7iehhdRU4Hl3alr CMPQ== X-Gm-Message-State: AAQBX9dqBdQKcRkG3X18vps1r+XFg3Wg84kyArLL4E468zK7I+8S+2pw VlFggjSw4iPlXNdj5Z7P/zuCwODUXvfiQnMGBR7D X-Received: by 2002:a17:902:fa0b:b0:1a6:d8a3:3346 with SMTP id la11-20020a170902fa0b00b001a6d8a33346mr9686473plb.31.1682238135103; Sun, 23 Apr 2023 01:22:15 -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: Yongji Xie Date: Sun, 23 Apr 2023 16:22:00 +0800 Message-ID: Subject: Re: [RFC 0/2] vduse: add support for networking devices To: Jason Wang 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,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 2:31=E2=80=AFPM Jason Wang wr= ote: > > 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 ne= ed > > >>> to fix the packed virtqueue case, I wonder if we need to call > > >>> set_vq_state() explicitly in virtio-vdpa before starting the device= . > > >>> > > >>> When bound to vhost-vdpa, Qemu will call VHOST_SET_VRING_BASE which > > >>> 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 in = a > > >> file (the status could change while the VDUSE application is stopped= , > > >> but maybe it would receive the notification at reconnect). > > > > > > I see. > > > > > >> > > >> I will prototype using a tmpfs file to save needed information, and = 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. Otherwise > > >>> 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 a= ble > > >> to fetch what was filled at VDUSE_CREATE_DEV time. > > >> > > >> With the tmpfs file, we can avoid doing that and just save the confi= g > > >> 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/53913f2b1155b02c= 44d5d3d298aafd357e7a8c48 > > 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. Thanks, Yongji