[spp] [PATCH 09/13] shared/sec: move lcore funcs in response_info_list
yasufum.o at gmail.com
yasufum.o at gmail.com
Mon Jun 24 06:36:09 CEST 2019
From: Yasufumi Ogawa <yasufum.o at gmail.com>
This update is to move operation functions for making command response
which is defined in `cmd_runner.c` to `cmd_res_formatter.c`. Operation
functions are defined as following, and this update moves
`add_master_lcore` and `add_core`. The rest of operation functions are
moved in next patches.
struct cmd_response response_info_list[] = {
{ "client-id", add_client_id },
{ "phy", add_interface },
{ "vhost", add_interface },
{ "ring", add_interface },
{ "master-lcore", add_master_lcore},
{ "core", add_core},
#ifdef SPP_VF_MODULE
{ "classifier_table", add_classifier_table},
#endif /* SPP_VF_MODULE */
{ "", NULL }
};
Signed-off-by: Yasufumi Ogawa <yasufum.o at gmail.com>
---
.../spp_worker_th/cmd_res_formatter.c | 104 ++++++++++++++++++
.../spp_worker_th/cmd_res_formatter.h | 6 +
.../secondary/spp_worker_th/cmd_runner.c | 100 -----------------
3 files changed, 110 insertions(+), 100 deletions(-)
diff --git a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
index b94cb29..d838a18 100644
--- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
+++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
@@ -4,6 +4,8 @@
#include "cmd_res_formatter.h"
#include "cmd_utils.h"
+#include "vf_deps.h"
+#include "mirror_deps.h"
#include "shared/secondary/json_helper.h"
#define RTE_LOGTYPE_WK_CMD_RES_FMT RTE_LOGTYPE_USER1
@@ -533,3 +535,105 @@ append_command_results_value(const char *name, char **output,
return ret;
}
+/* Iterate core information to create response to status command */
+static int
+spp_iterate_core_info(struct spp_iterate_core_params *params)
+{
+ int ret;
+ int lcore_id, cnt;
+ struct core_info *core = NULL;
+ struct sppwk_comp_info *comp_info_base = NULL;
+ struct sppwk_comp_info *comp_info = NULL;
+
+ RTE_LCORE_FOREACH_SLAVE(lcore_id) {
+ if (spp_get_core_status(lcore_id) == SPP_CORE_UNUSE)
+ continue;
+
+ core = get_core_info(lcore_id);
+ if (core->num == 0) {
+ ret = (*params->element_proc)(
+ params, lcore_id,
+ "", SPPWK_TYPE_NONE_STR,
+ 0, NULL, 0, NULL);
+ if (unlikely(ret != 0)) {
+ RTE_LOG(ERR, WK_CMD_RES_FMT,
+ "Cannot iterate core "
+ "information. "
+ "(core = %d, type = %d)\n",
+ lcore_id, SPPWK_TYPE_NONE);
+ return SPP_RET_NG;
+ }
+ continue;
+ }
+
+ for (cnt = 0; cnt < core->num; cnt++) {
+ sppwk_get_mng_data(NULL, NULL, &comp_info_base,
+ NULL, NULL, NULL, NULL);
+ comp_info = (comp_info_base + core->id[cnt]);
+#ifdef SPP_VF_MODULE
+ if (comp_info->wk_type == SPPWK_TYPE_CLS) {
+ ret = get_classifier_status(lcore_id,
+ core->id[cnt], params);
+ } else {
+ ret = get_forwarder_status(lcore_id,
+ core->id[cnt], params);
+ }
+#endif /* SPP_VF_MODULE */
+#ifdef SPP_MIRROR_MODULE
+ ret = get_mirror_status(lcore_id, core->id[cnt],
+ params);
+#endif /* SPP_MIRROR_MODULE */
+ if (unlikely(ret != 0)) {
+ RTE_LOG(ERR, WK_CMD_RES_FMT,
+ "Cannot iterate core "
+ "information. "
+ "(core = %d, type = %d)\n",
+ lcore_id, comp_info->wk_type);
+ return SPP_RET_NG;
+ }
+ }
+ }
+
+ return SPP_RET_OK;
+}
+
+/* Add entry of master lcore to a response in JSON. */
+int
+add_master_lcore(const char *name, char **output,
+ void *tmp __attribute__ ((unused)))
+{
+ int ret = SPP_RET_NG;
+ ret = append_json_int_value(output, name, rte_get_master_lcore());
+ return ret;
+}
+
+/* Add entry of core info of worker to a response in JSON such as "core:0". */
+int
+add_core(const char *name, char **output,
+ void *tmp __attribute__ ((unused)))
+{
+ int ret = SPP_RET_NG;
+ struct spp_iterate_core_params itr_params;
+ char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
+ if (unlikely(tmp_buff == NULL)) {
+ RTE_LOG(ERR, WK_CMD_RES_FMT,
+ /* TODO(yasufum) refactor no meaning err msg */
+ "allocate error. (name = %s)\n",
+ name);
+ return SPP_RET_NG;
+ }
+
+ itr_params.output = tmp_buff;
+ itr_params.element_proc = append_core_element_value;
+
+ ret = spp_iterate_core_info(&itr_params);
+ if (unlikely(ret != SPP_RET_OK)) {
+ spp_strbuf_free(itr_params.output);
+ return SPP_RET_NG;
+ }
+
+ ret = append_json_array_brackets(output, name, itr_params.output);
+ spp_strbuf_free(itr_params.output);
+ return ret;
+}
+
diff --git a/src/shared/secondary/spp_worker_th/cmd_res_formatter.h b/src/shared/secondary/spp_worker_th/cmd_res_formatter.h
index f3e9879..9c77763 100644
--- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.h
+++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.h
@@ -72,4 +72,10 @@ int append_response_list_value(char **output, struct cmd_response *responses,
int append_command_results_value(const char *name, char **output,
int num, struct cmd_result *results);
+int add_master_lcore(const char *name, char **output,
+ void *tmp __attribute__ ((unused)));
+
+int add_core(const char *name, char **output,
+ void *tmp __attribute__ ((unused)));
+
#endif
diff --git a/src/shared/secondary/spp_worker_th/cmd_runner.c b/src/shared/secondary/spp_worker_th/cmd_runner.c
index 5644aec..a6894fc 100644
--- a/src/shared/secondary/spp_worker_th/cmd_runner.c
+++ b/src/shared/secondary/spp_worker_th/cmd_runner.c
@@ -418,66 +418,6 @@ flush_cmd(void)
return ret;
}
-/* Iterate core information to create response to status command */
-static int
-spp_iterate_core_info(struct spp_iterate_core_params *params)
-{
- int ret;
- int lcore_id, cnt;
- struct core_info *core = NULL;
- struct sppwk_comp_info *comp_info_base = NULL;
- struct sppwk_comp_info *comp_info = NULL;
-
- RTE_LCORE_FOREACH_SLAVE(lcore_id) {
- if (spp_get_core_status(lcore_id) == SPP_CORE_UNUSE)
- continue;
-
- core = get_core_info(lcore_id);
- if (core->num == 0) {
- ret = (*params->element_proc)(
- params, lcore_id,
- "", SPPWK_TYPE_NONE_STR,
- 0, NULL, 0, NULL);
- if (unlikely(ret != 0)) {
- RTE_LOG(ERR, WK_CMD_RUNNER, "Cannot iterate core "
- "information. "
- "(core = %d, type = %d)\n",
- lcore_id, SPPWK_TYPE_NONE);
- return SPP_RET_NG;
- }
- continue;
- }
-
- for (cnt = 0; cnt < core->num; cnt++) {
- sppwk_get_mng_data(NULL, NULL, &comp_info_base,
- NULL, NULL, NULL, NULL);
- comp_info = (comp_info_base + core->id[cnt]);
-#ifdef SPP_VF_MODULE
- if (comp_info->wk_type == SPPWK_TYPE_CLS) {
- ret = get_classifier_status(lcore_id,
- core->id[cnt], params);
- } else {
- ret = get_forwarder_status(lcore_id,
- core->id[cnt], params);
- }
-#endif /* SPP_VF_MODULE */
-#ifdef SPP_MIRROR_MODULE
- ret = get_mirror_status(lcore_id, core->id[cnt],
- params);
-#endif /* SPP_MIRROR_MODULE */
- if (unlikely(ret != 0)) {
- RTE_LOG(ERR, WK_CMD_RUNNER, "Cannot iterate core "
- "information. "
- "(core = %d, type = %d)\n",
- lcore_id, comp_info->wk_type);
- return SPP_RET_NG;
- }
- }
- }
-
- return SPP_RET_OK;
-}
-
/* Iterate classifier_table to create response to status command */
#ifdef SPP_VF_MODULE
static int
@@ -684,46 +624,6 @@ add_interface(const char *name, char **output,
return ret;
}
-/* Add entry of master lcore to a response in JSON. */
-static int
-add_master_lcore(const char *name, char **output,
- void *tmp __attribute__ ((unused)))
-{
- int ret = SPP_RET_NG;
- ret = append_json_int_value(output, name, rte_get_master_lcore());
- return ret;
-}
-
-/* Add entry of core info of worker to a response in JSON such as "core:0". */
-static int
-add_core(const char *name, char **output,
- void *tmp __attribute__ ((unused)))
-{
- int ret = SPP_RET_NG;
- struct spp_iterate_core_params itr_params;
- char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
- if (unlikely(tmp_buff == NULL)) {
- RTE_LOG(ERR, WK_CMD_RUNNER,
- /* TODO(yasufum) refactor no meaning err msg */
- "allocate error. (name = %s)\n",
- name);
- return SPP_RET_NG;
- }
-
- itr_params.output = tmp_buff;
- itr_params.element_proc = append_core_element_value;
-
- ret = spp_iterate_core_info(&itr_params);
- if (unlikely(ret != SPP_RET_OK)) {
- spp_strbuf_free(itr_params.output);
- return SPP_RET_NG;
- }
-
- ret = append_json_array_brackets(output, name, itr_params.output);
- spp_strbuf_free(itr_params.output);
- return ret;
-}
-
#ifdef SPP_VF_MODULE
/**
* Add entries of classifier table in JSON. Before iterating the entries,
--
2.17.1
More information about the spp
mailing list