[spp] [PATCH 3/3] spp_primary: add lcore_id_used variable

ogawa.yasufumi at lab.ntt.co.jp ogawa.yasufumi at lab.ntt.co.jp
Tue Jan 29 13:20:28 CET 2019


From: Yasufumi Ogawa <ogawa.yasufumi at lab.ntt.co.jp>

To enable to retrieve lcore IDs used by spp_primary, add
`lcore_id_used` variable. It is intended to be refered for inspecting
the rest of cores can be used.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi at lab.ntt.co.jp>
---
 src/primary/init.c  | 16 +++++++++++++++-
 src/shared/common.h |  2 ++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/primary/init.c b/src/primary/init.c
index 8b1f396..85b54a3 100644
--- a/src/primary/init.c
+++ b/src/primary/init.c
@@ -9,8 +9,8 @@
 #include <rte_malloc.h>
 #include <rte_memzone.h>
 
+#include "shared/common.h"
 #include "args.h"
-#include "common.h"
 #include "init.h"
 #include "primary.h"
 
@@ -23,6 +23,8 @@ static struct rte_mempool *pktmbuf_pool;
 /* the port details */
 struct port_info *ports;
 
+uint8_t lcore_id_used[RTE_MAX_LCORE] = {};
+
 /**
  * Initialise the mbuf pool for packet reception for the NIC, and any other
  * buffer pools needed by the app - currently none.
@@ -104,8 +106,10 @@ int
 init(int argc, char *argv[])
 {
 	int retval;
+	int lcore_id;
 	const struct rte_memzone *mz;
 	uint16_t count, total_ports;
+	char log_msg[1024] = { '\0' };
 
 	/* init EAL, parsing EAL args */
 	retval = rte_eal_init(argc, argv);
@@ -159,6 +163,16 @@ init(int argc, char *argv[])
 	/* Initialise the ring_port. */
 	init_shm_rings();
 
+	RTE_LCORE_FOREACH(lcore_id) {
+		lcore_id_used[lcore_id] = 1;
+	}
+	sprintf(log_msg, "Used lcores: ");
+	for (int i = 0; i < RTE_MAX_LCORE; i++) {
+		if (lcore_id_used[i] == 1)
+			sprintf(log_msg + strlen(log_msg), "%d ", i);
+	}
+	RTE_LOG(DEBUG, PRIMARY, "%s\n", log_msg);
+
 	return 0;
 }
 
diff --git a/src/shared/common.h b/src/shared/common.h
index e244db9..d5c62bd 100644
--- a/src/shared/common.h
+++ b/src/shared/common.h
@@ -127,4 +127,6 @@ int set_user_log_debug(int num_user_log);
 int parse_num_clients(uint16_t *num_clients, const char *clients);
 int parse_server(char **server_ip, int *server_port, char *server_addr);
 
+extern uint8_t lcore_id_used[RTE_MAX_LCORE];
+
 #endif
-- 
2.7.4



More information about the spp mailing list