From: yasufum.o@gmail.com
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 2/2] spp_pcap: remove global master lcore ID
Date: Wed, 26 Jun 2019 14:36:17 +0900 [thread overview]
Message-ID: <20190626053617.39907-3-yasufum.o@gmail.com> (raw)
In-Reply-To: <20190626053617.39907-1-yasufum.o@gmail.com>
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
prev parent reply other threads:[~2019-06-26 5:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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=20190626053617.39907-3-yasufum.o@gmail.com \
--to=yasufum.o@gmail.com \
--cc=ferruh.yigit@intel.com \
--cc=spp@dpdk.org \
/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).