Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 6/6] shared/sec: rename struct spp_command
Date: Fri, 31 May 2019 12:36:59 +0900	[thread overview]
Message-ID: <1559273819-26243-7-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <1559273819-26243-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp>

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

The name of struct `spp_command` is too wide in meaning. It is just a
set of attributes of command for SPP worker thread actually. This update
is to rename it to `sppwk_cmd_attrs`.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 .../secondary/spp_worker_th/cmd_parser.c      | 47 ++++++++++---------
 .../secondary/spp_worker_th/cmd_parser.h      |  8 ++--
 .../secondary/spp_worker_th/cmd_runner.c      | 20 ++++----
 3 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index 0f0e64c..621bea4 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -796,25 +796,25 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 	{  /* classifier_table(mac) */
 		{
 			.name = "action",
-			.offset = offsetof(struct spp_command,
+			.offset = offsetof(struct sppwk_cmd_attrs,
 					spec.cls_table.wk_action),
 			.func = parse_cls_action
 		},
 		{
 			.name = "type",
-			.offset = offsetof(struct spp_command,
+			.offset = offsetof(struct sppwk_cmd_attrs,
 					spec.cls_table.type),
 			.func = parse_cls_type
 		},
 		{
 			.name = "mac address",
-			.offset = offsetof(struct spp_command,
+			.offset = offsetof(struct sppwk_cmd_attrs,
 					spec.cls_table.mac),
 			.func = parse_mac_addr
 		},
 		{
 			.name = "port",
-			.offset = offsetof(struct spp_command,
+			.offset = offsetof(struct sppwk_cmd_attrs,
 					spec.cls_table),
 			.func = parse_cls_port
 		},
@@ -823,31 +823,31 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 	{  /* classifier_table(VLAN) */
 		{
 			.name = "action",
-			.offset = offsetof(struct spp_command,
+			.offset = offsetof(struct sppwk_cmd_attrs,
 					spec.cls_table.wk_action),
 			.func = parse_cls_action
 		},
 		{
 			.name = "type",
-			.offset = offsetof(struct spp_command,
+			.offset = offsetof(struct sppwk_cmd_attrs,
 					spec.cls_table.type),
 			.func = parse_cls_type
 		},
 		{
 			.name = "vlan id",
-			.offset = offsetof(struct spp_command,
+			.offset = offsetof(struct sppwk_cmd_attrs,
 					spec.cls_table.vid),
 			.func = parse_cls_vid
 		},
 		{
 			.name = "mac address",
-			.offset = offsetof(struct spp_command,
+			.offset = offsetof(struct sppwk_cmd_attrs,
 					spec.cls_table.mac),
 			.func = parse_mac_addr
 		},
 		{
 			.name = "port",
-			.offset = offsetof(struct spp_command,
+			.offset = offsetof(struct sppwk_cmd_attrs,
 					spec.cls_table),
 			.func = parse_cls_port
 		},
@@ -859,23 +859,23 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 	{  /* component */
 		{
 			.name = "action",
-			.offset = offsetof(struct spp_command,
+			.offset = offsetof(struct sppwk_cmd_attrs,
 					spec.comp.wk_action),
 			.func = parse_comp_action
 		},
 		{
 			.name = "component name",
-			.offset = offsetof(struct spp_command, spec.comp),
+			.offset = offsetof(struct sppwk_cmd_attrs, spec.comp),
 			.func = parse_comp_name
 		},
 		{
 			.name = "core",
-			.offset = offsetof(struct spp_command, spec.comp),
+			.offset = offsetof(struct sppwk_cmd_attrs, spec.comp),
 			.func = parse_comp_lcore_id
 		},
 		{
 			.name = "component type",
-			.offset = offsetof(struct spp_command, spec.comp),
+			.offset = offsetof(struct sppwk_cmd_attrs, spec.comp),
 			.func = parse_comp_type
 		},
 		SPPWK_CMD_NO_PARAMS,
@@ -883,38 +883,39 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 	{  /* port */
 		{
 			.name = "action",
-			.offset = offsetof(struct spp_command,
+			.offset = offsetof(struct sppwk_cmd_attrs,
 					spec.port.wk_action),
 			.func = parse_port_action
 		},
 		{
 			.name = "port",
-			.offset = offsetof(struct spp_command, spec.port),
+			.offset = offsetof(struct sppwk_cmd_attrs, spec.port),
 			.func = parse_port
 		},
 		{
 			.name = "port rxtx",
-			.offset = offsetof(struct spp_command, spec.port),
+			.offset = offsetof(struct sppwk_cmd_attrs, spec.port),
 			.func = parse_port_rxtx
 		},
 		{
 			.name = "component name",
-			.offset = offsetof(struct spp_command, spec.port.name),
+			.offset = offsetof(struct sppwk_cmd_attrs,
+					spec.port.name),
 			.func = parse_comp_name_portcmd
 		},
 		{
 			.name = "port vlan operation",
-			.offset = offsetof(struct spp_command, spec.port),
+			.offset = offsetof(struct sppwk_cmd_attrs, spec.port),
 			.func = parse_port_vlan_ops
 		},
 		{
 			.name = "port vid",
-			.offset = offsetof(struct spp_command, spec.port),
+			.offset = offsetof(struct sppwk_cmd_attrs, spec.port),
 			.func = parse_port_vid
 		},
 		{
 			.name = "port pcp",
-			.offset = offsetof(struct spp_command, spec.port),
+			.offset = offsetof(struct sppwk_cmd_attrs, spec.port),
 			.func = parse_port_pcp
 		},
 		SPPWK_CMD_NO_PARAMS,
@@ -1130,7 +1131,7 @@ sppwk_parse_req(
 	int i;
 
 	/* decode request */
-	request->num_command = 1;
+	request->nof_cmds = 1;
 	ret = parse_wk_cmd(request, request_str, wk_err_msg);
 	if (unlikely(ret != SPP_RET_OK)) {
 		RTE_LOG(ERR, WK_CMD_PARSER,
@@ -1139,10 +1140,10 @@ sppwk_parse_req(
 				ret, (int)request_str_len, request_str);
 		return ret;
 	}
-	request->num_valid_command = 1;
+	request->nof_valid_cmds = 1;
 
 	/* check getter command */
-	for (i = 0; i < request->num_valid_command; ++i) {
+	for (i = 0; i < request->nof_valid_cmds; ++i) {
 		switch (request->commands[i].type) {
 		case SPPWK_CMDTYPE_CLIENT_ID:
 			request->is_requested_client_id = 1;
diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.h b/src/shared/secondary/spp_worker_th/cmd_parser.h
index de4dcba..5a7df84 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.h
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.h
@@ -108,7 +108,7 @@ struct sppwk_cmd_port {
 };
 
 /* TODO(yasufum) Add usage and desc for members. What's command descriptors? */
-struct spp_command {
+struct sppwk_cmd_attrs {
 	enum sppwk_cmd_type type; /**< command type */
 
 	union {  /**< command descriptors */
@@ -121,9 +121,9 @@ struct spp_command {
 
 /* Request parameters. */
 struct sppwk_cmd_req {
-	int num_command;  /**< Number of accepted commands */
-	int num_valid_command;  /**< Number of executed commands */
-	struct spp_command commands[SPPWK_MAX_CMDS];  /**< list of cmds */
+	int nof_cmds;  /**< Number of accepted commands */
+	int nof_valid_cmds;  /**< Number of executed commands */
+	struct sppwk_cmd_attrs commands[SPPWK_MAX_CMDS];  /**< list of cmds */
 
 	int is_requested_client_id;
 	int is_requested_status;
diff --git a/src/shared/secondary/spp_worker_th/cmd_runner.c b/src/shared/secondary/spp_worker_th/cmd_runner.c
index 3c80db9..c3e1c9c 100644
--- a/src/shared/secondary/spp_worker_th/cmd_runner.c
+++ b/src/shared/secondary/spp_worker_th/cmd_runner.c
@@ -726,7 +726,7 @@ append_json_block_brackets(const char *name, char **output, const char *str)
 
 /* Execute one command. */
 static int
-exec_one_cmd(const struct spp_command *cmd)
+exec_one_cmd(const struct sppwk_cmd_attrs *cmd)
 {
 	int ret;
 
@@ -856,7 +856,7 @@ prepare_parse_err_msg(struct cmd_result *results,
 	const char *tmp_buff;
 	char error_messege[CMD_ERR_MSG_LEN];
 
-	for (i = 0; i < request->num_command; i++) {
+	for (i = 0; i < request->nof_cmds; i++) {
 		if (wk_err_msg->code == 0)
 			set_cmd_result(&results[i], CMD_SUCCESS, "");
 		else
@@ -865,7 +865,7 @@ prepare_parse_err_msg(struct cmd_result *results,
 
 	if (wk_err_msg->code != 0) {
 		tmp_buff = get_parse_err_msg(wk_err_msg, error_messege);
-		set_cmd_result(&results[request->num_valid_command],
+		set_cmd_result(&results[request->nof_valid_cmds],
 				CMD_FAILED, tmp_buff);
 	}
 }
@@ -1482,7 +1482,7 @@ append_info_value(const char *name, char **output)
 static void
 send_decode_error_response(int *sock,
 		const struct sppwk_cmd_req *request,
-		struct cmd_result *command_results)
+		struct cmd_result *cmd_results)
 {
 	int ret = SPP_RET_NG;
 	char *msg, *tmp_buff;
@@ -1496,7 +1496,7 @@ send_decode_error_response(int *sock,
 
 	/* create & append result array */
 	ret = append_command_results_value("results", &tmp_buff,
-			request->num_command, command_results);
+			request->nof_cmds, cmd_results);
 	if (unlikely(ret < SPP_RET_OK)) {
 		spp_strbuf_free(tmp_buff);
 		RTE_LOG(ERR, WK_CMD_RUNNER,
@@ -1541,7 +1541,7 @@ send_decode_error_response(int *sock,
 static void
 send_command_result_response(int *sock,
 		const struct sppwk_cmd_req *request,
-		struct cmd_result *command_results)
+		struct cmd_result *cmd_results)
 {
 	int ret = SPP_RET_NG;
 	char *msg, *tmp_buff;
@@ -1555,7 +1555,7 @@ send_command_result_response(int *sock,
 
 	/* create & append result array */
 	ret = append_command_results_value("results", &tmp_buff,
-			request->num_command, command_results);
+			request->nof_cmds, cmd_results);
 	if (unlikely(ret < SPP_RET_OK)) {
 		spp_strbuf_free(tmp_buff);
 		RTE_LOG(ERR, WK_CMD_RUNNER,
@@ -1650,16 +1650,16 @@ exec_cmds(int *sock, const char *req_str, size_t req_str_len)
 
 	RTE_LOG(DEBUG, WK_CMD_RUNNER,
 			"Num of cmds is %d, and valid cmds is %d\n",
-			cmd_req.num_command, cmd_req.num_valid_command);
+			cmd_req.nof_cmds, cmd_req.nof_valid_cmds);
 
 	/* execute commands */
-	for (i = 0; i < cmd_req.num_command ; ++i) {
+	for (i = 0; i < cmd_req.nof_cmds; ++i) {
 		ret = exec_one_cmd(cmd_req.commands + i);
 		if (unlikely(ret != SPP_RET_OK)) {
 			set_cmd_result(&cmd_results[i], CMD_FAILED,
 					"error occur");
 			/* Does not execute remaining commands */
-			for (++i; i < cmd_req.num_command ; ++i)
+			for (++i; i < cmd_req.nof_cmds; ++i)
 				set_cmd_result(&cmd_results[i],
 					CMD_INVALID, "");
 			break;
-- 
2.17.1


      parent reply	other threads:[~2019-05-31  3:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31  3:36 [spp] [PATCH 0/6] Refactor functions for manipulating thread info ogawa.yasufumi
2019-05-31  3:36 ` [spp] [PATCH 1/6] shared/sec: refactor func for deleting comp info ogawa.yasufumi
2019-05-31  3:36 ` [spp] [PATCH 2/6] shared/sec: revise types of spp worker ogawa.yasufumi
2019-05-31  3:36 ` [spp] [PATCH 3/6] shared/sec: rename funcs of flush cmd ogawa.yasufumi
2019-05-31  3:36 ` [spp] [PATCH 4/6] shared/sec: rename file spp_proc to cmd_utils ogawa.yasufumi
2019-05-31  3:36 ` [spp] [PATCH 5/6] shared/sec: refactor name of funcs for exec cmd ogawa.yasufumi
2019-05-31  3:36 ` ogawa.yasufumi [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=1559273819-26243-7-git-send-email-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --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).