Received: by 10.192.165.148 with SMTP id m20csp471833imm; Fri, 20 Apr 2018 09:40:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/8Vre5L835XoZxyMpKegZuZud3+Wpguzjaw8buDauBC8PRtuRAeqKkJvOutFOcAxaKx/nD X-Received: by 2002:a17:902:684c:: with SMTP id f12-v6mr10995993pln.139.1524242415687; Fri, 20 Apr 2018 09:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524242415; cv=none; d=google.com; s=arc-20160816; b=S+HuFdX13WhAWjktlg/lDMFhzI2qKLKIgaAtsFu0tGDYTd3N9pBEnxBkR/gOyrVfLy 6K1FnsGXmZqzr5Hg+sMxaiamp4lJxN48DEmhRIhYeDjudknW4Rmn9oMv4rHWzIS+jUGm fDCzw9YetZZpiZ70B9RrODNcIK36shuTnO7pjMpZhPYD3m5FLpRTgV6zDHEzf+7P1cla WfBsDpJIpYC3bbF2tEHPzDDqDZGAwjqV5nZ+QoGtNlIDa75+5NmZ7tj/DOw2i5JyA0JE wb9TIRwxnY2Cl3cfUnw9TlK27m25LfJ1i17le3V5hMOG78V9+Gi8RHSzXWlGntHwnZaf fJzQ== 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:arc-authentication-results; bh=+1uZaNeXqrbvIk8+5gNXBOodbTLNYcPaT6w74/ZTOrk=; b=w4YsZyAgwE/Dzst1PuUlqiQVdlqd1m/MVj1JXl7W3PnGLLHNsUY/81XeUWhldSy5cE g8YJkuFMWCN/smFpmO4yP1at1qB11Xjjq3JP0svfNm7ib4r8RvInIzgMBjEK/g7eufiU gggF19jVijUrRN5L6wwW9ljcx9XCVnwYkHZVwMaxQ76ke0uK6DZgAikyXyHaXdMGe34x wD9el6AdoySXKxJqWS0RhX+OxH6/9Gtl3PbVBADTEKj2ZBFCH0ITcRJCxknQEnR9YH7n uEn1HxXIlcR3Y4pRzMpQKPbujSKiUsPitffbJrvzTQ10ABKrZR0znakDJ8q6cvqFARSP IUyA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p9-v6si6185945plk.294.2018.04.20.09.40.01; Fri, 20 Apr 2018 09:40:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753087AbeDTQij (ORCPT + 99 others); Fri, 20 Apr 2018 12:38:39 -0400 Received: from mga14.intel.com ([192.55.52.115]:64061 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751227AbeDTQig (ORCPT ); Fri, 20 Apr 2018 12:38:36 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Apr 2018 09:38:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,302,1520924400"; d="scan'208";a="48585495" Received: from ahduyck-green-test.jf.intel.com ([10.166.244.179]) by fmsmga001.fm.intel.com with ESMTP; 20 Apr 2018 09:38:35 -0700 Subject: [pci PATCH v8 4/4] 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: Fri, 20 Apr 2018 12:31:44 -0400 Message-ID: <20180420163109.46077.60334.stgit@ahduyck-green-test.jf.intel.com> In-Reply-To: <20180420162633.46077.49012.stgit@ahduyck-green-test.jf.intel.com> References: <20180420162633.46077.49012.stgit@ahduyck-green-test.jf.intel.com> 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 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 34b56a8..cdef2a2 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 9419709..4e133d3 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 0000000..9d5fdf2 --- /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 a637a7d..62dab14 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -2549,6 +2549,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