From patchwork Thu Mar 28 02:21:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 51826 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4051F5B2E; Thu, 28 Mar 2019 03:21:35 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id C72C15B12 for ; Thu, 28 Mar 2019 03:21:17 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2019 19:21:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,278,1549958400"; d="scan'208";a="331369606" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by fmsmga006.fm.intel.com with ESMTP; 27 Mar 2019 19:21:15 -0700 From: Anand Rawat To: dev@dpdk.org Cc: anand.rawat@intel.com, pallavi.kadam@intel.com, ranjit.menon@intel.com, jeffrey.b.shaw@intel.com, bruce.richardson@intel.com, thomas@monjalon.net Date: Wed, 27 Mar 2019 19:21:08 -0700 Message-Id: <20190328022115.4660-2-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190328022115.4660-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190328022115.4660-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v6 1/8] eal: eal stub to add windows support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Added initial stub source files for windows support and only the required meson changes for windows. Signed-off-by: Pallavi Kadam Signed-off-by: Anand Rawat Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon Acked-by: Harini Ramakrishnan Signed-off-by: Pallavi Kadam Signed-off-by: Anand Rawat Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon --- 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() + # 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 c592c6747..c2249855a 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 + + /* 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 + + /* 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 + + /* 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 + +#include + +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', +) From patchwork Thu Mar 28 02:21:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 51825 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 095BD5B3C; Thu, 28 Mar 2019 03:21:18 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 0C3425B12 for ; Thu, 28 Mar 2019 03:21:16 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2019 19:21:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,278,1549958400"; d="scan'208";a="331369609" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by fmsmga006.fm.intel.com with ESMTP; 27 Mar 2019 19:21:15 -0700 From: Anand Rawat To: dev@dpdk.org Cc: anand.rawat@intel.com, pallavi.kadam@intel.com, ranjit.menon@intel.com, jeffrey.b.shaw@intel.com, bruce.richardson@intel.com, thomas@monjalon.net Date: Wed, 27 Mar 2019 19:21:09 -0700 Message-Id: <20190328022115.4660-3-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190328022115.4660-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190328022115.4660-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v6 2/8] eal: add header files to support os specifics X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Added rte_os.h files to support os specific functionality. Updated rte_common.h to include rte_os.h. Updated lib/meson.build to inject rte_os.h in every library. Signed-off-by: Anand Rawat Signed-off-by: Pallavi Kadam Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon Acked-by: Harini Ramakrishnan Signed-off-by: Anand Rawat Signed-off-by: Pallavi Kadam Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon --- lib/librte_eal/common/include/rte_common.h | 5 +++- .../common/include/rte_string_fns.h | 4 ++- .../freebsd/eal/include/exec-env/rte_os.h | 10 +++++++ .../linux/eal/include/exec-env/rte_os.h | 8 +++++ .../windows/eal/include/exec-env/rte_os.h | 30 +++++++++++++++++++ lib/meson.build | 7 ++++- 6 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 lib/librte_eal/freebsd/eal/include/exec-env/rte_os.h create mode 100644 lib/librte_eal/linux/eal/include/exec-env/rte_os.h create mode 100644 lib/librte_eal/windows/eal/include/exec-env/rte_os.h diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index bcf8afd39..3e4768f4a 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation + * Copyright(c) 2010-2019 Intel Corporation */ #ifndef _RTE_COMMON_H_ @@ -24,6 +24,9 @@ extern "C" { #include +/* os specific include */ +#include + #ifndef typeof #define typeof __typeof__ #endif diff --git a/lib/librte_eal/common/include/rte_string_fns.h b/lib/librte_eal/common/include/rte_string_fns.h index 85bfe6c9a..8bac8243c 100644 --- a/lib/librte_eal/common/include/rte_string_fns.h +++ b/lib/librte_eal/common/include/rte_string_fns.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation + * Copyright(c) 2010-2019 Intel Corporation */ /** @@ -18,6 +18,8 @@ extern "C" { #include #include +#include + /** * Takes string "string" parameter and splits it at character "delim" * up to maxtokens-1 times - to give "maxtokens" resulting tokens. Like diff --git a/lib/librte_eal/freebsd/eal/include/exec-env/rte_os.h b/lib/librte_eal/freebsd/eal/include/exec-env/rte_os.h new file mode 100644 index 000000000..bda0c2d92 --- /dev/null +++ b/lib/librte_eal/freebsd/eal/include/exec-env/rte_os.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Intel Corporation + */ + +#ifndef _RTE_OS_H_ +#define _RTE_OS_H_ + +/* stub file for os specific logic */ + +#endif /* _RTE_OS_H_ */ diff --git a/lib/librte_eal/linux/eal/include/exec-env/rte_os.h b/lib/librte_eal/linux/eal/include/exec-env/rte_os.h new file mode 100644 index 000000000..c43ec6da5 --- /dev/null +++ b/lib/librte_eal/linux/eal/include/exec-env/rte_os.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Intel Corporation + */ + +#ifndef _RTE_OS_H_ +#define _RTE_OS_H_ + +#endif /* _RTE_OS_H_ */ diff --git a/lib/librte_eal/windows/eal/include/exec-env/rte_os.h b/lib/librte_eal/windows/eal/include/exec-env/rte_os.h new file mode 100644 index 000000000..65230cae9 --- /dev/null +++ b/lib/librte_eal/windows/eal/include/exec-env/rte_os.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Intel Corporation + */ + +#ifndef _RTE_OS_H_ +#define _RTE_OS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* macro substitution for windows supported strerror_r */ +#define strerror_r(a, b, c) strerror_s(b, c, a) + +/* macro substitution for windows supported strdup */ +#define strdup(str) _strdup(str) + +/* macro substitution for windows supported ssize_t type */ +typedef SSIZE_T ssize_t; + +/* macro substitution for windows supported strtok_r */ +#define strtok_r(str, delim, saveptr) strtok_s(str, delim, saveptr) + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_OS_H_ */ diff --git a/lib/meson.build b/lib/meson.build index 99957ba7d..a81faf0ed 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -1,5 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2017-2019 Intel Corporation # process all libraries equally, as far as possible @@ -64,6 +64,11 @@ foreach l:libraries dir_name = 'librte_' + l subdir(dir_name) + if host_machine.system() == 'windows' + # injecting rte_os.h in every library in windows + includes += include_directories('librte_eal/windows/eal/include/exec-env') + endif + if build enabled_libs += name dpdk_conf.set('RTE_LIBRTE_' + name.to_upper(), 1) From patchwork Thu Mar 28 02:21:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 51828 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7C9B35F2A; Thu, 28 Mar 2019 03:21:40 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 8D4EA5F0F for ; Thu, 28 Mar 2019 03:21:18 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2019 19:21:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,278,1549958400"; d="scan'208";a="331369612" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by fmsmga006.fm.intel.com with ESMTP; 27 Mar 2019 19:21:16 -0700 From: Anand Rawat To: dev@dpdk.org Cc: anand.rawat@intel.com, pallavi.kadam@intel.com, ranjit.menon@intel.com, jeffrey.b.shaw@intel.com, bruce.richardson@intel.com, thomas@monjalon.net Date: Wed, 27 Mar 2019 19:21:10 -0700 Message-Id: <20190328022115.4660-4-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190328022115.4660-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190328022115.4660-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v6 3/8] build: add module definition file for windows X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Updated lib/meson.build to create shared libraries on windows. Added DEF files to list the exports for the eal and kvargs libraries. Signed-off-by: Bruce Richardson Signed-off-by: Anand Rawat Reviewed-by: Pallavi Kadam Reviewed-by: Ranjit Menon Acked-by: Harini Ramakrishnan Signed-off-by: Bruce Richardson Signed-off-by: Anand Rawat Reviewed-by: Pallavi Kadam Reviewed-by: Ranjit Menon --- lib/librte_eal/rte_eal_exports.def | 9 +++++++++ lib/librte_kvargs/rte_kvargs_exports.def | 7 +++++++ lib/meson.build | 12 ++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 lib/librte_eal/rte_eal_exports.def create mode 100644 lib/librte_kvargs/rte_kvargs_exports.def diff --git a/lib/librte_eal/rte_eal_exports.def b/lib/librte_eal/rte_eal_exports.def new file mode 100644 index 000000000..12a6c79d6 --- /dev/null +++ b/lib/librte_eal/rte_eal_exports.def @@ -0,0 +1,9 @@ +EXPORTS + __rte_panic + rte_eal_get_configuration + rte_eal_init + rte_eal_mp_remote_launch + rte_eal_mp_wait_lcore + rte_eal_remote_launch + rte_log + rte_vlog diff --git a/lib/librte_kvargs/rte_kvargs_exports.def b/lib/librte_kvargs/rte_kvargs_exports.def new file mode 100644 index 000000000..10e839e00 --- /dev/null +++ b/lib/librte_kvargs/rte_kvargs_exports.def @@ -0,0 +1,7 @@ +EXPORTS + rte_kvargs_count + rte_kvargs_free + rte_kvargs_parse + rte_kvargs_process + rte_kvargs_parse_delim + rte_kvargs_strcmp diff --git a/lib/meson.build b/lib/meson.build index a81faf0ed..9cba4662e 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -122,14 +122,22 @@ foreach l:libraries objs += static_lib.extract_all_objects(recursive: false) version_map = '@0@/@1@/rte_@2@_version.map'.format( meson.current_source_dir(), dir_name, name) + exports = '@0@/@1@/rte_@2@_exports.def'.format( + meson.current_source_dir(), dir_name, name) + implib = dir_name + '.dll.a' + if host_machine.system() == 'windows' + lk_args = ['-Wl,/def:' + exports, '-Wl,/implib:lib\\' + implib] + else + lk_args = ['-Wl,--version-script=' + version_map] + endif shared_lib = shared_library(libname, sources, objects: objs, c_args: cflags, dependencies: shared_deps, include_directories: includes, - link_args: '-Wl,--version-script=' + version_map, - link_depends: version_map, + link_args: lk_args, + link_depends: [version_map, exports], version: lib_version, soversion: so_version, install: true) From patchwork Thu Mar 28 02:21:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 51830 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4478E5F72; Thu, 28 Mar 2019 03:21:45 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 19FAE5B12 for ; Thu, 28 Mar 2019 03:21:18 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2019 19:21:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,278,1549958400"; d="scan'208";a="331369615" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by fmsmga006.fm.intel.com with ESMTP; 27 Mar 2019 19:21:16 -0700 From: Anand Rawat To: dev@dpdk.org Cc: anand.rawat@intel.com, pallavi.kadam@intel.com, ranjit.menon@intel.com, jeffrey.b.shaw@intel.com, bruce.richardson@intel.com, thomas@monjalon.net Date: Wed, 27 Mar 2019 19:21:11 -0700 Message-Id: <20190328022115.4660-5-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190328022115.4660-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190328022115.4660-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v6 4/8] eal: sys/queue.h implementation for windows X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Adding sys/queue.h on windows for supporting common code. This is implementation has BSD-3-Clause licensing. Signed-off-by: Ranjit Menon Signed-off-by: Anand Rawat Reviewed-by: Jeff Shaw Acked-by: Harini Ramakrishnan Signed-off-by: Ranjit Menon Signed-off-by: Anand Rawat Reviewed-by: Jeff Shaw --- .../windows/eal/include/sys/queue.h | 320 ++++++++++++++++++ 1 file changed, 320 insertions(+) create mode 100644 lib/librte_eal/windows/eal/include/sys/queue.h diff --git a/lib/librte_eal/windows/eal/include/sys/queue.h b/lib/librte_eal/windows/eal/include/sys/queue.h new file mode 100644 index 000000000..5ee4916ad --- /dev/null +++ b/lib/librte_eal/windows/eal/include/sys/queue.h @@ -0,0 +1,320 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#ifndef _SYS_QUEUE_H_ +#define _SYS_QUEUE_H_ + +/* + * This file defines tail queues. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * Below is a summary of implemented functions where: + * + means the macro is available + * - means the macro is not available + * s means the macro is available but is slow (runs in O(n) time) + * + * TAILQ + * _HEAD + + * _CLASS_HEAD + + * _HEAD_INITIALIZER + + * _ENTRY + + * _CLASS_ENTRY + + * _INIT + + * _EMPTY + + * _FIRST + + * _NEXT + + * _PREV + + * _LAST + + * _LAST_FAST + + * _FOREACH + + * _FOREACH_FROM + + * _FOREACH_SAFE + + * _FOREACH_FROM_SAFE + + * _FOREACH_REVERSE + + * _FOREACH_REVERSE_FROM + + * _FOREACH_REVERSE_SAFE + + * _FOREACH_REVERSE_FROM_SAFE + + * _INSERT_HEAD + + * _INSERT_BEFORE + + * _INSERT_AFTER + + * _INSERT_TAIL + + * _CONCAT + + * _REMOVE_AFTER - + * _REMOVE_HEAD - + * _REMOVE + + * _SWAP + + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define QMD_TRACE_ELEM(elem) +#define QMD_TRACE_HEAD(head) +#define TRACEBUF +#define TRACEBUF_INITIALIZER + +#define TRASHIT(x) +#define QMD_IS_TRASHED(x) 0 + +#define QMD_SAVELINK(name, link) + +#ifdef __cplusplus +/* + * In C++ there can be structure lists and class lists: + */ +#define QUEUE_TYPEOF(type) type +#else +#define QUEUE_TYPEOF(type) struct type +#endif + +/* + * Tail queue declarations. + */ +#define TAILQ_HEAD(name, type) \ +struct name { \ + struct type *tqh_first; /* first element */ \ + struct type **tqh_last; /* addr of last next element */ \ + TRACEBUF \ +} + +#define TAILQ_CLASS_HEAD(name, type) \ +struct name { \ + class type *tqh_first; /* first element */ \ + class type **tqh_last; /* addr of last next element */ \ + TRACEBUF \ +} + +#define TAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER } + +#define TAILQ_ENTRY(type) \ +struct { \ + struct type *tqe_next; /* next element */ \ + struct type **tqe_prev; /* address of previous next element */ \ + TRACEBUF \ +} + +#define TAILQ_CLASS_ENTRY(type) \ +struct { \ + class type *tqe_next; /* next element */ \ + class type **tqe_prev; /* address of previous next element */ \ + TRACEBUF \ +} + +/* + * Tail queue functions. + */ +#define QMD_TAILQ_CHECK_HEAD(head, field) +#define QMD_TAILQ_CHECK_TAIL(head, headname) +#define QMD_TAILQ_CHECK_NEXT(elm, field) +#define QMD_TAILQ_CHECK_PREV(elm, field) + +#define TAILQ_CONCAT(head1, head2, field) do { \ + if (!TAILQ_EMPTY(head2)) { \ + *(head1)->tqh_last = (head2)->tqh_first; \ + (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ + (head1)->tqh_last = (head2)->tqh_last; \ + TAILQ_INIT((head2)); \ + QMD_TRACE_HEAD(head1); \ + QMD_TRACE_HEAD(head2); \ + } \ +} while (0) + +#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) + +#define TAILQ_FIRST(head) ((head)->tqh_first) + +#define TAILQ_FOREACH(var, head, field) \ + for ((var) = TAILQ_FIRST((head)); \ + (var); \ + (var) = TAILQ_NEXT((var), field)) + +#define TAILQ_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ + (var); \ + (var) = TAILQ_NEXT((var), field)) + +#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = TAILQ_FIRST((head)); \ + (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ + for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ + (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var); \ + (var) = TAILQ_PREV((var), headname, field)) + +#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \ + for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ + (var); \ + (var) = TAILQ_PREV((var), headname, field)) + +#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ + (var) = (tvar)) + +#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar) \ + for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ + (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ + (var) = (tvar)) + +#define TAILQ_INIT(head) do { \ + TAILQ_FIRST((head)) = NULL; \ + (head)->tqh_last = &TAILQ_FIRST((head)); \ + QMD_TRACE_HEAD(head); \ +} while (0) + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + QMD_TAILQ_CHECK_NEXT(listelm, field); \ + TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field); \ + if (TAILQ_NEXT((listelm), field) != NULL) \ + TAILQ_NEXT((elm), field)->field.tqe_prev = \ + &TAILQ_NEXT((elm), field); \ + else { \ + (head)->tqh_last = &TAILQ_NEXT((elm), field); \ + QMD_TRACE_HEAD(head); \ + } \ + TAILQ_NEXT((listelm), field) = (elm); \ + (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ + QMD_TRACE_ELEM(&(elm)->field); \ + QMD_TRACE_ELEM(&(listelm)->field); \ +} while (0) + +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + QMD_TAILQ_CHECK_PREV(listelm, field); \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + TAILQ_NEXT((elm), field) = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ + QMD_TRACE_ELEM(&(elm)->field); \ + QMD_TRACE_ELEM(&(listelm)->field); \ +} while (0) + +#define TAILQ_INSERT_HEAD(head, elm, field) do { \ + QMD_TAILQ_CHECK_HEAD(head, field); \ + TAILQ_NEXT((elm), field) = TAILQ_FIRST((head)); \ + if (TAILQ_FIRST((head)) != NULL) \ + TAILQ_FIRST((head))->field.tqe_prev = \ + &TAILQ_NEXT((elm), field); \ + else \ + (head)->tqh_last = &TAILQ_NEXT((elm), field); \ + TAILQ_FIRST((head)) = (elm); \ + (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ + QMD_TRACE_HEAD(head); \ + QMD_TRACE_ELEM(&(elm)->field); \ +} while (0) + +#define TAILQ_INSERT_TAIL(head, elm, field) do { \ + QMD_TAILQ_CHECK_TAIL(head, field); \ + TAILQ_NEXT((elm), field) = NULL; \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &TAILQ_NEXT((elm), field); \ + QMD_TRACE_HEAD(head); \ + QMD_TRACE_ELEM(&(elm)->field); \ +} while (0) + +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) + +/* + * The FAST function is fast in that it causes no data access other + * then the access to the head. The standard LAST function above + * will cause a data access of both the element you want and + * the previous element. FAST is very useful for instances when + * you may want to prefetch the last data element. + */ +#define TAILQ_LAST_FAST(head, type, field) \ + (TAILQ_EMPTY(head) ? NULL : __containerof((head)->tqh_last, \ + QUEUE_TYPEOF(type), field.tqe_next)) + +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) + +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) + +#define TAILQ_REMOVE(head, elm, field) do { \ + QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \ + QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \ + QMD_TAILQ_CHECK_NEXT(elm, field); \ + QMD_TAILQ_CHECK_PREV(elm, field); \ + if ((TAILQ_NEXT((elm), field)) != NULL) \ + TAILQ_NEXT((elm), field)->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else { \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + QMD_TRACE_HEAD(head); \ + } \ + *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \ + TRASHIT(*oldnext); \ + TRASHIT(*oldprev); \ + QMD_TRACE_ELEM(&(elm)->field); \ +} while (0) + +#define TAILQ_SWAP(head1, head2, type, field) do { \ + QUEUE_TYPEOF(type) * swap_first = (head1)->tqh_first; \ + QUEUE_TYPEOF(type) * *swap_last = (head1)->tqh_last; \ + (head1)->tqh_first = (head2)->tqh_first; \ + (head1)->tqh_last = (head2)->tqh_last; \ + (head2)->tqh_first = swap_first; \ + (head2)->tqh_last = swap_last; \ + swap_first = (head1)->tqh_first; \ + if (swap_first != NULL) \ + swap_first->field.tqe_prev = &(head1)->tqh_first; \ + else \ + (head1)->tqh_last = &(head1)->tqh_first; \ + swap_first = (head2)->tqh_first; \ + if (swap_first != NULL) \ + swap_first->field.tqe_prev = &(head2)->tqh_first; \ + else \ + (head2)->tqh_last = &(head2)->tqh_first; \ +} while (0) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_QUEUE_H_ */ From patchwork Thu Mar 28 02:21:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 51829 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B0F625F44; Thu, 28 Mar 2019 03:21:42 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 309065F0D for ; Thu, 28 Mar 2019 03:21:19 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2019 19:21:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,278,1549958400"; d="scan'208";a="331369618" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by fmsmga006.fm.intel.com with ESMTP; 27 Mar 2019 19:21:16 -0700 From: Anand Rawat To: dev@dpdk.org Cc: anand.rawat@intel.com, pallavi.kadam@intel.com, ranjit.menon@intel.com, jeffrey.b.shaw@intel.com, bruce.richardson@intel.com, thomas@monjalon.net Date: Wed, 27 Mar 2019 19:21:12 -0700 Message-Id: <20190328022115.4660-6-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190328022115.4660-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190328022115.4660-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v6 5/8] eal: add headers for compatibility with windows X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Added headers to support windows environment for common source. These headers will have windows specific implementions of the system library apis provided in linux and freebsd. Signed-off-by: Anand Rawat Signed-off-by: Pallavi Kadam Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon Acked-by: Harini Ramakrishnan Signed-off-by: Anand Rawat Signed-off-by: Pallavi Kadam Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon --- .../windows/eal/include/exec-env/fnmatch.h | 43 ++++++++++ .../windows/eal/include/exec-env/pthread.h | 22 +++++ .../windows/eal/include/exec-env/regex.h | 83 +++++++++++++++++++ .../windows/eal/include/exec-env/sched.h | 41 +++++++++ .../windows/eal/include/exec-env/unistd.h | 8 ++ 5 files changed, 197 insertions(+) create mode 100644 lib/librte_eal/windows/eal/include/exec-env/fnmatch.h create mode 100644 lib/librte_eal/windows/eal/include/exec-env/pthread.h create mode 100644 lib/librte_eal/windows/eal/include/exec-env/regex.h create mode 100644 lib/librte_eal/windows/eal/include/exec-env/sched.h create mode 100644 lib/librte_eal/windows/eal/include/exec-env/unistd.h diff --git a/lib/librte_eal/windows/eal/include/exec-env/fnmatch.h b/lib/librte_eal/windows/eal/include/exec-env/fnmatch.h new file mode 100644 index 000000000..c2e2131b1 --- /dev/null +++ b/lib/librte_eal/windows/eal/include/exec-env/fnmatch.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Intel Corporation + */ + +#ifndef _FNMATCH_H_ +#define _FNMATCH_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define FNM_NOMATCH 1 + +/** + * This function is used for searhing a given string source + * with the given regular expression pattern. + * + * @param pattern + * regular expression notation decribing the pattern to match + * + * @param string + * source string to searcg for the pattern + * + * @param flag + * containing information about the pattern + * + * @return + * if the pattern is found then return 0 or else FNM_NOMATCH + */ +static inline int fnmatch(__rte_unused const char *pattern, + __rte_unused const char *string, + __rte_unused int flags) +{ + /* TODO */ + /* This is a stub, not the expected result */ + return FNM_NOMATCH; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _FNMATCH_H_ */ diff --git a/lib/librte_eal/windows/eal/include/exec-env/pthread.h b/lib/librte_eal/windows/eal/include/exec-env/pthread.h new file mode 100644 index 000000000..a62b25bf6 --- /dev/null +++ b/lib/librte_eal/windows/eal/include/exec-env/pthread.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Intel Corporation + */ + +#ifndef _PTHREAD_H_ +#define _PTHREAD_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* defining pthread_t type on windows */ +typedef uintptr_t pthread_t; + +/* defining pthread_attr_t type on windows */ +typedef void *pthread_attr_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _PTHREAD_H_ */ diff --git a/lib/librte_eal/windows/eal/include/exec-env/regex.h b/lib/librte_eal/windows/eal/include/exec-env/regex.h new file mode 100644 index 000000000..daa102f74 --- /dev/null +++ b/lib/librte_eal/windows/eal/include/exec-env/regex.h @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Intel Corporation + */ + +#ifndef _REGEX_H_ +#define _REGEX_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define REG_NOMATCH 1 +#define REG_ESPACE 12 + +/* defining regex_t for windows */ +typedef void *regex_t; +/* defining regmatch_t for windows */ +typedef void *regmatch_t; + +/** + * The regcomp() function will compile the regular expression + * contained in the string pointed to by the pattern argument + * and place the results in the structure pointed to by preg. + * The cflags argument is the bitwise inclusive OR of zero or + * more of the flags + */ +static inline int regcomp(__rte_unused regex_t *preg, + __rte_unused const char *regex, __rte_unused int cflags) +{ + /* TODO */ + /* This is a stub, not the expected result */ + return REG_ESPACE; +} + +/** + * The regexec() function compares the null-terminated string + * specified by string with the compiled regular expression + * preg initialised by a previous call to regcomp(). If it finds + * a match, regexec() returns 0; otherwise it returns non-zero + * indicating either no match or an error. The eflags argument + * is the bitwise inclusive OR of zero or more of the flags. + */ +static inline int regexec(__rte_unused const regex_t *preg, + __rte_unused const char *string, __rte_unused size_t nmatch, + __rte_unused regmatch_t pmatch[], __rte_unused int eflags) +{ + /* TODO */ + /* This is a stub, not the expected result */ + return REG_NOMATCH; +} + +/** + * The regerror() function provides a mapping from error codes + * returned by regcomp() and regexec() to unspecified printable strings. + */ +static inline size_t regerror(__rte_unused int errcode, + __rte_unused const regex_t *preg, char *errbuf, + __rte_unused size_t errbuf_size) +{ + /* TODO */ + /* This is a stub, not the expected result */ + if (errbuf) { + *errbuf = '\0'; + return 1; + } + return 0; +} + +/** + * The regfree() function frees any memory allocated by regcomp() + * associated with preg. + */ +static inline void regfree(__rte_unused regex_t *preg) +{ + /* TODO */ + /* This is a stub, not the expected result */ +} + +#ifdef __cplusplus +} +#endif + +#endif /* _REGEX_H_ */ diff --git a/lib/librte_eal/windows/eal/include/exec-env/sched.h b/lib/librte_eal/windows/eal/include/exec-env/sched.h new file mode 100644 index 000000000..b105c43c3 --- /dev/null +++ b/lib/librte_eal/windows/eal/include/exec-env/sched.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Intel Corporation + */ + +#ifndef _SCHED_H_ +#define _SCHED_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef CPU_SET_SIZE +#define CPU_SET_SIZE RTE_MAX_LCORE +#endif + +#define _BITS_PER_SET (sizeof(long long) * 8) +#define _BIT_SET_MASK (_BITS_PER_SET - 1) + +#define _NUM_SETS(b) (((b) + _BIT_SET_MASK) / _BITS_PER_SET) +#define _WHICH_SET(b) ((b) / _BITS_PER_SET) +#define _WHICH_BIT(b) ((b) & (_BITS_PER_SET - 1)) + +typedef struct _rte_cpuset_s { + long long _bits[_NUM_SETS(CPU_SET_SIZE)]; +} rte_cpuset_t; + +#define CPU_SET(b, s) ((s)->_bits[_WHICH_SET(b)] |= (1LL << _WHICH_BIT(b))) + +#define CPU_ZERO(s) \ + do { \ + unsigned int _i; \ + \ + for (_i = 0; _i < _NUM_SETS(CPU_SET_SIZE); _i++) \ + (s)->_bits[_i] = 0LL; \ + } while (0) + +#ifdef __cplusplus +} +#endif + +#endif /* _SCHED_H_ */ diff --git a/lib/librte_eal/windows/eal/include/exec-env/unistd.h b/lib/librte_eal/windows/eal/include/exec-env/unistd.h new file mode 100644 index 000000000..fe3d9b579 --- /dev/null +++ b/lib/librte_eal/windows/eal/include/exec-env/unistd.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Intel Corporation + */ + +/* Added to support common code on windows */ +#ifndef _UNISTD_H_ +#define _UNISTD_H_ +#endif /* _UNISTD_H_ */ From patchwork Thu Mar 28 02:21:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 51833 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C09031B107; Thu, 28 Mar 2019 03:21:53 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id B2BAC5F13 for ; Thu, 28 Mar 2019 03:21:19 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2019 19:21:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,278,1549958400"; d="scan'208";a="331369621" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by fmsmga006.fm.intel.com with ESMTP; 27 Mar 2019 19:21:16 -0700 From: Anand Rawat To: dev@dpdk.org Cc: anand.rawat@intel.com, pallavi.kadam@intel.com, ranjit.menon@intel.com, jeffrey.b.shaw@intel.com, bruce.richardson@intel.com, thomas@monjalon.net Date: Wed, 27 Mar 2019 19:21:13 -0700 Message-Id: <20190328022115.4660-7-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190328022115.4660-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190328022115.4660-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v6 6/8] eal: add minimum viable code for eal on windows X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add windows specific logic for eal.c, eal_lcore.c, eal_debug.c and eal_thread.c. Updated header files to contain suitable function declaractions. Signed-off-by: Anand Rawat Signed-off-by: Pallavi Kadam Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon Acked-by: Harini Ramakrishnan Signed-off-by: Anand Rawat Signed-off-by: Pallavi Kadam Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon --- lib/librte_eal/windows/eal/eal.c | 76 ++++++++- lib/librte_eal/windows/eal/eal_debug.c | 14 +- lib/librte_eal/windows/eal/eal_lcore.c | 102 ++++++++++-- lib/librte_eal/windows/eal/eal_thread.c | 145 +++++++++++++++++- .../windows/eal/include/exec-env/regex.h | 2 + .../windows/eal/include/exec-env/rte_os.h | 20 +++ lib/librte_eal/windows/eal/meson.build | 2 + 7 files changed, 331 insertions(+), 30 deletions(-) diff --git a/lib/librte_eal/windows/eal/eal.c b/lib/librte_eal/windows/eal/eal.c index 37ed42233..ce460481f 100644 --- a/lib/librte_eal/windows/eal/eal.c +++ b/lib/librte_eal/windows/eal/eal.c @@ -2,13 +2,83 @@ * Copyright(c) 2019 Intel Corporation */ -#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Address of global and public configuration */ +static struct rte_config rte_config; + +/* internal configuration (per-core) */ +struct lcore_config lcore_config[RTE_MAX_LCORE]; + +/* Return a pointer to the configuration structure */ +struct rte_config * +rte_eal_get_configuration(void) +{ + return &rte_config; +} + +static int +sync_func(void *arg __rte_unused) +{ + return 0; +} + +static void +rte_eal_init_alert(const char *msg) +{ + fprintf(stderr, "EAL: FATAL: %s\n", msg); + RTE_LOG(ERR, EAL, "%s\n", msg); +} /* 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 */ + int i; + + /* create a map of all processors in the system */ + eal_create_cpu_map(); + + if (rte_eal_cpu_init() < 0) { + rte_eal_init_alert("Cannot detect lcores."); + rte_errno = ENOTSUP; + return -1; + } + + eal_thread_init_master(rte_config.master_lcore); + + RTE_LCORE_FOREACH_SLAVE(i) { + + /* + * create communication pipes between master thread + * and children + */ + if (_pipe(lcore_config[i].pipe_master2slave, + sizeof(char), _O_BINARY) < 0) + rte_panic("Cannot create pipe\n"); + if (_pipe(lcore_config[i].pipe_slave2master, + sizeof(char), _O_BINARY) < 0) + rte_panic("Cannot create pipe\n"); + + lcore_config[i].state = WAIT; + + /* create a thread for each lcore */ + if (eal_thread_create(&lcore_config[i].thread_id) != 0) + rte_panic("Cannot create thread\n"); + } + + /* + * Launch a dummy function on all slave lcores, so that master lcore + * knows they are all ready when this function returns. + */ + rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER); + rte_eal_mp_wait_lcore(); return 0; } diff --git a/lib/librte_eal/windows/eal/eal_debug.c b/lib/librte_eal/windows/eal/eal_debug.c index a9705e257..edcf257cc 100644 --- a/lib/librte_eal/windows/eal/eal_debug.c +++ b/lib/librte_eal/windows/eal/eal_debug.c @@ -2,14 +2,18 @@ * Copyright(c) 2019 Intel Corporation */ -#include +#include +#include /* call abort(), it will generate a coredump if enabled */ void -__rte_panic(const char *funcname __rte_unused, - const char *format __rte_unused, ...) +__rte_panic(const char *funcname, const char *format, ...) { - /* TODO */ - /* This is a stub, not the expected result */ + va_list ap; + + rte_log(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, "PANIC in %s():\n", funcname); + va_start(ap, format); + rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap); + va_end(ap); abort(); } diff --git a/lib/librte_eal/windows/eal/eal_lcore.c b/lib/librte_eal/windows/eal/eal_lcore.c index e4fcb2615..d39f348a3 100644 --- a/lib/librte_eal/windows/eal/eal_lcore.c +++ b/lib/librte_eal/windows/eal/eal_lcore.c @@ -2,31 +2,99 @@ * Copyright(c) 2019 Intel Corporation */ +#include + #include - /* Get the cpu core id value */ -unsigned int -eal_cpu_core_id(unsigned int lcore_id) +/* global data structure that contains the CPU map */ +static struct _wcpu_map { + unsigned int total_procs; + unsigned int proc_sockets; + unsigned int proc_cores; + unsigned int reserved; + struct _win_lcore_map { + uint8_t socket_id; + uint8_t core_id; + } wlcore_map[RTE_MAX_LCORE]; +} wcpu_map = { 0 }; + +/* + * Create a map of all processors and associated cores on the system + */ +void +eal_create_cpu_map() { - /* TODO */ - /* This is a stub, not the expected result */ - return lcore_id; + wcpu_map.total_procs = + GetActiveProcessorCount(ALL_PROCESSOR_GROUPS); + + LOGICAL_PROCESSOR_RELATIONSHIP lprocRel; + DWORD lprocInfoSize = 0; + BOOL ht_enabled = FALSE; + + /* First get the processor package information */ + lprocRel = RelationProcessorPackage; + /* Determine the size of buffer we need (pass NULL) */ + GetLogicalProcessorInformationEx(lprocRel, NULL, &lprocInfoSize); + wcpu_map.proc_sockets = lprocInfoSize / 48; + + lprocInfoSize = 0; + /* Next get the processor core information */ + lprocRel = RelationProcessorCore; + GetLogicalProcessorInformationEx(lprocRel, NULL, &lprocInfoSize); + wcpu_map.proc_cores = lprocInfoSize / 48; + + if (wcpu_map.total_procs > wcpu_map.proc_cores) + ht_enabled = TRUE; + + /* Distribute the socket and core ids appropriately + * across the logical cores. For now, split the cores + * equally across the sockets. + */ + unsigned int lcore = 0; + for (unsigned int socket = 0; socket < + wcpu_map.proc_sockets; ++socket) { + for (unsigned int core = 0; + core < (wcpu_map.proc_cores / wcpu_map.proc_sockets); + ++core) { + wcpu_map.wlcore_map[lcore] + .socket_id = socket; + wcpu_map.wlcore_map[lcore] + .core_id = core; + lcore++; + if (ht_enabled) { + wcpu_map.wlcore_map[lcore] + .socket_id = socket; + wcpu_map.wlcore_map[lcore] + .core_id = core; + lcore++; + } + } + } } -/* Check if a cpu is present by the presence of the cpu information for it */ +/* + * 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) +eal_cpu_detected(unsigned int lcore_id) +{ + return (lcore_id < wcpu_map.total_procs); +} + +/* + * Get CPU socket id for a logical core + */ +unsigned +eal_cpu_socket_id(unsigned int lcore_id) { - /* TODO */ - /* This is a stub, not the expected result */ - return 1; + return wcpu_map.wlcore_map[lcore_id].socket_id; } -/* Get CPU socket id (NUMA node) for a logical core */ -unsigned int -eal_cpu_socket_id(unsigned int cpu_id __rte_unused) +/* + * Get CPU socket id (NUMA node) for a logical core + */ +unsigned +eal_cpu_core_id(unsigned int lcore_id) { - /* TODO */ - /* This is a stub, not the expected result */ - return 0; + return wcpu_map.wlcore_map[lcore_id].core_id; } diff --git a/lib/librte_eal/windows/eal/eal_thread.c b/lib/librte_eal/windows/eal/eal_thread.c index f701443c3..906502f90 100644 --- a/lib/librte_eal/windows/eal/eal_thread.c +++ b/lib/librte_eal/windows/eal/eal_thread.c @@ -2,17 +2,152 @@ * Copyright(c) 2019 Intel Corporation */ -#include +#include +#include +#include +#include +#include +#include #include +#include -typedef uintptr_t eal_thread_t; + +RTE_DEFINE_PER_LCORE(unsigned int, _lcore_id) = LCORE_ID_ANY; + +/* + * Send a message to a slave lcore identified by slave_id to call a + * function f with argument arg. Once the execution is done, the + * remote lcore switch in FINISHED state. + */ +int +rte_eal_remote_launch(lcore_function_t *f, void *arg, unsigned int slave_id) +{ + int n; + char c = 0; + int m2s = lcore_config[slave_id].pipe_master2slave[1]; + int s2m = lcore_config[slave_id].pipe_slave2master[0]; + + if (lcore_config[slave_id].state != WAIT) + return -EBUSY; + + lcore_config[slave_id].f = f; + lcore_config[slave_id].arg = arg; + + /* send message */ + n = 0; + while (n == 0 || (n < 0 && errno == EINTR)) + n = _write(m2s, &c, 1); + if (n < 0) + rte_panic("cannot write on configuration pipe\n"); + + /* wait ack */ + do { + n = _read(s2m, &c, 1); + } while (n < 0 && errno == EINTR); + + if (n <= 0) + rte_panic("cannot read on configuration pipe\n"); + + return 0; +} + +void +eal_thread_init_master(unsigned int lcore_id) +{ + /* set the lcore ID in per-lcore memory area */ + RTE_PER_LCORE(_lcore_id) = lcore_id; +} + +static inline pthread_t +eal_thread_self(void) +{ + return GetCurrentThreadId(); +} + +/* main loop of threads */ +void * +eal_thread_loop(void *arg __rte_unused) +{ + char c; + int n, ret; + unsigned int lcore_id; + pthread_t thread_id; + int m2s, s2m; + char cpuset[RTE_CPU_AFFINITY_STR_LEN]; + + thread_id = eal_thread_self(); + + /* retrieve our lcore_id from the configuration structure */ + RTE_LCORE_FOREACH_SLAVE(lcore_id) { + if (thread_id == lcore_config[lcore_id].thread_id) + break; + } + if (lcore_id == RTE_MAX_LCORE) + rte_panic("cannot retrieve lcore id\n"); + + m2s = lcore_config[lcore_id].pipe_master2slave[0]; + s2m = lcore_config[lcore_id].pipe_slave2master[1]; + + /* set the lcore ID in per-lcore memory area */ + RTE_PER_LCORE(_lcore_id) = lcore_id; + + RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s])\n", + lcore_id, (uintptr_t)thread_id, cpuset); + + /* read on our pipe to get commands */ + while (1) { + void *fct_arg; + + /* wait command */ + do { + n = _read(m2s, &c, 1); + } while (n < 0 && errno == EINTR); + + if (n <= 0) + rte_panic("cannot read on configuration pipe\n"); + + lcore_config[lcore_id].state = RUNNING; + + /* send ack */ + n = 0; + while (n == 0 || (n < 0 && errno == EINTR)) + n = _write(s2m, &c, 1); + if (n < 0) + rte_panic("cannot write on configuration pipe\n"); + + if (lcore_config[lcore_id].f == NULL) + rte_panic("NULL function pointer\n"); + + /* call the function and store the return value */ + fct_arg = lcore_config[lcore_id].arg; + ret = lcore_config[lcore_id].f(fct_arg); + lcore_config[lcore_id].ret = ret; + rte_wmb(); + + /* when a service core returns, it should go directly to WAIT + * state, because the application will not lcore_wait() for it. + */ + if (lcore_config[lcore_id].core_role == ROLE_SERVICE) + lcore_config[lcore_id].state = WAIT; + else + lcore_config[lcore_id].state = FINISHED; + } +} /* function to create threads */ int -eal_thread_create(eal_thread_t *thread __rte_unused) +eal_thread_create(pthread_t *thread) { - /* TODO */ - /* This is a stub, not the expected result */ + HANDLE th; + + th = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)eal_thread_loop, + NULL, 0, (LPDWORD)thread); + if (!th) + return -1; + + SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); + SetThreadPriority(th, THREAD_PRIORITY_TIME_CRITICAL); + return 0; } diff --git a/lib/librte_eal/windows/eal/include/exec-env/regex.h b/lib/librte_eal/windows/eal/include/exec-env/regex.h index daa102f74..412b4edc5 100644 --- a/lib/librte_eal/windows/eal/include/exec-env/regex.h +++ b/lib/librte_eal/windows/eal/include/exec-env/regex.h @@ -12,6 +12,8 @@ extern "C" { #define REG_NOMATCH 1 #define REG_ESPACE 12 +#include + /* defining regex_t for windows */ typedef void *regex_t; /* defining regmatch_t for windows */ diff --git a/lib/librte_eal/windows/eal/include/exec-env/rte_os.h b/lib/librte_eal/windows/eal/include/exec-env/rte_os.h index 65230cae9..98b9c37cc 100644 --- a/lib/librte_eal/windows/eal/include/exec-env/rte_os.h +++ b/lib/librte_eal/windows/eal/include/exec-env/rte_os.h @@ -9,7 +9,9 @@ extern "C" { #endif +#include #include +#include /* macro substitution for windows supported strerror_r */ #define strerror_r(a, b, c) strerror_s(b, c, a) @@ -23,6 +25,24 @@ typedef SSIZE_T ssize_t; /* macro substitution for windows supported strtok_r */ #define strtok_r(str, delim, saveptr) strtok_s(str, delim, saveptr) +/** + * Create a thread. + * This function is private to EAL. + * + * @param thread + * The location to store the thread id if successful. + * @return + * 0 for success, -1 if the thread is not created. + */ +int eal_thread_create(pthread_t *thread); + +/** + * Create a map of processors and cores on the system. + * This function is private to EAL. + * + */ +void eal_create_cpu_map(void); + #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/windows/eal/meson.build b/lib/librte_eal/windows/eal/meson.build index 8b1735623..6bc577e5c 100644 --- a/lib/librte_eal/windows/eal/meson.build +++ b/lib/librte_eal/windows/eal/meson.build @@ -1,6 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2019 Intel Corporation +eal_inc += include_directories('include') + env_objs = [] env_headers = [] env_sources = files('eal.c', From patchwork Thu Mar 28 02:21:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 51832 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DD29A7D52; Thu, 28 Mar 2019 03:21:50 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id CB4295F14 for ; Thu, 28 Mar 2019 03:21:19 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2019 19:21:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,278,1549958400"; d="scan'208";a="331369624" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by fmsmga006.fm.intel.com with ESMTP; 27 Mar 2019 19:21:16 -0700 From: Anand Rawat To: dev@dpdk.org Cc: anand.rawat@intel.com, pallavi.kadam@intel.com, ranjit.menon@intel.com, jeffrey.b.shaw@intel.com, bruce.richardson@intel.com, thomas@monjalon.net Date: Wed, 27 Mar 2019 19:21:14 -0700 Message-Id: <20190328022115.4660-8-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190328022115.4660-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190328022115.4660-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v6 7/8] doc: add documentation for windows X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Added documentation to build helloworld example on windows using meson and clang. Updated the maintainers list to include windows maintainers. Signed-off-by: Pallavi Kadam Signed-off-by: Anand Rawat Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon Acked-by: Harini Ramakrishnan Signed-off-by: Pallavi Kadam Signed-off-by: Anand Rawat Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon --- MAINTAINERS | 7 +++ doc/guides/index.rst | 3 +- doc/guides/windows_gsg/build_dpdk.rst | 73 +++++++++++++++++++++++++++ doc/guides/windows_gsg/index.rst | 14 +++++ doc/guides/windows_gsg/intro.rst | 20 ++++++++ 5 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 doc/guides/windows_gsg/build_dpdk.rst create mode 100644 doc/guides/windows_gsg/index.rst create mode 100644 doc/guides/windows_gsg/intro.rst diff --git a/MAINTAINERS b/MAINTAINERS index 21e164095..d64d7ceb8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -278,6 +278,13 @@ FreeBSD UIO M: Bruce Richardson F: kernel/freebsd/nic_uio/ +Windows support +M: Harini Ramakrishnan +M: Omar Cardona +M: Anand Rawat +M: Ranjit Menon +F: lib/librte_eal/windows/ + Core Libraries -------------- diff --git a/doc/guides/index.rst b/doc/guides/index.rst index 8a9ed65c8..8a1601b27 100644 --- a/doc/guides/index.rst +++ b/doc/guides/index.rst @@ -1,5 +1,5 @@ .. SPDX-License-Identifier: BSD-3-Clause - Copyright(c) 2010-2014 Intel Corporation. + Copyright(c) 2010-2019 Intel Corporation. DPDK documentation ================== @@ -9,6 +9,7 @@ DPDK documentation linux_gsg/index freebsd_gsg/index + windows_gsg/index sample_app_ug/index prog_guide/index howto/index diff --git a/doc/guides/windows_gsg/build_dpdk.rst b/doc/guides/windows_gsg/build_dpdk.rst new file mode 100644 index 000000000..b88eb76c9 --- /dev/null +++ b/doc/guides/windows_gsg/build_dpdk.rst @@ -0,0 +1,73 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2019 Intel Corporation. + +Compiling the DPDK Target from Source +===================================== + +System Requirements +------------------- + +The DPDK and its applications require the Clang-LLVM* C compiler and MSVC* linker. +The Meson* Build system is used to prepare the sources for compilation with the Ninja backend. + +\*Other names and brands may be claimed as the property of others. + +Install the Compiler +-------------------- + +Download and install the clang compiler from `LLVM* website `_. +For example, Clang-LLVM direct download link:: + + http://releases.llvm.org/7.0.1/LLVM-7.0.1-win64.exe + + +Install the Linker +------------------ + +Download and install the Build Tools for Visual Studio to link and build the files on windows, from `Microsoft* website `_. +When installing build tools, select the "Visual C++ build tools" option and ensure the Windows SDK is selected. + + +Install the Build System +------------------------ + +Download and install the build system from `Meson* website `_. +A good option to choose is the MSI installer for both meson and ninja together:: + + http://mesonbuild.com/Getting-meson.html#installing-meson-and-ninja-with-the-msi-installer%22 + +Install the Backend +------------------- + +If using Ninja, download and install the backend from `Ninja* website `_ or +install along with the meson build system. + +Build the code +-------------- + +The build environment is setup to build the EAL and the helloworld example by +default. + +Using the ninja backend +~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: console + + cd C:\Users\me\dpdk + meson build + cd build + ninja + +Run the helloworld example +========================== + +Navigate to the build directory and run `dpdk-helloworld.exe`. + +.. code-block:: console + + cd C:\Users\me\dpdk\build + helloworld.exe + hello from core 1 + hello from core 3 + hello from core 0 + hello from core 2 diff --git a/doc/guides/windows_gsg/index.rst b/doc/guides/windows_gsg/index.rst new file mode 100644 index 000000000..d9b7990a8 --- /dev/null +++ b/doc/guides/windows_gsg/index.rst @@ -0,0 +1,14 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2019 Intel Corporation. + +.. _windows_gsg: + +Getting Started Guide for Windows +================================= + +.. toctree:: + :maxdepth: 2 + :numbered: + + intro + build_dpdk diff --git a/doc/guides/windows_gsg/intro.rst b/doc/guides/windows_gsg/intro.rst new file mode 100644 index 000000000..a0285732d --- /dev/null +++ b/doc/guides/windows_gsg/intro.rst @@ -0,0 +1,20 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2019 Intel Corporation. + +Introduction +============ + +This document contains instructions for installing and configuring the Data +Plane Development Kit (DPDK) software. The document describes how to compile +and run a DPDK application in a Windows* OS application environment, without +going deeply into detail. + +\*Other names and brands may be claimed as the property of others. + +Limitations +=========== + +DPDK for Windows is currently a work in progress. Not all DPDK source files +compile. Support is being added in pieces so as to limit the overall scope +of any individual patch series. The goal is to be able to run any DPDK +application natively on Windows. From patchwork Thu Mar 28 02:21:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 51831 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 11F846C9B; Thu, 28 Mar 2019 03:21:48 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id E42305F16 for ; Thu, 28 Mar 2019 03:21:19 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2019 19:21:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,278,1549958400"; d="scan'208";a="331369626" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by fmsmga006.fm.intel.com with ESMTP; 27 Mar 2019 19:21:16 -0700 From: Anand Rawat To: dev@dpdk.org Cc: anand.rawat@intel.com, pallavi.kadam@intel.com, ranjit.menon@intel.com, jeffrey.b.shaw@intel.com, bruce.richardson@intel.com, thomas@monjalon.net Date: Wed, 27 Mar 2019 19:21:15 -0700 Message-Id: <20190328022115.4660-9-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190328022115.4660-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190328022115.4660-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v6 8/8] build: meson changes to build on windows X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Added meson workarounds to build helloworld on windows. Windows currently only supports kvargs and eal libraries. This change restricts the build flow to supported libraries only. Signed-off-by: Anand Rawat Signed-off-by: Pallavi Kadam Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon Acked-by: Harini Ramakrishnan Signed-off-by: Anand Rawat Signed-off-by: Pallavi Kadam Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon --- app/meson.build | 6 +++++- buildtools/meson.build | 6 +++++- drivers/meson.build | 6 +++++- examples/meson.build | 6 +++++- kernel/windows/meson.build | 4 ++++ lib/librte_eal/common/meson.build | 14 +++++++++----- lib/meson.build | 4 ++++ 7 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 kernel/windows/meson.build diff --git a/app/meson.build b/app/meson.build index aa353f657..e949624b7 100644 --- a/app/meson.build +++ b/app/meson.build @@ -1,5 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2017-2019 Intel Corporation + +if host_machine.system() == 'windows' + subdir_done() +endif apps = [ 'pdump', diff --git a/buildtools/meson.build b/buildtools/meson.build index cdd38ed24..0209bec8f 100644 --- a/buildtools/meson.build +++ b/buildtools/meson.build @@ -1,5 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2017-2019 Intel Corporation + +if host_machine.system() == 'windows' + subdir_done() +endif subdir('pmdinfogen') diff --git a/drivers/meson.build b/drivers/meson.build index 8c76a5659..7520a16e3 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -1,5 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2017-2019 Intel Corporation + +if host_machine.system() == 'windows' + subdir_done() +endif # Defines the order in which the drivers are buit. dpdk_driver_classes = ['common', diff --git a/examples/meson.build b/examples/meson.build index af81c762e..bc1430fa8 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -35,7 +35,11 @@ foreach example: examples ext_deps = [execinfo] includes = [include_directories(example)] - deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline'] + if host_machine.system() != 'windows' + deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline'] + else + deps = ['eal'] # only supported lib on windows currently + endif subdir(example) if build diff --git a/kernel/windows/meson.build b/kernel/windows/meson.build new file mode 100644 index 000000000..c4a2a656a --- /dev/null +++ b/kernel/windows/meson.build @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2019 Intel Corporation + +# stub file for supporting windows logic in future release \ No newline at end of file diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build index 5ecae0b1f..e9021c00c 100644 --- a/lib/librte_eal/common/meson.build +++ b/lib/librte_eal/common/meson.build @@ -1,23 +1,26 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2017-2019 Intel Corporation eal_inc += include_directories('.', 'include', join_paths('include/arch', arch_subdir)) common_objs = [] +common_sources = files( + 'eal_common_errno.c', + 'eal_common_launch.c', + 'eal_common_lcore.c', + 'eal_common_log.c' + ) +if host_machine.system() != 'windows' common_sources = files( 'eal_common_bus.c', 'eal_common_cpuflags.c', 'eal_common_class.c', 'eal_common_devargs.c', 'eal_common_dev.c', - 'eal_common_errno.c', 'eal_common_fbarray.c', 'eal_common_hexdump.c', 'eal_common_hypervisor.c', - 'eal_common_launch.c', - 'eal_common_lcore.c', - 'eal_common_log.c', 'eal_common_memalloc.c', 'eal_common_memory.c', 'eal_common_memzone.c', @@ -38,6 +41,7 @@ common_sources = files( 'rte_reciprocal.c', 'rte_service.c' ) +endif # get architecture specific sources and objs eal_common_arch_sources = [] diff --git a/lib/meson.build b/lib/meson.build index 9cba4662e..d3e556ae3 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -30,6 +30,10 @@ libraries = [ # flow_classify lib depends on pkt framework table lib 'flow_classify', 'bpf', 'telemetry'] +if host_machine.system() == 'windows' + libraries = ['kvargs','eal'] # override libraries for windows +endif + default_cflags = machine_args if cc.has_argument('-Wno-format-truncation') default_cflags += '-Wno-format-truncation'