[3/9] eal: add windows compatible header files

Message ID 20190909195404.4760-4-pallavi.kadam@intel.com
State New
Delegated to: Thomas Monjalon
Headers show
Series
  • [1/9] eal: eal stub to support parsing feature on windows
Related show

Checks

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

Commit Message

Pallavi Kadam Sept. 9, 2019, 7:53 p.m.
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.

Adding getopt.h to support parsing options on Windows.

Adding rte_vect.h as Windows fails to compile:
\common\include\arch\x86\rte_vect.h.

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>
---
 lib/librte_eal/windows/eal/include/dlfcn.h    | 21 ++++
 .../windows/eal/include/eal_filesystem.h      | 99 +++++++++++++++++++
 lib/librte_eal/windows/eal/include/getopt.h   | 59 +++++++++++
 lib/librte_eal/windows/eal/include/rte_vect.h |  9 ++
 4 files changed, 188 insertions(+)
 create mode 100644 lib/librte_eal/windows/eal/include/dlfcn.h
 create mode 100644 lib/librte_eal/windows/eal/include/eal_filesystem.h
 create mode 100644 lib/librte_eal/windows/eal/include/getopt.h
 create mode 100644 lib/librte_eal/windows/eal/include/rte_vect.h

Comments

Stephen Hemminger Sept. 10, 2019, 9:19 a.m. | #1
On Mon,  9 Sep 2019 12:53:58 -0700
Pallavi Kadam <pallavi.kadam@intel.com> wrote:

> --- /dev/null
> +++ b/lib/librte_eal/windows/eal/include/getopt.h
> @@ -0,0 +1,59 @@
> +/* musl as a whole is licensed under the following standard MIT license:
> + *
> + * ----------------------------------------------------------------------
> + * Copyright (c) 2005-2014 Rich Felker, et al.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining
> + * a copy of this software and associated documentation files (the
> + * "Software"), to deal in the Software without restriction, including
> + * without limitation the rights to use, copy, modify, merge, publish,
> + * distribute, sublicense, and/or sell copies of the Software, and to
> + * permit persons to whom the Software is furnished to do so, subject to
> + * the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be
> + * included in all copies or substantial portions of the Software.
> + *

Although MIT license is similar to BSD license, it is not the same.
The DPDK project has converged to only use BSD-3 for all DPDK code (and GPL for kernel code).

Please find an alternative that is BSD licensed.
Pallavi Kadam Sept. 12, 2019, 5:11 p.m. | #2
On 9/10/2019 2:19 AM, Stephen Hemminger wrote:
> On Mon,  9 Sep 2019 12:53:58 -0700
> Pallavi Kadam <pallavi.kadam@intel.com> wrote:
>
>> --- /dev/null
>> +++ b/lib/librte_eal/windows/eal/include/getopt.h
>> @@ -0,0 +1,59 @@
>> +/* musl as a whole is licensed under the following standard MIT license:
>> + *
>> + * ----------------------------------------------------------------------
>> + * Copyright (c) 2005-2014 Rich Felker, et al.
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining
>> + * a copy of this software and associated documentation files (the
>> + * "Software"), to deal in the Software without restriction, including
>> + * without limitation the rights to use, copy, modify, merge, publish,
>> + * distribute, sublicense, and/or sell copies of the Software, and to
>> + * permit persons to whom the Software is furnished to do so, subject to
>> + * the following conditions:
>> + *
>> + * The above copyright notice and this permission notice shall be
>> + * included in all copies or substantial portions of the Software.
>> + *
> Although MIT license is similar to BSD license, it is not the same.
> The DPDK project has converged to only use BSD-3 for all DPDK code (and GPL for kernel code).
>
> Please find an alternative that is BSD licensed.

We discussed in the Windows Community call regarding the challenges we 
are facing to find and include

BSD-3 implementation of getopt and dirent files.

Please let us know if there can be any exceptions to include MIT license 
code for Windows

as mentionedin dpdk.org charter under 6.3 section.

Thomas, can you please comment on this?
Stephen Hemminger Sept. 12, 2019, 9:36 p.m. | #3
On Thu, 12 Sep 2019 10:11:23 -0700
Pallavi Kadam <pallavi.kadam@intel.com> wrote:

> On 9/10/2019 2:19 AM, Stephen Hemminger wrote:
> > On Mon,  9 Sep 2019 12:53:58 -0700
> > Pallavi Kadam <pallavi.kadam@intel.com> wrote:
> >  
> >> --- /dev/null
> >> +++ b/lib/librte_eal/windows/eal/include/getopt.h
> >> @@ -0,0 +1,59 @@
> >> +/* musl as a whole is licensed under the following standard MIT license:
> >> + *
> >> + * ----------------------------------------------------------------------
> >> + * Copyright (c) 2005-2014 Rich Felker, et al.
> >> + *
> >> + * Permission is hereby granted, free of charge, to any person obtaining
> >> + * a copy of this software and associated documentation files (the
> >> + * "Software"), to deal in the Software without restriction, including
> >> + * without limitation the rights to use, copy, modify, merge, publish,
> >> + * distribute, sublicense, and/or sell copies of the Software, and to
> >> + * permit persons to whom the Software is furnished to do so, subject to
> >> + * the following conditions:
> >> + *
> >> + * The above copyright notice and this permission notice shall be
> >> + * included in all copies or substantial portions of the Software.
> >> + *  
> > Although MIT license is similar to BSD license, it is not the same.
> > The DPDK project has converged to only use BSD-3 for all DPDK code (and GPL for kernel code).
> >
> > Please find an alternative that is BSD licensed.  
> 
> We discussed in the Windows Community call regarding the challenges we 
> are facing to find and include
> 
> BSD-3 implementation of getopt and dirent files.
> 
> Please let us know if there can be any exceptions to include MIT license 
> code for Windows
> 
> as mentionedin dpdk.org charter under 6.3 section.
> 
> Thomas, can you please comment on this?
> 

To  get exception needs at least TAB and probably even governing board approval.

Patch

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 */
diff --git a/lib/librte_eal/windows/eal/include/getopt.h b/lib/librte_eal/windows/eal/include/getopt.h
new file mode 100644
index 000000000..d47202ec9
--- /dev/null
+++ b/lib/librte_eal/windows/eal/include/getopt.h
@@ -0,0 +1,59 @@ 
+/* musl as a whole is licensed under the following standard MIT license:
+ *
+ * ----------------------------------------------------------------------
+ * Copyright (c) 2005-2014 Rich Felker, et al.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _GETOPT_H
+#define _GETOPT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int getopt(int, char * const [], const char *);
+extern char *optarg;
+extern int optind, opterr, optopt, optreset;
+
+struct option {
+	const char *name;
+	int has_arg;
+	int *flag;
+	int val;
+};
+
+void __getopt_msg(const char *a, const char *b, const char *c, size_t l);
+
+int getopt_long(int argc, char **argv, const char *optstring,
+	const struct option *longopts, int *idx);
+int getopt_long_only(int argc, char **argv, const char *optstring,
+	const struct option *longopts, int *idx);
+
+#define no_argument        0
+#define required_argument  1
+#define optional_argument  2
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/librte_eal/windows/eal/include/rte_vect.h b/lib/librte_eal/windows/eal/include/rte_vect.h
new file mode 100644
index 000000000..630473e28
--- /dev/null
+++ b/lib/librte_eal/windows/eal/include/rte_vect.h
@@ -0,0 +1,9 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#pragma once
+
+#define __ICC	1600
+
+#include "..\..\common\include\arch\x86\rte_vect.h"