From patchwork Tue Mar 13 21:28:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander H Duyck X-Patchwork-Id: 885493 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qpb1pRPn"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4017Jk5yl2z9sTt for ; Wed, 14 Mar 2018 08:28:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752692AbeCMV2w (ORCPT ); Tue, 13 Mar 2018 17:28:52 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35379 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752397AbeCMV2v (ORCPT ); Tue, 13 Mar 2018 17:28:51 -0400 Received: by mail-pg0-f67.google.com with SMTP id d1so448875pgv.2; Tue, 13 Mar 2018 14:28:51 -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=Ed4ikwizjsLBPJgGhJdQ/26iFo2M6bcOsDmoVV53A+c=; b=qpb1pRPntT1B1toZdzQNRhKifHixO3MEok7sIOGOrw1w6Zpf8LJdU436A3RhzsJSpY CJaFLWCkegFspHOgNs2egwfROU+hyWzEarZ6FQoZclBHwn9o8gW9KhscuRsoKkNxy+8G j+RYDbx+gVa1FOtk7AHZXwxmLVmwHJlIIXqCBTOL775qjI770r8c3j3rVrT7eivHaPmB I0nONn8CK0pvO+u3dnNFGS9uL3chvvJ42XrJIPBiirSUC/Wm8CP2O0c6wLiYu5lTgMkt HVVfK4X6/YkiyMDz1zcO/zzWsJAXEKYl8PYi/+rcPGY7phd9af6jz9IR5BmK0OjIV/ZQ iiIw== 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=Ed4ikwizjsLBPJgGhJdQ/26iFo2M6bcOsDmoVV53A+c=; b=U+PO8CZrq6HOiQ7sfx0SHoMpCmPGAM421IQpzHoEzOebl/An9oR7M1JXvTafyjaYe9 0wMM0Iza9MfyrI7S+hc3H2rYql3fZAHhOHOhQyV0Vi+Py3vCpuG2N4PsEklO7DvfQnd7 aJjyURNWOV1NuZzTipbXv6CybBdbr9pfGH8ecJ8nsAm0qM/RUpMFBDEilr0f0Oq1TufI tflXjtKU2iWdX6M/SikYBsSIY45L9oXa1psXXRNtrRfLKaelPagKDZWHbPubfvMGHglE EP4W+mekFIyGvtcODlFloJRD/jJppQeFAQjvb+dxbP5kpywKRSCahaUH3A2PF2FZ6kpu i1dQ== X-Gm-Message-State: AElRT7E6NBr/uimykGH9YfGHbg84nAOGTwT/jMRZbH1Z0PWz+z+VY04F aOIuSboOh5mlTAZW3QGAwxQ= X-Google-Smtp-Source: AG47ELutM8chTAexINwr5vFVnu+1RjMr7SsK+zA53R/sFV5IXCrlhuccDJMBytJYz7KgHQkeeNa4pQ== X-Received: by 10.99.111.78 with SMTP id k75mr1665840pgc.414.1520976530784; Tue, 13 Mar 2018 14:28:50 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id r78sm1898535pfb.24.2018.03.13.14.28.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 14:28:50 -0700 (PDT) Subject: [pci PATCH v6 1/5] pci: Add pci_sriov_configure_simple for PFs that don't manage VF resources 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: Tue, 13 Mar 2018 14:28:49 -0700 Message-ID: <20180313212754.3553.72176.stgit@localhost.localdomain> In-Reply-To: <20180313212508.3553.65326.stgit@localhost.localdomain> References: <20180313212508.3553.65326.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Alexander Duyck This patch adds a common configuration function called pci_sriov_configure_simple that will allow for managing VFs on devices where the PF is not capable of managing VF resources. Signed-off-by: Alexander Duyck Reviewed-by: Christoph Hellwig --- v5: New patch replacing pci_sriov_configure_unmanaged with pci_sriov_configure_simple Dropped bits related to autoprobe changes v6: Defined pci_sriov_configure_simple as NULL if IOV is disabled drivers/pci/iov.c | 32 ++++++++++++++++++++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 35 insertions(+) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 677924ae0350..bd7021491fdb 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -807,3 +807,35 @@ int pci_sriov_get_totalvfs(struct pci_dev *dev) return dev->sriov->total_VFs; } EXPORT_SYMBOL_GPL(pci_sriov_get_totalvfs); + +/** + * pci_sriov_configure_simple - helper to configure unmanaged SR-IOV + * @dev: the PCI device + * @nr_virtfn: number of virtual functions to enable, 0 to disable + * + * Used to provide generic enable/disable SR-IOV option for devices + * that do not manage the VFs generated by their driver + */ +int pci_sriov_configure_simple(struct pci_dev *dev, int nr_virtfn) +{ + int err = -EINVAL; + + might_sleep(); + + if (!dev->is_physfn) + return -ENODEV; + + if (pci_vfs_assigned(dev)) { + pci_warn(dev, + "Cannot modify SR-IOV while VFs are assigned\n"); + err = -EPERM; + } else if (!nr_virtfn) { + sriov_disable(dev); + err = 0; + } else if (!dev->sriov->num_VFs) { + err = sriov_enable(dev, nr_virtfn); + } + + return err ? err : nr_virtfn; +} +EXPORT_SYMBOL_GPL(pci_sriov_configure_simple); diff --git a/include/linux/pci.h b/include/linux/pci.h index 024a1beda008..f3099e940cda 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1953,6 +1953,7 @@ static inline void pci_mmcfg_late_init(void) { } int pci_vfs_assigned(struct pci_dev *dev); int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs); int pci_sriov_get_totalvfs(struct pci_dev *dev); +int pci_sriov_configure_simple(struct pci_dev *dev, int nr_virtfn); resource_size_t pci_iov_resource_size(struct pci_dev *dev, int resno); void pci_vf_drivers_autoprobe(struct pci_dev *dev, bool probe); #else @@ -1980,6 +1981,8 @@ static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs) { return 0; } static inline int pci_sriov_get_totalvfs(struct pci_dev *dev) { return 0; } +/* since this expected to be used as a function pointer just define as NULL */ +#define pci_sriov_configure_simple NULL static inline resource_size_t pci_iov_resource_size(struct pci_dev *dev, int resno) { return 0; } static inline void pci_vf_drivers_autoprobe(struct pci_dev *dev, bool probe) { } From patchwork Tue Mar 13 21:29:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander H Duyck X-Patchwork-Id: 885496 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SbzACczR"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4017LF52Jpz9sTd for ; Wed, 14 Mar 2018 08:30:13 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752840AbeCMV3w (ORCPT ); Tue, 13 Mar 2018 17:29:52 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:38285 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752555AbeCMV3v (ORCPT ); Tue, 13 Mar 2018 17:29:51 -0400 Received: by mail-pl0-f66.google.com with SMTP id m22-v6so556762pls.5; Tue, 13 Mar 2018 14:29:51 -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=j3Og+ENt3+Y2jUGYB9m1kQwWgI/AxSEmDluLYu5I6I8=; b=SbzACczRh8RkzxiP6lLJE4UTv9pFT2Ryo6E3Ftrq3uUetBRHVPsaKRUNRA6MAGum0o 0rHw9456oBogrTSB1Vyy3YAELUWLtaKDd2ug+kZYQXTde9Vst6M74k5/4h/QF/J9qtYx VyolNar1mjWTV7f7HsMy6xl/LwbYqF5OIO3OdcyHj9b4Je4lrTPGE9TPRZe0gl7n63JZ +n12Jz0MV+1BouViD21vsW3XU04qqX37PW2cSqpcfQk+5qsXDRjg9uGTbpgbmg3hVVsL 47NdRpHubW4uSboPaw/x5oQPLH3kC9dvAVoUt2iFGjqxR/SJfRrTGBvEVJKTKHNLuiRv Czaw== 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=j3Og+ENt3+Y2jUGYB9m1kQwWgI/AxSEmDluLYu5I6I8=; b=YphALZLMvnCRRbgafRD5MkctZMoKxPqfZluCNF83zXZCXQtJMaJPk8ZdD+Bm9KZPBM 5OaE13CX9mp8KJPRshepXvizx9TNJYQnIQWLTIUA8rnRDwMNfZ8TCSatulavgziq47VU JLUQ3SzxU4ioYN2dhdoqAd4PVSv8yMU5rf3nOz0UJgzxpeLfvR7Csr+WqM87NI9r9lli 9eMk9VTz8TGpnQIg/qquoHqPlpeK9EVrAg05nzQsHp5mE8okE/X3hKYMuoakvuowpwyK WmmHznPa3ffVyVlzEevAUYZ4Y9J3fxLUYgOUKQDGvaqURWmkgjBA/mTqQxNULGe2jfEg InZw== X-Gm-Message-State: AElRT7Hhd5w4DF1Saa2hjElurXG6x6dsgwMexaAGJM/GL9/BGoKwHLqY xumW4QFFICQ19JLbbQ+iQ/8= X-Google-Smtp-Source: AG47ELsib3xB4/k5BNIVEd38LaI7VAOO9gtNP6+NG8Y7h37Ex2lBxigV2yzRU23Ev3DhUwiewAvYeA== X-Received: by 2002:a17:902:a70c:: with SMTP id w12-v6mr1062406plq.243.1520976590639; Tue, 13 Mar 2018 14:29:50 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id k195sm1621058pgc.71.2018.03.13.14.29.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 14:29:50 -0700 (PDT) Subject: [pci PATCH v6 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices 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: Tue, 13 Mar 2018 14:29:49 -0700 Message-ID: <20180313212855.3553.97762.stgit@localhost.localdomain> In-Reply-To: <20180313212508.3553.65326.stgit@localhost.localdomain> References: <20180313212508.3553.65326.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Alexander Duyck Hardware-realized virtio_pci devices can implement SR-IOV, so this patch enables its use. The device in question is an upcoming Intel NIC that implements both a virtio_net PF and virtio_net VFs. These are hardware realizations of what has been up to now been a software interface. The device in question has the following 4-part PCI IDs: PF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 15fe VF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 05fe The patch currently needs no check for device ID, because the callback will never be made for devices that do not assert the capability or when run on a platform incapable of SR-IOV. One reason for this patch is because the hardware requires the vendor ID of a VF to be the same as the vendor ID of the PF that created it. So it seemed logical to simply have a fully-functioning virtio_net PF create the VFs. This patch makes that possible. Signed-off-by: Mark Rustad Signed-off-by: Alexander Duyck Reviewed-by: Christoph Hellwig --- v4: Dropped call to pci_disable_sriov in virtio_pci_remove function v5: Replaced call to pci_sriov_configure_unmanaged with pci_sriov_configure_simple v6: Dropped "#ifdef" checks for IOV wrapping sriov_configure definition drivers/virtio/virtio_pci_common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c index 48d4d1cf1cb6..67a227fd7aa0 100644 --- a/drivers/virtio/virtio_pci_common.c +++ b/drivers/virtio/virtio_pci_common.c @@ -596,6 +596,7 @@ static void virtio_pci_remove(struct pci_dev *pci_dev) #ifdef CONFIG_PM_SLEEP .driver.pm = &virtio_pci_pm_ops, #endif + .sriov_configure = pci_sriov_configure_simple, }; module_pci_driver(virtio_pci_driver); From patchwork Tue Mar 13 21:30:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander H Duyck X-Patchwork-Id: 885497 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ft+7Eu1x"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4017Ld0qPSz9sTy for ; Wed, 14 Mar 2018 08:30:33 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932397AbeCMVab (ORCPT ); Tue, 13 Mar 2018 17:30:31 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:39908 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932277AbeCMVaa (ORCPT ); Tue, 13 Mar 2018 17:30:30 -0400 Received: by mail-pl0-f65.google.com with SMTP id s13-v6so556996plq.6; Tue, 13 Mar 2018 14:30:30 -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=qTc1wktVoS9J/ugQsWcIQPJBGh9JAXNZszzk7xjQdZI=; b=Ft+7Eu1xNbarFcDHi5riHaKNVE5GaMvj5JEhX73JYJNERd5fkQRfaWsrssE8+r7LeQ pibPymcuD4DLNIhtsY7GY3mNFniVlAsYTuJkj6DTJEs78UmgUhT7p6PD3ITX7r7kVUlW SmUvX8ulWIKLt/LYHms5CBbnKSlkoVf/x0GZVOKv2NsMeKXV1aVcOhsMH360CfSnidAi mUEpKAJbF+aP859zkCtCrcRXLHczilg9vIFnOm4Ch9zJIFZ/U9IgtI80F8/ve8tegWSS 2ZaDjfoVBoZTSzCcGswSyTLot/L+Lyabb03quo2NrspfcZXFmn7haf+VTjl4pliD890l 1Dcg== 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=qTc1wktVoS9J/ugQsWcIQPJBGh9JAXNZszzk7xjQdZI=; b=ZmzQRbn4mbYoDs9L9dO6sD/1zGeGx5vRkr5/0EJGNfdor7lsSRiwv0uPBdV9VnIBUk EcC2HE3N09n5CsM5YPdCoUYloAEv7SO9ClU4y19O5p+yW7lsjMLMbU2GTxwy3efaeYkw Fuc12+GDw9zJVgsHsTu4sBCl8NaJYv0reaJicCrT8Js4bHrKizvnEDs/SEw4itxoWAQz /pBO+3dYQzdBq4CrusTgcckcXUvmem3U/dH8ih+8o3TKsEoIK/HhfMmY7Ct6eGKtQhhL PCy9PCsQ3zyINv7JvS7QJ8ANi05yGNMU9fq+ENc3HWumHQWizCwWfyNJ0+v52T0b7wTO 5kzQ== X-Gm-Message-State: AElRT7GxD9Sfkqi8z6avjk4WIMKLNGa88o5G7IB3c8e2+lMwYy/pTSez ojQ1wIPE5p5Y8RNal2NhlYY= X-Google-Smtp-Source: AG47ELsebVaz2uczpHI2uGQaVJ61kmw4OtJLwKeMAVosF1IAr2d5BgVVMwDg8ahcdlZLZyEnVzlh3w== X-Received: by 2002:a17:902:b901:: with SMTP id bf1-v6mr1803062plb.175.1520976629898; Tue, 13 Mar 2018 14:30:29 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id b9sm2006558pff.13.2018.03.13.14.30.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 14:30:29 -0700 (PDT) Subject: [pci PATCH v6 3/5] ena: Migrate over to unmanaged SR-IOV support 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: Tue, 13 Mar 2018 14:30:28 -0700 Message-ID: <20180313212955.3553.16026.stgit@localhost.localdomain> In-Reply-To: <20180313212508.3553.65326.stgit@localhost.localdomain> References: <20180313212508.3553.65326.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Alexander Duyck Instead of implementing our own version of a SR-IOV configuration stub in the ena driver we can just reuse the existing pci_sriov_configure_simple function. Signed-off-by: Alexander Duyck --- v5: Replaced call to pci_sriov_configure_unmanaged with pci_sriov_configure_simple v6: Dropped "#ifdef" checks for IOV wrapping sriov_configure definition drivers/net/ethernet/amazon/ena/ena_netdev.c | 28 +------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index 6975150d144e..6054deb1e6aa 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -3385,32 +3385,6 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } /*****************************************************************************/ -static int ena_sriov_configure(struct pci_dev *dev, int numvfs) -{ - int rc; - - if (numvfs > 0) { - rc = pci_enable_sriov(dev, numvfs); - if (rc != 0) { - dev_err(&dev->dev, - "pci_enable_sriov failed to enable: %d vfs with the error: %d\n", - numvfs, rc); - return rc; - } - - return numvfs; - } - - if (numvfs == 0) { - pci_disable_sriov(dev); - return 0; - } - - return -EINVAL; -} - -/*****************************************************************************/ -/*****************************************************************************/ /* ena_remove - Device Removal Routine * @pdev: PCI device information struct @@ -3525,7 +3499,7 @@ static int ena_resume(struct pci_dev *pdev) .suspend = ena_suspend, .resume = ena_resume, #endif - .sriov_configure = ena_sriov_configure, + .sriov_configure = pci_sriov_configure_simple, }; static int __init ena_init(void) From patchwork Tue Mar 13 21:30:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander H Duyck X-Patchwork-Id: 885499 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="om3WMrBi"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4017M25N4Pz9sTd for ; Wed, 14 Mar 2018 08:30:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932277AbeCMVaw (ORCPT ); Tue, 13 Mar 2018 17:30:52 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:37945 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752375AbeCMVat (ORCPT ); Tue, 13 Mar 2018 17:30:49 -0400 Received: by mail-pf0-f194.google.com with SMTP id d26so459616pfn.5; Tue, 13 Mar 2018 14:30:49 -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=6aY8TJ0PjareK4RpApZKr1aTROHxHKpmUdsDlDkMyUE=; b=om3WMrBiTFGa0yZmAdTbLX5kXM3CZ2GfRjacJGWGAUqX6JZF9+a/qJ0AXksY9Ynpjy KgHJlZZlRdARKvrb4TZreyB0X9jZQxRJkJlKISKH+dUe+epxrKCnwigJD0L/5q4sjWQM qt5WeldPq6BEjBKn/yTgvyqk/IY+xoU3xUlJyDkvXtM3mOUUHvL5A1b0p+lyywWFOKfu c3/9hdZBb2NN39CsZgeOsYB/Y7KlBM3AXxjPb7m8ax5rvHIWW6FT4mVjHEX6g36frXXt 1qF0crp3Yu2w8xMGP07WCpUdNXdyOn0bsFTB/A3cqPGZs6vRe76yh9YlRB3PgPOL25nb p9ow== 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=6aY8TJ0PjareK4RpApZKr1aTROHxHKpmUdsDlDkMyUE=; b=XweZMvin6IuCC8dSNyGKA6xF/NE1dzVrde6meYglfeLLgBuqtNbxPLOQSecs1ZF0jZ L84qmmjKz7AL/b15J7WKKJS9aw84npWpeMiO8njVhXtR/rvxVgoeNEbz6dC6A/yN9Kxz 8XnlLcuvj5A6rmHDWLKaoLnX0KAws6x1bP1pkKjz7SNZaXP26h2LAHvxhdveMsp3akA1 N5TX17NTqSAM7IsTjeW4vtTl83w+lZTDMRbM7oLOaxs/ruevv++vNBdU4i/l6/4Brs3y MFSsfEFIH0/Pde9J0hqWXvnytCDbYQ9u+ypLSybKazBep7LePoCKHJjitwuchMHro95Z 32jA== X-Gm-Message-State: AElRT7G9JkxZoKddiDp25Q/ELeZGqwlXGVVoBos4gYddQIimq4BMFNgW pgJ7K2sXstWBwS1Q4+4xd4M= X-Google-Smtp-Source: AG47ELty4MqFKjzdSRG5I0TQ7XLZR9vkJDVIpt1I8TR6HeGoAnWCtwpNN+fwnsQUHOkOt/6MKkxx+w== X-Received: by 10.99.132.72 with SMTP id k69mr1649092pgd.367.1520976649096; Tue, 13 Mar 2018 14:30:49 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id s9sm1707373pfm.39.2018.03.13.14.30.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 14:30:48 -0700 (PDT) Subject: [pci PATCH v6 4/5] nvme: Migrate over to unmanaged SR-IOV support 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: Tue, 13 Mar 2018 14:30:47 -0700 Message-ID: <20180313213034.3553.47677.stgit@localhost.localdomain> In-Reply-To: <20180313212508.3553.65326.stgit@localhost.localdomain> References: <20180313212508.3553.65326.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Alexander Duyck Instead of implementing our own version of a SR-IOV configuration stub in the nvme driver we can just reuse the existing pci_sriov_configure_simple function. Signed-off-by: Alexander Duyck Reviewed-by: Christoph Hellwig --- v5: Replaced call to pci_sriov_configure_unmanaged with pci_sriov_configure_simple v6: Dropped "#ifdef" checks for IOV wrapping sriov_configure definition drivers/nvme/host/pci.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 5933a5c732e8..5e963058882a 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2580,24 +2580,6 @@ static void nvme_remove(struct pci_dev *pdev) nvme_put_ctrl(&dev->ctrl); } -static int nvme_pci_sriov_configure(struct pci_dev *pdev, int numvfs) -{ - int ret = 0; - - if (numvfs == 0) { - if (pci_vfs_assigned(pdev)) { - dev_warn(&pdev->dev, - "Cannot disable SR-IOV VFs while assigned\n"); - return -EPERM; - } - pci_disable_sriov(pdev); - return 0; - } - - ret = pci_enable_sriov(pdev, numvfs); - return ret ? ret : numvfs; -} - #ifdef CONFIG_PM_SLEEP static int nvme_suspend(struct device *dev) { @@ -2716,7 +2698,7 @@ static void nvme_error_resume(struct pci_dev *pdev) .driver = { .pm = &nvme_dev_pm_ops, }, - .sriov_configure = nvme_pci_sriov_configure, + .sriov_configure = pci_sriov_configure_simple, .err_handler = &nvme_err_handler, }; From patchwork Tue Mar 13 21:31:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander H Duyck X-Patchwork-Id: 885501 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qiXTcJiw"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4017My5p52z9sTd for ; Wed, 14 Mar 2018 08:31:42 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932360AbeCMVbk (ORCPT ); Tue, 13 Mar 2018 17:31:40 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:40770 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752611AbeCMVbi (ORCPT ); Tue, 13 Mar 2018 17:31:38 -0400 Received: by mail-pf0-f195.google.com with SMTP id x1so458988pfh.7; Tue, 13 Mar 2018 14:31:37 -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=KJTtDSINu4jsN6HmZUMgUfjHcREro72wUCZkJlmnN+Y=; b=qiXTcJiwLNuTGiurPGilB9Z+bfUBGv1fq0T4xeJZE4qkyrkW3mFDQRiiG7jsihqOLq Mr2iWE9H6ihgJEEX5v3B6CPhczrH1NZzpHjAkNEmp6vvG0aAo342XjPo4jUo/Z/mstl1 1qe8ev69YU4kT4M054T4Ev0itATuxS2Dolp5OqCIR9oHBGvodb/Yl0ImHWPWyL5AVw49 pxnLUZMmpgVCdylLMcNUAvQYfOmkAIQIP5tZ7NPMGa2ccKS65B/uWVH01LA1aRErClWA sqSV+iJvZARAM36CJZJEWhmwaAND1XltH2SHWd5KkzEIf8fqgneLx/ReOmH3J7AHpHHv U/Gw== 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=KJTtDSINu4jsN6HmZUMgUfjHcREro72wUCZkJlmnN+Y=; b=W53PlzC6MnsYcKKBc3OvRmk8QIbSWc81N5LYOcFNQ1+mxGe+jsYJtMIf45sH4zLJca kLh94VGgJVLGNDRa2VBNvV8d4d40I7iPfZDQ6EdzX2OgqNr3BOFwXhqg/2eKk+2G/6Gq 8YfwwVBYn6iolZtoq3b4mAcrVz/UcsgMLUT4cS0Xay7gZ8vgNarpEb1xTdWKO0j5ECqu hwMY4EN9X+OPi7Ew9Bq+PTjl5NvOkcPZVYblE1ASX6mRvKupQgvM2LbZOMgwkEIaJJPY PxRVs/ak4lH4ZmoGn+Fthb4BzzvmKbf3xJ1eAcOohDoC7xk9NHAZlBt+dWi69MNNa8mh BdQg== X-Gm-Message-State: AElRT7GURUCHjDOqczTwaqNWHhPofiOJ1KzzKJgjwMy3yjVdkydoBK7+ o1o/pmGP22hClHOymMzk5+Q= X-Google-Smtp-Source: AG47ELutyEeMboV1eWAkpxBsyGFzYX3YO/omZLuI8PaqjQ3rUzAQYSGSAySoEdVSqhQo2m3Y8G7mzA== X-Received: by 10.101.89.65 with SMTP id g1mr1648092pgu.185.1520976697529; Tue, 13 Mar 2018 14:31:37 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id x5sm617022pgq.84.2018.03.13.14.31.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 14:31:36 -0700 (PDT) Subject: [pci PATCH v6 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: Tue, 13 Mar 2018 14:31:36 -0700 Message-ID: <20180313213054.3553.89366.stgit@localhost.localdomain> In-Reply-To: <20180313212508.3553.65326.stgit@localhost.localdomain> References: <20180313212508.3553.65326.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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 Reviewed-by: Christoph Hellwig --- v6: New driver to address concerns about Amazon devices left unsupported drivers/pci/Kconfig | 12 +++++++++ drivers/pci/Makefile | 2 ++ drivers/pci/pci-pf-stub.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 2 ++ 4 files changed, 76 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..d218924d9bdb --- /dev/null +++ b/drivers/pci/pci-pf-stub.c @@ -0,0 +1,60 @@ +// 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. + * + * Layout of the table below is as follows: + * { Vendor ID, Device ID, + * SubVendor ID, SubDevice ID, + * Class, Class Mask, + * private data (not used) } + */ +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