From patchwork Thu Sep 16 10:36:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Burakov, Anatoly" X-Patchwork-Id: 99022 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 CA2A1A0C41; Thu, 16 Sep 2021 12:36:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AFD304069E; Thu, 16 Sep 2021 12:36:42 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 51C744003F for ; Thu, 16 Sep 2021 12:36:41 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10108"; a="209764354" X-IronPort-AV: E=Sophos;i="5.85,298,1624345200"; d="scan'208";a="209764354" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2021 03:36:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,298,1624345200"; d="scan'208";a="509258147" Received: from silpixa00401191.ir.intel.com ([10.55.128.95]) by fmsmga008.fm.intel.com with ESMTP; 16 Sep 2021 03:36:39 -0700 From: Anatoly Burakov To: dev@dpdk.org Date: Thu, 16 Sep 2021 10:36:37 +0000 Message-Id: <25dd76eca01ec57d64be9c0a78ac2752f602984f.1631788595.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 1/2] vfio: make API return values consistent 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 VFIO support is not compiled, FreeBSD and Linux have different return values. Fix Linux implementation to follow FreeBSD one. Signed-off-by: Anatoly Burakov --- Notes: Current minimum support Linux kernel is 4.4, and Meson build file sets the RTE_EAL_VFIO config option to `true` simply because we are compiling for Linux. So, it looks like VFIO support is pretty much assumed on Linux, so i think we can safely drop the fallback dummy implementation from Linux altogether? lib/eal/linux/eal_vfio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/eal/linux/eal_vfio.c b/lib/eal/linux/eal_vfio.c index 25add2fa5d..b9e4d3ad3c 100644 --- a/lib/eal/linux/eal_vfio.c +++ b/lib/eal/linux/eal_vfio.c @@ -2111,19 +2111,19 @@ rte_vfio_enable(__rte_unused const char *modname) int rte_vfio_is_enabled(__rte_unused const char *modname) { - return -1; + return 0; } int rte_vfio_noiommu_is_enabled(void) { - return -1; + return 0; } int rte_vfio_clear_group(__rte_unused int vfio_group_fd) { - return -1; + return 0; } int From patchwork Thu Sep 16 10:36:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Burakov, Anatoly" X-Patchwork-Id: 99023 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 AF130A0C41; Thu, 16 Sep 2021 12:36:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BB130410F0; Thu, 16 Sep 2021 12:36:43 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id EC1414003F for ; Thu, 16 Sep 2021 12:36:41 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10108"; a="209764356" X-IronPort-AV: E=Sophos;i="5.85,298,1624345200"; d="scan'208";a="209764356" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2021 03:36:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,298,1624345200"; d="scan'208";a="509258160" Received: from silpixa00401191.ir.intel.com ([10.55.128.95]) by fmsmga008.fm.intel.com with ESMTP; 16 Sep 2021 03:36:40 -0700 From: Anatoly Burakov To: dev@dpdk.org, Bruce Richardson Date: Thu, 16 Sep 2021 10:36:38 +0000 Message-Id: <67c4e47e511558e2442c73c57c1764df656720e3.1631788595.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <25dd76eca01ec57d64be9c0a78ac2752f602984f.1631788595.git.anatoly.burakov@intel.com> References: <25dd76eca01ec57d64be9c0a78ac2752f602984f.1631788595.git.anatoly.burakov@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 2/2] 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 using fallback Linux implementation), there is no way to distinguish between a geniune error and a "VFIO is unsupported" error. Fix the dummy implemnetations to also set the rte_errno flag. Signed-off-by: Anatoly Burakov Acked-by: Bruce Richardson Acked-by: Chenbo Xia --- lib/eal/freebsd/eal.c | 12 ++++++++++++ lib/eal/linux/eal_vfio.c | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 6cee5ae369..6d249edb11 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -1000,6 +1000,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; } @@ -1007,11 +1008,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; } @@ -1035,30 +1038,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; } @@ -1066,6 +1074,7 @@ int rte_vfio_container_group_bind(__rte_unused int container_fd, __rte_unused int iommu_group_num) { + rte_errno = ENOTSUP; return -1; } @@ -1073,6 +1082,7 @@ int rte_vfio_container_group_unbind(__rte_unused int container_fd, __rte_unused int iommu_group_num) { + rte_errno = ENOTSUP; return -1; } @@ -1082,6 +1092,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; } @@ -1091,5 +1102,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/linux/eal_vfio.c b/lib/eal/linux/eal_vfio.c index b9e4d3ad3c..bb4c225aed 100644 --- a/lib/eal/linux/eal_vfio.c +++ b/lib/eal/linux/eal_vfio.c @@ -2092,6 +2092,7 @@ 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; } @@ -2099,12 +2100,14 @@ 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; } @@ -2131,30 +2134,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; } @@ -2162,6 +2170,7 @@ int rte_vfio_container_group_bind(__rte_unused int container_fd, __rte_unused int iommu_group_num) { + rte_errno = ENOTSUP; return -1; } @@ -2169,6 +2178,7 @@ int rte_vfio_container_group_unbind(__rte_unused int container_fd, __rte_unused int iommu_group_num) { + rte_errno = ENOTSUP; return -1; } @@ -2178,6 +2188,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; } @@ -2187,6 +2198,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; }