From: Pallavi Kadam <pallavi.kadam@intel.com>
To: dev@dpdk.org, thomas@monjalon.net, Harini.Ramakrishnan@microsoft.com
Cc: keith.wiles@intel.com, bruce.richardson@intel.com,
david.marchand@redhat.com, jerinjacobk@gmail.com,
ranjit.menon@intel.com, antara.ganesh.kolar@intel.com,
pallavi.kadam@intel.com
Subject: [dpdk-dev] [PATCH v3 7/9] eal: add function to detect process type
Date: Tue, 22 Oct 2019 13:02:25 -0700 [thread overview]
Message-ID: <20191022200227.1920-8-pallavi.kadam@intel.com> (raw)
In-Reply-To: <20191022200227.1920-1-pallavi.kadam@intel.com>
Adding a function to detect process type and include
header files to contain suitable function declarations.
Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Signed-off-by: Antara Ganesh Kolar <antara.ganesh.kolar@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
Reviewed-by: Keith Wiles <keith.wiles@intel.com>
---
lib/librte_eal/windows/eal/eal.c | 51 ++++++++++++++++++++++++-
lib/librte_eal/windows/eal/eal_thread.c | 3 ++
2 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/lib/librte_eal/windows/eal/eal.c b/lib/librte_eal/windows/eal/eal.c
index 83907ffa6..ffe5b8552 100644
--- a/lib/librte_eal/windows/eal/eal.c
+++ b/lib/librte_eal/windows/eal/eal.c
@@ -2,21 +2,38 @@
* Copyright(c) 2019 Intel Corporation
*/
+#include <sys/stat.h>
#include <io.h>
#include <fcntl.h>
#include <rte_debug.h>
#include <rte_eal.h>
+#include <eal_memcfg.h>
#include <rte_errno.h>
#include <rte_lcore.h>
#include <eal_thread.h>
+#include <eal_internal_cfg.h>
+#include <eal_filesystem.h>
#include <eal_private.h>
+/* define fd variable here, because file needs to be kept open for the
+ * duration of the program, as we hold a write lock on it in the primary proc
+ */
+static int mem_cfg_fd = -1; // INVALID_HANDLE_VALUE;
+
+/* early configuration structure, when memory config is not mmapped */
+static struct rte_mem_config early_mem_config;
+
/* Address of global and public configuration */
-static struct rte_config rte_config;
+static struct rte_config rte_config = {
+ .mem_config = &early_mem_config,
+};
/* internal configuration (per-core) */
struct lcore_config lcore_config[RTE_MAX_LCORE];
+/* internal configuration */
+struct internal_config internal_config;
+
/* Return a pointer to the configuration structure */
struct rte_config *
rte_eal_get_configuration(void)
@@ -24,6 +41,38 @@ rte_eal_get_configuration(void)
return &rte_config;
}
+/* Detect if we are a primary or a secondary process */
+enum rte_proc_type_t
+ eal_proc_type_detect(void)
+{
+ enum rte_proc_type_t ptype = RTE_PROC_PRIMARY;
+ const char *pathname = eal_runtime_config_path();
+
+ /* if we can open the file but not get a write-lock we are a secondary
+ * process. NOTE: if we get a file handle back, we keep that open
+ * and don't close it to prevent a race condition between multiple opens
+ */
+ errno_t err = _sopen_s(&mem_cfg_fd, pathname,
+ _O_RDWR, _SH_DENYNO, _S_IREAD | _S_IWRITE);
+ if (err == 0) {
+ OVERLAPPED sOverlapped = { 0 };
+ sOverlapped.Offset = sizeof(*rte_config.mem_config);
+ sOverlapped.OffsetHigh = 0;
+
+ HANDLE hWinFileHandle = (HANDLE)_get_osfhandle(mem_cfg_fd);
+
+ if (!LockFileEx(hWinFileHandle,
+ LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0,
+ sizeof(*rte_config.mem_config), 0, &sOverlapped))
+ ptype = RTE_PROC_SECONDARY;
+ }
+
+ RTE_LOG(INFO, EAL, "Auto-detected process type: %s\n",
+ ptype == RTE_PROC_PRIMARY ? "PRIMARY" : "SECONDARY");
+
+ return ptype;
+}
+
/* Parse the arguments for --log-level only */
static void
eal_log_level_parse(__rte_unused int argc, __rte_unused char **argv)
diff --git a/lib/librte_eal/windows/eal/eal_thread.c b/lib/librte_eal/windows/eal/eal_thread.c
index 6e5e6f4ab..54b9c1dd1 100644
--- a/lib/librte_eal/windows/eal/eal_thread.c
+++ b/lib/librte_eal/windows/eal/eal_thread.c
@@ -10,10 +10,13 @@
#include <rte_lcore.h>
#include <rte_per_lcore.h>
#include <rte_common.h>
+#include <rte_memory.h>
#include <eal_thread.h>
RTE_DEFINE_PER_LCORE(unsigned int, _lcore_id) = LCORE_ID_ANY;
+RTE_DEFINE_PER_LCORE(unsigned int, _socket_id) = (unsigned int)SOCKET_ID_ANY;
+RTE_DEFINE_PER_LCORE(rte_cpuset_t, _cpuset);
/*
* Send a message to a slave lcore identified by slave_id to call a
--
2.18.0.windows.1
next prev parent reply other threads:[~2019-10-22 20:29 UTC|newest]
Thread overview: 149+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-06 22:09 [dpdk-dev] [PATCH 0/9] Windows patchset with additional EAL functionalities Pallavi Kadam
2019-09-06 22:09 ` [dpdk-dev] [PATCH 1/9] eal: eal stub to support parsing feature on windows Pallavi Kadam
2019-09-06 22:09 ` [dpdk-dev] [PATCH 2/9] eal: syslog implementation for windows Pallavi Kadam
2019-09-06 22:09 ` [dpdk-dev] [PATCH 3/9] eal: add windows compatible header files Pallavi Kadam
2019-09-06 22:09 ` [dpdk-dev] [PATCH 4/9] eal: dirent.h implementation for windows Pallavi Kadam
2019-09-06 22:09 ` [dpdk-dev] [PATCH 5/9] eal: add additional function overrides in windows header files Pallavi Kadam
2019-09-06 22:09 ` [dpdk-dev] [PATCH 6/9] eal: getopt implementation for windows Pallavi Kadam
2019-09-06 22:09 ` [dpdk-dev] [PATCH 7/9] eal: add function to detect process type Pallavi Kadam
2019-09-06 22:09 ` [dpdk-dev] [PATCH 8/9] build: add additional common files support Pallavi Kadam
2019-09-06 22:09 ` [dpdk-dev] [PATCH 9/9] eal: add minimum viable code to support parsing Pallavi Kadam
2019-09-09 19:53 ` [dpdk-dev] [PATCH 0/9] Windows patchset with additional EAL functionalities Pallavi Kadam
2019-09-09 19:53 ` [dpdk-dev] [PATCH 1/9] eal: eal stub to support parsing feature on windows Pallavi Kadam
2019-09-09 19:53 ` [dpdk-dev] [PATCH 2/9] eal: syslog implementation for windows Pallavi Kadam
2019-09-10 9:17 ` Stephen Hemminger
2019-09-25 23:38 ` Pallavi Kadam
2019-09-09 19:53 ` [dpdk-dev] [PATCH 3/9] eal: add windows compatible header files Pallavi Kadam
2019-09-10 9:19 ` Stephen Hemminger
2019-09-12 17:11 ` Pallavi Kadam
2019-09-12 21:36 ` Stephen Hemminger
2019-09-09 19:53 ` [dpdk-dev] [PATCH 4/9] eal: dirent.h implementation for windows Pallavi Kadam
2019-09-09 19:54 ` [dpdk-dev] [PATCH 5/9] eal: add additional function overrides in windows header files Pallavi Kadam
2019-09-09 19:54 ` [dpdk-dev] [PATCH 6/9] eal: getopt implementation for windows Pallavi Kadam
2019-09-12 21:40 ` Stephen Hemminger
2019-09-13 9:46 ` Bruce Richardson
2019-09-13 17:23 ` Pallavi Kadam
2019-09-09 19:54 ` [dpdk-dev] [PATCH 7/9] eal: add function to detect process type Pallavi Kadam
2019-09-09 19:54 ` [dpdk-dev] [PATCH 8/9] build: add additional common files support Pallavi Kadam
2019-09-09 19:54 ` [dpdk-dev] [PATCH 9/9] eal: add minimum viable code to support parsing Pallavi Kadam
2019-09-26 20:29 ` [dpdk-dev] [PATCH v2 0/9] Windows patchset with additional EAL functionalities Pallavi Kadam
2019-09-26 20:29 ` [dpdk-dev] [PATCH v2 1/9] eal: eal stub to support parsing feature on windows Pallavi Kadam
2019-09-26 20:29 ` [dpdk-dev] [PATCH v2 2/9] eal: syslog implementation for windows Pallavi Kadam
2019-09-26 20:29 ` [dpdk-dev] [PATCH v2 3/9] eal: add windows compatible header files Pallavi Kadam
2019-09-27 7:58 ` Jerin Jacob
2019-09-30 17:49 ` Pallavi Kadam
2019-10-01 5:56 ` Jerin Jacob
2019-10-03 0:40 ` Pallavi Kadam
2019-09-26 20:29 ` [dpdk-dev] [PATCH v2 4/9] eal: dirent.h implementation for windows Pallavi Kadam
2019-09-26 20:29 ` [dpdk-dev] [PATCH v2 5/9] eal: add additional function overrides in windows header files Pallavi Kadam
2019-09-27 8:06 ` Jerin Jacob
2019-09-30 23:11 ` Pallavi Kadam
2019-09-26 20:29 ` [dpdk-dev] [PATCH v2 6/9] eal: getopt implementation for windows Pallavi Kadam
2019-09-26 21:27 ` Stephen Hemminger
2019-09-26 23:26 ` Pallavi Kadam
2019-09-26 20:29 ` [dpdk-dev] [PATCH v2 7/9] eal: add function to detect process type Pallavi Kadam
2019-09-26 20:29 ` [dpdk-dev] [PATCH v2 8/9] build: add additional common files support Pallavi Kadam
2019-09-26 20:29 ` [dpdk-dev] [PATCH v2 9/9] eal: add minimum viable code to support parsing Pallavi Kadam
2019-10-22 20:02 ` [dpdk-dev] [PATCH v3 0/9] Windows patchset with additional EAL functionalities Pallavi Kadam
2019-10-22 20:02 ` [dpdk-dev] [PATCH v3 1/9] eal: eal stub to support parsing feature on windows Pallavi Kadam
2019-10-22 20:02 ` [dpdk-dev] [PATCH v3 2/9] eal: syslog implementation for windows Pallavi Kadam
2019-10-22 20:02 ` [dpdk-dev] [PATCH v3 3/9] eal: add windows compatible header files Pallavi Kadam
2019-10-22 20:02 ` [dpdk-dev] [PATCH v3 4/9] eal: dirent.h implementation for windows Pallavi Kadam
2019-10-22 20:02 ` [dpdk-dev] [PATCH v3 5/9] eal: add additional function overrides in windows header files Pallavi Kadam
2019-10-22 20:02 ` [dpdk-dev] [PATCH v3 6/9] eal: getopt implementation for windows Pallavi Kadam
2019-10-22 20:02 ` Pallavi Kadam [this message]
2019-10-22 20:02 ` [dpdk-dev] [PATCH v3 8/9] build: add additional common files support Pallavi Kadam
2019-10-22 20:02 ` [dpdk-dev] [PATCH v3 9/9] eal: add minimum viable code to support parsing Pallavi Kadam
2020-01-09 3:13 ` [dpdk-dev] [PATCH v4 0/9] Windows patchset with additional EAL functionalities Pallavi Kadam
2020-01-09 3:13 ` [dpdk-dev] [PATCH v4 1/9] license: add license exception for windows Pallavi Kadam
2020-01-09 3:13 ` [dpdk-dev] [PATCH v4 2/9] eal: dirent.h implementation " Pallavi Kadam
2020-01-09 3:13 ` [dpdk-dev] [PATCH v4 3/9] eal: add windows compatible header files Pallavi Kadam
2020-01-09 3:13 ` [dpdk-dev] [PATCH v4 4/9] eal: add additional function overrides in windows " Pallavi Kadam
2020-01-09 3:13 ` [dpdk-dev] [PATCH v4 5/9] eal: getopt implementation for windows Pallavi Kadam
2020-01-09 3:13 ` [dpdk-dev] [PATCH v4 6/9] eal: add function to detect process type Pallavi Kadam
2020-01-09 6:35 ` Stephen Hemminger
2020-01-09 22:18 ` Pallavi Kadam
2020-01-09 3:13 ` [dpdk-dev] [PATCH v4 7/9] eal: remove syslog support for windows Pallavi Kadam
2020-01-09 3:13 ` [dpdk-dev] [PATCH v4 8/9] build: add additional common files support Pallavi Kadam
2020-01-09 3:13 ` [dpdk-dev] [PATCH v4 9/9] eal: add minimum viable code to support parsing Pallavi Kadam
2020-01-13 21:55 ` [dpdk-dev] [PATCH v5 0/9] Windows patchset with additional EAL functionalities Pallavi Kadam
2020-01-13 21:55 ` [dpdk-dev] [PATCH v5 1/9] license: add license exception for windows Pallavi Kadam
2020-01-13 21:55 ` [dpdk-dev] [PATCH v5 2/9] eal: dirent.h implementation " Pallavi Kadam
2020-01-13 21:55 ` [dpdk-dev] [PATCH v5 3/9] eal: add windows compatible header files Pallavi Kadam
2020-01-27 22:41 ` Thomas Monjalon
2020-01-28 23:34 ` Pallavi Kadam
2020-01-13 21:55 ` [dpdk-dev] [PATCH v5 4/9] eal: add additional function overrides in windows " Pallavi Kadam
2020-01-13 21:55 ` [dpdk-dev] [PATCH v5 5/9] eal: getopt implementation for windows Pallavi Kadam
2020-01-13 21:55 ` [dpdk-dev] [PATCH v5 6/9] eal: add function to detect process type Pallavi Kadam
2020-01-13 21:55 ` [dpdk-dev] [PATCH v5 7/9] eal: remove syslog support for windows Pallavi Kadam
2020-01-27 22:52 ` Thomas Monjalon
2020-01-28 23:45 ` Pallavi Kadam
2020-01-13 21:55 ` [dpdk-dev] [PATCH v5 8/9] build: add additional common files support Pallavi Kadam
2020-01-27 22:55 ` Thomas Monjalon
2020-01-28 23:46 ` Pallavi Kadam
2020-01-13 21:55 ` [dpdk-dev] [PATCH v5 9/9] eal: add minimum viable code to support parsing Pallavi Kadam
2020-01-31 0:02 ` [dpdk-dev] [PATCH v6 00/10] Windows patchset with additional EAL functionalities Pallavi Kadam
2020-01-31 0:02 ` [dpdk-dev] [PATCH v6 01/10] license: add license exception for windows Pallavi Kadam
2020-01-31 0:02 ` [dpdk-dev] [PATCH v6 02/10] eal: dirent.h implementation " Pallavi Kadam
2020-01-31 0:03 ` [dpdk-dev] [PATCH v6 03/10] eal: include filesystem " Pallavi Kadam
2020-01-31 6:04 ` Dmitry Kozliuk
2020-01-31 22:03 ` Pallavi Kadam
2020-01-31 0:03 ` [dpdk-dev] [PATCH v6 04/10] eal: add additional function overrides in windows header files Pallavi Kadam
2020-01-31 0:03 ` [dpdk-dev] [PATCH v6 05/10] eal: getopt implementation for windows Pallavi Kadam
2020-01-31 0:03 ` [dpdk-dev] [PATCH v6 06/10] eal: add function to detect process type Pallavi Kadam
2020-01-31 0:03 ` [dpdk-dev] [PATCH v6 07/10] eal: include SSE4 support for windows Pallavi Kadam
2020-01-31 0:03 ` [dpdk-dev] [PATCH v6 08/10] eal: remove syslog and dlfcn " Pallavi Kadam
2020-01-31 0:03 ` [dpdk-dev] [PATCH v6 09/10] build: add additional common files support Pallavi Kadam
2020-01-31 0:03 ` [dpdk-dev] [PATCH v6 10/10] eal: add minimum viable code to support parsing Pallavi Kadam
2020-02-01 0:03 ` [dpdk-dev] [PATCH v7 0/9] Windows patchset with additional EAL functionalities Pallavi Kadam
2020-02-01 0:03 ` [dpdk-dev] [PATCH v7 1/9] license: add license exception for windows Pallavi Kadam
2020-02-01 0:03 ` [dpdk-dev] [PATCH v7 2/9] eal: dirent.h implementation " Pallavi Kadam
2020-02-01 0:04 ` [dpdk-dev] [PATCH v7 3/9] eal: add additional function overrides in windows header files Pallavi Kadam
2020-02-05 19:54 ` Dmitry Kozlyuk
2020-02-01 0:04 ` [dpdk-dev] [PATCH v7 4/9] eal: getopt implementation for windows Pallavi Kadam
2020-02-01 0:04 ` [dpdk-dev] [PATCH v7 5/9] eal: add function to detect process type Pallavi Kadam
2020-02-05 20:04 ` Dmitry Kozlyuk
2020-02-06 0:56 ` Pallavi Kadam
2020-02-01 0:04 ` [dpdk-dev] [PATCH v7 6/9] eal: include SSE4 support for windows Pallavi Kadam
2020-02-01 0:04 ` [dpdk-dev] [PATCH v7 7/9] eal: remove syslog and dlfcn " Pallavi Kadam
2020-02-01 0:04 ` [dpdk-dev] [PATCH v7 8/9] build: add additional common files support Pallavi Kadam
2020-02-01 0:04 ` [dpdk-dev] [PATCH v7 9/9] eal: add minimum viable code to support parsing Pallavi Kadam
2020-02-05 19:54 ` Dmitry Kozlyuk
2020-02-06 0:39 ` Pallavi Kadam
2020-02-06 1:39 ` Pallavi Kadam
2020-02-06 2:11 ` Thomas Monjalon
2020-02-06 3:18 ` Pallavi Kadam
2020-02-06 6:41 ` Dmitry Kozlyuk
2020-02-06 9:26 ` Thomas Monjalon
2020-02-07 16:46 ` Ranjit Menon
2020-02-07 17:17 ` Ranjit Menon
2020-02-08 0:43 ` [dpdk-dev] [EXTERNAL] " Narcisa Ana Maria Vasile
2020-02-07 3:45 ` [dpdk-dev] " Pallavi Kadam
2020-02-07 3:14 ` [dpdk-dev] [PATCH v8 0/9] Windows patchset with additional EAL functionalities Pallavi Kadam
2020-02-07 3:14 ` [dpdk-dev] [PATCH v8 1/9] license: add license exception for windows Pallavi Kadam
2020-02-12 0:38 ` [dpdk-dev] [EXTERNAL] " Narcisa Ana Maria Vasile
2020-02-12 21:38 ` [dpdk-dev] " Thomas Monjalon
2020-02-12 21:55 ` Ranjit Menon
2020-02-07 3:14 ` [dpdk-dev] [PATCH v8 2/9] eal: dirent.h implementation " Pallavi Kadam
2020-02-12 0:40 ` [dpdk-dev] [EXTERNAL] " Narcisa Ana Maria Vasile
2020-02-07 3:14 ` [dpdk-dev] [PATCH v8 3/9] eal: add additional function overrides in windows header files Pallavi Kadam
2020-02-12 0:40 ` [dpdk-dev] [EXTERNAL] " Narcisa Ana Maria Vasile
2020-02-07 3:14 ` [dpdk-dev] [PATCH v8 4/9] eal: getopt implementation for windows Pallavi Kadam
2020-02-12 0:41 ` [dpdk-dev] [EXTERNAL] " Narcisa Ana Maria Vasile
2020-02-07 3:14 ` [dpdk-dev] [PATCH v8 5/9] eal: add function to detect process type Pallavi Kadam
2020-02-12 0:42 ` [dpdk-dev] [EXTERNAL] " Narcisa Ana Maria Vasile
2020-02-07 3:14 ` [dpdk-dev] [PATCH v8 6/9] eal: include SSE4 support for windows Pallavi Kadam
2020-02-12 0:42 ` [dpdk-dev] [EXTERNAL] " Narcisa Ana Maria Vasile
2020-02-07 3:14 ` [dpdk-dev] [PATCH v8 7/9] eal: remove syslog and dlfcn " Pallavi Kadam
2020-02-12 0:42 ` [dpdk-dev] [EXTERNAL] " Narcisa Ana Maria Vasile
2020-02-07 3:14 ` [dpdk-dev] [PATCH v8 8/9] build: add additional common files support Pallavi Kadam
2020-02-12 0:42 ` [dpdk-dev] [EXTERNAL] " Narcisa Ana Maria Vasile
2020-02-07 3:14 ` [dpdk-dev] [PATCH v8 9/9] eal: add minimum viable code to support parsing Pallavi Kadam
2020-02-12 0:43 ` [dpdk-dev] [EXTERNAL] " Narcisa Ana Maria Vasile
2020-02-07 19:05 ` [dpdk-dev] [PATCH v8 0/9] Windows patchset with additional EAL functionalities Dmitry Kozlyuk
2020-02-12 21:52 ` Thomas Monjalon
2020-02-08 0:36 ` [dpdk-dev] [EXTERNAL] " Narcisa Ana Maria Vasile
2020-02-08 1:04 ` Narcisa Ana Maria Vasile
2020-02-10 20:32 ` Narcisa Ana Maria Vasile
2020-02-10 21:22 ` Narcisa Ana Maria Vasile
2020-02-11 21:25 ` Narcisa Ana Maria Vasile
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191022200227.1920-8-pallavi.kadam@intel.com \
--to=pallavi.kadam@intel.com \
--cc=Harini.Ramakrishnan@microsoft.com \
--cc=antara.ganesh.kolar@intel.com \
--cc=bruce.richardson@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=jerinjacobk@gmail.com \
--cc=keith.wiles@intel.com \
--cc=ranjit.menon@intel.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).