[v5,3/9] eal: add windows compatible header files
diff mbox series

Message ID 20200113215534.10084-4-pallavi.kadam@intel.com
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series
  • Windows patchset with additional EAL functionalities
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Pallavi Kadam Jan. 13, 2020, 9:55 p.m. UTC
Modified \common\include\arch\x86\rte_vect.h
to include SSE4 header for Windows.

Adding dlfcn.h on Windows to support common code.

Adding eal_filesystem.h to support functions and
path defines for files and directories on Windows.

Signed-off-by: Antara Ganesh Kolar <antara.ganesh.kolar@intel.com>
Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
Reviewed-by: Keith Wiles <keith.wiles@intel.com>
---
 .../common/include/arch/x86/rte_vect.h        |  4 +-
 lib/librte_eal/windows/eal/include/dlfcn.h    | 21 ++++
 .../windows/eal/include/eal_filesystem.h      | 99 +++++++++++++++++++
 3 files changed, 123 insertions(+), 1 deletion(-)
 create mode 100644 lib/librte_eal/windows/eal/include/dlfcn.h
 create mode 100644 lib/librte_eal/windows/eal/include/eal_filesystem.h

Comments

Thomas Monjalon Jan. 27, 2020, 10:41 p.m. UTC | #1
13/01/2020 22:55, Pallavi Kadam:
> Modified \common\include\arch\x86\rte_vect.h
> to include SSE4 header for Windows.
> 
> Adding dlfcn.h on Windows to support common code.
> 
> Adding eal_filesystem.h to support functions and
> path defines for files and directories on Windows.

I don't see any relationship between these 3 items,
so I think they should be 3 separate patches.

> --- a/lib/librte_eal/common/include/arch/x86/rte_vect.h
> +++ b/lib/librte_eal/common/include/arch/x86/rte_vect.h
> @@ -15,7 +15,9 @@
>  #include <rte_config.h>
>  #include "generic/rte_vect.h"
>  
> -#if (defined(__ICC) || (__GNUC__ == 4 &&  __GNUC_MINOR__ < 4))
> +#if (defined(__ICC) || \
> +	(defined(_WIN64)) || \
> +	(__GNUC__ == 4 &&  __GNUC_MINOR__ < 4))
>  
>  #include <smmintrin.h> /* SSE4 */

I trust you on this change :)

> --- /dev/null
> +++ b/lib/librte_eal/windows/eal/include/dlfcn.h
> @@ -0,0 +1,21 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2019 Intel Corporation
> + */
> +
> +#ifndef _DLFCN_H_
> +#define _DLFCN_H_
> +
> +/**
> + * This file is added to support common code in eal_common_options.c
> + * as Microsoft libc does not contain dlfcn.h. This may be removed
> + * in future releases.
> + */
> +
> +/* The windows port does not currently support dynamic loading of libraries,
> + * so fail these calls
> + */
> +#define dlopen(lib, flag)   (0)
> +#define RTLD_NOW 0
> +#define dlerror()           ("Not supported!")

This is only for the function eal_plugins_init().
The plugin logic and directory search might be different on Windows.
I believe it would be better handled directly in eal_plugins_init().
For now, my advice is to not compile this function (and not call it
in Windows init of course):

int
eal_plugins_init(void)
{
#ifndef RTE_EXEC_ENV_WINDOWS

The right fix would be to move this "common" function in an UNIX-only file:
What about creating eal_unix_options.c file?
Could be in lib/librte_eal/unix/ directory?


> --- /dev/null
> +++ b/lib/librte_eal/windows/eal/include/eal_filesystem.h
> @@ -0,0 +1,99 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2019 Intel Corporation
> + */
> +
> +/**
> + * @file
> + * Stores functions and path defines for files and directories
> + * on the filesystem for Windows, that are used by the Windows EAL.
> + */
[...]
> +/** Function to read a single numeric value from a file on the filesystem.
> + * Used to read information from files on /sys
> + */
> +int eal_parse_sysfs_value(const char *filename, unsigned long *val);

Given that sysfs is a Linux system, I guess you don't need this function at all.
Pallavi Kadam Jan. 28, 2020, 11:34 p.m. UTC | #2
On 1/27/2020 2:41 PM, Thomas Monjalon wrote:
> 13/01/2020 22:55, Pallavi Kadam:
>> Modified \common\include\arch\x86\rte_vect.h
>> to include SSE4 header for Windows.
>>
>> Adding dlfcn.h on Windows to support common code.
>>
>> Adding eal_filesystem.h to support functions and
>> path defines for files and directories on Windows.
> I don't see any relationship between these 3 items,
> so I think they should be 3 separate patches.

Ok, will submit 3 separate patches in v6.

>
>> --- a/lib/librte_eal/common/include/arch/x86/rte_vect.h
>> +++ b/lib/librte_eal/common/include/arch/x86/rte_vect.h
>> @@ -15,7 +15,9 @@
>>   #include <rte_config.h>
>>   #include "generic/rte_vect.h"
>>   
>> -#if (defined(__ICC) || (__GNUC__ == 4 &&  __GNUC_MINOR__ < 4))
>> +#if (defined(__ICC) || \
>> +	(defined(_WIN64)) || \
>> +	(__GNUC__ == 4 &&  __GNUC_MINOR__ < 4))
>>   
>>   #include <smmintrin.h> /* SSE4 */
> I trust you on this change :)
>
>> --- /dev/null
>> +++ b/lib/librte_eal/windows/eal/include/dlfcn.h
>> @@ -0,0 +1,21 @@
>> +/* SPDX-License-Identifier: BSD-3-Clause
>> + * Copyright(c) 2019 Intel Corporation
>> + */
>> +
>> +#ifndef _DLFCN_H_
>> +#define _DLFCN_H_
>> +
>> +/**
>> + * This file is added to support common code in eal_common_options.c
>> + * as Microsoft libc does not contain dlfcn.h. This may be removed
>> + * in future releases.
>> + */
>> +
>> +/* The windows port does not currently support dynamic loading of libraries,
>> + * so fail these calls
>> + */
>> +#define dlopen(lib, flag)   (0)
>> +#define RTLD_NOW 0
>> +#define dlerror()           ("Not supported!")
> This is only for the function eal_plugins_init().
> The plugin logic and directory search might be different on Windows.
> I believe it would be better handled directly in eal_plugins_init().
> For now, my advice is to not compile this function (and not call it
> in Windows init of course):
>
> int
> eal_plugins_init(void)
> {
> #ifndef RTE_EXEC_ENV_WINDOWS
>
> The right fix would be to move this "common" function in an UNIX-only file:
> What about creating eal_unix_options.c file?
> Could be in lib/librte_eal/unix/ directory?

Ok. For now will include #ifndef RTE_EXEC_ENV_WINDOWSin v6 and will start working on this new 'unix' directory to add all 
unix based functions.

>
>
>> --- /dev/null
>> +++ b/lib/librte_eal/windows/eal/include/eal_filesystem.h
>> @@ -0,0 +1,99 @@
>> +/* SPDX-License-Identifier: BSD-3-Clause
>> + * Copyright(c) 2019 Intel Corporation
>> + */
>> +
>> +/**
>> + * @file
>> + * Stores functions and path defines for files and directories
>> + * on the filesystem for Windows, that are used by the Windows EAL.
>> + */
> [...]
>> +/** Function to read a single numeric value from a file on the filesystem.
>> + * Used to read information from files on /sys
>> + */
>> +int eal_parse_sysfs_value(const char *filename, unsigned long *val);
> Given that sysfs is a Linux system, I guess you don't need this function at all.

Thanks, will remove this function in v6.

>
>

Patch
diff mbox series

diff --git a/lib/librte_eal/common/include/arch/x86/rte_vect.h b/lib/librte_eal/common/include/arch/x86/rte_vect.h
index cf4e9db38..df5a60762 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_vect.h
@@ -15,7 +15,9 @@ 
 #include <rte_config.h>
 #include "generic/rte_vect.h"
 
-#if (defined(__ICC) || (__GNUC__ == 4 &&  __GNUC_MINOR__ < 4))
+#if (defined(__ICC) || \
+	(defined(_WIN64)) || \
+	(__GNUC__ == 4 &&  __GNUC_MINOR__ < 4))
 
 #include <smmintrin.h> /* SSE4 */
 
diff --git a/lib/librte_eal/windows/eal/include/dlfcn.h b/lib/librte_eal/windows/eal/include/dlfcn.h
new file mode 100644
index 000000000..1572910b0
--- /dev/null
+++ b/lib/librte_eal/windows/eal/include/dlfcn.h
@@ -0,0 +1,21 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef _DLFCN_H_
+#define _DLFCN_H_
+
+/**
+ * This file is added to support common code in eal_common_options.c
+ * as Microsoft libc does not contain dlfcn.h. This may be removed
+ * in future releases.
+ */
+
+/* The windows port does not currently support dynamic loading of libraries,
+ * so fail these calls
+ */
+#define dlopen(lib, flag)   (0)
+#define RTLD_NOW 0
+#define dlerror()           ("Not supported!")
+
+#endif /* _DLFCN_H_ */
diff --git a/lib/librte_eal/windows/eal/include/eal_filesystem.h b/lib/librte_eal/windows/eal/include/eal_filesystem.h
new file mode 100644
index 000000000..583617c83
--- /dev/null
+++ b/lib/librte_eal/windows/eal/include/eal_filesystem.h
@@ -0,0 +1,99 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+/**
+ * @file
+ * Stores functions and path defines for files and directories
+ * on the filesystem for Windows, that are used by the Windows EAL.
+ */
+
+#ifndef EAL_FILESYSTEM_H
+#define EAL_FILESYSTEM_H
+
+#include "eal_internal_cfg.h"
+
+/* sets up platform-specific runtime data dir */
+int
+eal_create_runtime_dir(void);
+
+/* returns runtime dir */
+const char *
+eal_get_runtime_dir(void);
+
+/* define the default filename prefix for the %s values below */
+#define HUGEFILE_PREFIX_DEFAULT "rte"
+
+/** Path of rte config file */
+#define RUNTIME_CONFIG_FMT "%s\\%s.config"
+
+static inline const char *
+eal_runtime_config_path(void)
+{
+	static char buffer[PATH_MAX];  /* static so auto-zeroed */
+	char  Directory[PATH_MAX];
+
+	GetTempPathA(sizeof(Directory), Directory);
+	snprintf(buffer, sizeof(buffer)-1, RUNTIME_CONFIG_FMT, Directory,
+		internal_config.hugefile_prefix);
+
+	return buffer;
+}
+
+/* Path of file backed array */
+#define FBARRAY_NAME_FMT "%s\\fbarray_%s"
+
+static inline const char *
+eal_get_fbarray_path(char *buffer, size_t buflen, const char *name) {
+	snprintf(buffer, buflen, FBARRAY_NAME_FMT, eal_get_runtime_dir(), name);
+	return buffer;
+}
+
+/* Path of primary/secondary communication unix socket file. */
+#define MP_SOCKET_FNAME "mp_socket"
+
+static inline const char *
+eal_mp_socket_path(void)
+{
+	static char buffer[PATH_MAX]; /* static so auto-zeroed */
+
+	snprintf(buffer, sizeof(buffer) - 1, "%s/%s", eal_get_runtime_dir(),
+		MP_SOCKET_FNAME);
+	return buffer;
+}
+
+/** Path of hugepage info file */
+#define HUGEPAGE_INFO_FMT "%s\\.%s_hugepage_info"
+
+static inline const char *
+eal_hugepage_info_path(void)
+{
+	static char buffer[PATH_MAX];  /* static so auto-zeroed */
+	TCHAR  Directory[PATH_MAX];
+
+	GetSystemDirectory(Directory, sizeof(Directory));
+	snprintf(buffer, sizeof(buffer)-1, HUGEPAGE_INFO_FMT, Directory,
+		internal_config.hugefile_prefix);
+	return buffer;
+}
+
+/** String format for hugepage map files */
+#define HUGEFILE_FMT "%s/%smap_%d"
+#define TEMP_HUGEFILE_FMT "%s/%smap_temp_%d"
+
+static inline const char *
+eal_get_hugefile_path(char *buffer, size_t buflen, const char *hugedir,
+	int f_id)
+{
+	snprintf(buffer, buflen, HUGEFILE_FMT, hugedir,
+		internal_config.hugefile_prefix, f_id);
+	buffer[buflen - 1] = '\0';
+	return buffer;
+}
+
+/** Function to read a single numeric value from a file on the filesystem.
+ * Used to read information from files on /sys
+ */
+int eal_parse_sysfs_value(const char *filename, unsigned long *val);
+
+#endif /* EAL_FILESYSTEM_H */