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 07/11] shared/sec: rename func for getting component ID
Date: Fri, 31 May 2019 12:36:01 +0900	[thread overview]
Message-ID: <1559273765-26130-8-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <1559273765-26130-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp>

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

The term `component ID` is lcore ID used by a SPP worker thread
actually. Fuctions for managing component ID should be renamed for
lcore ID because it is confusing to use several terms for the same
resource. This update is to rename the functions and variables of
component ID to lcore ID to be explicit in meaning.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 .../secondary/spp_worker_th/cmd_parser.c      |  4 +-
 .../secondary/spp_worker_th/cmd_runner.c      | 42 ++++++++++---------
 src/shared/secondary/spp_worker_th/spp_proc.c | 21 ++++------
 src/shared/secondary/spp_worker_th/spp_proc.h | 16 ++++---
 4 files changed, 40 insertions(+), 43 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index f78664b..084b3e2 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -335,7 +335,7 @@ parse_comp_name(void *output, const char *arg_val,
 	/* Parsing the name is required only for action `start`. */
 	if (component->wk_action == SPPWK_ACT_START) {
 		/* Check if lcore is already used. */
-		ret = spp_get_component_id(arg_val);  /* Get lcore ID. */
+		ret = sppwk_get_lcore_id(arg_val);  /* Get lcore ID. */
 		if (unlikely(ret >= 0)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
 					"Comp name '%s' is already used.\n",
@@ -492,7 +492,7 @@ parse_comp_name_portcmd(void *output, const char *arg_val,
 	int ret = SPP_RET_OK;
 
 	/* Check if lcore is already used. */
-	ret = spp_get_component_id(arg_val);  /* Get lcore ID. */
+	ret = sppwk_get_lcore_id(arg_val);  /* Get lcore ID. */
 	if (unlikely(ret < SPP_RET_OK)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Unknown component name. val=%s\n", arg_val);
diff --git a/src/shared/secondary/spp_worker_th/cmd_runner.c b/src/shared/secondary/spp_worker_th/cmd_runner.c
index 3d07a28..420e19c 100644
--- a/src/shared/secondary/spp_worker_th/cmd_runner.c
+++ b/src/shared/secondary/spp_worker_th/cmd_runner.c
@@ -92,6 +92,7 @@ const char *CLS_TYPE_A_LIST[] = {
 	"",  /* termination */
 };
 
+/* TODO(yasufum) move to another file for util funcs. */
 /* Get client ID from global command params. */
 static int
 sppwk_get_client_id(void)
@@ -101,6 +102,7 @@ sppwk_get_client_id(void)
 	return params->client_id;
 }
 
+/* TODO(yasufum) move to another file for util funcs. */
 /* Get proc type from global command params. */
 static int
 sppwk_get_proc_type(void)
@@ -215,7 +217,7 @@ spp_update_component(
 {
 	int ret = SPP_RET_NG;
 	int ret_del = -1;
-	int component_id = 0;
+	int comp_lcore_id = 0;
 	unsigned int tmp_lcore_id = 0;
 	struct spp_component_info *comp_info = NULL;
 	struct core_info *core = NULL;
@@ -237,15 +239,15 @@ spp_update_component(
 			return SPP_RET_NG;
 		}
 
-		component_id = spp_get_component_id(name);
-		if (component_id >= 0) {
+		comp_lcore_id = sppwk_get_lcore_id(name);
+		if (comp_lcore_id >= 0) {
 			RTE_LOG(ERR, APP, "Component name '%s' is already "
 				"used.\n", name);
 			return SPP_RET_NG;
 		}
 
-		component_id = get_free_component();
-		if (component_id < 0) {
+		comp_lcore_id = get_free_lcore_id();
+		if (comp_lcore_id < 0) {
 			RTE_LOG(ERR, APP, "Cannot assign component over the "
 				"maximum number.\n");
 			return SPP_RET_NG;
@@ -253,26 +255,26 @@ spp_update_component(
 
 		core = &info->core[info->upd_index];
 
-		comp_info = (comp_info_base + component_id);
+		comp_info = (comp_info_base + comp_lcore_id);
 		memset(comp_info, 0x00, sizeof(struct spp_component_info));
 		strcpy(comp_info->name, name);
 		comp_info->type		= type;
 		comp_info->lcore_id	= lcore_id;
-		comp_info->component_id	= component_id;
+		comp_info->component_id	= comp_lcore_id;
 
-		core->id[core->num] = component_id;
+		core->id[core->num] = comp_lcore_id;
 		core->num++;
 		ret = SPP_RET_OK;
 		tmp_lcore_id = lcore_id;
-		*(change_component + component_id) = 1;
+		*(change_component + comp_lcore_id) = 1;
 		break;
 
 	case SPPWK_ACT_STOP:
-		component_id = spp_get_component_id(name);
-		if (component_id < 0)
+		comp_lcore_id = sppwk_get_lcore_id(name);
+		if (comp_lcore_id < 0)
 			return SPP_RET_OK;
 
-		comp_info = (comp_info_base + component_id);
+		comp_info = (comp_info_base + comp_lcore_id);
 		tmp_lcore_id = comp_info->lcore_id;
 		memset(comp_info, 0x00, sizeof(struct spp_component_info));
 
@@ -282,17 +284,17 @@ spp_update_component(
 #ifdef SPP_VF_MODULE
 		/* initialize classifier information */
 		if (comp_info->type == SPP_COMPONENT_CLASSIFIER_MAC)
-			init_classifier_info(component_id);
+			init_classifier_info(comp_lcore_id);
 #endif /* SPP_VF_MODULE */
 
-		ret_del = del_component_info(component_id,
+		ret_del = del_component_info(comp_lcore_id,
 				core->num, core->id);
 		if (ret_del >= 0)
 			/* If deleted, decrement number. */
 			core->num--;
 
 		ret = SPP_RET_OK;
-		*(change_component + component_id) = 0;
+		*(change_component + comp_lcore_id) = 0;
 		break;
 
 	default:
@@ -358,7 +360,7 @@ spp_update_port(enum sppwk_action wk_action,
 	int ret = SPP_RET_NG;
 	int port_idx;
 	int ret_del = -1;
-	int component_id = 0;
+	int comp_lcore_id = 0;
 	int cnt = 0;
 	struct spp_component_info *comp_info = NULL;
 	struct sppwk_port_info *port_info = NULL;
@@ -367,15 +369,15 @@ spp_update_port(enum sppwk_action wk_action,
 	struct spp_component_info *comp_info_base = NULL;
 	int *change_component = NULL;
 
-	component_id = spp_get_component_id(name);
-	if (component_id < 0) {
+	comp_lcore_id = sppwk_get_lcore_id(name);
+	if (comp_lcore_id < 0) {
 		RTE_LOG(ERR, APP, "Unknown component by port command. "
 				"(component = %s)\n", name);
 		return SPP_RET_NG;
 	}
 	sppwk_get_mng_data(NULL, NULL,
 			&comp_info_base, NULL, NULL, &change_component, NULL);
-	comp_info = (comp_info_base + component_id);
+	comp_info = (comp_info_base + comp_lcore_id);
 	port_info = get_sppwk_port(port->iface_type, port->iface_no);
 	if (rxtx == SPP_PORT_RXTX_RX) {
 		nof_ports = &comp_info->num_rx_port;
@@ -466,7 +468,7 @@ spp_update_port(enum sppwk_action wk_action,
 		return SPP_RET_NG;
 	}
 
-	*(change_component + component_id) = 1;
+	*(change_component + comp_lcore_id) = 1;
 	return ret;
 }
 
diff --git a/src/shared/secondary/spp_worker_th/spp_proc.c b/src/shared/secondary/spp_worker_th/spp_proc.c
index 971ec9c..9c62bab 100644
--- a/src/shared/secondary/spp_worker_th/spp_proc.c
+++ b/src/shared/secondary/spp_worker_th/spp_proc.c
@@ -710,35 +710,32 @@ set_component_change_port(struct sppwk_port_info *port, enum spp_port_rxtx rxtx)
 	}
 }
 
-/* Get unused component id */
+/* Get ID of unused lcore. */
 int
-get_free_component(void)
+get_free_lcore_id(void)
 {
-	struct spp_component_info *component_info =
-					g_mng_data.p_component_info;
+	struct spp_component_info *comp_info = g_mng_data.p_component_info;
 
 	int cnt = 0;
 	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		if ((component_info + cnt)->type == SPP_COMPONENT_UNUSE)
+		if ((comp_info + cnt)->type == SPP_COMPONENT_UNUSE)
 			return cnt;
 	}
 	return SPP_RET_NG;
 }
 
-/* Get lcore id for as component name. */
-/* TODO(yasufum) change the name because it's not comp ID. */
+/* Get lcore ID as user-defined component name. */
 int
-spp_get_component_id(const char *name)
+sppwk_get_lcore_id(const char *comp_name)
 {
-	struct spp_component_info *component_info =
-		g_mng_data.p_component_info;
+	struct spp_component_info *comp_info = g_mng_data.p_component_info;
 
 	int cnt = 0;
-	if (name[0] == '\0')
+	if (comp_name[0] == '\0')
 		return SPP_RET_NG;
 
 	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		if (strcmp(name, (component_info + cnt)->name) == 0)
+		if (strcmp(comp_name, (comp_info + cnt)->name) == 0)
 			return cnt;
 	}
 	return SPP_RET_NG;
diff --git a/src/shared/secondary/spp_worker_th/spp_proc.h b/src/shared/secondary/spp_worker_th/spp_proc.h
index b490471..bdd628e 100644
--- a/src/shared/secondary/spp_worker_th/spp_proc.h
+++ b/src/shared/secondary/spp_worker_th/spp_proc.h
@@ -536,23 +536,21 @@ set_component_change_port(
 		struct sppwk_port_info *port, enum spp_port_rxtx rxtx);
 
 /**
- * Get unused component id
+ * Get ID of unused lcore.
  *
  * @retval 0~127 Component ID.
  * @retval -1    failed.
  */
-int get_free_component(void);
+int get_free_lcore_id(void);
 
 /**
- * Get component id for specified component name
+ * Get component ID from given name.
  *
- * @param name
- *  Component name.
- *
- * @retval 0~127      Component ID.
- * @retval SPP_RET_NG failed.
+ * @param[in] name Component name.
+ * @retval 0~127 Component ID.
+ * @retval SPP_RET_NG if failed.
  */
-int spp_get_component_id(const char *name);
+int sppwk_get_lcore_id(const char *comp_name);
 
 /**
  *  Delete component information.
-- 
2.17.1


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

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31  3:35 [spp] [PATCH 00/11] Refactor functions for handling commands ogawa.yasufumi
2019-05-31  3:35 ` [spp] [PATCH 01/11] shared/sec: rename functions of sppwk_cmd_runner ogawa.yasufumi
2019-05-31  3:35 ` [spp] [PATCH 02/11] shared/sec: revise enum for cmd response ogawa.yasufumi
2019-05-31  3:35 ` [spp] [PATCH 03/11] shared/sec: refactor passing err in cmd_runner ogawa.yasufumi
2019-05-31  3:35 ` [spp] [PATCH 04/11] shared/sec: rename struct for command response ogawa.yasufumi
2019-05-31  3:35 ` [spp] [PATCH 05/11] shared/sec: refactor funcs for managing port info ogawa.yasufumi
2019-05-31  3:36 ` [spp] [PATCH 06/11] shared/sec: rename util functions in cmd_runner ogawa.yasufumi
2019-05-31  3:36 ` ogawa.yasufumi [this message]
2019-05-31  3:36 ` [spp] [PATCH 08/11] shared/sec: refactor func for updating cls table ogawa.yasufumi
2019-05-31  3:36 ` [spp] [PATCH 09/11] shared/sec: rename func for executing command ogawa.yasufumi
2019-05-31  3:36 ` [spp] [PATCH 10/11] shared/sec: add helpers for logging cmd parser ogawa.yasufumi
2019-05-31  3:36 ` [spp] [PATCH 11/11] shared/sec: rename func for updating port ogawa.yasufumi

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=1559273765-26130-8-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).