From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 1/6] shared/sec: refactor func for deleting comp info
Date: Fri, 31 May 2019 12:36:54 +0900 [thread overview]
Message-ID: <1559273819-26243-2-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>
This update is to rename function misspelled `del_componet_info()` to
`del_comp_info()` to be simple, and revise name of vars and comments
for refactoring.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
.../secondary/spp_worker_th/cmd_runner.c | 19 +++++++----
src/shared/secondary/spp_worker_th/spp_proc.c | 33 ++++++++++---------
src/shared/secondary/spp_worker_th/spp_proc.h | 19 ++++++-----
3 files changed, 41 insertions(+), 30 deletions(-)
diff --git a/src/shared/secondary/spp_worker_th/cmd_runner.c b/src/shared/secondary/spp_worker_th/cmd_runner.c
index 613e924..cf86a6a 100644
--- a/src/shared/secondary/spp_worker_th/cmd_runner.c
+++ b/src/shared/secondary/spp_worker_th/cmd_runner.c
@@ -207,18 +207,21 @@ update_cls_table(enum sppwk_action wk_action,
}
/* Assign worker thread or remove on specified lcore. */
+/* TODO(yasufum) revise func name for removing the term `component`. */
static int
update_comp(enum sppwk_action wk_action, const char *name,
unsigned int lcore_id, enum spp_component_type type)
{
- int ret = SPP_RET_NG;
- int ret_del = -1;
+ int ret;
+ int ret_del;
int comp_lcore_id = 0;
unsigned int tmp_lcore_id = 0;
struct spp_component_info *comp_info = NULL;
+ /* TODO(yasufum) revise `core` to be more specific. */
struct core_info *core = NULL;
struct core_mng_info *info = NULL;
struct spp_component_info *comp_info_base = NULL;
+ /* TODO(yasufum) revise `core_info` which is same as struct name. */
struct core_mng_info *core_info = NULL;
int *change_core = NULL;
int *change_component = NULL;
@@ -277,23 +280,27 @@ update_comp(enum sppwk_action wk_action, const char *name,
info = (core_info + tmp_lcore_id);
core = &info->core[info->upd_index];
+ /**
+ * TODO(yasufum) check if this ifdef is simply removed by
+ * running other than spp_vf.
+ */
#ifdef SPP_VF_MODULE
/* initialize classifier information */
if (comp_info->type == SPP_COMPONENT_CLASSIFIER_MAC)
init_classifier_info(comp_lcore_id);
#endif /* SPP_VF_MODULE */
- ret_del = del_component_info(comp_lcore_id,
- core->num, core->id);
+ /* The latest lcore is released if worker thread is stopped. */
+ ret_del = del_comp_info(comp_lcore_id, core->num, core->id);
if (ret_del >= 0)
- /* If deleted, decrement number. */
core->num--;
ret = SPP_RET_OK;
*(change_component + comp_lcore_id) = 0;
break;
- default:
+ default: /* Unexpected case. */
+ ret = SPP_RET_NG;
break;
}
diff --git a/src/shared/secondary/spp_worker_th/spp_proc.c b/src/shared/secondary/spp_worker_th/spp_proc.c
index 9c62bab..386144f 100644
--- a/src/shared/secondary/spp_worker_th/spp_proc.c
+++ b/src/shared/secondary/spp_worker_th/spp_proc.c
@@ -742,30 +742,33 @@ sppwk_get_lcore_id(const char *comp_name)
}
/* Delete component information */
+/**
+ * TODO(yasufum) consider to move to cmd_runner because this func is only
+ * used in.
+ */
int
-del_component_info(int component_id, int component_num, int *componet_array)
+del_comp_info(int lcore_id, int nof_comps, int *comp_ary)
{
+ int idx; /* The index of comp_ary to be deleted. */
int cnt;
- int match = -1;
- int max = component_num;
- for (cnt = 0; cnt < max; cnt++) {
- if (component_id == componet_array[cnt])
- match = cnt;
+ /* Find the index. */
+ for (cnt = 0; cnt < nof_comps; cnt++) {
+ if (lcore_id == comp_ary[cnt])
+ idx = cnt;
}
-
- if (match < 0)
+ if (idx < 0)
return SPP_RET_NG;
- /* Last element is excluded from movement. */
- max--;
+ /* Overwrite the deleted entry, and shift the remained. */
+ nof_comps--;
+ for (cnt = idx; cnt < nof_comps; cnt++)
+ comp_ary[cnt] = comp_ary[cnt + 1];
- for (cnt = match; cnt < max; cnt++)
- componet_array[cnt] = componet_array[cnt+1];
+ /* Clean the unused last entry. */
+ comp_ary[cnt] = 0;
- /* Last element is cleared. */
- componet_array[cnt] = 0;
- return 0;
+ return SPP_RET_OK;
}
/**
diff --git a/src/shared/secondary/spp_worker_th/spp_proc.h b/src/shared/secondary/spp_worker_th/spp_proc.h
index bdd628e..61f3597 100644
--- a/src/shared/secondary/spp_worker_th/spp_proc.h
+++ b/src/shared/secondary/spp_worker_th/spp_proc.h
@@ -555,18 +555,19 @@ int sppwk_get_lcore_id(const char *comp_name);
/**
* Delete component information.
*
- * @param component_id
- * check data
- * @param component_num
- * array check count
- * @param componet_array
- * check array address
+ * @param[in] lcore_id The lcore ID of deleted comp.
+ * @param[in] nof_comps The num of elements in comp_ary.
+ * @param[in] *comp_ary Set of comps from which an comp is deleted.
*
- * @retval 0 succeeded.
- * @retval -1 failed.
+ * @retval SPP_RET_OK If succeeded.
+ * @retval SPP_RET_NG If failed.
+ */
+/**
+ * TODO(yasufum) consider to move to cmd_runner because this func is only
+ * used in.
*/
int
-del_component_info(int component_id, int component_num, int *componet_array);
+del_comp_info(int lcore_id, int nof_comps, int *comp_ary);
/**
* Get index of given entry in given port info array. It returns the index,
--
2.17.1
next prev 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 ` ogawa.yasufumi [this message]
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 ` [spp] [PATCH 6/6] shared/sec: rename struct spp_command 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=1559273819-26243-2-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).