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 10/13] shared/sec: move ope cli-id in response_info_list
Date: Mon, 24 Jun 2019 13:36:10 +0900	[thread overview]
Message-ID: <20190624043613.19271-11-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 `add_client_id` and
`add_interface` which is defined in `cmd_runner.c` to
`cmd_res_formatter.c`.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 .../spp_worker_th/cmd_res_formatter.c         | 57 +++++++++++++++++++
 .../spp_worker_th/cmd_res_formatter.h         | 11 ++++
 .../secondary/spp_worker_th/cmd_runner.c      | 52 -----------------
 3 files changed, 68 insertions(+), 52 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 d838a18..3476580 100644
--- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
+++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
@@ -597,6 +597,63 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
 	return SPP_RET_OK;
 }
 
+/* TODO(yasufum) move to another file for util funcs. */
+/* Get client ID from global command params. */
+static int
+wk_get_client_id(void)
+{
+	struct startup_param *params;
+	sppwk_get_mng_data(&params, NULL, NULL, NULL, NULL, NULL, NULL);
+	return params->client_id;
+}
+
+/**
+ * Operator functions start with prefix `add_` defined in `response_info_list`
+ * of struct `cmd_response` which are for making each of parts of command
+ * response.
+ */
+/* Add entry of client ID to a response in JSON. */
+int
+add_client_id(const char *name, char **output,
+		void *tmp __attribute__ ((unused)))
+{
+	return append_json_int_value(output, name, wk_get_client_id());
+}
+
+/* Add entry of port to a response in JSON such as "phy:0". */
+int
+add_interface(const char *name, char **output,
+		void *tmp __attribute__ ((unused)))
+{
+	int ret = SPP_RET_NG;
+	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;
+	}
+
+	if (strcmp(name, SPP_IFTYPE_NIC_STR) == 0)
+		ret = append_interface_array(&tmp_buff, PHY);
+
+	else if (strcmp(name, SPP_IFTYPE_VHOST_STR) == 0)
+		ret = append_interface_array(&tmp_buff, VHOST);
+
+	else if (strcmp(name, SPP_IFTYPE_RING_STR) == 0)
+		ret = append_interface_array(&tmp_buff, RING);
+
+	if (unlikely(ret < SPP_RET_OK)) {
+		spp_strbuf_free(tmp_buff);
+		return SPP_RET_NG;
+	}
+
+	ret = append_json_array_brackets(output, name, tmp_buff);
+	spp_strbuf_free(tmp_buff);
+	return ret;
+}
+
 /* Add entry of master lcore to a response in JSON. */
 int
 add_master_lcore(const char *name, char **output,
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 9c77763..bc0109c 100644
--- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.h
+++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.h
@@ -72,6 +72,17 @@ 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);
 
+/**
+ * Operator functions start with prefix `add_` defined in `response_info_list`
+ * of struct `cmd_response` which are for making each of parts of command
+ * response.
+ */
+int add_client_id(const char *name, char **output,
+		void *tmp __attribute__ ((unused)));
+
+int add_interface(const char *name, char **output,
+		void *tmp __attribute__ ((unused)));
+
 int add_master_lcore(const char *name, char **output,
 		void *tmp __attribute__ ((unused)));
 
diff --git a/src/shared/secondary/spp_worker_th/cmd_runner.c b/src/shared/secondary/spp_worker_th/cmd_runner.c
index a6894fc..007d62e 100644
--- a/src/shared/secondary/spp_worker_th/cmd_runner.c
+++ b/src/shared/secondary/spp_worker_th/cmd_runner.c
@@ -29,16 +29,6 @@ enum cmd_res_code {
 	CMD_INVALID,
 };
 
-/* TODO(yasufum) move to another file for util funcs. */
-/* Get client ID from global command params. */
-static int
-sppwk_get_client_id(void)
-{
-	struct startup_param *params;
-	sppwk_get_mng_data(&params, NULL, NULL, NULL, NULL, NULL, NULL);
-	return params->client_id;
-}
-
 /* Update classifier table with given action, add or del. */
 static int
 update_cls_table(enum sppwk_action wk_action,
@@ -582,48 +572,6 @@ prepare_parse_err_msg(struct cmd_result *results,
 	}
 }
 
-/* Add entry of client ID to a response in JSON. */
-static int
-add_client_id(const char *name, char **output,
-		void *tmp __attribute__ ((unused)))
-{
-	return append_json_int_value(output, name, sppwk_get_client_id());
-}
-
-/* Add entry of port to a response in JSON such as "phy:0". */
-static int
-add_interface(const char *name, char **output,
-		void *tmp __attribute__ ((unused)))
-{
-	int ret = SPP_RET_NG;
-	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;
-	}
-
-	if (strcmp(name, SPP_IFTYPE_NIC_STR) == 0)
-		ret = append_interface_array(&tmp_buff, PHY);
-
-	else if (strcmp(name, SPP_IFTYPE_VHOST_STR) == 0)
-		ret = append_interface_array(&tmp_buff, VHOST);
-
-	else if (strcmp(name, SPP_IFTYPE_RING_STR) == 0)
-		ret = append_interface_array(&tmp_buff, RING);
-
-	if (unlikely(ret < SPP_RET_OK)) {
-		spp_strbuf_free(tmp_buff);
-		return SPP_RET_NG;
-	}
-
-	ret = append_json_array_brackets(output, name, tmp_buff);
-	spp_strbuf_free(tmp_buff);
-	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 ` [spp] [PATCH 09/13] shared/sec: move lcore funcs in response_info_list yasufum.o
2019-06-24  4:36 ` yasufum.o [this message]
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-11-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).