From patchwork Mon Oct 17 21:22:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirti Wankhede X-Patchwork-Id: 683422 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3syWWb4g6Yz9sD6 for ; Tue, 18 Oct 2016 08:27:39 +1100 (AEDT) Received: from localhost ([::1]:36091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwFRY-0003v0-4R for incoming@patchwork.ozlabs.org; Mon, 17 Oct 2016 17:27:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwFLw-0007be-EU for qemu-devel@nongnu.org; Mon, 17 Oct 2016 17:21:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwFLs-0004Mk-5b for qemu-devel@nongnu.org; Mon, 17 Oct 2016 17:21:48 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:1966) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bwFLs-0004Lc-0y for qemu-devel@nongnu.org; Mon, 17 Oct 2016 17:21:44 -0400 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com id ; Mon, 17 Oct 2016 14:18:50 -0700 Received: from HQMAIL107.nvidia.com ([172.20.13.39]) by hqnvupgp07.nvidia.com (PGP Universal service); Mon, 17 Oct 2016 14:14:39 -0700 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Mon, 17 Oct 2016 14:14:39 -0700 Received: from HQMAIL102.nvidia.com (172.18.146.10) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 17 Oct 2016 21:21:42 +0000 Received: from HQMAIL103.nvidia.com (172.20.187.11) by HQMAIL102.nvidia.com (172.18.146.10) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 17 Oct 2016 21:21:42 +0000 Received: from kwankhede-dev.nvidia.com (172.20.13.39) by HQMAIL103.nvidia.com (172.20.187.11) with Microsoft SMTP Server (TLS) id 15.0.1210.3 via Frontend Transport; Mon, 17 Oct 2016 21:21:38 +0000 From: Kirti Wankhede To: , , , Date: Tue, 18 Oct 2016 02:52:10 +0530 Message-ID: <1476739332-4911-11-git-send-email-kwankhede@nvidia.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1476739332-4911-1-git-send-email-kwankhede@nvidia.com> References: <1476739332-4911-1-git-send-email-kwankhede@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 216.228.121.65 Subject: [Qemu-devel] [PATCH v9 10/12] vfio: Add function to get device_api string from vfio_device_info.flags X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jike.song@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, kevin.tian@intel.com, qemu-devel@nongnu.org, Kirti Wankhede , bjsdjshi@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Function vfio_device_api_string() returns string based on flag set in vfio_device_info's flag. This should be used by vendor driver to get string based on flag for device_api attribute. Signed-off-by: Kirti Wankhede Signed-off-by: Neo Jia Change-Id: I42d29f475f02a7132ce13297fbf2b48f1da10995 --- drivers/vfio/vfio.c | 15 +++++++++++++++ include/linux/vfio.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 10ef1c5fa762..aec470454a13 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -1917,6 +1917,21 @@ int vfio_set_irqs_validate_and_prepare(struct vfio_irq_set *hdr, int num_irqs, } EXPORT_SYMBOL(vfio_set_irqs_validate_and_prepare); +const char *vfio_device_api_string(u32 flags) +{ + if (flags & VFIO_DEVICE_FLAGS_PCI) + return "vfio-pci"; + + if (flags & VFIO_DEVICE_FLAGS_PLATFORM) + return "vfio-platform"; + + if (flags & VFIO_DEVICE_FLAGS_AMBA) + return "vfio-amba"; + + return ""; +} +EXPORT_SYMBOL(vfio_device_api_string); + /* * Pin a set of guest PFNs and return their associated host PFNs for local * domain only. diff --git a/include/linux/vfio.h b/include/linux/vfio.h index 31d059f1649b..fca2bf23c4f1 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -116,6 +116,8 @@ extern int vfio_set_irqs_validate_and_prepare(struct vfio_irq_set *hdr, int num_irqs, int max_irq_type, size_t *data_size); +extern const char *vfio_device_api_string(u32 flags); + struct pci_dev; #ifdef CONFIG_EEH extern void vfio_spapr_pci_eeh_open(struct pci_dev *pdev);