Soft Patch Panel
 help / color / Atom feed
* [spp] [PATCH] shared/sec: remove worker process type
@ 2019-06-24 10:41 yasufum.o
  0 siblings, 0 replies; only message in thread
From: yasufum.o @ 2019-06-24 10:41 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

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

Three of SPP worker process types are defined as an enum for vf,
mirror and none. It is only used as index for getting name of types of
string value from an array.

  enum sppwk_proc_type {
       WK_PROC_TYPE_NONE,
       WK_PROC_TYPE_VF,
       WK_PROC_TYPE_MIRROR,
  }

However, it is menaingless because type for vf is not used in
spp_mirror, or vise versa. In addition, type none is not used from
anywhere. It should be simply replaced with fixed string values in each
of processes because it is not needed to be shared among processes.

This update is to replace this enum and array of string with
`#define WK_PROC_TYPE "vf"` and `#define WK_PROC_TYPE "mirror"` in each
of processes independently.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/mirror/spp_mirror.c                       | 12 +++------
 .../spp_worker_th/cmd_res_formatter.c         | 25 +------------------
 .../secondary/spp_worker_th/cmd_utils.h       |  9 -------
 .../secondary/spp_worker_th/mirror_deps.h     |  2 ++
 src/shared/secondary/spp_worker_th/vf_deps.h  |  2 ++
 src/vf/spp_vf.c                               | 10 +++-----
 6 files changed, 12 insertions(+), 48 deletions(-)

diff --git a/src/mirror/spp_mirror.c b/src/mirror/spp_mirror.c
index 19d79ef..9d9b4a8 100644
--- a/src/mirror/spp_mirror.c
+++ b/src/mirror/spp_mirror.c
@@ -194,15 +194,11 @@ parse_app_args(int argc, char *argv[])
 		usage(progname);
 		return SPP_RET_NG;
 	}
-	g_startup_param.wk_proc_type = WK_PROC_TYPE_MIRROR;
 	RTE_LOG(INFO, MIRROR,
-			"app opts (client_id=%d,type=%d,"
-			"server=%s:%d,vhost_client=%d,)\n",
-			cli_id,
-			g_startup_param.wk_proc_type,
-			g_startup_param.server_ip,
-			g_startup_param.server_port,
-			g_enable_vhost_cli);
+			"Parsed app args (client_id=%d, server=%s:%d, "
+			"vhost_client=%d,)\n",
+			cli_id, g_startup_param.server_ip,
+			g_startup_param.server_port, g_enable_vhost_cli);
 	return SPP_RET_OK;
 }
 
diff --git a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
index 291c1f5..f095b08 100644
--- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
+++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
@@ -21,18 +21,6 @@ static int append_result_value(const char *name, char **output, void *tmp);
 static int append_error_details_value(const char *name, char **output,
 		void *tmp);
 
-/**
- * List of worker process type. The order of items should be same as the order
- * of enum `wk_proc_type` in cmd_utils.h.
- */
-/* TODO(yasufum) Add "pcap" after spp_pcap is made to use shared. */
-const char *SPPWK_PROC_TYPE_LIST[] = {
-	"none",
-	"vf",
-	"mirror",
-	"",  /* termination */
-};
-
 /**
  * List of port abilities. The order of items should be same as the order of
  * enum `sppwk_port_abl_ops` in spp_vf.h.
@@ -121,23 +109,12 @@ append_interface_array(char **output, const enum port_type type)
 	return SPP_RET_OK;
 }
 
-/* TODO(yasufum) move to another file for util funcs. */
-/* Get proc type from global command params. */
-static int
-get_wk_type(void)
-{
-	struct startup_param *params;
-	sppwk_get_mng_data(&params, NULL, NULL, NULL, NULL, NULL, NULL);
-	return params->wk_proc_type;
-}
-
 /* append a secondary process type for JSON format */
 int
 append_process_type_value(const char *name, char **output,
 		void *tmp __attribute__ ((unused)))
 {
-	return append_json_str_value(output, name,
-			SPPWK_PROC_TYPE_LIST[get_wk_type()]);
+	return append_json_str_value(output, name, SPPWK_PROC_TYPE);
 }
 
 /* append a value of vlan for JSON format */
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.h b/src/shared/secondary/spp_worker_th/cmd_utils.h
index 9022589..425d3eb 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.h
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.h
@@ -134,14 +134,6 @@ enum copy_mng_flg {
 	COPY_MNG_FLG_ALLCOPY,
 };
 
-/* secondary process type used only from spp_vf and spp_mirror */
-/* TODO(yasufum) Add WK_PROC_TYPE_PCAP. */
-enum sppwk_proc_type {
-	WK_PROC_TYPE_NONE,
-	WK_PROC_TYPE_VF,
-	WK_PROC_TYPE_MIRROR,
-};
-
 /** VLAN tag information */
 struct sppwk_vlan_tag {
 	int vid; /**< VLAN ID */
@@ -203,7 +195,6 @@ struct sppwk_comp_info {
 struct startup_param {
 	char server_ip[INET_ADDRSTRLEN];  /* IP address of spp-ctl */
 	int server_port;   /* Port Number of spp-ctl */
-	enum sppwk_proc_type wk_proc_type;
 };
 
 /* Manage number of interfaces  and port information as global variable. */
diff --git a/src/shared/secondary/spp_worker_th/mirror_deps.h b/src/shared/secondary/spp_worker_th/mirror_deps.h
index 1446027..085b01e 100644
--- a/src/shared/secondary/spp_worker_th/mirror_deps.h
+++ b/src/shared/secondary/spp_worker_th/mirror_deps.h
@@ -9,6 +9,8 @@
 #include "cmd_parser.h"
 #include "cmd_res_formatter.h"
 
+#define SPPWK_PROC_TYPE "mirror"
+
 /* Num of entries of ops_list in mir_cmd_runner.c. */
 #define NOF_STAT_OPS 7
 
diff --git a/src/shared/secondary/spp_worker_th/vf_deps.h b/src/shared/secondary/spp_worker_th/vf_deps.h
index 8da81a5..fd3c201 100644
--- a/src/shared/secondary/spp_worker_th/vf_deps.h
+++ b/src/shared/secondary/spp_worker_th/vf_deps.h
@@ -11,6 +11,8 @@
 #include "cmd_parser.h"
 #include "cmd_res_formatter.h"
 
+#define SPPWK_PROC_TYPE "vf"
+
 /* Number of VLAN ID */
 #define NOF_VLAN 4096
 
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index d8b0c87..f4bafb4 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -151,15 +151,11 @@ parse_app_args(int argc, char *argv[])
 		usage(progname);
 		return SPP_RET_NG;
 	}
-	g_startup_param.wk_proc_type = WK_PROC_TYPE_VF;
 	RTE_LOG(INFO, APP,
-			"app opts (client_id=%d,type=%d,server=%s:%d,"
+			"Parsed app args (client_id=%d,server=%s:%d,"
 			"vhost_client=%d)\n",
-			cli_id,
-			g_startup_param.wk_proc_type,
-			g_startup_param.server_ip,
-			g_startup_param.server_port,
-			g_enable_vhost_cli);
+			cli_id, g_startup_param.server_ip,
+			g_startup_param.server_port, g_enable_vhost_cli);
 	return SPP_RET_OK;
 }
 
-- 
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-24 10:41 [spp] [PATCH] shared/sec: remove worker process type 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