Soft Patch Panel
 help / color / Atom feed
* [spp] [PATCH 0/2] Remove global variable g_main_lcore_id
@ 2019-06-26  5:36 yasufum.o
  2019-06-26  5:36 ` [spp] [PATCH 1/2] shared/sec: remove global master lcore ID yasufum.o
  2019-06-26  5:36 ` [spp] [PATCH 2/2] spp_pcap: " yasufum.o
  0 siblings, 2 replies; 3+ messages in thread
From: yasufum.o @ 2019-06-26  5:36 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

From: Yasufumi Ogawa <yasufum.o@gmail.com>

Master lcore ID is managed in SPP worker processes, but it can be
retrieved with rte_get_master_lcore(). This series of update is to
remove global `g_main_lcore_id` and change to use this function instead.

Yasufumi Ogawa (2):
  shared/sec: remove global master lcore ID
  spp_pcap: remove global master lcore ID

 src/mirror/spp_mirror.c                       | 44 ++++++---------
 src/pcap/cmd_utils.c                          | 13 ++---
 src/pcap/cmd_utils.h                          |  4 +-
 src/pcap/spp_pcap.c                           | 51 ++++++++---------
 .../secondary/spp_worker_th/cmd_utils.c       | 13 ++---
 .../secondary/spp_worker_th/cmd_utils.h       |  4 +-
 src/vf/spp_vf.c                               | 55 ++++++++-----------
 7 files changed, 80 insertions(+), 104 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [spp] [PATCH 1/2] shared/sec: remove global master lcore ID
  2019-06-26  5:36 [spp] [PATCH 0/2] Remove global variable g_main_lcore_id yasufum.o
@ 2019-06-26  5:36 ` yasufum.o
  2019-06-26  5:36 ` [spp] [PATCH 2/2] spp_pcap: " yasufum.o
  1 sibling, 0 replies; 3+ messages in thread
From: yasufum.o @ 2019-06-26  5:36 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

From: Yasufumi Ogawa <yasufum.o@gmail.com>

In SPP worker processes, master lcore ID is managed as a member of
global variable, but no need to this because it can be retrieved with
rte_get_master_lcore(). This update is to change to use this function.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/mirror/spp_mirror.c                       | 44 ++++++---------
 .../secondary/spp_worker_th/cmd_utils.c       | 13 ++---
 .../secondary/spp_worker_th/cmd_utils.h       |  4 +-
 src/vf/spp_vf.c                               | 55 ++++++++-----------
 4 files changed, 49 insertions(+), 67 deletions(-)

diff --git a/src/mirror/spp_mirror.c b/src/mirror/spp_mirror.c
index f040010..898755d 100644
--- a/src/mirror/spp_mirror.c
+++ b/src/mirror/spp_mirror.c
@@ -56,9 +56,6 @@ struct mirror_info {
 static uint16_t nb_rxd = MIR_RX_DESC_DEFAULT;
 static uint16_t nb_txd = MIR_TX_DESC_DEFAULT;
 
-/* Logical core ID for main process */
-static unsigned int g_main_lcore_id = 0xffffffff;
-
 /* Interface management information */
 static struct iface_info g_iface_info;
 
@@ -421,7 +418,7 @@ slave_main(void *arg __attribute__ ((unused)))
 	struct core_mng_info *info = &g_core_info[lcore_id];
 	struct core_info *core = get_core_info(lcore_id);
 
-	RTE_LOG(INFO, MIRROR, "Core[%d] Start.\n", lcore_id);
+	RTE_LOG(INFO, MIRROR, "Slave started on lcore %d.\n", lcore_id);
 	set_core_status(lcore_id, SPP_CORE_IDLE);
 
 	while ((status = spp_get_core_status(lcore_id)) !=
@@ -446,14 +443,14 @@ slave_main(void *arg __attribute__ ((unused)))
 		}
 		if (unlikely(ret != 0)) {
 			RTE_LOG(ERR, MIRROR,
-				"Core[%d] Component Error. (id = %d)\n",
+				"Failed to forward on lcore %d (id = %d)\n",
 					lcore_id, core->id[cnt]);
 			break;
 		}
 	}
 
 	set_core_status(lcore_id, SPP_CORE_STOP);
-	RTE_LOG(INFO, MIRROR, "Core[%d] End.\n", lcore_id);
+	RTE_LOG(INFO, MIRROR, "Terminated slave on lcore %d.\n", lcore_id);
 	return ret;
 }
 
@@ -469,6 +466,7 @@ main(int argc, char *argv[])
 	char ctl_ip[IPADDR_LEN] = { 0 };
 	int ctl_port;
 	int ret_cmd_init;
+	unsigned int master_lcore;
 	unsigned int lcore_id;
 
 #ifdef SPP_DEMONIZE
@@ -498,13 +496,12 @@ main(int argc, char *argv[])
 		if (unlikely(ret_parse != 0))
 			break;
 
-		/* Get lcore id of main thread to set its status after */
-		g_main_lcore_id = rte_lcore_id();
+		master_lcore = rte_get_master_lcore();
 
 		if (sppwk_set_mng_data(&g_iface_info, g_component_info,
 					g_core_info, g_change_core,
-					g_change_component, &g_backup_info,
-					g_main_lcore_id) < 0) {
+					g_change_component,
+					&g_backup_info) < 0) {
 			RTE_LOG(ERR, MIRROR,
 				"Failed to set management data.\n");
 			break;
@@ -514,7 +511,7 @@ main(int argc, char *argv[])
 		ret = mirror_pool_create(get_client_id());
 		if (ret == SPP_RET_NG) {
 			RTE_LOG(ERR, MIRROR,
-					"mirror mnuf pool create failed.\n");
+					"Failed to create mbuf pool.\n");
 			return SPP_RET_NG;
 		}
 
@@ -547,7 +544,7 @@ main(int argc, char *argv[])
 		}
 
 		/* Set the status of main thread to idle */
-		g_core_info[g_main_lcore_id].status = SPP_CORE_IDLE;
+		g_core_info[master_lcore].status = SPP_CORE_IDLE;
 		int ret_wait = check_core_status_wait(SPP_CORE_IDLE);
 		if (unlikely(ret_wait != 0))
 			break;
@@ -569,7 +566,7 @@ main(int argc, char *argv[])
 		/* Enter loop for accepting commands */
 		int ret_do = 0;
 #ifndef USE_UT_SPP_VF
-		while (likely(g_core_info[g_main_lcore_id].status !=
+		while (likely(g_core_info[master_lcore].status !=
 				SPP_CORE_STOP_REQUEST)) {
 #else
 		{
@@ -599,24 +596,19 @@ main(int argc, char *argv[])
 	}
 
 	/* Finalize to exit */
-	if (g_main_lcore_id == rte_lcore_id()) {
-		g_core_info[g_main_lcore_id].status = SPP_CORE_STOP;
-		int ret_core_end = check_core_status_wait(SPP_CORE_STOP);
-		if (unlikely(ret_core_end != 0))
-			RTE_LOG(ERR, MIRROR, "Core did not stop.\n");
-
-		/*
-		 * Remove vhost sock file if it is not running
-		 *  in vhost-client mode
-		 */
-		del_vhost_sockfile(g_iface_info.vhost);
-	}
+	g_core_info[master_lcore].status = SPP_CORE_STOP;
+	int ret_core_end = check_core_status_wait(SPP_CORE_STOP);
+	if (unlikely(ret_core_end != 0))
+		RTE_LOG(ERR, MIRROR, "Failed to terminate master thread.\n");
+
+	 /* Remove vhost sock file if not running in vhost-client mode. */
+	del_vhost_sockfile(g_iface_info.vhost);
 
 #ifdef SPP_RINGLATENCYSTATS_ENABLE
 	spp_ringlatencystats_uninit();
 #endif /* SPP_RINGLATENCYSTATS_ENABLE */
 
-	RTE_LOG(INFO, MIRROR, "spp_mirror exit.\n");
+	RTE_LOG(INFO, MIRROR, "Exit spp_mirror.\n");
 	return ret;
 }
 
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.c b/src/shared/secondary/spp_worker_th/cmd_utils.c
index 4f84365..32929ec 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.c
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.c
@@ -40,7 +40,6 @@ struct mng_data_info {
 	int *p_change_core;
 	int *p_change_component;  /* Set of flags for udpated components */
 	struct cancel_backup_info *p_backup_info;
-	unsigned int main_lcore_id;
 };
 
 /* Logical core ID for main process */
@@ -137,13 +136,15 @@ set_all_core_status(enum sppwk_lcore_status status)
 void
 stop_process(int signal)
 {
+	unsigned int master_lcore;
 	if (unlikely(signal != SIGTERM) &&
 			unlikely(signal != SIGINT)) {
 		return;
 	}
 
-	(g_mng_data.p_core_info + g_mng_data.main_lcore_id)->status =
-							SPP_CORE_STOP_REQUEST;
+	master_lcore = rte_get_master_lcore();
+	(g_mng_data.p_core_info + master_lcore)->status =
+		SPP_CORE_STOP_REQUEST;
 	set_all_core_status(SPP_CORE_STOP_REQUEST);
 }
 
@@ -843,8 +844,7 @@ int sppwk_set_mng_data(
 		struct core_mng_info *core_mng_p,
 		int *change_core_p,
 		int *change_component_p,
-		struct cancel_backup_info *backup_info_p,
-		unsigned int main_lcore_id)
+		struct cancel_backup_info *backup_info_p)
 {
 	/**
 	 * TODO(yasufum) confirm why the last `0xffffffff` is same as NULL,
@@ -852,7 +852,7 @@ int sppwk_set_mng_data(
 	 */
 	if (iface_p == NULL || component_p == NULL || core_mng_p == NULL ||
 			change_core_p == NULL || change_component_p == NULL ||
-			backup_info_p == NULL || main_lcore_id == 0xffffffff)
+			backup_info_p == NULL)
 		return SPP_RET_NG;
 
 	g_mng_data.p_iface_info = iface_p;
@@ -861,7 +861,6 @@ int sppwk_set_mng_data(
 	g_mng_data.p_change_core = change_core_p;
 	g_mng_data.p_change_component = change_component_p;
 	g_mng_data.p_backup_info = backup_info_p;
-	g_mng_data.main_lcore_id = main_lcore_id;
 
 	return SPP_RET_OK;
 }
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.h b/src/shared/secondary/spp_worker_th/cmd_utils.h
index e2b987f..f33bc62 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.h
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.h
@@ -532,7 +532,6 @@ int64_t sppwk_convert_mac_str_to_int64(const char *macaddr);
  * @param change_core_p Pointer to g_change_core address.
  * @param change_component_p Pointer to g_change_component address.
  * @param backup_info_p Pointer to g_backup_info address.
- * @param main_lcore_id Lcore ID of main thread.
  * @retval SPP_RET_OK If succeeded.
  * @retval SPP_RET_NG If failed.
  */
@@ -541,8 +540,7 @@ int sppwk_set_mng_data(struct iface_info *iface_p,
 		struct core_mng_info *core_mng_p,
 		int *change_core_p,
 		int *change_component_p,
-		struct cancel_backup_info *backup_info_p,
-		unsigned int main_lcore_id);
+		struct cancel_backup_info *backup_info_p);
 
 /**
  * Get mange data address.
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index 44e39fc..0068329 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -18,9 +18,6 @@
 #include "shared/secondary/spp_worker_th/spp_port.h"
 
 /* Declare global variables */
-/* Logical core ID for main process */
-static unsigned int g_main_lcore_id = 0xffffffff;
-
 /* Interface management information */
 static struct iface_info g_iface_info;
 
@@ -147,7 +144,7 @@ slave_main(void *arg __attribute__ ((unused)))
 	struct core_mng_info *info = &g_core_info[lcore_id];
 	struct core_info *core = get_core_info(lcore_id);
 
-	RTE_LOG(INFO, APP, "Core[%d] Start.\n", lcore_id);
+	RTE_LOG(INFO, APP, "Slave started on lcore %d.\n", lcore_id);
 	set_core_status(lcore_id, SPP_CORE_IDLE);
 
 	while ((status = spp_get_core_status(lcore_id)) !=
@@ -178,15 +175,15 @@ slave_main(void *arg __attribute__ ((unused)))
 			}
 		}
 		if (unlikely(ret != 0)) {
-			RTE_LOG(ERR, APP, "Core[%d] Component Error. "
-					"(id = %d)\n",
+			RTE_LOG(ERR, APP, "Failed to forward on lcore %d. "
+					"(id = %d).\n",
 					lcore_id, core->id[cnt]);
 			break;
 		}
 	}
 
 	set_core_status(lcore_id, SPP_CORE_STOP);
-	RTE_LOG(INFO, APP, "Core[%d] End.\n", lcore_id);
+	RTE_LOG(INFO, APP, "Terminated slave on lcore %d.\n", lcore_id);
 	return ret;
 }
 
@@ -202,7 +199,8 @@ main(int argc, char *argv[])
 	char ctl_ip[IPADDR_LEN] = { 0 };
 	int ctl_port;
 	int ret_cmd_init;
-	unsigned int lcore_id = 0;
+	unsigned int master_lcore;
+	unsigned int lcore_id;
 
 #ifdef SPP_DEMONIZE
 	/* Daemonize process */
@@ -231,14 +229,10 @@ main(int argc, char *argv[])
 		if (unlikely(ret_parse != SPP_RET_OK))
 			break;
 
-		/* Get lcore id of main thread to set its status after */
-		g_main_lcore_id = rte_lcore_id();
-
-		if (sppwk_set_mng_data(&g_iface_info,
-					g_component_info, g_core_info,
-					g_change_core, g_change_component,
-					&g_backup_info,
-					g_main_lcore_id) < SPP_RET_OK) {
+		if (sppwk_set_mng_data(&g_iface_info, g_component_info,
+					g_core_info, g_change_core,
+					g_change_component,
+					&g_backup_info) < SPP_RET_OK) {
 			RTE_LOG(ERR, APP,
 				"Failed to set management data.\n");
 			break;
@@ -276,7 +270,8 @@ main(int argc, char *argv[])
 		}
 
 		/* Set the status of main thread to idle */
-		g_core_info[g_main_lcore_id].status = SPP_CORE_IDLE;
+		master_lcore = rte_get_master_lcore();
+		g_core_info[master_lcore].status = SPP_CORE_IDLE;
 		int ret_wait = check_core_status_wait(SPP_CORE_IDLE);
 		if (unlikely(ret_wait != SPP_RET_OK))
 			break;
@@ -292,7 +287,7 @@ main(int argc, char *argv[])
 		/* Enter loop for accepting commands */
 		int ret_do = SPP_RET_OK;
 #ifndef USE_UT_SPP_VF
-		while (likely(g_core_info[g_main_lcore_id].status !=
+		while (likely(g_core_info[master_lcore].status !=
 				SPP_CORE_STOP_REQUEST)) {
 #else
 		{
@@ -322,23 +317,21 @@ main(int argc, char *argv[])
 	}
 
 	/* Finalize to exit */
-	if (g_main_lcore_id == rte_lcore_id()) {
-		g_core_info[g_main_lcore_id].status = SPP_CORE_STOP;
-		int ret_core_end = check_core_status_wait(SPP_CORE_STOP);
-		if (unlikely(ret_core_end != SPP_RET_OK))
-			RTE_LOG(ERR, APP, "Core did not stop.\n");
-
-		/*
-		 * Remove vhost sock file if it is not running
-		 *  in vhost-client mode
-		 */
-		del_vhost_sockfile(g_iface_info.vhost);
-	}
+	g_core_info[master_lcore].status = SPP_CORE_STOP;
+	int ret_core_end = check_core_status_wait(SPP_CORE_STOP);
+	if (unlikely(ret_core_end != SPP_RET_OK))
+		RTE_LOG(ERR, APP, "Failed to terminate master thread.\n");
+
+	/*
+	 * Remove vhost sock file if it is not running
+	 *  in vhost-client mode
+	 */
+	del_vhost_sockfile(g_iface_info.vhost);
 
 #ifdef SPP_RINGLATENCYSTATS_ENABLE
 	spp_ringlatencystats_uninit();
 #endif /* SPP_RINGLATENCYSTATS_ENABLE */
 
-	RTE_LOG(INFO, APP, "spp_vf exit.\n");
+	RTE_LOG(INFO, APP, "Exit spp_vf.\n");
 	return ret;
 }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [spp] [PATCH 2/2] spp_pcap: remove global master lcore ID
  2019-06-26  5:36 [spp] [PATCH 0/2] Remove global variable g_main_lcore_id yasufum.o
  2019-06-26  5:36 ` [spp] [PATCH 1/2] shared/sec: remove global master lcore ID yasufum.o
@ 2019-06-26  5:36 ` " yasufum.o
  1 sibling, 0 replies; 3+ messages in thread
From: yasufum.o @ 2019-06-26  5:36 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

From: Yasufumi Ogawa <yasufum.o@gmail.com>

As previous patch, this update is to remove variable of master lcore ID
and change to use rte_get_master_lcore().

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/pcap/cmd_utils.c | 13 ++++++-----
 src/pcap/cmd_utils.h |  4 +---
 src/pcap/spp_pcap.c  | 51 +++++++++++++++++++++-----------------------
 3 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/src/pcap/cmd_utils.c b/src/pcap/cmd_utils.c
index 52ca905..66e6d05 100644
--- a/src/pcap/cmd_utils.c
+++ b/src/pcap/cmd_utils.c
@@ -18,7 +18,6 @@ struct mng_data_info {
 	struct core_mng_info	  *p_core_info;
 	int			  *p_capture_request;
 	int			  *p_capture_status;
-	unsigned int		  main_lcore_id;
 };
 
 /* Declare global variables */
@@ -130,12 +129,15 @@ set_all_core_status(enum sppwk_lcore_status status)
 void
 stop_process(int signal)
 {
+	unsigned int master_lcore;
+
 	if (unlikely(signal != SIGTERM) &&
 			unlikely(signal != SIGINT)) {
 		return;
 	}
 
-	(g_mng_data_addr.p_core_info + g_mng_data_addr.main_lcore_id)->status =
+	master_lcore = rte_get_master_lcore();
+	(g_mng_data_addr.p_core_info + master_lcore)->status =
 							SPP_CORE_STOP_REQUEST;
 	set_all_core_status(SPP_CORE_STOP_REQUEST);
 }
@@ -260,20 +262,17 @@ int spp_format_port_string(char *port, enum port_type iface_type, int iface_no)
 int spp_set_mng_data_addr(struct iface_info *iface_p,
 			  struct core_mng_info *core_mng_p,
 			  int *capture_request_p,
-			  int *capture_status_p,
-			  unsigned int main_lcore_id)
+			  int *capture_status_p)
 {
 	if (iface_p == NULL || core_mng_p == NULL ||
 			capture_request_p == NULL ||
-			capture_status_p == NULL ||
-			main_lcore_id == 0xffffffff)
+			capture_status_p == NULL)
 		return SPPWK_RET_NG;
 
 	g_mng_data_addr.p_iface_info = iface_p;
 	g_mng_data_addr.p_core_info = core_mng_p;
 	g_mng_data_addr.p_capture_request = capture_request_p;
 	g_mng_data_addr.p_capture_status = capture_status_p;
-	g_mng_data_addr.main_lcore_id = main_lcore_id;
 
 	return SPPWK_RET_OK;
 }
diff --git a/src/pcap/cmd_utils.h b/src/pcap/cmd_utils.h
index 4fa2ea9..9b7ae52 100644
--- a/src/pcap/cmd_utils.h
+++ b/src/pcap/cmd_utils.h
@@ -324,15 +324,13 @@ spp_format_port_string(char *port, enum port_type iface_type, int iface_no);
  * @param core_mng_p Pointer to g_core_info address.
  * @param capture_status_p Pointer to status of pcap.
  * @param capture_request_p Pointer to req of pcap.
- * @param main_lcore_id Lcore ID of main thread.
  * @retval SPP_RET_OK If succeeded.
  * @retval SPP_RET_NG If failed.
  */
 int spp_set_mng_data_addr(struct iface_info *iface_p,
 			  struct core_mng_info *core_mng_p,
 			  int *capture_request_p,
-			  int *capture_status_p,
-			  unsigned int main_lcore_id);
+			  int *capture_status_p);
 
 /**
  * Get mange data address
diff --git a/src/pcap/spp_pcap.c b/src/pcap/spp_pcap.c
index 0b846f3..6762337 100644
--- a/src/pcap/spp_pcap.c
+++ b/src/pcap/spp_pcap.c
@@ -129,9 +129,6 @@ struct pcap_status_info {
 	int start_up_cnt;  /* thread start up count */
 };
 
-/* Lcore ID of main thread. */
-static unsigned int g_main_lcore_id = 0xffffffff;
-
 /* Interface management information */
 static struct iface_info g_iface_info;
 
@@ -855,11 +852,12 @@ slave_main(void *arg __attribute__ ((unused)))
 	struct pcap_mng_info *pcap_info = &g_pcap_info[lcore_id];
 
 	if (pcap_info->thread_no == 0) {
-		RTE_LOG(INFO, SPP_PCAP, "Core[%d] Start recive.\n", lcore_id);
+		RTE_LOG(INFO, SPP_PCAP, "Receiver started on lcore %d.\n",
+				lcore_id);
 		pcap_info->type = PCAP_RECEIVE;
 	} else {
-		RTE_LOG(INFO, SPP_PCAP, "Core[%d] Start write(%d).\n",
-					lcore_id, pcap_info->thread_no);
+		RTE_LOG(INFO, SPP_PCAP, "Writer %d started on lcore %d.\n",
+					pcap_info->thread_no, lcore_id);
 		pcap_info->type = PCAP_WRITE;
 	}
 	set_core_status(lcore_id, SPP_CORE_IDLE);
@@ -877,14 +875,16 @@ slave_main(void *arg __attribute__ ((unused)))
 		else
 			ret = pcap_proc_write(lcore_id);
 		if (unlikely(ret != SPPWK_RET_OK)) {
-			RTE_LOG(ERR, SPP_PCAP, "Core[%d] Thread Error.\n",
-								lcore_id);
+			RTE_LOG(ERR, SPP_PCAP,
+					"Failed to capture on lcore %d.\n",
+					lcore_id);
 			break;
 		}
 	}
 
 	set_core_status(lcore_id, SPP_CORE_STOP);
-	RTE_LOG(INFO, SPP_PCAP, "Core[%d] End.\n", lcore_id);
+	RTE_LOG(INFO, SPP_PCAP,
+			"Terminated slave on lcore %d.\n", lcore_id);
 	return ret;
 }
 
@@ -900,6 +900,7 @@ main(int argc, char *argv[])
 	char ctl_ip[IPADDR_LEN] = { 0 };
 	int ctl_port;
 	int ret_cmd_init;
+	unsigned int master_lcore;
 	unsigned int lcore_id;
 	unsigned int thread_no;
 
@@ -930,13 +931,10 @@ main(int argc, char *argv[])
 		if (unlikely(ret_parse != 0))
 			break;
 
-		/* Get lcore id of main thread to set its status after */
-		g_main_lcore_id = rte_lcore_id();
-
 		/* set manage address */
 		if (spp_set_mng_data_addr(&g_iface_info, g_core_info,
-					&g_capture_request, &g_capture_status,
-					g_main_lcore_id) < 0) {
+					&g_capture_request,
+					&g_capture_status) < 0) {
 			RTE_LOG(ERR, SPP_PCAP,
 				"manage address set is failed.\n");
 			break;
@@ -1025,7 +1023,8 @@ main(int argc, char *argv[])
 		}
 
 		/* Set the status of main thread to idle */
-		g_core_info[g_main_lcore_id].status = SPP_CORE_IDLE;
+		master_lcore = rte_get_master_lcore();
+		g_core_info[master_lcore].status = SPP_CORE_IDLE;
 		int ret_wait = check_core_status_wait(SPP_CORE_IDLE);
 		if (unlikely(ret_wait != 0))
 			break;
@@ -1036,7 +1035,7 @@ main(int argc, char *argv[])
 
 		/* Enter loop for accepting commands */
 		int ret_do = 0;
-		while (likely(g_core_info[g_main_lcore_id].status !=
+		while (likely(g_core_info[master_lcore].status !=
 				SPP_CORE_STOP_REQUEST)) {
 			/* Receive command */
 			ret_do = spp_command_proc_do();
@@ -1059,18 +1058,16 @@ main(int argc, char *argv[])
 	}
 
 	/* Finalize to exit */
-	if (g_main_lcore_id == rte_lcore_id()) {
-		g_core_info[g_main_lcore_id].status = SPP_CORE_STOP;
-		int ret_core_end = check_core_status_wait(SPP_CORE_STOP);
-		if (unlikely(ret_core_end != 0))
-			RTE_LOG(ERR, SPP_PCAP, "Core did not stop.\n");
-
-		/* capture write ring free */
-		if (g_pcap_option.cap_ring != NULL)
-			rte_ring_free(g_pcap_option.cap_ring);
-	}
+	g_core_info[master_lcore].status = SPP_CORE_STOP;
+	int ret_core_end = check_core_status_wait(SPP_CORE_STOP);
+	if (unlikely(ret_core_end != 0))
+		RTE_LOG(ERR, SPP_PCAP, "Failed to terminate master thread.\n");
+
+	/* capture write ring free */
+	if (g_pcap_option.cap_ring != NULL)
+		rte_ring_free(g_pcap_option.cap_ring);
 
 
-	RTE_LOG(INFO, SPP_PCAP, "spp_pcap exit.\n");
+	RTE_LOG(INFO, SPP_PCAP, "Exit spp_pcap.\n");
 	return ret;
 }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-26  5:36 [spp] [PATCH 0/2] Remove global variable g_main_lcore_id yasufum.o
2019-06-26  5:36 ` [spp] [PATCH 1/2] shared/sec: remove global master lcore ID yasufum.o
2019-06-26  5:36 ` [spp] [PATCH 2/2] spp_pcap: " yasufum.o

Soft Patch Panel

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/spp/0 spp/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 spp spp/ http://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


AGPL code for this site: git clone https://public-inbox.org/ public-inbox