Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp356392pxb; Thu, 9 Sep 2021 02:32:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuywbmD74fazzUJUOzPa3g/B55Rk6nrlqTaMMUM3wkIHNZ+a8wxZhvZS76d9F3g+Mpv9PX X-Received: by 2002:a17:906:a24c:: with SMTP id bi12mr2221502ejb.530.1631179956435; Thu, 09 Sep 2021 02:32:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631179956; cv=none; d=google.com; s=arc-20160816; b=j0lnco9p4RKd5IIAWDyMigsMbQV0wsxsWsBXJvrqk+iuiLnpXIUPeZEnCai1B3GtTl UNnSaGh/MS4KDynXO++PqyTUZDtmzMEmoeqxcETTaX9zUvUQPB0Mh/8VSKkiSoDwgNKE 9UqmPNSIlxXVZmSu/YpW9vYWBOSeWDKnxDZe46ifZNFtqqiMs6GbGpAZfj9c1K7mSBt3 7k9Yc3x5oci6PCwwbEx4gvANzCdqYPxM4mFH/f2QaphYmf57pAJko4vSvodHpnemKzQZ /svU3Ww+RxzR6Ltoa7M/Zy/8tZFbZRFpKUKbysFj975IlXF/zntu11evIKNiu60I1WV0 zCAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=z4/21SiMFWF3Zx5Us2Sk9TowrO3r4kSIRTbLTVgZ8c8=; b=Ef7hO5QaXNcAKEdqZAlEP+sG/LV5KW3ddChM73Ft8HShOksqFgJdBLu/oOau/rzPi9 z+1+1bWbN9DkHNbsYT4KvrmsHCO2gBdtmNwkPJvFbHVV5Hptte2AE4D3Pi7AQTdROMhS Y1wwYI6GO9JHW9uierX5amqU1mivyJmUm8VPK3aYpcX5UQL/i1+m2YYZWm6cSBgckU4V GESejMXH5SfKymGx+3fWdGmpC2NMPuJWkaqQ3UpA/Sc/p0/Js9ndCk75XJDJoS4w0wZi aTnrIyNSTcRWiEbut1keeEW9xMRE7F7zdghFL1WEdlCr1FYSTfAholySB1CRMY4Di8cv zA1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y9WF9i5i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h14si1246915ejt.392.2021.09.09.02.32.05; Thu, 09 Sep 2021 02:32:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y9WF9i5i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232630AbhIIJbV (ORCPT + 99 others); Thu, 9 Sep 2021 05:31:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:22747 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229927AbhIIJbU (ORCPT ); Thu, 9 Sep 2021 05:31:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631179811; 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: in-reply-to:in-reply-to:references:references; bh=z4/21SiMFWF3Zx5Us2Sk9TowrO3r4kSIRTbLTVgZ8c8=; b=Y9WF9i5inVAP1lf8H2BvkNHah0AXHJBeJlC/gY4kAasgm9xNqsVO8mgJIOld9lgzb8X2Dv PwtLAurhSmijOXJyQzk4xBjy3PjR3YEcEy0g0berNObn9AlTNcjQ0nA8UgyLJHMVYirwfU zSv0Ls3MWkHL5XLZVN3Qp879yol4dPI= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-13-zb9BtJANOVKeNGymxaFWsg-1; Thu, 09 Sep 2021 05:30:10 -0400 X-MC-Unique: zb9BtJANOVKeNGymxaFWsg-1 Received: by mail-lj1-f199.google.com with SMTP id w11-20020a2e998b000000b001c071349c96so491938lji.15 for ; Thu, 09 Sep 2021 02:30:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=z4/21SiMFWF3Zx5Us2Sk9TowrO3r4kSIRTbLTVgZ8c8=; b=iPLT3kaQ4U4E30VW3Wt6Y99ZbfNuhl7UVWlrQehQexAWSpFid3vNNvz+DQ/GztvdJ6 T3rf4TF9xmVA3PZrbn3q4XdfDqvQV5zNzhgpm+6S5P/iL01SERWO48YmyvR2sHfagl5u RjsySIjCc3pEonq6wNSjLH/Eo71fdVErMqEuhn6bMt08ppZjofp0n3jk9/3cGMhy9j79 CW5wjhE//JLG35/LO2EVenUIOOJlWcxTxCU4Q430jb6YsHmw7jWfpsJotDrJ7ajpKz8V Y8Hh/1v5mipJkCHSUi3a1qjhDkqScBQHNqnrR1YEwrkxtWYQZ4bg/Pk9M+z/P9SRPK8C MMwg== X-Gm-Message-State: AOAM531N7O/sorvYIgZyyNk1EQ86ArSJ6gljfYn5m1OPrRiiJTAthbmV hEI3/ci2Ydo6ogEzvxN5o3ZzJQFGkjafpr033BkbHU4+n7g/oeh6fJvVVc0SUNWDHyh/KnWxNdS 3bvgSIXBG+cAUduUChlyliD6HpW0X/2lgGMJZpoOm X-Received: by 2002:a05:6512:110b:: with SMTP id l11mr1606251lfg.199.1631179808341; Thu, 09 Sep 2021 02:30:08 -0700 (PDT) X-Received: by 2002:a05:6512:110b:: with SMTP id l11mr1606239lfg.199.1631179808125; Thu, 09 Sep 2021 02:30:08 -0700 (PDT) MIME-Version: 1.0 References: <20210909081211.GB17383@L-PF27918B-1352.localdomain> In-Reply-To: <20210909081211.GB17383@L-PF27918B-1352.localdomain> From: Jason Wang Date: Thu, 9 Sep 2021 17:29:57 +0800 Message-ID: Subject: Re: [PATCH 0/6] vDPA driver for legacy virtio-pci device To: Wu Zongyong Cc: virtualization , linux-kernel , mst , wei.yang1@linux.alibaba.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 9, 2021 at 4:12 PM Wu Zongyong wrote: > > On Thu, Sep 09, 2021 at 11:05:06AM +0800, Jason Wang wrote: > > On Wed, Sep 8, 2021 at 8:22 PM Wu Zongyong wrote: > > > > > > This series implements the vDPA driver for legacy virtio-pci device. > > > Currently we already have the vDPA driver for modern virtio-pci device > > > only, but there are some legacy virtio-pci devices conforming to the > > > virtio-pci specifications of 0.9.x or older versions. For example, > > > ENI(Elastic Network Interface) of Alibaba ECS baremetal instance is a > > > hardware virtio network device which follows the Virtio PCI Card 0.9.5 > > > Draft specification. Such legacy virtio-pci devices have some > > > inconsistent behaviour with modern virtio-pci devices, so some common > > > codes are split out and modern device specific codes are moved to a > > > separated file. > > > > What worries me a little bit are: > > > > 1) vDPA requires IOMMU_PLATFORM to be supported by the device to work, > > if I understand ENI correctly, it's a legacy device so it can't > > support ACCESS_PLATFORM. Or is it a legacy device that supports > > ACCESS_PLATFORM implicitly. > > 2) vDPA tries to present a 1.0 device, in this case the behavior could > > be ruled by the spec. If we tries to present an 1.0 device on top of > > legacy device we may suffer a lot of issues: > > > > - endian issue: 1.0 use le but legacy may use native endian > > - queue_enable semantic which is missed in the legacy > > Writting the queue_address is regarded as enable queue in the legacy. > Right? It's implementation specific details that virtio spec can't mandate. E.g if your ENI behaves like this, you can delay the queue_address write to hardware until set_vq_ready() in the ENI vDPA driver. Thanks > > > - virtqueue size, as you mentioned below > > > > I guess what the device(ENI) supports are: > > > > 1) semantic of ACCESS_PLATFORM without a feature > > 2) little endian > > 3) but a legacy device > > > > So I think it might be better: > > > > 1) introduce the library for legacy as you did in this patch > > 2) having a dedicated ENI vDPA driver > > > > 3) live migration support, though it was not supported by the spec > > yet, but we are working on the support, and we know legacy device can > > support this. > > > > Thanks > > > > I agree. > It's better to implement a dedicated vDPA driver for ENI only. ENI is > not a standard legacy virtio-pci device. > > > > > > > For legacy devices, it is not supported to negotiate the virtqueue size > > > by the specification. So a new callback get_vq_num_unchangeable is > > > introduced to indicate user not to try change the virtqueue size of the > > > legacy vdpa device. For example, QEMU should not allocate memory for > > > virtqueue according to the properties tx_queue_size and rx_queue_size if > > > we use legacy virtio-pci device as the vhost-vdpa backend. Instead, QEMU > > > should use the new callback get_vq_num_unchangeable first to check if > > > the vdpa device support to change virtqueue size. If not, QEMU should > > > call the callback get_vq_num_max to get the static virtqueue size then > > > allocate the same size memory for the virtqueue. > > > > > > This series have been tested with the ENI in Alibaba ECS baremetal > > > instance. > > > > > > These patches may under consideration, welcome for comments. > > > > > > > > > Wu Zongyong (6): > > > virtio-pci: introduce legacy device module > > > vdpa: fix typo > > > vp_vdpa: add vq irq offloading support > > > vp_vdpa: split out reusable and device specific codes to separate file > > > vdpa: add get_vq_num_unchangeable callback in vdpa_config_ops > > > vp_vdpa: introduce legacy virtio pci driver > > > > > > drivers/vdpa/Kconfig | 7 + > > > drivers/vdpa/virtio_pci/Makefile | 3 + > > > drivers/vdpa/virtio_pci/vp_vdpa.c | 8 + > > > drivers/vdpa/virtio_pci/vp_vdpa_common.c | 220 ++++++++++++++ > > > drivers/vdpa/virtio_pci/vp_vdpa_common.h | 67 +++++ > > > drivers/vdpa/virtio_pci/vp_vdpa_legacy.c | 346 +++++++++++++++++++++++ > > > drivers/vdpa/virtio_pci/vp_vdpa_modern.c | 327 +++++++++++++++++++++ > > > drivers/vhost/vdpa.c | 19 ++ > > > drivers/virtio/Kconfig | 10 + > > > drivers/virtio/Makefile | 1 + > > > drivers/virtio/virtio_pci_common.c | 10 +- > > > drivers/virtio/virtio_pci_common.h | 9 +- > > > drivers/virtio/virtio_pci_legacy.c | 101 ++----- > > > drivers/virtio/virtio_pci_legacy_dev.c | 220 ++++++++++++++ > > > drivers/virtio/virtio_vdpa.c | 5 +- > > > include/linux/vdpa.h | 6 +- > > > include/linux/virtio_pci_legacy.h | 44 +++ > > > include/uapi/linux/vhost.h | 2 + > > > 18 files changed, 1320 insertions(+), 85 deletions(-) > > > create mode 100644 drivers/vdpa/virtio_pci/vp_vdpa_common.c > > > create mode 100644 drivers/vdpa/virtio_pci/vp_vdpa_common.h > > > create mode 100644 drivers/vdpa/virtio_pci/vp_vdpa_legacy.c > > > create mode 100644 drivers/vdpa/virtio_pci/vp_vdpa_modern.c > > > create mode 100644 drivers/virtio/virtio_pci_legacy_dev.c > > > create mode 100644 include/linux/virtio_pci_legacy.h > > > > > > -- > > > 2.31.1 > > > >