Received: by 10.213.65.68 with SMTP id h4csp130528imn; Thu, 15 Mar 2018 11:45:21 -0700 (PDT) X-Google-Smtp-Source: AG47ELuaKNC9iz46QncIf/n5GaeLkCIaHzGEVVcOdLoUdcqLdlUSVpmEeDUaDsA1TSmKNEF8Adla X-Received: by 2002:a17:902:5993:: with SMTP id p19-v6mr9047966pli.347.1521139521003; Thu, 15 Mar 2018 11:45:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521139520; cv=none; d=google.com; s=arc-20160816; b=ZZAlPciIfwpY2U8K7fOh1P9qeCupfIlUFigkWs4qJTJb/SyNGUPExg3voGlTMwVBtX NHpzibf5CaymTdsWI/k+UKl54GS+Yny0pAdTUHi26j63g9ShMy/9Z+Pe3k6LYVNTL+Bv cN2jQ0KXL5L4hoMdTJ02eXaksP05gGEE97Q7rp1g0ezrF4nolGfLid2kxU8/jIFfDXPD bX/bGQMRYbXP9DtW2VRGRfz7T43aZw2cM2Douh4uJQnONDFvfAg8cBn7pmptCvxkX8Dj WJwOvvE1l64JKCFubhDoUOwPQxWHzq9bAPXNij1poctQIHr5KZHHsnByZ5SHVRwoeQmK gdAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature:arc-authentication-results; bh=3X23UYEF2uUXYUxHN7J2PnSiBHvuTzsdt7J0Un4vHoA=; b=YRbeIRLWjHMDhoOLMZ7K995koNHuxFxHlqSQM/Z3IbMRaZOksF2Cj3qCBAUVv66PAZ pzeWqfzY5adbULZbdKi3tj67BZzBmkmOQHRbJIEgxaeIHeX7d5OgzHPgvNAtULJZ296k ijFpL+ZNqFImFwvLY1+29aJuSdlGpP24dPk/oaUS5tTGLaniJtPDGRd5bSF/L/zfTTMn FQHd9We60HeOeW2bF5rA05cgjpHMrmvgS4It1rndhM5KDQ/fUey2c5VdT6ko0UreuiBw lMFY4toWTZSBiHZZTL5B/ix1mFA46eb/jF9pBegD/3qwLNf4RmRwOBBmA4HbksOqtpS7 JMbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WDyZdGoZ; 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 c12-v6si4354688pls.325.2018.03.15.11.45.06; Thu, 15 Mar 2018 11:45:20 -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=WDyZdGoZ; 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 S1752886AbeCOSoO (ORCPT + 99 others); Thu, 15 Mar 2018 14:44:14 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:38332 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751492AbeCOSoK (ORCPT ); Thu, 15 Mar 2018 14:44:10 -0400 Received: by mail-pl0-f67.google.com with SMTP id m22-v6so4316194pls.5; Thu, 15 Mar 2018 11:44:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=3X23UYEF2uUXYUxHN7J2PnSiBHvuTzsdt7J0Un4vHoA=; b=WDyZdGoZ7AsjCZumIA24zKdq2Lu8DwnrawIZxqKSyRjUuCYB5dnEO2mPaoe9fbR8nK lLgZ7u+OSGK7TXOEklGgM7lkqRpTjCX/ohbFTX0eR7pkkhgV4YPl2wdJh0XPzZ5ePf40 QUSMw3r3F/kuRoAJEc5quxtbZqmFE3FaaPYUGYjyCux7ZnZnIFRfVfPBZQM6c/O4+7DS dk/RjgpYJ+urYLc8eFdUgCEVPweabMlGj7MW2TDsDpAng9ZomLuzHaA7vYhEcdgnkuKg bzX4ttz+fUBWtV9YHvGVRb/dwG1vZ3og5VKELbFGXI2mNfrESYPBUcZYa9xl8ROkt6U0 4CZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=3X23UYEF2uUXYUxHN7J2PnSiBHvuTzsdt7J0Un4vHoA=; b=NWgzteTKKFhiVsnrpNaoD2SxZj/Y/j51i0u0iaHrCWYP/DKciSre84n/nqP5l6+DNA ZSJWWtyze233Ql3a1tmmr6lJSjaCJcrbleLYKgb8+GDrrxaYkejP+xAdjP8oiaiSli2T 7cJniWeV8dO55je/TCrq5Vkhz4oDZedoamX1QgsHGsTpoTt2GxeYvhU3ahx95cJLVZxD GR13LTDV7agc2uD5tAyqreMHHnYj2Sumur5Etrz0K9XZ54jn0DI3+lZOY5T8Rq9IfMkN qUximEemi1OoNLmXMd9Xf9acJ7IGx1zhhoztRFwn+vdy6wq7+d7HMUBSrBtZEsig6z2y /h7g== X-Gm-Message-State: AElRT7E24VJTpnUTY+ISWPjCzUZOUdcJ0rQDszO1PP3J4De05an0z/CZ zEeuQKoExicjOI15VNHNt18= X-Received: by 2002:a17:902:d24:: with SMTP id 33-v6mr9348586plu.8.1521139449572; Thu, 15 Mar 2018 11:44:09 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id g16sm11971498pfd.23.2018.03.15.11.44.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 11:44:08 -0700 (PDT) Subject: [pci PATCH v7 5/5] pci-pf-stub: Add PF driver stub for PFs that function only to enable VFs From: Alexander Duyck To: bhelgaas@google.com, alexander.h.duyck@intel.com, linux-pci@vger.kernel.org Cc: virtio-dev@lists.oasis-open.org, kvm@vger.kernel.org, netdev@vger.kernel.org, dan.daly@intel.com, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, keith.busch@intel.com, netanel@amazon.com, ddutile@redhat.com, mheyne@amazon.de, liang-min.wang@intel.com, mark.d.rustad@intel.com, dwmw2@infradead.org, hch@lst.de, dwmw@amazon.co.uk Date: Thu, 15 Mar 2018 11:44:07 -0700 Message-ID: <20180315184356.3102.71367.stgit@localhost.localdomain> In-Reply-To: <20180315183449.3102.64791.stgit@localhost.localdomain> References: <20180315183449.3102.64791.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Duyck Add a new driver called "pci-pf-stub" to act as a "white-list" for PF devices that provide no other functionality other then acting as a means of allocating a set of VFs. For now I only have one example ID provided by Amazon in terms of devices that require this functionality. The general idea is that in the future we will see other devices added as vendors come up with devices where the PF is more or less just a lightweight shim used to allocate VFs. Signed-off-by: Alexander Duyck --- v6: New driver to address concerns about Amazon devices left unsupported v7: Dropped pci_id table explanation from pci-pf-stub driver drivers/pci/Kconfig | 12 ++++++++++ drivers/pci/Makefile | 2 ++ drivers/pci/pci-pf-stub.c | 54 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 2 ++ 4 files changed, 70 insertions(+) create mode 100644 drivers/pci/pci-pf-stub.c diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 34b56a8f8480..cdef2a2a9bc5 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -71,6 +71,18 @@ config PCI_STUB When in doubt, say N. +config PCI_PF_STUB + tristate "PCI PF Stub driver" + depends on PCI + depends on PCI_IOV + help + Say Y or M here if you want to enable support for devices that + require SR-IOV support, while at the same time the PF itself is + not providing any actual services on the host itself such as + storage or networking. + + When in doubt, say N. + config XEN_PCIDEV_FRONTEND tristate "Xen PCI Frontend" depends on PCI && X86 && XEN diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 941970936840..4e133d3df403 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -43,6 +43,8 @@ obj-$(CONFIG_PCI_SYSCALL) += syscall.o obj-$(CONFIG_PCI_STUB) += pci-stub.o +obj-$(CONFIG_PCI_PF_STUB) += pci-pf-stub.o + obj-$(CONFIG_PCI_ECAM) += ecam.o obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o diff --git a/drivers/pci/pci-pf-stub.c b/drivers/pci/pci-pf-stub.c new file mode 100644 index 000000000000..9d5fdf20d485 --- /dev/null +++ b/drivers/pci/pci-pf-stub.c @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0 +/* pci-pf-stub - simple stub driver for PCI SR-IOV PF device + * + * This driver is meant to act as a "white-list" for devices that provde + * SR-IOV functionality while at the same time not actually needing a + * driver of their own. + */ + +#include +#include + +/** + * pci_pf_stub_white_list - White list of devices to bind pci-pf-stub onto + * + * This table provides the list of IDs this driver is supposed to bind + * onto. You could think of this as a list of "quirked" devices where we + * are adding support for SR-IOV here since there are no other drivers + * that they would be running under. + */ +static const struct pci_device_id pci_pf_stub_white_list[] = { + { PCI_VDEVICE(AMAZON, 0x0053) }, + /* required last entry */ + { 0 } +}; +MODULE_DEVICE_TABLE(pci, pci_pf_stub_white_list); + +static int pci_pf_stub_probe(struct pci_dev *dev, + const struct pci_device_id *id) +{ + pci_info(dev, "claimed by pci-pf-stub\n"); + return 0; +} + +static struct pci_driver pf_stub_driver = { + .name = "pci-pf-stub", + .id_table = pci_pf_stub_white_list, + .probe = pci_pf_stub_probe, + .sriov_configure = pci_sriov_configure_simple, +}; + +static int __init pci_pf_stub_init(void) +{ + return pci_register_driver(&pf_stub_driver); +} + +static void __exit pci_pf_stub_exit(void) +{ + pci_unregister_driver(&pf_stub_driver); +} + +module_init(pci_pf_stub_init); +module_exit(pci_pf_stub_exit); + +MODULE_LICENSE("GPL"); diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index a6b30667a331..b10621896017 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -2548,6 +2548,8 @@ #define PCI_VENDOR_ID_CIRCUITCO 0x1cc8 #define PCI_SUBSYSTEM_ID_CIRCUITCO_MINNOWBOARD 0x0001 +#define PCI_VENDOR_ID_AMAZON 0x1d0f + #define PCI_VENDOR_ID_TEKRAM 0x1de1 #define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29