* [spp] [PATCH 1/2] shared/sec: rename members of sppwk_lcore_status
2019-06-26 5:36 [spp] [PATCH 0/2] Rename members of sppwk_lcore_status 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>
This update is to rename members of enum `sppwk_lcore_status` which
defines each of status of worker threads, such as idling or running or
so.
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
src/mirror/mir_cmd_runner.c | 9 +++----
src/mirror/spp_mirror.c | 24 +++++++++----------
.../secondary/spp_worker_th/cmd_utils.c | 8 +++----
.../secondary/spp_worker_th/cmd_utils.h | 15 ++++++------
src/vf/spp_vf.c | 24 +++++++++----------
src/vf/vf_cmd_runner.c | 9 +++----
6 files changed, 45 insertions(+), 44 deletions(-)
diff --git a/src/mirror/mir_cmd_runner.c b/src/mirror/mir_cmd_runner.c
index f63a84b..17c2c27 100644
--- a/src/mirror/mir_cmd_runner.c
+++ b/src/mirror/mir_cmd_runner.c
@@ -39,9 +39,10 @@ update_comp(enum sppwk_action wk_action, const char *name,
switch (wk_action) {
case SPPWK_ACT_START:
info = (core_info + lcore_id);
- if (info->status == SPP_CORE_UNUSE) {
- RTE_LOG(ERR, MIR_CMD_RUNNER, "Core %d is not available because "
- "it is in SPP_CORE_UNUSE state.\n", lcore_id);
+ if (info->status == SPPWK_LCORE_UNUSED) {
+ RTE_LOG(ERR, MIR_CMD_RUNNER,
+ "Not available lcore %d for %s.\n",
+ lcore_id, "SPPWK_LCORE_UNUSED");
return SPP_RET_NG;
}
@@ -302,7 +303,7 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
struct sppwk_comp_info *comp_info = NULL;
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
- if (spp_get_core_status(lcore_id) == SPP_CORE_UNUSE)
+ if (spp_get_core_status(lcore_id) == SPPWK_LCORE_UNUSED)
continue;
core = get_core_info(lcore_id);
diff --git a/src/mirror/spp_mirror.c b/src/mirror/spp_mirror.c
index 898755d..695f3ac 100644
--- a/src/mirror/spp_mirror.c
+++ b/src/mirror/spp_mirror.c
@@ -414,16 +414,16 @@ slave_main(void *arg __attribute__ ((unused)))
int ret = SPP_RET_OK;
int cnt = 0;
unsigned int lcore_id = rte_lcore_id();
- enum sppwk_lcore_status status = SPP_CORE_STOP;
+ enum sppwk_lcore_status status = SPPWK_LCORE_STOPPED;
struct core_mng_info *info = &g_core_info[lcore_id];
struct core_info *core = get_core_info(lcore_id);
RTE_LOG(INFO, MIRROR, "Slave started on lcore %d.\n", lcore_id);
- set_core_status(lcore_id, SPP_CORE_IDLE);
+ set_core_status(lcore_id, SPPWK_LCORE_IDLING);
while ((status = spp_get_core_status(lcore_id)) !=
- SPP_CORE_STOP_REQUEST) {
- if (status != SPP_CORE_FORWARD)
+ SPPWK_LCORE_REQ_STOP) {
+ if (status != SPPWK_LCORE_RUNNING)
continue;
if (spp_check_core_update(lcore_id) == SPP_RET_OK) {
@@ -449,7 +449,7 @@ slave_main(void *arg __attribute__ ((unused)))
}
}
- set_core_status(lcore_id, SPP_CORE_STOP);
+ set_core_status(lcore_id, SPPWK_LCORE_STOPPED);
RTE_LOG(INFO, MIRROR, "Terminated slave on lcore %d.\n", lcore_id);
return ret;
}
@@ -544,13 +544,13 @@ main(int argc, char *argv[])
}
/* Set the status of main thread to idle */
- g_core_info[master_lcore].status = SPP_CORE_IDLE;
- int ret_wait = check_core_status_wait(SPP_CORE_IDLE);
+ g_core_info[master_lcore].status = SPPWK_LCORE_IDLING;
+ int ret_wait = check_core_status_wait(SPPWK_LCORE_IDLING);
if (unlikely(ret_wait != 0))
break;
/* Start forwarding */
- set_all_core_status(SPP_CORE_FORWARD);
+ set_all_core_status(SPPWK_LCORE_RUNNING);
#ifdef SPP_MIRROR_SHALLOWCOPY
RTE_LOG(INFO, MIRROR,
"My ID %d start handling messagei(ShallowCopy)\n", 0);
@@ -567,7 +567,7 @@ main(int argc, char *argv[])
int ret_do = 0;
#ifndef USE_UT_SPP_VF
while (likely(g_core_info[master_lcore].status !=
- SPP_CORE_STOP_REQUEST)) {
+ SPPWK_LCORE_REQ_STOP)) {
#else
{
#endif
@@ -587,7 +587,7 @@ main(int argc, char *argv[])
}
if (unlikely(ret_do != SPP_RET_OK)) {
- set_all_core_status(SPP_CORE_STOP_REQUEST);
+ set_all_core_status(SPPWK_LCORE_REQ_STOP);
break;
}
@@ -596,8 +596,8 @@ main(int argc, char *argv[])
}
/* Finalize to exit */
- g_core_info[master_lcore].status = SPP_CORE_STOP;
- int ret_core_end = check_core_status_wait(SPP_CORE_STOP);
+ g_core_info[master_lcore].status = SPPWK_LCORE_STOPPED;
+ int ret_core_end = check_core_status_wait(SPPWK_LCORE_STOPPED);
if (unlikely(ret_core_end != 0))
RTE_LOG(ERR, MIRROR, "Failed to terminate master thread.\n");
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.c b/src/shared/secondary/spp_worker_th/cmd_utils.c
index 32929ec..6f93400 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.c
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.c
@@ -130,7 +130,7 @@ set_all_core_status(enum sppwk_lcore_status status)
}
/**
- * Set all of component status to SPP_CORE_STOP_REQUEST if received signal
+ * Set all of component status to SPPWK_LCORE_REQ_STOP if received signal
* is SIGTERM or SIGINT
*/
void
@@ -144,8 +144,8 @@ stop_process(int signal)
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);
+ SPPWK_LCORE_REQ_STOP;
+ set_all_core_status(SPPWK_LCORE_REQ_STOP);
}
/**
@@ -397,7 +397,7 @@ init_core_info(void)
struct core_mng_info *p_core_info = g_mng_data.p_core_info;
memset(p_core_info, 0x00,
sizeof(struct core_mng_info)*RTE_MAX_LCORE);
- set_all_core_status(SPP_CORE_STOP);
+ set_all_core_status(SPPWK_LCORE_STOPPED);
for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
(p_core_info + cnt)->ref_index = 0;
(p_core_info + cnt)->upd_index = 1;
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.h b/src/shared/secondary/spp_worker_th/cmd_utils.h
index f33bc62..596ba5e 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.h
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.h
@@ -74,14 +74,13 @@
#define CORE_TYPE_FORWARD_STR "forward"
#define CORE_TYPE_MIRROR_STR "mirror"
-/* State on component */
+/* Status of a component on lcore. */
enum sppwk_lcore_status {
- SPP_CORE_UNUSE, /**< Not used */
- SPP_CORE_STOP, /**< Stopped */
- SPP_CORE_IDLE, /**< Idling */
- SPP_CORE_FORWARD, /**< Forwarding */
- SPP_CORE_STOP_REQUEST, /**< Request stopping */
- SPP_CORE_IDLE_REQUEST /**< Request idling */
+ SPPWK_LCORE_UNUSED,
+ SPPWK_LCORE_STOPPED,
+ SPPWK_LCORE_IDLING,
+ SPPWK_LCORE_RUNNING,
+ SPPWK_LCORE_REQ_STOP /**< Request stopping */
};
/* Type of SPP worker thread. */
@@ -336,7 +335,7 @@ void set_core_status(unsigned int lcore_id, enum sppwk_lcore_status status);
void set_all_core_status(enum sppwk_lcore_status status);
/**
- * Set all comp status to SPP_CORE_STOP_REQUEST if received SIGTERM or SIGINT.
+ * Set all comp status to SPPWK_LCORE_REQ_STOP if received SIGTERM or SIGINT.
*
* @param[in] signal Received signal.
*/
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index 0068329..18a3619 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -140,16 +140,16 @@ slave_main(void *arg __attribute__ ((unused)))
int ret = 0;
int cnt = 0;
unsigned int lcore_id = rte_lcore_id();
- enum sppwk_lcore_status status = SPP_CORE_STOP;
+ enum sppwk_lcore_status status = SPPWK_LCORE_STOPPED;
struct core_mng_info *info = &g_core_info[lcore_id];
struct core_info *core = get_core_info(lcore_id);
RTE_LOG(INFO, APP, "Slave started on lcore %d.\n", lcore_id);
- set_core_status(lcore_id, SPP_CORE_IDLE);
+ set_core_status(lcore_id, SPPWK_LCORE_IDLING);
while ((status = spp_get_core_status(lcore_id)) !=
- SPP_CORE_STOP_REQUEST) {
- if (status != SPP_CORE_FORWARD)
+ SPPWK_LCORE_REQ_STOP) {
+ if (status != SPPWK_LCORE_RUNNING)
continue;
if (spp_check_core_update(lcore_id) == SPP_RET_OK) {
@@ -182,7 +182,7 @@ slave_main(void *arg __attribute__ ((unused)))
}
}
- set_core_status(lcore_id, SPP_CORE_STOP);
+ set_core_status(lcore_id, SPPWK_LCORE_STOPPED);
RTE_LOG(INFO, APP, "Terminated slave on lcore %d.\n", lcore_id);
return ret;
}
@@ -271,13 +271,13 @@ main(int argc, char *argv[])
/* Set the status of main thread to 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);
+ g_core_info[master_lcore].status = SPPWK_LCORE_IDLING;
+ int ret_wait = check_core_status_wait(SPPWK_LCORE_IDLING);
if (unlikely(ret_wait != SPP_RET_OK))
break;
/* Start forwarding */
- set_all_core_status(SPP_CORE_FORWARD);
+ set_all_core_status(SPPWK_LCORE_RUNNING);
RTE_LOG(INFO, APP, "My ID %d start handling message\n", 0);
RTE_LOG(INFO, APP, "[Press Ctrl-C to quit ...]\n");
@@ -288,7 +288,7 @@ main(int argc, char *argv[])
int ret_do = SPP_RET_OK;
#ifndef USE_UT_SPP_VF
while (likely(g_core_info[master_lcore].status !=
- SPP_CORE_STOP_REQUEST)) {
+ SPPWK_LCORE_REQ_STOP)) {
#else
{
#endif
@@ -308,7 +308,7 @@ main(int argc, char *argv[])
}
if (unlikely(ret_do != SPP_RET_OK)) {
- set_all_core_status(SPP_CORE_STOP_REQUEST);
+ set_all_core_status(SPPWK_LCORE_REQ_STOP);
break;
}
@@ -317,8 +317,8 @@ main(int argc, char *argv[])
}
/* Finalize to exit */
- g_core_info[master_lcore].status = SPP_CORE_STOP;
- int ret_core_end = check_core_status_wait(SPP_CORE_STOP);
+ g_core_info[master_lcore].status = SPPWK_LCORE_STOPPED;
+ int ret_core_end = check_core_status_wait(SPPWK_LCORE_STOPPED);
if (unlikely(ret_core_end != SPP_RET_OK))
RTE_LOG(ERR, APP, "Failed to terminate master thread.\n");
diff --git a/src/vf/vf_cmd_runner.c b/src/vf/vf_cmd_runner.c
index d9adc48..f5854b0 100644
--- a/src/vf/vf_cmd_runner.c
+++ b/src/vf/vf_cmd_runner.c
@@ -137,9 +137,10 @@ update_comp(enum sppwk_action wk_action, const char *name,
switch (wk_action) {
case SPPWK_ACT_START:
info = (core_info + lcore_id);
- if (info->status == SPP_CORE_UNUSE) {
- RTE_LOG(ERR, VF_CMD_RUNNER, "Core %d is not available because "
- "it is in SPP_CORE_UNUSE state.\n", lcore_id);
+ if (info->status == SPPWK_LCORE_UNUSED) {
+ RTE_LOG(ERR, VF_CMD_RUNNER,
+ "Not available lcore %d for %s.\n",
+ lcore_id, "SPPWK_LCORE_UNUSED");
return SPP_RET_NG;
}
@@ -436,7 +437,7 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
struct sppwk_comp_info *comp_info = NULL;
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
- if (spp_get_core_status(lcore_id) == SPP_CORE_UNUSE)
+ if (spp_get_core_status(lcore_id) == SPPWK_LCORE_UNUSED)
continue;
core = get_core_info(lcore_id);
--
2.17.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [spp] [PATCH 2/2] spp_pcap: rename members of sppwk_lcore_status
2019-06-26 5:36 [spp] [PATCH 0/2] Rename members of sppwk_lcore_status yasufum.o
2019-06-26 5:36 ` [spp] [PATCH 1/2] shared/sec: rename " 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 same as previous update, this patch is to rename members of enum
`sppwk_lcore_status` which defines each of status of worker threads,
such as idling or running or so.
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
src/pcap/cmd_runner.c | 2 +-
src/pcap/cmd_utils.c | 6 +++---
src/pcap/cmd_utils.h | 18 ++++++++---------
src/pcap/spp_pcap.c | 20 +++++++++----------
.../secondary/spp_worker_th/cmd_utils.h | 2 +-
5 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/src/pcap/cmd_runner.c b/src/pcap/cmd_runner.c
index 48e8eba..5754841 100644
--- a/src/pcap/cmd_runner.c
+++ b/src/pcap/cmd_runner.c
@@ -71,7 +71,7 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
int lcore_id;
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
- if (sppwk_get_lcore_status(lcore_id) == SPP_CORE_UNUSE)
+ if (sppwk_get_lcore_status(lcore_id) == SPPWK_LCORE_UNUSED)
continue;
ret = spp_pcap_get_core_status(lcore_id, params);
diff --git a/src/pcap/cmd_utils.c b/src/pcap/cmd_utils.c
index 66e6d05..69f0fa0 100644
--- a/src/pcap/cmd_utils.c
+++ b/src/pcap/cmd_utils.c
@@ -138,8 +138,8 @@ stop_process(int signal)
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);
+ SPPWK_LCORE_REQ_STOP;
+ set_all_core_status(SPPWK_LCORE_REQ_STOP);
}
/**
@@ -194,7 +194,7 @@ init_core_info(void)
struct core_mng_info *p_core_info = g_mng_data_addr.p_core_info;
memset(p_core_info, 0x00,
sizeof(struct core_mng_info)*RTE_MAX_LCORE);
- set_all_core_status(SPP_CORE_STOP);
+ set_all_core_status(SPPWK_LCORE_STOPPED);
*g_mng_data_addr.p_capture_request = SPP_CAPTURE_IDLE;
*g_mng_data_addr.p_capture_status = SPP_CAPTURE_IDLE;
}
diff --git a/src/pcap/cmd_utils.h b/src/pcap/cmd_utils.h
index 9b7ae52..1b757f5 100644
--- a/src/pcap/cmd_utils.h
+++ b/src/pcap/cmd_utils.h
@@ -12,10 +12,9 @@
#define _SPPWK_CMD_UTILS_H_
/**
- * @file
- * SPP process
+ * @file cmd_utils.h
*
- * SPP component common function.
+ * Command utility functions for SPP worker thread.
*/
#include <netinet/in.h>
@@ -34,14 +33,13 @@
#define SPP_CORE_STATUS_CHECK_MAX 5
/* TODO(yasufum) merge it to the same definition in shared/.../cmd_utils.h */
-/* State on core */
+/* Status of a component on lcore. */
enum sppwk_lcore_status {
- SPP_CORE_UNUSE, /**< Not used */
- SPP_CORE_STOP, /**< Stopped */
- SPP_CORE_IDLE, /**< Idling */
- SPP_CORE_FORWARD, /**< Forwarding */
- SPP_CORE_STOP_REQUEST, /**< Request stopping */
- SPP_CORE_IDLE_REQUEST /**< Request idling */
+ SPPWK_LCORE_UNUSED,
+ SPPWK_LCORE_STOPPED,
+ SPPWK_LCORE_IDLING,
+ SPPWK_LCORE_RUNNING,
+ SPPWK_LCORE_REQ_STOP /**< Request for stopping. */
};
/* State on capture */
diff --git a/src/pcap/spp_pcap.c b/src/pcap/spp_pcap.c
index 6762337..80e6aad 100644
--- a/src/pcap/spp_pcap.c
+++ b/src/pcap/spp_pcap.c
@@ -860,10 +860,10 @@ slave_main(void *arg __attribute__ ((unused)))
pcap_info->thread_no, lcore_id);
pcap_info->type = PCAP_WRITE;
}
- set_core_status(lcore_id, SPP_CORE_IDLE);
+ set_core_status(lcore_id, SPPWK_LCORE_IDLING);
while (1) {
- if (sppwk_get_lcore_status(lcore_id) == SPP_CORE_STOP_REQUEST) {
+ if (sppwk_get_lcore_status(lcore_id) == SPPWK_LCORE_REQ_STOP) {
if (pcap_info->status == SPP_CAPTURE_IDLE)
break;
if (pcap_info->type == PCAP_RECEIVE)
@@ -882,7 +882,7 @@ slave_main(void *arg __attribute__ ((unused)))
}
}
- set_core_status(lcore_id, SPP_CORE_STOP);
+ set_core_status(lcore_id, SPPWK_LCORE_STOPPED);
RTE_LOG(INFO, SPP_PCAP,
"Terminated slave on lcore %d.\n", lcore_id);
return ret;
@@ -1024,19 +1024,19 @@ main(int argc, char *argv[])
/* Set the status of main thread to 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);
+ g_core_info[master_lcore].status = SPPWK_LCORE_IDLING;
+ int ret_wait = check_core_status_wait(SPPWK_LCORE_IDLING);
if (unlikely(ret_wait != 0))
break;
/* Start secondary */
- set_all_core_status(SPP_CORE_FORWARD);
+ set_all_core_status(SPPWK_LCORE_RUNNING);
RTE_LOG(INFO, SPP_PCAP, "[Press Ctrl-C to quit ...]\n");
/* Enter loop for accepting commands */
int ret_do = 0;
while (likely(g_core_info[master_lcore].status !=
- SPP_CORE_STOP_REQUEST)) {
+ SPPWK_LCORE_REQ_STOP)) {
/* Receive command */
ret_do = spp_command_proc_do();
if (unlikely(ret_do != SPPWK_RET_OK))
@@ -1049,7 +1049,7 @@ main(int argc, char *argv[])
}
if (unlikely(ret_do != SPPWK_RET_OK)) {
- set_all_core_status(SPP_CORE_STOP_REQUEST);
+ set_all_core_status(SPPWK_LCORE_REQ_STOP);
break;
}
@@ -1058,8 +1058,8 @@ main(int argc, char *argv[])
}
/* Finalize to exit */
- g_core_info[master_lcore].status = SPP_CORE_STOP;
- int ret_core_end = check_core_status_wait(SPP_CORE_STOP);
+ g_core_info[master_lcore].status = SPPWK_LCORE_STOPPED;
+ int ret_core_end = check_core_status_wait(SPPWK_LCORE_STOPPED);
if (unlikely(ret_core_end != 0))
RTE_LOG(ERR, SPP_PCAP, "Failed to terminate master thread.\n");
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.h b/src/shared/secondary/spp_worker_th/cmd_utils.h
index 596ba5e..87c9b2c 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.h
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.h
@@ -80,7 +80,7 @@ enum sppwk_lcore_status {
SPPWK_LCORE_STOPPED,
SPPWK_LCORE_IDLING,
SPPWK_LCORE_RUNNING,
- SPPWK_LCORE_REQ_STOP /**< Request stopping */
+ SPPWK_LCORE_REQ_STOP /**< Request for stopping. */
};
/* Type of SPP worker thread. */
--
2.17.1
^ permalink raw reply [flat|nested] 3+ messages in thread