From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 88E4BA0613 for ; Tue, 27 Aug 2019 13:58:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CC5B21C118; Tue, 27 Aug 2019 13:58:25 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 0AEB31C0B2 for ; Tue, 27 Aug 2019 13:58:20 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Aug 2019 04:58:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,437,1559545200"; d="scan'208";a="355751180" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga005.jf.intel.com with ESMTP; 27 Aug 2019 04:58:18 -0700 Received: from wgcvswdev001.ir.intel.com (wgcvswdev001.ir.intel.com [10.102.246.100]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id x7RBwHvV021193; Tue, 27 Aug 2019 12:58:17 +0100 Received: from wgcvswdev001.ir.intel.com (localhost [127.0.0.1]) by wgcvswdev001.ir.intel.com with ESMTP id x7RBvgmw002290; Tue, 27 Aug 2019 12:57:42 +0100 Received: (from tchaitax@localhost) by wgcvswdev001.ir.intel.com with œ id x7RBvgjt002286; Tue, 27 Aug 2019 12:57:42 +0100 From: Chaitanya Babu Talluri To: dev@dpdk.org Cc: reshma.pattan@intel.com, jananeex.m.parthasarathy@intel.com, anatoly.burakov@intel.com, Chaitanya Babu Talluri Date: Tue, 27 Aug 2019 12:57:10 +0100 Message-Id: <1566907031-2105-4-git-send-email-tallurix.chaitanya.babu@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1566474836-30480-1-git-send-email-tallurix.chaitanya.babu@intel.com> References: <1566474836-30480-1-git-send-email-tallurix.chaitanya.babu@intel.com> Subject: [dpdk-dev] [PATCH v3 3/4] lib/eal: add API to check iommu type is set X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add rte_vfio_iommu_type_is_set() to check IOMMU type for default container. Signed-off-by: Chaitanya Babu Talluri --- lib/librte_eal/common/include/rte_vfio.h | 10 ++++++++++ lib/librte_eal/linux/eal/eal_vfio.c | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/librte_eal/common/include/rte_vfio.h b/lib/librte_eal/common/include/rte_vfio.h index b360485fa..a62006e5a 100644 --- a/lib/librte_eal/common/include/rte_vfio.h +++ b/lib/librte_eal/common/include/rte_vfio.h @@ -397,6 +397,16 @@ int rte_vfio_container_dma_unmap(int container_fd, uint64_t vaddr, uint64_t iova, uint64_t len); +/** + * Check VFIO IOMMU Type is set for default container. + * + * @return + * 0 if successful + * <0 if failed + */ +int +rte_vfio_iommu_type_is_set(void); + #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c index 04c284cb2..a5bb1cff4 100644 --- a/lib/librte_eal/linux/eal/eal_vfio.c +++ b/lib/librte_eal/linux/eal/eal_vfio.c @@ -2071,6 +2071,17 @@ rte_vfio_container_dma_unmap(int container_fd, uint64_t vaddr, uint64_t iova, return container_dma_unmap(vfio_cfg, vaddr, iova, len); } +int +rte_vfio_iommu_type_is_set(void) +{ + if (vfio_get_iommu_type() < 0) { + RTE_LOG(ERR, EAL, "VFIO IOMMU Type is not set\n"); + return -1; + } + + return 0; +} + #else int @@ -2191,4 +2202,9 @@ rte_vfio_container_dma_unmap(__rte_unused int container_fd, return -1; } +int +rte_vfio_iommu_type_is_set(void) +{ + return -1; +} #endif /* VFIO_PRESENT */ -- 2.17.2