Soft Patch Panel
 help / color / Atom feed
* [spp] [PATCH] shared/sec: move del_comp_info to cmd_runner.c
@ 2019-06-27  4:39 yasufum.o
  0 siblings, 0 replies; only message in thread
From: yasufum.o @ 2019-06-27  4:39 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

From: Yasufumi Ogawa <yasufum.o@gmail.com>

Function del_comp_info() is called for `stop` command by which running
worker thread is terminated. It should be included in `cmd_runner.c` for
considering this behavior. This update is to move this function from
`cmd_utils.c` to `cmd_runner.c`, and also its header files.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 .../secondary/spp_worker_th/cmd_runner.c      | 26 ++++++++++++++++
 .../secondary/spp_worker_th/cmd_runner.h      | 13 ++++++++
 .../secondary/spp_worker_th/cmd_utils.c       | 30 -------------------
 .../secondary/spp_worker_th/cmd_utils.h       | 26 ++--------------
 4 files changed, 42 insertions(+), 53 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_runner.c b/src/shared/secondary/spp_worker_th/cmd_runner.c
index 3ab69f9..4e43fe6 100644
--- a/src/shared/secondary/spp_worker_th/cmd_runner.c
+++ b/src/shared/secondary/spp_worker_th/cmd_runner.c
@@ -405,3 +405,29 @@ sppwk_run_cmd(void)
 
 	return ret;
 }
+
+/* Delete component information */
+int
+del_comp_info(int lcore_id, int nof_comps, int *comp_ary)
+{
+	int idx = 0;  /* The index of comp_ary to be deleted. */
+	int cnt;
+
+	/* Find the index. */
+	for (cnt = 0; cnt < nof_comps; cnt++) {
+		if (lcore_id == comp_ary[cnt])
+			idx = cnt;
+	}
+	if (idx < 0)
+		return SPP_RET_NG;
+
+	/* Overwrite the deleted entry, and shift the remained. */
+	nof_comps--;
+	for (cnt = idx; cnt < nof_comps; cnt++)
+		comp_ary[cnt] = comp_ary[cnt + 1];
+
+	/* Clean the unused last entry. */
+	comp_ary[cnt] = 0;
+
+	return SPP_RET_OK;
+}
diff --git a/src/shared/secondary/spp_worker_th/cmd_runner.h b/src/shared/secondary/spp_worker_th/cmd_runner.h
index 3a71e3e..e13e936 100644
--- a/src/shared/secondary/spp_worker_th/cmd_runner.h
+++ b/src/shared/secondary/spp_worker_th/cmd_runner.h
@@ -43,4 +43,17 @@ sppwk_cmd_runner_conn(const char *ctl_ipaddr, int ctl_port);
 int
 sppwk_run_cmd(void);
 
+/**
+ *  Delete component information.
+ *
+ * @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 SPP_RET_OK If succeeded.
+ * @retval SPP_RET_NG If failed.
+ */
+int
+del_comp_info(int lcore_id, int nof_comps, int *comp_ary);
+
 #endif  /* _SPPWK_CMD_RUNNER_H_ */
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.c b/src/shared/secondary/spp_worker_th/cmd_utils.c
index 6072186..894f559 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.c
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.c
@@ -628,36 +628,6 @@ sppwk_get_lcore_id(const char *comp_name)
 	return SPP_RET_NG;
 }
 
-/* Delete component information */
-/**
- * TODO(yasufum) consider to move to cmd_runner because this func is only
- * used in.
- */
-int
-del_comp_info(int lcore_id, int nof_comps, int *comp_ary)
-{
-	int idx = 0;  /* The index of comp_ary to be deleted. */
-	int cnt;
-
-	/* Find the index. */
-	for (cnt = 0; cnt < nof_comps; cnt++) {
-		if (lcore_id == comp_ary[cnt])
-			idx = cnt;
-	}
-	if (idx < 0)
-		return SPP_RET_NG;
-
-	/* Overwrite the deleted entry, and shift the remained. */
-	nof_comps--;
-	for (cnt = idx; cnt < nof_comps; cnt++)
-		comp_ary[cnt] = comp_ary[cnt + 1];
-
-	/* Clean the unused last entry. */
-	comp_ary[cnt] = 0;
-
-	return SPP_RET_OK;
-}
-
 /**
  * Get index of given entry in given port info array. It returns the index,
  * or NG code if the entry is not found.
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.h b/src/shared/secondary/spp_worker_th/cmd_utils.h
index ff363f5..7e5cda3 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.h
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.h
@@ -384,7 +384,7 @@ void print_ring_latency_stats(void);
 #endif /* SPP_RINGLATENCYSTATS_ENABLE */
 
 /* Remove sock file if spp is not running */
-void  del_vhost_sockfile(struct sppwk_port_info *vhost);
+void del_vhost_sockfile(struct sppwk_port_info *vhost);
 
 /**
  * Get core ID of target component
@@ -423,11 +423,8 @@ int spp_check_used_port(
 /**
  * Set component update flag for given port.
  *
- * @param port
- *  sppwk_port_info address
- * @param rxtx
- *  enum spp_port_rxtx
- *
+ * @param port Pointer of sppwk_port_info.
+ * @param rxtx Enum spp_port_rxtx.
  */
 void
 set_component_change_port(struct sppwk_port_info *port,
@@ -450,23 +447,6 @@ int get_free_lcore_id(void);
  */
 int sppwk_get_lcore_id(const char *comp_name);
 
-/**
- *  Delete component information.
- *
- * @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 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_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,
  * or NG code if the entry is not found.
-- 
2.17.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-27  4:39 [spp] [PATCH] shared/sec: move del_comp_info to cmd_runner.c yasufum.o

Soft Patch Panel

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/spp/0 spp/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 spp spp/ http://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


AGPL code for this site: git clone https://public-inbox.org/ public-inbox