From patchwork Tue Apr 2 03:54:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 52037 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 6A8A058F6; Tue, 2 Apr 2019 05:55:05 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 954D854AE for ; Tue, 2 Apr 2019 05:55:01 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 20:55:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,298,1549958400"; d="scan'208";a="287910248" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by orsmga004.jf.intel.com with ESMTP; 01 Apr 2019 20:54:59 -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: Mon, 1 Apr 2019 20:54:49 -0700 Message-Id: <20190402035458.14664-2-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190402035458.14664-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190402035458.14664-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v8 01/10] 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. Updated the MAINTAINERS list for windows support. Signed-off-by: Pallavi Kadam Signed-off-by: Anand Rawat Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon --- MAINTAINERS | 7 ++++++ 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 ++++++++++++++ 5 files changed, 86 insertions(+) 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 diff --git a/MAINTAINERS b/MAINTAINERS index 9f34f905f..5d70fba9b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -283,6 +283,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/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; +} From patchwork Tue Apr 2 03:54:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 52038 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 7C0525B12; Tue, 2 Apr 2019 05:55:07 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id E0A735699 for ; Tue, 2 Apr 2019 05:55:01 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 20:55:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,298,1549958400"; d="scan'208";a="287910251" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by orsmga004.jf.intel.com with ESMTP; 01 Apr 2019 20:54:59 -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: Mon, 1 Apr 2019 20:54:50 -0700 Message-Id: <20190402035458.14664-3-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190402035458.14664-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190402035458.14664-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v8 02/10] meson: required changes 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" These are the required meson changes for Windows. kernel/windows/meson is a stub file added to support Windows specific source in future releases. Signed-off-by: Anand Rawat Signed-off-by: Pallavi Kadam Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon --- config/meson.build | 23 ++++++++++++++++------- config/x86/meson.build | 14 ++++++++------ kernel/windows/meson.build | 4 ++++ lib/librte_eal/meson.build | 6 +++++- lib/librte_eal/windows/eal/meson.build | 10 ++++++++++ 5 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 kernel/windows/meson.build create mode 100644 lib/librte_eal/windows/eal/meson.build diff --git a/config/meson.build b/config/meson.build index 30a7261a5..483139b10 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('libm', 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/kernel/windows/meson.build b/kernel/windows/meson.build new file mode 100644 index 000000000..94c47682d --- /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 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/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 Tue Apr 2 03:54:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 52039 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 1D2B35B2E; Tue, 2 Apr 2019 05:55:10 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 37EB356A3 for ; Tue, 2 Apr 2019 05:55:02 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 20:55:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,298,1549958400"; d="scan'208";a="287910254" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by orsmga004.jf.intel.com with ESMTP; 01 Apr 2019 20:55:00 -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: Mon, 1 Apr 2019 20:54:51 -0700 Message-Id: <20190402035458.14664-4-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190402035458.14664-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190402035458.14664-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v8 03/10] eal: add new rte_os.h header to build system 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 build system to contain OS headers in the include path. Signed-off-by: Anand Rawat Reviewed-by: Pallavi Kadam --- lib/librte_eal/freebsd/eal/Makefile | 4 ++-- lib/librte_eal/freebsd/eal/include/rte_os.h | 14 ++++++++++++++ lib/librte_eal/linux/eal/Makefile | 3 ++- lib/librte_eal/linux/eal/include/rte_os.h | 14 ++++++++++++++ lib/librte_eal/windows/eal/include/rte_os.h | 14 ++++++++++++++ meson.build | 6 ++++-- mk/exec-env/freebsd/rte.vars.mk | 5 ++++- mk/exec-env/linux/rte.vars.mk | 5 ++++- 8 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 lib/librte_eal/freebsd/eal/include/rte_os.h create mode 100644 lib/librte_eal/linux/eal/include/rte_os.h create mode 100644 lib/librte_eal/windows/eal/include/rte_os.h diff --git a/lib/librte_eal/freebsd/eal/Makefile b/lib/librte_eal/freebsd/eal/Makefile index 55d476e5b..19854ee2c 100644 --- a/lib/librte_eal/freebsd/eal/Makefile +++ b/lib/librte_eal/freebsd/eal/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2010-2015 Intel Corporation +# Copyright(c) 2010-2019 Intel Corporation include $(RTE_SDK)/mk/rte.vars.mk @@ -86,7 +86,7 @@ CFLAGS_eal_thread.o += -Wno-return-type CFLAGS_eal_hpet.o += -Wno-return-type endif -INC := # no bsd specific headers +INC := rte_os.h SYMLINK-$(CONFIG_RTE_EXEC_ENV_FREEBSD)-include := $(addprefix include/,$(INC)) diff --git a/lib/librte_eal/freebsd/eal/include/rte_os.h b/lib/librte_eal/freebsd/eal/include/rte_os.h new file mode 100644 index 000000000..49cd4d4d9 --- /dev/null +++ b/lib/librte_eal/freebsd/eal/include/rte_os.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2019 Intel Corporation + */ + +#ifndef _RTE_OS_H_ +#define _RTE_OS_H_ + +/** + * This is header should contain any function/macro definition + * which are not supported natively or named differently in the + * freebsd OS. Functions will be added in future releases. + */ + +#endif /* _RTE_OS_H_ */ diff --git a/lib/librte_eal/linux/eal/Makefile b/lib/librte_eal/linux/eal/Makefile index 2aa6e8c6a..6e5261152 100644 --- a/lib/librte_eal/linux/eal/Makefile +++ b/lib/librte_eal/linux/eal/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2010-2016 Intel Corporation +# Copyright(c) 2010-2019 Intel Corporation include $(RTE_SDK)/mk/rte.vars.mk @@ -94,6 +94,7 @@ CFLAGS_eal_thread.o += -Wno-return-type endif INC := rte_kni_common.h +INC += rte_os.h SYMLINK-$(CONFIG_RTE_EXEC_ENV_LINUX)-include := $(addprefix include/,$(INC)) diff --git a/lib/librte_eal/linux/eal/include/rte_os.h b/lib/librte_eal/linux/eal/include/rte_os.h new file mode 100644 index 000000000..bc6ad14d2 --- /dev/null +++ b/lib/librte_eal/linux/eal/include/rte_os.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2019 Intel Corporation + */ + +#ifndef _RTE_OS_H_ +#define _RTE_OS_H_ + +/** + * This is header should contain any function/macro definition + * which are not supported natively or named differently in the + * linux OS. Functions will be added in future releases. + */ + +#endif /* _RTE_OS_H_ */ diff --git a/lib/librte_eal/windows/eal/include/rte_os.h b/lib/librte_eal/windows/eal/include/rte_os.h new file mode 100644 index 000000000..421ed8e7f --- /dev/null +++ b/lib/librte_eal/windows/eal/include/rte_os.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2019 Intel Corporation + */ + +#ifndef _RTE_OS_H_ +#define _RTE_OS_H_ + +/** + * This is header should contain any function/macro definition + * which are not supported natively or named differently in the + * Windows OS. Functions will be added in future releases. + */ + +#endif /* _RTE_OS_H_ */ diff --git a/meson.build b/meson.build index 6061c4b1e..5a93c1f1a 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2017-2019 Intel Corporation project('DPDK', 'C', # Get version number from file. @@ -24,7 +24,9 @@ dpdk_app_link_libraries = [] # configure the build, and make sure configs here and in config folder are # able to be included in any file. We also store a global array of include dirs # for passing to pmdinfogen scripts -global_inc = include_directories('.', 'config', 'lib/librte_eal/common/include') +global_inc = include_directories('.', 'config', + 'lib/librte_eal/common/include', + 'lib/librte_eal/@0@/eal/include'.format(host_machine.system())) subdir('config') # build libs and drivers diff --git a/mk/exec-env/freebsd/rte.vars.mk b/mk/exec-env/freebsd/rte.vars.mk index c6be560b3..3608530d3 100644 --- a/mk/exec-env/freebsd/rte.vars.mk +++ b/mk/exec-env/freebsd/rte.vars.mk @@ -1,5 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2010-2014 Intel Corporation +# Copyright(c) 2010-2019 Intel Corporation # # exec-env: @@ -17,6 +17,9 @@ else EXECENV_CFLAGS = -pthread endif +# include in every library to build +EXECENV_CFLAGS += -I$(RTE_SDK)/lib/librte_eal/freebsd/eal/include + EXECENV_LDFLAGS = EXECENV_LDLIBS = -lexecinfo EXECENV_ASFLAGS = diff --git a/mk/exec-env/linux/rte.vars.mk b/mk/exec-env/linux/rte.vars.mk index d04d0e29c..bea3f7657 100644 --- a/mk/exec-env/linux/rte.vars.mk +++ b/mk/exec-env/linux/rte.vars.mk @@ -1,5 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2010-2014 Intel Corporation +# Copyright(c) 2010-2019 Intel Corporation # # exec-env: @@ -17,6 +17,9 @@ else EXECENV_CFLAGS = -pthread endif +# include in every library to build +EXECENV_CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linux/eal/include + EXECENV_LDLIBS = EXECENV_ASFLAGS = From patchwork Tue Apr 2 03:54:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 52040 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 3F9CA5F0D; Tue, 2 Apr 2019 05:55:12 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id ABD9058C4 for ; Tue, 2 Apr 2019 05:55:02 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 20:55:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,298,1549958400"; d="scan'208";a="287910258" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by orsmga004.jf.intel.com with ESMTP; 01 Apr 2019 20:55:00 -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: Mon, 1 Apr 2019 20:54:52 -0700 Message-Id: <20190402035458.14664-5-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190402035458.14664-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190402035458.14664-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v8 04/10] eal: update common headers to use rte_os.h 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 rte_common.h to include rte_os.h to contain OS specific macros and functions. Updated rte_string_fns.h to include rte_common.h for rte_os.h Signed-off-by: Anand Rawat Reviewed-by: Pallavi Kadam Reviewed-by: Ranjit Menon --- lib/librte_eal/common/include/rte_common.h | 5 ++++- .../common/include/rte_string_fns.h | 4 +++- lib/librte_eal/windows/eal/include/rte_os.h | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) 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/windows/eal/include/rte_os.h b/lib/librte_eal/windows/eal/include/rte_os.h index 421ed8e7f..8da1e235f 100644 --- a/lib/librte_eal/windows/eal/include/rte_os.h +++ b/lib/librte_eal/windows/eal/include/rte_os.h @@ -11,4 +11,23 @@ * Windows OS. Functions will be added in future releases. */ +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define strerror_r(a, b, c) strerror_s(b, c, a) + +/* strdup is deprecated in Microsoft libc and _strdup is preferred */ +#define strdup(str) _strdup(str) + +typedef SSIZE_T ssize_t; + +#define strtok_r(str, delim, saveptr) strtok_s(str, delim, saveptr) + +#ifdef __cplusplus +} +#endif + #endif /* _RTE_OS_H_ */ From patchwork Tue Apr 2 03:54:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 52041 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 C23625F17; Tue, 2 Apr 2019 05:55:13 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id D7D8F5699 for ; Tue, 2 Apr 2019 05:55:02 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 20:55:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,298,1549958400"; d="scan'208";a="287910261" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by orsmga004.jf.intel.com with ESMTP; 01 Apr 2019 20:55:00 -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: Mon, 1 Apr 2019 20:54:53 -0700 Message-Id: <20190402035458.14664-6-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190402035458.14664-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190402035458.14664-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v8 05/10] 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 --- lib/librte_eal/rte_eal_exports.def | 9 +++++++++ lib/librte_kvargs/rte_kvargs_exports.def | 7 +++++++ lib/meson.build | 15 ++++++++++++--- 3 files changed, 28 insertions(+), 3 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 99957ba7d..a7b5a9194 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 @@ -117,14 +117,23 @@ 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 = [] + implib = dir_name + '.dll.a' + if host_machine.system() == 'windows' + exports = '@0@/@1@/rte_@2@_exports.def'.format( + meson.current_source_dir(), dir_name, name) + 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 Tue Apr 2 03:54:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 52044 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 AE6F55F62; Tue, 2 Apr 2019 05:55:18 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 4CE6B56A3 for ; Tue, 2 Apr 2019 05:55:03 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 20:55:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,298,1549958400"; d="scan'208";a="287910264" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by orsmga004.jf.intel.com with ESMTP; 01 Apr 2019 20:55:00 -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: Mon, 1 Apr 2019 20:54:54 -0700 Message-Id: <20190402035458.14664-7-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190402035458.14664-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190402035458.14664-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v8 06/10] 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 implementation has BSD-3-Clause licensing. 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 Tue Apr 2 03:54:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 52043 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 140205F34; Tue, 2 Apr 2019 05:55:17 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 4E55E58CB for ; Tue, 2 Apr 2019 05:55:03 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 20:55:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,298,1549958400"; d="scan'208";a="287910269" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by orsmga004.jf.intel.com with ESMTP; 01 Apr 2019 20:55:00 -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: Mon, 1 Apr 2019 20:54:55 -0700 Message-Id: <20190402035458.14664-8-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190402035458.14664-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190402035458.14664-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v8 07/10] 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 --- lib/librte_eal/windows/eal/include/fnmatch.h | 48 +++++++++++ lib/librte_eal/windows/eal/include/pthread.h | 27 ++++++ lib/librte_eal/windows/eal/include/regex.h | 88 ++++++++++++++++++++ lib/librte_eal/windows/eal/include/sched.h | 46 ++++++++++ lib/librte_eal/windows/eal/include/unistd.h | 12 +++ 5 files changed, 221 insertions(+) create mode 100644 lib/librte_eal/windows/eal/include/fnmatch.h create mode 100644 lib/librte_eal/windows/eal/include/pthread.h create mode 100644 lib/librte_eal/windows/eal/include/regex.h create mode 100644 lib/librte_eal/windows/eal/include/sched.h create mode 100644 lib/librte_eal/windows/eal/include/unistd.h diff --git a/lib/librte_eal/windows/eal/include/fnmatch.h b/lib/librte_eal/windows/eal/include/fnmatch.h new file mode 100644 index 000000000..41b574312 --- /dev/null +++ b/lib/librte_eal/windows/eal/include/fnmatch.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Intel Corporation + */ + +#ifndef _FNMATCH_H_ +#define _FNMATCH_H_ + +/** + * This file is required to support the common code in eal_common_log.c + * as Microsoft libc does not contain fnmatch.h. This may be removed in + * future releases. + */ +#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/pthread.h b/lib/librte_eal/windows/eal/include/pthread.h new file mode 100644 index 000000000..503329266 --- /dev/null +++ b/lib/librte_eal/windows/eal/include/pthread.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Intel Corporation + */ + +#ifndef _PTHREAD_H_ +#define _PTHREAD_H_ + +/** + * This file is required to support the common code in eal_common_proc.c, + * eal_common_thread.c and common\include\rte_per_lcore.h as Microsoft libc + * does not contain pthread.h. This may be removed in future releases. + */ +#ifdef __cplusplus +extern "C" { +#endif + +/* defining pthread_t type on Windows since there is no in Microsoft libc*/ +typedef uintptr_t pthread_t; + +/* defining pthread_attr_t type on Windows since there is no in Microsoft libc*/ +typedef void *pthread_attr_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _PTHREAD_H_ */ diff --git a/lib/librte_eal/windows/eal/include/regex.h b/lib/librte_eal/windows/eal/include/regex.h new file mode 100644 index 000000000..c335120e1 --- /dev/null +++ b/lib/librte_eal/windows/eal/include/regex.h @@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Intel Corporation + */ + +#ifndef _REGEX_H_ +#define _REGEX_H_ + +/** + * This file is required to support the common code in eal_common_log.c + * as Microsoft libc does not contain regex.h. This may be removed in + * future releases. + */ +#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/sched.h b/lib/librte_eal/windows/eal/include/sched.h new file mode 100644 index 000000000..257060594 --- /dev/null +++ b/lib/librte_eal/windows/eal/include/sched.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Intel Corporation + */ + +#ifndef _SCHED_H_ +#define _SCHED_H_ + +/** + * This file is added to support the common code in eal_common_thread.c + * as Microsoft libc does not contain sched.h. This may be removed + * in future releases. + */ +#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/unistd.h b/lib/librte_eal/windows/eal/include/unistd.h new file mode 100644 index 000000000..757b7f3c5 --- /dev/null +++ b/lib/librte_eal/windows/eal/include/unistd.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Intel Corporation + */ + +#ifndef _UNISTD_H_ +#define _UNISTD_H_ +/** + * This file is added to support common code in eal_common_lcore.c + * as Microsoft libc does not contain unistd.h. This may be removed + * in future releases. + */ +#endif /* _UNISTD_H_ */ From patchwork Tue Apr 2 03:54:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 52042 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 6C1F45F21; Tue, 2 Apr 2019 05:55:15 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 814265699 for ; Tue, 2 Apr 2019 05:55:03 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 20:55:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,298,1549958400"; d="scan'208";a="287910273" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by orsmga004.jf.intel.com with ESMTP; 01 Apr 2019 20:55:00 -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: Mon, 1 Apr 2019 20:54:56 -0700 Message-Id: <20190402035458.14664-9-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190402035458.14664-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190402035458.14664-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v8 08/10] 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 --- 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 +++++++++++++++++++- lib/librte_eal/windows/eal/include/regex.h | 2 + lib/librte_eal/windows/eal/include/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/regex.h b/lib/librte_eal/windows/eal/include/regex.h index c335120e1..827f93841 100644 --- a/lib/librte_eal/windows/eal/include/regex.h +++ b/lib/librte_eal/windows/eal/include/regex.h @@ -17,6 +17,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/rte_os.h b/lib/librte_eal/windows/eal/include/rte_os.h index 8da1e235f..4946af041 100644 --- a/lib/librte_eal/windows/eal/include/rte_os.h +++ b/lib/librte_eal/windows/eal/include/rte_os.h @@ -15,7 +15,9 @@ extern "C" { #endif +#include #include +#include #define strerror_r(a, b, c) strerror_s(b, c, a) @@ -26,6 +28,24 @@ typedef SSIZE_T ssize_t; #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 Tue Apr 2 03:54:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 52045 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 501266C9B; Tue, 2 Apr 2019 05:55:20 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id F1E7258F6 for ; Tue, 2 Apr 2019 05:55:03 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 20:55:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,298,1549958400"; d="scan'208";a="287910276" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by orsmga004.jf.intel.com with ESMTP; 01 Apr 2019 20:55:01 -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: Mon, 1 Apr 2019 20:54:57 -0700 Message-Id: <20190402035458.14664-10-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190402035458.14664-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190402035458.14664-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v8 09/10] 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. Signed-off-by: Pallavi Kadam Signed-off-by: Anand Rawat Reviewed-by: Jeff Shaw Reviewed-by: Ranjit Menon --- MAINTAINERS | 1 + doc/guides/index.rst | 3 +- doc/guides/windows_gsg/build_dpdk.rst | 81 +++++++++++++++++++++++++++ doc/guides/windows_gsg/index.rst | 14 +++++ doc/guides/windows_gsg/intro.rst | 20 +++++++ 5 files changed, 118 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 5d70fba9b..5273639f4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -289,6 +289,7 @@ M: Omar Cardona M: Anand Rawat M: Ranjit Menon F: lib/librte_eal/windows/ +F: doc/guides/windows_gsg/ 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..f48805236 --- /dev/null +++ b/doc/guides/windows_gsg/build_dpdk.rst @@ -0,0 +1,81 @@ +.. 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 Microsoft MSVC linker. +The Meson Build system is used to prepare the sources for compilation +with the Ninja backend. +The installation of these tools is covered in this section. + + +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 Tue Apr 2 03:54:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Rawat X-Patchwork-Id: 52046 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 E791A7CEB; Tue, 2 Apr 2019 05:55:21 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 26CB65920 for ; Tue, 2 Apr 2019 05:55:03 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 20:55:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,298,1549958400"; d="scan'208";a="287910279" Received: from anandraw-devbx.amr.corp.intel.com ([10.19.242.57]) by orsmga004.jf.intel.com with ESMTP; 01 Apr 2019 20:55:01 -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: Mon, 1 Apr 2019 20:54:58 -0700 Message-Id: <20190402035458.14664-11-anand.rawat@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190402035458.14664-1-anand.rawat@intel.com> References: <20190306041634.12976-1-anand.rawat@intel.com> <20190402035458.14664-1-anand.rawat@intel.com> Subject: [dpdk-dev] [PATCH v8 10/10] 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 --- app/meson.build | 6 +++++- buildtools/meson.build | 6 +++++- drivers/meson.build | 6 +++++- examples/meson.build | 6 ++++-- lib/librte_eal/windows/eal/meson.build | 6 ++++++ lib/meson.build | 4 ++++ 6 files changed, 29 insertions(+), 5 deletions(-) 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..3bf1c2db8 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -1,5 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2017-2019 Intel Corporation driver_libs = [] if get_option('default_library') == 'static' @@ -35,7 +35,9 @@ foreach example: examples ext_deps = [execinfo] includes = [include_directories(example)] - deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline'] + if host_machine.system() == 'windows' + deps = ['eal'] # only supported lib on Windows currently + endif subdir(example) if build diff --git a/lib/librte_eal/windows/eal/meson.build b/lib/librte_eal/windows/eal/meson.build index 6bc577e5c..e9b7138c5 100644 --- a/lib/librte_eal/windows/eal/meson.build +++ b/lib/librte_eal/windows/eal/meson.build @@ -5,6 +5,12 @@ eal_inc += include_directories('include') env_objs = [] env_headers = [] +common_sources = files( + '../../common/eal_common_errno.c', + '../../common/eal_common_launch.c', + '../../common/eal_common_lcore.c', + '../../common/eal_common_log.c' +) env_sources = files('eal.c', 'eal_debug.c', 'eal_lcore.c', diff --git a/lib/meson.build b/lib/meson.build index a7b5a9194..c3289f885 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'] # only supported libraries for windows +endif + default_cflags = machine_args if cc.has_argument('-Wno-format-truncation') default_cflags += '-Wno-format-truncation'