[v7,1/8] eal: eal stub to add windows support

Message ID 20190328232451.16988-2-anand.rawat@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series HelloWorld example for windows |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues
ci/Performance-Testing fail build patch failure

Commit Message

Anand Rawat March 28, 2019, 11:24 p.m. UTC
  Added initial stub source files for windows support
and only the required meson changes for windows.

Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Signed-off-by: Anand Rawat <anand.rawat@intel.com>
Reviewed-by: Jeff Shaw <jeffrey.b.shaw@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
---
 config/meson.build                      | 23 ++++++++++++------
 config/x86/meson.build                  | 14 ++++++-----
 lib/librte_eal/meson.build              |  6 ++++-
 lib/librte_eal/windows/eal/eal.c        | 14 +++++++++++
 lib/librte_eal/windows/eal/eal_debug.c  | 15 ++++++++++++
 lib/librte_eal/windows/eal/eal_lcore.c  | 32 +++++++++++++++++++++++++
 lib/librte_eal/windows/eal/eal_thread.c | 18 ++++++++++++++
 lib/librte_eal/windows/eal/meson.build  | 10 ++++++++
 8 files changed, 118 insertions(+), 14 deletions(-)
 create mode 100644 lib/librte_eal/windows/eal/eal.c
 create mode 100644 lib/librte_eal/windows/eal/eal_debug.c
 create mode 100644 lib/librte_eal/windows/eal/eal_lcore.c
 create mode 100644 lib/librte_eal/windows/eal/eal_thread.c
 create mode 100644 lib/librte_eal/windows/eal/meson.build
  

Comments

Bruce Richardson April 1, 2019, 4:17 p.m. UTC | #1
On Thu, Mar 28, 2019 at 04:24:44PM -0700, Anand Rawat wrote:
> Added initial stub source files for windows support
> and only the required meson changes for windows.
> 
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Signed-off-by: Anand Rawat <anand.rawat@intel.com>
> Reviewed-by: Jeff Shaw <jeffrey.b.shaw@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> ---
>  config/meson.build                      | 23 ++++++++++++------
>  config/x86/meson.build                  | 14 ++++++-----
>  lib/librte_eal/meson.build              |  6 ++++-
>  lib/librte_eal/windows/eal/eal.c        | 14 +++++++++++
>  lib/librte_eal/windows/eal/eal_debug.c  | 15 ++++++++++++
>  lib/librte_eal/windows/eal/eal_lcore.c  | 32 +++++++++++++++++++++++++
>  lib/librte_eal/windows/eal/eal_thread.c | 18 ++++++++++++++
>  lib/librte_eal/windows/eal/meson.build  | 10 ++++++++
>  8 files changed, 118 insertions(+), 14 deletions(-)
>  create mode 100644 lib/librte_eal/windows/eal/eal.c
>  create mode 100644 lib/librte_eal/windows/eal/eal_debug.c
>  create mode 100644 lib/librte_eal/windows/eal/eal_lcore.c
>  create mode 100644 lib/librte_eal/windows/eal/eal_thread.c
>  create mode 100644 lib/librte_eal/windows/eal/meson.build
> 
> diff --git a/config/meson.build b/config/meson.build
> index 30a7261a5..4bd73b1e9 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -1,5 +1,5 @@
>  # SPDX-License-Identifier: BSD-3-Clause
> -# Copyright(c) 2017 Intel Corporation
> +# Copyright(c) 2017-2019 Intel Corporation
>  
>  # set the major version, which might be used by drivers and libraries
>  # depending on the configuration options
> @@ -80,18 +80,27 @@ dpdk_extra_ldflags += '-Wl,--no-as-needed'
>  add_project_link_arguments('-pthread', language: 'c')
>  dpdk_extra_ldflags += '-pthread'
>  
> -# some libs depend on maths lib
> -add_project_link_arguments('-lm', language: 'c')
> -dpdk_extra_ldflags += '-lm'
> +# on some OS, maths functions are in a separate library
> +if cc.find_library('lm', required : false).found()

The library is "libm", not "liblm" so this breaks the linux builds as there
is not found an "lm" library. Instead use "cc.find_library('m',..."

/Bruce
  
Bruce Richardson April 1, 2019, 4:34 p.m. UTC | #2
On Thu, Mar 28, 2019 at 04:24:44PM -0700, Anand Rawat wrote:
> Added initial stub source files for windows support
> and only the required meson changes for windows.
> 
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Signed-off-by: Anand Rawat <anand.rawat@intel.com>
> Reviewed-by: Jeff Shaw <jeffrey.b.shaw@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> ---
>  config/meson.build                      | 23 ++++++++++++------
>  config/x86/meson.build                  | 14 ++++++-----
>  lib/librte_eal/meson.build              |  6 ++++-
>  lib/librte_eal/windows/eal/eal.c        | 14 +++++++++++
>  lib/librte_eal/windows/eal/eal_debug.c  | 15 ++++++++++++
>  lib/librte_eal/windows/eal/eal_lcore.c  | 32 +++++++++++++++++++++++++
>  lib/librte_eal/windows/eal/eal_thread.c | 18 ++++++++++++++
>  lib/librte_eal/windows/eal/meson.build  | 10 ++++++++
>  8 files changed, 118 insertions(+), 14 deletions(-)
>  create mode 100644 lib/librte_eal/windows/eal/eal.c
>  create mode 100644 lib/librte_eal/windows/eal/eal_debug.c
>  create mode 100644 lib/librte_eal/windows/eal/eal_lcore.c
>  create mode 100644 lib/librte_eal/windows/eal/eal_thread.c
>  create mode 100644 lib/librte_eal/windows/eal/meson.build
> 

I'm a little uncertain behind putting the stub files and the meson.build
changes in the one patch, since the result doesn't build anyway. However,
you can get meson to successfully configure the project on windows by
adding in an empty file called meson.build to the kernel/windows directory.

/Bruce
  
Anand Rawat April 1, 2019, 5:06 p.m. UTC | #3
On 4/1/2019 9:34 AM, Bruce Richardson wrote:
> On Thu, Mar 28, 2019 at 04:24:44PM -0700, Anand Rawat wrote:
>>   config/meson.build                      | 23 ++++++++++++------
>>   config/x86/meson.build                  | 14 ++++++-----
>>   lib/librte_eal/meson.build              |  6 ++++-
>>   lib/librte_eal/windows/eal/eal.c        | 14 +++++++++++
>>   lib/librte_eal/windows/eal/eal_debug.c  | 15 ++++++++++++
>>   lib/librte_eal/windows/eal/eal_lcore.c  | 32 +++++++++++++++++++++++++
>>   lib/librte_eal/windows/eal/eal_thread.c | 18 ++++++++++++++
>>   lib/librte_eal/windows/eal/meson.build  | 10 ++++++++
> 
> I'm a little uncertain behind putting the stub files and the meson.build
> changes in the one patch, since the result doesn't build anyway. However,
> you can get meson to successfully configure the project on windows by
> adding in an empty file called meson.build to the kernel/windows directory.
> 
> /Bruce
> 

Thanks Bruce, libm is a part of V8 fixes.
kernel/windows directory is the patch 8/8 as I thought of it as a 
temporary workaround. I'll move it to another patch along with meson 
changes here.
  
Bruce Richardson April 1, 2019, 8:10 p.m. UTC | #4
On Mon, Apr 01, 2019 at 10:06:18AM -0700, Anand Rawat wrote:
> On 4/1/2019 9:34 AM, Bruce Richardson wrote:
> > On Thu, Mar 28, 2019 at 04:24:44PM -0700, Anand Rawat wrote:
> > >   config/meson.build                      | 23 ++++++++++++------
> > >   config/x86/meson.build                  | 14 ++++++-----
> > >   lib/librte_eal/meson.build              |  6 ++++-
> > >   lib/librte_eal/windows/eal/eal.c        | 14 +++++++++++
> > >   lib/librte_eal/windows/eal/eal_debug.c  | 15 ++++++++++++
> > >   lib/librte_eal/windows/eal/eal_lcore.c  | 32 +++++++++++++++++++++++++
> > >   lib/librte_eal/windows/eal/eal_thread.c | 18 ++++++++++++++
> > >   lib/librte_eal/windows/eal/meson.build  | 10 ++++++++
> > 
> > I'm a little uncertain behind putting the stub files and the meson.build
> > changes in the one patch, since the result doesn't build anyway. However,
> > you can get meson to successfully configure the project on windows by
> > adding in an empty file called meson.build to the kernel/windows directory.
> > 
> > /Bruce
> > 
> 
> Thanks Bruce, libm is a part of V8 fixes.
> kernel/windows directory is the patch 8/8 as I thought of it as a temporary
> workaround. I'll move it to another patch along with meson changes here.

Oh, I wasn't thinking of it being temporary, as I assumed you had kernel
modules for uio on windows. However, if they are not being hosted on DPDK,
I still think having a directory with a meson.build file with just a
comment in it e.g. "No kernel drivers for this OS",  is probably tidier
than having if conditions in the higher level build files.
  

Patch

diff --git a/config/meson.build b/config/meson.build
index 30a7261a5..4bd73b1e9 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -1,5 +1,5 @@ 
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright(c) 2017 Intel Corporation
+# Copyright(c) 2017-2019 Intel Corporation
 
 # set the major version, which might be used by drivers and libraries
 # depending on the configuration options
@@ -80,18 +80,27 @@  dpdk_extra_ldflags += '-Wl,--no-as-needed'
 add_project_link_arguments('-pthread', language: 'c')
 dpdk_extra_ldflags += '-pthread'
 
-# some libs depend on maths lib
-add_project_link_arguments('-lm', language: 'c')
-dpdk_extra_ldflags += '-lm'
+# on some OS, maths functions are in a separate library
+if cc.find_library('lm', required : false).found()
+	# some libs depend on maths lib
+	add_project_link_arguments('-lm', language: 'c')
+	dpdk_extra_ldflags += '-lm'
+endif
 
 # for linux link against dl, for bsd execinfo
 if host_machine.system() == 'linux'
 	link_lib = 'dl'
-else
+elif host_machine.system() == 'freebsd'
 	link_lib = 'execinfo'
+else
+	link_lib = ''
+endif
+
+# if link_lib is empty, do not add it to project properties
+if link_lib != ''
+	add_project_link_arguments('-l' + link_lib, language: 'c')
+	dpdk_extra_ldflags += '-l' + link_lib
 endif
-add_project_link_arguments('-l' + link_lib, language: 'c')
-dpdk_extra_ldflags += '-l' + link_lib
 
 # check for libraries used in multiple places in DPDK
 has_libnuma = 0
diff --git a/config/x86/meson.build b/config/x86/meson.build
index 7504cb9e5..558edfda9 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -1,15 +1,17 @@ 
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright(c) 2017 Intel Corporation
+# Copyright(c) 2017-2019 Intel Corporation
 
 # for checking defines we need to use the correct compiler flags
 march_opt = ['-march=@0@'.format(machine)]
 
 # get binutils version for the workaround of Bug 97
-ldver = run_command('ld', '-v').stdout().strip()
-if ldver.contains('2.30')
-	if cc.has_argument('-mno-avx512f')
-		march_opt += '-mno-avx512f'
-		message('Binutils 2.30 detected, disabling AVX512 support as workaround for bug #97')
+if host_machine.system() != 'windows'
+	ldver = run_command('ld', '-v').stdout().strip()
+	if ldver.contains('2.30')
+		if cc.has_argument('-mno-avx512f')
+			march_opt += '-mno-avx512f'
+			message('Binutils 2.30 detected, disabling AVX512 support as workaround for bug #97')
+		endif
 	endif
 endif
 
diff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build
index d48c5e11d..1863622c0 100644
--- a/lib/librte_eal/meson.build
+++ b/lib/librte_eal/meson.build
@@ -1,5 +1,5 @@ 
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright(c) 2017 Intel Corporation
+# Copyright(c) 2017-2019 Intel Corporation
 
 # Custom EAL processing. EAL is complicated enough that it can't just
 # have a straight list of headers and source files.
@@ -17,6 +17,10 @@  elif host_machine.system() == 'freebsd'
 	dpdk_conf.set('RTE_EXEC_ENV_FREEBSD', 1)
 	subdir('freebsd/eal')
 
+elif host_machine.system() == 'windows'
+	dpdk_conf.set('RTE_EXEC_ENV_WINDOWS', 1)
+	subdir('windows/eal')
+
 else
 	error('unsupported system type "@0@"'.format(host_machine.system()))
 endif
diff --git a/lib/librte_eal/windows/eal/eal.c b/lib/librte_eal/windows/eal/eal.c
new file mode 100644
index 000000000..37ed42233
--- /dev/null
+++ b/lib/librte_eal/windows/eal/eal.c
@@ -0,0 +1,14 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#include <rte_common.h>
+
+ /* Launch threads, called at application init(). */
+int
+rte_eal_init(int argc __rte_unused, char **argv __rte_unused)
+{
+	/* TODO */
+	/* This is a stub, not the expected result */
+	return 0;
+}
diff --git a/lib/librte_eal/windows/eal/eal_debug.c b/lib/librte_eal/windows/eal/eal_debug.c
new file mode 100644
index 000000000..a9705e257
--- /dev/null
+++ b/lib/librte_eal/windows/eal/eal_debug.c
@@ -0,0 +1,15 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#include <rte_common.h>
+
+ /* call abort(), it will generate a coredump if enabled */
+void
+__rte_panic(const char *funcname __rte_unused,
+		const char *format __rte_unused, ...)
+{
+	/* TODO */
+	/* This is a stub, not the expected result */
+	abort();
+}
diff --git a/lib/librte_eal/windows/eal/eal_lcore.c b/lib/librte_eal/windows/eal/eal_lcore.c
new file mode 100644
index 000000000..e4fcb2615
--- /dev/null
+++ b/lib/librte_eal/windows/eal/eal_lcore.c
@@ -0,0 +1,32 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#include <rte_common.h>
+
+ /* Get the cpu core id value */
+unsigned int
+eal_cpu_core_id(unsigned int lcore_id)
+{
+	/* TODO */
+	/* This is a stub, not the expected result */
+	return lcore_id;
+}
+
+/* Check if a cpu is present by the presence of the cpu information for it */
+int
+eal_cpu_detected(unsigned int lcore_id __rte_unused)
+{
+	/* TODO */
+	/* This is a stub, not the expected result */
+	return 1;
+}
+
+/* Get CPU socket id (NUMA node) for a logical core */
+unsigned int
+eal_cpu_socket_id(unsigned int cpu_id __rte_unused)
+{
+	/* TODO */
+	/* This is a stub, not the expected result */
+	return 0;
+}
diff --git a/lib/librte_eal/windows/eal/eal_thread.c b/lib/librte_eal/windows/eal/eal_thread.c
new file mode 100644
index 000000000..f701443c3
--- /dev/null
+++ b/lib/librte_eal/windows/eal/eal_thread.c
@@ -0,0 +1,18 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#include <windows.h>
+
+#include <rte_common.h>
+
+typedef uintptr_t eal_thread_t;
+
+/* function to create threads */
+int
+eal_thread_create(eal_thread_t *thread __rte_unused)
+{
+	/* TODO */
+	/* This is a stub, not the expected result */
+	return 0;
+}
diff --git a/lib/librte_eal/windows/eal/meson.build b/lib/librte_eal/windows/eal/meson.build
new file mode 100644
index 000000000..8b1735623
--- /dev/null
+++ b/lib/librte_eal/windows/eal/meson.build
@@ -0,0 +1,10 @@ 
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2019 Intel Corporation
+
+env_objs = []
+env_headers = []
+env_sources = files('eal.c',
+	'eal_debug.c',
+	'eal_lcore.c',
+	'eal_thread.c',
+)