From patchwork Thu Oct 28 14:15:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 103170 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E5226A0547; Thu, 28 Oct 2021 16:15:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AC12B41140; Thu, 28 Oct 2021 16:15:23 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 05EB44111A for ; Thu, 28 Oct 2021 16:15:21 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10151"; a="253986055" X-IronPort-AV: E=Sophos;i="5.87,190,1631602800"; d="scan'208";a="253986055" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2021 07:15:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,190,1631602800"; d="scan'208";a="498417150" Received: from silpixa00401191.ir.intel.com ([10.55.128.95]) by orsmga008.jf.intel.com with ESMTP; 28 Oct 2021 07:15:20 -0700 From: Anatoly Burakov To: dev@dpdk.org Date: Thu, 28 Oct 2021 14:15:16 +0000 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 1/4] vfio: drop fallback Linux implementation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Currently, VFIO support for Linux is compiled unconditionally, and supported kernel versions start with 4.4, so VFIO is assumed to always be enabled. There is no way of disabling VFIO support at compile time anyway, so just drop the "VFIO not available" fallback code altogether. Signed-off-by: Anatoly Burakov Acked-by: Chenbo Xia --- lib/eal/linux/eal_vfio.c | 110 --------------------------------------- 1 file changed, 110 deletions(-) diff --git a/lib/eal/linux/eal_vfio.c b/lib/eal/linux/eal_vfio.c index aa2087a2da..549b86ae1d 100644 --- a/lib/eal/linux/eal_vfio.c +++ b/lib/eal/linux/eal_vfio.c @@ -20,8 +20,6 @@ #include "eal_private.h" #include "eal_internal_cfg.h" -#ifdef VFIO_PRESENT - #define VFIO_MEM_EVENT_CLB_NAME "vfio_mem_event_clb" /* hot plug/unplug of VFIO groups may cause all DMA maps to be dropped. we can @@ -2201,111 +2199,3 @@ rte_vfio_container_dma_unmap(int container_fd, uint64_t vaddr, uint64_t iova, return container_dma_unmap(vfio_cfg, vaddr, iova, len); } - -#else - -int -rte_vfio_setup_device(__rte_unused const char *sysfs_base, - __rte_unused const char *dev_addr, - __rte_unused int *vfio_dev_fd, - __rte_unused struct vfio_device_info *device_info) -{ - return -1; -} - -int -rte_vfio_release_device(__rte_unused const char *sysfs_base, - __rte_unused const char *dev_addr, __rte_unused int fd) -{ - return -1; -} - -int -rte_vfio_enable(__rte_unused const char *modname) -{ - return -1; -} - -int -rte_vfio_is_enabled(__rte_unused const char *modname) -{ - return -1; -} - -int -rte_vfio_noiommu_is_enabled(void) -{ - return -1; -} - -int -rte_vfio_clear_group(__rte_unused int vfio_group_fd) -{ - return -1; -} - -int -rte_vfio_get_group_num(__rte_unused const char *sysfs_base, - __rte_unused const char *dev_addr, - __rte_unused int *iommu_group_num) -{ - return -1; -} - -int -rte_vfio_get_container_fd(void) -{ - return -1; -} - -int -rte_vfio_get_group_fd(__rte_unused int iommu_group_num) -{ - return -1; -} - -int -rte_vfio_container_create(void) -{ - return -1; -} - -int -rte_vfio_container_destroy(__rte_unused int container_fd) -{ - return -1; -} - -int -rte_vfio_container_group_bind(__rte_unused int container_fd, - __rte_unused int iommu_group_num) -{ - return -1; -} - -int -rte_vfio_container_group_unbind(__rte_unused int container_fd, - __rte_unused int iommu_group_num) -{ - return -1; -} - -int -rte_vfio_container_dma_map(__rte_unused int container_fd, - __rte_unused uint64_t vaddr, - __rte_unused uint64_t iova, - __rte_unused uint64_t len) -{ - return -1; -} - -int -rte_vfio_container_dma_unmap(__rte_unused int container_fd, - __rte_unused uint64_t vaddr, - __rte_unused uint64_t iova, - __rte_unused uint64_t len) -{ - return -1; -} - -#endif /* VFIO_PRESENT */ From patchwork Thu Oct 28 14:15:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 103171 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0B1E0A0547; Thu, 28 Oct 2021 16:15:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 984C9426D2; Thu, 28 Oct 2021 16:15:26 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id E7F434111A; Thu, 28 Oct 2021 16:15:22 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10151"; a="253986064" X-IronPort-AV: E=Sophos;i="5.87,190,1631602800"; d="scan'208";a="253986064" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2021 07:15:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,190,1631602800"; d="scan'208";a="498417182" Received: from silpixa00401191.ir.intel.com ([10.55.128.95]) by orsmga008.jf.intel.com with ESMTP; 28 Oct 2021 07:15:21 -0700 From: Anatoly Burakov To: dev@dpdk.org, Bruce Richardson Cc: stable@dpdk.org Date: Thu, 28 Oct 2021 14:15:17 +0000 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 2/4] vfio: fix wrong return value for FreeBSD X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" On FreeBSD, `rte_vfio_clear_group()` was returning 0 even though this function is not valid for FreeBSD, and is called out to return error in doxygen comments. Fix the return value to match documentation. Cc: stable@dpdk.org Signed-off-by: Anatoly Burakov --- lib/eal/freebsd/eal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 9935356ed4..dada210b19 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -1032,7 +1032,7 @@ int rte_vfio_noiommu_is_enabled(void) int rte_vfio_clear_group(__rte_unused int vfio_group_fd) { - return 0; + return -1; } int From patchwork Thu Oct 28 14:15:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 103172 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AB333A0547; Thu, 28 Oct 2021 16:15:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 96434426DE; Thu, 28 Oct 2021 16:15:27 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id E496141C27; Thu, 28 Oct 2021 16:15:23 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10151"; a="253986068" X-IronPort-AV: E=Sophos;i="5.87,190,1631602800"; d="scan'208";a="253986068" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2021 07:15:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,190,1631602800"; d="scan'208";a="498417184" Received: from silpixa00401191.ir.intel.com ([10.55.128.95]) by orsmga008.jf.intel.com with ESMTP; 28 Oct 2021 07:15:22 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: stable@dpdk.org Date: Thu, 28 Oct 2021 14:15:18 +0000 Message-Id: <9802c552ddd70f0d9b751ea567804bcaf0b7f0bd.1635430513.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 3/4] vfio: fix documentation to match intended behavior X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" On FreeBSD, `rte_vfio_is_enabled()` and `rte_vfio_noiommu_is_enabled()` API calls will not return error, and will instead return 0. This is intentional, because the caller of this API does not care whether VFIO is supported at all, and will instead be interested in whether VFIO is enabled or not. However, the doxygen comments for these functions state that they will return an error on FreeBSD, which is incorrect. Fix the doxygen comment to call out the fact that these functions are only relevant on Linux, but remove the reference to returning errors. Cc: stable@dpdk.org Signed-off-by: Anatoly Burakov Acked-by: Chenbo Xia --- lib/eal/include/rte_vfio.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/eal/include/rte_vfio.h b/lib/eal/include/rte_vfio.h index 2d90b36480..7bdb8932b2 100644 --- a/lib/eal/include/rte_vfio.h +++ b/lib/eal/include/rte_vfio.h @@ -150,8 +150,7 @@ int rte_vfio_enable(const char *modname); /** * Check whether a VFIO-related kmod is enabled. * - * This function is only relevant to linux and will return - * an error on BSD. + * This function is only relevant to Linux. * * @param modname * kernel module name. @@ -165,8 +164,7 @@ int rte_vfio_is_enabled(const char *modname); /** * Whether VFIO NOIOMMU mode is enabled. * - * This function is only relevant to linux and will return - * an error on BSD. + * This function is only relevant to Linux. * * @return * 1 if true. From patchwork Thu Oct 28 14:15:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 103173 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 07A0BA0547; Thu, 28 Oct 2021 16:15:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A5A1C426DC; Thu, 28 Oct 2021 16:15:30 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 8990741C27; Thu, 28 Oct 2021 16:15:26 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10151"; a="253986082" X-IronPort-AV: E=Sophos;i="5.87,190,1631602800"; d="scan'208";a="253986082" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2021 07:15:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,190,1631602800"; d="scan'208";a="498417219" Received: from silpixa00401191.ir.intel.com ([10.55.128.95]) by orsmga008.jf.intel.com with ESMTP; 28 Oct 2021 07:15:23 -0700 From: Anatoly Burakov To: dev@dpdk.org, Bruce Richardson , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Cc: stable@dpdk.org, Chenbo Xia Date: Thu, 28 Oct 2021 14:15:19 +0000 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 4/4] vfio: add errno on unsupported platforms X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Currently, when code is running on FreeBSD or Windows,, there is no way to distinguish between a geniune error and a "VFIO is unsupported" error. Fix the dummy implementations to also set the rte_errno flag. Cc: stable@dpdk.org Signed-off-by: Anatoly Burakov Acked-by: Chenbo Xia Acked-by: Bruce Richardson --- lib/eal/freebsd/eal.c | 13 +++++++++++++ lib/eal/windows/eal.c | 2 ++ 2 files changed, 15 insertions(+) diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index dada210b19..fce13accc8 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -1005,6 +1005,7 @@ int rte_vfio_setup_device(__rte_unused const char *sysfs_base, __rte_unused int *vfio_dev_fd, __rte_unused struct vfio_device_info *device_info) { + rte_errno = ENOTSUP; return -1; } @@ -1012,11 +1013,13 @@ int rte_vfio_release_device(__rte_unused const char *sysfs_base, __rte_unused const char *dev_addr, __rte_unused int fd) { + rte_errno = ENOTSUP; return -1; } int rte_vfio_enable(__rte_unused const char *modname) { + rte_errno = ENOTSUP; return -1; } @@ -1032,6 +1035,7 @@ int rte_vfio_noiommu_is_enabled(void) int rte_vfio_clear_group(__rte_unused int vfio_group_fd) { + rte_errno = ENOTSUP; return -1; } @@ -1040,30 +1044,35 @@ rte_vfio_get_group_num(__rte_unused const char *sysfs_base, __rte_unused const char *dev_addr, __rte_unused int *iommu_group_num) { + rte_errno = ENOTSUP; return -1; } int rte_vfio_get_container_fd(void) { + rte_errno = ENOTSUP; return -1; } int rte_vfio_get_group_fd(__rte_unused int iommu_group_num) { + rte_errno = ENOTSUP; return -1; } int rte_vfio_container_create(void) { + rte_errno = ENOTSUP; return -1; } int rte_vfio_container_destroy(__rte_unused int container_fd) { + rte_errno = ENOTSUP; return -1; } @@ -1071,6 +1080,7 @@ int rte_vfio_container_group_bind(__rte_unused int container_fd, __rte_unused int iommu_group_num) { + rte_errno = ENOTSUP; return -1; } @@ -1078,6 +1088,7 @@ int rte_vfio_container_group_unbind(__rte_unused int container_fd, __rte_unused int iommu_group_num) { + rte_errno = ENOTSUP; return -1; } @@ -1087,6 +1098,7 @@ rte_vfio_container_dma_map(__rte_unused int container_fd, __rte_unused uint64_t iova, __rte_unused uint64_t len) { + rte_errno = ENOTSUP; return -1; } @@ -1096,5 +1108,6 @@ rte_vfio_container_dma_unmap(__rte_unused int container_fd, __rte_unused uint64_t iova, __rte_unused uint64_t len) { + rte_errno = ENOTSUP; return -1; } diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c index f7ce1b6671..67db7f099a 100644 --- a/lib/eal/windows/eal.c +++ b/lib/eal/windows/eal.c @@ -481,6 +481,7 @@ rte_vfio_container_dma_map(__rte_unused int container_fd, __rte_unused uint64_t iova, __rte_unused uint64_t len) { + rte_errno = ENOTSUP; return -1; } @@ -490,6 +491,7 @@ rte_vfio_container_dma_unmap(__rte_unused int container_fd, __rte_unused uint64_t iova, __rte_unused uint64_t len) { + rte_errno = ENOTSUP; return -1; }