From patchwork Thu Mar 8 19:03:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 10268693 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 958B66037E for ; Thu, 8 Mar 2018 19:03:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85A7E29A97 for ; Thu, 8 Mar 2018 19:03:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A77B29A99; Thu, 8 Mar 2018 19:03:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F190C29A97 for ; Thu, 8 Mar 2018 19:03:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752286AbeCHTDr (ORCPT ); Thu, 8 Mar 2018 14:03:47 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:35877 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752173AbeCHTDp (ORCPT ); Thu, 8 Mar 2018 14:03:45 -0500 Received: by mail-io0-f195.google.com with SMTP id e30so826059ioc.3; Thu, 08 Mar 2018 11:03:45 -0800 (PST) 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=CC5/HV0EqkzB2CEaccts+xR1ya6yic025BGjMOIxsLA=; b=OOe5W9jtqe/MceiQwVdFyvSBIKkuFIrG8ufIcAnPqqrgrGV24XggWx6j3FyfQYPyKR d73bmaN0dAqOwJe2sIp9l1fOp6UkXMSOwufJzsrvNfAGl1x0jk84E4LtSAiLz5M9VnBJ v9xnS06zYD2zNrGx2GC+48BfRA8qdQqv5hYGE092/EaofDZ94MjkXanbbz2UfOhnNSBN 43Flat4IhXlzAH90VusQYMM9h2PppnEz0g+5WiherIRIoKOuJL2wU4M+EK7NKet3P8Sq xM6s4zFs38E7LFtMB71XOgzmK2ewOWr1WjlJ5XqF3ADTogWn06omptU8yDQwPZJSDWGs UqbA== 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=CC5/HV0EqkzB2CEaccts+xR1ya6yic025BGjMOIxsLA=; b=N4MVqc2Ea+5ejJPgjz0tVutPPLE7bwB4CH+0sAZ67xYbizPfC4uqfJTkvACI4Nb97f Ip0fB922OAQQ9GDd/rbj5U4FBbX0dAv74WOej15gmc5v5bjm00suW4Utyea4rYfSESN6 l0FWEvxYsoyslWXKh5+fo20NSlnV4y3WqVaR7LIdeN7cJZ2yFDLXQ8SDYOq5DCpNgfxT O4LK868fiqhnF64sAXJGzGImO68ZjtZU1T86qjLhH+GkDEHmTZtH5xc58YUSl2sbZVH7 57Pe3du1GnwupUo5kJmlFNdfywgV0FcCqqd/VoXpG3lbfFfPN/K8XbWf5Bf3BbodPH/M ZU8A== X-Gm-Message-State: APf1xPAHW94ExKTZ3uJwEjFu26glEPLnFGn7EMHTuowGLQRk3j9XUXjE sQi2I1M2rMz6rhL4mzXvN8bc9B4GjTY= X-Google-Smtp-Source: AG47ELti3Q5L4QrF/W9SRih+G8DBvHJC36dkyWwGn14JVDNlsEPYC5c1iCjkjRlYLx5dDvd5GIptHw== X-Received: by 10.107.70.14 with SMTP id t14mr31442976ioa.281.1520535824480; Thu, 08 Mar 2018 11:03:44 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id p194sm11419324itp.34.2018.03.08.11.03.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Mar 2018 11:03:43 -0800 (PST) Subject: [pci PATCH v4 2/4] 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, 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, 08 Mar 2018 11:03:42 -0800 Message-ID: <20180308190236.5433.64788.stgit@localhost.localdomain> In-Reply-To: <20180308185507.5433.98830.stgit@localhost.localdomain> References: <20180308185507.5433.98830.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 X-Virus-Scanned: ClamAV using ClamSMTP 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 --- v4: Dropped call to pci_disable_sriov in virtio_pci_remove function drivers/virtio/virtio_pci_common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c index 48d4d1cf1cb6..27ab090163b4 100644 --- a/drivers/virtio/virtio_pci_common.c +++ b/drivers/virtio/virtio_pci_common.c @@ -596,6 +596,9 @@ static void virtio_pci_remove(struct pci_dev *pci_dev) #ifdef CONFIG_PM_SLEEP .driver.pm = &virtio_pci_pm_ops, #endif +#ifdef CONFIG_PCI_IOV + .sriov_configure = pci_sriov_configure_unmanaged, +#endif }; module_pci_driver(virtio_pci_driver);