From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 9F361A045E for ; Fri, 31 May 2019 05:38:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 86A841B964; Fri, 31 May 2019 05:38:41 +0200 (CEST) Received: from tama50.ecl.ntt.co.jp (tama50.ecl.ntt.co.jp [129.60.39.147]) by dpdk.org (Postfix) with ESMTP id 8504F1B948 for ; Fri, 31 May 2019 05:38:39 +0200 (CEST) Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id x4V3ccut023655; Fri, 31 May 2019 12:38:38 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 61BD66395DC; Fri, 31 May 2019 12:38:38 +0900 (JST) Received: from localhost.localdomain (lobster.nslab.ecl.ntt.co.jp [129.60.13.95]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 4AFBF6395E1; Fri, 31 May 2019 12:38:38 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp Date: Fri, 31 May 2019 12:36:01 +0900 Message-Id: <1559273765-26130-8-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1559273765-26130-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> References: <1559273765-26130-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH 07/11] shared/sec: rename func for getting component ID X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" From: Yasufumi Ogawa 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 --- .../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