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 80543A2E1B for ; Wed, 4 Sep 2019 14:06:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E90CD1EDB7; Wed, 4 Sep 2019 14:05:43 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id AB1C31ED8A for ; Wed, 4 Sep 2019 14:05:41 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 05:05:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,465,1559545200"; d="scan'208";a="187607530" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga006.jf.intel.com with ESMTP; 04 Sep 2019 05:05:38 -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 x84C5buN023732; Wed, 4 Sep 2019 13:05:37 +0100 Received: from wgcvswdev001.ir.intel.com (localhost [127.0.0.1]) by wgcvswdev001.ir.intel.com with ESMTP id x84C51lL002425; Wed, 4 Sep 2019 13:05:01 +0100 Received: (from tchaitax@localhost) by wgcvswdev001.ir.intel.com with œ id x84C51Uk002421; Wed, 4 Sep 2019 13:05:01 +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: Wed, 4 Sep 2019 13:04:41 +0100 Message-Id: <1567598682-2225-4-git-send-email-tallurix.chaitanya.babu@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1566907031-2105-1-git-send-email-tallurix.chaitanya.babu@intel.com> References: <1566907031-2105-1-git-send-email-tallurix.chaitanya.babu@intel.com> Subject: [dpdk-dev] [PATCH v4 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 | 11 +++++++++++ lib/librte_eal/linux/eal/eal_vfio.c | 16 ++++++++++++++++ lib/librte_eal/rte_eal_version.map | 3 +++ 3 files changed, 30 insertions(+) diff --git a/lib/librte_eal/common/include/rte_vfio.h b/lib/librte_eal/common/include/rte_vfio.h index b360485fa..e3f80f772 100644 --- a/lib/librte_eal/common/include/rte_vfio.h +++ b/lib/librte_eal/common/include/rte_vfio.h @@ -397,6 +397,17 @@ 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 + */ +__rte_experimental +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 */ diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 7cbf82d37..5b1ba6fbd 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -419,4 +419,7 @@ EXPERIMENTAL { rte_mcfg_timer_lock; rte_mcfg_timer_unlock; rte_rand_max; + + # added in 19.11 + rte_vfio_iommu_type_is_set; }; -- 2.17.2