diff mbox series

[v1,2/2] vfio: add errno on unsupported platforms

Message ID 67c4e47e511558e2442c73c57c1764df656720e3.1631788595.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers show
Series [v1,1/2] vfio: make API return values consistent | expand

Checks

Context Check Description
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/intel-Testing fail Testing issues
ci/Intel-compilation success Compilation OK
ci/iol-x86_64-unit-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/checkpatch success coding style OK

Commit Message

Burakov, Anatoly Sept. 16, 2021, 10:36 a.m. UTC
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 <anatoly.burakov@intel.com>
---
 lib/eal/freebsd/eal.c    | 12 ++++++++++++
 lib/eal/linux/eal_vfio.c | 12 ++++++++++++
 2 files changed, 24 insertions(+)

Comments

Bruce Richardson Sept. 16, 2021, 10:39 a.m. UTC | #1
On Thu, Sep 16, 2021 at 10:36:38AM +0000, Anatoly Burakov wrote:
> 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 <anatoly.burakov@intel.com>
> ---
>  lib/eal/freebsd/eal.c    | 12 ++++++++++++
>  lib/eal/linux/eal_vfio.c | 12 ++++++++++++
>  2 files changed, 24 insertions(+)
>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Xia, Chenbo Sept. 22, 2021, 3:31 a.m. UTC | #2
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Anatoly Burakov
> Sent: Thursday, September 16, 2021 6:37 PM
> To: dev@dpdk.org; Richardson, Bruce <bruce.richardson@intel.com>
> Subject: [dpdk-dev] [PATCH v1 2/2] vfio: add errno on unsupported platforms
> 
> 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

Should be 'implementation'

With this fixed:

Acked-by: Chenbo Xia <chenbo.xia@intel.com>

> set the rte_errno flag.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>  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;
>  }
> 
> --
> 2.25.1
diff mbox series

Patch

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;
 }