* [dpdk-dev] [PATCH] eal/vfio: export all VFIO functions when not compiling VFIO
@ 2018-04-16 10:59 Anatoly Burakov
2018-04-16 11:55 ` Thomas Monjalon
2018-04-16 12:13 ` [dpdk-dev] [PATCH v2] " Anatoly Burakov
0 siblings, 2 replies; 5+ messages in thread
From: Anatoly Burakov @ 2018-04-16 10:59 UTC (permalink / raw)
To: dev
Cc: Bruce Richardson, thomas, shahafs, hemant.agrawal, gaetan.rivet,
anatoly.burakov
Previously, VFIO functions were not compiled in and exported if
VFIO compilation was disabled. Fix this by actually compiling
all of the functions unconditionally, , and provide missing
prototypes on Linux.
Fixes: 279b581c897d ("vfio: expose functions")
Fixes: 73a639085938 ("vfio: allow to map other memory regions")
Fixes: 964b2f3bfb07 ("vfio: export some internal functions")
Cc: hemant.agrawal@nxp.com
Cc: gaetan.rivet@6wind.com
Cc: anatoly.burakov@intel.com
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
lib/librte_eal/bsdapp/eal/eal.c | 15 +-------
lib/librte_eal/common/include/rte_vfio.h | 17 +++++----
lib/librte_eal/linuxapp/eal/eal_vfio.c | 60 ++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 20 deletions(-)
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index bfbec0d..d996190 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -40,6 +40,7 @@
#include <rte_dev.h>
#include <rte_devargs.h>
#include <rte_version.h>
+#include <rte_vfio.h>
#include <rte_atomic.h>
#include <malloc_heap.h>
@@ -756,20 +757,6 @@ rte_eal_vfio_intr_mode(void)
return RTE_INTR_MODE_NONE;
}
-/* dummy forward declaration. */
-struct vfio_device_info;
-
-/* dummy prototypes. */
-int rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
- int *vfio_dev_fd, struct vfio_device_info *device_info);
-int rte_vfio_release_device(const char *sysfs_base, const char *dev_addr, int fd);
-int rte_vfio_enable(const char *modname);
-int rte_vfio_is_enabled(const char *modname);
-int rte_vfio_noiommu_is_enabled(void);
-int rte_vfio_clear_group(int vfio_group_fd);
-int rte_vfio_dma_map(uint64_t vaddr, uint64_t iova, uint64_t len);
-int rte_vfio_dma_unmap(uint64_t vaddr, uint64_t iova, uint64_t len);
-
int rte_vfio_setup_device(__rte_unused const char *sysfs_base,
__rte_unused const char *dev_addr,
__rte_unused int *vfio_dev_fd,
diff --git a/lib/librte_eal/common/include/rte_vfio.h b/lib/librte_eal/common/include/rte_vfio.h
index c4a2e60..899baef 100644
--- a/lib/librte_eal/common/include/rte_vfio.h
+++ b/lib/librte_eal/common/include/rte_vfio.h
@@ -33,10 +33,6 @@
#define VFIO_NOIOMMU_MODE \
"/sys/module/vfio/parameters/enable_unsafe_noiommu_mode"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* NOIOMMU is defined from kernel version 4.5 onwards */
#ifdef VFIO_NOIOMMU_IOMMU
#define RTE_VFIO_NOIOMMU VFIO_NOIOMMU_IOMMU
@@ -44,6 +40,17 @@ extern "C" {
#define RTE_VFIO_NOIOMMU 8
#endif
+#else /* not VFIO_PRESENT */
+
+/* we don't need an actual definition, only pointer is used */
+struct vfio_device_info;
+
+#endif /* VFIO_PRESENT */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* Setup vfio_cfg for the device identified by its address.
* It discovers the configured I/O MMU groups or sets a new one for the device.
@@ -249,6 +256,4 @@ rte_vfio_get_group_fd(int iommu_group_num);
}
#endif
-#endif /* VFIO_PRESENT */
-
#endif /* _RTE_VFIO_H_ */
diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c
index 16ee730..19b3841 100644
--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
@@ -1547,4 +1547,64 @@ rte_vfio_dma_unmap(uint64_t __rte_unused vaddr, uint64_t __rte_unused iova,
return -1;
}
+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_experimental
+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_experimental
+rte_vfio_get_container_fd(void)
+{
+ return -1;
+}
+
+int __rte_experimental
+rte_vfio_get_group_fd(__rte_unused int iommu_group_num)
+{
+ return -1;
+}
+
#endif
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH] eal/vfio: export all VFIO functions when not compiling VFIO
2018-04-16 10:59 [dpdk-dev] [PATCH] eal/vfio: export all VFIO functions when not compiling VFIO Anatoly Burakov
@ 2018-04-16 11:55 ` Thomas Monjalon
2018-04-16 12:05 ` Burakov, Anatoly
2018-04-16 12:13 ` [dpdk-dev] [PATCH v2] " Anatoly Burakov
1 sibling, 1 reply; 5+ messages in thread
From: Thomas Monjalon @ 2018-04-16 11:55 UTC (permalink / raw)
To: Anatoly Burakov
Cc: dev, Bruce Richardson, shahafs, hemant.agrawal, gaetan.rivet
16/04/2018 12:59, Anatoly Burakov:
> --- a/lib/librte_eal/common/include/rte_vfio.h
> +++ b/lib/librte_eal/common/include/rte_vfio.h
> @@ -33,10 +33,6 @@
> #define VFIO_NOIOMMU_MODE \
> "/sys/module/vfio/parameters/enable_unsafe_noiommu_mode"
>
> -#ifdef __cplusplus
> -extern "C" {
> -#endif
> -
> /* NOIOMMU is defined from kernel version 4.5 onwards */
> #ifdef VFIO_NOIOMMU_IOMMU
> #define RTE_VFIO_NOIOMMU VFIO_NOIOMMU_IOMMU
> @@ -44,6 +40,17 @@ extern "C" {
> #define RTE_VFIO_NOIOMMU 8
> #endif
>
> +#else /* not VFIO_PRESENT */
> +
> +/* we don't need an actual definition, only pointer is used */
> +struct vfio_device_info;
> +
> +#endif /* VFIO_PRESENT */
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
Why moving this extern "C"?
Could it be at the top of the file?
[...]
> +int __rte_experimental
> +rte_vfio_get_group_fd(__rte_unused int iommu_group_num)
> +{
> + return -1;
> +}
> +
> #endif
This #endif needs a comment.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH] eal/vfio: export all VFIO functions when not compiling VFIO
2018-04-16 11:55 ` Thomas Monjalon
@ 2018-04-16 12:05 ` Burakov, Anatoly
0 siblings, 0 replies; 5+ messages in thread
From: Burakov, Anatoly @ 2018-04-16 12:05 UTC (permalink / raw)
To: Thomas Monjalon
Cc: dev, Bruce Richardson, shahafs, hemant.agrawal, gaetan.rivet
On 16-Apr-18 12:55 PM, Thomas Monjalon wrote:
> 16/04/2018 12:59, Anatoly Burakov:
>> --- a/lib/librte_eal/common/include/rte_vfio.h
>> +++ b/lib/librte_eal/common/include/rte_vfio.h
>> @@ -33,10 +33,6 @@
>> #define VFIO_NOIOMMU_MODE \
>> "/sys/module/vfio/parameters/enable_unsafe_noiommu_mode"
>>
>> -#ifdef __cplusplus
>> -extern "C" {
>> -#endif
>> -
>> /* NOIOMMU is defined from kernel version 4.5 onwards */
>> #ifdef VFIO_NOIOMMU_IOMMU
>> #define RTE_VFIO_NOIOMMU VFIO_NOIOMMU_IOMMU
>> @@ -44,6 +40,17 @@ extern "C" {
>> #define RTE_VFIO_NOIOMMU 8
>> #endif
>>
>> +#else /* not VFIO_PRESENT */
>> +
>> +/* we don't need an actual definition, only pointer is used */
>> +struct vfio_device_info;
>> +
>> +#endif /* VFIO_PRESENT */
>> +
>> +#ifdef __cplusplus
>> +extern "C" {
>> +#endif
>
> Why moving this extern "C"?
> Could it be at the top of the file?
As it was, it was inside #ifdef VFIO_PRESENT. It can be at the top, or
it can be where it is in this patch, not much difference.
>
> [...]
>> +int __rte_experimental
>> +rte_vfio_get_group_fd(__rte_unused int iommu_group_num)
>> +{
>> + return -1;
>> +}
>> +
>> #endif
>
> This #endif needs a comment.
>
Will do.
--
Thanks,
Anatoly
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH v2] eal/vfio: export all VFIO functions when not compiling VFIO
2018-04-16 10:59 [dpdk-dev] [PATCH] eal/vfio: export all VFIO functions when not compiling VFIO Anatoly Burakov
2018-04-16 11:55 ` Thomas Monjalon
@ 2018-04-16 12:13 ` Anatoly Burakov
2018-04-16 17:27 ` Thomas Monjalon
1 sibling, 1 reply; 5+ messages in thread
From: Anatoly Burakov @ 2018-04-16 12:13 UTC (permalink / raw)
To: dev
Cc: Bruce Richardson, thomas, shahafs, hemant.agrawal, gaetan.rivet,
anatoly.burakov
Previously, VFIO functions were not compiled in and exported if
VFIO compilation was disabled. Fix this by actually compiling
all of the functions unconditionally, , and provide missing
prototypes on Linux.
Fixes: 279b581c897d ("vfio: expose functions")
Fixes: 73a639085938 ("vfio: allow to map other memory regions")
Fixes: 964b2f3bfb07 ("vfio: export some internal functions")
Cc: hemant.agrawal@nxp.com
Cc: gaetan.rivet@6wind.com
Cc: anatoly.burakov@intel.com
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
Notes:
v2:
- Move "extern C" declaration to top of the file
- Add comment for closing #endif in .c file
lib/librte_eal/bsdapp/eal/eal.c | 15 +-------
lib/librte_eal/common/include/rte_vfio.h | 17 +++++----
lib/librte_eal/linuxapp/eal/eal_vfio.c | 62 +++++++++++++++++++++++++++++++-
3 files changed, 73 insertions(+), 21 deletions(-)
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index bfbec0d..d996190 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -40,6 +40,7 @@
#include <rte_dev.h>
#include <rte_devargs.h>
#include <rte_version.h>
+#include <rte_vfio.h>
#include <rte_atomic.h>
#include <malloc_heap.h>
@@ -756,20 +757,6 @@ rte_eal_vfio_intr_mode(void)
return RTE_INTR_MODE_NONE;
}
-/* dummy forward declaration. */
-struct vfio_device_info;
-
-/* dummy prototypes. */
-int rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
- int *vfio_dev_fd, struct vfio_device_info *device_info);
-int rte_vfio_release_device(const char *sysfs_base, const char *dev_addr, int fd);
-int rte_vfio_enable(const char *modname);
-int rte_vfio_is_enabled(const char *modname);
-int rte_vfio_noiommu_is_enabled(void);
-int rte_vfio_clear_group(int vfio_group_fd);
-int rte_vfio_dma_map(uint64_t vaddr, uint64_t iova, uint64_t len);
-int rte_vfio_dma_unmap(uint64_t vaddr, uint64_t iova, uint64_t len);
-
int rte_vfio_setup_device(__rte_unused const char *sysfs_base,
__rte_unused const char *dev_addr,
__rte_unused int *vfio_dev_fd,
diff --git a/lib/librte_eal/common/include/rte_vfio.h b/lib/librte_eal/common/include/rte_vfio.h
index c4a2e60..8900064 100644
--- a/lib/librte_eal/common/include/rte_vfio.h
+++ b/lib/librte_eal/common/include/rte_vfio.h
@@ -10,6 +10,10 @@
* RTE VFIO. This library provides various VFIO related utility functions.
*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* determine if VFIO is present on the system
*/
@@ -33,10 +37,6 @@
#define VFIO_NOIOMMU_MODE \
"/sys/module/vfio/parameters/enable_unsafe_noiommu_mode"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* NOIOMMU is defined from kernel version 4.5 onwards */
#ifdef VFIO_NOIOMMU_IOMMU
#define RTE_VFIO_NOIOMMU VFIO_NOIOMMU_IOMMU
@@ -44,6 +44,13 @@ extern "C" {
#define RTE_VFIO_NOIOMMU 8
#endif
+#else /* not VFIO_PRESENT */
+
+/* we don't need an actual definition, only pointer is used */
+struct vfio_device_info;
+
+#endif /* VFIO_PRESENT */
+
/**
* Setup vfio_cfg for the device identified by its address.
* It discovers the configured I/O MMU groups or sets a new one for the device.
@@ -249,6 +256,4 @@ rte_vfio_get_group_fd(int iommu_group_num);
}
#endif
-#endif /* VFIO_PRESENT */
-
#endif /* _RTE_VFIO_H_ */
diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c
index 16ee730..def71a6 100644
--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
@@ -1547,4 +1547,64 @@ rte_vfio_dma_unmap(uint64_t __rte_unused vaddr, uint64_t __rte_unused iova,
return -1;
}
-#endif
+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_experimental
+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_experimental
+rte_vfio_get_container_fd(void)
+{
+ return -1;
+}
+
+int __rte_experimental
+rte_vfio_get_group_fd(__rte_unused int iommu_group_num)
+{
+ return -1;
+}
+
+#endif /* VFIO_PRESENT */
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH v2] eal/vfio: export all VFIO functions when not compiling VFIO
2018-04-16 12:13 ` [dpdk-dev] [PATCH v2] " Anatoly Burakov
@ 2018-04-16 17:27 ` Thomas Monjalon
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2018-04-16 17:27 UTC (permalink / raw)
To: Anatoly Burakov
Cc: dev, Bruce Richardson, shahafs, hemant.agrawal, gaetan.rivet
16/04/2018 14:13, Anatoly Burakov:
> Previously, VFIO functions were not compiled in and exported if
> VFIO compilation was disabled. Fix this by actually compiling
> all of the functions unconditionally, , and provide missing
> prototypes on Linux.
>
> Fixes: 279b581c897d ("vfio: expose functions")
> Fixes: 73a639085938 ("vfio: allow to map other memory regions")
> Fixes: 964b2f3bfb07 ("vfio: export some internal functions")
> Cc: hemant.agrawal@nxp.com
> Cc: gaetan.rivet@6wind.com
> Cc: anatoly.burakov@intel.com
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-04-16 17:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-16 10:59 [dpdk-dev] [PATCH] eal/vfio: export all VFIO functions when not compiling VFIO Anatoly Burakov
2018-04-16 11:55 ` Thomas Monjalon
2018-04-16 12:05 ` Burakov, Anatoly
2018-04-16 12:13 ` [dpdk-dev] [PATCH v2] " Anatoly Burakov
2018-04-16 17:27 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).