Received: by 10.192.165.148 with SMTP id m20csp1830098imm; Sat, 21 Apr 2018 17:23:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/YKmUUY+5dIv3iFYe3oNI2kCGRdz5QWN3OJUa81Kt3UI7gXjxlAMssWDAEAwwNNRoOpfj2 X-Received: by 10.99.125.78 with SMTP id m14mr12369030pgn.190.1524356634386; Sat, 21 Apr 2018 17:23:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524356634; cv=none; d=google.com; s=arc-20160816; b=DoKYX6jFprsWLh76/y89RwmHQV/HIiVifzQrDae4l/5RGOwOqLdAF8sglno0c9SG0i kfhSWSRvUHR3xx6RBiROZ5hwsNKuqFuA7QnBlaXdd2s8wP6dROEw1gVP5veZR8HcgBRe A9WmmxsIGT0Uf3xpBES9Zi86KAWDaKD770TbanOZO9p7VlrwxnDkA8tFQi4WF4obvzSv 4YLdID41GmdH6V7XT+cxjTWR7TrwJ7zQmfbP0UOFDtqRykt+N3mOxDj4cB4f5QXXiFCW Q6DOXRnjENd5tX/oWfl5WKj0uYejVMS/E8tSqp4sUBJrAVYqqCTOXp77esepo+YRoI0f HTFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=6bpUDJYTwHpBmt1DceYWJiMAMPpVxcvrQKSstyKXXaw=; b=Y6aQtha3VIyH86y6bWjyv9109ztAUv2SHIGgFt92V1WZgNGqhFYIjNvx8rhszoOSKE rnnBWcLpNrKJOmtn78rvs/WhT9gNhTz63LphaQu12+nfHCeOi40kx+tOBx8DpOX7ZINp pf1Gih7VfmlM7xpys5uiTxpUlI0fgIDoxyMm0JuGPc6uYGdSWVZcDEfX1XuoS0bSgD6C Xn0vmtlVrgFvqCPv/VKkckUc2SaoFVROsAjBSIWxsY4KS2BCAbb2/smYaFRH8FHJDkrT 1CsNXeplSpAc8/xeL+QZlygThdNRqyWHpWzD6t81o0So0EOj8VTlJDnqAMM+hALpS0CI wl6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NG3bnEcu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si3424773pgp.298.2018.04.21.17.23.39; Sat, 21 Apr 2018 17:23:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NG3bnEcu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753395AbeDVAWa (ORCPT + 99 others); Sat, 21 Apr 2018 20:22:30 -0400 Received: from mail-ot0-f196.google.com ([74.125.82.196]:33244 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753310AbeDVAW2 (ORCPT ); Sat, 21 Apr 2018 20:22:28 -0400 Received: by mail-ot0-f196.google.com with SMTP id l22-v6so2927767otj.0; Sat, 21 Apr 2018 17:22:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=6bpUDJYTwHpBmt1DceYWJiMAMPpVxcvrQKSstyKXXaw=; b=NG3bnEcu1VhqbcOVlExaKggWfa4mLjNxdJMZiTz0SJRH0bgBkBP2yh+vMnnYNJp/I6 6cqltPHPIsze2PO7ECQyNE5O5GdcNeHeGUpJPMDaew+fn+r0/K6I0t2R6DQ6jnjERpnH K83Fy2m7KRj7pmdes93zxWIlAXvq96ZBw7YVX1PJna0X+KV2E72ADNCLAdfACu21iaWz QW0IfB6yHfENE5y0ytlHgw3ruWUY1jSaVq/milyFxKDbFEX/aM8pPrMdAJKBIzXy9UA8 Q01KaNqXliw6CRnnIEyGJiAYScndncHmq8kzTWog5hJV/fWfV9cpRe0nMkQNFuQqnfRe c/4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=6bpUDJYTwHpBmt1DceYWJiMAMPpVxcvrQKSstyKXXaw=; b=ZnTrLgb0Zis8Hlud47zc5BynwE2Er6mKSmt2MS4xKnAlU1tQBeDobASxj/xJI5Hpef /0b3ipM8bxchBHETg/0+zR7qWLyE79SXrdFfpSl1JSS8PbOqCuPu/b2h17Uyrz0+GfOd QTCyH3sCl1qyzf+W/DCbzQRZmc8F6VAXxqkBOnNAyNHJcPAv2FKoo7SC1x2bwyofRQXl sYB/Kwsaa1QIRi2/fhmRo6ISOGGpyFwEIZlSXyz8FfAhphJp5htKdU/T1OmuBODwntTh 0C26k7rHUcUhElMMnQWBia03lIfv911WZtIjY7dxqY4m+sJD+WH90sxtSWQommxbL02c 5+YA== X-Gm-Message-State: ALQs6tDB7AZSY8qGYcWu7GvGSkdaChAbp56JcAoBWVC3xPXsOJtvSBiA 12vsqTwbPyUpupVvXsYHOjTDMoPEusCkG1wl6ek= X-Received: by 2002:a9d:3a36:: with SMTP id j51-v6mr9828908otc.157.1524356547656; Sat, 21 Apr 2018 17:22:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.201.52.1 with HTTP; Sat, 21 Apr 2018 17:22:27 -0700 (PDT) In-Reply-To: <20180421203437.GW28657@bhelgaas-glaptop.roam.corp.google.com> References: <20180420162633.46077.49012.stgit@ahduyck-green-test.jf.intel.com> <20180421203437.GW28657@bhelgaas-glaptop.roam.corp.google.com> From: Alexander Duyck Date: Sat, 21 Apr 2018 17:22:27 -0700 Message-ID: Subject: Re: [pci PATCH v8 0/4] Add support for unmanaged SR-IOV To: Bjorn Helgaas Cc: Alexander Duyck , Bjorn Helgaas , linux-pci@vger.kernel.org, virtio-dev@lists.oasis-open.org, kvm@vger.kernel.org, Netdev , "Daly, Dan" , LKML , linux-nvme@lists.infradead.org, Keith Busch , netanel@amazon.com, Don Dutile , Maximilian Heyne , "Wang, Liang-min" , "Rustad, Mark D" , David Woodhouse , Christoph Hellwig , dwmw@amazon.co.uk Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 21, 2018 at 1:34 PM, Bjorn Helgaas wrote: > On Fri, Apr 20, 2018 at 12:28:08PM -0400, Alexander Duyck wrote: >> This series is meant to add support for SR-IOV on devices when the VFs are >> not managed by the kernel. Examples of recent patches attempting to do this >> include: >> virto - https://patchwork.kernel.org/patch/10241225/ >> pci-stub - https://patchwork.kernel.org/patch/10109935/ >> vfio - https://patchwork.kernel.org/patch/10103353/ >> uio - https://patchwork.kernel.org/patch/9974031/ >> >> Since this is quickly blowing up into a multi-driver problem it is probably >> best to implement this solution as generically as possible. >> >> This series is an attempt to do that. What we do with this patch set is >> provide a generic framework to enable SR-IOV in the case that the PF driver >> doesn't support managing the VFs itself. >> >> I based my patch set originally on the patch by Mark Rustad but there isn't >> much left after going through and cleaning out the bits that were no longer >> needed, and after incorporating the feedback from David Miller. At this point >> the only items to be fully reused was his patch description which is now >> present in patch 3 of the set. >> >> This solution is limited in scope to just adding support for devices that >> provide no functionality for SR-IOV other than allocating the VFs by >> calling pci_enable_sriov. Previous sets had included patches for VFIO, but >> for now I am dropping that as the scope of that work is larger then I >> think I can take on at this time. >> >> v2: Reduced scope back to just virtio_pci and vfio-pci >> Broke into 3 patch set from single patch >> Changed autoprobe behavior to always set when num_vfs is set non-zero >> v3: Updated Documentation to clarify when sriov_unmanaged_autoprobe is used >> Wrapped vfio_pci_sriov_configure to fix build errors w/o SR-IOV in kernel >> v4: Dropped vfio-pci patch >> Added ena and nvme to drivers now using pci_sriov_configure_unmanaged >> Dropped pci_disable_sriov call in virtio_pci to be consistent with ena >> v5: Dropped sriov_unmanaged_autoprobe and pci_sriov_conifgure_unmanaged >> Added new patch that enables pci_sriov_configure_simple >> Updated drivers to use pci_sriov_configure_simple >> v6: Defined pci_sriov_configure_simple as NULL when SR-IOV is not enabled >> Updated drivers to drop "#ifdef" checks for IOV >> Added pci-pf-stub as place for PF-only drivers to add support >> v7: Dropped pci_id table explanation from pci-pf-stub driver >> Updated pci_sriov_configure_simple to drop need for err value >> Fixed comment explaining why pci_sriov_configure_simple is NULL >> v8: Dropped virtio from the set, support to be added later after TC approval >> >> Cc: Mark Rustad >> Cc: Maximilian Heyne >> Cc: Liang-Min Wang >> Cc: David Woodhouse >> >> --- >> >> Alexander Duyck (4): >> pci: Add pci_sriov_configure_simple for PFs that don't manage VF resources >> ena: Migrate over to unmanaged SR-IOV support >> nvme: Migrate over to unmanaged SR-IOV support >> pci-pf-stub: Add PF driver stub for PFs that function only to enable VFs >> >> >> drivers/net/ethernet/amazon/ena/ena_netdev.c | 28 ------------- >> drivers/nvme/host/pci.c | 20 ---------- >> drivers/pci/Kconfig | 12 ++++++ >> drivers/pci/Makefile | 2 + >> drivers/pci/iov.c | 31 +++++++++++++++ >> drivers/pci/pci-pf-stub.c | 54 ++++++++++++++++++++++++++ >> include/linux/pci.h | 3 + >> include/linux/pci_ids.h | 2 + >> 8 files changed, 106 insertions(+), 46 deletions(-) >> create mode 100644 drivers/pci/pci-pf-stub.c > > I tentatively applied these to pci/virtualization-review. > > The code changes look fine, but I want to flesh out the changelogs a > little bit before merging them. Thanks. > For example, I'm not sure what you mean by "devices where the PF is > not capable of managing VF resources." > > It *sounds* like you're saying the hardware works differently on some > devices, but I don't think that's what you mean. I think you're > saying something about which drivers are used for the PF and the VF. That is sort of what I am saying. So for example with ixgbe there is functionality which is controlled in the MMIO space of the PF that affects the functionality of the VFs that are generated on the device. The PF has to rearrange the resources such as queues and interrupts on the device before it can enable SR-IOV, and it could alter those later to limit what the VF is capable of doing. The model I am dealing with via this patch set has a PF that is not much different than the VFs other than the fact that it has some extended configuration space bits in place for SR-IOV, ARI, ACS, and whatever other bits are needed in order to support spawning isolated VFs. > I think a trivial example of how this will be used might help. I > assume this involves a virtualization scenario where the host uses the > PF to enable several VFs, but the host doesn't use the PF for much > else. Then you assign the VFs to guests, and drivers in the guest > OSes use the VFs. So this description would work for the pci-pf-stub driver. Basically the idea here is that you have a device that is nothing more than a function there to spawn VFs. The other scenario that I am supporting are the ena and nvme models. They match what I have described above where the PF is really just another VF with some extra configuration space bits that add support for spawning what amount to peer VFs to the already present PF. > Since .sriov_configure() is only used by sriov_numvfs_store(), I > assume the usage model involves writing to the sysfs sriov_numvfs > attribute to enable the VFs, then assigning them to guests? > > Bjorn Yes. The assumption for this function is that we are only supporting the sysfs approach for spawning VFs. - Alex