Soft Patch Panel
 help / color / mirror / Atom feed
From: yasufum.o@gmail.com
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 09/13] shared/sec: move lcore funcs in response_info_list
Date: Mon, 24 Jun 2019 13:36:09 +0900	[thread overview]
Message-ID: <20190624043613.19271-10-yasufum.o@gmail.com> (raw)
In-Reply-To: <20190624043613.19271-1-yasufum.o@gmail.com>

From: Yasufumi Ogawa <yasufum.o@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@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


  parent reply	other threads:[~2019-06-24  4:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24  4:36 [spp] [PATCH 00/13] Move JSON utils from libs for running cmds yasufum.o
2019-06-24  4:36 ` [spp] [PATCH 01/13] shared/sec: rename ops for setup cmd response yasufum.o
2019-06-24  4:36 ` [spp] [PATCH 02/13] shared/sec: rename functions for spp_mirror yasufum.o
2019-06-24  4:36 ` [spp] [PATCH 03/13] shared/sec: move principle JSON formatter funcs yasufum.o
2019-06-24  4:36 ` [spp] [PATCH 04/13] shared/sec: change order of args of JSON fmtters yasufum.o
2019-06-24  4:36 ` [spp] [PATCH 05/13] shared/sec: move JSON formatter to shard/secondary yasufum.o
2019-06-24  4:36 ` [spp] [PATCH 06/13] shared/sec: revise including headers yasufum.o
2019-06-24  4:36 ` [spp] [PATCH 07/13] shared/sec: move JSON formatters from cmd_runner yasufum.o
2019-06-24  4:36 ` [spp] [PATCH 08/13] shared/sec: move rest of JSON formatters yasufum.o
2019-06-24  4:36 ` yasufum.o [this message]
2019-06-24  4:36 ` [spp] [PATCH 10/13] shared/sec: move ope cli-id in response_info_list yasufum.o
2019-06-24  4:36 ` [spp] [PATCH 11/13] shared/sec: move rest of ops " yasufum.o
2019-06-24  4:36 ` [spp] [PATCH 12/13] shared/sec: remove local funcs from header yasufum.o
2019-06-24  4:36 ` [spp] [PATCH 13/13] shared/sec: refactor comments for JSON formatter yasufum.o

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=20190624043613.19271-10-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).