Soft Patch Panel
 help / color / mirror / Atom feed
* [spp] [PATCH 01/23] spp_vf: fix invalid code for max chars
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 02/23] spp_vf: move common source and header files x-fn-spp
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Refactor invalid code for the maximum 80 characters to apply with
DPDK's coding style.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/Makefile           |  5 ++-
 src/vf/classifier_mac.c   | 72 +++++++++++++++++++++--------------
 src/vf/command_conn.c     |  7 ++--
 src/vf/command_conn.h     |  2 +-
 src/vf/command_dec.c      | 35 +++++++++--------
 src/vf/command_dec.h      |  2 +-
 src/vf/command_proc.c     | 58 +++++++++++++++-------------
 src/vf/ringlatencystats.c | 10 +++--
 src/vf/spp_forward.c      | 18 ++++++---
 src/vf/spp_port.c         | 17 +++++----
 src/vf/spp_vf.c           | 79 ++++++++++++++++++++++++---------------
 src/vf/spp_vf.h           |  3 +-
 src/vf/string_buffer.c    |  3 +-
 13 files changed, 186 insertions(+), 125 deletions(-)

diff --git a/src/vf/Makefile b/src/vf/Makefile
index 43d3db0..88381be 100644
--- a/src/vf/Makefile
+++ b/src/vf/Makefile
@@ -12,7 +12,10 @@ include $(RTE_SDK)/mk/rte.vars.mk
 APP = spp_vf
 
 # all source are stored in SRCS-y
-SRCS-y := spp_vf.c classifier_mac.c spp_forward.c string_buffer.c command_conn.c command_dec.c command_proc.c ringlatencystats.c spp_port.c ../shared/common.c
+SRCS-y := spp_vf.c classifier_mac.c spp_forward.c
+SRCS-y += string_buffer.c ringlatencystats.c spp_port.c
+SRCS-y += command_conn.c command_dec.c command_proc.c
+SRCS-y += ../shared/common.c
 
 CFLAGS += $(WERROR_FLAGS) -O3
 CFLAGS += -I$(SRCDIR)/../shared
diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index 1ca788d..2a01f0e 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -45,7 +45,10 @@
 /* interval that wait until change update index (micro second) */
 #define CHANGE_UPDATE_INDEX_WAIT_INTERVAL SPP_CHANGE_UPDATE_INTERVAL
 
-/* interval that transmit burst packet, if buffer is not filled (nano second) */
+/*
+ *  interval that transmit burst packet,
+ *  if buffer is not filled (nano second)
+ */
 #define DRAIN_TX_PACKET_INTERVAL 100
 
 /* VID of VLAN untagged */
@@ -190,7 +193,8 @@ log_packet(const char *name, struct rte_mbuf *pkt,
 			&eth->s_addr);
 
 	RTE_LOG_DP(DEBUG, SPP_CLASSIFIER_MAC,
-			"[%s]Packet(%s:%d). d_addr=%s, s_addr=%s, vid=%hu, pktlen=%u\n",
+			"[%s]Packet(%s:%d). d_addr=%s, s_addr=%s, "
+			"vid=%hu, pktlen=%u\n",
 			name,
 			func_name,
 			line_num,
@@ -234,7 +238,8 @@ log_classification(
 				clsd_data[clsd_idx].iface_no_global);
 
 	RTE_LOG_DP(DEBUG, SPP_CLASSIFIER_MAC,
-			"[%s]Classification(%s:%d). d_addr=%s, s_addr=%s, vid=%hu, pktlen=%u, tx_iface=%s\n",
+			"[%s]Classification(%s:%d). d_addr=%s, "
+			"s_addr=%s, vid=%hu, pktlen=%u, tx_iface=%s\n",
 			cmp_info->name,
 			func_name,
 			line_num,
@@ -335,7 +340,8 @@ create_mac_classification(void)
 	/* create classifier mac table (hash table) */
 	*mac_cls_tab = rte_hash_create(&hash_params);
 	if (unlikely(*mac_cls_tab == NULL)) {
-		RTE_LOG(ERR, SPP_CLASSIFIER_MAC, "Cannot create mac classification table. "
+		RTE_LOG(ERR, SPP_CLASSIFIER_MAC,
+				"Cannot create mac classification table. "
 				"name=%s\n", hash_tab_name);
 		rte_free(mac_cls);
 		return NULL;
@@ -396,8 +402,8 @@ init_component_info(struct component_info *cmp_info,
 		/* if mac classification is NULL, make instance */
 		if (unlikely(cmp_info->mac_classifications[vid] == NULL)) {
 			RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC,
-					"Mac classification is not registered. create."
-					"vid=%hu\n", vid);
+					"Mac classification is not registered."
+					" create. vid=%hu\n", vid);
 			cmp_info->mac_classifications[vid] =
 					create_mac_classification();
 			if (unlikely(cmp_info->mac_classifications[vid] ==
@@ -414,8 +420,10 @@ init_component_info(struct component_info *cmp_info,
 		if (unlikely(tx_port->class_id.mac_addr ==
 				SPP_DEFAULT_CLASSIFIED_DMY_ADDR)) {
 			mac_cls->default_classified = i;
-			RTE_LOG(INFO, SPP_CLASSIFIER_MAC, "default classified. "
-					"vid=%hu, iface_type=%d, iface_no=%d, dpdk_port=%d\n",
+			RTE_LOG(INFO, SPP_CLASSIFIER_MAC,
+					"default classified. vid=%hu, "
+					"iface_type=%d, iface_no=%d, "
+					"dpdk_port=%d\n",
 					vid,
 					tx_port->iface_type,
 					tx_port->iface_no,
@@ -433,14 +441,17 @@ init_component_info(struct component_info *cmp_info,
 				(void *)&eth_addr, (void *)(long)i);
 		if (unlikely(ret < 0)) {
 			RTE_LOG(ERR, SPP_CLASSIFIER_MAC,
-					"Cannot add entry to classifier mac table. "
-					"ret=%d, vid=%hu, mac_addr=%s\n",
+					"Cannot add entry to classifier mac "
+					"table. ret=%d, vid=%hu, "
+					"mac_addr=%s\n",
 					ret, vid, mac_addr_str);
 			return -1;
 		}
 
-		RTE_LOG(INFO, SPP_CLASSIFIER_MAC, "Add entry to classifier mac table. "
-				"vid=%hu, mac_addr=%s, iface_type=%d, iface_no=%d, dpdk_port=%d\n",
+		RTE_LOG(INFO, SPP_CLASSIFIER_MAC,
+				"Add entry to classifier mac table. "
+				"vid=%hu, mac_addr=%s, iface_type=%d, "
+				"iface_no=%d, dpdk_port=%d\n",
 				vid,
 				mac_addr_str,
 				tx_port->iface_type,
@@ -472,7 +483,8 @@ init_classifier(struct management_info *mng_info)
 #ifdef RTE_MACHINE_CPUFLAG_SSE4_2
 	RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC, "Enabled SSE4.2. use CRC hash.\n");
 #else
-	RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC, "Disabled SSE4.2. use Jenkins hash.\n");
+	RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC,
+			"Disabled SSE4.2. use Jenkins hash.\n");
 #endif
 
 	/* populate the classifier information at reference */
@@ -480,8 +492,8 @@ init_classifier(struct management_info *mng_info)
 			cmp_infos[mng_info->ref_index], &component_info);
 	if (unlikely(ret != 0)) {
 		RTE_LOG(ERR, SPP_CLASSIFIER_MAC,
-				"Cannot initialize classifier mac table. ret=%d\n",
-				ret);
+				"Cannot initialize classifier mac table. "
+				"ret=%d\n", ret);
 		return -1;
 	}
 
@@ -604,8 +616,8 @@ get_general_default_classified_index(struct component_info *cmp_info)
 
 	mac_cls = cmp_info->mac_classifications[VLAN_UNTAGGED_VID];
 	if (unlikely(mac_cls == NULL)) {
-		LOG_DBG(cmp_info->name, "Untagged's default is not set. vid=%d\n",
-				(int)VLAN_UNTAGGED_VID);
+		LOG_DBG(cmp_info->name, "Untagged's default is not set. "
+				"vid=%d\n", (int)VLAN_UNTAGGED_VID);
 		return -1;
 	}
 
@@ -683,8 +695,8 @@ select_classified_index(const struct rte_mbuf *pkt,
 	/* select mac address classification by vid */
 	mac_cls = cmp_info->mac_classifications[vid];
 	if (unlikely(mac_cls == NULL)) {
-		LOG_DBG(cmp_info->name, "Mac classification is not registered. vid=%hu\n",
-				vid);
+		LOG_DBG(cmp_info->name, "Mac classification is not "
+				"registered. vid=%hu\n", vid);
 		return get_general_default_classified_index(cmp_info);
 	}
 
@@ -692,14 +704,14 @@ select_classified_index(const struct rte_mbuf *pkt,
 	ret = rte_hash_lookup_data(mac_cls->classification_tab,
 			(const void *)&eth->d_addr, &lookup_data);
 	if (ret >= 0) {
-		LOG_DBG(cmp_info->name, "Mac address is registered. ret=%d, vid=%hu\n",
-				ret, vid);
+		LOG_DBG(cmp_info->name, "Mac address is registered. "
+				"ret=%d, vid=%hu\n", ret, vid);
 		return (int)(long)lookup_data;
 	}
 
 	LOG_DBG(cmp_info->name,
-			"Mac address is not registered. ret=%d, (EINVAL=%d, ENOENT=%d)\n",
-			ret, EINVAL, ENOENT);
+			"Mac address is not registered. ret=%d, "
+			"(EINVAL=%d, ENOENT=%d)\n", ret, EINVAL, ENOENT);
 
 	/* check if packet is l2 multicast */
 	if (unlikely(is_multicast_ether_addr(&eth->d_addr)))
@@ -708,8 +720,8 @@ select_classified_index(const struct rte_mbuf *pkt,
 	/* if default is not set, use untagged's default */
 	if (unlikely(mac_cls->default_classified < 0 &&
 			vid != VLAN_UNTAGGED_VID)) {
-		LOG_DBG(cmp_info->name, "Vid's default is not set. use general default. vid=%hu\n",
-				vid);
+		LOG_DBG(cmp_info->name, "Vid's default is not set. "
+				"use general default. vid=%hu\n", vid);
 		return get_general_default_classified_index(cmp_info);
 	}
 
@@ -741,8 +753,8 @@ classify_packet(struct rte_mbuf **rx_pkts, uint16_t n_rx,
 					i);
 			push_packet(rx_pkts[i], clsd_data + clsd_idx);
 		} else if (unlikely(clsd_idx == -1)) {
-			LOG_DBG(cmp_info->name, "no destination. drop packet. i=%d\n",
-					i);
+			LOG_DBG(cmp_info->name, "no destination. "
+					"drop packet. i=%d\n", i);
 			rte_pktmbuf_free(rx_pkts[i]);
 		} else if (unlikely(clsd_idx == -2)) {
 			LOG_DBG(cmp_info->name, "as multicast packet. i=%d\n",
@@ -760,7 +772,8 @@ change_update_index(struct management_info *mng_info, int id)
 	if (unlikely(mng_info->ref_index ==
 			mng_info->upd_index)) {
 		/* Change reference index of port ability. */
-		spp_port_ability_change_index(PORT_ABILITY_CHG_INDEX_REF, 0, 0);
+		spp_port_ability_change_index(PORT_ABILITY_CHG_INDEX_REF,
+									0, 0);
 
 		/* Transmit all packets for switching the using data. */
 		transmit_all_packet(mng_info->cmp_infos +
@@ -924,7 +937,8 @@ spp_classifier_get_component_status(
 	mng_info = g_mng_infos + id;
 	if (!is_used_mng_info(mng_info)) {
 		RTE_LOG(ERR, SPP_CLASSIFIER_MAC,
-				"Component[%d] Not used. (status)(core = %d, type = %d)\n",
+				"Component[%d] Not used. "
+				"(status)(core = %d, type = %d)\n",
 				id, lcore_id, SPP_COMPONENT_CLASSIFIER_MAC);
 		return -1;
 	}
diff --git a/src/vf/command_conn.c b/src/vf/command_conn.c
index e81eda9..4c3de54 100644
--- a/src/vf/command_conn.c
+++ b/src/vf/command_conn.c
@@ -98,8 +98,8 @@ spp_receive_message(int *sock, char **strbuf)
 	ret = recv(*sock, rx_buf, rx_buf_sz, 0);
 	if (unlikely(ret <= 0)) {
 		if (likely(ret == 0)) {
-			RTE_LOG(INFO, SPP_COMMAND_PROC,
-					"Controller has performed an shutdown.");
+			RTE_LOG(INFO, SPP_COMMAND_PROC, "Controller has "
+					"performed an shutdown.");
 		} else if (unlikely(errno != EAGAIN && errno != EWOULDBLOCK)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
 					"Receive failure. errno=%d\n", errno);
@@ -108,7 +108,8 @@ spp_receive_message(int *sock, char **strbuf)
 			return 0;
 		}
 
-		RTE_LOG(INFO, SPP_COMMAND_PROC, "Assume Server closed connection.\n");
+		RTE_LOG(INFO, SPP_COMMAND_PROC, "Assume Server closed "
+							"connection.\n");
 		close(*sock);
 		*sock = -1;
 		return SPP_CONNERR_TEMPORARY;
diff --git a/src/vf/command_conn.h b/src/vf/command_conn.h
index 09b19c4..ce2f56c 100644
--- a/src/vf/command_conn.h
+++ b/src/vf/command_conn.h
@@ -56,7 +56,7 @@ int spp_connect_to_controller(int *sock);
  * @retval 0 <                   succeeded. number of bytes received.
  * @retval 0                     no receive message.
  * @retval SPP_CONNERR_TEMPORARY temporary error. please reconnect.
- * @retval SPP_CONNERR_FATAL     fatal error occurred. should terminate process.
+ * @retval SPP_CONNERR_FATAL    fatal error occurred. should terminate process.
  */
 int spp_receive_message(int *sock, char **msgbuf);
 
diff --git a/src/vf/command_dec.c b/src/vf/command_dec.c
index 74b0c1d..204cb86 100644
--- a/src/vf/command_dec.c
+++ b/src/vf/command_dec.c
@@ -284,7 +284,8 @@ decode_component_type_value(void *output, const char *arg_val)
 	org_type = spp_get_component_type_update(component->core);
 	if ((org_type != SPP_COMPONENT_UNUSE) && (org_type != set_type)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
-				"Component type does not match. val=%s (org=%d, new=%d)\n",
+				"Component type does not match. "
+				"val=%s (org=%d, new=%d)\n",
 				arg_val, org_type, set_type);
 		return -1;
 	}
@@ -383,8 +384,8 @@ decode_port_name_value(void *output, const char *arg_val)
 
 	ret = spp_get_component_id(arg_val);
 	if (unlikely(ret < 0)) {
-		RTE_LOG(ERR, SPP_COMMAND_PROC, "Unknown component name. val=%s\n",
-				arg_val);
+		RTE_LOG(ERR, SPP_COMMAND_PROC,
+				"Unknown component name. val=%s\n", arg_val);
 		return -1;
 	}
 
@@ -457,8 +458,8 @@ decode_mac_addr_str_value(void *output, const char *arg_val)
 
 	ret = spp_change_mac_str_to_int64(str_val);
 	if (unlikely(ret < 0)) {
-		RTE_LOG(ERR, SPP_COMMAND_PROC, "Bad mac address string. val=%s\n",
-				str_val);
+		RTE_LOG(ERR, SPP_COMMAND_PROC,
+				"Bad mac address string. val=%s\n", str_val);
 		return -1;
 	}
 
@@ -533,7 +534,8 @@ decode_classifier_port_value(void *output, const char *arg_val)
 	if (ret < 0)
 		return -1;
 
-	if (spp_check_added_port(tmp_port.iface_type, tmp_port.iface_no) == 0) {
+	if (spp_check_added_port(tmp_port.iface_type,
+					tmp_port.iface_no) == 0) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC, "Port not added. val=%s\n",
 				arg_val);
 		return -1;
@@ -545,8 +547,8 @@ decode_classifier_port_value(void *output, const char *arg_val)
 	if (unlikely(classifier_table->action == SPP_CMD_ACTION_ADD)) {
 		if (!spp_check_classid_used_port(ETH_VLAN_ID_MAX, 0,
 				tmp_port.iface_type, tmp_port.iface_no)) {
-			RTE_LOG(ERR, SPP_COMMAND_PROC,
-					"Port in used. (classifier_table command) val=%s\n",
+			RTE_LOG(ERR, SPP_COMMAND_PROC, "Port in used. "
+					"(classifier_table command) val=%s\n",
 					arg_val);
 			return -1;
 		}
@@ -558,8 +560,8 @@ decode_classifier_port_value(void *output, const char *arg_val)
 		if (!spp_check_classid_used_port(classifier_table->vid,
 				(uint64_t)mac_addr,
 				tmp_port.iface_type, tmp_port.iface_no)) {
-			RTE_LOG(ERR, SPP_COMMAND_PROC,
-					"Port in used. (classifier_table command) val=%s\n",
+			RTE_LOG(ERR, SPP_COMMAND_PROC, "Port in used. "
+					"(classifier_table command) val=%s\n",
 					arg_val);
 			return -1;
 		}
@@ -581,7 +583,8 @@ struct decode_parameter_list {
 };
 
 /* parameter list for each command */
-static struct decode_parameter_list parameter_list[][SPP_CMD_MAX_PARAMETERS] = {
+static struct decode_parameter_list
+parameter_list[][SPP_CMD_MAX_PARAMETERS] = {
 	{                                /* classifier_table(mac) */
 		{
 			.name = "action",
@@ -728,7 +731,8 @@ decode_command_parameter_in_list(struct spp_command_request *request,
 				argv[pi]);
 		if (unlikely(ret < 0)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
-					"Bad value. command=%s, name=%s, index=%d, value=%s\n",
+					"Bad value. command=%s, name=%s, "
+					"index=%d, value=%s\n",
 					argv[0], list->name, pi, argv[pi]);
 			return set_string_value_decode_error(error, argv[pi],
 					list->name);
@@ -742,8 +746,8 @@ struct decode_command_list {
 	const char *name;       /* Command name */
 	int   param_min;        /* Min number of parameters */
 	int   param_max;        /* Max number of parameters */
-	int (*func)(struct spp_command_request *request, int argc, char *argv[],
-			struct spp_command_decode_error *error);
+	int (*func)(struct spp_command_request *request, int argc,
+			char *argv[], struct spp_command_decode_error *error);
 				/* Pointer to command handling function */
 };
 
@@ -833,7 +837,8 @@ spp_command_decode_request(
 	request->num_command = 1;
 	ret = decode_command_in_list(request, request_str, error);
 	if (unlikely(ret != 0)) {
-		RTE_LOG(ERR, SPP_COMMAND_PROC, "Cannot decode command request. "
+		RTE_LOG(ERR, SPP_COMMAND_PROC,
+				"Cannot decode command request. "
 				"ret=%d, request_str=%.*s\n",
 				ret, (int)request_str_len, request_str);
 		return ret;
diff --git a/src/vf/command_dec.h b/src/vf/command_dec.h
index 93444cb..281a8c4 100644
--- a/src/vf/command_dec.h
+++ b/src/vf/command_dec.h
@@ -146,7 +146,7 @@ struct spp_command_request {
 	int num_command;                /**< Number of accepted commands */
 	int num_valid_command;          /**< Number of executed commands */
 	struct spp_command commands[SPP_CMD_MAX_COMMANDS];
-					/**< Information of executed commands */
+					/**<Information of executed commands */
 
 	int is_requested_client_id;     /**< Id for get_client_id command */
 	int is_requested_status;        /**< Id for status command */
diff --git a/src/vf/command_proc.c b/src/vf/command_proc.c
index 0cda68e..3b9d687 100644
--- a/src/vf/command_proc.c
+++ b/src/vf/command_proc.c
@@ -90,7 +90,8 @@ append_json_comma(char **output)
 {
 	*output = spp_strbuf_append(*output, JSON_COMMA, strlen(JSON_COMMA));
 	if (unlikely(*output == NULL)) {
-		RTE_LOG(ERR, SPP_COMMAND_PROC, "JSON's comma failed to add.\n");
+		RTE_LOG(ERR, SPP_COMMAND_PROC,
+				"JSON's comma failed to add.\n");
 		return -1;
 	}
 
@@ -107,8 +108,8 @@ append_json_uint_value(const char *name, char **output, unsigned int value)
 			strlen(name) + CMD_TAG_APPEND_SIZE*2);
 	if (unlikely(*output == NULL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
-				"JSON's numeric format failed to add. (name = %s, uint = %u)\n",
-				name, value);
+				"JSON's numeric format failed to add. "
+				"(name = %s, uint = %u)\n", name, value);
 		return -1;
 	}
 
@@ -127,8 +128,8 @@ append_json_int_value(const char *name, char **output, int value)
 			strlen(name) + CMD_TAG_APPEND_SIZE*2);
 	if (unlikely(*output == NULL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
-				"JSON's numeric format failed to add. (name = %s, int = %d)\n",
-				name, value);
+				"JSON's numeric format failed to add. "
+				"(name = %s, int = %d)\n", name, value);
 		return -1;
 	}
 
@@ -147,8 +148,8 @@ append_json_str_value(const char *name, char **output, const char *str)
 			strlen(name) + strlen(str) + CMD_TAG_APPEND_SIZE);
 	if (unlikely(*output == NULL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
-				"JSON's string format failed to add. (name = %s, str = %s)\n",
-				name, str);
+				"JSON's string format failed to add. "
+				"(name = %s, str = %s)\n", name, str);
 		return -1;
 	}
 
@@ -167,8 +168,8 @@ append_json_array_brackets(const char *name, char **output, const char *str)
 			strlen(name) + strlen(str) + CMD_TAG_APPEND_SIZE);
 	if (unlikely(*output == NULL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
-				"JSON's square bracket failed to add. (name = %s, str = %s)\n",
-				name, str);
+				"JSON's square bracket failed to add. "
+				"(name = %s, str = %s)\n", name, str);
 		return -1;
 	}
 
@@ -187,8 +188,8 @@ append_json_block_brackets(const char *name, char **output, const char *str)
 			strlen(name) + strlen(str) + CMD_TAG_APPEND_SIZE);
 	if (unlikely(*output == NULL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
-				"JSON's curly bracket failed to add. (name = %s, str = %s)\n",
-				name, str);
+				"JSON's curly bracket failed to add. "
+				"(name = %s, str = %s)\n", name, str);
 		return -1;
 	}
 
@@ -226,7 +227,8 @@ execute_command(const struct spp_command *command)
 		break;
 
 	case SPP_CMDTYPE_COMPONENT:
-		RTE_LOG(INFO, SPP_COMMAND_PROC, "Execute component command.\n");
+		RTE_LOG(INFO, SPP_COMMAND_PROC,
+				"Execute component command.\n");
 		ret = spp_update_component(
 				command->spec.component.action,
 				command->spec.component.name,
@@ -415,8 +417,8 @@ append_interface_array(char **output, const enum port_type type)
 		*output = spp_strbuf_append(*output, tmp_str, strlen(tmp_str));
 		if (unlikely(*output == NULL)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
-					"Interface number failed to add. (type = %d)\n",
-					type);
+					"Interface number failed to add. "
+					"(type = %d)\n", type);
 			return -1;
 		}
 
@@ -778,8 +780,8 @@ append_response_list_value(char **output,
 		if (unlikely(ret < 0)) {
 			spp_strbuf_free(tmp_buff);
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
-					"Failed to get reply string. (tag = %s)\n",
-					list[i].tag_name);
+					"Failed to get reply string. "
+					"(tag = %s)\n", list[i].tag_name);
 			return -1;
 		}
 
@@ -791,7 +793,8 @@ append_response_list_value(char **output,
 			if (unlikely(ret < 0)) {
 				spp_strbuf_free(tmp_buff);
 				RTE_LOG(ERR, SPP_COMMAND_PROC,
-						"Failed to add commas. (tag = %s)\n",
+						"Failed to add commas. "
+						"(tag = %s)\n",
 						list[i].tag_name);
 				return -1;
 			}
@@ -802,7 +805,8 @@ append_response_list_value(char **output,
 		if (unlikely(*output == NULL)) {
 			spp_strbuf_free(tmp_buff);
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
-					"Failed to add reply string. (tag = %s)\n",
+					"Failed to add reply string. "
+					"(tag = %s)\n",
 					list[i].tag_name);
 			return -1;
 		}
@@ -910,15 +914,16 @@ append_info_value(const char *name, char **output)
 
 /* send response for decode error */
 static void
-send_decode_error_response(int *sock, const struct spp_command_request *request,
+send_decode_error_response(int *sock,
+		const struct spp_command_request *request,
 		struct command_result *command_results)
 {
 	int ret = -1;
 	char *msg, *tmp_buff;
 	tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
 	if (unlikely(tmp_buff == NULL)) {
-		RTE_LOG(ERR, SPP_COMMAND_PROC,
-				"allocate error. (name = decode_error_response)\n");
+		RTE_LOG(ERR, SPP_COMMAND_PROC, "allocate error. "
+				"(name = decode_error_response)\n");
 		return;
 	}
 
@@ -935,8 +940,8 @@ send_decode_error_response(int *sock, const struct spp_command_request *request,
 	msg = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
 	if (unlikely(msg == NULL)) {
 		spp_strbuf_free(tmp_buff);
-		RTE_LOG(ERR, SPP_COMMAND_PROC,
-				"allocate error. (name = decode_error_response)\n");
+		RTE_LOG(ERR, SPP_COMMAND_PROC, "allocate error. "
+				"(name = decode_error_response)\n");
 		return;
 	}
 	ret = append_json_block_brackets("", &msg, tmp_buff);
@@ -993,8 +998,8 @@ send_command_result_response(int *sock,
 		ret = append_client_id_value("client_id", &tmp_buff, NULL);
 		if (unlikely(ret < 0)) {
 			spp_strbuf_free(tmp_buff);
-			RTE_LOG(ERR, SPP_COMMAND_PROC,
-					"Failed to make client id response.\n");
+			RTE_LOG(ERR, SPP_COMMAND_PROC, "Failed to make "
+					"client id response.\n");
 			return;
 		}
 	}
@@ -1132,7 +1137,8 @@ spp_command_proc_do(void)
 		msgbuf = spp_strbuf_allocate(CMD_REQ_BUF_INIT_SIZE);
 		if (unlikely(msgbuf == NULL)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
-					"Cannot allocate memory for receive data(init).\n");
+					"Cannot allocate memory "
+					"for receive data(init).\n");
 			return -1;
 		}
 	}
diff --git a/src/vf/ringlatencystats.c b/src/vf/ringlatencystats.c
index 4ad469d..a0cc901 100644
--- a/src/vf/ringlatencystats.c
+++ b/src/vf/ringlatencystats.c
@@ -55,8 +55,8 @@ spp_ringlatencystats_init(uint64_t samp_intvl, uint16_t stats_count)
 			sizeof(struct ring_latency_stats_info) * stats_count,
 			0);
 	if (unlikely(g_stats_info == NULL)) {
-		RTE_LOG(ERR, SPP_RING_LATENCY_STATS,
-				"Cannot allocate memory for ring latency stats info\n");
+		RTE_LOG(ERR, SPP_RING_LATENCY_STATS, "Cannot allocate memory "
+				"for ring latency stats info\n");
 		return -1;
 	}
 
@@ -65,7 +65,8 @@ spp_ringlatencystats_init(uint64_t samp_intvl, uint16_t stats_count)
 	g_stats_count = stats_count;
 
 	RTE_LOG(DEBUG, SPP_RING_LATENCY_STATS,
-			"g_samp_intvl=%lu, g_stats_count=%hu, cpns=%lu, NS_PER_SEC=%f\n",
+			"g_samp_intvl=%lu, g_stats_count=%hu, "
+			"cpns=%lu, NS_PER_SEC=%f\n",
 			g_samp_intvl, g_stats_count,
 			cycles_per_ns(), NS_PER_SEC);
 
@@ -103,7 +104,8 @@ spp_ringlatencystats_add_time_stamp(int ring_id,
 		/* set tsc to mbuf::timestamp */
 		if (unlikely(stats_info->timer_tsc >= g_samp_intvl)) {
 			RTE_LOG(DEBUG, SPP_RING_LATENCY_STATS,
-					"Set timestamp. ring_id=%d, pkts_index=%u, timestamp=%lu\n",
+					"Set timestamp. ring_id=%d, "
+					"pkts_index=%u, timestamp=%lu\n",
 					ring_id, i, now);
 			pkts[i]->timestamp = now;
 			stats_info->timer_tsc = 0;
diff --git a/src/vf/spp_forward.c b/src/vf/spp_forward.c
index 03bda10..b0846c6 100644
--- a/src/vf/spp_forward.c
+++ b/src/vf/spp_forward.c
@@ -80,7 +80,8 @@ spp_forward_update(struct spp_component_info *component)
 	memset(path, 0x00, sizeof(struct forward_path));
 
 	RTE_LOG(INFO, FORWARD,
-			"Component[%d] Start update component. (name = %s, type = %d)\n",
+			"Component[%d] Start update component. "
+			"(name = %s, type = %d)\n",
 			component->component_id,
 			component->name,
 			component->type);
@@ -103,7 +104,8 @@ spp_forward_update(struct spp_component_info *component)
 		rte_delay_us_block(SPP_CHANGE_UPDATE_INTERVAL);
 
 	RTE_LOG(INFO, FORWARD,
-			"Component[%d] Complete update component. (name = %s, type = %d)\n",
+			"Component[%d] Complete update component. "
+			"(name = %s, type = %d)\n",
 			component->component_id,
 			component->name,
 			component->type);
@@ -118,7 +120,8 @@ change_forward_index(int id)
 	struct forward_info *info = &g_forward_info[id];
 	if (info->ref_index == info->upd_index) {
 		/* Change reference index of port ability. */
-		spp_port_ability_change_index(PORT_ABILITY_CHG_INDEX_REF, 0, 0);
+		spp_port_ability_change_index(PORT_ABILITY_CHG_INDEX_REF,
+									0, 0);
 
 		info->ref_index = (info->upd_index+1)%SPP_INFO_AREA_MAX;
 	}
@@ -149,13 +152,15 @@ spp_forward(int id)
 		tx = &path->ports[cnt].tx;
 
 		/* Receive packets */
-		nb_rx = spp_eth_rx_burst(rx->dpdk_port, 0, bufs, MAX_PKT_BURST);
+		nb_rx = spp_eth_rx_burst(rx->dpdk_port, 0,
+						bufs, MAX_PKT_BURST);
 		if (unlikely(nb_rx == 0))
 			continue;
 
 		/* Send packets */
 		if (tx->dpdk_port >= 0)
-			nb_tx = spp_eth_tx_burst(tx->dpdk_port, 0, bufs, nb_rx);
+			nb_tx = spp_eth_tx_burst(tx->dpdk_port,
+							0, bufs, nb_rx);
 
 		/* Discard remained packets to release mbuf */
 		if (unlikely(nb_tx < nb_rx)) {
@@ -182,7 +187,8 @@ spp_forward_get_component_status(
 
 	if (unlikely(path->type == SPP_COMPONENT_UNUSE)) {
 		RTE_LOG(ERR, FORWARD,
-				"Component[%d] Not used. (status)(core = %d, type = %d)\n",
+				"Component[%d] Not used. "
+				"(status)(core = %d, type = %d)\n",
 				id, lcore_id, path->type);
 		return -1;
 	}
diff --git a/src/vf/spp_port.c b/src/vf/spp_port.c
index 3b96df7..9a29f35 100644
--- a/src/vf/spp_port.c
+++ b/src/vf/spp_port.c
@@ -110,7 +110,8 @@ add_vlantag_packet(
 		new_ether = (struct ether_hdr *)rte_pktmbuf_prepend(pkt,
 				sizeof(struct vlan_hdr));
 		if (unlikely(new_ether == NULL)) {
-			RTE_LOG(ERR, PORT, "Failed to get additional header area.\n");
+			RTE_LOG(ERR, PORT, "Failed to "
+					"get additional header area.\n");
 			return -1;
 		}
 
@@ -137,8 +138,8 @@ add_vlantag_all_packets(
 		ret = add_vlantag_packet(pkts[cnt], data);
 		if (unlikely(ret < 0)) {
 			RTE_LOG(ERR, PORT,
-					"Failed to add VLAN tag.(pkts %d/%d)\n",
-					cnt, nb_pkts);
+					"Failed to add VLAN tag."
+					"(pkts %d/%d)\n", cnt, nb_pkts);
 			break;
 		}
 	}
@@ -161,7 +162,8 @@ del_vlantag_packet(
 		new_ether = (struct ether_hdr *)rte_pktmbuf_adj(pkt,
 				sizeof(struct vlan_hdr));
 		if (unlikely(new_ether == NULL)) {
-			RTE_LOG(ERR, PORT, "Failed to delete unnecessary header area.\n");
+			RTE_LOG(ERR, PORT, "Failed to "
+					"delete unnecessary header area.\n");
 			return -1;
 		}
 
@@ -188,8 +190,8 @@ del_vlantag_all_packets(
 		ret = del_vlantag_packet(pkts[cnt], data);
 		if (unlikely(ret < 0)) {
 			RTE_LOG(ERR, PORT,
-					"Failed to del VLAN tag.(pkts %d/%d)\n",
-					cnt, nb_pkts);
+					"Failed to del VLAN tag."
+					"(pkts %d/%d)\n", cnt, nb_pkts);
 			break;
 		}
 	}
@@ -251,7 +253,8 @@ port_ability_set_ability(
 {
 	int in_cnt, out_cnt = 0;
 	int port_id = port->dpdk_port;
-	struct port_ability_port_mng_info *port_mng = &g_port_mng_info[port_id];
+	struct port_ability_port_mng_info *port_mng =
+						&g_port_mng_info[port_id];
 	struct port_ability_mng_info *mng         = NULL;
 	struct spp_port_ability      *in_ability  = port->ability;
 	struct spp_port_ability      *out_ability = NULL;
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index e493980..96d331e 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -75,7 +75,8 @@ struct core_info {
 	volatile enum spp_component_type type;
 				/* Component type */
 	int num;                /* The number of IDs below */
-	int id[RTE_MAX_LCORE];  /* ID list of components executed on cpu core */
+	int id[RTE_MAX_LCORE];
+			/* ID list of components executed on cpu core */
 };
 
 /* Manage core status and component information as global variable */
@@ -139,7 +140,8 @@ usage(const char *progname)
 			" -s SERVER_IP:SERVER_PORT"
 			" [--vhost-client]\n"
 			" --client-id CLIENT_ID   : My client ID\n"
-			" -s SERVER_IP:SERVER_PORT  : Access information to the server\n"
+			" -s SERVER_IP:SERVER_PORT  :"
+			" Access information to the server\n"
 			" --vhost-client            : Run vhost on client\n"
 			, progname);
 }
@@ -211,8 +213,8 @@ add_vhost_pmd(int index, int client)
 
 	mp = rte_mempool_lookup(PKTMBUF_POOL_NAME);
 	if (unlikely(mp == NULL)) {
-		RTE_LOG(ERR, APP, "Cannot get mempool for mbufs. (name = %s)\n",
-				PKTMBUF_POOL_NAME);
+		RTE_LOG(ERR, APP, "Cannot get mempool for mbufs. "
+				"(name = %s)\n", PKTMBUF_POOL_NAME);
 		return -1;
 	}
 
@@ -232,8 +234,8 @@ add_vhost_pmd(int index, int client)
 	ret = rte_eth_dev_configure(vhost_port_id, nr_queues, nr_queues,
 		&port_conf);
 	if (unlikely(ret < 0)) {
-		RTE_LOG(ERR, APP, "rte_eth_dev_configure error. (ret = %d)\n",
-				ret);
+		RTE_LOG(ERR, APP, "rte_eth_dev_configure error. "
+				"(ret = %d)\n", ret);
 		return ret;
 	}
 
@@ -264,7 +266,8 @@ add_vhost_pmd(int index, int client)
 	/* Start the Ethernet port. */
 	ret = rte_eth_dev_start(vhost_port_id);
 	if (unlikely(ret < 0)) {
-		RTE_LOG(ERR, APP, "rte_eth_dev_start error. (ret = %d)\n", ret);
+		RTE_LOG(ERR, APP, "rte_eth_dev_start error. (ret = %d)\n",
+				ret);
 		return ret;
 	}
 
@@ -389,7 +392,8 @@ parse_app_server(const char *server_str, char *server_ip, int *server_port)
 		return -1;
 
 	port = strtol(&server_str[pos+1], &endptr, 0);
-	if (unlikely(&server_str[pos+1] == endptr) || unlikely(*endptr != '\0'))
+	if (unlikely(&server_str[pos+1] == endptr) ||
+				unlikely(*endptr != '\0'))
 		return -1;
 
 	memcpy(server_ip, server_str, pos);
@@ -466,7 +470,8 @@ parse_app_args(int argc, char *argv[])
 		return -1;
 	}
 	RTE_LOG(INFO, APP,
-			"app opts (client_id=%d,server=%s:%d,vhost_client=%d)\n",
+			"app opts (client_id=%d,server=%s:%d,"
+			"vhost_client=%d)\n",
 			g_startup_param.client_id,
 			g_startup_param.server_ip,
 			g_startup_param.server_port,
@@ -509,11 +514,13 @@ dump_core_info(const struct core_mng_info *core_info)
 
 		sprintf(str, "core[%d]-0 type=%d, num=%d", lcore_id,
 				info->core[0].type, info->core[0].num);
-		dump_buff(str, info->core[0].id, sizeof(int)*info->core[0].num);
+		dump_buff(str, info->core[0].id,
+				sizeof(int)*info->core[0].num);
 
 		sprintf(str, "core[%d]-1 type=%d, num=%d", lcore_id,
 				info->core[1].type, info->core[1].num);
-		dump_buff(str, info->core[1].id, sizeof(int)*info->core[1].num);
+		dump_buff(str, info->core[1].id,
+				sizeof(int)*info->core[1].num);
 	}
 }
 
@@ -529,7 +536,8 @@ dump_component_info(const struct spp_component_info *component_info)
 		if (component->type == SPP_COMPONENT_UNUSE)
 			continue;
 
-		RTE_LOG(DEBUG, APP, "component[%d] name=%s, type=%d, core=%u, index=%d\n",
+		RTE_LOG(DEBUG, APP, "component[%d] name=%s, type=%d, "
+				"core=%u, index=%d\n",
 				cnt, component->name, component->type,
 				component->lcore_id, component->component_id);
 
@@ -907,7 +915,8 @@ slave_main(void *arg __attribute__ ((unused)))
 				break;
 		}
 		if (unlikely(ret != 0)) {
-			RTE_LOG(ERR, APP, "Core[%d] Component Error. (id = %d)\n",
+			RTE_LOG(ERR, APP, "Core[%d] Component Error. "
+					"(id = %d)\n",
 					lcore_id, core->id[cnt]);
 			break;
 		}
@@ -1165,7 +1174,8 @@ spp_update_classifier_table(
 	int64_t ret_mac = 0;
 	uint64_t mac_addr = 0;
 
-	RTE_LOG(DEBUG, APP, "update_classifier_table ( type = mac, mac addr = %s, port = %d:%d )\n",
+	RTE_LOG(DEBUG, APP, "update_classifier_table "
+			"( type = mac, mac addr = %s, port = %d:%d )\n",
 			mac_addr_str, port->iface_type, port->iface_no);
 
 	ret_mac = spp_change_mac_str_to_int64(mac_addr_str);
@@ -1193,32 +1203,35 @@ spp_update_classifier_table(
 		if ((port_info->class_id.vlantag.vid != 0) &&
 				unlikely(port_info->class_id.vlantag.vid !=
 				vid)) {
-			RTE_LOG(ERR, APP, "VLAN ID is different. ( vid = %d )\n",
-					vid);
+			RTE_LOG(ERR, APP, "VLAN ID is different. "
+					"( vid = %d )\n", vid);
 			return SPP_RET_NG;
 		}
 		if ((port_info->class_id.mac_addr != 0) &&
 				unlikely(port_info->class_id.mac_addr !=
 						mac_addr)) {
-			RTE_LOG(ERR, APP, "MAC address is different. ( mac = %s )\n",
-					mac_addr_str);
+			RTE_LOG(ERR, APP, "MAC address is different. "
+					"( mac = %s )\n", mac_addr_str);
 			return SPP_RET_NG;
 		}
 
 		port_info->class_id.vlantag.vid = ETH_VLAN_ID_MAX;
 		port_info->class_id.mac_addr    = 0;
-		memset(port_info->class_id.mac_addr_str, 0x00, SPP_MIN_STR_LEN);
+		memset(port_info->class_id.mac_addr_str, 0x00,
+							SPP_MIN_STR_LEN);
 	} else if (action == SPP_CMD_ACTION_ADD) {
 		/* Setting */
 		if (unlikely(port_info->class_id.vlantag.vid !=
 				ETH_VLAN_ID_MAX)) {
-			RTE_LOG(ERR, APP, "Port in used. ( port = %d:%d, vlan = %d != %d )\n",
+			RTE_LOG(ERR, APP, "Port in used. "
+					"( port = %d:%d, vlan = %d != %d )\n",
 					port->iface_type, port->iface_no,
 					port_info->class_id.vlantag.vid, vid);
 			return SPP_RET_NG;
 		}
 		if (unlikely(port_info->class_id.mac_addr != 0)) {
-			RTE_LOG(ERR, APP, "Port in used. ( port = %d:%d, mac = %s != %s )\n",
+			RTE_LOG(ERR, APP, "Port in used. "
+					"( port = %d:%d, mac = %s != %s )\n",
 					port->iface_type, port->iface_no,
 					port_info->class_id.mac_addr_str,
 					mac_addr_str);
@@ -1437,8 +1450,8 @@ spp_update_port(enum spp_command_action action,
 
 	component_id = spp_get_component_id(name);
 	if (component_id < 0) {
-		RTE_LOG(ERR, APP, "Unknown component by port command. (component = %s)\n",
-				name);
+		RTE_LOG(ERR, APP, "Unknown component by port command. "
+				"(component = %s)\n", name);
 		return SPP_RET_NG;
 	}
 
@@ -1470,7 +1483,8 @@ spp_update_port(enum spp_command_action action,
 				cnt++;
 			}
 			if (cnt >= SPP_PORT_ABILITY_MAX) {
-				RTE_LOG(ERR, APP, "No space of port ability.\n");
+				RTE_LOG(ERR, APP,
+						"No space of port ability.\n");
 				return SPP_RET_NG;
 			}
 			memcpy(&port_info->ability[cnt], ability,
@@ -1592,7 +1606,8 @@ flush_component(void)
 			ret = spp_forward_update(component_info);
 
 		if (unlikely(ret < 0)) {
-			RTE_LOG(ERR, APP, "Flush error. ( component = %s, type = %d)\n",
+			RTE_LOG(ERR, APP, "Flush error. "
+					"( component = %s, type = %d)\n",
 					component_info->name,
 					component_info->type);
 			return SPP_RET_NG;
@@ -1641,7 +1656,8 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
 				"", SPP_TYPE_UNUSE_STR,
 				0, NULL, 0, NULL);
 			if (unlikely(ret != 0)) {
-				RTE_LOG(ERR, APP, "Cannot iterate core information. "
+				RTE_LOG(ERR, APP, "Cannot iterate core "
+						"information. "
 						"(core = %d, type = %d)\n",
 						lcore_id, SPP_COMPONENT_UNUSE);
 				return SPP_RET_NG;
@@ -1662,7 +1678,8 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
 						params);
 			}
 			if (unlikely(ret != 0)) {
-				RTE_LOG(ERR, APP, "Cannot iterate core information. "
+				RTE_LOG(ERR, APP, "Cannot iterate core "
+						"information. "
 						"(core = %d, type = %d)\n",
 						lcore_id, core->type);
 				return SPP_RET_NG;
@@ -1712,7 +1729,9 @@ spp_get_dpdk_port(enum port_type iface_type, int iface_no)
  * For instance, 'ring:0' is separated to 'ring' and '0'.
  */
 int
-spp_get_iface_index(const char *port, enum port_type *iface_type, int *iface_no)
+spp_get_iface_index(const char *port,
+		    enum port_type *iface_type,
+		    int *iface_no)
 {
 	enum port_type type = UNDEF;
 	const char *no_str = NULL;
@@ -1809,8 +1828,8 @@ spp_change_mac_str_to_int64(const char *mac)
 
 		/* Check for mal-formatted address */
 		if (unlikely(token_cnt >= ETHER_ADDR_LEN)) {
-			RTE_LOG(ERR, APP, "MAC address format error. (mac = %s)\n",
-					mac);
+			RTE_LOG(ERR, APP, "MAC address format error. "
+					"(mac = %s)\n", mac);
 			return -1;
 		}
 
diff --git a/src/vf/spp_vf.h b/src/vf/spp_vf.h
index 3491879..8bc5961 100644
--- a/src/vf/spp_vf.h
+++ b/src/vf/spp_vf.h
@@ -513,7 +513,8 @@ int spp_get_iface_index(
  * @retval 0  succeeded.
  * @retval -1 failed.
  */
-int spp_format_port_string(char *port, enum port_type iface_type, int iface_no);
+int
+spp_format_port_string(char *port, enum port_type iface_type, int iface_no);
 
 /**
  * Change component type from string to type value.
diff --git a/src/vf/string_buffer.c b/src/vf/string_buffer.c
index 3e1d9f5..acf0f81 100644
--- a/src/vf/string_buffer.c
+++ b/src/vf/string_buffer.c
@@ -62,7 +62,8 @@ spp_strbuf_free(char *strbuf)
 {
 	if (likely(strbuf != NULL)) {
 		RTE_LOG(DEBUG, SPP_STRING_BUFF,
-				";free   ; addr=%p; size=%lu; str=%s; len=%lu;\n",
+				";free   ; addr=%p; size=%lu; "
+				"str=%s; len=%lu;\n",
 				strbuf, strbuf_get_capacity(strbuf),
 				strbuf, strlen(strbuf));
 		free(strbuf - sizeof(size_t));
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 02/23] spp_vf: move common source and header files
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
  2018-11-21  1:35 ` [spp] [PATCH 01/23] spp_vf: fix invalid code for max chars x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 03/23] spp_vf: change include path x-fn-spp
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Move common source and header files to be used from spp_vf and
spp_mirror.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/{ => common}/command_conn.c     | 0
 src/vf/{ => common}/command_conn.h     | 0
 src/vf/{ => common}/command_dec.c      | 0
 src/vf/{ => common}/command_dec.h      | 0
 src/vf/{ => common}/command_proc.c     | 0
 src/vf/{ => common}/command_proc.h     | 0
 src/vf/{ => common}/ringlatencystats.c | 0
 src/vf/{ => common}/ringlatencystats.h | 0
 src/vf/{ => common}/spp_port.c         | 0
 src/vf/{ => common}/spp_port.h         | 0
 src/vf/{ => common}/string_buffer.c    | 0
 src/vf/{ => common}/string_buffer.h    | 0
 12 files changed, 0 insertions(+), 0 deletions(-)
 rename src/vf/{ => common}/command_conn.c (100%)
 rename src/vf/{ => common}/command_conn.h (100%)
 rename src/vf/{ => common}/command_dec.c (100%)
 rename src/vf/{ => common}/command_dec.h (100%)
 rename src/vf/{ => common}/command_proc.c (100%)
 rename src/vf/{ => common}/command_proc.h (100%)
 rename src/vf/{ => common}/ringlatencystats.c (100%)
 rename src/vf/{ => common}/ringlatencystats.h (100%)
 rename src/vf/{ => common}/spp_port.c (100%)
 rename src/vf/{ => common}/spp_port.h (100%)
 rename src/vf/{ => common}/string_buffer.c (100%)
 rename src/vf/{ => common}/string_buffer.h (100%)

diff --git a/src/vf/command_conn.c b/src/vf/common/command_conn.c
similarity index 100%
rename from src/vf/command_conn.c
rename to src/vf/common/command_conn.c
diff --git a/src/vf/command_conn.h b/src/vf/common/command_conn.h
similarity index 100%
rename from src/vf/command_conn.h
rename to src/vf/common/command_conn.h
diff --git a/src/vf/command_dec.c b/src/vf/common/command_dec.c
similarity index 100%
rename from src/vf/command_dec.c
rename to src/vf/common/command_dec.c
diff --git a/src/vf/command_dec.h b/src/vf/common/command_dec.h
similarity index 100%
rename from src/vf/command_dec.h
rename to src/vf/common/command_dec.h
diff --git a/src/vf/command_proc.c b/src/vf/common/command_proc.c
similarity index 100%
rename from src/vf/command_proc.c
rename to src/vf/common/command_proc.c
diff --git a/src/vf/command_proc.h b/src/vf/common/command_proc.h
similarity index 100%
rename from src/vf/command_proc.h
rename to src/vf/common/command_proc.h
diff --git a/src/vf/ringlatencystats.c b/src/vf/common/ringlatencystats.c
similarity index 100%
rename from src/vf/ringlatencystats.c
rename to src/vf/common/ringlatencystats.c
diff --git a/src/vf/ringlatencystats.h b/src/vf/common/ringlatencystats.h
similarity index 100%
rename from src/vf/ringlatencystats.h
rename to src/vf/common/ringlatencystats.h
diff --git a/src/vf/spp_port.c b/src/vf/common/spp_port.c
similarity index 100%
rename from src/vf/spp_port.c
rename to src/vf/common/spp_port.c
diff --git a/src/vf/spp_port.h b/src/vf/common/spp_port.h
similarity index 100%
rename from src/vf/spp_port.h
rename to src/vf/common/spp_port.h
diff --git a/src/vf/string_buffer.c b/src/vf/common/string_buffer.c
similarity index 100%
rename from src/vf/string_buffer.c
rename to src/vf/common/string_buffer.c
diff --git a/src/vf/string_buffer.h b/src/vf/common/string_buffer.h
similarity index 100%
rename from src/vf/string_buffer.h
rename to src/vf/common/string_buffer.h
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 03/23] spp_vf: change include path
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
  2018-11-21  1:35 ` [spp] [PATCH 01/23] spp_vf: fix invalid code for max chars x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 02/23] spp_vf: move common source and header files x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 04/23] spp_vf: update Makefile for common files x-fn-spp
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Change include path because defines and enums are moved to be common.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/command_dec.c  | 2 +-
 src/vf/common/command_proc.c | 2 +-
 src/vf/common/spp_port.c     | 1 -
 src/vf/common/spp_port.h     | 2 +-
 4 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/vf/common/command_dec.c b/src/vf/common/command_dec.c
index 204cb86..d16f358 100644
--- a/src/vf/common/command_dec.c
+++ b/src/vf/common/command_dec.c
@@ -9,7 +9,7 @@
 #include <rte_log.h>
 #include <rte_branch_prediction.h>
 
-#include "spp_vf.h"
+#include "../spp_vf.h"
 #include "command_dec.h"
 
 #define RTE_LOGTYPE_SPP_COMMAND_PROC RTE_LOGTYPE_USER1
diff --git a/src/vf/common/command_proc.c b/src/vf/common/command_proc.c
index 3b9d687..b8ad907 100644
--- a/src/vf/common/command_proc.c
+++ b/src/vf/common/command_proc.c
@@ -8,7 +8,7 @@
 #include <rte_log.h>
 #include <rte_branch_prediction.h>
 
-#include "spp_vf.h"
+#include "../spp_vf.h"
 #include "spp_port.h"
 #include "string_buffer.h"
 #include "command_conn.h"
diff --git a/src/vf/common/spp_port.c b/src/vf/common/spp_port.c
index 9a29f35..3b1f5c3 100644
--- a/src/vf/common/spp_port.c
+++ b/src/vf/common/spp_port.c
@@ -8,7 +8,6 @@
 #include <rte_tcp.h>
 #include <rte_net_crc.h>
 
-#include "spp_vf.h"
 #include "spp_port.h"
 #include "ringlatencystats.h"
 
diff --git a/src/vf/common/spp_port.h b/src/vf/common/spp_port.h
index 5c00233..71d1325 100644
--- a/src/vf/common/spp_port.h
+++ b/src/vf/common/spp_port.h
@@ -12,7 +12,7 @@
  * Provide about the ability per port.
  */
 
-#include "spp_vf.h"
+#include "../spp_vf.h"
 
 /** Calculate TCI of VLAN tag. */
 #define SPP_VLANTAG_CALC_TCI(id, pcp) (((pcp & 0x07) << 13) | (id & 0x0fff))
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 04/23] spp_vf: update Makefile for common files
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (2 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 03/23] spp_vf: change include path x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 05/23] spp_vf: move functions to common directory x-fn-spp
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Update `SRCS-y` and `CFLAGS` options because the paths of common files
are changed.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/vf/Makefile b/src/vf/Makefile
index 88381be..a1c7886 100644
--- a/src/vf/Makefile
+++ b/src/vf/Makefile
@@ -13,12 +13,13 @@ APP = spp_vf
 
 # all source are stored in SRCS-y
 SRCS-y := spp_vf.c classifier_mac.c spp_forward.c
-SRCS-y += string_buffer.c ringlatencystats.c spp_port.c
-SRCS-y += command_conn.c command_dec.c command_proc.c
+SRCS-y += common/string_buffer.c common/ringlatencystats.c common/spp_port.c
+SRCS-y += common/command_conn.c common/command_dec.c common/command_proc.c
 SRCS-y += ../shared/common.c
 
 CFLAGS += $(WERROR_FLAGS) -O3
 CFLAGS += -I$(SRCDIR)/../shared
+CFLAGS += -I$(SRCDIR)/common
 #CFLAGS += -DSPP_DEMONIZE
 #CFLAGS += -DSPP_RINGLATENCYSTATS_ENABLE
 
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 05/23] spp_vf: move functions to common directory
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (3 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 04/23] spp_vf: update Makefile for common files x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 06/23] spp_vf: move defines to common dir x-fn-spp
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Move common functions of spp_vf and spp_mirror to common directory.

This patch also refactors code on following point.
 change of a function name and the return value.
  - from spp_check_core_index() to spp_check_core_update()
  - from get_del_core_element() to del_component_info()

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/classifier_mac.c     |   2 +-
 src/vf/common/command_dec.c |   2 +-
 src/vf/common/spp_proc.c    | 932 ++++++++++++++++++++++++++++++++++++
 src/vf/common/spp_proc.h    | 364 ++++++++++++++
 src/vf/spp_vf.c             | 916 +----------------------------------
 src/vf/spp_vf.h             | 100 ----
 6 files changed, 1300 insertions(+), 1016 deletions(-)
 create mode 100644 src/vf/common/spp_proc.c
 create mode 100644 src/vf/common/spp_proc.h

diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index 2a01f0e..4016ab1 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -868,7 +868,7 @@ spp_classifier_mac_do(int id)
 	}
 
 	while (likely(spp_get_core_status(lcore_id) == SPP_CORE_FORWARD) &&
-			likely(spp_check_core_index(lcore_id) == 0)) {
+		    likely(spp_check_core_update(lcore_id) == SPP_RET_NG)) {
 		/* change index of update side */
 		change_update_index(mng_info, id);
 
diff --git a/src/vf/common/command_dec.c b/src/vf/common/command_dec.c
index d16f358..5275f4f 100644
--- a/src/vf/common/command_dec.c
+++ b/src/vf/common/command_dec.c
@@ -273,7 +273,7 @@ decode_component_type_value(void *output, const char *arg_val)
 	if (component->action != SPP_CMD_ACTION_START)
 		return 0;
 
-	set_type = spp_change_component_type(arg_val);
+	set_type = spp_get_component_type(arg_val);
 	if (unlikely(set_type <= 0)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Unknown component type. val=%s\n",
diff --git a/src/vf/common/spp_proc.c b/src/vf/common/spp_proc.c
new file mode 100644
index 0000000..7b92e38
--- /dev/null
+++ b/src/vf/common/spp_proc.c
@@ -0,0 +1,932 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
+ */
+
+#include <unistd.h>
+#include <string.h>
+
+#include <rte_eth_ring.h>
+#include <rte_eth_vhost.h>
+#include <rte_cycles.h>
+#include <rte_log.h>
+#include <rte_branch_prediction.h>
+
+#include "spp_proc.h"
+#include "spp_port.h"
+
+#include "../vf/spp_forward.h"
+#include "../vf/classifier_mac.h"
+
+/* Declare global variables */
+
+/**
+ * Make a hexdump of an array data in every 4 byte.
+ * This function is used to dump core_info or component info.
+ */
+void
+dump_buff(const char *name, const void *addr, const size_t size)
+{
+	size_t cnt = 0;
+	size_t max = (size / sizeof(unsigned int)) +
+			((size % sizeof(unsigned int)) != 0);
+	const uint32_t *buff = addr;
+
+	if ((name != NULL) && (name[0] != '\0'))
+		RTE_LOG(DEBUG, APP, "dump buff. (%s)\n", name);
+
+	for (cnt = 0; cnt < max; cnt += 16) {
+		RTE_LOG(DEBUG, APP, "[%p]"
+				" %08x %08x %08x %08x %08x %08x %08x %08x"
+				" %08x %08x %08x %08x %08x %08x %08x %08x",
+				&buff[cnt],
+				buff[cnt+0], buff[cnt+1],
+				buff[cnt+2], buff[cnt+3],
+				buff[cnt+4], buff[cnt+5],
+				buff[cnt+6], buff[cnt+7],
+				buff[cnt+8], buff[cnt+9],
+				buff[cnt+10], buff[cnt+11],
+				buff[cnt+12], buff[cnt+13],
+				buff[cnt+14], buff[cnt+15]);
+	}
+}
+
+int
+add_ring_pmd(int ring_id)
+{
+	struct rte_ring *ring;
+	int ring_port_id;
+
+	/* Lookup ring of given id */
+	ring = rte_ring_lookup(get_rx_queue_name(ring_id));
+	if (unlikely(ring == NULL)) {
+		RTE_LOG(ERR, APP,
+			"Cannot get RX ring - is server process running?\n");
+		return -1;
+	}
+
+	/* Create ring pmd */
+	ring_port_id = rte_eth_from_ring(ring);
+	RTE_LOG(INFO, APP, "ring port add. (no = %d / port = %d)\n",
+			ring_id, ring_port_id);
+	return ring_port_id;
+}
+
+int
+add_vhost_pmd(int index, int client)
+{
+	struct rte_eth_conf port_conf = {
+		.rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
+	};
+	struct rte_mempool *mp;
+	uint16_t vhost_port_id;
+	int nr_queues = 1;
+	const char *name;
+	char devargs[64];
+	char *iface;
+	uint16_t q;
+	int ret;
+#define NR_DESCS 128
+
+	mp = rte_mempool_lookup(PKTMBUF_POOL_NAME);
+	if (unlikely(mp == NULL)) {
+		RTE_LOG(ERR, APP, "Cannot get mempool for mbufs. "
+				"(name = %s)\n", PKTMBUF_POOL_NAME);
+		return -1;
+	}
+
+	/* eth_vhost0 index 0 iface /tmp/sock0 on numa 0 */
+	name = get_vhost_backend_name(index);
+	iface = get_vhost_iface_name(index);
+
+	sprintf(devargs, "%s,iface=%s,queues=%d,client=%d",
+			name, iface, nr_queues, client);
+	ret = dev_attach_by_devargs(devargs, &vhost_port_id);
+	if (unlikely(ret < 0)) {
+		RTE_LOG(ERR, APP, "spp_rte_eth_dev_attach error. "
+				"(ret = %d)\n", ret);
+		return ret;
+	}
+
+	ret = rte_eth_dev_configure(vhost_port_id, nr_queues, nr_queues,
+		&port_conf);
+	if (unlikely(ret < 0)) {
+		RTE_LOG(ERR, APP, "rte_eth_dev_configure error. "
+				"(ret = %d)\n", ret);
+		return ret;
+	}
+
+	/* Allocate and set up 1 RX queue per Ethernet port. */
+	for (q = 0; q < nr_queues; q++) {
+		ret = rte_eth_rx_queue_setup(vhost_port_id, q, NR_DESCS,
+			rte_eth_dev_socket_id(vhost_port_id), NULL, mp);
+		if (unlikely(ret < 0)) {
+			RTE_LOG(ERR, APP,
+				"rte_eth_rx_queue_setup error. (ret = %d)\n",
+				ret);
+			return ret;
+		}
+	}
+
+	/* Allocate and set up 1 TX queue per Ethernet port. */
+	for (q = 0; q < nr_queues; q++) {
+		ret = rte_eth_tx_queue_setup(vhost_port_id, q, NR_DESCS,
+			rte_eth_dev_socket_id(vhost_port_id), NULL);
+		if (unlikely(ret < 0)) {
+			RTE_LOG(ERR, APP,
+				"rte_eth_tx_queue_setup error. (ret = %d)\n",
+				ret);
+			return ret;
+		}
+	}
+
+	/* Start the Ethernet port. */
+	ret = rte_eth_dev_start(vhost_port_id);
+	if (unlikely(ret < 0)) {
+		RTE_LOG(ERR, APP, "rte_eth_dev_start error. (ret = %d)\n",
+			ret);
+		return ret;
+	}
+
+	RTE_LOG(INFO, APP, "vhost port add. (no = %d / port = %d)\n",
+			index, vhost_port_id);
+	return vhost_port_id;
+}
+
+/* Get core status */
+enum spp_core_status
+spp_get_core_status(unsigned int lcore_id)
+{
+	return g_core_info[lcore_id].status;
+}
+
+/**
+ * Check status of all of cores is same as given
+ *
+ * It returns -1 as status mismatch if status is not same.
+ * If core is in use, status will be checked.
+ */
+static int
+check_core_status(enum spp_core_status status)
+{
+	unsigned int lcore_id = 0;
+	RTE_LCORE_FOREACH_SLAVE(lcore_id) {
+		if (g_core_info[lcore_id].status != status) {
+			/* Status is mismatched */
+			return -1;
+		}
+	}
+	return 0;
+}
+
+int
+check_core_status_wait(enum spp_core_status status)
+{
+	int cnt = 0;
+	for (cnt = 0; cnt < SPP_CORE_STATUS_CHECK_MAX; cnt++) {
+		sleep(1);
+		int ret = check_core_status(status);
+		if (ret == 0)
+			return 0;
+	}
+
+	RTE_LOG(ERR, APP, "Status check time out. (status = %d)\n", status);
+	return -1;
+}
+
+/* Set core status */
+void
+set_core_status(unsigned int lcore_id,
+		enum spp_core_status status)
+{
+	g_core_info[lcore_id].status = status;
+}
+
+/* Set all core to given status */
+void
+set_all_core_status(enum spp_core_status status)
+{
+	unsigned int lcore_id = 0;
+	RTE_LCORE_FOREACH_SLAVE(lcore_id) {
+		g_core_info[lcore_id].status = status;
+	}
+}
+
+/**
+ * Set all of component status to SPP_CORE_STOP_REQUEST if received signal
+ * is SIGTERM or SIGINT
+ */
+void
+stop_process(int signal)
+{
+	if (unlikely(signal != SIGTERM) &&
+			unlikely(signal != SIGINT)) {
+		return;
+	}
+
+	g_core_info[g_main_lcore_id].status = SPP_CORE_STOP_REQUEST;
+	set_all_core_status(SPP_CORE_STOP_REQUEST);
+}
+
+/**
+ * Return port info of given type and num of interface
+ *
+ * It returns NULL value if given type is invalid.
+ */
+struct spp_port_info *
+get_iface_info(enum port_type iface_type, int iface_no)
+{
+	switch (iface_type) {
+	case PHY:
+		return &g_iface_info.nic[iface_no];
+	case VHOST:
+		return &g_iface_info.vhost[iface_no];
+	case RING:
+		return &g_iface_info.ring[iface_no];
+	default:
+		return NULL;
+	}
+}
+
+/* Dump of core information */
+void
+dump_core_info(const struct core_mng_info *core_info)
+{
+	char str[SPP_NAME_STR_LEN];
+	const struct core_mng_info *info = NULL;
+	unsigned int lcore_id = 0;
+	RTE_LCORE_FOREACH_SLAVE(lcore_id) {
+		info = &core_info[lcore_id];
+		RTE_LOG(DEBUG, APP, "core[%d] status=%d, ref=%d, upd=%d\n",
+				lcore_id, info->status,
+				info->ref_index, info->upd_index);
+
+		sprintf(str, "core[%d]-0 type=%d, num=%d", lcore_id,
+				info->core[0].type, info->core[0].num);
+		dump_buff(str, info->core[0].id,
+				sizeof(int)*info->core[0].num);
+
+		sprintf(str, "core[%d]-1 type=%d, num=%d", lcore_id,
+				info->core[1].type, info->core[1].num);
+		dump_buff(str, info->core[1].id,
+				sizeof(int)*info->core[1].num);
+	}
+}
+
+/* Dump of component information */
+void
+dump_component_info(const struct spp_component_info *component_info)
+{
+	char str[SPP_NAME_STR_LEN];
+	const struct spp_component_info *component = NULL;
+	int cnt = 0;
+	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
+		component = &component_info[cnt];
+		if (component->type == SPP_COMPONENT_UNUSE)
+			continue;
+
+		RTE_LOG(DEBUG, APP, "component[%d] name=%s, type=%d, "
+				"core=%u, index=%d\n",
+				cnt, component->name, component->type,
+				component->lcore_id, component->component_id);
+
+		sprintf(str, "component[%d] rx=%d", cnt,
+				component->num_rx_port);
+		dump_buff(str, component->rx_ports,
+			sizeof(struct spp_port_info *)*component->num_rx_port);
+
+		sprintf(str, "component[%d] tx=%d", cnt,
+				component->num_tx_port);
+		dump_buff(str, component->tx_ports,
+			sizeof(struct spp_port_info *)*component->num_tx_port);
+	}
+}
+
+/* Dump of interface information */
+void
+dump_interface_info(const struct iface_info *iface_info)
+{
+	const struct spp_port_info *port = NULL;
+	int cnt = 0;
+	RTE_LOG(DEBUG, APP, "interface phy=%d, vhost=%d, ring=%d\n",
+			iface_info->num_nic,
+			iface_info->num_vhost,
+			iface_info->num_ring);
+	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
+		port = &iface_info->nic[cnt];
+		if (port->iface_type == UNDEF)
+			continue;
+
+		RTE_LOG(DEBUG, APP, "phy  [%d] type=%d, no=%d, port=%d, "
+				"vid = %u, mac=%08lx(%s)\n",
+				cnt, port->iface_type, port->iface_no,
+				port->dpdk_port,
+				port->class_id.vlantag.vid,
+				port->class_id.mac_addr,
+				port->class_id.mac_addr_str);
+	}
+	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
+		port = &iface_info->vhost[cnt];
+		if (port->iface_type == UNDEF)
+			continue;
+
+		RTE_LOG(DEBUG, APP, "vhost[%d] type=%d, no=%d, port=%d, "
+				"vid = %u, mac=%08lx(%s)\n",
+				cnt, port->iface_type, port->iface_no,
+				port->dpdk_port,
+				port->class_id.vlantag.vid,
+				port->class_id.mac_addr,
+				port->class_id.mac_addr_str);
+	}
+	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
+		port = &iface_info->ring[cnt];
+		if (port->iface_type == UNDEF)
+			continue;
+
+		RTE_LOG(DEBUG, APP, "ring [%d] type=%d, no=%d, port=%d, "
+				"vid = %u, mac=%08lx(%s)\n",
+				cnt, port->iface_type, port->iface_no,
+				port->dpdk_port,
+				port->class_id.vlantag.vid,
+				port->class_id.mac_addr,
+				port->class_id.mac_addr_str);
+	}
+}
+
+/* Dump of all management information */
+void
+dump_all_mng_info(
+		const struct core_mng_info *core,
+		const struct spp_component_info *component,
+		const struct iface_info *interface)
+{
+	if (rte_log_get_global_level() < RTE_LOG_DEBUG)
+		return;
+
+	dump_core_info(core);
+	dump_component_info(component);
+	dump_interface_info(interface);
+}
+
+/* Copy management information */
+void
+copy_mng_info(
+		struct core_mng_info *dst_core,
+		struct spp_component_info *dst_component,
+		struct iface_info *dst_interface,
+		const struct core_mng_info *src_core,
+		const struct spp_component_info *src_component,
+		const struct iface_info *src_interface,
+		enum copy_mng_flg flg)
+{
+	int upd_index = 0;
+	unsigned int lcore_id = 0;
+
+	switch (flg) {
+	case COPY_MNG_FLG_UPDCOPY:
+		RTE_LCORE_FOREACH_SLAVE(lcore_id) {
+			upd_index = src_core[lcore_id].upd_index;
+			memcpy(&dst_core[lcore_id].core[upd_index],
+					&src_core[lcore_id].core[upd_index],
+					sizeof(struct core_info));
+		}
+		break;
+	default:
+		/*
+		 * Even if the flag is set to None,
+		 * copying of core is necessary,
+		 * so we will treat all copies as default.
+		 */
+		memcpy(dst_core, src_core,
+				sizeof(struct core_mng_info)*RTE_MAX_LCORE);
+		break;
+	}
+
+	memcpy(dst_component, src_component,
+			sizeof(struct spp_component_info)*RTE_MAX_LCORE);
+	memcpy(dst_interface, src_interface,
+			sizeof(struct iface_info));
+}
+
+/* Backup the management information */
+void
+backup_mng_info(struct cancel_backup_info *backup)
+{
+	dump_all_mng_info(g_core_info, g_component_info, &g_iface_info);
+	copy_mng_info(backup->core, backup->component, &backup->interface,
+			g_core_info, g_component_info, &g_iface_info,
+			COPY_MNG_FLG_ALLCOPY);
+	dump_all_mng_info(backup->core, backup->component, &backup->interface);
+	memset(g_change_core, 0x00, sizeof(g_change_core));
+	memset(g_change_component, 0x00, sizeof(g_change_component));
+}
+
+/**
+ * Initialize g_iface_info
+ *
+ * Clear g_iface_info and set initial value.
+ */
+static void
+init_iface_info(void)
+{
+	int port_cnt;  /* increment ether ports */
+	memset(&g_iface_info, 0x00, sizeof(g_iface_info));
+	for (port_cnt = 0; port_cnt < RTE_MAX_ETHPORTS; port_cnt++) {
+		g_iface_info.nic[port_cnt].iface_type = UNDEF;
+		g_iface_info.nic[port_cnt].iface_no   = port_cnt;
+		g_iface_info.nic[port_cnt].dpdk_port  = -1;
+		g_iface_info.nic[port_cnt].class_id.vlantag.vid =
+				ETH_VLAN_ID_MAX;
+		g_iface_info.vhost[port_cnt].iface_type = UNDEF;
+		g_iface_info.vhost[port_cnt].iface_no   = port_cnt;
+		g_iface_info.vhost[port_cnt].dpdk_port  = -1;
+		g_iface_info.vhost[port_cnt].class_id.vlantag.vid =
+				ETH_VLAN_ID_MAX;
+		g_iface_info.ring[port_cnt].iface_type = UNDEF;
+		g_iface_info.ring[port_cnt].iface_no   = port_cnt;
+		g_iface_info.ring[port_cnt].dpdk_port  = -1;
+		g_iface_info.ring[port_cnt].class_id.vlantag.vid =
+				ETH_VLAN_ID_MAX;
+	}
+}
+
+/**
+ * Initialize g_component_info
+ */
+static void
+init_component_info(void)
+{
+	int cnt;
+	memset(&g_component_info, 0x00, sizeof(g_component_info));
+	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++)
+		g_component_info[cnt].component_id = cnt;
+	memset(g_change_component, 0x00, sizeof(g_change_component));
+}
+
+/**
+ * Initialize g_core_info
+ */
+static void
+init_core_info(void)
+{
+	int cnt = 0;
+	memset(&g_core_info, 0x00, sizeof(g_core_info));
+	set_all_core_status(SPP_CORE_STOP);
+	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
+		g_core_info[cnt].ref_index = 0;
+		g_core_info[cnt].upd_index = 1;
+	}
+	memset(g_change_core, 0x00, sizeof(g_change_core));
+}
+
+/**
+ * Setup port info of port on host
+ */
+static int
+set_nic_interface(void)
+{
+	int nic_cnt = 0;
+
+	/* NIC Setting */
+	g_iface_info.num_nic = rte_eth_dev_count_avail();
+	if (g_iface_info.num_nic > RTE_MAX_ETHPORTS)
+		g_iface_info.num_nic = RTE_MAX_ETHPORTS;
+
+	for (nic_cnt = 0; nic_cnt < g_iface_info.num_nic; nic_cnt++) {
+		g_iface_info.nic[nic_cnt].iface_type   = PHY;
+		g_iface_info.nic[nic_cnt].dpdk_port = nic_cnt;
+	}
+
+	return 0;
+}
+
+/**
+ * Setup management info for spp_vf
+ */
+int
+init_mng_data(void)
+{
+	/* Initialize interface and core information */
+	init_iface_info();
+	init_core_info();
+	init_component_info();
+
+	int ret_nic = set_nic_interface();
+	if (unlikely(ret_nic != 0))
+		return -1;
+
+	return 0;
+}
+
+#ifdef SPP_RINGLATENCYSTATS_ENABLE
+/**
+ * Print statistics of time for packet processing in ring interface
+ */
+static void
+print_ring_latency_stats(void)
+{
+	/* Clear screen and move cursor to top left */
+	const char topLeft[] = { 27, '[', '1', ';', '1', 'H', '\0' };
+	const char clr[] = { 27, '[', '2', 'J', '\0' };
+	printf("%s%s", clr, topLeft);
+
+	int ring_cnt, stats_cnt;
+	struct spp_ringlatencystats_ring_latency_stats stats[RTE_MAX_ETHPORTS];
+	memset(&stats, 0x00, sizeof(stats));
+
+	printf("RING Latency\n");
+	printf(" RING");
+	for (ring_cnt = 0; ring_cnt < RTE_MAX_ETHPORTS; ring_cnt++) {
+		if (g_iface_info.ring[ring_cnt].iface_type == UNDEF)
+			continue;
+
+		spp_ringlatencystats_get_stats(ring_cnt, &stats[ring_cnt]);
+		printf(", %-18d", ring_cnt);
+	}
+	printf("\n");
+
+	for (stats_cnt = 0; stats_cnt < SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT;
+			stats_cnt++) {
+		printf("%3dns", stats_cnt);
+		for (ring_cnt = 0; ring_cnt < RTE_MAX_ETHPORTS; ring_cnt++) {
+			if (g_iface_info.ring[ring_cnt].iface_type == UNDEF)
+				continue;
+
+			printf(", 0x%-16lx", stats[ring_cnt].slot[stats_cnt]);
+		}
+		printf("\n");
+	}
+}
+#endif /* SPP_RINGLATENCYSTATS_ENABLE */
+
+/* Remove sock file if spp is not running */
+void
+del_vhost_sockfile(struct spp_port_info *vhost)
+{
+	int cnt;
+
+	/* Do not remove for if it is running in vhost-client mode. */
+	if (g_startup_param.vhost_client != 0)
+		return;
+
+	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
+		if (likely(vhost[cnt].iface_type == UNDEF)) {
+			/* Skip removing if it is not using vhost */
+			continue;
+		}
+
+		remove(get_vhost_iface_name(cnt));
+	}
+}
+
+/* Get component type of target core */
+enum spp_component_type
+spp_get_component_type(unsigned int lcore_id)
+{
+	struct core_mng_info *info = &g_core_info[lcore_id];
+	return info->core[info->ref_index].type;
+}
+
+/* Get core ID of target component */
+unsigned int
+spp_get_component_core(int component_id)
+{
+	struct spp_component_info *info = &g_component_info[component_id];
+	return info->lcore_id;
+}
+
+/* Get core information which is in use */
+struct core_info *
+get_core_info(unsigned int lcore_id)
+{
+	struct core_mng_info *info = &g_core_info[lcore_id];
+	return &(info->core[info->ref_index]);
+}
+
+/* Check core index change */
+int
+spp_check_core_update(unsigned int lcore_id)
+{
+	struct core_mng_info *info = &g_core_info[lcore_id];
+	if (info->ref_index == info->upd_index)
+		return SPP_RET_OK;
+	else
+		return SPP_RET_NG;
+}
+
+int
+spp_check_used_port(
+		enum port_type iface_type,
+		int iface_no,
+		enum spp_port_rxtx rxtx)
+{
+	int cnt, port_cnt, max = 0;
+	struct spp_component_info *component = NULL;
+	struct spp_port_info **port_array = NULL;
+	struct spp_port_info *port = get_iface_info(iface_type, iface_no);
+
+	if (port == NULL)
+		return SPP_RET_NG;
+
+	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
+		component = &g_component_info[cnt];
+		if (component->type == SPP_COMPONENT_UNUSE)
+			continue;
+
+		if (rxtx == SPP_PORT_RXTX_RX) {
+			max = component->num_rx_port;
+			port_array = component->rx_ports;
+		} else if (rxtx == SPP_PORT_RXTX_TX) {
+			max = component->num_tx_port;
+			port_array = component->tx_ports;
+		}
+		for (port_cnt = 0; port_cnt < max; port_cnt++) {
+			if (unlikely(port_array[port_cnt] == port))
+				return cnt;
+		}
+	}
+
+	return SPP_RET_NG;
+}
+
+/* Set component update flag for given port */
+void
+set_component_change_port(struct spp_port_info *port, enum spp_port_rxtx rxtx)
+{
+	int ret = 0;
+	if ((rxtx == SPP_PORT_RXTX_RX) || (rxtx == SPP_PORT_RXTX_ALL)) {
+		ret = spp_check_used_port(port->iface_type, port->iface_no,
+				SPP_PORT_RXTX_RX);
+		if (ret >= 0)
+			g_change_component[ret] = 1;
+	}
+
+	if ((rxtx == SPP_PORT_RXTX_TX) || (rxtx == SPP_PORT_RXTX_ALL)) {
+		ret = spp_check_used_port(port->iface_type, port->iface_no,
+				SPP_PORT_RXTX_TX);
+		if (ret >= 0)
+			g_change_component[ret] = 1;
+	}
+}
+
+/* Get unused component id */
+int
+get_free_component(void)
+{
+	int cnt = 0;
+	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
+		if (g_component_info[cnt].type == SPP_COMPONENT_UNUSE)
+			return cnt;
+	}
+	return -1;
+}
+
+/* Get component id for specified component name */
+int
+spp_get_component_id(const char *name)
+{
+	int cnt = 0;
+	if (name[0] == '\0')
+		return SPP_RET_NG;
+
+	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
+		if (strcmp(name, g_component_info[cnt].name) == 0)
+			return cnt;
+	}
+	return SPP_RET_NG;
+}
+
+/* Delete component information */
+int
+del_component_info(int component_id, int component_num, int *componet_array)
+{
+	int cnt;
+	int match = -1;
+	int max = component_num;
+
+	for (cnt = 0; cnt < max; cnt++) {
+		if (component_id == componet_array[cnt])
+			match = cnt;
+	}
+
+	if (match < 0)
+		return -1;
+
+	/* Last element is excluded from movement. */
+	max--;
+
+	for (cnt = match; cnt < max; cnt++)
+		componet_array[cnt] = componet_array[cnt+1];
+
+	/* Last element is cleared. */
+	componet_array[cnt] = 0;
+	return 0;
+}
+
+/* get port element which matches the condition */
+int
+check_port_element(
+		struct spp_port_info *info,
+		int num,
+		struct spp_port_info *array[])
+{
+	int cnt = 0;
+	int match = -1;
+	for (cnt = 0; cnt < num; cnt++) {
+		if (info == array[cnt])
+			match = cnt;
+	}
+	return match;
+}
+
+/* search matched port_info from array and delete it */
+int
+get_del_port_element(
+		struct spp_port_info *info,
+		int num,
+		struct spp_port_info *array[])
+{
+	int cnt = 0;
+	int match = -1;
+	int max = num;
+
+	match = check_port_element(info, num, array);
+	if (match < 0)
+		return -1;
+
+	/* Last element is excluded from movement. */
+	max--;
+
+	for (cnt = match; cnt < max; cnt++)
+		array[cnt] = array[cnt+1];
+
+	/* Last element is cleared. */
+	array[cnt] = NULL;
+	return 0;
+}
+
+/* Flush initial setting of each interface. */
+int
+flush_port(void)
+{
+	int ret = 0;
+	int cnt = 0;
+	struct spp_port_info *port = NULL;
+
+	/* Initialize added vhost. */
+	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
+		port = &g_iface_info.vhost[cnt];
+		if ((port->iface_type != UNDEF) && (port->dpdk_port < 0)) {
+			ret = add_vhost_pmd(port->iface_no,
+					g_startup_param.vhost_client);
+			if (ret < 0)
+				return SPP_RET_NG;
+			port->dpdk_port = ret;
+		}
+	}
+
+	/* Initialize added ring. */
+	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
+		port = &g_iface_info.ring[cnt];
+		if ((port->iface_type != UNDEF) && (port->dpdk_port < 0)) {
+			ret = add_ring_pmd(port->iface_no);
+			if (ret < 0)
+				return SPP_RET_NG;
+			port->dpdk_port = ret;
+		}
+	}
+	return SPP_RET_OK;
+}
+
+/* Flush changed core. */
+void
+flush_core(void)
+{
+	int cnt = 0;
+	struct core_mng_info *info = NULL;
+
+	/* Changed core has changed index. */
+	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
+		if (g_change_core[cnt] != 0) {
+			info = &g_core_info[cnt];
+			info->upd_index = info->ref_index;
+		}
+	}
+
+	/* Waiting for changed core change. */
+	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
+		if (g_change_core[cnt] != 0) {
+			info = &g_core_info[cnt];
+			while (likely(info->ref_index == info->upd_index))
+				rte_delay_us_block(SPP_CHANGE_UPDATE_INTERVAL);
+
+			memcpy(&info->core[info->upd_index],
+					&info->core[info->ref_index],
+					sizeof(struct core_info));
+		}
+	}
+}
+
+/* Flush change for forwarder or classifier_mac */
+int
+flush_component(void)
+{
+	int ret = 0;
+	int cnt = 0;
+	struct spp_component_info *component_info = NULL;
+
+	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
+		if (g_change_component[cnt] == 0)
+			continue;
+
+		component_info = &g_component_info[cnt];
+		spp_port_ability_update(component_info);
+
+		if (component_info->type == SPP_COMPONENT_CLASSIFIER_MAC)
+			ret = spp_classifier_mac_update(component_info);
+		else
+			ret = spp_forward_update(component_info);
+
+		if (unlikely(ret < 0)) {
+			RTE_LOG(ERR, APP, "Flush error. "
+					"( component = %s, type = %d)\n",
+					component_info->name,
+					component_info->type);
+			return SPP_RET_NG;
+		}
+	}
+	return SPP_RET_OK;
+}
+
+/**
+ * Generate a formatted string of combination from interface type and
+ * number and assign to given 'port'
+ */
+int spp_format_port_string(char *port, enum port_type iface_type, int iface_no)
+{
+	const char *iface_type_str;
+
+	switch (iface_type) {
+	case PHY:
+		iface_type_str = SPP_IFTYPE_NIC_STR;
+		break;
+	case RING:
+		iface_type_str = SPP_IFTYPE_RING_STR;
+		break;
+	case VHOST:
+		iface_type_str = SPP_IFTYPE_VHOST_STR;
+		break;
+	default:
+		return -1;
+	}
+
+	sprintf(port, "%s:%d", iface_type_str, iface_no);
+
+	return 0;
+}
+
+/**
+ * Change mac address of 'aa:bb:cc:dd:ee:ff' to int64 and return it
+ */
+int64_t
+spp_change_mac_str_to_int64(const char *mac)
+{
+	int64_t ret_mac = 0;
+	int64_t token_val = 0;
+	int token_cnt = 0;
+	char tmp_mac[SPP_MIN_STR_LEN];
+	char *str = tmp_mac;
+	char *saveptr = NULL;
+	char *endptr = NULL;
+
+	RTE_LOG(DEBUG, APP, "MAC address change. (mac = %s)\n", mac);
+
+	strcpy(tmp_mac, mac);
+	while (1) {
+		/* Split by colon(':') */
+		char *ret_tok = strtok_r(str, ":", &saveptr);
+		if (unlikely(ret_tok == NULL))
+			break;
+
+		/* Check for mal-formatted address */
+		if (unlikely(token_cnt >= ETHER_ADDR_LEN)) {
+			RTE_LOG(ERR, APP, "MAC address format error. "
+					"(mac = %s)\n", mac);
+			return -1;
+		}
+
+		/* Convert string to hex value */
+		int ret_tol = strtol(ret_tok, &endptr, 16);
+		if (unlikely(ret_tok == endptr) || unlikely(*endptr != '\0'))
+			break;
+
+		/* Append separated value to the result */
+		token_val = (int64_t)ret_tol;
+		ret_mac |= token_val << (token_cnt * 8);
+		token_cnt++;
+		str = NULL;
+	}
+
+	RTE_LOG(DEBUG, APP, "MAC address change. (mac = %s => 0x%08lx)\n",
+			 mac, ret_mac);
+	return ret_mac;
+}
diff --git a/src/vf/common/spp_proc.h b/src/vf/common/spp_proc.h
new file mode 100644
index 0000000..125af52
--- /dev/null
+++ b/src/vf/common/spp_proc.h
@@ -0,0 +1,364 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
+ */
+
+#ifndef _SPP_PROC_H_
+#define _SPP_PROC_H_
+
+/**
+ * @file
+ * SPP process
+ *
+ * SPP component common function.
+ */
+
+#include <netinet/in.h>
+#include "common.h"
+
+/**
+ * Make a hexdump of an array data in every 4 byte.
+ * This function is used to dump core_info or component info.
+ *
+ * @param name
+ *  dump name.
+ * @param addr
+ *  dump address.
+ * @param size
+ *  dump byte size.
+ *
+ */
+void dump_buff(const char *name, const void *addr, const size_t size);
+
+/**
+ * added ring_pmd
+ *
+ * @param ring_id
+ *  added ring id.
+ *
+ * @retval 0~   ring_port_id.
+ * @retval -1   failed.
+ */
+int add_ring_pmd(int ring_id);
+
+/**
+ * added vhost_pmd
+ *
+ * @param index
+ *  add vohst id.
+ * @param client
+ *  add client id.
+ *
+ * @retval 0~   vhost_port_id.
+ * @retval -1   failed.
+ */
+int add_vhost_pmd(int index, int client);
+
+/**
+ * Get core status
+ *
+ * @param lcore_id
+ *  Logical core ID.
+ *
+ * @return
+ *  Status of specified logical core.
+ */
+enum spp_core_status spp_get_core_status(unsigned int lcore_id);
+
+/**
+ * Get component type of target core
+ *
+ * @param lcore_id
+ *  Logical core ID.
+ *
+ * @return
+ *  Type of component executed on specified logical core
+ */
+enum spp_component_type spp_get_component_type(unsigned int lcore_id);
+
+/**
+ * Run check_core_status() for SPP_CORE_STATUS_CHECK_MAX times with
+ * interval time (1sec)
+ *
+ * @param status
+ *  wait check status.
+ *
+ * @retval 0  succeeded.
+ * @retval -1 failed.
+ */
+int check_core_status_wait(enum spp_core_status status);
+
+/**
+ * Set core status
+ *
+ * @param lcore_id
+ *  Logical core ID.
+ * @param status
+ *  set status.
+ *
+ */
+void set_core_status(unsigned int lcore_id, enum spp_core_status status);
+
+/**
+ * Set all core status to given
+ *
+ * @param status
+ *  set status.
+ *
+ */
+void set_all_core_status(enum spp_core_status status);
+
+/**
+ * Set all of component status to SPP_CORE_STOP_REQUEST if received signal
+ * is SIGTERM or SIGINT
+ *
+ * @param signl
+ *  received signal.
+ *
+ */
+void stop_process(int signal);
+
+/**
+ * Return port info of given type and num of interface
+ *
+ * @param iface_type
+ *  Interface type to be validated.
+ * @param iface_no
+ *  Interface number to be validated.
+ *
+ * @retval !NULL  spp_port_info.
+ * @retval NULL   failed.
+ */
+struct spp_port_info *
+get_iface_info(enum port_type iface_type, int iface_no);
+
+/* Dump of core information */
+void dump_core_info(const struct core_mng_info *core_info);
+
+/* Dump of component information */
+void dump_component_info(const struct spp_component_info *component_info);
+
+/* Dump of interface information */
+void dump_interface_info(const struct iface_info *iface_info);
+
+/* Dump of all management information */
+void dump_all_mng_info(
+		const struct core_mng_info *core,
+		const struct spp_component_info *component,
+		const struct iface_info *interface);
+
+/* Copy management information */
+void copy_mng_info(
+		struct core_mng_info *dst_core,
+		struct spp_component_info *dst_component,
+		struct iface_info *dst_interface,
+		const struct core_mng_info *src_core,
+		const struct spp_component_info *src_component,
+		const struct iface_info *src_interface,
+		enum copy_mng_flg flg);
+
+/* Backup the management information */
+void backup_mng_info(struct cancel_backup_info *backup);
+
+/**
+ * Setup management info for spp_vf
+ */
+int init_mng_data(void);
+
+#ifdef SPP_RINGLATENCYSTATS_ENABLE
+/**
+ * Print statistics of time for packet processing in ring interface
+ */
+void print_ring_latency_stats(void);
+#endif /* SPP_RINGLATENCYSTATS_ENABLE */
+
+/* Remove sock file if spp is not running */
+void  del_vhost_sockfile(struct spp_port_info *vhost);
+
+/**
+ * Get component type of target core
+ *
+ * @param lcore_id
+ *  Logical core ID.
+ *
+ * @return
+ *  Type of component executed on specified logical core
+ */
+enum spp_component_type
+spp_get_component_type(unsigned int lcore_id);
+
+/**
+ * Get core ID of target component
+ *
+ * @param component_id
+ *  unique component ID.
+ *
+ * @return
+ *  Logical core id of specified component.
+ */
+unsigned int spp_get_component_core(int component_id);
+
+/* Get core information which is in use */
+struct core_info *get_core_info(unsigned int lcore_id);
+
+/**
+ * Check core index change
+ *
+ * @param lcore_id
+ *  Logical core ID.
+ *
+ *  True if index has changed.
+ * @retval SPP_RET_OK index has changed.
+ * @retval SPP_RET_NG index not changed.
+ */
+int spp_check_core_update(unsigned int lcore_id);
+
+/**
+ * Check if component is using port.
+ *
+ * @param iface_type
+ *  Interface type to be validated.
+ * @param iface_no
+ *  Interface number to be validated.
+ * @param rxtx
+ *  tx/rx type to be validated.
+ *
+ * @retval 0~127      match component ID
+ * @retval SPP_RET_NG failed.
+ */
+int spp_check_used_port(
+		enum port_type iface_type,
+		int iface_no,
+		enum spp_port_rxtx rxtx);
+
+/**
+ * Set component update flag for given port.
+ *
+ * @param port
+ *  spp_port_info address
+ * @param rxtx
+ *  enum spp_port_rxtx
+ *
+ */
+void
+set_component_change_port(struct spp_port_info *port, enum spp_port_rxtx rxtx);
+
+/**
+ * Get unused component id
+ *
+ * @retval 0~127 Component ID.
+ * @retval -1    failed.
+ */
+int get_free_component(void);
+
+/**
+ * Get component id for specified component name
+ *
+ * @param name
+ *  Component name.
+ *
+ * @retval 0~127      Component ID.
+ * @retval SPP_RET_NG failed.
+ */
+int spp_get_component_id(const char *name);
+
+/**
+ *  Delete component information.
+ *
+ * @param component_id
+ *  check data
+ * @param component_num
+ *  array check count
+ * @param componet_array
+ *  check array address
+ *
+ * @retval 0  succeeded.
+ * @retval -1 failed.
+ */
+int
+del_component_info(int component_id, int component_num, int *componet_array);
+
+/**
+ * get port element which matches the condition.
+ *
+ * @param info
+ *  spp_port_info address
+ * @param num
+ *  port count
+ * @param array[]
+ *  spp_port_info array address
+ *
+ * @retval 0~ match index.
+ * @retval -1 failed.
+ */
+int check_port_element(
+		struct spp_port_info *info,
+		int num,
+		struct spp_port_info *array[]);
+
+/**
+ *  search matched port_info from array and delete it.
+ *
+ * @param info
+ *  spp_port_info address
+ * @param num
+ *  port count
+ * @param array[]
+ *  spp_port_info array address
+ *
+ * @retval 0  succeeded.
+ * @retval -1 failed.
+ */
+int get_del_port_element(
+		struct spp_port_info *info,
+		int num,
+		struct spp_port_info *array[]);
+
+/**
+ * Flush initial setting of each interface.
+ *
+ * @retval SPP_RET_OK succeeded.
+ * @retval SPP_RET_NG failed.
+ */
+int flush_port(void);
+
+/**
+ *  Flush changed core.
+ */
+void flush_core(void);
+
+/**
+ *  Flush change for forwarder or classifier_mac.
+ *
+ * @retval SPP_RET_OK succeeded.
+ * @retval SPP_RET_NG failed.
+ */
+int flush_component(void);
+
+/**
+ * Port type to string
+ *
+ * @param port
+ *  Character string of Port type to be converted.
+ * @param iface_type
+ *  port interface type
+ * @param iface_no
+ *  interface no
+ *
+ * @retval 0  succeeded.
+ * @retval -1 failed.
+ */
+int
+spp_format_port_string(char *port, enum port_type iface_type, int iface_no);
+
+/**
+ * Change mac address string to int64
+ *
+ * @param mac
+ *  Character string of MAC address to be converted.
+ *
+ * @retval 0< int64 that store mac address
+ * @retval -1
+ */
+int64_t spp_change_mac_str_to_int64(const char *mac);
+
+#endif /* _SPP_PROC_H_ */
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index 96d331e..accef02 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -146,214 +146,6 @@ usage(const char *progname)
 			, progname);
 }
 
-/* Make a hexdump of an array data in every 4 byte */
-static void
-dump_buff(const char *name, const void *addr, const size_t size)
-{
-	size_t cnt = 0;
-	size_t max = (size / sizeof(unsigned int)) +
-			((size % sizeof(unsigned int)) != 0);
-	const uint32_t *buff = addr;
-
-	if ((name != NULL) && (name[0] != '\0'))
-		RTE_LOG(DEBUG, APP, "dump buff. (%s)\n", name);
-
-	for (cnt = 0; cnt < max; cnt += 16) {
-		RTE_LOG(DEBUG, APP, "[%p]"
-				" %08x %08x %08x %08x %08x %08x %08x %08x"
-				" %08x %08x %08x %08x %08x %08x %08x %08x",
-				&buff[cnt],
-				buff[cnt+0], buff[cnt+1],
-				buff[cnt+2], buff[cnt+3],
-				buff[cnt+4], buff[cnt+5],
-				buff[cnt+6], buff[cnt+7],
-				buff[cnt+8], buff[cnt+9],
-				buff[cnt+10], buff[cnt+11],
-				buff[cnt+12], buff[cnt+13],
-				buff[cnt+14], buff[cnt+15]);
-	}
-}
-
-static int
-add_ring_pmd(int ring_id)
-{
-	struct rte_ring *ring;
-	int ring_port_id;
-
-	/* Lookup ring of given id */
-	ring = rte_ring_lookup(get_rx_queue_name(ring_id));
-	if (unlikely(ring == NULL)) {
-		RTE_LOG(ERR, APP,
-			"Cannot get RX ring - is server process running?\n");
-		return -1;
-	}
-
-	/* Create ring pmd */
-	ring_port_id = rte_eth_from_ring(ring);
-	RTE_LOG(INFO, APP, "ring port add. (no = %d / port = %d)\n",
-			ring_id, ring_port_id);
-	return ring_port_id;
-}
-
-static int
-add_vhost_pmd(int index, int client)
-{
-	struct rte_eth_conf port_conf = {
-		.rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
-	};
-	struct rte_mempool *mp;
-	uint16_t vhost_port_id;
-	int nr_queues = 1;
-	const char *name;
-	char devargs[64];
-	char *iface;
-	uint16_t q;
-	int ret;
-#define NR_DESCS 128
-
-	mp = rte_mempool_lookup(PKTMBUF_POOL_NAME);
-	if (unlikely(mp == NULL)) {
-		RTE_LOG(ERR, APP, "Cannot get mempool for mbufs. "
-				"(name = %s)\n", PKTMBUF_POOL_NAME);
-		return -1;
-	}
-
-	/* eth_vhost0 index 0 iface /tmp/sock0 on numa 0 */
-	name = get_vhost_backend_name(index);
-	iface = get_vhost_iface_name(index);
-
-	sprintf(devargs, "%s,iface=%s,queues=%d,client=%d",
-			name, iface, nr_queues, client);
-	ret = dev_attach_by_devargs(devargs, &vhost_port_id);
-	if (unlikely(ret < 0)) {
-		RTE_LOG(ERR, APP, "dev_attach_by_devargs error. (ret = %d)\n",
-				ret);
-		return ret;
-	}
-
-	ret = rte_eth_dev_configure(vhost_port_id, nr_queues, nr_queues,
-		&port_conf);
-	if (unlikely(ret < 0)) {
-		RTE_LOG(ERR, APP, "rte_eth_dev_configure error. "
-				"(ret = %d)\n", ret);
-		return ret;
-	}
-
-	/* Allocate and set up 1 RX queue per Ethernet port. */
-	for (q = 0; q < nr_queues; q++) {
-		ret = rte_eth_rx_queue_setup(vhost_port_id, q, NR_DESCS,
-			rte_eth_dev_socket_id(vhost_port_id), NULL, mp);
-		if (unlikely(ret < 0)) {
-			RTE_LOG(ERR, APP,
-				"rte_eth_rx_queue_setup error. (ret = %d)\n",
-				ret);
-			return ret;
-		}
-	}
-
-	/* Allocate and set up 1 TX queue per Ethernet port. */
-	for (q = 0; q < nr_queues; q++) {
-		ret = rte_eth_tx_queue_setup(vhost_port_id, q, NR_DESCS,
-			rte_eth_dev_socket_id(vhost_port_id), NULL);
-		if (unlikely(ret < 0)) {
-			RTE_LOG(ERR, APP,
-				"rte_eth_tx_queue_setup error. (ret = %d)\n",
-				ret);
-			return ret;
-		}
-	}
-
-	/* Start the Ethernet port. */
-	ret = rte_eth_dev_start(vhost_port_id);
-	if (unlikely(ret < 0)) {
-		RTE_LOG(ERR, APP, "rte_eth_dev_start error. (ret = %d)\n",
-				ret);
-		return ret;
-	}
-
-	RTE_LOG(INFO, APP, "vhost port add. (no = %d / port = %d)\n",
-			index, vhost_port_id);
-	return vhost_port_id;
-}
-
-/* Get core status */
-enum spp_core_status
-spp_get_core_status(unsigned int lcore_id)
-{
-	return g_core_info[lcore_id].status;
-}
-
-/**
- * Check status of all of cores is same as given
- *
- * It returns -1 as status mismatch if status is not same.
- * If core is in use, status will be checked.
- */
-static int
-check_core_status(enum spp_core_status status)
-{
-	unsigned int lcore_id = 0;
-	RTE_LCORE_FOREACH_SLAVE(lcore_id) {
-		if (g_core_info[lcore_id].status != status) {
-			/* Status is mismatched */
-			return -1;
-		}
-	}
-	return 0;
-}
-
-/**
- * Run check_core_status() for SPP_CORE_STATUS_CHECK_MAX times with
- * interval time (1sec)
- */
-static int
-check_core_status_wait(enum spp_core_status status)
-{
-	int cnt = 0;
-	for (cnt = 0; cnt < SPP_CORE_STATUS_CHECK_MAX; cnt++) {
-		sleep(1);
-		int ret = check_core_status(status);
-		if (ret == 0)
-			return 0;
-	}
-
-	RTE_LOG(ERR, APP, "Status check time out. (status = %d)\n", status);
-	return -1;
-}
-
-/* Set core status */
-static void
-set_core_status(unsigned int lcore_id,
-		enum spp_core_status status)
-{
-	g_core_info[lcore_id].status = status;
-}
-
-/* Set all core to given status */
-static void
-set_all_core_status(enum spp_core_status status)
-{
-	unsigned int lcore_id = 0;
-	RTE_LCORE_FOREACH_SLAVE(lcore_id) {
-		g_core_info[lcore_id].status = status;
-	}
-}
-
-/**
- * Set all of component status to SPP_CORE_STOP_REQUEST if received signal
- * is SIGTERM or SIGINT
- */
-static void
-stop_process(int signal) {
-	if (unlikely(signal != SIGTERM) &&
-			unlikely(signal != SIGINT)) {
-		return;
-	}
-
-	g_core_info[g_main_lcore_id].status = SPP_CORE_STOP_REQUEST;
-	set_all_core_status(SPP_CORE_STOP_REQUEST);
-}
-
 /**
  * Convert string of given client id to integer
  *
@@ -479,367 +271,6 @@ parse_app_args(int argc, char *argv[])
 	return 0;
 }
 
-/**
- * Return port info of given type and num of interface
- *
- * It returns NULL value if given type is invalid.
- */
-static struct spp_port_info *
-get_iface_info(enum port_type iface_type, int iface_no)
-{
-	switch (iface_type) {
-	case PHY:
-		return &g_iface_info.nic[iface_no];
-	case VHOST:
-		return &g_iface_info.vhost[iface_no];
-	case RING:
-		return &g_iface_info.ring[iface_no];
-	default:
-		return NULL;
-	}
-}
-
-/* Dump of core information */
-static void
-dump_core_info(const struct core_mng_info *core_info)
-{
-	char str[SPP_NAME_STR_LEN];
-	const struct core_mng_info *info = NULL;
-	unsigned int lcore_id = 0;
-	RTE_LCORE_FOREACH_SLAVE(lcore_id) {
-		info = &core_info[lcore_id];
-		RTE_LOG(DEBUG, APP, "core[%d] status=%d, ref=%d, upd=%d\n",
-				lcore_id, info->status,
-				info->ref_index, info->upd_index);
-
-		sprintf(str, "core[%d]-0 type=%d, num=%d", lcore_id,
-				info->core[0].type, info->core[0].num);
-		dump_buff(str, info->core[0].id,
-				sizeof(int)*info->core[0].num);
-
-		sprintf(str, "core[%d]-1 type=%d, num=%d", lcore_id,
-				info->core[1].type, info->core[1].num);
-		dump_buff(str, info->core[1].id,
-				sizeof(int)*info->core[1].num);
-	}
-}
-
-/* Dump of component information */
-static void
-dump_component_info(const struct spp_component_info *component_info)
-{
-	char str[SPP_NAME_STR_LEN];
-	const struct spp_component_info *component = NULL;
-	int cnt = 0;
-	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		component = &component_info[cnt];
-		if (component->type == SPP_COMPONENT_UNUSE)
-			continue;
-
-		RTE_LOG(DEBUG, APP, "component[%d] name=%s, type=%d, "
-				"core=%u, index=%d\n",
-				cnt, component->name, component->type,
-				component->lcore_id, component->component_id);
-
-		sprintf(str, "component[%d] rx=%d", cnt,
-				component->num_rx_port);
-		dump_buff(str, component->rx_ports,
-			sizeof(struct spp_port_info *)*component->num_rx_port);
-
-		sprintf(str, "component[%d] tx=%d", cnt,
-				component->num_tx_port);
-		dump_buff(str, component->tx_ports,
-			sizeof(struct spp_port_info *)*component->num_tx_port);
-	}
-}
-
-/* Dump of interface information */
-static void
-dump_interface_info(const struct iface_info *iface_info)
-{
-	const struct spp_port_info *port = NULL;
-	int cnt = 0;
-	RTE_LOG(DEBUG, APP, "interface phy=%d, vhost=%d, ring=%d\n",
-			iface_info->num_nic,
-			iface_info->num_vhost,
-			iface_info->num_ring);
-	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
-		port = &iface_info->nic[cnt];
-		if (port->iface_type == UNDEF)
-			continue;
-
-		RTE_LOG(DEBUG, APP, "phy  [%d] type=%d, no=%d, port=%d, "
-				"vid = %u, mac=%08lx(%s)\n",
-				cnt, port->iface_type, port->iface_no,
-				port->dpdk_port,
-				port->class_id.vlantag.vid,
-				port->class_id.mac_addr,
-				port->class_id.mac_addr_str);
-	}
-	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
-		port = &iface_info->vhost[cnt];
-		if (port->iface_type == UNDEF)
-			continue;
-
-		RTE_LOG(DEBUG, APP, "vhost[%d] type=%d, no=%d, port=%d, "
-				"vid = %u, mac=%08lx(%s)\n",
-				cnt, port->iface_type, port->iface_no,
-				port->dpdk_port,
-				port->class_id.vlantag.vid,
-				port->class_id.mac_addr,
-				port->class_id.mac_addr_str);
-	}
-	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
-		port = &iface_info->ring[cnt];
-		if (port->iface_type == UNDEF)
-			continue;
-
-		RTE_LOG(DEBUG, APP, "ring [%d] type=%d, no=%d, port=%d, "
-				"vid = %u, mac=%08lx(%s)\n",
-				cnt, port->iface_type, port->iface_no,
-				port->dpdk_port,
-				port->class_id.vlantag.vid,
-				port->class_id.mac_addr,
-				port->class_id.mac_addr_str);
-	}
-}
-
-/* Dump of all management information */
-static void
-dump_all_mng_info(
-		const struct core_mng_info *core,
-		const struct spp_component_info *component,
-		const struct iface_info *interface)
-{
-	if (rte_log_get_global_level() < RTE_LOG_DEBUG)
-		return;
-
-	dump_core_info(core);
-	dump_component_info(component);
-	dump_interface_info(interface);
-}
-
-/* Copy management information */
-static void
-copy_mng_info(
-		struct core_mng_info *dst_core,
-		struct spp_component_info *dst_component,
-		struct iface_info *dst_interface,
-		const struct core_mng_info *src_core,
-		const struct spp_component_info *src_component,
-		const struct iface_info *src_interface,
-		enum copy_mng_flg flg)
-{
-	int upd_index = 0;
-	unsigned int lcore_id = 0;
-
-	switch (flg) {
-	case COPY_MNG_FLG_UPDCOPY:
-		RTE_LCORE_FOREACH_SLAVE(lcore_id) {
-			upd_index = src_core[lcore_id].upd_index;
-			memcpy(&dst_core[lcore_id].core[upd_index],
-					&src_core[lcore_id].core[upd_index],
-					sizeof(struct core_info));
-		}
-		break;
-	default:
-		/*
-		 * Even if the flag is set to None,
-		 * copying of core is necessary,
-		 * so we will treat all copies as default.
-		 */
-		memcpy(dst_core, src_core,
-				sizeof(struct core_mng_info)*RTE_MAX_LCORE);
-		break;
-	}
-
-	memcpy(dst_component, src_component,
-			sizeof(struct spp_component_info)*RTE_MAX_LCORE);
-	memcpy(dst_interface, src_interface,
-			sizeof(struct iface_info));
-}
-
-/* Backup the management information */
-static void
-backup_mng_info(struct cancel_backup_info *backup)
-{
-	dump_all_mng_info(g_core_info, g_component_info, &g_iface_info);
-	copy_mng_info(backup->core, backup->component, &backup->interface,
-			g_core_info, g_component_info, &g_iface_info,
-			COPY_MNG_FLG_ALLCOPY);
-	dump_all_mng_info(backup->core, backup->component, &backup->interface);
-	memset(g_change_core, 0x00, sizeof(g_change_core));
-	memset(g_change_component, 0x00, sizeof(g_change_component));
-}
-
-/**
- * Initialize g_iface_info
- *
- * Clear g_iface_info and set initial value.
- */
-static void
-init_iface_info(void)
-{
-	int port_cnt;  /* increment ether ports */
-	memset(&g_iface_info, 0x00, sizeof(g_iface_info));
-	for (port_cnt = 0; port_cnt < RTE_MAX_ETHPORTS; port_cnt++) {
-		g_iface_info.nic[port_cnt].iface_type = UNDEF;
-		g_iface_info.nic[port_cnt].iface_no   = port_cnt;
-		g_iface_info.nic[port_cnt].dpdk_port  = -1;
-		g_iface_info.nic[port_cnt].class_id.vlantag.vid =
-				ETH_VLAN_ID_MAX;
-		g_iface_info.vhost[port_cnt].iface_type = UNDEF;
-		g_iface_info.vhost[port_cnt].iface_no   = port_cnt;
-		g_iface_info.vhost[port_cnt].dpdk_port  = -1;
-		g_iface_info.vhost[port_cnt].class_id.vlantag.vid =
-				ETH_VLAN_ID_MAX;
-		g_iface_info.ring[port_cnt].iface_type = UNDEF;
-		g_iface_info.ring[port_cnt].iface_no   = port_cnt;
-		g_iface_info.ring[port_cnt].dpdk_port  = -1;
-		g_iface_info.ring[port_cnt].class_id.vlantag.vid =
-				ETH_VLAN_ID_MAX;
-	}
-}
-
-/**
- * Initialize g_component_info
- */
-static void
-init_component_info(void)
-{
-	int cnt;
-	memset(&g_component_info, 0x00, sizeof(g_component_info));
-	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++)
-		g_component_info[cnt].component_id = cnt;
-	memset(g_change_component, 0x00, sizeof(g_change_component));
-}
-
-/**
- * Initialize g_core_info
- */
-static void
-init_core_info(void)
-{
-	int cnt = 0;
-	memset(&g_core_info, 0x00, sizeof(g_core_info));
-	set_all_core_status(SPP_CORE_STOP);
-	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		g_core_info[cnt].ref_index = 0;
-		g_core_info[cnt].upd_index = 1;
-	}
-	memset(g_change_core, 0x00, sizeof(g_change_core));
-}
-
-/**
- * Setup port info of port on host
- */
-static int
-set_nic_interface(void)
-{
-	int nic_cnt = 0;
-
-	/* NIC Setting */
-	g_iface_info.num_nic = rte_eth_dev_count_avail();
-	if (g_iface_info.num_nic > RTE_MAX_ETHPORTS)
-		g_iface_info.num_nic = RTE_MAX_ETHPORTS;
-
-	for (nic_cnt = 0; nic_cnt < g_iface_info.num_nic; nic_cnt++) {
-		g_iface_info.nic[nic_cnt].iface_type   = PHY;
-		g_iface_info.nic[nic_cnt].dpdk_port = nic_cnt;
-	}
-
-	return 0;
-}
-
-/**
- * Setup management info for spp_vf
- */
-static int
-init_mng_data(void)
-{
-	/* Initialize interface and core information */
-	init_iface_info();
-	init_core_info();
-	init_component_info();
-
-	int ret_nic = set_nic_interface();
-	if (unlikely(ret_nic != 0))
-		return -1;
-
-	return 0;
-}
-
-#ifdef SPP_RINGLATENCYSTATS_ENABLE
-/**
- * Print statistics of time for packet processing in ring interface
- */
-static void
-print_ring_latency_stats(void)
-{
-	/* Clear screen and move cursor to top left */
-	const char topLeft[] = { 27, '[', '1', ';', '1', 'H', '\0' };
-	const char clr[] = { 27, '[', '2', 'J', '\0' };
-	printf("%s%s", clr, topLeft);
-
-	int ring_cnt, stats_cnt;
-	struct spp_ringlatencystats_ring_latency_stats stats[RTE_MAX_ETHPORTS];
-	memset(&stats, 0x00, sizeof(stats));
-
-	printf("RING Latency\n");
-	printf(" RING");
-	for (ring_cnt = 0; ring_cnt < RTE_MAX_ETHPORTS; ring_cnt++) {
-		if (g_iface_info.ring[ring_cnt].iface_type == UNDEF)
-			continue;
-
-		spp_ringlatencystats_get_stats(ring_cnt, &stats[ring_cnt]);
-		printf(", %-18d", ring_cnt);
-	}
-	printf("\n");
-
-	for (stats_cnt = 0; stats_cnt < SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT;
-			stats_cnt++) {
-		printf("%3dns", stats_cnt);
-		for (ring_cnt = 0; ring_cnt < RTE_MAX_ETHPORTS; ring_cnt++) {
-			if (g_iface_info.ring[ring_cnt].iface_type == UNDEF)
-				continue;
-
-			printf(", 0x%-16lx", stats[ring_cnt].slot[stats_cnt]);
-		}
-		printf("\n");
-	}
-}
-#endif /* SPP_RINGLATENCYSTATS_ENABLE */
-
-/**
- * Remove sock file
- */
-static void
-del_vhost_sockfile(struct spp_port_info *vhost)
-{
-	int cnt;
-
-	/* Do not remove for if it is running in vhost-client mode. */
-	if (g_startup_param.vhost_client != 0)
-		return;
-
-	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
-		if (likely(vhost[cnt].iface_type == UNDEF)) {
-			/* Skip removing if it is not using vhost */
-			continue;
-		}
-
-		remove(get_vhost_iface_name(cnt));
-	}
-}
-
-/* Get component type of target core */
-enum spp_component_type
-spp_get_component_type(unsigned int lcore_id)
-{
-	struct core_mng_info *info = &g_core_info[lcore_id];
-	return info->core[info->ref_index].type;
-}
-
 /* Get component type being updated on target core */
 enum spp_component_type
 spp_get_component_type_update(unsigned int lcore_id)
@@ -848,29 +279,6 @@ spp_get_component_type_update(unsigned int lcore_id)
 	return info->core[info->upd_index].type;
 }
 
-/* Get core ID of target component */
-unsigned int
-spp_get_component_core(int component_id)
-{
-	struct spp_component_info *info = &g_component_info[component_id];
-	return info->lcore_id;
-}
-
-/* Get usage area of target core */
-static struct core_info *
-get_core_info(unsigned int lcore_id)
-{
-	struct core_mng_info *info = &g_core_info[lcore_id];
-	return &(info->core[info->ref_index]);
-}
-
-/* Check core index change */
-int
-spp_check_core_index(unsigned int lcore_id)
-{
-	struct core_mng_info *info = &g_core_info[lcore_id];
-	return info->ref_index == info->upd_index;
-}
 
 /* Main process of slave core */
 static int
@@ -891,7 +299,7 @@ slave_main(void *arg __attribute__ ((unused)))
 		if (status != SPP_CORE_FORWARD)
 			continue;
 
-		if (spp_check_core_index(lcore_id)) {
+		if (spp_check_core_update(lcore_id) == SPP_RET_OK) {
 			/* Setting with the flush command trigger. */
 			info->ref_index = (info->upd_index+1) %
 					SPP_INFO_AREA_MAX;
@@ -1102,66 +510,6 @@ spp_check_flush_port(enum port_type iface_type, int iface_no)
 	return port->dpdk_port >= 0;
 }
 
-/*
- * Check if component is using port.
- */
-int
-spp_check_used_port(
-		enum port_type iface_type,
-		int iface_no,
-		enum spp_port_rxtx rxtx)
-{
-	int cnt, port_cnt, max = 0;
-	struct spp_component_info *component = NULL;
-	struct spp_port_info **port_array = NULL;
-	struct spp_port_info *port = get_iface_info(iface_type, iface_no);
-
-	if (port == NULL)
-		return SPP_RET_NG;
-
-	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		component = &g_component_info[cnt];
-		if (component->type == SPP_COMPONENT_UNUSE)
-			continue;
-
-		if (rxtx == SPP_PORT_RXTX_RX) {
-			max = component->num_rx_port;
-			port_array = component->rx_ports;
-		} else if (rxtx == SPP_PORT_RXTX_TX) {
-			max = component->num_tx_port;
-			port_array = component->tx_ports;
-		}
-		for (port_cnt = 0; port_cnt < max; port_cnt++) {
-			if (unlikely(port_array[port_cnt] == port))
-				return cnt;
-		}
-	}
-
-	return SPP_RET_NG;
-}
-
-/*
- * Set port change to component.
- */
-static void
-set_component_change_port(struct spp_port_info *port, enum spp_port_rxtx rxtx)
-{
-	int ret = 0;
-	if ((rxtx == SPP_PORT_RXTX_RX) || (rxtx == SPP_PORT_RXTX_ALL)) {
-		ret = spp_check_used_port(port->iface_type, port->iface_no,
-				SPP_PORT_RXTX_RX);
-		if (ret >= 0)
-			g_change_component[ret] = 1;
-	}
-
-	if ((rxtx == SPP_PORT_RXTX_TX) || (rxtx == SPP_PORT_RXTX_ALL)) {
-		ret = spp_check_used_port(port->iface_type, port->iface_no,
-				SPP_PORT_RXTX_TX);
-		if (ret >= 0)
-			g_change_component[ret] = 1;
-	}
-}
-
 int
 spp_update_classifier_table(
 		enum spp_command_action action,
@@ -1247,59 +595,6 @@ spp_update_classifier_table(
 	return SPP_RET_OK;
 }
 
-/* Get free component */
-static int
-get_free_component(void)
-{
-	int cnt = 0;
-	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		if (g_component_info[cnt].type == SPP_COMPONENT_UNUSE)
-			return cnt;
-	}
-	return -1;
-}
-
-/* Get name matching component */
-int
-spp_get_component_id(const char *name)
-{
-	int cnt = 0;
-	if (name[0] == '\0')
-		return SPP_RET_NG;
-
-	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		if (strcmp(name, g_component_info[cnt].name) == 0)
-			return cnt;
-	}
-	return SPP_RET_NG;
-}
-
-static int
-get_del_core_element(int info, int num, int *array)
-{
-	int cnt;
-	int match = -1;
-	int max = num;
-
-	for (cnt = 0; cnt < max; cnt++) {
-		if (info == array[cnt])
-			match = cnt;
-	}
-
-	if (match < 0)
-		return -1;
-
-	/* Last element is excluded from movement. */
-	max--;
-
-	for (cnt = match; cnt < max; cnt++)
-		array[cnt] = array[cnt+1];
-
-	/* Last element is cleared. */
-	array[cnt] = 0;
-	return 0;
-}
-
 /* Component command to execute it */
 int
 spp_update_component(
@@ -1369,7 +664,7 @@ spp_update_component(
 
 		info = &g_core_info[tmp_lcore_id];
 		core = &info->core[info->upd_index];
-		ret_del = get_del_core_element(component_id,
+		ret_del = del_component_info(component_id,
 				core->num, core->id);
 		if (ret_del >= 0)
 			/* If deleted, decrement number. */
@@ -1390,46 +685,6 @@ spp_update_component(
 	return ret;
 }
 
-static int
-check_port_element(
-		struct spp_port_info *info,
-		int num,
-		struct spp_port_info *array[])
-{
-	int cnt = 0;
-	int match = -1;
-	for (cnt = 0; cnt < num; cnt++) {
-		if (info == array[cnt])
-			match = cnt;
-	}
-	return match;
-}
-
-static int
-get_del_port_element(
-		struct spp_port_info *info,
-		int num,
-		struct spp_port_info *array[])
-{
-	int cnt = 0;
-	int match = -1;
-	int max = num;
-
-	match = check_port_element(info, num, array);
-	if (match < 0)
-		return -1;
-
-	/* Last element is excluded from movement. */
-	max--;
-
-	for (cnt = match; cnt < max; cnt++)
-		array[cnt] = array[cnt+1];
-
-	/* Last element is cleared. */
-	array[cnt] = NULL;
-	return 0;
-}
-
 /* Port add or del to execute it */
 int
 spp_update_port(enum spp_command_action action,
@@ -1523,99 +778,6 @@ spp_update_port(enum spp_command_action action,
 	return ret;
 }
 
-/* Flush initial setting of each interface. */
-static int
-flush_port(void)
-{
-	int ret = 0;
-	int cnt = 0;
-	struct spp_port_info *port = NULL;
-
-	/* Initialize added vhost. */
-	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
-		port = &g_iface_info.vhost[cnt];
-		if ((port->iface_type != UNDEF) && (port->dpdk_port < 0)) {
-			ret = add_vhost_pmd(port->iface_no,
-					g_startup_param.vhost_client);
-			if (ret < 0)
-				return SPP_RET_NG;
-			port->dpdk_port = ret;
-		}
-	}
-
-	/* Initialize added ring. */
-	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
-		port = &g_iface_info.ring[cnt];
-		if ((port->iface_type != UNDEF) && (port->dpdk_port < 0)) {
-			ret = add_ring_pmd(port->iface_no);
-			if (ret < 0)
-				return SPP_RET_NG;
-			port->dpdk_port = ret;
-		}
-	}
-	return SPP_RET_OK;
-}
-
-/* Flush changed core. */
-static void
-flush_core(void)
-{
-	int cnt = 0;
-	struct core_mng_info *info = NULL;
-
-	/* Changed core has changed index. */
-	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		if (g_change_core[cnt] != 0) {
-			info = &g_core_info[cnt];
-			info->upd_index = info->ref_index;
-		}
-	}
-
-	/* Waiting for changed core change. */
-	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		if (g_change_core[cnt] != 0) {
-			info = &g_core_info[cnt];
-			while (likely(info->ref_index == info->upd_index))
-				rte_delay_us_block(SPP_CHANGE_UPDATE_INTERVAL);
-
-			memcpy(&info->core[info->upd_index],
-					&info->core[info->ref_index],
-					sizeof(struct core_info));
-		}
-	}
-}
-
-/* Flush changed component */
-static int
-flush_component(void)
-{
-	int ret = 0;
-	int cnt = 0;
-	struct spp_component_info *component_info = NULL;
-
-	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		if (g_change_component[cnt] == 0)
-			continue;
-
-		component_info = &g_component_info[cnt];
-		spp_port_ability_update(component_info);
-
-		if (component_info->type == SPP_COMPONENT_CLASSIFIER_MAC)
-			ret = spp_classifier_mac_update(component_info);
-		else
-			ret = spp_forward_update(component_info);
-
-		if (unlikely(ret < 0)) {
-			RTE_LOG(ERR, APP, "Flush error. "
-					"( component = %s, type = %d)\n",
-					component_info->name,
-					component_info->type);
-			return SPP_RET_NG;
-		}
-	}
-	return SPP_RET_OK;
-}
-
 /* Flush command to execute it */
 int
 spp_flush(void)
@@ -1776,80 +938,6 @@ spp_get_iface_index(const char *port,
 	return 0;
 }
 
-/**
- * Generate a formatted string of combination from interface type and
- * number and assign to given 'port'
- */
-int spp_format_port_string(char *port, enum port_type iface_type, int iface_no)
-{
-	const char *iface_type_str;
-
-	switch (iface_type) {
-	case PHY:
-		iface_type_str = SPP_IFTYPE_NIC_STR;
-		break;
-	case RING:
-		iface_type_str = SPP_IFTYPE_RING_STR;
-		break;
-	case VHOST:
-		iface_type_str = SPP_IFTYPE_VHOST_STR;
-		break;
-	default:
-		return -1;
-	}
-
-	sprintf(port, "%s:%d", iface_type_str, iface_no);
-
-	return 0;
-}
-
-/**
- * Change mac address of 'aa:bb:cc:dd:ee:ff' to int64 and return it
- */
-int64_t
-spp_change_mac_str_to_int64(const char *mac)
-{
-	int64_t ret_mac = 0;
-	int64_t token_val = 0;
-	int token_cnt = 0;
-	char tmp_mac[SPP_MIN_STR_LEN];
-	char *str = tmp_mac;
-	char *saveptr = NULL;
-	char *endptr = NULL;
-
-	RTE_LOG(DEBUG, APP, "MAC address change. (mac = %s)\n", mac);
-
-	strcpy(tmp_mac, mac);
-	while (1) {
-		/* Split by colon(':') */
-		char *ret_tok = strtok_r(str, ":", &saveptr);
-		if (unlikely(ret_tok == NULL))
-			break;
-
-		/* Check for mal-formatted address */
-		if (unlikely(token_cnt >= ETHER_ADDR_LEN)) {
-			RTE_LOG(ERR, APP, "MAC address format error. "
-					"(mac = %s)\n", mac);
-			return -1;
-		}
-
-		/* Convert string to hex value */
-		int ret_tol = strtol(ret_tok, &endptr, 16);
-		if (unlikely(ret_tok == endptr) || unlikely(*endptr != '\0'))
-			break;
-
-		/* Append separated value to the result */
-		token_val = (int64_t)ret_tol;
-		ret_mac |= token_val << (token_cnt * 8);
-		token_cnt++;
-		str = NULL;
-	}
-
-	RTE_LOG(DEBUG, APP, "MAC address change. (mac = %s => 0x%08lx)\n",
-			 mac, ret_mac);
-	return ret_mac;
-}
-
 /**
  * Return the type of forwarder as a member of enum of spp_component_type
  */
diff --git a/src/vf/spp_vf.h b/src/vf/spp_vf.h
index 8bc5961..5586207 100644
--- a/src/vf/spp_vf.h
+++ b/src/vf/spp_vf.h
@@ -327,28 +327,6 @@ struct spp_iterate_classifier_table_params {
 int spp_iterate_classifier_table(
 		struct spp_iterate_classifier_table_params *params);
 
-/**
- * Get core status
- *
- * @param lcore_id
- *  Logical core ID.
- *
- * @return
- *  Status of specified logical core.
- */
-enum spp_core_status spp_get_core_status(unsigned int lcore_id);
-
-/**
- * Get component type of target core
- *
- * @param lcore_id
- *  Logical core ID.
- *
- * @return
- *  Type of component executed on specified logical core
- */
-enum spp_component_type spp_get_component_type(unsigned int lcore_id);
-
 /**
  * Get component type being updated on target core
  *
@@ -361,39 +339,6 @@ enum spp_component_type spp_get_component_type(unsigned int lcore_id);
  */
 enum spp_component_type spp_get_component_type_update(unsigned int lcore_id);
 
-/**
- * Get core ID of target component
- *
- * @param component_id
- *  unique component ID.
- *
- * @return
- *  Logical core id of specified component.
- */
-unsigned int spp_get_component_core(int component_id);
-
-/**
- * Check core index change
- *
- * @param lcore_id
- *  Logical core ID.
- *
- * @return
- *  True if index has changed.
- */
-int spp_check_core_index(unsigned int lcore_id);
-
-/**
- * Get name matching component ID
- *
- * @param name
- *  Component name.
- *
- * @retval 0~127      Component ID.
- * @retval SPP_RET_NG failed.
- */
-int spp_get_component_id(const char *name);
-
 /**
  * Check mac address used on the port for registering or removing
  *
@@ -440,35 +385,6 @@ int spp_check_added_port(enum port_type iface_type, int iface_no);
  */
 int spp_check_flush_port(enum port_type iface_type, int iface_no);
 
-/**
- * Check if component is using port.
- *
- * @param iface_type
- *  Interface type to be validated.
- * @param iface_no
- *  Interface number to be validated.
- * @param rxtx
- *  tx/rx type to be validated.
- *
- * @retval 0~127      match component ID
- * @retval SPP_RET_NG failed.
- */
-int spp_check_used_port(
-		enum port_type iface_type,
-		int iface_no,
-		enum spp_port_rxtx rxtx);
-
-/**
- * Change mac address string to int64
- *
- * @param mac
- *  Character string of MAC address to be converted.
- *
- * @retval 0< int64 that store mac address
- * @retval -1
- */
-int64_t spp_change_mac_str_to_int64(const char *mac);
-
 /**
  * Get the port number of DPDK.
  *
@@ -500,22 +416,6 @@ int spp_get_iface_index(
 		enum port_type *iface_type,
 		int *iface_no);
 
-/**
- * Format port string form if-type/if-number
- *
- * @param port
- *  Character string expressing the port, e.g. "phy:0","ring:1"
- * @param iface_type
- *  Interface type.
- * @param iface_no
- *  Interface number.
- *
- * @retval 0  succeeded.
- * @retval -1 failed.
- */
-int
-spp_format_port_string(char *port, enum port_type iface_type, int iface_no);
-
 /**
  * Change component type from string to type value.
  *
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 06/23] spp_vf: move defines to common dir
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (4 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 05/23] spp_vf: move functions to common directory x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 07/23] spp_vf: move functions for decode " x-fn-spp
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Move defines of consts, enums and structs of spp_vf and spp_mirror
common directory.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/spp_proc.h | 309 ++++++++++++++++++++++++++++++++++++++-
 src/vf/spp_vf.c          |  88 -----------
 src/vf/spp_vf.h          | 196 -------------------------
 3 files changed, 307 insertions(+), 286 deletions(-)

diff --git a/src/vf/common/spp_proc.h b/src/vf/common/spp_proc.h
index 125af52..f90b2ac 100644
--- a/src/vf/common/spp_proc.h
+++ b/src/vf/common/spp_proc.h
@@ -16,8 +16,313 @@
 #include "common.h"
 
 /**
- * Make a hexdump of an array data in every 4 byte.
- * This function is used to dump core_info or component info.
+ * TODO(Yamashita) change type names.
+ *  "merge" -> "merger", "forward" -> "forwarder".
+ */
+/** Identifier string for each component (status command) */
+#define SPP_TYPE_CLASSIFIER_MAC_STR "classifier_mac"
+#define SPP_TYPE_MERGE_STR          "merge"
+#define SPP_TYPE_FORWARD_STR        "forward"
+#define SPP_TYPE_UNUSE_STR          "unuse"
+
+/** Identifier string for each interface */
+#define SPP_IFTYPE_NIC_STR   "phy"
+#define SPP_IFTYPE_VHOST_STR "vhost"
+#define SPP_IFTYPE_RING_STR  "ring"
+
+/** Update wait timer (micro sec) */
+#define SPP_CHANGE_UPDATE_INTERVAL 10
+
+/** The max number of buffer for management */
+#define SPP_INFO_AREA_MAX 2
+
+/** The length of shortest character string */
+#define SPP_MIN_STR_LEN   32
+
+/** The length of NAME string */
+#define SPP_NAME_STR_LEN  128
+
+/** Maximum number of port abilities available */
+#define SPP_PORT_ABILITY_MAX 4
+
+/** Number of VLAN ID */
+#define SPP_NUM_VLAN_VID 4096
+
+/** Maximum VLAN PCP */
+#define SPP_VLAN_PCP_MAX 7
+
+/* Max number of core status check */
+#define SPP_CORE_STATUS_CHECK_MAX 5
+
+/** Character sting for default port of classifier */
+#define SPP_DEFAULT_CLASSIFIED_SPEC_STR     "default"
+
+/** Value for default MAC address of classifier */
+#define SPP_DEFAULT_CLASSIFIED_DMY_ADDR     0x010000000000
+
+/** Character sting for default MAC address of classifier */
+#define SPP_DEFAULT_CLASSIFIED_DMY_ADDR_STR "00:00:00:00:00:01"
+
+/* Sampling interval timer for latency evaluation */
+#define SPP_RING_LATENCY_STATS_SAMPLING_INTERVAL 1000000
+
+/**
+ * TODO(Yamashita) change type names.
+ *  "merge" -> "merger", "forward" -> "forwarder".
+ */
+/* Name string for each component */
+#define CORE_TYPE_CLASSIFIER_MAC_STR "classifier_mac"
+#define CORE_TYPE_MERGE_STR          "merge"
+#define CORE_TYPE_FORWARD_STR        "forward"
+
+/* State on component */
+enum spp_core_status {
+	SPP_CORE_UNUSE,        /**< Not used */
+	SPP_CORE_STOP,         /**< Stopped */
+	SPP_CORE_IDLE,         /**< Idling */
+	SPP_CORE_FORWARD,      /**< Forwarding  */
+	SPP_CORE_STOP_REQUEST, /**< Request stopping */
+	SPP_CORE_IDLE_REQUEST /**< Request idling */
+};
+
+/* Process type for each component */
+enum spp_component_type {
+	SPP_COMPONENT_UNUSE,          /**< Not used */
+	SPP_COMPONENT_CLASSIFIER_MAC, /**< Classifier_mac */
+	SPP_COMPONENT_MERGE,          /**< Merger */
+	SPP_COMPONENT_FORWARD,        /**< Forwarder */
+};
+
+/* Classifier Type */
+enum spp_classifier_type {
+	SPP_CLASSIFIER_TYPE_NONE, /**< Type none */
+	SPP_CLASSIFIER_TYPE_MAC,  /**< MAC address */
+	SPP_CLASSIFIER_TYPE_VLAN  /**< VLAN ID */
+};
+
+enum spp_return_value {
+	SPP_RET_OK = 0,  /**< succeeded */
+	SPP_RET_NG = -1, /**< failed */
+};
+
+/**
+ * Port type (rx or tx) to indicate which direction packet goes
+ * (e.g. receiving or transmitting)
+ */
+enum spp_port_rxtx {
+	SPP_PORT_RXTX_NONE, /**< none */
+	SPP_PORT_RXTX_RX,   /**< rx port */
+	SPP_PORT_RXTX_TX,   /**< tx port */
+	SPP_PORT_RXTX_ALL,  /**< rx/tx port */
+};
+
+/**
+ * Port ability operation which indicates vlan tag operation on the port
+ * (e.g. add vlan tag or delete vlan tag)
+ */
+enum spp_port_ability_ope {
+	SPP_PORT_ABILITY_OPE_NONE,	  /**< none */
+	SPP_PORT_ABILITY_OPE_ADD_VLANTAG, /**< add VLAN tag */
+	SPP_PORT_ABILITY_OPE_DEL_VLANTAG, /**< delete VLAN tag */
+};
+
+/* getopt_long return value for long option */
+enum SPP_LONGOPT_RETVAL {
+	SPP_LONGOPT_RETVAL__ = 127,
+
+	/*
+	 * Return value definition for getopt_long()
+	 * Only for long option
+	 */
+	SPP_LONGOPT_RETVAL_CLIENT_ID,   /* --client-id    */
+	SPP_LONGOPT_RETVAL_VHOST_CLIENT /* --vhost-client */
+};
+
+/* Flag of processing type to copy management information */
+enum copy_mng_flg {
+	COPY_MNG_FLG_NONE,
+	COPY_MNG_FLG_UPDCOPY,
+	COPY_MNG_FLG_ALLCOPY,
+};
+
+/**
+ * Interface information structure
+ */
+struct spp_port_index {
+	enum port_type  iface_type; /**< Interface type (phy/vhost/ring) */
+	int             iface_no;   /**< Interface number */
+};
+
+/** VLAN tag information */
+struct spp_vlantag_info {
+	int vid; /**< VLAN ID */
+	int pcp; /**< Priority Code Point */
+	int tci; /**< Tag Control Information */
+};
+
+/**
+ * Data for each port ability which indicates vlantag related information
+ * for the port
+ */
+union spp_ability_data {
+	/** VLAN tag information */
+	struct spp_vlantag_info vlantag;
+};
+
+/** Port ability information */
+struct spp_port_ability {
+	enum spp_port_ability_ope ope; /**< Operation */
+	enum spp_port_rxtx rxtx;       /**< rx/tx identifier */
+	union spp_ability_data data;   /**< Port ability data */
+};
+
+/** Port class identifier for classifying */
+struct spp_port_class_identifier {
+	uint64_t mac_addr;                      /**< Mac address (binary) */
+	char     mac_addr_str[SPP_MIN_STR_LEN]; /**< Mac address (text) */
+	struct spp_vlantag_info vlantag;        /**< VLAN tag information */
+};
+
+/* Port info */
+struct spp_port_info {
+	enum port_type iface_type;      /**< Interface type (phy/vhost/ring) */
+	int            iface_no;        /**< Interface number */
+	int            dpdk_port;       /**< DPDK port number */
+	struct spp_port_class_identifier class_id;
+					/**< Port class identifier */
+	struct spp_port_ability ability[SPP_PORT_ABILITY_MAX];
+					/**< Port ability */
+};
+
+/* Component info */
+struct spp_component_info {
+	char name[SPP_NAME_STR_LEN];	/**< Component name */
+	enum spp_component_type type;	/**< Component type */
+	unsigned int lcore_id;		/**< Logical core ID for component */
+	int component_id;		/**< Component ID */
+	int num_rx_port;		/**< The number of rx ports */
+	int num_tx_port;		/**< The number of tx ports */
+	struct spp_port_info *rx_ports[RTE_MAX_ETHPORTS];
+					/**< Array of pointers to rx ports */
+	struct spp_port_info *tx_ports[RTE_MAX_ETHPORTS];
+					/**< Array of pointers to tx ports */
+};
+
+/* Manage given options as global variable */
+struct startup_param {
+	int client_id;		/* Client ID */
+	char server_ip[INET_ADDRSTRLEN];
+				/* IP address stiring of spp-ctl */
+	int server_port;	/* Port Number of spp-ctl */
+	int vhost_client;	/* Flag for --vhost-client option */
+};
+
+/* Manage number of interfaces  and port information as global variable */
+struct iface_info {
+	int num_nic;		/* The number of phy */
+	int num_vhost;		/* The number of vhost */
+	int num_ring;		/* The number of ring */
+	struct spp_port_info nic[RTE_MAX_ETHPORTS];
+				/* Port information of phy */
+	struct spp_port_info vhost[RTE_MAX_ETHPORTS];
+				/* Port information of vhost */
+	struct spp_port_info ring[RTE_MAX_ETHPORTS];
+				/* Port information of ring */
+};
+
+/* Manage component running in core as global variable */
+struct core_info {
+	volatile enum spp_component_type type;
+			       /* Component type */
+	int num;	       /* The number of IDs below */
+	int id[RTE_MAX_LCORE]; /* ID list of components executed on cpu core */
+};
+
+/* Manage core status and component information as global variable */
+struct core_mng_info {
+	/* Status of cpu core */
+	volatile enum spp_core_status status;
+
+	/* Index number of core information for reference */
+	volatile int ref_index;
+
+	/* Index number of core information for updating */
+	volatile int upd_index;
+
+	/* Core information of each cpu core */
+	struct core_info core[SPP_INFO_AREA_MAX];
+};
+
+/* Manage data to be backup */
+struct cancel_backup_info {
+	/* Backup data of core information */
+	struct core_mng_info core[RTE_MAX_LCORE];
+
+	/* Backup data of component information */
+	struct spp_component_info component[RTE_MAX_LCORE];
+
+	/* Backup data of interface information */
+	struct iface_info interface;
+};
+
+struct spp_iterate_core_params;
+/**
+ * definition of iterated core element procedure function
+ * which is member of spp_iterate_core_params structure.
+ * Above structure is used when listing core information
+ * (e.g) create resonse to status command.
+ */
+typedef int (*spp_iterate_core_element_proc)(
+		struct spp_iterate_core_params *params,
+		const unsigned int lcore_id,
+		const char *name,
+		const char *type,
+		const int num_rx,
+		const struct spp_port_index *rx_ports,
+		const int num_tx,
+		const struct spp_port_index *tx_ports);
+
+/**
+ * iterate core table parameters which is
+ * used when listing core table content
+ * (e.g.) create response to status command.
+ */
+struct spp_iterate_core_params {
+	/** Output buffer */
+	char *output;
+
+	/** The function for creating core information */
+	spp_iterate_core_element_proc element_proc;
+};
+
+struct spp_iterate_classifier_table_params;
+/**
+ * definition of iterated classifier element procedure function
+ * which is member of spp_iterate_classifier_table_params structure.
+ * Above structure is used when listing classifier table information
+ * (e.g) create resonse to status command.
+ */
+typedef int (*spp_iterate_classifier_element_proc)(
+		struct spp_iterate_classifier_table_params *params,
+		enum spp_classifier_type type,
+		int vid, const char *mac,
+		const struct spp_port_index *port);
+
+/**
+ * iterate classifier table parameters which is
+ * used when listing classifier table content
+ * (e.g.) create response to status command.
+ */
+struct spp_iterate_classifier_table_params {
+	/* Output buffer */
+	void *output;
+
+	/* The function for creating classifier table information */
+	spp_iterate_classifier_element_proc element_proc;
+};
+
+/**
+ * Make a hexdump of an array data in every 4 byte
  *
  * @param name
  *  dump name.
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index accef02..62ceb20 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -18,94 +18,6 @@
 #include "command_proc.h"
 #include "spp_port.h"
 
-/* Max number of core status check */
-#define SPP_CORE_STATUS_CHECK_MAX 5
-
-/* Sampling interval timer for latency evaluation */
-#define SPP_RING_LATENCY_STATS_SAMPLING_INTERVAL 1000000
-
-/* Name string for each component */
-#define CORE_TYPE_CLASSIFIER_MAC_STR "classifier_mac"
-#define CORE_TYPE_MERGE_STR          "merge"
-#define CORE_TYPE_FORWARD_STR        "forward"
-
-/* getopt_long return value for long option */
-enum SPP_LONGOPT_RETVAL {
-	SPP_LONGOPT_RETVAL__ = 127,
-
-	/*
-	 * Return value definition for getopt_long()
-	 * Only for long option
-	 */
-	SPP_LONGOPT_RETVAL_CLIENT_ID,   /* --client-id    */
-	SPP_LONGOPT_RETVAL_VHOST_CLIENT /* --vhost-client */
-};
-
-/* Flag of processing type to copy management information */
-enum copy_mng_flg {
-	COPY_MNG_FLG_NONE,
-	COPY_MNG_FLG_UPDCOPY,
-	COPY_MNG_FLG_ALLCOPY,
-};
-
-/* Manage given options as global variable */
-struct startup_param {
-	int client_id;          /* Client ID of spp_vf */
-	char server_ip[INET_ADDRSTRLEN];
-				/* IP address sting of spp controller */
-	int server_port;        /* Port Number of spp controller */
-	int vhost_client;       /* Flag for --vhost-client option */
-};
-
-/* Manage number of interfaces  and port information as global variable */
-struct iface_info {
-	int num_nic;            /* The number of phy */
-	int num_vhost;          /* The number of vhost */
-	int num_ring;           /* The number of ring */
-	struct spp_port_info nic[RTE_MAX_ETHPORTS];
-				/* Port information of phy */
-	struct spp_port_info vhost[RTE_MAX_ETHPORTS];
-				/* Port information of vhost */
-	struct spp_port_info ring[RTE_MAX_ETHPORTS];
-				/* Port information of ring */
-};
-
-/* Manage component running in core as global variable */
-struct core_info {
-	volatile enum spp_component_type type;
-				/* Component type */
-	int num;                /* The number of IDs below */
-	int id[RTE_MAX_LCORE];
-			/* ID list of components executed on cpu core */
-};
-
-/* Manage core status and component information as global variable */
-struct core_mng_info {
-	/* Status of cpu core */
-	volatile enum spp_core_status status;
-
-	/* Index number of core information for reference */
-	volatile int ref_index;
-
-	/* Index number of core information for updating */
-	volatile int upd_index;
-
-	/* Core information of each cpu core */
-	struct core_info core[SPP_INFO_AREA_MAX];
-};
-
-/* Manage data to be backup */
-struct cancel_backup_info {
-	/* Backup data of core information */
-	struct core_mng_info core[RTE_MAX_LCORE];
-
-	/* Backup data of component information */
-	struct spp_component_info component[RTE_MAX_LCORE];
-
-	/* Backup data of interface information */
-	struct iface_info interface;
-};
-
 /* Declare global variables */
 /* Logical core ID for main process */
 static unsigned int g_main_lcore_id = 0xffffffff;
diff --git a/src/vf/spp_vf.h b/src/vf/spp_vf.h
index 5586207..1d05e66 100644
--- a/src/vf/spp_vf.h
+++ b/src/vf/spp_vf.h
@@ -15,99 +15,9 @@
 
 #include "common.h"
 
-/** Identifier string for each component (status command) @{*/
-#define SPP_TYPE_CLASSIFIER_MAC_STR "classifier_mac"
-#define SPP_TYPE_MERGE_STR          "merge"
-#define SPP_TYPE_FORWARD_STR        "forward"
-#define SPP_TYPE_UNUSE_STR          "unuse"
-/**@}*/
-
-/** Identifier string for each interface @{*/
-#define SPP_IFTYPE_NIC_STR   "phy"
-#define SPP_IFTYPE_VHOST_STR "vhost"
-#define SPP_IFTYPE_RING_STR  "ring"
-/**@}*/
-
 /** The max number of client ID */
 #define SPP_CLIENT_MAX    128
 
-/** The max number of buffer for management */
-#define SPP_INFO_AREA_MAX 2
-
-/** The length of shortest character string */
-#define SPP_MIN_STR_LEN   32
-
-/** The length of NAME string */
-#define SPP_NAME_STR_LEN  128
-
-/** Update wait timer (micro sec) */
-#define SPP_CHANGE_UPDATE_INTERVAL 10
-
-/** Character sting for default port of classifier */
-#define SPP_DEFAULT_CLASSIFIED_SPEC_STR     "default"
-
-/** Character sting for default MAC address of classifier */
-#define SPP_DEFAULT_CLASSIFIED_DMY_ADDR_STR "00:00:00:00:00:01"
-
-/** Value for default MAC address of classifier */
-#define SPP_DEFAULT_CLASSIFIED_DMY_ADDR     0x010000000000
-
-/** Maximum number of port abilities available */
-#define SPP_PORT_ABILITY_MAX 4
-
-/** Number of VLAN ID */
-#define SPP_NUM_VLAN_VID 4096
-
-/** Maximum VLAN PCP */
-#define SPP_VLAN_PCP_MAX 7
-
-/**
- * State on component
- */
-enum spp_core_status {
-	SPP_CORE_UNUSE,        /**< Not used */
-	SPP_CORE_STOP,         /**< Stopped */
-	SPP_CORE_IDLE,         /**< Idling */
-	SPP_CORE_FORWARD,      /**< Forwarding  */
-	SPP_CORE_STOP_REQUEST, /**< Request stopping */
-	SPP_CORE_IDLE_REQUEST  /**< Request idling */
-};
-
-/**
- * Process type for each component
- */
-enum spp_component_type {
-	SPP_COMPONENT_UNUSE,          /**< Not used */
-	SPP_COMPONENT_CLASSIFIER_MAC, /**< Classifier_mac */
-	SPP_COMPONENT_MERGE,          /**< Merger */
-	SPP_COMPONENT_FORWARD,        /**< Forwarder */
-};
-
-/**
- * Classifier Type
- */
-enum spp_classifier_type {
-	SPP_CLASSIFIER_TYPE_NONE, /**< Type none */
-	SPP_CLASSIFIER_TYPE_MAC,  /**< MAC address */
-	SPP_CLASSIFIER_TYPE_VLAN  /**< VLAN ID */
-};
-
-/**
- * API Return value
- */
-enum spp_return_value {
-	SPP_RET_OK = 0,  /**< succeeded */
-	SPP_RET_NG = -1, /**< failed */
-};
-
-/** Port type (rx or tx) */
-enum spp_port_rxtx {
-	SPP_PORT_RXTX_NONE, /**< none */
-	SPP_PORT_RXTX_RX,   /**< rx port */
-	SPP_PORT_RXTX_TX,   /**< tx port */
-	SPP_PORT_RXTX_ALL,  /**< rx/tx port */
-};
-
 /** command setting type */
 enum spp_command_action {
 	SPP_CMD_ACTION_NONE,  /**< none */
@@ -117,77 +27,6 @@ enum spp_command_action {
 	SPP_CMD_ACTION_DEL,   /**< delete */
 };
 
-/** Port ability operation */
-enum spp_port_ability_ope {
-	SPP_PORT_ABILITY_OPE_NONE,        /**< none */
-	SPP_PORT_ABILITY_OPE_ADD_VLANTAG, /**< add VLAN tag */
-	SPP_PORT_ABILITY_OPE_DEL_VLANTAG, /**< delete VLAN tag */
-};
-
-/**
- * Interface information structure
- */
-struct spp_port_index {
-	enum port_type  iface_type; /**< Interface type (phy/vhost/ring) */
-	int             iface_no;   /**< Interface number */
-};
-
-/** VLAN tag information */
-struct spp_vlantag_info {
-	int vid; /**< VLAN ID */
-	int pcp; /**< Priority Code Point */
-	int tci; /**< Tag Control Information */
-};
-
-/** Data for each port ability */
-union spp_ability_data {
-	/** VLAN tag information */
-	struct spp_vlantag_info vlantag;
-};
-
-/** Port ability information */
-struct spp_port_ability {
-	enum spp_port_ability_ope ope; /**< Operation */
-	enum spp_port_rxtx rxtx;       /**< rx/tx identifier */
-	union spp_ability_data data;   /**< Port ability data */
-};
-
-/** Port class identifier for classifying */
-struct spp_port_class_identifier {
-	uint64_t mac_addr;                      /**< Mac address (binary) */
-	char     mac_addr_str[SPP_MIN_STR_LEN]; /**< Mac address (text) */
-	struct spp_vlantag_info vlantag;        /**< VLAN tag information */
-};
-
-/**
- * Port info
- */
-struct spp_port_info {
-	enum port_type iface_type;      /**< Interface type (phy/vhost/ring) */
-	int            iface_no;        /**< Interface number */
-	int            dpdk_port;       /**< DPDK port number */
-	struct spp_port_class_identifier class_id;
-					/**< Port class identifier */
-	struct spp_port_ability ability[SPP_PORT_ABILITY_MAX];
-					/**< Port ability */
-};
-
-/**
- * Component info
- */
-struct spp_component_info {
-	char name[SPP_NAME_STR_LEN];    /**< Component name */
-	enum spp_component_type type;   /**< Component type */
-	unsigned int lcore_id;          /**< Logical core ID for component */
-	int component_id;               /**< Component ID */
-	int num_rx_port;                /**< The number of rx ports */
-	int num_tx_port;                /**< The number of tx ports */
-	struct spp_port_info *rx_ports[RTE_MAX_ETHPORTS];
-					/**< Array of pointers to rx ports */
-	struct spp_port_info *tx_ports[RTE_MAX_ETHPORTS];
-					/**< Array of pointers to tx ports */
-};
-
 /**
  * Get client ID
  *
@@ -267,27 +106,6 @@ int spp_update_port(
  */
 int spp_flush(void);
 
-struct spp_iterate_core_params;
-/** definition of iterated core element procedure function */
-typedef int (*spp_iterate_core_element_proc)(
-		struct spp_iterate_core_params *params,
-		const unsigned int lcore_id,
-		const char *name,
-		const char *type,
-		const int num_rx,
-		const struct spp_port_index *rx_ports,
-		const int num_tx,
-		const struct spp_port_index *tx_ports);
-
-/** iterate core information parameters */
-struct spp_iterate_core_params {
-	/** Output buffer */
-	char *output;
-
-	/** The function for creating core information */
-	spp_iterate_core_element_proc element_proc;
-};
-
 /**
  * Iterate core information
  *
@@ -300,20 +118,6 @@ struct spp_iterate_core_params {
  */
 int spp_iterate_core_info(struct spp_iterate_core_params *params);
 
-struct spp_iterate_classifier_table_params;
-/** definition of iterated classifier element procedure function */
-typedef int (*spp_iterate_classifier_element_proc)(
-		struct spp_iterate_classifier_table_params *params,
-		enum spp_classifier_type type,
-		int vid, const char *mac,
-		const struct spp_port_index *port);
-
-/** iterate classifier table parameters */
-struct spp_iterate_classifier_table_params {
-	void *output;
-	spp_iterate_classifier_element_proc element_proc;
-};
-
 /**
  * Iterate Classifier_table
  *
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 07/23] spp_vf: move functions for decode to common dir
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (5 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 06/23] spp_vf: move defines to common dir x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 08/23] spp_vf: move defines " x-fn-spp
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Move functions for decode to common directory.

This patch also refactors code on following point.
  change of a function name.
   - from spp_get_iface_index() to spp_convert_port_to_iface()
   - from spp_change_component_type() to spp_convert_component_type()

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/command_dec.c | 113 +++++++++++++++++++++++++++++++++++-
 src/vf/spp_vf.c             | 108 ----------------------------------
 src/vf/spp_vf.h             |  74 -----------------------
 3 files changed, 110 insertions(+), 185 deletions(-)

diff --git a/src/vf/common/command_dec.c b/src/vf/common/command_dec.c
index 5275f4f..35066c2 100644
--- a/src/vf/common/command_dec.c
+++ b/src/vf/common/command_dec.c
@@ -64,6 +64,112 @@ const char *PORT_ABILITY_STRINGS[] = {
 	/* termination */ "",
 };
 
+/* Get component type being updated on target core */
+static enum spp_component_type
+spp_get_component_type_update(unsigned int lcore_id)
+{
+	struct core_mng_info *info = &g_core_info[lcore_id];
+	return info->core[info->upd_index].type;
+}
+
+/* Check mac address used on the port for registering or removing */
+static int
+spp_check_classid_used_port(
+		int vid, uint64_t mac_addr,
+		enum port_type iface_type, int iface_no)
+{
+	struct spp_port_info *port_info = get_iface_info(iface_type, iface_no);
+
+	/**
+	 * return true if given mac_addr/vid matches
+	 *  with that of port_info/vid
+	 */
+	return ((mac_addr == port_info->class_id.mac_addr) &&
+		(vid == port_info->class_id.vlantag.vid));
+}
+
+/* Check if port has been added. */
+static int
+spp_check_added_port(enum port_type iface_type, int iface_no)
+{
+	struct spp_port_info *port = get_iface_info(iface_type, iface_no);
+	return port->iface_type != UNDEF;
+}
+
+/**
+ * Separate port id of combination of iface type and number and
+ * assign to given argument, iface_type and iface_no.
+ *
+ * For instance, 'ring:0' is separated to 'ring' and '0'.
+ */
+static int
+spp_convert_port_to_iface(const char *port,
+		    enum port_type *iface_type,
+		    int *iface_no)
+{
+	enum port_type type = UNDEF;
+	const char *no_str = NULL;
+	char *endptr = NULL;
+
+	/* Find out which type of interface from port */
+	if (strncmp(port, SPP_IFTYPE_NIC_STR ":",
+			strlen(SPP_IFTYPE_NIC_STR)+1) == 0) {
+		/* NIC */
+		type = PHY;
+		no_str = &port[strlen(SPP_IFTYPE_NIC_STR)+1];
+	} else if (strncmp(port, SPP_IFTYPE_VHOST_STR ":",
+			strlen(SPP_IFTYPE_VHOST_STR)+1) == 0) {
+		/* VHOST */
+		type = VHOST;
+		no_str = &port[strlen(SPP_IFTYPE_VHOST_STR)+1];
+	} else if (strncmp(port, SPP_IFTYPE_RING_STR ":",
+			strlen(SPP_IFTYPE_RING_STR)+1) == 0) {
+		/* RING */
+		type = RING;
+		no_str = &port[strlen(SPP_IFTYPE_RING_STR)+1];
+	} else {
+		/* OTHER */
+		RTE_LOG(ERR, APP, "Unknown interface type. (port = %s)\n",
+				port);
+		return -1;
+	}
+
+	/* Change type of number of interface */
+	int ret_no = strtol(no_str, &endptr, 0);
+	if (unlikely(no_str == endptr) || unlikely(*endptr != '\0')) {
+		/* No IF number */
+		RTE_LOG(ERR, APP, "No interface number. (port = %s)\n", port);
+		return -1;
+	}
+
+	*iface_type = type;
+	*iface_no = ret_no;
+
+	RTE_LOG(DEBUG, APP, "Port = %s => Type = %d No = %d\n",
+			port, *iface_type, *iface_no);
+	return 0;
+}
+
+/* Convert component name to component type */
+static enum spp_component_type
+spp_convert_component_type(const char *type_str)
+{
+	if (strncmp(type_str, CORE_TYPE_CLASSIFIER_MAC_STR,
+			strlen(CORE_TYPE_CLASSIFIER_MAC_STR)+1) == 0) {
+		/* Classifier */
+		return SPP_COMPONENT_CLASSIFIER_MAC;
+	} else if (strncmp(type_str, CORE_TYPE_MERGE_STR,
+			strlen(CORE_TYPE_MERGE_STR)+1) == 0) {
+		/* Merger */
+		return SPP_COMPONENT_MERGE;
+	} else if (strncmp(type_str, CORE_TYPE_FORWARD_STR,
+			strlen(CORE_TYPE_FORWARD_STR)+1) == 0) {
+		/* Forwarder */
+		return SPP_COMPONENT_FORWARD;
+	}
+	return SPP_COMPONENT_UNUSE;
+}
+
 /* set decode error */
 inline int
 set_decode_error(struct spp_command_decode_error *error,
@@ -179,7 +285,8 @@ decode_port_value(void *output, const char *arg_val)
 {
 	int ret = 0;
 	struct spp_port_index *port = output;
-	ret = spp_get_iface_index(arg_val, &port->iface_type, &port->iface_no);
+	ret = spp_convert_port_to_iface(arg_val, &port->iface_type,
+							&port->iface_no);
 	if (unlikely(ret != 0)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC, "Bad port. val=%s\n", arg_val);
 		return -1;
@@ -273,7 +380,7 @@ decode_component_type_value(void *output, const char *arg_val)
 	if (component->action != SPP_CMD_ACTION_START)
 		return 0;
 
-	set_type = spp_get_component_type(arg_val);
+	set_type = spp_convert_component_type(arg_val);
 	if (unlikely(set_type <= 0)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Unknown component type. val=%s\n",
@@ -392,7 +499,7 @@ decode_port_name_value(void *output, const char *arg_val)
 	return decode_str_value(output, arg_val);
 }
 
-#/* decoding procedure of port ability for port command */
+/* decoding procedure of port ability for port command */
 static int
 decode_port_ability_value(void *output, const char *arg_val)
 {
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index 62ceb20..f086eaf 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -183,15 +183,6 @@ parse_app_args(int argc, char *argv[])
 	return 0;
 }
 
-/* Get component type being updated on target core */
-enum spp_component_type
-spp_get_component_type_update(unsigned int lcore_id)
-{
-	struct core_mng_info *info = &g_core_info[lcore_id];
-	return info->core[info->upd_index].type;
-}
-
-
 /* Main process of slave core */
 static int
 slave_main(void *arg __attribute__ ((unused)))
@@ -389,29 +380,6 @@ spp_get_client_id(void)
 	return g_startup_param.client_id;
 }
 
-/**
- * Check mac address used on the port for registering or removing
- */
-int
-spp_check_classid_used_port(
-		int vid, uint64_t mac_addr,
-		enum port_type iface_type, int iface_no)
-{
-	struct spp_port_info *port_info = get_iface_info(iface_type, iface_no);
-	return ((mac_addr == port_info->class_id.mac_addr) &&
-			(vid == port_info->class_id.vlantag.vid));
-}
-
-/*
- * Check if port has been added.
- */
-int
-spp_check_added_port(enum port_type iface_type, int iface_no)
-{
-	struct spp_port_info *port = get_iface_info(iface_type, iface_no);
-	return port->iface_type != UNDEF;
-}
-
 /*
  * Check if port has been flushed.
  */
@@ -795,79 +763,3 @@ spp_get_dpdk_port(enum port_type iface_type, int iface_no)
 		return -1;
 	}
 }
-
-/**
- * Separate port id of combination of iface type and number and
- * assign to given argument, iface_type and iface_no.
- *
- * For instance, 'ring:0' is separated to 'ring' and '0'.
- */
-int
-spp_get_iface_index(const char *port,
-		    enum port_type *iface_type,
-		    int *iface_no)
-{
-	enum port_type type = UNDEF;
-	const char *no_str = NULL;
-	char *endptr = NULL;
-
-	/* Find out which type of interface from port */
-	if (strncmp(port, SPP_IFTYPE_NIC_STR ":",
-			strlen(SPP_IFTYPE_NIC_STR)+1) == 0) {
-		/* NIC */
-		type = PHY;
-		no_str = &port[strlen(SPP_IFTYPE_NIC_STR)+1];
-	} else if (strncmp(port, SPP_IFTYPE_VHOST_STR ":",
-			strlen(SPP_IFTYPE_VHOST_STR)+1) == 0) {
-		/* VHOST */
-		type = VHOST;
-		no_str = &port[strlen(SPP_IFTYPE_VHOST_STR)+1];
-	} else if (strncmp(port, SPP_IFTYPE_RING_STR ":",
-			strlen(SPP_IFTYPE_RING_STR)+1) == 0) {
-		/* RING */
-		type = RING;
-		no_str = &port[strlen(SPP_IFTYPE_RING_STR)+1];
-	} else {
-		/* OTHER */
-		RTE_LOG(ERR, APP, "Unknown interface type. (port = %s)\n",
-				port);
-		return -1;
-	}
-
-	/* Change type of number of interface */
-	int ret_no = strtol(no_str, &endptr, 0);
-	if (unlikely(no_str == endptr) || unlikely(*endptr != '\0')) {
-		/* No IF number */
-		RTE_LOG(ERR, APP, "No interface number. (port = %s)\n", port);
-		return -1;
-	}
-
-	*iface_type = type;
-	*iface_no = ret_no;
-
-	RTE_LOG(DEBUG, APP, "Port = %s => Type = %d No = %d\n",
-			port, *iface_type, *iface_no);
-	return 0;
-}
-
-/**
- * Return the type of forwarder as a member of enum of spp_component_type
- */
-enum spp_component_type
-spp_change_component_type(const char *type_str)
-{
-	if (strncmp(type_str, CORE_TYPE_CLASSIFIER_MAC_STR,
-			 strlen(CORE_TYPE_CLASSIFIER_MAC_STR)+1) == 0) {
-		/* Classifier */
-		return SPP_COMPONENT_CLASSIFIER_MAC;
-	} else if (strncmp(type_str, CORE_TYPE_MERGE_STR,
-			 strlen(CORE_TYPE_MERGE_STR)+1) == 0) {
-		/* Merger */
-		return SPP_COMPONENT_MERGE;
-	} else if (strncmp(type_str, CORE_TYPE_FORWARD_STR,
-			 strlen(CORE_TYPE_FORWARD_STR)+1) == 0) {
-		/* Forwarder */
-		return SPP_COMPONENT_FORWARD;
-	}
-	return SPP_COMPONENT_UNUSE;
-}
diff --git a/src/vf/spp_vf.h b/src/vf/spp_vf.h
index 1d05e66..1a49847 100644
--- a/src/vf/spp_vf.h
+++ b/src/vf/spp_vf.h
@@ -131,51 +131,6 @@ int spp_iterate_core_info(struct spp_iterate_core_params *params);
 int spp_iterate_classifier_table(
 		struct spp_iterate_classifier_table_params *params);
 
-/**
- * Get component type being updated on target core
- *
- * @param lcore_id
- *  Logical core ID.
- *
- * @return
- *  Type of component that will be executed on
- *  specified logical core after update.
- */
-enum spp_component_type spp_get_component_type_update(unsigned int lcore_id);
-
-/**
- * Check mac address used on the port for registering or removing
- *
- * @param vid
- *  VLAN ID to be validated.
- * @param mac_addr
- *  Mac address to be validated.
- * @param iface_type
- *  Interface to be validated.
- * @param iface_no
- *  Interface number to be validated.
- *
- * @return
- *  True if target identifier(VLAN ID, MAC address)
- *  matches identifier(VLAN ID, MAC address) of port.
- */
-int spp_check_classid_used_port(
-		int vid, uint64_t mac_addr,
-		enum port_type iface_type, int iface_no);
-
-/**
- * Check if port has been added.
- *
- * @param iface_type
- *  Interface to be validated.
- * @param iface_no
- *  Interface number to be validated.
- *
- * @return
- *  True if port has been added.
- */
-int spp_check_added_port(enum port_type iface_type, int iface_no);
-
 /**
  * Check if port has been flushed.
  *
@@ -202,33 +157,4 @@ int spp_check_flush_port(enum port_type iface_type, int iface_no);
  */
 int spp_get_dpdk_port(enum port_type iface_type, int iface_no);
 
-/**
- * Extract if-type/if-number from port string
- *
- * @param port
- *  Character string expressing the port, e.g. "phy:0","ring:1"
- * @param iface_type
- *  Interface type obtained from port.
- * @param iface_no
- *  Interface number obtained from port.
- *
- * @retval 0  succeeded.
- * @retval -1 failed.
- */
-int spp_get_iface_index(
-		const char *port,
-		enum port_type *iface_type,
-		int *iface_no);
-
-/**
- * Change component type from string to type value.
- *
- * @param type_str
- *  Name string for each component
- *
- * @return
- *  Component type corresponding to type_str.
- */
-enum spp_component_type spp_change_component_type(const char *type_str);
-
 #endif /* __SPP_VF_H__ */
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 08/23] spp_vf: move defines for decode to common dir
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (6 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 07/23] spp_vf: move functions for decode " x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 09/23] spp_vf: move functions to command_proc.c x-fn-spp
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Move defines, enums and structs used for decode to common directory.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/command_dec.h | 15 +++++++++++++++
 src/vf/spp_vf.h             |  9 ---------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/vf/common/command_dec.h b/src/vf/common/command_dec.h
index 281a8c4..538eb57 100644
--- a/src/vf/common/command_dec.h
+++ b/src/vf/common/command_dec.h
@@ -37,6 +37,21 @@ enum spp_command_decode_error_code {
 	SPP_CMD_DERR_BAD_VALUE,       /**< Wrong value */
 };
 
+/**
+ * Define actions of each of components
+ *  The Run option of the folllwing commands.
+ *   compomnent       : start,stop
+ *   port             : add,del
+ *   classifier_table : add,del
+ */
+enum spp_command_action {
+	SPP_CMD_ACTION_NONE,  /**< none */
+	SPP_CMD_ACTION_START, /**< start */
+	SPP_CMD_ACTION_STOP,  /**< stop */
+	SPP_CMD_ACTION_ADD,   /**< add */
+	SPP_CMD_ACTION_DEL,   /**< delete */
+};
+
 /**
  * spp command type.
  *
diff --git a/src/vf/spp_vf.h b/src/vf/spp_vf.h
index 1a49847..f540122 100644
--- a/src/vf/spp_vf.h
+++ b/src/vf/spp_vf.h
@@ -18,15 +18,6 @@
 /** The max number of client ID */
 #define SPP_CLIENT_MAX    128
 
-/** command setting type */
-enum spp_command_action {
-	SPP_CMD_ACTION_NONE,  /**< none */
-	SPP_CMD_ACTION_START, /**< start */
-	SPP_CMD_ACTION_STOP,  /**< stop */
-	SPP_CMD_ACTION_ADD,   /**< add */
-	SPP_CMD_ACTION_DEL,   /**< delete */
-};
-
 /**
  * Get client ID
  *
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 09/23] spp_vf: move functions to command_proc.c
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (7 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 08/23] spp_vf: move defines " x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 10/23] spp_vf: add management data registration x-fn-spp
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Move util functions used from spp_vf and spp_mirror to common
directory.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/command_proc.c | 399 +++++++++++++++++++++++++++++++++++
 src/vf/spp_vf.c              | 390 ----------------------------------
 src/vf/spp_vf.h              | 133 ------------
 3 files changed, 399 insertions(+), 523 deletions(-)

diff --git a/src/vf/common/command_proc.c b/src/vf/common/command_proc.c
index b8ad907..02c41b6 100644
--- a/src/vf/common/command_proc.c
+++ b/src/vf/common/command_proc.c
@@ -84,6 +84,405 @@ const char *CLASSIFILER_TYPE_STATUS_STRINGS[] = {
 	/* termination */ "",
 };
 
+/* get client id */
+static int
+spp_get_client_id(void)
+{
+	return g_startup_param.client_id;
+}
+
+/* Check if port has been flushed. */
+static int
+spp_check_flush_port(enum port_type iface_type, int iface_no)
+{
+	struct spp_port_info *port = get_iface_info(iface_type, iface_no);
+	return port->dpdk_port >= 0;
+}
+
+/* update classifier table according to the specified action(add or del). */
+static int
+spp_update_classifier_table(
+		enum spp_command_action action,
+		enum spp_classifier_type type __attribute__ ((unused)),
+		int vid,
+		const char *mac_addr_str,
+		const struct spp_port_index *port)
+{
+	struct spp_port_info *port_info = NULL;
+	int64_t ret_mac = 0;
+	uint64_t mac_addr = 0;
+
+	RTE_LOG(DEBUG, APP, "update_classifier_table "
+			"( type = mac, mac addr = %s, port = %d:%d )\n",
+			mac_addr_str, port->iface_type, port->iface_no);
+
+	ret_mac = spp_change_mac_str_to_int64(mac_addr_str);
+	if (unlikely(ret_mac == -1)) {
+		RTE_LOG(ERR, APP, "MAC address format error. ( mac = %s )\n",
+			mac_addr_str);
+		return SPP_RET_NG;
+	}
+	mac_addr = (uint64_t)ret_mac;
+
+	port_info = get_iface_info(port->iface_type, port->iface_no);
+	if (unlikely(port_info == NULL)) {
+		RTE_LOG(ERR, APP, "No port. ( port = %d:%d )\n",
+				port->iface_type, port->iface_no);
+		return SPP_RET_NG;
+	}
+	if (unlikely(port_info->iface_type == UNDEF)) {
+		RTE_LOG(ERR, APP, "Port not added. ( port = %d:%d )\n",
+				port->iface_type, port->iface_no);
+		return SPP_RET_NG;
+	}
+
+	if (action == SPP_CMD_ACTION_DEL) {
+		/* Delete */
+		if ((port_info->class_id.vlantag.vid != 0) &&
+				unlikely(port_info->class_id.vlantag.vid !=
+				vid)) {
+			RTE_LOG(ERR, APP, "VLAN ID is different. "
+					"( vid = %d )\n", vid);
+			return SPP_RET_NG;
+		}
+		if ((port_info->class_id.mac_addr != 0) &&
+			unlikely(port_info->class_id.mac_addr !=
+					mac_addr)) {
+			RTE_LOG(ERR, APP, "MAC address is different. "
+					"( mac = %s )\n", mac_addr_str);
+			return SPP_RET_NG;
+		}
+
+		port_info->class_id.vlantag.vid = ETH_VLAN_ID_MAX;
+		port_info->class_id.mac_addr    = 0;
+		memset(port_info->class_id.mac_addr_str, 0x00,
+							SPP_MIN_STR_LEN);
+
+	} else if (action == SPP_CMD_ACTION_ADD) {
+		/* Setting */
+		if (unlikely(port_info->class_id.vlantag.vid !=
+				ETH_VLAN_ID_MAX)) {
+			RTE_LOG(ERR, APP, "Port in used. "
+					"( port = %d:%d, vlan = %d != %d )\n",
+					port->iface_type, port->iface_no,
+					port_info->class_id.vlantag.vid, vid);
+			return SPP_RET_NG;
+		}
+		if (unlikely(port_info->class_id.mac_addr != 0)) {
+			RTE_LOG(ERR, APP, "Port in used. "
+					"( port = %d:%d, mac = %s != %s )\n",
+					port->iface_type, port->iface_no,
+					port_info->class_id.mac_addr_str,
+					mac_addr_str);
+			return SPP_RET_NG;
+		}
+
+		port_info->class_id.vlantag.vid = vid;
+		port_info->class_id.mac_addr    = mac_addr;
+		strcpy(port_info->class_id.mac_addr_str, mac_addr_str);
+	}
+
+	set_component_change_port(port_info, SPP_PORT_RXTX_TX);
+	return SPP_RET_OK;
+}
+
+/**
+ * Assign or remove component to/from specified lcore depending
+ * on component action
+ */
+static int
+spp_update_component(
+		enum spp_command_action action,
+		const char *name,
+		unsigned int lcore_id,
+		enum spp_component_type type)
+{
+	int ret = SPP_RET_NG;
+	int ret_del = -1;
+	int component_id = 0;
+	unsigned int tmp_lcore_id = 0;
+	struct spp_component_info *component = NULL;
+	struct core_info *core = NULL;
+	struct core_mng_info *info = NULL;
+
+	switch (action) {
+	case SPP_CMD_ACTION_START:
+		info = &g_core_info[lcore_id];
+		if (info->status == SPP_CORE_UNUSE) {
+			RTE_LOG(ERR, APP, "Core %d is not available because "
+				"it is in SPP_CORE_UNUSE state.\n", lcore_id);
+			return SPP_RET_NG;
+		}
+
+		component_id = spp_get_component_id(name);
+		if (component_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) {
+			RTE_LOG(ERR, APP, "Cannot assign component over the "
+				"maximum number.\n");
+			return SPP_RET_NG;
+		}
+
+		core = &info->core[info->upd_index];
+		if ((core->type != SPP_COMPONENT_UNUSE) &&
+				(core->type != type)) {
+			RTE_LOG(ERR, APP, "Component type '%s' is invalid.\n",
+				name);
+			return SPP_RET_NG;
+		}
+
+		component = &g_component_info[component_id];
+		memset(component, 0x00, sizeof(struct spp_component_info));
+		strcpy(component->name, name);
+		component->type		= type;
+		component->lcore_id	= lcore_id;
+		component->component_id	= component_id;
+
+		core->type = type;
+		core->id[core->num] = component_id;
+		core->num++;
+		ret = SPP_RET_OK;
+		tmp_lcore_id = lcore_id;
+		g_change_component[component_id] = 1;
+		break;
+
+	case SPP_CMD_ACTION_STOP:
+		component_id = spp_get_component_id(name);
+		if (component_id < 0)
+			return SPP_RET_OK;
+
+		component = &g_component_info[component_id];
+		tmp_lcore_id = component->lcore_id;
+		memset(component, 0x00, sizeof(struct spp_component_info));
+
+		info = &g_core_info[tmp_lcore_id];
+		core = &info->core[info->upd_index];
+		ret_del = del_component_info(component_id,
+				core->num, core->id);
+		if (ret_del >= 0)
+			/* If deleted, decrement number. */
+			core->num--;
+
+		if (core->num == 0)
+			core->type = SPP_COMPONENT_UNUSE;
+
+		ret = SPP_RET_OK;
+		g_change_component[component_id] = 0;
+		break;
+
+	default:
+		break;
+	}
+
+	g_change_core[tmp_lcore_id] = 1;
+	return ret;
+}
+
+/* Port add or del to execute it */
+static int
+spp_update_port(enum spp_command_action action,
+		const struct spp_port_index *port,
+		enum spp_port_rxtx rxtx,
+		const char *name,
+		const struct spp_port_ability *ability)
+{
+	int ret = SPP_RET_NG;
+	int ret_check = -1;
+	int ret_del = -1;
+	int component_id = 0;
+	int cnt = 0;
+	struct spp_component_info *component = NULL;
+	struct spp_port_info *port_info = NULL;
+	int *num = NULL;
+	struct spp_port_info **ports = NULL;
+
+	component_id = spp_get_component_id(name);
+	if (component_id < 0) {
+		RTE_LOG(ERR, APP, "Unknown component by port command. "
+				"(component = %s)\n", name);
+		return SPP_RET_NG;
+	}
+
+	component = &g_component_info[component_id];
+	port_info = get_iface_info(port->iface_type, port->iface_no);
+	if (rxtx == SPP_PORT_RXTX_RX) {
+		num = &component->num_rx_port;
+		ports = component->rx_ports;
+	} else {
+		num = &component->num_tx_port;
+		ports = component->tx_ports;
+	}
+
+	switch (action) {
+	case SPP_CMD_ACTION_ADD:
+		ret_check = check_port_element(port_info, *num, ports);
+		if (ret_check >= 0)
+			return SPP_RET_OK;
+
+		if (*num >= RTE_MAX_ETHPORTS) {
+			RTE_LOG(ERR, APP, "Cannot assign port over the "
+				"maximum number.\n");
+			break;
+		}
+
+		if (ability->ope != SPP_PORT_ABILITY_OPE_NONE) {
+			while ((cnt < SPP_PORT_ABILITY_MAX) &&
+					(port_info->ability[cnt].ope !=
+					SPP_PORT_ABILITY_OPE_NONE)) {
+				cnt++;
+			}
+			if (cnt >= SPP_PORT_ABILITY_MAX) {
+				RTE_LOG(ERR, APP,
+						"No space of port ability.\n");
+				return SPP_RET_NG;
+			}
+			memcpy(&port_info->ability[cnt], ability,
+					sizeof(struct spp_port_ability));
+		}
+
+		port_info->iface_type = port->iface_type;
+		ports[*num] = port_info;
+		(*num)++;
+
+		ret = SPP_RET_OK;
+		break;
+
+	case SPP_CMD_ACTION_DEL:
+		for (cnt = 0; cnt < SPP_PORT_ABILITY_MAX; cnt++) {
+			if (port_info->ability[cnt].ope ==
+					SPP_PORT_ABILITY_OPE_NONE)
+				continue;
+
+			if (port_info->ability[cnt].rxtx == rxtx)
+				memset(&port_info->ability[cnt], 0x00,
+					sizeof(struct spp_port_ability));
+		}
+
+		ret_del = get_del_port_element(port_info, *num, ports);
+		if (ret_del == 0)
+			(*num)--; /* If deleted, decrement number. */
+
+		ret = SPP_RET_OK;
+		break;
+	default:
+		break;
+	}
+
+	g_change_component[component_id] = 1;
+	return ret;
+}
+
+/* Flush command to execute it */
+static int
+spp_flush(void)
+{
+	int ret = -1;
+
+	/* Initial setting of each interface. */
+	ret = flush_port();
+	if (ret < 0)
+		return ret;
+
+	/* Flush of core index. */
+	flush_core();
+
+	/* Flush of component */
+	ret = flush_component();
+
+	backup_mng_info(&g_backup_info);
+	return ret;
+}
+
+/* Iterate core information to create response to status command */
+static int
+spp_iterate_core_info(struct spp_iterate_core_params *params)
+{
+	int ret;
+	int lcore_id, cnt;
+	struct core_info *core = NULL;
+
+	RTE_LCORE_FOREACH_SLAVE(lcore_id) {
+		if (spp_get_core_status(lcore_id) == SPP_CORE_UNUSE)
+			continue;
+
+		core = get_core_info(lcore_id);
+		if (core->num == 0) {
+			ret = (*params->element_proc)(
+				params, lcore_id,
+				"", SPP_TYPE_UNUSE_STR,
+				0, NULL, 0, NULL);
+			if (unlikely(ret != 0)) {
+				RTE_LOG(ERR, APP, "Cannot iterate core "
+						"information. "
+						"(core = %d, type = %d)\n",
+						lcore_id, SPP_COMPONENT_UNUSE);
+				return SPP_RET_NG;
+			}
+			continue;
+		}
+
+		for (cnt = 0; cnt < core->num; cnt++) {
+			if (core->type == SPP_COMPONENT_CLASSIFIER_MAC) {
+				ret = spp_classifier_get_component_status(
+						lcore_id,
+						core->id[cnt],
+						params);
+			} else {
+				ret = spp_forward_get_component_status(
+						lcore_id,
+						core->id[cnt],
+						params);
+			}
+			if (unlikely(ret != 0)) {
+				RTE_LOG(ERR, APP, "Cannot iterate core "
+						"information. "
+						"(core = %d, type = %d)\n",
+						lcore_id, core->type);
+				return SPP_RET_NG;
+			}
+		}
+	}
+
+	return SPP_RET_OK;
+}
+
+/* Iterate classifier_table to create response to status command */
+static int
+spp_iterate_classifier_table(
+		struct spp_iterate_classifier_table_params *params)
+{
+	int ret;
+
+	ret = spp_classifier_mac_iterate_table(params);
+	if (unlikely(ret != 0)) {
+		RTE_LOG(ERR, APP, "Cannot iterate classifier_mac_table.\n");
+		return SPP_RET_NG;
+	}
+
+	return SPP_RET_OK;
+}
+
+/* Get port number assigned by DPDK lib */
+static int
+spp_get_dpdk_port(enum port_type iface_type, int iface_no)
+{
+	switch (iface_type) {
+	case PHY:
+		return g_iface_info.nic[iface_no].dpdk_port;
+	case RING:
+		return g_iface_info.ring[iface_no].dpdk_port;
+	case VHOST:
+		return g_iface_info.vhost[iface_no].dpdk_port;
+	default:
+		return -1;
+	}
+}
+
 /* append a comma for JSON format */
 static int
 append_json_comma(char **output)
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index f086eaf..9095c73 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -373,393 +373,3 @@ main(int argc, char *argv[])
 	RTE_LOG(INFO, APP, "spp_vf exit.\n");
 	return ret;
 }
-
-int
-spp_get_client_id(void)
-{
-	return g_startup_param.client_id;
-}
-
-/*
- * Check if port has been flushed.
- */
-int
-spp_check_flush_port(enum port_type iface_type, int iface_no)
-{
-	struct spp_port_info *port = get_iface_info(iface_type, iface_no);
-	return port->dpdk_port >= 0;
-}
-
-int
-spp_update_classifier_table(
-		enum spp_command_action action,
-		enum spp_classifier_type type __attribute__ ((unused)),
-		int vid,
-		const char *mac_addr_str,
-		const struct spp_port_index *port)
-{
-	struct spp_port_info *port_info = NULL;
-	int64_t ret_mac = 0;
-	uint64_t mac_addr = 0;
-
-	RTE_LOG(DEBUG, APP, "update_classifier_table "
-			"( type = mac, mac addr = %s, port = %d:%d )\n",
-			mac_addr_str, port->iface_type, port->iface_no);
-
-	ret_mac = spp_change_mac_str_to_int64(mac_addr_str);
-	if (unlikely(ret_mac == -1)) {
-		RTE_LOG(ERR, APP, "MAC address format error. ( mac = %s )\n",
-				mac_addr_str);
-		return SPP_RET_NG;
-	}
-	mac_addr = (uint64_t)ret_mac;
-
-	port_info = get_iface_info(port->iface_type, port->iface_no);
-	if (unlikely(port_info == NULL)) {
-		RTE_LOG(ERR, APP, "No port. ( port = %d:%d )\n",
-				port->iface_type, port->iface_no);
-		return SPP_RET_NG;
-	}
-	if (unlikely(port_info->iface_type == UNDEF)) {
-		RTE_LOG(ERR, APP, "Port not added. ( port = %d:%d )\n",
-				port->iface_type, port->iface_no);
-		return SPP_RET_NG;
-	}
-
-	if (action == SPP_CMD_ACTION_DEL) {
-		/* Delete */
-		if ((port_info->class_id.vlantag.vid != 0) &&
-				unlikely(port_info->class_id.vlantag.vid !=
-				vid)) {
-			RTE_LOG(ERR, APP, "VLAN ID is different. "
-					"( vid = %d )\n", vid);
-			return SPP_RET_NG;
-		}
-		if ((port_info->class_id.mac_addr != 0) &&
-				unlikely(port_info->class_id.mac_addr !=
-						mac_addr)) {
-			RTE_LOG(ERR, APP, "MAC address is different. "
-					"( mac = %s )\n", mac_addr_str);
-			return SPP_RET_NG;
-		}
-
-		port_info->class_id.vlantag.vid = ETH_VLAN_ID_MAX;
-		port_info->class_id.mac_addr    = 0;
-		memset(port_info->class_id.mac_addr_str, 0x00,
-							SPP_MIN_STR_LEN);
-	} else if (action == SPP_CMD_ACTION_ADD) {
-		/* Setting */
-		if (unlikely(port_info->class_id.vlantag.vid !=
-				ETH_VLAN_ID_MAX)) {
-			RTE_LOG(ERR, APP, "Port in used. "
-					"( port = %d:%d, vlan = %d != %d )\n",
-					port->iface_type, port->iface_no,
-					port_info->class_id.vlantag.vid, vid);
-			return SPP_RET_NG;
-		}
-		if (unlikely(port_info->class_id.mac_addr != 0)) {
-			RTE_LOG(ERR, APP, "Port in used. "
-					"( port = %d:%d, mac = %s != %s )\n",
-					port->iface_type, port->iface_no,
-					port_info->class_id.mac_addr_str,
-					mac_addr_str);
-			return SPP_RET_NG;
-		}
-
-		port_info->class_id.vlantag.vid = vid;
-		port_info->class_id.mac_addr    = mac_addr;
-		strcpy(port_info->class_id.mac_addr_str, mac_addr_str);
-	}
-
-	set_component_change_port(port_info, SPP_PORT_RXTX_TX);
-	return SPP_RET_OK;
-}
-
-/* Component command to execute it */
-int
-spp_update_component(
-		enum spp_command_action action,
-		const char *name,
-		unsigned int lcore_id,
-		enum spp_component_type type)
-{
-	int ret = SPP_RET_NG;
-	int ret_del = -1;
-	int component_id = 0;
-	unsigned int tmp_lcore_id = 0;
-	struct spp_component_info *component = NULL;
-	struct core_info *core = NULL;
-	struct core_mng_info *info = NULL;
-
-	switch (action) {
-	case SPP_CMD_ACTION_START:
-		info = &g_core_info[lcore_id];
-		if (info->status == SPP_CORE_UNUSE) {
-			RTE_LOG(ERR, APP, "Core unavailable.\n");
-			return SPP_RET_NG;
-		}
-
-		component_id = spp_get_component_id(name);
-		if (component_id >= 0) {
-			RTE_LOG(ERR, APP, "Component name in used.\n");
-			return SPP_RET_NG;
-		}
-
-		component_id = get_free_component();
-		if (component_id < 0) {
-			RTE_LOG(ERR, APP, "Component upper limit is over.\n");
-			return SPP_RET_NG;
-		}
-
-		core = &info->core[info->upd_index];
-		if ((core->type != SPP_COMPONENT_UNUSE) &&
-				(core->type != type)) {
-			RTE_LOG(ERR, APP, "Component type is error.\n");
-			return SPP_RET_NG;
-		}
-
-		component = &g_component_info[component_id];
-		memset(component, 0x00, sizeof(struct spp_component_info));
-		strcpy(component->name, name);
-		component->type         = type;
-		component->lcore_id     = lcore_id;
-		component->component_id = component_id;
-
-		core->type = type;
-		core->id[core->num] = component_id;
-		core->num++;
-		ret = SPP_RET_OK;
-		tmp_lcore_id = lcore_id;
-		g_change_component[component_id] = 1;
-		break;
-
-	case SPP_CMD_ACTION_STOP:
-		component_id = spp_get_component_id(name);
-		if (component_id < 0)
-			return SPP_RET_OK;
-
-		component = &g_component_info[component_id];
-		tmp_lcore_id = component->lcore_id;
-		memset(component, 0x00, sizeof(struct spp_component_info));
-
-		info = &g_core_info[tmp_lcore_id];
-		core = &info->core[info->upd_index];
-		ret_del = del_component_info(component_id,
-				core->num, core->id);
-		if (ret_del >= 0)
-			/* If deleted, decrement number. */
-			core->num--;
-
-		if (core->num == 0)
-			core->type = SPP_COMPONENT_UNUSE;
-
-		ret = SPP_RET_OK;
-		g_change_component[component_id] = 0;
-		break;
-
-	default:
-		break;
-	}
-
-	g_change_core[tmp_lcore_id] = 1;
-	return ret;
-}
-
-/* Port add or del to execute it */
-int
-spp_update_port(enum spp_command_action action,
-		const struct spp_port_index *port,
-		enum spp_port_rxtx rxtx,
-		const char *name,
-		const struct spp_port_ability *ability)
-{
-	int ret = SPP_RET_NG;
-	int ret_check = -1;
-	int ret_del = -1;
-	int component_id = 0;
-	int cnt = 0;
-	struct spp_component_info *component = NULL;
-	struct spp_port_info *port_info = NULL;
-	int *num = NULL;
-	struct spp_port_info **ports = NULL;
-
-	component_id = spp_get_component_id(name);
-	if (component_id < 0) {
-		RTE_LOG(ERR, APP, "Unknown component by port command. "
-				"(component = %s)\n", name);
-		return SPP_RET_NG;
-	}
-
-	component = &g_component_info[component_id];
-	port_info = get_iface_info(port->iface_type, port->iface_no);
-	if (rxtx == SPP_PORT_RXTX_RX) {
-		num = &component->num_rx_port;
-		ports = component->rx_ports;
-	} else {
-		num = &component->num_tx_port;
-		ports = component->tx_ports;
-	}
-
-	switch (action) {
-	case SPP_CMD_ACTION_ADD:
-		ret_check = check_port_element(port_info, *num, ports);
-		if (ret_check >= 0)
-			return SPP_RET_OK;
-
-		if (*num >= RTE_MAX_ETHPORTS) {
-			RTE_LOG(ERR, APP, "Port upper limit is over.\n");
-			break;
-		}
-
-		if (ability->ope != SPP_PORT_ABILITY_OPE_NONE) {
-			while ((cnt < SPP_PORT_ABILITY_MAX) &&
-					(port_info->ability[cnt].ope !=
-					SPP_PORT_ABILITY_OPE_NONE)) {
-				cnt++;
-			}
-			if (cnt >= SPP_PORT_ABILITY_MAX) {
-				RTE_LOG(ERR, APP,
-						"No space of port ability.\n");
-				return SPP_RET_NG;
-			}
-			memcpy(&port_info->ability[cnt], ability,
-					sizeof(struct spp_port_ability));
-		}
-
-		port_info->iface_type = port->iface_type;
-		ports[*num] = port_info;
-		(*num)++;
-
-		ret = SPP_RET_OK;
-		break;
-
-	case SPP_CMD_ACTION_DEL:
-		for (cnt = 0; cnt < SPP_PORT_ABILITY_MAX; cnt++) {
-			if (port_info->ability[cnt].ope ==
-					SPP_PORT_ABILITY_OPE_NONE)
-				continue;
-
-			if (port_info->ability[cnt].rxtx == rxtx)
-				memset(&port_info->ability[cnt], 0x00,
-					sizeof(struct spp_port_ability));
-		}
-
-		ret_del = get_del_port_element(port_info, *num, ports);
-		if (ret_del == 0)
-			(*num)--; /* If deleted, decrement number. */
-
-		ret = SPP_RET_OK;
-		break;
-	default:
-		break;
-	}
-
-	g_change_component[component_id] = 1;
-	return ret;
-}
-
-/* Flush command to execute it */
-int
-spp_flush(void)
-{
-	int ret = -1;
-
-	/* Initial setting of each interface. */
-	ret = flush_port();
-	if (ret < 0)
-		return ret;
-
-	/* Flush of core index. */
-	flush_core();
-
-	/* Flush of component */
-	ret = flush_component();
-
-	backup_mng_info(&g_backup_info);
-	return ret;
-}
-
-/* Iterate core information */
-int
-spp_iterate_core_info(struct spp_iterate_core_params *params)
-{
-	int ret;
-	int lcore_id, cnt;
-	struct core_info *core = NULL;
-
-	RTE_LCORE_FOREACH_SLAVE(lcore_id) {
-		if (spp_get_core_status(lcore_id) == SPP_CORE_UNUSE)
-			continue;
-
-		core = get_core_info(lcore_id);
-		if (core->num == 0) {
-			ret = (*params->element_proc)(
-				params, lcore_id,
-				"", SPP_TYPE_UNUSE_STR,
-				0, NULL, 0, NULL);
-			if (unlikely(ret != 0)) {
-				RTE_LOG(ERR, APP, "Cannot iterate core "
-						"information. "
-						"(core = %d, type = %d)\n",
-						lcore_id, SPP_COMPONENT_UNUSE);
-				return SPP_RET_NG;
-			}
-			continue;
-		}
-
-		for (cnt = 0; cnt < core->num; cnt++) {
-			if (core->type == SPP_COMPONENT_CLASSIFIER_MAC) {
-				ret = spp_classifier_get_component_status(
-						lcore_id,
-						core->id[cnt],
-						params);
-			} else {
-				ret = spp_forward_get_component_status(
-						lcore_id,
-						core->id[cnt],
-						params);
-			}
-			if (unlikely(ret != 0)) {
-				RTE_LOG(ERR, APP, "Cannot iterate core "
-						"information. "
-						"(core = %d, type = %d)\n",
-						lcore_id, core->type);
-				return SPP_RET_NG;
-			}
-		}
-	}
-
-	return SPP_RET_OK;
-}
-
-/* Iterate Classifier_table */
-int
-spp_iterate_classifier_table(
-		struct spp_iterate_classifier_table_params *params)
-{
-	int ret;
-
-	ret = spp_classifier_mac_iterate_table(params);
-	if (unlikely(ret != 0)) {
-		RTE_LOG(ERR, APP, "Cannot iterate classifier_mac_table.\n");
-		return SPP_RET_NG;
-	}
-
-	return SPP_RET_OK;
-}
-
-/* Get the port number of DPDK. */
-int
-spp_get_dpdk_port(enum port_type iface_type, int iface_no)
-{
-	switch (iface_type) {
-	case PHY:
-		return g_iface_info.nic[iface_no].dpdk_port;
-	case RING:
-		return g_iface_info.ring[iface_no].dpdk_port;
-	case VHOST:
-		return g_iface_info.vhost[iface_no].dpdk_port;
-	default:
-		return -1;
-	}
-}
diff --git a/src/vf/spp_vf.h b/src/vf/spp_vf.h
index f540122..f7f08c8 100644
--- a/src/vf/spp_vf.h
+++ b/src/vf/spp_vf.h
@@ -15,137 +15,4 @@
 
 #include "common.h"
 
-/** The max number of client ID */
-#define SPP_CLIENT_MAX    128
-
-/**
- * Get client ID
- *
- * @return Client ID(0~127)
- */
-int spp_get_client_id(void);
-
-/**
- * Update Classifier_table
- *
- * @param action
- *  Action identifier (add or del)
- * @param type
- *  Classify type (currently only for mac)
- * @param data
- *  Value to be classified
- * @param port
- *  Destination port type and number
- *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
- */
-int spp_update_classifier_table(
-		enum spp_command_action action,
-		enum spp_classifier_type type,
-		int vid,
-		const char *mac,
-		const struct spp_port_index *port);
-
-/**
- * Update component
- *
- * @param action
- *  Action identifier (start or stop)
- * @param name
- *  Component name
- * @param lcore_id
- *  Logical core number
- * @param type
- *  Component type
- *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
- */
-int spp_update_component(
-		enum spp_command_action action,
-		const char *name, unsigned int lcore_id,
-		enum spp_component_type type);
-
-/**
- * Update port
- *
- * @param action
- *  Action identifier (add or del)
- * @param port
- *  Port type and number
- * @param rxtx
- *  rx/tx identifier
- * @param name
- *  Attached component name
- *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
- */
-int spp_update_port(
-		enum spp_command_action action,
-		const struct spp_port_index *port,
-		enum spp_port_rxtx rxtx,
-		const char *name,
-		const struct spp_port_ability *ability);
-
-/**
- * Flush SPP component
- *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
- */
-int spp_flush(void);
-
-/**
- * Iterate core information
- *
- * @param params
- *  The pointer to struct spp_iterate_core_params.@n
- *  The value for generating core information (status command).
- *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
- */
-int spp_iterate_core_info(struct spp_iterate_core_params *params);
-
-/**
- * Iterate Classifier_table
- *
- * @param params
- *  The pointer to struct spp_iterate_classifier_table_params.@n
- *  The value for generating classifier table.
- *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
- */
-int spp_iterate_classifier_table(
-		struct spp_iterate_classifier_table_params *params);
-
-/**
- * Check if port has been flushed.
- *
- * @param iface_type
- *  Interface to be validated.
- * @param iface_no
- *  Interface number to be validated.
- *
- * @return
- *  True if port has been flushed.
- */
-int spp_check_flush_port(enum port_type iface_type, int iface_no);
-
-/**
- * Get the port number of DPDK.
- *
- * @param iface_type
- *  Interface type obtained from port.
- * @param iface_no
- *  Interface number obtained from port.
- *
- * @return
- *  Port id generated by DPDK.
- */
-int spp_get_dpdk_port(enum port_type iface_type, int iface_no);
-
 #endif /* __SPP_VF_H__ */
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 10/23] spp_vf: add management data registration
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (8 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 09/23] spp_vf: move functions to command_proc.c x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 11/23] spp_vf: change reference of management data x-fn-spp
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

This patch adds the registration and retrieval functions of management
data to 'common/spp_proc.c'.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/spp_proc.c | 71 ++++++++++++++++++++++++++++++++++++++++
 src/vf/common/spp_proc.h | 58 ++++++++++++++++++++++++++++++++
 src/vf/spp_vf.c          | 13 ++++++++
 3 files changed, 142 insertions(+)

diff --git a/src/vf/common/spp_proc.c b/src/vf/common/spp_proc.c
index 7b92e38..5bb8571 100644
--- a/src/vf/common/spp_proc.c
+++ b/src/vf/common/spp_proc.c
@@ -17,7 +17,21 @@
 #include "../vf/spp_forward.h"
 #include "../vf/classifier_mac.h"
 
+/* Manage data to addoress */
+struct manage_data_addr_info {
+	struct startup_param	  *p_startup_param;
+	struct iface_info	  *p_iface_info;
+	struct spp_component_info *p_component_info;
+	struct core_mng_info	  *p_core_info;
+	int			  *p_change_core;
+	int			  *p_change_component;
+	struct cancel_backup_info *p_backup_info;
+	unsigned int		  main_lcore_id;
+};
+
 /* Declare global variables */
+/* Logical core ID for main process */
+static struct manage_data_addr_info g_mng_data_addr;
 
 /**
  * Make a hexdump of an array data in every 4 byte.
@@ -930,3 +944,60 @@ spp_change_mac_str_to_int64(const char *mac)
 			 mac, ret_mac);
 	return ret_mac;
 }
+
+/* Set mange data address */
+int spp_set_mng_data_addr(struct startup_param *startup_param_addr,
+			  struct iface_info *iface_addr,
+			  struct spp_component_info *component_addr,
+			  struct core_mng_info *core_mng_addr,
+			  int *change_core_addr,
+			  int *change_component_addr,
+			  struct cancel_backup_info *backup_info_addr,
+			  unsigned int main_lcore_id)
+{
+	if (startup_param_addr == NULL || iface_addr == NULL ||
+			component_addr == NULL || core_mng_addr == NULL ||
+			change_core_addr == NULL ||
+			change_component_addr == NULL ||
+			backup_info_addr == NULL ||
+			main_lcore_id == 0xffffffff)
+		return SPP_RET_NG;
+
+	g_mng_data_addr.p_startup_param = startup_param_addr;
+	g_mng_data_addr.p_iface_info = iface_addr;
+	g_mng_data_addr.p_component_info = component_addr;
+	g_mng_data_addr.p_core_info = core_mng_addr;
+	g_mng_data_addr.p_change_core = change_core_addr;
+	g_mng_data_addr.p_change_component = change_component_addr;
+	g_mng_data_addr.p_backup_info = backup_info_addr;
+	g_mng_data_addr.main_lcore_id = main_lcore_id;
+
+	return SPP_RET_OK;
+}
+
+/* Get manage data address */
+void spp_get_mng_data_addr(struct startup_param **startup_param_addr,
+			   struct iface_info **iface_addr,
+			   struct spp_component_info **component_addr,
+			   struct core_mng_info **core_mng_addr,
+			   int **change_core_addr,
+			   int **change_component_addr,
+			   struct cancel_backup_info **backup_info_addr)
+{
+
+	if (startup_param_addr != NULL)
+		*startup_param_addr = g_mng_data_addr.p_startup_param;
+	if (iface_addr != NULL)
+		*iface_addr = g_mng_data_addr.p_iface_info;
+	if (component_addr != NULL)
+		*component_addr = g_mng_data_addr.p_component_info;
+	if (core_mng_addr != NULL)
+		*core_mng_addr = g_mng_data_addr.p_core_info;
+	if (change_core_addr != NULL)
+		*change_core_addr = g_mng_data_addr.p_change_core;
+	if (change_component_addr != NULL)
+		*change_component_addr = g_mng_data_addr.p_change_component;
+	if (backup_info_addr != NULL)
+		*backup_info_addr = g_mng_data_addr.p_backup_info;
+
+}
diff --git a/src/vf/common/spp_proc.h b/src/vf/common/spp_proc.h
index f90b2ac..ce205d8 100644
--- a/src/vf/common/spp_proc.h
+++ b/src/vf/common/spp_proc.h
@@ -666,4 +666,62 @@ spp_format_port_string(char *port, enum port_type iface_type, int iface_no);
  */
 int64_t spp_change_mac_str_to_int64(const char *mac);
 
+/**
+ * Set mange data address
+ *
+ * @param startup_param_addr
+ *  g_startup_param address
+ * @param iface_addr
+ *  g_iface_info address
+ * @param component_addr
+ *  g_component_info address
+ * @param core_mng_addr
+ *  g_core_info address
+ * @param change_core_addr
+ *  g_change_core address
+ * @param change_component_addr
+ *  g_change_component address
+ * @param backup_info_addr
+ *  g_backup_info address
+ * @param main_lcore_id
+ *  main_lcore_id mask
+ *
+ * @retval SPP_RET_OK succeeded.
+ * @retval SPP_RET_NG failed.
+ */
+int spp_set_mng_data_addr(struct startup_param *startup_param_addr,
+			  struct iface_info *iface_addr,
+			  struct spp_component_info *component_addr,
+			  struct core_mng_info *core_mng_addr,
+			  int *change_core_addr,
+			  int *change_component_addr,
+			  struct cancel_backup_info *backup_info_addr,
+			  unsigned int main_lcore_id);
+
+/**
+ * Get mange data address
+ *
+ * @param iface_addr
+ *  g_startup_param write address
+ * @param iface_addr
+ *  g_iface_info write address
+ * @param component_addr
+ *  g_component_info write address
+ * @param core_mng_addr
+ *  g_core_mng_info write address
+ * @param change_core_addr
+ *  g_change_core write address
+ * @param change_component_addr
+ *  g_change_component write address
+ * @param backup_info_addr
+ *  g_backup_info write address
+ */
+void spp_get_mng_data_addr(struct startup_param **startup_param_addr,
+			   struct iface_info **iface_addr,
+			   struct spp_component_info **component_addr,
+			   struct core_mng_info **core_mng_addr,
+			   int **change_core_addr,
+			   int **change_component_addr,
+			   struct cancel_backup_info **backup_info_addr);
+
 #endif /* _SPP_PROC_H_ */
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index 9095c73..1433731 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -277,6 +277,19 @@ main(int argc, char *argv[])
 		/* Get lcore id of main thread to set its status after */
 		g_main_lcore_id = rte_lcore_id();
 
+		/* set manage address */
+		if (spp_set_mng_data_addr(&g_startup_param,
+					  &g_iface_info,
+					  g_component_info,
+					  g_core_info,
+					  g_change_core,
+					  g_change_component,
+					  &g_backup_info,
+					  g_main_lcore_id) < 0) {
+			RTE_LOG(ERR, APP, "manage address set is failed.\n");
+			break;
+		}
+
 		int ret_mng = init_mng_data();
 		if (unlikely(ret_mng != 0))
 			break;
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 11/23] spp_vf: change reference of management data
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (9 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 10/23] spp_vf: add management data registration x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 12/23] spp_vf: change return values to explain result x-fn-spp
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Change referring management data for previous update. Management data is
retrieved with `spp_get_mng_data_add()`.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/command_dec.c  |   5 +-
 src/vf/common/command_proc.c |  52 +++++++---
 src/vf/common/spp_proc.c     | 183 ++++++++++++++++++++---------------
 3 files changed, 147 insertions(+), 93 deletions(-)

diff --git a/src/vf/common/command_dec.c b/src/vf/common/command_dec.c
index 35066c2..1b08650 100644
--- a/src/vf/common/command_dec.c
+++ b/src/vf/common/command_dec.c
@@ -68,7 +68,10 @@ const char *PORT_ABILITY_STRINGS[] = {
 static enum spp_component_type
 spp_get_component_type_update(unsigned int lcore_id)
 {
-	struct core_mng_info *info = &g_core_info[lcore_id];
+	struct core_mng_info *core_info;
+
+	spp_get_mng_data_addr(NULL, NULL, NULL, &core_info, NULL, NULL, NULL);
+	struct core_mng_info *info = (core_info + lcore_id);
 	return info->core[info->upd_index].type;
 }
 
diff --git a/src/vf/common/command_proc.c b/src/vf/common/command_proc.c
index 02c41b6..d30acf3 100644
--- a/src/vf/common/command_proc.c
+++ b/src/vf/common/command_proc.c
@@ -88,7 +88,11 @@ const char *CLASSIFILER_TYPE_STATUS_STRINGS[] = {
 static int
 spp_get_client_id(void)
 {
-	return g_startup_param.client_id;
+	struct startup_param *startup_param;
+
+	spp_get_mng_data_addr(&startup_param,
+			NULL, NULL, NULL, NULL, NULL, NULL);
+	return startup_param->client_id;
 }
 
 /* Check if port has been flushed. */
@@ -204,10 +208,17 @@ spp_update_component(
 	struct spp_component_info *component = NULL;
 	struct core_info *core = NULL;
 	struct core_mng_info *info = NULL;
+	struct spp_component_info *component_info = NULL;
+	struct core_mng_info *core_info = NULL;
+	int *change_core = NULL;
+	int *change_component = NULL;
+
+	spp_get_mng_data_addr(NULL, NULL, &component_info, &core_info,
+				&change_core, &change_component, NULL);
 
 	switch (action) {
 	case SPP_CMD_ACTION_START:
-		info = &g_core_info[lcore_id];
+		info = (core_info + lcore_id);
 		if (info->status == SPP_CORE_UNUSE) {
 			RTE_LOG(ERR, APP, "Core %d is not available because "
 				"it is in SPP_CORE_UNUSE state.\n", lcore_id);
@@ -236,7 +247,7 @@ spp_update_component(
 			return SPP_RET_NG;
 		}
 
-		component = &g_component_info[component_id];
+		component = (component_info + component_id);
 		memset(component, 0x00, sizeof(struct spp_component_info));
 		strcpy(component->name, name);
 		component->type		= type;
@@ -248,7 +259,7 @@ spp_update_component(
 		core->num++;
 		ret = SPP_RET_OK;
 		tmp_lcore_id = lcore_id;
-		g_change_component[component_id] = 1;
+		*(change_component + component_id) = 1;
 		break;
 
 	case SPP_CMD_ACTION_STOP:
@@ -256,11 +267,11 @@ spp_update_component(
 		if (component_id < 0)
 			return SPP_RET_OK;
 
-		component = &g_component_info[component_id];
+		component = (component_info + component_id);
 		tmp_lcore_id = component->lcore_id;
 		memset(component, 0x00, sizeof(struct spp_component_info));
 
-		info = &g_core_info[tmp_lcore_id];
+		info = (core_info + tmp_lcore_id);
 		core = &info->core[info->upd_index];
 		ret_del = del_component_info(component_id,
 				core->num, core->id);
@@ -272,14 +283,14 @@ spp_update_component(
 			core->type = SPP_COMPONENT_UNUSE;
 
 		ret = SPP_RET_OK;
-		g_change_component[component_id] = 0;
+		*(change_component + component_id) = 0;
 		break;
 
 	default:
 		break;
 	}
 
-	g_change_core[tmp_lcore_id] = 1;
+	*(change_core + tmp_lcore_id) = 1;
 	return ret;
 }
 
@@ -300,6 +311,8 @@ spp_update_port(enum spp_command_action action,
 	struct spp_port_info *port_info = NULL;
 	int *num = NULL;
 	struct spp_port_info **ports = NULL;
+	struct spp_component_info *component_info = NULL;
+	int *change_component = NULL;
 
 	component_id = spp_get_component_id(name);
 	if (component_id < 0) {
@@ -308,7 +321,9 @@ spp_update_port(enum spp_command_action action,
 		return SPP_RET_NG;
 	}
 
-	component = &g_component_info[component_id];
+	spp_get_mng_data_addr(NULL, NULL,
+			&component_info, NULL, NULL, &change_component, NULL);
+	component = (component_info + component_id);
 	port_info = get_iface_info(port->iface_type, port->iface_no);
 	if (rxtx == SPP_PORT_RXTX_RX) {
 		num = &component->num_rx_port;
@@ -369,11 +384,12 @@ spp_update_port(enum spp_command_action action,
 
 		ret = SPP_RET_OK;
 		break;
+
 	default:
 		break;
 	}
 
-	g_change_component[component_id] = 1;
+	*(change_component + component_id) = 1;
 	return ret;
 }
 
@@ -382,6 +398,10 @@ static int
 spp_flush(void)
 {
 	int ret = -1;
+	struct cancel_backup_info *backup_info = NULL;
+
+	spp_get_mng_data_addr(NULL, NULL, NULL,
+				NULL, NULL, NULL, &backup_info);
 
 	/* Initial setting of each interface. */
 	ret = flush_port();
@@ -394,7 +414,7 @@ spp_flush(void)
 	/* Flush of component */
 	ret = flush_component();
 
-	backup_mng_info(&g_backup_info);
+	backup_mng_info(backup_info);
 	return ret;
 }
 
@@ -471,13 +491,17 @@ spp_iterate_classifier_table(
 static int
 spp_get_dpdk_port(enum port_type iface_type, int iface_no)
 {
+	struct iface_info *iface_info = NULL;
+
+	spp_get_mng_data_addr(NULL, &iface_info,
+				NULL, NULL, NULL, NULL, NULL);
 	switch (iface_type) {
 	case PHY:
-		return g_iface_info.nic[iface_no].dpdk_port;
+		return iface_info->nic[iface_no].dpdk_port;
 	case RING:
-		return g_iface_info.ring[iface_no].dpdk_port;
+		return iface_info->ring[iface_no].dpdk_port;
 	case VHOST:
-		return g_iface_info.vhost[iface_no].dpdk_port;
+		return iface_info->vhost[iface_no].dpdk_port;
 	default:
 		return -1;
 	}
diff --git a/src/vf/common/spp_proc.c b/src/vf/common/spp_proc.c
index 5bb8571..37179f5 100644
--- a/src/vf/common/spp_proc.c
+++ b/src/vf/common/spp_proc.c
@@ -64,6 +64,7 @@ dump_buff(const char *name, const void *addr, const size_t size)
 	}
 }
 
+/* generation of the ring port */
 int
 add_ring_pmd(int ring_id)
 {
@@ -85,6 +86,7 @@ add_ring_pmd(int ring_id)
 	return ring_port_id;
 }
 
+/* generation of the vhost port */
 int
 add_vhost_pmd(int index, int client)
 {
@@ -170,7 +172,7 @@ add_vhost_pmd(int index, int client)
 enum spp_core_status
 spp_get_core_status(unsigned int lcore_id)
 {
-	return g_core_info[lcore_id].status;
+	return (g_mng_data_addr.p_core_info + lcore_id)->status;
 }
 
 /**
@@ -184,7 +186,8 @@ check_core_status(enum spp_core_status status)
 {
 	unsigned int lcore_id = 0;
 	RTE_LCORE_FOREACH_SLAVE(lcore_id) {
-		if (g_core_info[lcore_id].status != status) {
+		if ((g_mng_data_addr.p_core_info + lcore_id)->status !=
+								status) {
 			/* Status is mismatched */
 			return -1;
 		}
@@ -212,7 +215,7 @@ void
 set_core_status(unsigned int lcore_id,
 		enum spp_core_status status)
 {
-	g_core_info[lcore_id].status = status;
+	(g_mng_data_addr.p_core_info + lcore_id)->status = status;
 }
 
 /* Set all core to given status */
@@ -221,7 +224,7 @@ set_all_core_status(enum spp_core_status status)
 {
 	unsigned int lcore_id = 0;
 	RTE_LCORE_FOREACH_SLAVE(lcore_id) {
-		g_core_info[lcore_id].status = status;
+		(g_mng_data_addr.p_core_info + lcore_id)->status = status;
 	}
 }
 
@@ -237,7 +240,8 @@ stop_process(int signal)
 		return;
 	}
 
-	g_core_info[g_main_lcore_id].status = SPP_CORE_STOP_REQUEST;
+	(g_mng_data_addr.p_core_info + g_mng_data_addr.main_lcore_id)->status =
+							SPP_CORE_STOP_REQUEST;
 	set_all_core_status(SPP_CORE_STOP_REQUEST);
 }
 
@@ -249,13 +253,15 @@ stop_process(int signal)
 struct spp_port_info *
 get_iface_info(enum port_type iface_type, int iface_no)
 {
+	struct iface_info *iface_info = g_mng_data_addr.p_iface_info;
+
 	switch (iface_type) {
 	case PHY:
-		return &g_iface_info.nic[iface_no];
+		return &iface_info->nic[iface_no];
 	case VHOST:
-		return &g_iface_info.vhost[iface_no];
+		return &iface_info->vhost[iface_no];
 	case RING:
-		return &g_iface_info.ring[iface_no];
+		return &iface_info->ring[iface_no];
 	default:
 		return NULL;
 	}
@@ -425,13 +431,19 @@ copy_mng_info(
 void
 backup_mng_info(struct cancel_backup_info *backup)
 {
-	dump_all_mng_info(g_core_info, g_component_info, &g_iface_info);
+	dump_all_mng_info(g_mng_data_addr.p_core_info,
+			g_mng_data_addr.p_component_info,
+			g_mng_data_addr.p_iface_info);
 	copy_mng_info(backup->core, backup->component, &backup->interface,
-			g_core_info, g_component_info, &g_iface_info,
+			g_mng_data_addr.p_core_info,
+			g_mng_data_addr.p_component_info,
+			g_mng_data_addr.p_iface_info,
 			COPY_MNG_FLG_ALLCOPY);
 	dump_all_mng_info(backup->core, backup->component, &backup->interface);
-	memset(g_change_core, 0x00, sizeof(g_change_core));
-	memset(g_change_component, 0x00, sizeof(g_change_component));
+	memset(g_mng_data_addr.p_change_core, 0x00,
+				sizeof(int)*RTE_MAX_LCORE);
+	memset(g_mng_data_addr.p_change_component, 0x00,
+				sizeof(int)*RTE_MAX_LCORE);
 }
 
 /**
@@ -443,79 +455,77 @@ static void
 init_iface_info(void)
 {
 	int port_cnt;  /* increment ether ports */
-	memset(&g_iface_info, 0x00, sizeof(g_iface_info));
+	struct iface_info *p_iface_info = g_mng_data_addr.p_iface_info;
+	memset(p_iface_info, 0x00, sizeof(struct iface_info));
 	for (port_cnt = 0; port_cnt < RTE_MAX_ETHPORTS; port_cnt++) {
-		g_iface_info.nic[port_cnt].iface_type = UNDEF;
-		g_iface_info.nic[port_cnt].iface_no   = port_cnt;
-		g_iface_info.nic[port_cnt].dpdk_port  = -1;
-		g_iface_info.nic[port_cnt].class_id.vlantag.vid =
+		p_iface_info->nic[port_cnt].iface_type = UNDEF;
+		p_iface_info->nic[port_cnt].iface_no   = port_cnt;
+		p_iface_info->nic[port_cnt].dpdk_port  = -1;
+		p_iface_info->nic[port_cnt].class_id.vlantag.vid =
 				ETH_VLAN_ID_MAX;
-		g_iface_info.vhost[port_cnt].iface_type = UNDEF;
-		g_iface_info.vhost[port_cnt].iface_no   = port_cnt;
-		g_iface_info.vhost[port_cnt].dpdk_port  = -1;
-		g_iface_info.vhost[port_cnt].class_id.vlantag.vid =
+		p_iface_info->vhost[port_cnt].iface_type = UNDEF;
+		p_iface_info->vhost[port_cnt].iface_no   = port_cnt;
+		p_iface_info->vhost[port_cnt].dpdk_port  = -1;
+		p_iface_info->vhost[port_cnt].class_id.vlantag.vid =
 				ETH_VLAN_ID_MAX;
-		g_iface_info.ring[port_cnt].iface_type = UNDEF;
-		g_iface_info.ring[port_cnt].iface_no   = port_cnt;
-		g_iface_info.ring[port_cnt].dpdk_port  = -1;
-		g_iface_info.ring[port_cnt].class_id.vlantag.vid =
+		p_iface_info->ring[port_cnt].iface_type = UNDEF;
+		p_iface_info->ring[port_cnt].iface_no   = port_cnt;
+		p_iface_info->ring[port_cnt].dpdk_port  = -1;
+		p_iface_info->ring[port_cnt].class_id.vlantag.vid =
 				ETH_VLAN_ID_MAX;
 	}
 }
 
-/**
- * Initialize g_component_info
- */
+/* Initialize g_component_info */
 static void
 init_component_info(void)
 {
 	int cnt;
-	memset(&g_component_info, 0x00, sizeof(g_component_info));
+	memset(g_mng_data_addr.p_component_info, 0x00,
+			sizeof(struct spp_component_info)*RTE_MAX_LCORE);
 	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++)
-		g_component_info[cnt].component_id = cnt;
-	memset(g_change_component, 0x00, sizeof(g_change_component));
+		(g_mng_data_addr.p_component_info + cnt)->component_id = cnt;
+	memset(g_mng_data_addr.p_change_component, 0x00,
+			sizeof(int)*RTE_MAX_LCORE);
 }
 
-/**
- * Initialize g_core_info
- */
+/* Initialize g_core_info */
 static void
 init_core_info(void)
 {
 	int cnt = 0;
-	memset(&g_core_info, 0x00, sizeof(g_core_info));
+	struct core_mng_info *p_core_info = g_mng_data_addr.p_core_info;
+	memset(p_core_info, 0x00,
+			sizeof(struct core_mng_info)*RTE_MAX_LCORE);
 	set_all_core_status(SPP_CORE_STOP);
 	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		g_core_info[cnt].ref_index = 0;
-		g_core_info[cnt].upd_index = 1;
+		(p_core_info + cnt)->ref_index = 0;
+		(p_core_info + cnt)->upd_index = 1;
 	}
-	memset(g_change_core, 0x00, sizeof(g_change_core));
+	memset(g_mng_data_addr.p_change_core, 0x00, sizeof(int)*RTE_MAX_LCORE);
 }
 
-/**
- * Setup port info of port on host
- */
+/* Setup port info of port on host */
 static int
 set_nic_interface(void)
 {
 	int nic_cnt = 0;
+	struct iface_info *p_iface_info = g_mng_data_addr.p_iface_info;
 
 	/* NIC Setting */
-	g_iface_info.num_nic = rte_eth_dev_count_avail();
-	if (g_iface_info.num_nic > RTE_MAX_ETHPORTS)
-		g_iface_info.num_nic = RTE_MAX_ETHPORTS;
+	p_iface_info->num_nic = rte_eth_dev_count_avail();
+	if (p_iface_info->num_nic > RTE_MAX_ETHPORTS)
+		p_iface_info->num_nic = RTE_MAX_ETHPORTS;
 
-	for (nic_cnt = 0; nic_cnt < g_iface_info.num_nic; nic_cnt++) {
-		g_iface_info.nic[nic_cnt].iface_type   = PHY;
-		g_iface_info.nic[nic_cnt].dpdk_port = nic_cnt;
+	for (nic_cnt = 0; nic_cnt < p_iface_info->num_nic; nic_cnt++) {
+		p_iface_info->nic[nic_cnt].iface_type   = PHY;
+		p_iface_info->nic[nic_cnt].dpdk_port = nic_cnt;
 	}
 
 	return 0;
 }
 
-/**
- * Setup management info for spp_vf
- */
+/* Setup management info for spp_vf */
 int
 init_mng_data(void)
 {
@@ -532,9 +542,7 @@ init_mng_data(void)
 }
 
 #ifdef SPP_RINGLATENCYSTATS_ENABLE
-/**
- * Print statistics of time for packet processing in ring interface
- */
+/* Print statistics of time for packet processing in ring interface */
 static void
 print_ring_latency_stats(void)
 {
@@ -547,10 +555,11 @@ print_ring_latency_stats(void)
 	struct spp_ringlatencystats_ring_latency_stats stats[RTE_MAX_ETHPORTS];
 	memset(&stats, 0x00, sizeof(stats));
 
+	struct iface_info *p_iface_info = g_mng_data_addr.p_iface_info;
 	printf("RING Latency\n");
 	printf(" RING");
 	for (ring_cnt = 0; ring_cnt < RTE_MAX_ETHPORTS; ring_cnt++) {
-		if (g_iface_info.ring[ring_cnt].iface_type == UNDEF)
+		if (p_iface_info->ring[ring_cnt].iface_type == UNDEF)
 			continue;
 
 		spp_ringlatencystats_get_stats(ring_cnt, &stats[ring_cnt]);
@@ -562,7 +571,7 @@ print_ring_latency_stats(void)
 			stats_cnt++) {
 		printf("%3dns", stats_cnt);
 		for (ring_cnt = 0; ring_cnt < RTE_MAX_ETHPORTS; ring_cnt++) {
-			if (g_iface_info.ring[ring_cnt].iface_type == UNDEF)
+			if (p_iface_info->ring[ring_cnt].iface_type == UNDEF)
 				continue;
 
 			printf(", 0x%-16lx", stats[ring_cnt].slot[stats_cnt]);
@@ -579,7 +588,7 @@ del_vhost_sockfile(struct spp_port_info *vhost)
 	int cnt;
 
 	/* Do not remove for if it is running in vhost-client mode. */
-	if (g_startup_param.vhost_client != 0)
+	if (g_mng_data_addr.p_startup_param->vhost_client != 0)
 		return;
 
 	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
@@ -596,7 +605,7 @@ del_vhost_sockfile(struct spp_port_info *vhost)
 enum spp_component_type
 spp_get_component_type(unsigned int lcore_id)
 {
-	struct core_mng_info *info = &g_core_info[lcore_id];
+	struct core_mng_info *info = (g_mng_data_addr.p_core_info + lcore_id);
 	return info->core[info->ref_index].type;
 }
 
@@ -604,7 +613,8 @@ spp_get_component_type(unsigned int lcore_id)
 unsigned int
 spp_get_component_core(int component_id)
 {
-	struct spp_component_info *info = &g_component_info[component_id];
+	struct spp_component_info *info =
+			(g_mng_data_addr.p_component_info + component_id);
 	return info->lcore_id;
 }
 
@@ -612,7 +622,7 @@ spp_get_component_core(int component_id)
 struct core_info *
 get_core_info(unsigned int lcore_id)
 {
-	struct core_mng_info *info = &g_core_info[lcore_id];
+	struct core_mng_info *info = (g_mng_data_addr.p_core_info + lcore_id);
 	return &(info->core[info->ref_index]);
 }
 
@@ -620,13 +630,14 @@ get_core_info(unsigned int lcore_id)
 int
 spp_check_core_update(unsigned int lcore_id)
 {
-	struct core_mng_info *info = &g_core_info[lcore_id];
+	struct core_mng_info *info = (g_mng_data_addr.p_core_info + lcore_id);
 	if (info->ref_index == info->upd_index)
 		return SPP_RET_OK;
 	else
 		return SPP_RET_NG;
 }
 
+/* Check if component is using port. */
 int
 spp_check_used_port(
 		enum port_type iface_type,
@@ -637,12 +648,14 @@ spp_check_used_port(
 	struct spp_component_info *component = NULL;
 	struct spp_port_info **port_array = NULL;
 	struct spp_port_info *port = get_iface_info(iface_type, iface_no);
+	struct spp_component_info *component_info =
+					g_mng_data_addr.p_component_info;
 
 	if (port == NULL)
 		return SPP_RET_NG;
 
 	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		component = &g_component_info[cnt];
+		component = (component_info + cnt);
 		if (component->type == SPP_COMPONENT_UNUSE)
 			continue;
 
@@ -671,14 +684,14 @@ set_component_change_port(struct spp_port_info *port, enum spp_port_rxtx rxtx)
 		ret = spp_check_used_port(port->iface_type, port->iface_no,
 				SPP_PORT_RXTX_RX);
 		if (ret >= 0)
-			g_change_component[ret] = 1;
+			*(g_mng_data_addr.p_change_component + ret) = 1;
 	}
 
 	if ((rxtx == SPP_PORT_RXTX_TX) || (rxtx == SPP_PORT_RXTX_ALL)) {
 		ret = spp_check_used_port(port->iface_type, port->iface_no,
 				SPP_PORT_RXTX_TX);
 		if (ret >= 0)
-			g_change_component[ret] = 1;
+			*(g_mng_data_addr.p_change_component + ret) = 1;
 	}
 }
 
@@ -686,9 +699,12 @@ set_component_change_port(struct spp_port_info *port, enum spp_port_rxtx rxtx)
 int
 get_free_component(void)
 {
+	struct spp_component_info *component_info =
+					g_mng_data_addr.p_component_info;
+
 	int cnt = 0;
 	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		if (g_component_info[cnt].type == SPP_COMPONENT_UNUSE)
+		if ((component_info + cnt)->type == SPP_COMPONENT_UNUSE)
 			return cnt;
 	}
 	return -1;
@@ -698,12 +714,15 @@ get_free_component(void)
 int
 spp_get_component_id(const char *name)
 {
+	struct spp_component_info *component_info =
+					g_mng_data_addr.p_component_info;
+
 	int cnt = 0;
 	if (name[0] == '\0')
 		return SPP_RET_NG;
 
 	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		if (strcmp(name, g_component_info[cnt].name) == 0)
+		if (strcmp(name, (component_info + cnt)->name) == 0)
 			return cnt;
 	}
 	return SPP_RET_NG;
@@ -785,13 +804,14 @@ flush_port(void)
 	int ret = 0;
 	int cnt = 0;
 	struct spp_port_info *port = NULL;
+	struct iface_info *p_iface_info = g_mng_data_addr.p_iface_info;
 
 	/* Initialize added vhost. */
 	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
-		port = &g_iface_info.vhost[cnt];
+		port = &p_iface_info->vhost[cnt];
 		if ((port->iface_type != UNDEF) && (port->dpdk_port < 0)) {
 			ret = add_vhost_pmd(port->iface_no,
-					g_startup_param.vhost_client);
+				g_mng_data_addr.p_startup_param->vhost_client);
 			if (ret < 0)
 				return SPP_RET_NG;
 			port->dpdk_port = ret;
@@ -800,7 +820,7 @@ flush_port(void)
 
 	/* Initialize added ring. */
 	for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
-		port = &g_iface_info.ring[cnt];
+		port = &p_iface_info->ring[cnt];
 		if ((port->iface_type != UNDEF) && (port->dpdk_port < 0)) {
 			ret = add_ring_pmd(port->iface_no);
 			if (ret < 0)
@@ -817,19 +837,21 @@ flush_core(void)
 {
 	int cnt = 0;
 	struct core_mng_info *info = NULL;
+	struct core_mng_info *p_core_info = g_mng_data_addr.p_core_info;
+	int *p_change_core = g_mng_data_addr.p_change_core;
 
 	/* Changed core has changed index. */
 	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		if (g_change_core[cnt] != 0) {
-			info = &g_core_info[cnt];
+		if (*(p_change_core + cnt) != 0) {
+			info = (p_core_info + cnt);
 			info->upd_index = info->ref_index;
 		}
 	}
 
 	/* Waiting for changed core change. */
 	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		if (g_change_core[cnt] != 0) {
-			info = &g_core_info[cnt];
+		if (*(p_change_core + cnt) != 0) {
+			info = (p_core_info + cnt);
 			while (likely(info->ref_index == info->upd_index))
 				rte_delay_us_block(SPP_CHANGE_UPDATE_INTERVAL);
 
@@ -847,19 +869,26 @@ flush_component(void)
 	int ret = 0;
 	int cnt = 0;
 	struct spp_component_info *component_info = NULL;
+	int *p_change_component = g_mng_data_addr.p_change_component;
+	struct spp_component_info *p_component_info =
+					g_mng_data_addr.p_component_info;
 
 	for (cnt = 0; cnt < RTE_MAX_LCORE; cnt++) {
-		if (g_change_component[cnt] == 0)
+		if (*(p_change_component + cnt) == 0)
 			continue;
 
-		component_info = &g_component_info[cnt];
+		component_info = (p_component_info + cnt);
 		spp_port_ability_update(component_info);
 
+#ifdef SPP_VF_MODULE
 		if (component_info->type == SPP_COMPONENT_CLASSIFIER_MAC)
 			ret = spp_classifier_mac_update(component_info);
 		else
 			ret = spp_forward_update(component_info);
-
+#endif /* SPP_VF_MODULE */
+#ifdef SPP_MIRROR_MODULE
+		ret = spp_mirror_update(component_info);
+#endif /* SPP_MIRROR_MODULE */
 		if (unlikely(ret < 0)) {
 			RTE_LOG(ERR, APP, "Flush error. "
 					"( component = %s, type = %d)\n",
@@ -898,9 +927,7 @@ int spp_format_port_string(char *port, enum port_type iface_type, int iface_no)
 	return 0;
 }
 
-/**
- * Change mac address of 'aa:bb:cc:dd:ee:ff' to int64 and return it
- */
+/* Change mac address of 'aa:bb:cc:dd:ee:ff' to int64 and return it */
 int64_t
 spp_change_mac_str_to_int64(const char *mac)
 {
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 12/23] spp_vf: change return values to explain result
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (10 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 11/23] spp_vf: change reference of management data x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 13/23] spp_vf: define terms of commands as consts x-fn-spp
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Change to use SPP_RET_OK and SPP_RET_NG instead of 0 or -1 as a returned
value to explain a result of a function.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/classifier_mac.c          |  42 +++----
 src/vf/classifier_mac.h          |  20 +--
 src/vf/common/command_conn.c     |  16 +--
 src/vf/common/command_conn.h     |  14 +--
 src/vf/common/command_dec.c      | 166 ++++++++++++-------------
 src/vf/common/command_dec.h      |   2 +-
 src/vf/common/command_proc.c     | 206 +++++++++++++++----------------
 src/vf/common/command_proc.h     |   8 +-
 src/vf/common/ringlatencystats.c |   4 +-
 src/vf/common/ringlatencystats.h |   4 +-
 src/vf/common/spp_port.c         |  16 +--
 src/vf/common/spp_proc.c         |  40 +++---
 src/vf/common/spp_proc.h         |   6 +-
 src/vf/spp_forward.c             |  18 +--
 src/vf/spp_forward.h             |  12 +-
 src/vf/spp_vf.c                  |  58 ++++-----
 16 files changed, 317 insertions(+), 315 deletions(-)

diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index 4016ab1..42e43dc 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -355,7 +355,7 @@ static int
 init_component_info(struct component_info *cmp_info,
 		const struct spp_component_info *component_info)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int i;
 	struct mac_classification *mac_cls;
 	struct ether_addr eth_addr;
@@ -408,7 +408,7 @@ init_component_info(struct component_info *cmp_info,
 					create_mac_classification();
 			if (unlikely(cmp_info->mac_classifications[vid] ==
 					NULL))
-				return -1;
+				return SPP_RET_NG;
 		}
 		mac_cls = cmp_info->mac_classifications[vid];
 
@@ -445,7 +445,7 @@ init_component_info(struct component_info *cmp_info,
 					"table. ret=%d, vid=%hu, "
 					"mac_addr=%s\n",
 					ret, vid, mac_addr_str);
-			return -1;
+			return SPP_RET_NG;
 		}
 
 		RTE_LOG(INFO, SPP_CLASSIFIER_MAC,
@@ -459,14 +459,14 @@ init_component_info(struct component_info *cmp_info,
 				tx_port->dpdk_port);
 	}
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* initialize classifier. */
 static int
 init_classifier(struct management_info *mng_info)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	struct spp_component_info component_info;
 
 	memset(mng_info, 0, sizeof(struct management_info));
@@ -490,18 +490,18 @@ init_classifier(struct management_info *mng_info)
 	/* populate the classifier information at reference */
 	ret = init_component_info(&mng_info->
 			cmp_infos[mng_info->ref_index], &component_info);
-	if (unlikely(ret != 0)) {
+	if (unlikely(ret != SPP_RET_OK)) {
 		RTE_LOG(ERR, SPP_CLASSIFIER_MAC,
 				"Cannot initialize classifier mac table. "
 				"ret=%d\n", ret);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	/* updating side can be set by completion of initialization. */
 	mng_info->upd_index = mng_info->ref_index + 1;
 	mng_info->is_used = 1;
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* free mac classification instance. */
@@ -618,7 +618,7 @@ get_general_default_classified_index(struct component_info *cmp_info)
 	if (unlikely(mac_cls == NULL)) {
 		LOG_DBG(cmp_info->name, "Untagged's default is not set. "
 				"vid=%d\n", (int)VLAN_UNTAGGED_VID);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	return mac_cls->default_classified;
@@ -800,7 +800,7 @@ spp_classifier_mac_init(void)
 int
 spp_classifier_mac_update(struct spp_component_info *component_info)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int id = component_info->component_id;
 	struct management_info *mng_info = g_mng_infos + id;
 	struct component_info *cmp_info = NULL;
@@ -817,7 +817,7 @@ spp_classifier_mac_update(struct spp_component_info *component_info)
 
 	/* initialize update side classifier information */
 	ret = init_component_info(cmp_info, component_info);
-	if (unlikely(ret != 0)) {
+	if (unlikely(ret != SPP_RET_OK)) {
 		RTE_LOG(ERR, SPP_CLASSIFIER_MAC,
 				"Cannot update classifier mac. ret=%d\n", ret);
 		return ret;
@@ -838,14 +838,14 @@ spp_classifier_mac_update(struct spp_component_info *component_info)
 	RTE_LOG(INFO, SPP_CLASSIFIER_MAC,
 			"Component[%u] Complete update component.\n", id);
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* classifier(mac address) thread function. */
 int
 spp_classifier_mac_do(int id)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int i;
 	int n_rx;
 	unsigned int lcore_id = rte_lcore_id();
@@ -862,7 +862,7 @@ spp_classifier_mac_do(int id)
 
 	/* initialize */
 	ret = init_classifier(mng_info);
-	if (unlikely(ret != 0)) {
+	if (unlikely(ret != SPP_RET_OK)) {
 		uninit_classifier(mng_info);
 		return ret;
 	}
@@ -917,7 +917,7 @@ spp_classifier_mac_do(int id)
 	/* uninitialize */
 	uninit_classifier(mng_info);
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* classifier iterate component information */
@@ -926,7 +926,7 @@ spp_classifier_get_component_status(
 		unsigned int lcore_id, int id,
 		struct spp_iterate_core_params *params)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int i, num_tx, num_rx = 0;
 	struct management_info *mng_info;
 	struct component_info *cmp_info;
@@ -940,7 +940,7 @@ spp_classifier_get_component_status(
 				"Component[%d] Not used. "
 				"(status)(core = %d, type = %d)\n",
 				id, lcore_id, SPP_COMPONENT_CLASSIFIER_MAC);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	cmp_info = mng_info->cmp_infos + mng_info->ref_index;
@@ -967,10 +967,10 @@ spp_classifier_get_component_status(
 		params, lcore_id,
 		cmp_info->name, SPP_TYPE_CLASSIFIER_MAC_STR,
 		num_rx, rx_ports, num_tx, tx_ports);
-	if (unlikely(ret != 0))
-		return -1;
+	if (unlikely(ret != SPP_RET_OK))
+		return SPP_RET_NG;
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 static void
@@ -1071,5 +1071,5 @@ spp_classifier_mac_iterate_table(
 		}
 	}
 
-	return 0;
+	return SPP_RET_OK;
 }
diff --git a/src/vf/classifier_mac.h b/src/vf/classifier_mac.h
index 2a97dc5..ba25e75 100644
--- a/src/vf/classifier_mac.h
+++ b/src/vf/classifier_mac.h
@@ -22,8 +22,8 @@ struct spp_iterate_classifier_table_params;
 /**
  * classifier(mac address) initialize globals.
  *
- * @retval 0  succeeded.
- * @retval -1 failed.
+ * @retval SPP_RET_OK succeeded.
+ * @retval SPP_RET_NG failed.
  */
 int spp_classifier_mac_init(void);
 
@@ -34,8 +34,8 @@ int spp_classifier_mac_init(void);
  *  The pointer to struct spp_component_info.@n
  *  The data for updating the internal data of classifier.
  *
- * @retval 0  succeeded.
- * @retval -1 failed.
+ * @retval SPP_RET_OK succeeded.
+ * @retval SPP_RET_NG failed.
  */
 int spp_classifier_mac_update(struct spp_component_info *component_info);
 
@@ -45,8 +45,8 @@ int spp_classifier_mac_update(struct spp_component_info *component_info);
  * @param id
  *  The unique component ID.
  *
- * @retval 0  succeeded.
- * @retval -1 failed.
+ * @retval SPP_RET_OK succeeded.
+ * @retval SPP_RET_NG failed.
  */
 int spp_classifier_mac_do(int id);
 
@@ -62,8 +62,8 @@ int spp_classifier_mac_do(int id);
  *  The pointer to struct spp_iterate_core_params.@n
  *  Detailed data of classifier status.
  *
- * @retval 0  succeeded.
- * @retval -1 failed.
+ * @retval SPP_RET_OK succeeded.
+ * @retval SPP_RET_NG failed.
  */
 int
 spp_classifier_get_component_status(unsigned int lcore_id, int id,
@@ -76,8 +76,8 @@ spp_classifier_get_component_status(unsigned int lcore_id, int id,
  *  Point to struct spp_iterate_classifier_table_params.@n
  *  Detailed data of classifier table.
  *
- * @retval 0  succeeded.
- * @retval -1 failed.
+ * @retval SPP_RET_OK succeeded.
+ * @retval SPP_RET_NG failed.
  */
 int spp_classifier_mac_iterate_table(
 		struct spp_iterate_classifier_table_params *params);
diff --git a/src/vf/common/command_conn.c b/src/vf/common/command_conn.c
index 4c3de54..a72180a 100644
--- a/src/vf/common/command_conn.c
+++ b/src/vf/common/command_conn.c
@@ -33,7 +33,7 @@ spp_command_conn_init(const char *controller_ip, int controller_port)
 	strcpy(g_controller_ip, controller_ip);
 	g_controller_port = controller_port;
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* connect to controller */
@@ -41,11 +41,11 @@ int
 spp_connect_to_controller(int *sock)
 {
 	static struct sockaddr_in controller_addr;
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int sock_flg = 0;
 
 	if (likely(*sock >= 0))
-		return 0;
+		return SPP_RET_OK;
 
 	/* create socket */
 	RTE_LOG(INFO, SPP_COMMAND_PROC, "Creating socket...\n");
@@ -81,14 +81,14 @@ spp_connect_to_controller(int *sock)
 	sock_flg = fcntl(*sock, F_GETFL, 0);
 	fcntl(*sock, F_SETFL, sock_flg | O_NONBLOCK);
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* receive message */
 int
 spp_receive_message(int *sock, char **strbuf)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int n_rx = 0;
 	char *new_strbuf = NULL;
 
@@ -105,7 +105,7 @@ spp_receive_message(int *sock, char **strbuf)
 					"Receive failure. errno=%d\n", errno);
 		} else {
 			/* no receive message */
-			return 0;
+			return SPP_RET_OK;
 		}
 
 		RTE_LOG(INFO, SPP_COMMAND_PROC, "Assume Server closed "
@@ -134,7 +134,7 @@ spp_receive_message(int *sock, char **strbuf)
 int
 spp_send_message(int *sock, const char *message, size_t message_len)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 
 	ret = send(*sock, message, message_len, 0);
 	if (unlikely(ret == -1)) {
@@ -144,5 +144,5 @@ spp_send_message(int *sock, const char *message, size_t message_len)
 		return SPP_CONNERR_TEMPORARY;
 	}
 
-	return 0;
+	return SPP_RET_OK;
 }
diff --git a/src/vf/common/command_conn.h b/src/vf/common/command_conn.h
index ce2f56c..3e56570 100644
--- a/src/vf/common/command_conn.h
+++ b/src/vf/common/command_conn.h
@@ -25,8 +25,8 @@
  * @param controller_port
  *  The controller's port number.
  *
- * @retval 0  succeeded.
- * @retval -1 failed.
+ * @retval SPP_RET_OK  succeeded.
+ * @retval SPP_RET_NG failed.
  */
 int spp_command_conn_init(const char *controller_ip, int controller_port);
 
@@ -38,7 +38,7 @@ int spp_command_conn_init(const char *controller_ip, int controller_port);
  * @param sock
  *  Socket number for connecting to controller.
  *
- * @retval 0                     succeeded.
+ * @retval SPP_RET_OK		 succeeded.
  * @retval SPP_CONNERR_TEMPORARY temporary error. please retry.
  */
 int spp_connect_to_controller(int *sock);
@@ -53,10 +53,10 @@ int spp_connect_to_controller(int *sock);
  * @param msgbuf
  *  The pointer to command message buffer.
  *
- * @retval 0 <                   succeeded. number of bytes received.
- * @retval 0                     no receive message.
+ * @retval 0 <			 succeeded. number of bytes received.
+ * @retval SPP_RET_OK		 no receive message.
  * @retval SPP_CONNERR_TEMPORARY temporary error. please reconnect.
- * @retval SPP_CONNERR_FATAL    fatal error occurred. should terminate process.
+ * @retval SPP_CONNERR_FATAL	fatal error occurred. should terminate process.
  */
 int spp_receive_message(int *sock, char **msgbuf);
 
@@ -72,7 +72,7 @@ int spp_receive_message(int *sock, char **msgbuf);
  * @param message_len
  *  The length of message.
  *
- * @retval 0                     succeeded.
+ * @retval SPP_RET_OK		 succeeded.
  * @retval SPP_CONNERR_TEMPORARY temporary error. please reconnect.
  */
 int spp_send_message(int *sock, const char *message, size_t message_len);
diff --git a/src/vf/common/command_dec.c b/src/vf/common/command_dec.c
index 1b08650..7cebbb5 100644
--- a/src/vf/common/command_dec.c
+++ b/src/vf/common/command_dec.c
@@ -134,7 +134,7 @@ spp_convert_port_to_iface(const char *port,
 		/* OTHER */
 		RTE_LOG(ERR, APP, "Unknown interface type. (port = %s)\n",
 				port);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	/* Change type of number of interface */
@@ -142,7 +142,7 @@ spp_convert_port_to_iface(const char *port,
 	if (unlikely(no_str == endptr) || unlikely(*endptr != '\0')) {
 		/* No IF number */
 		RTE_LOG(ERR, APP, "No interface number. (port = %s)\n", port);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	*iface_type = type;
@@ -150,7 +150,7 @@ spp_convert_port_to_iface(const char *port,
 
 	RTE_LOG(DEBUG, APP, "Port = %s => Type = %d No = %d\n",
 			port, *iface_type, *iface_no);
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* Convert component name to component type */
@@ -207,14 +207,14 @@ decode_parameter_value(char *string, int max, int *argc, char *argv[])
 	argv_tok = strtok_r(string, delim, &saveptr);
 	while (argv_tok != NULL) {
 		if (cnt >= max)
-			return -1;
+			return SPP_RET_NG;
 		argv[cnt] = argv_tok;
 		cnt++;
 		argv_tok = strtok_r(NULL, delim, &saveptr);
 	}
 	*argc = cnt;
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* Get index of array */
@@ -226,7 +226,7 @@ get_arrary_index(const char *match, const char *list[])
 		if (strcmp(list[i], match) == 0)
 			return i;
 	}
-	return -1;
+	return SPP_RET_NG;
 }
 
 /* Get int type value */
@@ -241,13 +241,13 @@ get_int_value(
 	char *endptr = NULL;
 	ret = strtol(arg_val, &endptr, 0);
 	if (unlikely(endptr == arg_val) || unlikely(*endptr != '\0'))
-		return -1;
+		return SPP_RET_NG;
 
 	if (unlikely(ret < min) || unlikely(ret > max))
-		return -1;
+		return SPP_RET_NG;
 
 	*output = ret;
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* Get unsigned int type value */
@@ -258,17 +258,17 @@ get_uint_value(
 		unsigned int min,
 		unsigned int max)
 {
-	unsigned int ret = 0;
+	unsigned int ret = SPP_RET_OK;
 	char *endptr = NULL;
 	ret = strtoul(arg_val, &endptr, 0);
 	if (unlikely(endptr == arg_val) || unlikely(*endptr != '\0'))
-		return -1;
+		return SPP_RET_NG;
 
 	if (unlikely(ret < min) || unlikely(ret > max))
-		return -1;
+		return SPP_RET_NG;
 
 	*output = ret;
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* decoding procedure of string */
@@ -276,54 +276,54 @@ static int
 decode_str_value(char *output, const char *arg_val)
 {
 	if (strlen(arg_val) >= SPP_CMD_VALUE_BUFSZ)
-		return -1;
+		return SPP_RET_NG;
 
 	strcpy(output, arg_val);
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* decoding procedure of port */
 static int
 decode_port_value(void *output, const char *arg_val)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	struct spp_port_index *port = output;
 	ret = spp_convert_port_to_iface(arg_val, &port->iface_type,
 							&port->iface_no);
 	if (unlikely(ret != 0)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC, "Bad port. val=%s\n", arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* decoding procedure of core */
 static int
 decode_core_value(void *output, const char *arg_val)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	ret = get_uint_value(output, arg_val, 0, RTE_MAX_LCORE-1);
 	if (unlikely(ret < 0)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC, "Bad core id. val=%s\n",
 				arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* decoding procedure of action for component command */
 static int
 decode_component_action_value(void *output, const char *arg_val)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	ret = get_arrary_index(arg_val, COMMAND_ACTION_STRINGS);
 	if (unlikely(ret <= 0)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Unknown component action. val=%s\n",
 				arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	if (unlikely(ret != SPP_CMD_ACTION_START) &&
@@ -331,18 +331,18 @@ decode_component_action_value(void *output, const char *arg_val)
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Unknown component action. val=%s\n",
 				arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	*(int *)output = ret;
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* decoding procedure of action for component command */
 static int
 decode_component_name_value(void *output, const char *arg_val)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	struct spp_command_component *component = output;
 
 	/* "stop" has no core ID parameter. */
@@ -352,7 +352,7 @@ decode_component_name_value(void *output, const char *arg_val)
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
 					"Component name in used. val=%s\n",
 					arg_val);
-			return -1;
+			return SPP_RET_NG;
 		}
 	}
 
@@ -367,7 +367,7 @@ decode_component_core_value(void *output, const char *arg_val)
 
 	/* "stop" has no core ID parameter. */
 	if (component->action != SPP_CMD_ACTION_START)
-		return 0;
+		return SPP_RET_OK;
 
 	return decode_core_value(&component->core, arg_val);
 }
@@ -381,14 +381,14 @@ decode_component_type_value(void *output, const char *arg_val)
 
 	/* "stop" has no type parameter. */
 	if (component->action != SPP_CMD_ACTION_START)
-		return 0;
+		return SPP_RET_OK;
 
 	set_type = spp_convert_component_type(arg_val);
 	if (unlikely(set_type <= 0)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Unknown component type. val=%s\n",
 				arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	org_type = spp_get_component_type_update(component->core);
@@ -397,24 +397,24 @@ decode_component_type_value(void *output, const char *arg_val)
 				"Component type does not match. "
 				"val=%s (org=%d, new=%d)\n",
 				arg_val, org_type, set_type);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	component->type = set_type;
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* decoding procedure of action for port command */
 static int
 decode_port_action_value(void *output, const char *arg_val)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	ret = get_arrary_index(arg_val, COMMAND_ACTION_STRINGS);
 	if (unlikely(ret <= 0)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Unknown port action. val=%s\n",
 				arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	if (unlikely(ret != SPP_CMD_ACTION_ADD) &&
@@ -422,24 +422,24 @@ decode_port_action_value(void *output, const char *arg_val)
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Unknown port action. val=%s\n",
 				arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	*(int *)output = ret;
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* decoding procedure of port for port command */
 static int
 decode_port_port_value(void *output, const char *arg_val)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	struct spp_port_index tmp_port;
 	struct spp_command_port *port = output;
 
 	ret = decode_port_value(&tmp_port, arg_val);
-	if (ret < 0)
-		return -1;
+	if (ret < SPP_RET_OK)
+		return SPP_RET_NG;
 
 	if ((port->action == SPP_CMD_ACTION_ADD) &&
 			(spp_check_used_port(tmp_port.iface_type,
@@ -451,26 +451,26 @@ decode_port_port_value(void *output, const char *arg_val)
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Port in used. (port command) val=%s\n",
 				arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	port->port.iface_type = tmp_port.iface_type;
 	port->port.iface_no   = tmp_port.iface_no;
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* decoding procedure of rxtx type for port command */
 static int
 decode_port_rxtx_value(void *output, const char *arg_val)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	struct spp_command_port *port = output;
 
 	ret = get_arrary_index(arg_val, PORT_RXTX_STRINGS);
 	if (unlikely(ret <= 0)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC, "Unknown port rxtx. val=%s\n",
 				arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	if ((port->action == SPP_CMD_ACTION_ADD) &&
@@ -479,24 +479,24 @@ decode_port_rxtx_value(void *output, const char *arg_val)
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Port in used. (port command) val=%s\n",
 				arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	port->rxtx = ret;
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* decoding procedure of component name for port command */
 static int
 decode_port_name_value(void *output, const char *arg_val)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 
 	ret = spp_get_component_id(arg_val);
-	if (unlikely(ret < 0)) {
+	if (unlikely(ret < SPP_RET_OK)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Unknown component name. val=%s\n", arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	return decode_str_value(output, arg_val);
@@ -506,7 +506,7 @@ decode_port_name_value(void *output, const char *arg_val)
 static int
 decode_port_ability_value(void *output, const char *arg_val)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	struct spp_command_port *port = output;
 	struct spp_port_ability *ability = &port->ability;
 
@@ -517,7 +517,7 @@ decode_port_ability_value(void *output, const char *arg_val)
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
 					"Unknown port ability. val=%s\n",
 					arg_val);
-			return -1;
+			return SPP_RET_NG;
 		}
 		ability->ope  = ret;
 		ability->rxtx = port->rxtx;
@@ -530,7 +530,7 @@ decode_port_ability_value(void *output, const char *arg_val)
 				RTE_LOG(ERR, SPP_COMMAND_PROC,
 						"Bad VLAN ID. val=%s\n",
 						arg_val);
-				return -1;
+				return SPP_RET_NG;
 			}
 			ability->data.vlantag.pcp = -1;
 		} else {
@@ -540,7 +540,7 @@ decode_port_ability_value(void *output, const char *arg_val)
 				RTE_LOG(ERR, SPP_COMMAND_PROC,
 						"Bad VLAN PCP. val=%s\n",
 						arg_val);
-				return -1;
+				return SPP_RET_NG;
 			}
 		}
 		break;
@@ -552,14 +552,14 @@ decode_port_ability_value(void *output, const char *arg_val)
 		break;
 	}
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* decoding procedure of mac address string */
 static int
 decode_mac_addr_str_value(void *output, const char *arg_val)
 {
-	int64_t ret = 0;
+	int64_t ret = SPP_RET_OK;
 	const char *str_val = arg_val;
 
 	/* if default specification, convert to internal dummy address */
@@ -567,88 +567,88 @@ decode_mac_addr_str_value(void *output, const char *arg_val)
 		str_val = SPP_DEFAULT_CLASSIFIED_DMY_ADDR_STR;
 
 	ret = spp_change_mac_str_to_int64(str_val);
-	if (unlikely(ret < 0)) {
+	if (unlikely(ret < SPP_RET_OK)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Bad mac address string. val=%s\n", str_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	strcpy((char *)output, str_val);
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* decoding procedure of action for classifier_table command */
 static int
 decode_classifier_action_value(void *output, const char *arg_val)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	ret = get_arrary_index(arg_val, COMMAND_ACTION_STRINGS);
 	if (unlikely(ret <= 0)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC, "Unknown port action. val=%s\n",
 				arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	if (unlikely(ret != SPP_CMD_ACTION_ADD) &&
 			unlikely(ret != SPP_CMD_ACTION_DEL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC, "Unknown port action. val=%s\n",
 				arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	*(int *)output = ret;
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* decoding procedure of type for classifier_table command */
 static int
 decode_classifier_type_value(void *output, const char *arg_val)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	ret = get_arrary_index(arg_val, CLASSIFILER_TYPE_STRINGS);
 	if (unlikely(ret <= 0)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Unknown classifier type. val=%s\n",
 				arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	*(int *)output = ret;
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* decoding procedure of vlan id for classifier_table command */
 static int
 decode_classifier_vid_value(void *output, const char *arg_val)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	ret = get_int_value(output, arg_val, 0, ETH_VLAN_ID_MAX);
-	if (unlikely(ret < 0)) {
+	if (unlikely(ret < SPP_RET_OK)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC, "Bad VLAN ID. val=%s\n",
 				arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* decoding procedure of port for classifier_table command */
 static int
 decode_classifier_port_value(void *output, const char *arg_val)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	struct spp_command_classifier_table *classifier_table = output;
 	struct spp_port_index tmp_port;
 	int64_t mac_addr = 0;
 
 	ret = decode_port_value(&tmp_port, arg_val);
-	if (ret < 0)
-		return -1;
+	if (ret < SPP_RET_OK)
+		return SPP_RET_NG;
 
 	if (spp_check_added_port(tmp_port.iface_type,
 					tmp_port.iface_no) == 0) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC, "Port not added. val=%s\n",
 				arg_val);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	if (classifier_table->type == SPP_CLASSIFIER_TYPE_MAC)
@@ -660,12 +660,12 @@ decode_classifier_port_value(void *output, const char *arg_val)
 			RTE_LOG(ERR, SPP_COMMAND_PROC, "Port in used. "
 					"(classifier_table command) val=%s\n",
 					arg_val);
-			return -1;
+			return SPP_RET_NG;
 		}
 	} else if (unlikely(classifier_table->action == SPP_CMD_ACTION_DEL)) {
 		mac_addr = spp_change_mac_str_to_int64(classifier_table->mac);
 		if (mac_addr < 0)
-			return -1;
+			return SPP_RET_NG;
 
 		if (!spp_check_classid_used_port(classifier_table->vid,
 				(uint64_t)mac_addr,
@@ -673,13 +673,13 @@ decode_classifier_port_value(void *output, const char *arg_val)
 			RTE_LOG(ERR, SPP_COMMAND_PROC, "Port in used. "
 					"(classifier_table command) val=%s\n",
 					arg_val);
-			return -1;
+			return SPP_RET_NG;
 		}
 	}
 
 	classifier_table->port.iface_type = tmp_port.iface_type;
 	classifier_table->port.iface_no   = tmp_port.iface_no;
-	return 0;
+	return SPP_RET_OK;
 }
 
 #define DECODE_PARAMETER_LIST_EMPTY { NULL, 0, NULL }
@@ -830,7 +830,7 @@ decode_command_parameter_in_list(struct spp_command_request *request,
 				int argc, char *argv[],
 				struct spp_command_decode_error *error)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	int ci = request->commands[0].type;
 	int pi = 0;
 	struct decode_parameter_list *list = NULL;
@@ -848,7 +848,7 @@ decode_command_parameter_in_list(struct spp_command_request *request,
 					list->name);
 		}
 	}
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* command list for decoding */
@@ -883,7 +883,7 @@ decode_command_in_list(struct spp_command_request *request,
 			const char *request_str,
 			struct spp_command_decode_error *error)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	int command_name_check = 0;
 	struct decode_command_list *list = NULL;
 	int i = 0;
@@ -896,7 +896,7 @@ decode_command_in_list(struct spp_command_request *request,
 	strcpy(tmp_str, request_str);
 	ret = decode_parameter_value(tmp_str, SPP_CMD_MAX_PARAMETERS,
 			&argc, argv);
-	if (ret < 0) {
+	if (ret < SPP_RET_OK) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC, "Parameter number over limit."
 				"request_str=%s\n", request_str);
 		return set_decode_error(error, SPP_CMD_DERR_BAD_FORMAT, NULL);
@@ -918,7 +918,7 @@ decode_command_in_list(struct spp_command_request *request,
 		if (list->func != NULL)
 			return (*list->func)(request, argc, argv, error);
 
-		return 0;
+		return SPP_RET_OK;
 	}
 
 	if (command_name_check != 0) {
@@ -940,13 +940,13 @@ spp_command_decode_request(
 		const char *request_str, size_t request_str_len,
 		struct spp_command_decode_error *error)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int i;
 
 	/* decode request */
 	request->num_command = 1;
 	ret = decode_command_in_list(request, request_str, error);
-	if (unlikely(ret != 0)) {
+	if (unlikely(ret != SPP_RET_OK)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Cannot decode command request. "
 				"ret=%d, request_str=%.*s\n",
diff --git a/src/vf/common/command_dec.h b/src/vf/common/command_dec.h
index 538eb57..84644f2 100644
--- a/src/vf/common/command_dec.h
+++ b/src/vf/common/command_dec.h
@@ -189,7 +189,7 @@ struct spp_command_decode_error {
  *  The pointer to struct spp_command_decode_error.@n
  *  Detailed error information will be stored.
  *
- * @retval 0  succeeded.
+ * @retval SPP_RET_OK succeeded.
  * @retval !0 failed.
  */
 int spp_command_decode_request(struct spp_command_request *request,
diff --git a/src/vf/common/command_proc.c b/src/vf/common/command_proc.c
index d30acf3..a726302 100644
--- a/src/vf/common/command_proc.c
+++ b/src/vf/common/command_proc.c
@@ -397,7 +397,7 @@ spp_update_port(enum spp_command_action action,
 static int
 spp_flush(void)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	struct cancel_backup_info *backup_info = NULL;
 
 	spp_get_mng_data_addr(NULL, NULL, NULL,
@@ -405,7 +405,7 @@ spp_flush(void)
 
 	/* Initial setting of each interface. */
 	ret = flush_port();
-	if (ret < 0)
+	if (ret < SPP_RET_OK)
 		return ret;
 
 	/* Flush of core index. */
@@ -503,7 +503,7 @@ spp_get_dpdk_port(enum port_type iface_type, int iface_no)
 	case VHOST:
 		return iface_info->vhost[iface_no].dpdk_port;
 	default:
-		return -1;
+		return SPP_RET_NG;
 	}
 }
 
@@ -515,10 +515,10 @@ append_json_comma(char **output)
 	if (unlikely(*output == NULL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"JSON's comma failed to add.\n");
-		return -1;
+		return SPP_RET_NG;
 	}
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* append data of unsigned integral type for JSON format */
@@ -533,12 +533,12 @@ append_json_uint_value(const char *name, char **output, unsigned int value)
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"JSON's numeric format failed to add. "
 				"(name = %s, uint = %u)\n", name, value);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	sprintf(&(*output)[len], JSON_APPEND_VALUE("%u"),
 			JSON_APPEND_COMMA(len), name, value);
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* append data of integral type for JSON format */
@@ -553,12 +553,12 @@ append_json_int_value(const char *name, char **output, int value)
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"JSON's numeric format failed to add. "
 				"(name = %s, int = %d)\n", name, value);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	sprintf(&(*output)[len], JSON_APPEND_VALUE("%d"),
 			JSON_APPEND_COMMA(len), name, value);
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* append data of string type for JSON format */
@@ -573,12 +573,12 @@ append_json_str_value(const char *name, char **output, const char *str)
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"JSON's string format failed to add. "
 				"(name = %s, str = %s)\n", name, str);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	sprintf(&(*output)[len], JSON_APPEND_VALUE("\"%s\""),
 			JSON_APPEND_COMMA(len), name, str);
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* append brackets of the array for JSON format */
@@ -593,12 +593,12 @@ append_json_array_brackets(const char *name, char **output, const char *str)
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"JSON's square bracket failed to add. "
 				"(name = %s, str = %s)\n", name, str);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	sprintf(&(*output)[len], JSON_APPEND_ARRAY,
 			JSON_APPEND_COMMA(len), name, str);
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* append brackets of the blocks for JSON format */
@@ -613,7 +613,7 @@ append_json_block_brackets(const char *name, char **output, const char *str)
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"JSON's curly bracket failed to add. "
 				"(name = %s, str = %s)\n", name, str);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	if (name[0] == '\0')
@@ -622,14 +622,14 @@ append_json_block_brackets(const char *name, char **output, const char *str)
 	else
 		sprintf(&(*output)[len], JSON_APPEND_BLOCK,
 				JSON_APPEND_COMMA(len), name, str);
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* execute one command */
 static int
 execute_command(const struct spp_command *command)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 
 	switch (command->type) {
 	case SPP_CMDTYPE_CLASSIFIER_TABLE_MAC:
@@ -789,26 +789,26 @@ append_result_value(const char *name, char **output, void *tmp)
 static int
 append_error_details_value(const char *name, char **output, void *tmp)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	const struct command_result *result = tmp;
 	char *tmp_buff;
 	/* string is empty, except for errors */
 	if (result->error_message[0] == '\0')
-		return 0;
+		return SPP_RET_OK;
 
 	tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
 	if (unlikely(tmp_buff == NULL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"allocate error. (name = %s)\n",
 				name);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	ret = append_json_str_value("message", &tmp_buff,
 			result->error_message);
 	if (unlikely(ret < 0)) {
 		spp_strbuf_free(tmp_buff);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	ret = append_json_block_brackets(name, output, tmp_buff);
@@ -842,13 +842,13 @@ append_interface_array(char **output, const enum port_type type)
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
 					"Interface number failed to add. "
 					"(type = %d)\n", type);
-			return -1;
+			return SPP_RET_NG;
 		}
 
 		port_cnt++;
 	}
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* append a list of interface numbers for JSON format */
@@ -856,13 +856,13 @@ static int
 append_interface_value(const char *name, char **output,
 		void *tmp __attribute__ ((unused)))
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
 	if (unlikely(tmp_buff == NULL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"allocate error. (name = %s)\n",
 				name);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	if (strcmp(name, SPP_IFTYPE_NIC_STR) == 0)
@@ -874,9 +874,9 @@ append_interface_value(const char *name, char **output,
 	else if (strcmp(name, SPP_IFTYPE_RING_STR) == 0)
 		ret = append_interface_array(&tmp_buff, RING);
 
-	if (unlikely(ret < 0)) {
+	if (unlikely(ret < SPP_RET_OK)) {
 		spp_strbuf_free(tmp_buff);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	ret = append_json_array_brackets(name, output, tmp_buff);
@@ -888,21 +888,21 @@ append_interface_value(const char *name, char **output,
 static int
 append_vlan_value(char **output, const int ope, const int vid, const int pcp)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	ret = append_json_str_value("operation", output,
 			PORT_ABILITY_STATUS_STRINGS[ope]);
-	if (unlikely(ret < 0))
-		return -1;
+	if (unlikely(ret < SPP_RET_OK))
+		return SPP_RET_NG;
 
 	ret = append_json_int_value("id", output, vid);
 	if (unlikely(ret < 0))
-		return -1;
+		return SPP_RET_NG;
 
 	ret = append_json_int_value("pcp", output, pcp);
 	if (unlikely(ret < 0))
-		return -1;
+		return SPP_RET_NG;
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* append a block of vlan for JSON format */
@@ -910,7 +910,7 @@ static int
 append_vlan_block(const char *name, char **output,
 		const int port_id, const enum spp_port_rxtx rxtx)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int i = 0;
 	struct spp_port_ability *info = NULL;
 	char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
@@ -918,7 +918,7 @@ append_vlan_block(const char *name, char **output,
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"allocate error. (name = %s)\n",
 				name);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	spp_port_ability_get_info(port_id, rxtx, &info);
@@ -929,8 +929,8 @@ append_vlan_block(const char *name, char **output,
 			ret = append_vlan_value(&tmp_buff, info[i].ope,
 					info[i].data.vlantag.vid,
 					info[i].data.vlantag.pcp);
-			if (unlikely(ret < 0))
-				return -1;
+			if (unlikely(ret < SPP_RET_OK))
+				return SPP_RET_NG;
 
 			/*
 			 * Change counter to "maximum+1" for exit the loop.
@@ -947,8 +947,8 @@ append_vlan_block(const char *name, char **output,
 	if (i == SPP_PORT_ABILITY_MAX) {
 		ret = append_vlan_value(&tmp_buff, SPP_PORT_ABILITY_OPE_NONE,
 				0, 0);
-		if (unlikely(ret < 0))
-			return -1;
+		if (unlikely(ret < SPP_RET_OK))
+			return SPP_RET_NG;
 	}
 
 	ret = append_json_block_brackets(name, output, tmp_buff);
@@ -961,25 +961,25 @@ static int
 append_port_block(char **output, const struct spp_port_index *port,
 		const enum spp_port_rxtx rxtx)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	char port_str[CMD_TAG_APPEND_SIZE];
 	char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
 	if (unlikely(tmp_buff == NULL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"allocate error. (name = port_block)\n");
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	spp_format_port_string(port_str, port->iface_type, port->iface_no);
 	ret = append_json_str_value("port", &tmp_buff, port_str);
-	if (unlikely(ret < 0))
-		return -1;
+	if (unlikely(ret < SPP_RET_OK))
+		return SPP_RET_NG;
 
 	ret = append_vlan_block("vlan", &tmp_buff,
 			spp_get_dpdk_port(port->iface_type, port->iface_no),
 			rxtx);
-	if (unlikely(ret < 0))
-		return -1;
+	if (unlikely(ret < SPP_RET_OK))
+		return SPP_RET_NG;
 
 	ret = append_json_block_brackets("", output, tmp_buff);
 	spp_strbuf_free(tmp_buff);
@@ -992,20 +992,20 @@ append_port_array(const char *name, char **output, const int num,
 		const struct spp_port_index *ports,
 		const enum spp_port_rxtx rxtx)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int i = 0;
 	char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
 	if (unlikely(tmp_buff == NULL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"allocate error. (name = %s)\n",
 				name);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	for (i = 0; i < num; i++) {
 		ret = append_port_block(&tmp_buff, &ports[i], rxtx);
-		if (unlikely(ret < 0))
-			return -1;
+		if (unlikely(ret < SPP_RET_OK))
+			return SPP_RET_NG;
 	}
 
 	ret = append_json_array_brackets(name, output, tmp_buff);
@@ -1022,7 +1022,7 @@ append_core_element_value(
 		const int num_rx, const struct spp_port_index *rx_ports,
 		const int num_tx, const struct spp_port_index *tx_ports)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int unuse_flg = 0;
 	char *buff, *tmp_buff;
 	buff = params->output;
@@ -1038,7 +1038,7 @@ append_core_element_value(
 	unuse_flg = strcmp(type, SPP_TYPE_UNUSE_STR);
 
 	ret = append_json_uint_value("core", &tmp_buff, lcore_id);
-	if (unlikely(ret < 0))
+	if (unlikely(ret < SPP_RET_OK))
 		return ret;
 
 	if (unuse_flg) {
@@ -1048,7 +1048,7 @@ append_core_element_value(
 	}
 
 	ret = append_json_str_value("type", &tmp_buff, type);
-	if (unlikely(ret < 0))
+	if (unlikely(ret < SPP_RET_OK))
 		return ret;
 
 	if (unuse_flg) {
@@ -1059,7 +1059,7 @@ append_core_element_value(
 
 		ret = append_port_array("tx_port", &tmp_buff,
 				num_tx, tx_ports, SPP_PORT_RXTX_TX);
-		if (unlikely(ret < 0))
+		if (unlikely(ret < SPP_RET_OK))
 			return ret;
 	}
 
@@ -1074,23 +1074,23 @@ static int
 append_core_value(const char *name, char **output,
 		void *tmp __attribute__ ((unused)))
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	struct spp_iterate_core_params itr_params;
 	char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
 	if (unlikely(tmp_buff == NULL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"allocate error. (name = %s)\n",
 				name);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	itr_params.output = tmp_buff;
 	itr_params.element_proc = append_core_element_value;
 
 	ret = spp_iterate_core_info(&itr_params);
-	if (unlikely(ret != 0)) {
+	if (unlikely(ret != SPP_RET_OK)) {
 		spp_strbuf_free(itr_params.output);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	ret = append_json_array_brackets(name, output, itr_params.output);
@@ -1106,7 +1106,7 @@ append_classifier_element_value(
 		int vid, const char *mac,
 		const struct spp_port_index *port)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	char *buff, *tmp_buff;
 	char port_str[CMD_TAG_APPEND_SIZE];
 	char value_str[SPP_MIN_STR_LEN];
@@ -1122,7 +1122,7 @@ append_classifier_element_value(
 
 	ret = append_json_str_value("type", &tmp_buff,
 			CLASSIFILER_TYPE_STATUS_STRINGS[type]);
-	if (unlikely(ret < 0))
+	if (unlikely(ret < SPP_RET_OK))
 		return ret;
 
 	memset(value_str, 0x00, SPP_MIN_STR_LEN);
@@ -1143,7 +1143,7 @@ append_classifier_element_value(
 		return ret;
 
 	ret = append_json_str_value("port", &tmp_buff, port_str);
-	if (unlikely(ret < 0))
+	if (unlikely(ret < SPP_RET_OK))
 		return ret;
 
 	ret = append_json_block_brackets("", &buff, tmp_buff);
@@ -1157,23 +1157,23 @@ static int
 append_classifier_table_value(const char *name, char **output,
 		void *tmp __attribute__ ((unused)))
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	struct spp_iterate_classifier_table_params itr_params;
 	char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
 	if (unlikely(tmp_buff == NULL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"allocate error. (name = %s)\n",
 				name);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	itr_params.output = tmp_buff;
 	itr_params.element_proc = append_classifier_element_value;
 
 	ret = spp_iterate_classifier_table(&itr_params);
-	if (unlikely(ret != 0)) {
+	if (unlikely(ret != SPP_RET_OK)) {
 		spp_strbuf_free(itr_params.output);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	ret = append_json_array_brackets(name, output, itr_params.output);
@@ -1187,25 +1187,25 @@ append_response_list_value(char **output,
 		struct command_response_list *list,
 		void *tmp)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int i;
 	char *tmp_buff;
 	tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
 	if (unlikely(tmp_buff == NULL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"allocate error. (name = response_list)\n");
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	for (i = 0; list[i].tag_name[0] != '\0'; i++) {
 		tmp_buff[0] = '\0';
 		ret = list[i].func(list[i].tag_name, &tmp_buff, tmp);
-		if (unlikely(ret < 0)) {
+		if (unlikely(ret < SPP_RET_OK)) {
 			spp_strbuf_free(tmp_buff);
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
 					"Failed to get reply string. "
 					"(tag = %s)\n", list[i].tag_name);
-			return -1;
+			return SPP_RET_NG;
 		}
 
 		if (tmp_buff[0] == '\0')
@@ -1213,13 +1213,13 @@ append_response_list_value(char **output,
 
 		if ((*output)[0] != '\0') {
 			ret = append_json_comma(output);
-			if (unlikely(ret < 0)) {
+			if (unlikely(ret < SPP_RET_OK)) {
 				spp_strbuf_free(tmp_buff);
 				RTE_LOG(ERR, SPP_COMMAND_PROC,
 						"Failed to add commas. "
 						"(tag = %s)\n",
 						list[i].tag_name);
-				return -1;
+				return SPP_RET_NG;
 			}
 		}
 
@@ -1231,12 +1231,12 @@ append_response_list_value(char **output,
 					"Failed to add reply string. "
 					"(tag = %s)\n",
 					list[i].tag_name);
-			return -1;
+			return SPP_RET_NG;
 		}
 	}
 
 	spp_strbuf_free(tmp_buff);
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* termination constant of command response list */
@@ -1265,7 +1265,7 @@ static int
 append_command_results_value(const char *name, char **output,
 		int num, struct command_result *results)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int i;
 	char *tmp_buff1, *tmp_buff2;
 	tmp_buff1 = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
@@ -1273,7 +1273,7 @@ append_command_results_value(const char *name, char **output,
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"allocate error. (name = %s, buff=1)\n",
 				name);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	tmp_buff2 = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
@@ -1282,7 +1282,7 @@ append_command_results_value(const char *name, char **output,
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"allocate error. (name = %s, buff=2)\n",
 				name);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	for (i = 0; i < num; i++) {
@@ -1292,14 +1292,14 @@ append_command_results_value(const char *name, char **output,
 		if (unlikely(ret < 0)) {
 			spp_strbuf_free(tmp_buff1);
 			spp_strbuf_free(tmp_buff2);
-			return -1;
+			return SPP_RET_NG;
 		}
 
 		ret = append_json_block_brackets("", &tmp_buff2, tmp_buff1);
 		if (unlikely(ret < 0)) {
 			spp_strbuf_free(tmp_buff1);
 			spp_strbuf_free(tmp_buff2);
-			return -1;
+			return SPP_RET_NG;
 		}
 
 	}
@@ -1314,20 +1314,20 @@ append_command_results_value(const char *name, char **output,
 static int
 append_info_value(const char *name, char **output)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
 	if (unlikely(tmp_buff == NULL)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"allocate error. (name = %s)\n",
 				name);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	ret = append_response_list_value(&tmp_buff,
 			response_info_list, NULL);
-	if (unlikely(ret < 0)) {
+	if (unlikely(ret < SPP_RET_OK)) {
 		spp_strbuf_free(tmp_buff);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	ret = append_json_block_brackets(name, output, tmp_buff);
@@ -1341,7 +1341,7 @@ send_decode_error_response(int *sock,
 		const struct spp_command_request *request,
 		struct command_result *command_results)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	char *msg, *tmp_buff;
 	tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
 	if (unlikely(tmp_buff == NULL)) {
@@ -1353,7 +1353,7 @@ send_decode_error_response(int *sock,
 	/* create & append result array */
 	ret = append_command_results_value("results", &tmp_buff,
 			request->num_command, command_results);
-	if (unlikely(ret < 0)) {
+	if (unlikely(ret < SPP_RET_OK)) {
 		spp_strbuf_free(tmp_buff);
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Failed to make command result response.\n");
@@ -1369,7 +1369,7 @@ send_decode_error_response(int *sock,
 	}
 	ret = append_json_block_brackets("", &msg, tmp_buff);
 	spp_strbuf_free(tmp_buff);
-	if (unlikely(ret < 0)) {
+	if (unlikely(ret < SPP_RET_OK)) {
 		spp_strbuf_free(msg);
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"allocate error. (name = result_response)\n");
@@ -1382,7 +1382,7 @@ send_decode_error_response(int *sock,
 
 	/* send response to requester */
 	ret = spp_send_message(sock, msg, strlen(msg));
-	if (unlikely(ret != 0)) {
+	if (unlikely(ret != SPP_RET_OK)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Failed to send decode error response.\n");
 		/* not return */
@@ -1397,7 +1397,7 @@ send_command_result_response(int *sock,
 		const struct spp_command_request *request,
 		struct command_result *command_results)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	char *msg, *tmp_buff;
 	tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
 	if (unlikely(tmp_buff == NULL)) {
@@ -1409,7 +1409,7 @@ send_command_result_response(int *sock,
 	/* create & append result array */
 	ret = append_command_results_value("results", &tmp_buff,
 			request->num_command, command_results);
-	if (unlikely(ret < 0)) {
+	if (unlikely(ret < SPP_RET_OK)) {
 		spp_strbuf_free(tmp_buff);
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Failed to make command result response.\n");
@@ -1419,7 +1419,7 @@ send_command_result_response(int *sock,
 	/* append client id information value */
 	if (request->is_requested_client_id) {
 		ret = append_client_id_value("client_id", &tmp_buff, NULL);
-		if (unlikely(ret < 0)) {
+		if (unlikely(ret < SPP_RET_OK)) {
 			spp_strbuf_free(tmp_buff);
 			RTE_LOG(ERR, SPP_COMMAND_PROC, "Failed to make "
 					"client id response.\n");
@@ -1430,7 +1430,7 @@ send_command_result_response(int *sock,
 	/* append info value */
 	if (request->is_requested_status) {
 		ret = append_info_value("info", &tmp_buff);
-		if (unlikely(ret < 0)) {
+		if (unlikely(ret < SPP_RET_OK)) {
 			spp_strbuf_free(tmp_buff);
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
 					"Failed to make status response.\n");
@@ -1447,7 +1447,7 @@ send_command_result_response(int *sock,
 	}
 	ret = append_json_block_brackets("", &msg, tmp_buff);
 	spp_strbuf_free(tmp_buff);
-	if (unlikely(ret < 0)) {
+	if (unlikely(ret < SPP_RET_OK)) {
 		spp_strbuf_free(msg);
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"allocate error. (name = result_response)\n");
@@ -1460,7 +1460,7 @@ send_command_result_response(int *sock,
 
 	/* send response to requester */
 	ret = spp_send_message(sock, msg, strlen(msg));
-	if (unlikely(ret != 0)) {
+	if (unlikely(ret != SPP_RET_OK)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 			"Failed to send command result response.\n");
 		/* not return */
@@ -1473,7 +1473,7 @@ send_command_result_response(int *sock,
 static int
 process_request(int *sock, const char *request_str, size_t request_str_len)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int i;
 
 	struct spp_command_request request;
@@ -1491,14 +1491,14 @@ process_request(int *sock, const char *request_str, size_t request_str_len)
 	/* decode request message */
 	ret = spp_command_decode_request(
 			&request, request_str, request_str_len, &decode_error);
-	if (unlikely(ret != 0)) {
+	if (unlikely(ret != SPP_RET_OK)) {
 		/* send error response */
 		set_decode_error_to_results(command_results, &request,
 				&decode_error);
 		send_decode_error_response(sock, &request, command_results);
 		RTE_LOG(DEBUG, SPP_COMMAND_PROC,
 				"End command request processing.\n");
-		return 0;
+		return SPP_RET_OK;
 	}
 
 	RTE_LOG(DEBUG, SPP_COMMAND_PROC, "Command request is valid. "
@@ -1508,7 +1508,7 @@ process_request(int *sock, const char *request_str, size_t request_str_len)
 	/* execute commands */
 	for (i = 0; i < request.num_command ; ++i) {
 		ret = execute_command(request.commands + i);
-		if (unlikely(ret != 0)) {
+		if (unlikely(ret != SPP_RET_OK)) {
 			set_command_results(&command_results[i], CRES_FAILURE,
 					"error occur");
 
@@ -1528,7 +1528,7 @@ process_request(int *sock, const char *request_str, size_t request_str_len)
 		/* Other route is normal end because it responds to command. */
 		RTE_LOG(INFO, SPP_COMMAND_PROC,
 				"No response with process exit command.\n");
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	/* send response */
@@ -1536,7 +1536,7 @@ process_request(int *sock, const char *request_str, size_t request_str_len)
 
 	RTE_LOG(DEBUG, SPP_COMMAND_PROC, "End command request processing.\n");
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* initialize command processor. */
@@ -1550,7 +1550,7 @@ spp_command_proc_init(const char *controller_ip, int controller_port)
 int
 spp_command_proc_do(void)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int msg_ret = -1;
 
 	static int sock = -1;
@@ -1562,22 +1562,22 @@ spp_command_proc_do(void)
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
 					"Cannot allocate memory "
 					"for receive data(init).\n");
-			return -1;
+			return SPP_RET_NG;
 		}
 	}
 
 	ret = spp_connect_to_controller(&sock);
-	if (unlikely(ret != 0))
-		return 0;
+	if (unlikely(ret != SPP_RET_OK))
+		return SPP_RET_OK;
 
 	msg_ret = spp_receive_message(&sock, &msgbuf);
 	if (unlikely(msg_ret <= 0)) {
 		if (likely(msg_ret == 0))
-			return 0;
+			return SPP_RET_OK;
 		else if (unlikely(msg_ret == SPP_CONNERR_TEMPORARY))
-			return 0;
+			return SPP_RET_OK;
 		else
-			return -1;
+			return SPP_RET_NG;
 	}
 
 	ret = process_request(&sock, msgbuf, msg_ret);
diff --git a/src/vf/common/command_proc.h b/src/vf/common/command_proc.h
index 3a8d0cd..9e261f3 100644
--- a/src/vf/common/command_proc.h
+++ b/src/vf/common/command_proc.h
@@ -21,8 +21,8 @@
  * @param controller_port
  *  The controller's port number.
  *
- * @retval 0  succeeded.
- * @retval -1 failed.
+ * @retval SPP_RET_OK succeeded.
+ * @retval SPP_RET_NG failed.
  */
 int
 spp_command_proc_init(const char *controller_ip, int controller_port);
@@ -30,8 +30,8 @@ spp_command_proc_init(const char *controller_ip, int controller_port);
 /**
  * process command from controller.
  *
- * @retval 0  succeeded.
- * @retval -1 process termination is required.
+ * @retval SPP_RET_OK succeeded.
+ * @retval SPP_RET_NG process termination is required.
  *            (occurred connection failure, or received exit command)
  */
 int
diff --git a/src/vf/common/ringlatencystats.c b/src/vf/common/ringlatencystats.c
index a0cc901..1483a7e 100644
--- a/src/vf/common/ringlatencystats.c
+++ b/src/vf/common/ringlatencystats.c
@@ -57,7 +57,7 @@ spp_ringlatencystats_init(uint64_t samp_intvl, uint16_t stats_count)
 	if (unlikely(g_stats_info == NULL)) {
 		RTE_LOG(ERR, SPP_RING_LATENCY_STATS, "Cannot allocate memory "
 				"for ring latency stats info\n");
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	/* store global information for ring latency statistics */
@@ -70,7 +70,7 @@ spp_ringlatencystats_init(uint64_t samp_intvl, uint16_t stats_count)
 			g_samp_intvl, g_stats_count,
 			cycles_per_ns(), NS_PER_SEC);
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 void
diff --git a/src/vf/common/ringlatencystats.h b/src/vf/common/ringlatencystats.h
index 0daa7c4..b919c62 100644
--- a/src/vf/common/ringlatencystats.h
+++ b/src/vf/common/ringlatencystats.h
@@ -33,8 +33,8 @@ struct spp_ringlatencystats_ring_latency_stats {
  * @param stats_count
  *  The number of ring to be measured.
  *
- * @retval 0: succeeded.
- * @retval -1: failed.
+ * @retval SPP_RET_OK: succeeded.
+ * @retval SPP_RET_NG: failed.
  */
 int spp_ringlatencystats_init(uint64_t samp_intvl, uint16_t stats_count);
 
diff --git a/src/vf/common/spp_port.c b/src/vf/common/spp_port.c
index 3b1f5c3..d7d374e 100644
--- a/src/vf/common/spp_port.c
+++ b/src/vf/common/spp_port.c
@@ -111,7 +111,7 @@ add_vlantag_packet(
 		if (unlikely(new_ether == NULL)) {
 			RTE_LOG(ERR, PORT, "Failed to "
 					"get additional header area.\n");
-			return -1;
+			return SPP_RET_NG;
 		}
 
 		rte_memcpy(new_ether, old_ether, sizeof(struct ether_hdr));
@@ -122,7 +122,7 @@ add_vlantag_packet(
 
 	vlan->vlan_tci = vlantag->tci;
 	set_fcs_packet(pkt);
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* Add VLAN tag to all packets. */
@@ -131,7 +131,7 @@ add_vlantag_all_packets(
 		struct rte_mbuf **pkts, int nb_pkts,
 		const union spp_ability_data *data)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	int cnt = 0;
 	for (cnt = 0; cnt < nb_pkts; cnt++) {
 		ret = add_vlantag_packet(pkts[cnt], data);
@@ -163,7 +163,7 @@ del_vlantag_packet(
 		if (unlikely(new_ether == NULL)) {
 			RTE_LOG(ERR, PORT, "Failed to "
 					"delete unnecessary header area.\n");
-			return -1;
+			return SPP_RET_NG;
 		}
 
 		old = (uint32_t *)old_ether;
@@ -174,7 +174,7 @@ del_vlantag_packet(
 		old[0] = 0;
 		set_fcs_packet(pkt);
 	}
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* Delete VLAN tag to all packets. */
@@ -183,7 +183,7 @@ del_vlantag_all_packets(
 		struct rte_mbuf **pkts, int nb_pkts,
 		const union spp_ability_data *data)
 {
-	int ret = 0;
+	int ret = SPP_RET_OK;
 	int cnt = 0;
 	for (cnt = 0; cnt < nb_pkts; cnt++) {
 		ret = del_vlantag_packet(pkts[cnt], data);
@@ -373,7 +373,7 @@ spp_eth_rx_burst(
 	uint16_t nb_rx = 0;
 	nb_rx = rte_eth_rx_burst(port_id, 0, rx_pkts, nb_pkts);
 	if (unlikely(nb_rx == 0))
-		return 0;
+		return SPP_RET_OK;
 
 #ifdef SPP_RINGLATENCYSTATS_ENABLE
 	if (g_port_mng_info[port_id].iface_type == RING)
@@ -396,7 +396,7 @@ spp_eth_tx_burst(
 	nb_tx = port_ability_each_operation(port_id, tx_pkts, nb_pkts,
 			SPP_PORT_RXTX_TX);
 	if (unlikely(nb_tx == 0))
-		return 0;
+		return SPP_RET_OK;
 
 #ifdef SPP_RINGLATENCYSTATS_ENABLE
 	if (g_port_mng_info[port_id].iface_type == RING)
diff --git a/src/vf/common/spp_proc.c b/src/vf/common/spp_proc.c
index 37179f5..a6ddeb6 100644
--- a/src/vf/common/spp_proc.c
+++ b/src/vf/common/spp_proc.c
@@ -76,7 +76,7 @@ add_ring_pmd(int ring_id)
 	if (unlikely(ring == NULL)) {
 		RTE_LOG(ERR, APP,
 			"Cannot get RX ring - is server process running?\n");
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	/* Create ring pmd */
@@ -107,7 +107,7 @@ add_vhost_pmd(int index, int client)
 	if (unlikely(mp == NULL)) {
 		RTE_LOG(ERR, APP, "Cannot get mempool for mbufs. "
 				"(name = %s)\n", PKTMBUF_POOL_NAME);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	/* eth_vhost0 index 0 iface /tmp/sock0 on numa 0 */
@@ -178,7 +178,7 @@ spp_get_core_status(unsigned int lcore_id)
 /**
  * Check status of all of cores is same as given
  *
- * It returns -1 as status mismatch if status is not same.
+ * It returns SPP_RET_NG as status mismatch if status is not same.
  * If core is in use, status will be checked.
  */
 static int
@@ -189,10 +189,10 @@ check_core_status(enum spp_core_status status)
 		if ((g_mng_data_addr.p_core_info + lcore_id)->status !=
 								status) {
 			/* Status is mismatched */
-			return -1;
+			return SPP_RET_NG;
 		}
 	}
-	return 0;
+	return SPP_RET_OK;
 }
 
 int
@@ -203,11 +203,11 @@ check_core_status_wait(enum spp_core_status status)
 		sleep(1);
 		int ret = check_core_status(status);
 		if (ret == 0)
-			return 0;
+			return SPP_RET_OK;
 	}
 
 	RTE_LOG(ERR, APP, "Status check time out. (status = %d)\n", status);
-	return -1;
+	return SPP_RET_NG;
 }
 
 /* Set core status */
@@ -522,7 +522,7 @@ set_nic_interface(void)
 		p_iface_info->nic[nic_cnt].dpdk_port = nic_cnt;
 	}
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* Setup management info for spp_vf */
@@ -535,10 +535,10 @@ init_mng_data(void)
 	init_component_info();
 
 	int ret_nic = set_nic_interface();
-	if (unlikely(ret_nic != 0))
-		return -1;
+	if (unlikely(ret_nic != SPP_RET_OK))
+		return SPP_RET_NG;
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 #ifdef SPP_RINGLATENCYSTATS_ENABLE
@@ -707,7 +707,7 @@ get_free_component(void)
 		if ((component_info + cnt)->type == SPP_COMPONENT_UNUSE)
 			return cnt;
 	}
-	return -1;
+	return SPP_RET_NG;
 }
 
 /* Get component id for specified component name */
@@ -742,7 +742,7 @@ del_component_info(int component_id, int component_num, int *componet_array)
 	}
 
 	if (match < 0)
-		return -1;
+		return SPP_RET_NG;
 
 	/* Last element is excluded from movement. */
 	max--;
@@ -763,7 +763,7 @@ check_port_element(
 		struct spp_port_info *array[])
 {
 	int cnt = 0;
-	int match = -1;
+	int match = SPP_RET_NG;
 	for (cnt = 0; cnt < num; cnt++) {
 		if (info == array[cnt])
 			match = cnt;
@@ -779,12 +779,12 @@ get_del_port_element(
 		struct spp_port_info *array[])
 {
 	int cnt = 0;
-	int match = -1;
+	int match = SPP_RET_NG;
 	int max = num;
 
 	match = check_port_element(info, num, array);
 	if (match < 0)
-		return -1;
+		return SPP_RET_NG;
 
 	/* Last element is excluded from movement. */
 	max--;
@@ -794,7 +794,7 @@ get_del_port_element(
 
 	/* Last element is cleared. */
 	array[cnt] = NULL;
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* Flush initial setting of each interface. */
@@ -919,12 +919,12 @@ int spp_format_port_string(char *port, enum port_type iface_type, int iface_no)
 		iface_type_str = SPP_IFTYPE_VHOST_STR;
 		break;
 	default:
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	sprintf(port, "%s:%d", iface_type_str, iface_no);
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* Change mac address of 'aa:bb:cc:dd:ee:ff' to int64 and return it */
@@ -952,7 +952,7 @@ spp_change_mac_str_to_int64(const char *mac)
 		if (unlikely(token_cnt >= ETHER_ADDR_LEN)) {
 			RTE_LOG(ERR, APP, "MAC address format error. "
 					"(mac = %s)\n", mac);
-			return -1;
+			return SPP_RET_NG;
 		}
 
 		/* Convert string to hex value */
diff --git a/src/vf/common/spp_proc.h b/src/vf/common/spp_proc.h
index ce205d8..a6de55c 100644
--- a/src/vf/common/spp_proc.h
+++ b/src/vf/common/spp_proc.h
@@ -649,8 +649,8 @@ int flush_component(void);
  * @param iface_no
  *  interface no
  *
- * @retval 0  succeeded.
- * @retval -1 failed.
+ * @retval SPP_RET_OK succeeded.
+ * @retval SPP_RET_NG failed.
  */
 int
 spp_format_port_string(char *port, enum port_type iface_type, int iface_no);
@@ -662,7 +662,7 @@ spp_format_port_string(char *port, enum port_type iface_type, int iface_no);
  *  Character string of MAC address to be converted.
  *
  * @retval 0< int64 that store mac address
- * @retval -1
+ * @retval SPP_RET_NG
  */
 int64_t spp_change_mac_str_to_int64(const char *mac);
 
diff --git a/src/vf/spp_forward.c b/src/vf/spp_forward.c
index b0846c6..5e6189c 100644
--- a/src/vf/spp_forward.c
+++ b/src/vf/spp_forward.c
@@ -66,7 +66,7 @@ spp_forward_update(struct spp_component_info *component)
 		RTE_LOG(ERR, FORWARD,
 			"Component[%d] Setting error. (type = %d, rx = %d)\n",
 			component->component_id, component->type, num_rx);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	/* Component allows only one transmit port. */
@@ -74,7 +74,7 @@ spp_forward_update(struct spp_component_info *component)
 		RTE_LOG(ERR, FORWARD,
 			"Component[%d] Setting error. (type = %d, tx = %d)\n",
 			component->component_id, component->type, num_tx);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	memset(path, 0x00, sizeof(struct forward_path));
@@ -110,7 +110,7 @@ spp_forward_update(struct spp_component_info *component)
 			component->name,
 			component->type);
 
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* Change index of forward info */
@@ -168,7 +168,7 @@ spp_forward(int id)
 				rte_pktmbuf_free(bufs[buf]);
 		}
 	}
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* Merge/Forward get component status */
@@ -177,7 +177,7 @@ spp_forward_get_component_status(
 		unsigned int lcore_id, int id,
 		struct spp_iterate_core_params *params)
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 	int cnt;
 	const char *component_type = NULL;
 	struct forward_info *info = &g_forward_info[id];
@@ -190,7 +190,7 @@ spp_forward_get_component_status(
 				"Component[%d] Not used. "
 				"(status)(core = %d, type = %d)\n",
 				id, lcore_id, path->type);
-		return -1;
+		return SPP_RET_NG;
 	}
 
 	if (path->type == SPP_COMPONENT_MERGE)
@@ -215,8 +215,8 @@ spp_forward_get_component_status(
 		params, lcore_id,
 		path->name, component_type,
 		path->num_rx, rx_ports, path->num_tx, tx_ports);
-	if (unlikely(ret != 0))
-		return -1;
+	if (unlikely(ret != SPP_RET_OK))
+		return SPP_RET_NG;
 
-	return 0;
+	return SPP_RET_OK;
 }
diff --git a/src/vf/spp_forward.h b/src/vf/spp_forward.h
index 526ffcb..14adb0c 100644
--- a/src/vf/spp_forward.h
+++ b/src/vf/spp_forward.h
@@ -31,8 +31,8 @@ void spp_forward_init(void);
  *  The pointer to struct spp_component_info.@n
  *  The data for updating the internal data of forwarder and merger.
  *
- * @retval 0  succeeded.
- * @retval -1 failed.
+ * @retval SPP_RET_OK succeeded.
+ * @retval SPP_RET_NG failed.
  */
 int spp_forward_update(struct spp_component_info *component);
 
@@ -42,8 +42,8 @@ int spp_forward_update(struct spp_component_info *component);
  * @param id
  *  The unique component ID.
  *
- * @retval 0  succeeded.
- * @retval -1 failed.
+ * @retval SPP_RET_OK succeeded.
+ * @retval SPP_RET_NG failed.
  */
 int spp_forward(int id);
 
@@ -58,8 +58,8 @@ int spp_forward(int id);
  *  The pointer to struct spp_iterate_core_params.@n
  *  Detailed data of forwarder/merger status.
  *
- * @retval 0  succeeded.
- * @retval -1 failed.
+ * @retval SPP_RET_OK succeeded.
+ * @retval SPP_RET_NG failed.
  */
 int spp_forward_get_component_status(
 		unsigned int lcore_id, int id,
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index 1433731..9537591 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -62,7 +62,7 @@ usage(const char *progname)
  * Convert string of given client id to integer
  *
  * If succeeded, client id of integer is assigned to client_id and
- * return 0. Or return -1 if failed.
+ * return SPP_RET_OK Or return SPP_RET_NG if failed.
  */
 static int
 parse_app_client_id(const char *client_id_str, int *client_id)
@@ -72,14 +72,14 @@ parse_app_client_id(const char *client_id_str, int *client_id)
 
 	id = strtol(client_id_str, &endptr, 0);
 	if (unlikely(client_id_str == endptr) || unlikely(*endptr != '\0'))
-		return -1;
+		return SPP_RET_NG;
 
 	if (id >= RTE_MAX_LCORE)
-		return -1;
+		return SPP_RET_NG;
 
 	*client_id = id;
 	RTE_LOG(DEBUG, APP, "Set client id = %d\n", *client_id);
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* Parse options for server IP and port */
@@ -93,19 +93,19 @@ parse_app_server(const char *server_str, char *server_ip, int *server_port)
 
 	pos = strcspn(server_str, delim);
 	if (pos >= strlen(server_str))
-		return -1;
+		return SPP_RET_NG;
 
 	port = strtol(&server_str[pos+1], &endptr, 0);
 	if (unlikely(&server_str[pos+1] == endptr) ||
 				unlikely(*endptr != '\0'))
-		return -1;
+		return SPP_RET_NG;
 
 	memcpy(server_ip, server_str, pos);
 	server_ip[pos] = '\0';
 	*server_port = port;
 	RTE_LOG(DEBUG, APP, "Set server IP   = %s\n", server_ip);
 	RTE_LOG(DEBUG, APP, "Set server port = %d\n", *server_port);
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* Parse options for client app */
@@ -145,9 +145,10 @@ parse_app_args(int argc, char *argv[])
 		switch (opt) {
 		case SPP_LONGOPT_RETVAL_CLIENT_ID:
 			if (parse_app_client_id(optarg,
-					&g_startup_param.client_id) != 0) {
+					&g_startup_param.client_id) !=
+								SPP_RET_OK) {
 				usage(progname);
-				return -1;
+				return SPP_RET_NG;
 			}
 			proc_flg = 1;
 			break;
@@ -156,22 +157,23 @@ parse_app_args(int argc, char *argv[])
 			break;
 		case 's':
 			if (parse_app_server(optarg, g_startup_param.server_ip,
-					&g_startup_param.server_port) != 0) {
+					&g_startup_param.server_port) !=
+								SPP_RET_OK) {
 				usage(progname);
-				return -1;
+				return SPP_RET_NG;
 			}
 			server_flg = 1;
 			break;
 		default:
 			usage(progname);
-			return -1;
+			return SPP_RET_NG;
 		}
 	}
 
 	/* Check mandatory parameters */
 	if ((proc_flg == 0) || (server_flg == 0)) {
 		usage(progname);
-		return -1;
+		return SPP_RET_NG;
 	}
 	RTE_LOG(INFO, APP,
 			"app opts (client_id=%d,server=%s:%d,"
@@ -180,7 +182,7 @@ parse_app_args(int argc, char *argv[])
 			g_startup_param.server_ip,
 			g_startup_param.server_port,
 			g_startup_param.vhost_client);
-	return 0;
+	return SPP_RET_OK;
 }
 
 /* Main process of slave core */
@@ -241,12 +243,12 @@ slave_main(void *arg __attribute__ ((unused)))
 /**
  * Main function
  *
- * Return -1 explicitly if error is occurred.
+ * Return SPP_RET_NG explicitly if error is occurred.
  */
 int
 main(int argc, char *argv[])
 {
-	int ret = -1;
+	int ret = SPP_RET_NG;
 #ifdef SPP_DEMONIZE
 	/* Daemonize process */
 	int ret_daemon = daemon(0, 0);
@@ -271,7 +273,7 @@ main(int argc, char *argv[])
 
 		/* Parse spp_vf specific parameters */
 		int ret_parse = parse_app_args(argc, argv);
-		if (unlikely(ret_parse != 0))
+		if (unlikely(ret_parse != SPP_RET_OK))
 			break;
 
 		/* Get lcore id of main thread to set its status after */
@@ -285,17 +287,17 @@ main(int argc, char *argv[])
 					  g_change_core,
 					  g_change_component,
 					  &g_backup_info,
-					  g_main_lcore_id) < 0) {
+					  g_main_lcore_id) < SPP_RET_OK) {
 			RTE_LOG(ERR, APP, "manage address set is failed.\n");
 			break;
 		}
 
 		int ret_mng = init_mng_data();
-		if (unlikely(ret_mng != 0))
+		if (unlikely(ret_mng != SPP_RET_OK))
 			break;
 
 		int ret_classifier_mac_init = spp_classifier_mac_init();
-		if (unlikely(ret_classifier_mac_init != 0))
+		if (unlikely(ret_classifier_mac_init != SPP_RET_OK))
 			break;
 
 		spp_forward_init();
@@ -305,14 +307,14 @@ main(int argc, char *argv[])
 		int ret_command_init = spp_command_proc_init(
 				g_startup_param.server_ip,
 				g_startup_param.server_port);
-		if (unlikely(ret_command_init != 0))
+		if (unlikely(ret_command_init != SPP_RET_OK))
 			break;
 
 #ifdef SPP_RINGLATENCYSTATS_ENABLE
 		int ret_ringlatency = spp_ringlatencystats_init(
 				SPP_RING_LATENCY_STATS_SAMPLING_INTERVAL,
 				g_iface_info.num_ring);
-		if (unlikely(ret_ringlatency != 0))
+		if (unlikely(ret_ringlatency != SPP_RET_OK))
 			break;
 #endif /* SPP_RINGLATENCYSTATS_ENABLE */
 
@@ -325,7 +327,7 @@ main(int argc, char *argv[])
 		/* Set the status of main thread to idle */
 		g_core_info[g_main_lcore_id].status = SPP_CORE_IDLE;
 		int ret_wait = check_core_status_wait(SPP_CORE_IDLE);
-		if (unlikely(ret_wait != 0))
+		if (unlikely(ret_wait != SPP_RET_OK))
 			break;
 
 		/* Start forwarding */
@@ -337,7 +339,7 @@ main(int argc, char *argv[])
 		backup_mng_info(&g_backup_info);
 
 		/* Enter loop for accepting commands */
-		int ret_do = 0;
+		int ret_do = SPP_RET_OK;
 #ifndef USE_UT_SPP_VF
 		while (likely(g_core_info[g_main_lcore_id].status !=
 				SPP_CORE_STOP_REQUEST)) {
@@ -346,7 +348,7 @@ main(int argc, char *argv[])
 #endif
 			/* Receive command */
 			ret_do = spp_command_proc_do();
-			if (unlikely(ret_do != 0))
+			if (unlikely(ret_do != SPP_RET_OK))
 				break;
 
 			sleep(1);
@@ -356,12 +358,12 @@ main(int argc, char *argv[])
 #endif /* SPP_RINGLATENCYSTATS_ENABLE */
 		}
 
-		if (unlikely(ret_do != 0)) {
+		if (unlikely(ret_do != SPP_RET_OK)) {
 			set_all_core_status(SPP_CORE_STOP_REQUEST);
 			break;
 		}
 
-		ret = 0;
+		ret = SPP_RET_OK;
 		break;
 	}
 
@@ -369,7 +371,7 @@ main(int argc, char *argv[])
 	if (g_main_lcore_id == rte_lcore_id()) {
 		g_core_info[g_main_lcore_id].status = SPP_CORE_STOP;
 		int ret_core_end = check_core_status_wait(SPP_CORE_STOP);
-		if (unlikely(ret_core_end != 0))
+		if (unlikely(ret_core_end != SPP_RET_OK))
 			RTE_LOG(ERR, APP, "Core did not stop.\n");
 
 		/*
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 13/23] spp_vf: define terms of commands as consts
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (11 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 12/23] spp_vf: change return values to explain result x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 14/23] spp_vf: remove unnecessary includes x-fn-spp
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Add defines of terms of commands of spp_vf.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/command_dec.c | 80 ++++++++++++++++++++++++++-----------
 1 file changed, 56 insertions(+), 24 deletions(-)

diff --git a/src/vf/common/command_dec.c b/src/vf/common/command_dec.c
index 7cebbb5..13af984 100644
--- a/src/vf/common/command_dec.c
+++ b/src/vf/common/command_dec.c
@@ -14,14 +14,44 @@
 
 #define RTE_LOGTYPE_SPP_COMMAND_PROC RTE_LOGTYPE_USER1
 
+/* command string  */
+#define SPP_COMMAND_CLASSFIER_TABLE_STR	"classifier_table"
+#define SPP_COMMAND_GET_CLIENT_ID_STR	"_get_client_id"
+#define SPP_COMMAND_STATUS_STR		"status"
+#define SPP_COMMAND_EXIT_STR		"exit"
+#define SPP_COMMAND_COMPONENT_STR	"component"
+#define SPP_COMMAND_PORT_STR		"port"
+
+/* classifiler_type string */
+#define SPP_CLASSIFLER_NONE_STR		"none"
+#define SPP_CLASSIFLER_MAC_STR		"mac"
+#define SPP_CLASSIFLER_VLAN_STR		"vlan"
+
+/* command action string */
+#define SPP_ACTION_NONE_STR		"none"
+#define SPP_ACTION_START_STR		"start"
+#define SPP_ACTION_STOP_STR		"stop"
+#define SPP_ACTION_ADD_STR		"add"
+#define SPP_ACTION_DEL_STR		"del"
+
+/* port rx/tx string */
+#define SPP_PORT_RXTX_NONE_STR		"none"
+#define SPP_PORT_RXTX_RX_STR		"rx"
+#define SPP_PORT_RXTX_TX_STR		"tx"
+
+/* port ability string */
+#define SPP_ABILITY_NONE_STR		"none"
+#define SPP_ABILITY_ADD_VLANTAG_STR	"add_vlantag"
+#define SPP_ABILITY_DEL_VLANTAG_STR	"del_vlantag"
+
 /*
  * classifier type string list
  * do it same as the order of enum spp_classifier_type (spp_vf.h)
  */
 const char *CLASSIFILER_TYPE_STRINGS[] = {
-	"none",
-	"mac",
-	"vlan",
+	SPP_CLASSIFLER_NONE_STR,
+	SPP_CLASSIFLER_MAC_STR,
+	SPP_CLASSIFLER_VLAN_STR,
 
 	/* termination */ "",
 };
@@ -31,11 +61,11 @@ const char *CLASSIFILER_TYPE_STRINGS[] = {
  * do it same as the order of enum spp_command_action (spp_vf.h)
  */
 const char *COMMAND_ACTION_STRINGS[] = {
-	"none",
-	"start",
-	"stop",
-	"add",
-	"del",
+	SPP_ACTION_NONE_STR,
+	SPP_ACTION_START_STR,
+	SPP_ACTION_STOP_STR,
+	SPP_ACTION_ADD_STR,
+	SPP_ACTION_DEL_STR,
 
 	/* termination */ "",
 };
@@ -45,9 +75,9 @@ const char *COMMAND_ACTION_STRINGS[] = {
  * do it same as the order of enum spp_port_rxtx (spp_vf.h)
  */
 const char *PORT_RXTX_STRINGS[] = {
-	"none",
-	"rx",
-	"tx",
+	SPP_PORT_RXTX_NONE_STR,
+	SPP_PORT_RXTX_RX_STR,
+	SPP_PORT_RXTX_TX_STR,
 
 	/* termination */ "",
 };
@@ -57,9 +87,9 @@ const char *PORT_RXTX_STRINGS[] = {
  * do it same as the order of enum spp_port_ability_type (spp_vf.h)
  */
 const char *PORT_ABILITY_STRINGS[] = {
-	"none",
-	"add_vlantag",
-	"del_vlantag",
+	SPP_ABILITY_NONE_STR,
+	SPP_ABILITY_ADD_VLANTAG_STR,
+	SPP_ABILITY_DEL_VLANTAG_STR,
 
 	/* termination */ "",
 };
@@ -863,18 +893,20 @@ struct decode_command_list {
 
 /* command list */
 static struct decode_command_list command_list[] = {
-	{ "classifier_table", 5, 5, decode_command_parameter_in_list },
+	{ SPP_COMMAND_CLASSFIER_TABLE_STR, 5, 5,
+		decode_command_parameter_in_list },
 						/* classifier_table(mac) */
-	{ "classifier_table", 6, 6, decode_command_parameter_in_list },
+	{ SPP_COMMAND_CLASSFIER_TABLE_STR, 6, 6,
+		decode_command_parameter_in_list },
 						/* classifier_table(vlan) */
-	{ "_get_client_id",   1, 1, NULL },     /* _get_client_id   */
-	{ "status",           1, 1, NULL },     /* status           */
-	{ "exit",             1, 1, NULL },     /* exit             */
-	{ "component",        3, 5, decode_command_parameter_in_list },
-						/* component        */
-	{ "port",             5, 8, decode_command_parameter_in_list },
-						/* port             */
-	{ "",                 0, 0, NULL }      /* termination      */
+	{ SPP_COMMAND_GET_CLIENT_ID_STR, 1, 1, NULL }, /* _get_client_id  */
+	{ SPP_COMMAND_STATUS_STR,	 1, 1, NULL }, /* status	  */
+	{ SPP_COMMAND_EXIT_STR,		 1, 1, NULL }, /* exit		  */
+	{ SPP_COMMAND_COMPONENT_STR,	 3, 5,
+		decode_command_parameter_in_list },    /* component	  */
+	{ SPP_COMMAND_PORT_STR,		 5, 8,
+		decode_command_parameter_in_list },    /* port		  */
+	{ "",				 0, 0, NULL }  /* termination     */
 };
 
 /* Decode command line parameters */
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 14/23] spp_vf: remove unnecessary includes
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (12 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 13/23] spp_vf: define terms of commands as consts x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 15/23] spp_vf: add include header files x-fn-spp
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Remove including header files not needed anymore bacase of previous
change.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/command_dec.c  | 1 -
 src/vf/common/command_proc.c | 1 -
 src/vf/common/spp_port.h     | 2 --
 src/vf/spp_vf.c              | 6 ------
 4 files changed, 10 deletions(-)

diff --git a/src/vf/common/command_dec.c b/src/vf/common/command_dec.c
index 13af984..29c7951 100644
--- a/src/vf/common/command_dec.c
+++ b/src/vf/common/command_dec.c
@@ -9,7 +9,6 @@
 #include <rte_log.h>
 #include <rte_branch_prediction.h>
 
-#include "../spp_vf.h"
 #include "command_dec.h"
 
 #define RTE_LOGTYPE_SPP_COMMAND_PROC RTE_LOGTYPE_USER1
diff --git a/src/vf/common/command_proc.c b/src/vf/common/command_proc.c
index a726302..d1c04db 100644
--- a/src/vf/common/command_proc.c
+++ b/src/vf/common/command_proc.c
@@ -8,7 +8,6 @@
 #include <rte_log.h>
 #include <rte_branch_prediction.h>
 
-#include "../spp_vf.h"
 #include "spp_port.h"
 #include "string_buffer.h"
 #include "command_conn.h"
diff --git a/src/vf/common/spp_port.h b/src/vf/common/spp_port.h
index 71d1325..a59feca 100644
--- a/src/vf/common/spp_port.h
+++ b/src/vf/common/spp_port.h
@@ -12,8 +12,6 @@
  * Provide about the ability per port.
  */
 
-#include "../spp_vf.h"
-
 /** Calculate TCI of VLAN tag. */
 #define SPP_VLANTAG_CALC_TCI(id, pcp) (((pcp & 0x07) << 13) | (id & 0x0fff))
 
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index 9537591..63ad71a 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -6,13 +6,7 @@
 #include <arpa/inet.h>
 #include <getopt.h>
 
-#include <rte_eth_ring.h>
-#include <rte_eth_vhost.h>
-#include <rte_memzone.h>
-#include <rte_cycles.h>
-
 #include "spp_vf.h"
-#include "ringlatencystats.h"
 #include "classifier_mac.h"
 #include "spp_forward.h"
 #include "command_proc.h"
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 15/23] spp_vf: add include header files
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (13 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 14/23] spp_vf: remove unnecessary includes x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 16/23] spp_vf: update comments for header file x-fn-spp
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Add include paths for common files and 'spp_vf.c' for previous changes.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/command_conn.h     | 2 ++
 src/vf/common/command_dec.h      | 2 ++
 src/vf/common/command_proc.c     | 2 ++
 src/vf/common/command_proc.h     | 2 ++
 src/vf/common/ringlatencystats.c | 1 +
 src/vf/common/spp_port.h         | 2 ++
 src/vf/common/spp_proc.c         | 9 ++-------
 src/vf/spp_vf.c                  | 2 ++
 8 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/vf/common/command_conn.h b/src/vf/common/command_conn.h
index 3e56570..517c0e9 100644
--- a/src/vf/common/command_conn.h
+++ b/src/vf/common/command_conn.h
@@ -12,6 +12,8 @@
  * Command connection management.
  */
 
+#include "spp_proc.h"
+
 /** result code - temporary error. please retry */
 #define SPP_CONNERR_TEMPORARY -1
 /** result code - fatal error occurred. should terminate process. */
diff --git a/src/vf/common/command_dec.h b/src/vf/common/command_dec.h
index 84644f2..93b4ebe 100644
--- a/src/vf/common/command_dec.h
+++ b/src/vf/common/command_dec.h
@@ -12,6 +12,8 @@
  * Decode and validate the command message string.
  */
 
+#include "spp_proc.h"
+
 /** max number of command per request */
 #define SPP_CMD_MAX_COMMANDS 32
 
diff --git a/src/vf/common/command_proc.c b/src/vf/common/command_proc.c
index d1c04db..1331400 100644
--- a/src/vf/common/command_proc.c
+++ b/src/vf/common/command_proc.c
@@ -10,6 +10,8 @@
 
 #include "spp_port.h"
 #include "string_buffer.h"
+#include "../classifier_mac.h"
+#include "../spp_forward.h"
 #include "command_conn.h"
 #include "command_dec.h"
 #include "command_proc.h"
diff --git a/src/vf/common/command_proc.h b/src/vf/common/command_proc.h
index 9e261f3..5e846a3 100644
--- a/src/vf/common/command_proc.h
+++ b/src/vf/common/command_proc.h
@@ -13,6 +13,8 @@
  * result JSON formatted data.
  */
 
+#include "spp_proc.h"
+
 /**
  * initialize command processor.
  *
diff --git a/src/vf/common/ringlatencystats.c b/src/vf/common/ringlatencystats.c
index 1483a7e..6ea5a7e 100644
--- a/src/vf/common/ringlatencystats.c
+++ b/src/vf/common/ringlatencystats.c
@@ -15,6 +15,7 @@
 #include <rte_memcpy.h>
 
 #include "ringlatencystats.h"
+#include "spp_proc.h"
 
 #define NS_PER_SEC 1E9
 
diff --git a/src/vf/common/spp_port.h b/src/vf/common/spp_port.h
index a59feca..10409ab 100644
--- a/src/vf/common/spp_port.h
+++ b/src/vf/common/spp_port.h
@@ -12,6 +12,8 @@
  * Provide about the ability per port.
  */
 
+#include "spp_proc.h"
+
 /** Calculate TCI of VLAN tag. */
 #define SPP_VLANTAG_CALC_TCI(id, pcp) (((pcp & 0x07) << 13) | (id & 0x0fff))
 
diff --git a/src/vf/common/spp_proc.c b/src/vf/common/spp_proc.c
index a6ddeb6..87fb9d3 100644
--- a/src/vf/common/spp_proc.c
+++ b/src/vf/common/spp_proc.c
@@ -14,8 +14,8 @@
 #include "spp_proc.h"
 #include "spp_port.h"
 
-#include "../vf/spp_forward.h"
-#include "../vf/classifier_mac.h"
+#include "../spp_forward.h"
+#include "../classifier_mac.h"
 
 /* Manage data to addoress */
 struct manage_data_addr_info {
@@ -880,15 +880,10 @@ flush_component(void)
 		component_info = (p_component_info + cnt);
 		spp_port_ability_update(component_info);
 
-#ifdef SPP_VF_MODULE
 		if (component_info->type == SPP_COMPONENT_CLASSIFIER_MAC)
 			ret = spp_classifier_mac_update(component_info);
 		else
 			ret = spp_forward_update(component_info);
-#endif /* SPP_VF_MODULE */
-#ifdef SPP_MIRROR_MODULE
-		ret = spp_mirror_update(component_info);
-#endif /* SPP_MIRROR_MODULE */
 		if (unlikely(ret < 0)) {
 			RTE_LOG(ERR, APP, "Flush error. "
 					"( component = %s, type = %d)\n",
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index 63ad71a..7ceb88f 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -6,10 +6,12 @@
 #include <arpa/inet.h>
 #include <getopt.h>
 
+#include "spp_proc.h"
 #include "spp_vf.h"
 #include "classifier_mac.h"
 #include "spp_forward.h"
 #include "command_proc.h"
+#include "command_dec.h"
 #include "spp_port.h"
 
 /* Declare global variables */
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 16/23] spp_vf: update comments for header file
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (14 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 15/23] spp_vf: add include header files x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 17/23] spp_vf: update makefile of spp_vf x-fn-spp
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

This is a misc update. Change the name of header file for previous
change.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/command_dec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/vf/common/command_dec.c b/src/vf/common/command_dec.c
index 29c7951..9a49185 100644
--- a/src/vf/common/command_dec.c
+++ b/src/vf/common/command_dec.c
@@ -45,7 +45,7 @@
 
 /*
  * classifier type string list
- * do it same as the order of enum spp_classifier_type (spp_vf.h)
+ * do it same as the order of enum spp_classifier_type (spp_proc.h)
  */
 const char *CLASSIFILER_TYPE_STRINGS[] = {
 	SPP_CLASSIFLER_NONE_STR,
@@ -57,7 +57,7 @@ const char *CLASSIFILER_TYPE_STRINGS[] = {
 
 /*
  * command action type string list
- * do it same as the order of enum spp_command_action (spp_vf.h)
+ * do it same as the order of enum spp_command_action (command_dec.h)
  */
 const char *COMMAND_ACTION_STRINGS[] = {
 	SPP_ACTION_NONE_STR,
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 17/23] spp_vf: update makefile of spp_vf
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (15 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 16/23] spp_vf: update comments for header file x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 18/23] spp_vf: add check num of ports before forwarding x-fn-spp
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Update `SRCS-y` to add entry for 'common/spp_proc.c'.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/vf/Makefile b/src/vf/Makefile
index a1c7886..b0a1fdb 100644
--- a/src/vf/Makefile
+++ b/src/vf/Makefile
@@ -15,6 +15,7 @@ APP = spp_vf
 SRCS-y := spp_vf.c classifier_mac.c spp_forward.c
 SRCS-y += common/string_buffer.c common/ringlatencystats.c common/spp_port.c
 SRCS-y += common/command_conn.c common/command_dec.c common/command_proc.c
+SRCS-y += common/spp_proc.c
 SRCS-y += ../shared/common.c
 
 CFLAGS += $(WERROR_FLAGS) -O3
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 18/23] spp_vf: add check num of ports before forwarding
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (16 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 17/23] spp_vf: update makefile of spp_vf x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 19/23] spp_vf: add flag for classifier table x-fn-spp
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Add check the number of ports before forwarding for forwarder and
merger. For forwarder, start if both of rx and tx ports exist. For
merger, start if more than one rx ports and one tx port exist.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/spp_forward.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/vf/spp_forward.c b/src/vf/spp_forward.c
index 5e6189c..2dbb171 100644
--- a/src/vf/spp_forward.c
+++ b/src/vf/spp_forward.c
@@ -147,6 +147,17 @@ spp_forward(int id)
 	change_forward_index(id);
 	path = &info->path[info->ref_index];
 
+	/* Practice condition check */
+	if (path->type == SPP_COMPONENT_MERGE) {
+		/* merger */
+		if (!(path->num_tx == 1 && path->num_rx >= 1))
+			return SPP_RET_OK;
+	} else {
+		/* forwarder */
+		if (!(path->num_tx == 1 && path->num_rx == 1))
+			return SPP_RET_OK;
+	}
+
 	for (cnt = 0; cnt < path->num_rx; cnt++) {
 		rx = &path->ports[cnt].rx;
 		tx = &path->ports[cnt].tx;
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 19/23] spp_vf: add flag for classifier table
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (17 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 18/23] spp_vf: add check num of ports before forwarding x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 20/23] spp_vf: add checking the number of ports x-fn-spp
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Add a flag to check if any of MAC address is registered to the
classifier table. This flag is set to 0 if no entries, or 1 if one or
more entries are registered.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/classifier_mac.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index 42e43dc..0244f7e 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -112,6 +112,9 @@ struct component_info {
 	/* component name */
 	char name[SPP_NAME_STR_LEN];
 
+	/* mac address entry flag */
+	int mac_addr_entry;
+
 	/* mac address classification per vlan-id */
 	struct mac_classification *mac_classifications[SPP_NUM_VLAN_VID];
 
@@ -385,6 +388,7 @@ init_component_info(struct component_info *cmp_info,
 
 	/* set tx */
 	cmp_info->n_classified_data_tx = component_info->num_tx_port;
+	cmp_info->mac_addr_entry = 0;
 	for (i = 0; i < component_info->num_tx_port; i++) {
 		tx_port = component_info->tx_ports[i];
 		vid = tx_port->class_id.vlantag.vid;
@@ -416,6 +420,9 @@ init_component_info(struct component_info *cmp_info,
 		mac_cls->active_classifieds[
 				mac_cls->num_active_classified++] = i;
 
+		/* mac address entry flag set */
+		cmp_info->mac_addr_entry = 1;
+
 		/* store default classified */
 		if (unlikely(tx_port->class_id.mac_addr ==
 				SPP_DEFAULT_CLASSIFIED_DMY_ADDR)) {
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 20/23] spp_vf: add checking the number of ports
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (18 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 19/23] spp_vf: add flag for classifier table x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 21/23] spp_vf: add vlantag command check flag x-fn-spp
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Add checking the number of ports for classifier. It only allows exactly
one of rx port, tx port and classifier table exist while starting to
classify.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/classifier_mac.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index 0244f7e..cfaf96a 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -879,11 +879,25 @@ spp_classifier_mac_do(int id)
 		/* change index of update side */
 		change_update_index(mng_info, id);
 
-		/* decide classifier information of the current cycle */
+		/**
+		 * decide classifier information of the current cycle
+		 * If at least, one rx port, one tx port and one
+		 * classifier_table exist, then start classifying.
+		 * If not, stop classifying.
+		 */
 		cmp_info = mng_info->cmp_infos + mng_info->ref_index;
 		clsd_data_rx = &cmp_info->classified_data_rx;
 		clsd_data_tx = cmp_info->classified_data_tx;
 
+		/**
+		 * Perform condition check if reception/transmission
+		 * of packet should be done or not
+		 */
+		if (!(clsd_data_rx->iface_type != UNDEF &&
+				cmp_info->n_classified_data_tx >= 1 &&
+				cmp_info->mac_addr_entry == 1))
+			continue;
+
 		/* drain tx packets, if buffer is not filled for interval */
 		cur_tsc = rte_rdtsc();
 		if (unlikely(cur_tsc - prev_tsc > drain_tsc)) {
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 21/23] spp_vf: add vlantag command check flag
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (19 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 20/23] spp_vf: add checking the number of ports x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 22/23] spp_vf: simplify changing VLAN tag x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 23/23] spp_vf: add SPP_VF_MODULE preprocessor directive x-fn-spp
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Add a flag to override VLAN tag. If it is disabled, `port add` command
is failed to. This update is for allowing to execute `add_vlantag' even
if existing port.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/command_dec.c | 305 +++++++++++++++++++++++++-----------
 1 file changed, 216 insertions(+), 89 deletions(-)

diff --git a/src/vf/common/command_dec.c b/src/vf/common/command_dec.c
index 9a49185..82cd619 100644
--- a/src/vf/common/command_dec.c
+++ b/src/vf/common/command_dec.c
@@ -14,34 +14,34 @@
 #define RTE_LOGTYPE_SPP_COMMAND_PROC RTE_LOGTYPE_USER1
 
 /* command string  */
-#define SPP_COMMAND_CLASSFIER_TABLE_STR	"classifier_table"
-#define SPP_COMMAND_GET_CLIENT_ID_STR	"_get_client_id"
-#define SPP_COMMAND_STATUS_STR		"status"
-#define SPP_COMMAND_EXIT_STR		"exit"
-#define SPP_COMMAND_COMPONENT_STR	"component"
-#define SPP_COMMAND_PORT_STR		"port"
+#define SPP_COMMAND_CLASSFIER_TABLE_STR "classifier_table"
+#define SPP_COMMAND_GET_CLIENT_ID_STR   "_get_client_id"
+#define SPP_COMMAND_STATUS_STR          "status"
+#define SPP_COMMAND_EXIT_STR            "exit"
+#define SPP_COMMAND_COMPONENT_STR       "component"
+#define SPP_COMMAND_PORT_STR            "port"
 
 /* classifiler_type string */
-#define SPP_CLASSIFLER_NONE_STR		"none"
-#define SPP_CLASSIFLER_MAC_STR		"mac"
-#define SPP_CLASSIFLER_VLAN_STR		"vlan"
+#define SPP_CLASSIFLER_NONE_STR         "none"
+#define SPP_CLASSIFLER_MAC_STR          "mac"
+#define SPP_CLASSIFLER_VLAN_STR         "vlan"
 
 /* command action string */
-#define SPP_ACTION_NONE_STR		"none"
-#define SPP_ACTION_START_STR		"start"
-#define SPP_ACTION_STOP_STR		"stop"
-#define SPP_ACTION_ADD_STR		"add"
-#define SPP_ACTION_DEL_STR		"del"
+#define SPP_ACTION_NONE_STR             "none"
+#define SPP_ACTION_START_STR            "start"
+#define SPP_ACTION_STOP_STR             "stop"
+#define SPP_ACTION_ADD_STR              "add"
+#define SPP_ACTION_DEL_STR              "del"
 
 /* port rx/tx string */
-#define SPP_PORT_RXTX_NONE_STR		"none"
-#define SPP_PORT_RXTX_RX_STR		"rx"
-#define SPP_PORT_RXTX_TX_STR		"tx"
+#define SPP_PORT_RXTX_NONE_STR          "none"
+#define SPP_PORT_RXTX_RX_STR            "rx"
+#define SPP_PORT_RXTX_TX_STR            "tx"
 
 /* port ability string */
-#define SPP_ABILITY_NONE_STR		"none"
-#define SPP_ABILITY_ADD_VLANTAG_STR	"add_vlantag"
-#define SPP_ABILITY_DEL_VLANTAG_STR	"del_vlantag"
+#define SPP_ABILITY_NONE_STR            "none"
+#define SPP_ABILITY_ADD_VLANTAG_STR     "add_vlantag"
+#define SPP_ABILITY_DEL_VLANTAG_STR     "del_vlantag"
 
 /*
  * classifier type string list
@@ -344,7 +344,8 @@ decode_core_value(void *output, const char *arg_val)
 
 /* decoding procedure of action for component command */
 static int
-decode_component_action_value(void *output, const char *arg_val)
+decode_component_action_value(void *output, const char *arg_val,
+				int allow_override __attribute__ ((unused)))
 {
 	int ret = SPP_RET_OK;
 	ret = get_arrary_index(arg_val, COMMAND_ACTION_STRINGS);
@@ -369,7 +370,8 @@ decode_component_action_value(void *output, const char *arg_val)
 
 /* decoding procedure of action for component command */
 static int
-decode_component_name_value(void *output, const char *arg_val)
+decode_component_name_value(void *output, const char *arg_val,
+				int allow_override __attribute__ ((unused)))
 {
 	int ret = SPP_RET_OK;
 	struct spp_command_component *component = output;
@@ -390,7 +392,8 @@ decode_component_name_value(void *output, const char *arg_val)
 
 /* decoding procedure of core id for component command */
 static int
-decode_component_core_value(void *output, const char *arg_val)
+decode_component_core_value(void *output, const char *arg_val,
+				int allow_override __attribute__ ((unused)))
 {
 	struct spp_command_component *component = output;
 
@@ -403,7 +406,8 @@ decode_component_core_value(void *output, const char *arg_val)
 
 /* decoding procedure of type for component command */
 static int
-decode_component_type_value(void *output, const char *arg_val)
+decode_component_type_value(void *output, const char *arg_val,
+				int allow_override __attribute__ ((unused)))
 {
 	enum spp_component_type org_type, set_type;
 	struct spp_command_component *component = output;
@@ -435,7 +439,8 @@ decode_component_type_value(void *output, const char *arg_val)
 
 /* decoding procedure of action for port command */
 static int
-decode_port_action_value(void *output, const char *arg_val)
+decode_port_action_value(void *output, const char *arg_val,
+				int allow_override __attribute__ ((unused)))
 {
 	int ret = SPP_RET_OK;
 	ret = get_arrary_index(arg_val, COMMAND_ACTION_STRINGS);
@@ -460,7 +465,7 @@ decode_port_action_value(void *output, const char *arg_val)
 
 /* decoding procedure of port for port command */
 static int
-decode_port_port_value(void *output, const char *arg_val)
+decode_port_port_value(void *output, const char *arg_val, int allow_override)
 {
 	int ret = SPP_RET_NG;
 	struct spp_port_index tmp_port;
@@ -470,17 +475,20 @@ decode_port_port_value(void *output, const char *arg_val)
 	if (ret < SPP_RET_OK)
 		return SPP_RET_NG;
 
-	if ((port->action == SPP_CMD_ACTION_ADD) &&
-			(spp_check_used_port(tmp_port.iface_type,
-					tmp_port.iface_no,
-					SPP_PORT_RXTX_RX) >= 0) &&
-			(spp_check_used_port(tmp_port.iface_type,
-					tmp_port.iface_no,
-					SPP_PORT_RXTX_TX) >= 0)) {
-		RTE_LOG(ERR, SPP_COMMAND_PROC,
+	/* add vlantag command check */
+	if (allow_override == 0) {
+		if ((port->action == SPP_CMD_ACTION_ADD) &&
+				(spp_check_used_port(tmp_port.iface_type,
+						tmp_port.iface_no,
+						SPP_PORT_RXTX_RX) >= 0) &&
+				(spp_check_used_port(tmp_port.iface_type,
+						tmp_port.iface_no,
+						SPP_PORT_RXTX_TX) >= 0)) {
+			RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Port in used. (port command) val=%s\n",
 				arg_val);
-		return SPP_RET_NG;
+			return SPP_RET_NG;
+		}
 	}
 
 	port->port.iface_type = tmp_port.iface_type;
@@ -490,7 +498,7 @@ decode_port_port_value(void *output, const char *arg_val)
 
 /* decoding procedure of rxtx type for port command */
 static int
-decode_port_rxtx_value(void *output, const char *arg_val)
+decode_port_rxtx_value(void *output, const char *arg_val, int allow_override)
 {
 	int ret = SPP_RET_OK;
 	struct spp_command_port *port = output;
@@ -502,13 +510,16 @@ decode_port_rxtx_value(void *output, const char *arg_val)
 		return SPP_RET_NG;
 	}
 
-	if ((port->action == SPP_CMD_ACTION_ADD) &&
-			(spp_check_used_port(port->port.iface_type,
+	/* add vlantag command check */
+	if (allow_override == 0) {
+		if ((port->action == SPP_CMD_ACTION_ADD) &&
+				(spp_check_used_port(port->port.iface_type,
 					port->port.iface_no, ret) >= 0)) {
-		RTE_LOG(ERR, SPP_COMMAND_PROC,
+			RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Port in used. (port command) val=%s\n",
 				arg_val);
-		return SPP_RET_NG;
+			return SPP_RET_NG;
+		}
 	}
 
 	port->rxtx = ret;
@@ -517,7 +528,8 @@ decode_port_rxtx_value(void *output, const char *arg_val)
 
 /* decoding procedure of component name for port command */
 static int
-decode_port_name_value(void *output, const char *arg_val)
+decode_port_name_value(void *output, const char *arg_val,
+				int allow_override __attribute__ ((unused)))
 {
 	int ret = SPP_RET_OK;
 
@@ -531,9 +543,10 @@ decode_port_name_value(void *output, const char *arg_val)
 	return decode_str_value(output, arg_val);
 }
 
-/* decoding procedure of port ability for port command */
+/* decoding procedure of vlan operation for port command */
 static int
-decode_port_ability_value(void *output, const char *arg_val)
+decode_port_vlan_operation(void *output, const char *arg_val,
+				int allow_override __attribute__ ((unused)))
 {
 	int ret = SPP_RET_OK;
 	struct spp_command_port *port = output;
@@ -552,29 +565,62 @@ decode_port_ability_value(void *output, const char *arg_val)
 		ability->rxtx = port->rxtx;
 		break;
 	case SPP_PORT_ABILITY_OPE_ADD_VLANTAG:
-		if (ability->data.vlantag.pcp == 0) {
-			ret = get_int_value(&ability->data.vlantag.vid,
-					arg_val, 0, ETH_VLAN_ID_MAX);
-			if (unlikely(ret < 0)) {
-				RTE_LOG(ERR, SPP_COMMAND_PROC,
-						"Bad VLAN ID. val=%s\n",
-						arg_val);
-				return SPP_RET_NG;
-			}
-			ability->data.vlantag.pcp = -1;
-		} else {
-			ret = get_int_value(&ability->data.vlantag.pcp,
-					arg_val, 0, SPP_VLAN_PCP_MAX);
-			if (unlikely(ret < 0)) {
-				RTE_LOG(ERR, SPP_COMMAND_PROC,
-						"Bad VLAN PCP. val=%s\n",
-						arg_val);
-				return SPP_RET_NG;
-			}
+		/* Nothing to do. */
+		break;
+	default:
+		/* Not used. */
+		break;
+	}
+
+	return SPP_RET_OK;
+}
+
+/* decoding procedure of vid  for port command */
+static int
+decode_port_vid(void *output, const char *arg_val,
+				int allow_override __attribute__ ((unused)))
+{
+	int ret = SPP_RET_OK;
+	struct spp_command_port *port = output;
+	struct spp_port_ability *ability = &port->ability;
+
+	switch (ability->ope) {
+	case SPP_PORT_ABILITY_OPE_ADD_VLANTAG:
+		ret = get_int_value(&ability->data.vlantag.vid,
+			arg_val, 0, ETH_VLAN_ID_MAX);
+		if (unlikely(ret < SPP_RET_OK)) {
+			RTE_LOG(ERR, SPP_COMMAND_PROC,
+					"Bad VLAN ID. val=%s\n", arg_val);
+			return SPP_RET_NG;
 		}
+		ability->data.vlantag.pcp = -1;
 		break;
-	case SPP_PORT_ABILITY_OPE_DEL_VLANTAG:
-		/* Nothing to do. */
+	default:
+		/* Not used. */
+		break;
+	}
+
+	return SPP_RET_OK;
+}
+
+/* decoding procedure of pcp for port command */
+static int
+decode_port_pcp(void *output, const char *arg_val,
+				int allow_override __attribute__ ((unused)))
+{
+	int ret = SPP_RET_OK;
+	struct spp_command_port *port = output;
+	struct spp_port_ability *ability = &port->ability;
+
+	switch (ability->ope) {
+	case SPP_PORT_ABILITY_OPE_ADD_VLANTAG:
+		ret = get_int_value(&ability->data.vlantag.pcp,
+				arg_val, 0, SPP_VLAN_PCP_MAX);
+		if (unlikely(ret < SPP_RET_OK)) {
+			RTE_LOG(ERR, SPP_COMMAND_PROC,
+					"Bad VLAN PCP. val=%s\n", arg_val);
+			return SPP_RET_NG;
+		}
 		break;
 	default:
 		/* Not used. */
@@ -586,7 +632,8 @@ decode_port_ability_value(void *output, const char *arg_val)
 
 /* decoding procedure of mac address string */
 static int
-decode_mac_addr_str_value(void *output, const char *arg_val)
+decode_mac_addr_str_value(void *output, const char *arg_val,
+				int allow_override __attribute__ ((unused)))
 {
 	int64_t ret = SPP_RET_OK;
 	const char *str_val = arg_val;
@@ -608,7 +655,8 @@ decode_mac_addr_str_value(void *output, const char *arg_val)
 
 /* decoding procedure of action for classifier_table command */
 static int
-decode_classifier_action_value(void *output, const char *arg_val)
+decode_classifier_action_value(void *output, const char *arg_val,
+				int allow_override __attribute__ ((unused)))
 {
 	int ret = SPP_RET_OK;
 	ret = get_arrary_index(arg_val, COMMAND_ACTION_STRINGS);
@@ -631,7 +679,8 @@ decode_classifier_action_value(void *output, const char *arg_val)
 
 /* decoding procedure of type for classifier_table command */
 static int
-decode_classifier_type_value(void *output, const char *arg_val)
+decode_classifier_type_value(void *output, const char *arg_val,
+				int allow_override __attribute__ ((unused)))
 {
 	int ret = SPP_RET_OK;
 	ret = get_arrary_index(arg_val, CLASSIFILER_TYPE_STRINGS);
@@ -648,7 +697,8 @@ decode_classifier_type_value(void *output, const char *arg_val)
 
 /* decoding procedure of vlan id for classifier_table command */
 static int
-decode_classifier_vid_value(void *output, const char *arg_val)
+decode_classifier_vid_value(void *output, const char *arg_val,
+				int allow_override __attribute__ ((unused)))
 {
 	int ret = SPP_RET_NG;
 	ret = get_int_value(output, arg_val, 0, ETH_VLAN_ID_MAX);
@@ -662,7 +712,8 @@ decode_classifier_vid_value(void *output, const char *arg_val)
 
 /* decoding procedure of port for classifier_table command */
 static int
-decode_classifier_port_value(void *output, const char *arg_val)
+decode_classifier_port_value(void *output, const char *arg_val,
+				int allow_override __attribute__ ((unused)))
 {
 	int ret = SPP_RET_OK;
 	struct spp_command_classifier_table *classifier_table = output;
@@ -717,7 +768,7 @@ decode_classifier_port_value(void *output, const char *arg_val)
 struct decode_parameter_list {
 	const char *name;       /* Parameter name */
 	size_t offset;          /* Offset value of struct spp_command */
-	int (*func)(void *output, const char *arg_val);
+	int (*func)(void *output, const char *arg_val, int allow_override);
 				/* Pointer to parameter handling function */
 };
 
@@ -834,30 +885,31 @@ parameter_list[][SPP_CMD_MAX_PARAMETERS] = {
 			.func = decode_port_name_value
 		},
 		{
-			.name = "port ability 1",
+			.name = "port vlan operation",
 			.offset = offsetof(struct spp_command, spec.port),
-			.func = decode_port_ability_value
+			.func = decode_port_vlan_operation
 		},
 		{
-			.name = "port ability 2",
+			.name = "port vid",
 			.offset = offsetof(struct spp_command, spec.port),
-			.func = decode_port_ability_value
+			.func = decode_port_vid
 		},
 		{
-			.name = "port ability 3",
+			.name = "port pcp",
 			.offset = offsetof(struct spp_command, spec.port),
-			.func = decode_port_ability_value
+			.func = decode_port_pcp
 		},
 		DECODE_PARAMETER_LIST_EMPTY,
 	},
 	{ DECODE_PARAMETER_LIST_EMPTY }, /* termination      */
 };
 
-/* check by list for each command line parameter */
+/* check by list for each command line parameter component */
 static int
-decode_command_parameter_in_list(struct spp_command_request *request,
+decode_command_parameter_component(struct spp_command_request *request,
 				int argc, char *argv[],
-				struct spp_command_decode_error *error)
+				struct spp_command_decode_error *error,
+				int maxargc __attribute__ ((unused)))
 {
 	int ret = SPP_RET_OK;
 	int ci = request->commands[0].type;
@@ -867,7 +919,7 @@ decode_command_parameter_in_list(struct spp_command_request *request,
 		list = &parameter_list[ci][pi-1];
 		ret = (*list->func)((void *)
 				((char *)&request->commands[0]+list->offset),
-				argv[pi]);
+				argv[pi], 0);
 		if (unlikely(ret < 0)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
 					"Bad value. command=%s, name=%s, "
@@ -880,31 +932,105 @@ decode_command_parameter_in_list(struct spp_command_request *request,
 	return SPP_RET_OK;
 }
 
+/* check by list for each command line parameter clssfier_table */
+static int
+decode_command_parameter_cls_table(struct spp_command_request *request,
+				int argc, char *argv[],
+				struct spp_command_decode_error *error,
+				int maxargc)
+{
+	return decode_command_parameter_component(request,
+						argc,
+						argv,
+						error,
+						maxargc);
+}
+/* check by list for each command line parameter clssfier_table(vlan) */
+static int
+decode_command_parameter_cls_table_vlan(struct spp_command_request *request,
+				int argc, char *argv[],
+				struct spp_command_decode_error *error,
+				int maxargc __attribute__ ((unused)))
+{
+	int ret = SPP_RET_OK;
+	int ci = request->commands[0].type;
+	int pi = 0;
+	struct decode_parameter_list *list = NULL;
+	for (pi = 1; pi < argc; pi++) {
+		list = &parameter_list[ci][pi-1];
+		ret = (*list->func)((void *)
+				((char *)&request->commands[0]+list->offset),
+				argv[pi], 0);
+		if (unlikely(ret < SPP_RET_OK)) {
+			RTE_LOG(ERR, SPP_COMMAND_PROC, "Bad value. "
+				"command=%s, name=%s, index=%d, value=%s\n",
+					argv[0], list->name, pi, argv[pi]);
+			return set_string_value_decode_error(error, argv[pi],
+				list->name);
+		}
+	}
+	return SPP_RET_OK;
+}
+
+/* check by list for each command line parameter port */
+static int
+decode_command_parameter_port(struct spp_command_request *request,
+				int argc, char *argv[],
+				struct spp_command_decode_error *error,
+				int maxargc)
+{
+	int ret = SPP_RET_OK;
+	int ci = request->commands[0].type;
+	int pi = 0;
+	struct decode_parameter_list *list = NULL;
+	int flag = 0;
+
+	/* check add vlatag */
+	if (argc == maxargc)
+		flag = 1;
+
+	for (pi = 1; pi < argc; pi++) {
+		list = &parameter_list[ci][pi-1];
+		ret = (*list->func)((void *)
+				((char *)&request->commands[0]+list->offset),
+				argv[pi], flag);
+		if (unlikely(ret < SPP_RET_OK)) {
+			RTE_LOG(ERR, SPP_COMMAND_PROC, "Bad value. "
+				"command=%s, name=%s, index=%d, value=%s\n",
+					argv[0], list->name, pi, argv[pi]);
+			return set_string_value_decode_error(error, argv[pi],
+				list->name);
+		}
+	}
+	return SPP_RET_OK;
+}
+
 /* command list for decoding */
 struct decode_command_list {
 	const char *name;       /* Command name */
 	int   param_min;        /* Min number of parameters */
 	int   param_max;        /* Max number of parameters */
 	int (*func)(struct spp_command_request *request, int argc,
-			char *argv[], struct spp_command_decode_error *error);
+			char *argv[], struct spp_command_decode_error *error,
+			int maxargc);
 				/* Pointer to command handling function */
 };
 
 /* command list */
 static struct decode_command_list command_list[] = {
 	{ SPP_COMMAND_CLASSFIER_TABLE_STR, 5, 5,
-		decode_command_parameter_in_list },
-						/* classifier_table(mac) */
+		decode_command_parameter_cls_table  },
+						/* classifier_table(mac)  */
 	{ SPP_COMMAND_CLASSFIER_TABLE_STR, 6, 6,
-		decode_command_parameter_in_list },
+		decode_command_parameter_cls_table_vlan },
 						/* classifier_table(vlan) */
 	{ SPP_COMMAND_GET_CLIENT_ID_STR, 1, 1, NULL }, /* _get_client_id  */
-	{ SPP_COMMAND_STATUS_STR,	 1, 1, NULL }, /* status	  */
-	{ SPP_COMMAND_EXIT_STR,		 1, 1, NULL }, /* exit		  */
+	{ SPP_COMMAND_STATUS_STR,	 1, 1, NULL }, /* status          */
+	{ SPP_COMMAND_EXIT_STR,		 1, 1, NULL }, /* exit            */
 	{ SPP_COMMAND_COMPONENT_STR,	 3, 5,
-		decode_command_parameter_in_list },    /* component	  */
+		decode_command_parameter_component  }, /* component       */
 	{ SPP_COMMAND_PORT_STR,		 5, 8,
-		decode_command_parameter_in_list },    /* port		  */
+		decode_command_parameter_port       }, /* port            */
 	{ "",				 0, 0, NULL }  /* termination     */
 };
 
@@ -947,7 +1073,8 @@ decode_command_in_list(struct spp_command_request *request,
 
 		request->commands[0].type = i;
 		if (list->func != NULL)
-			return (*list->func)(request, argc, argv, error);
+			return (*list->func)(request, argc, argv, error,
+							list->param_max);
 
 		return SPP_RET_OK;
 	}
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 22/23] spp_vf: simplify changing VLAN tag
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (20 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 21/23] spp_vf: add vlantag command check flag x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  2018-11-21  1:35 ` [spp] [PATCH 23/23] spp_vf: add SPP_VF_MODULE preprocessor directive x-fn-spp
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

To change VLAN tag of a port, it should be deleted before and added as
new one. This update is to allow to change VLAN tag at once.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/command_proc.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/vf/common/command_proc.c b/src/vf/common/command_proc.c
index 1331400..0c62968 100644
--- a/src/vf/common/command_proc.c
+++ b/src/vf/common/command_proc.c
@@ -337,13 +337,32 @@ spp_update_port(enum spp_command_action action,
 	switch (action) {
 	case SPP_CMD_ACTION_ADD:
 		ret_check = check_port_element(port_info, *num, ports);
-		if (ret_check >= 0)
+		/* registered check */
+		if (ret_check >= SPP_RET_OK) {
+			/* registered */
+			if (ability->ope == SPP_PORT_ABILITY_OPE_ADD_VLANTAG) {
+				while ((cnt < SPP_PORT_ABILITY_MAX) &&
+					    (port_info->ability[cnt].ope !=
+					    SPP_PORT_ABILITY_OPE_ADD_VLANTAG))
+					cnt++;
+				if (cnt >= SPP_PORT_ABILITY_MAX) {
+					RTE_LOG(ERR, APP, "update VLAN tag "
+						"Non-registratio\n");
+					return SPP_RET_NG;
+				}
+				memcpy(&port_info->ability[cnt], ability,
+					sizeof(struct spp_port_ability));
+
+				ret = SPP_RET_OK;
+				break;
+			}
 			return SPP_RET_OK;
+		}
 
 		if (*num >= RTE_MAX_ETHPORTS) {
 			RTE_LOG(ERR, APP, "Cannot assign port over the "
 				"maximum number.\n");
-			break;
+			return SPP_RET_NG;
 		}
 
 		if (ability->ope != SPP_PORT_ABILITY_OPE_NONE) {
@@ -387,7 +406,7 @@ spp_update_port(enum spp_command_action action,
 		break;
 
 	default:
-		break;
+		return SPP_RET_NG;
 	}
 
 	*(change_component + component_id) = 1;
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [spp] [PATCH 23/23] spp_vf: add SPP_VF_MODULE preprocessor directive
       [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (21 preceding siblings ...)
  2018-11-21  1:35 ` [spp] [PATCH 22/23] spp_vf: simplify changing VLAN tag x-fn-spp
@ 2018-11-21  1:35 ` x-fn-spp
  22 siblings, 0 replies; 23+ messages in thread
From: x-fn-spp @ 2018-11-21  1:35 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Add `SPP_VF_MODULE` preprocessor directive to compile just spp_vf in
selective.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/command_dec.c  |  2 ++
 src/vf/common/command_proc.c | 13 ++++++++++++-
 src/vf/common/spp_proc.c     |  4 ++++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/vf/common/command_dec.c b/src/vf/common/command_dec.c
index 82cd619..84268de 100644
--- a/src/vf/common/command_dec.c
+++ b/src/vf/common/command_dec.c
@@ -186,6 +186,7 @@ spp_convert_port_to_iface(const char *port,
 static enum spp_component_type
 spp_convert_component_type(const char *type_str)
 {
+#ifdef SPP_VF_MODULE
 	if (strncmp(type_str, CORE_TYPE_CLASSIFIER_MAC_STR,
 			strlen(CORE_TYPE_CLASSIFIER_MAC_STR)+1) == 0) {
 		/* Classifier */
@@ -199,6 +200,7 @@ spp_convert_component_type(const char *type_str)
 		/* Forwarder */
 		return SPP_COMPONENT_FORWARD;
 	}
+#endif /* SPP_VF_MODULE */
 	return SPP_COMPONENT_UNUSE;
 }
 
diff --git a/src/vf/common/command_proc.c b/src/vf/common/command_proc.c
index 0c62968..f274707 100644
--- a/src/vf/common/command_proc.c
+++ b/src/vf/common/command_proc.c
@@ -10,8 +10,10 @@
 
 #include "spp_port.h"
 #include "string_buffer.h"
+#ifdef SPP_VF_MODULE
 #include "../classifier_mac.h"
 #include "../spp_forward.h"
+#endif /* SPP_VF_MODULE */
 #include "command_conn.h"
 #include "command_dec.h"
 #include "command_proc.h"
@@ -467,6 +469,7 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
 		}
 
 		for (cnt = 0; cnt < core->num; cnt++) {
+#ifdef SPP_VF_MODULE
 			if (core->type == SPP_COMPONENT_CLASSIFIER_MAC) {
 				ret = spp_classifier_get_component_status(
 						lcore_id,
@@ -478,6 +481,7 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
 						core->id[cnt],
 						params);
 			}
+#endif /* SPP_VF_MODULE */
 			if (unlikely(ret != 0)) {
 				RTE_LOG(ERR, APP, "Cannot iterate core "
 						"information. "
@@ -492,6 +496,7 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
 }
 
 /* Iterate classifier_table to create response to status command */
+#ifdef SPP_VF_MODULE
 static int
 spp_iterate_classifier_table(
 		struct spp_iterate_classifier_table_params *params)
@@ -506,6 +511,7 @@ spp_iterate_classifier_table(
 
 	return SPP_RET_OK;
 }
+#endif /* SPP_VF_MODULE */
 
 /* Get port number assigned by DPDK lib */
 static int
@@ -1119,6 +1125,7 @@ append_core_value(const char *name, char **output,
 }
 
 /* append one element of classifier table for JSON format */
+#ifdef SPP_VF_MODULE
 static int
 append_classifier_element_value(
 		struct spp_iterate_classifier_table_params *params,
@@ -1171,8 +1178,10 @@ append_classifier_element_value(
 	params->output = buff;
 	return ret;
 }
+#endif /* SPP_VF_MODULE */
 
 /* append a list of classifier table for JSON format */
+#ifdef SPP_VF_MODULE
 static int
 append_classifier_table_value(const char *name, char **output,
 		void *tmp __attribute__ ((unused)))
@@ -1200,7 +1209,7 @@ append_classifier_table_value(const char *name, char **output,
 	spp_strbuf_free(itr_params.output);
 	return ret;
 }
-
+#endif /* SPP_VF_MODULE */
 /* append string of command response list for JSON format */
 static int
 append_response_list_value(char **output,
@@ -1276,7 +1285,9 @@ struct command_response_list response_info_list[] = {
 	{ "vhost",            append_interface_value },
 	{ "ring",             append_interface_value },
 	{ "core",             append_core_value },
+#ifdef SPP_VF_MODULE
 	{ "classifier_table", append_classifier_table_value },
+#endif /* SPP_VF_MODULE */
 	COMMAND_RESP_TAG_LIST_EMPTY
 };
 
diff --git a/src/vf/common/spp_proc.c b/src/vf/common/spp_proc.c
index 87fb9d3..5119612 100644
--- a/src/vf/common/spp_proc.c
+++ b/src/vf/common/spp_proc.c
@@ -14,8 +14,10 @@
 #include "spp_proc.h"
 #include "spp_port.h"
 
+#ifdef SPP_VF_MODULE
 #include "../spp_forward.h"
 #include "../classifier_mac.h"
+#endif /* SPP_VF_MODULE */
 
 /* Manage data to addoress */
 struct manage_data_addr_info {
@@ -880,10 +882,12 @@ flush_component(void)
 		component_info = (p_component_info + cnt);
 		spp_port_ability_update(component_info);
 
+#ifdef SPP_VF_MODULE
 		if (component_info->type == SPP_COMPONENT_CLASSIFIER_MAC)
 			ret = spp_classifier_mac_update(component_info);
 		else
 			ret = spp_forward_update(component_info);
+#endif /* SPP_VF_MODULE */
 		if (unlikely(ret < 0)) {
 			RTE_LOG(ERR, APP, "Flush error. "
 					"( component = %s, type = %d)\n",
-- 
2.18.0

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2018-11-21  1:41 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20181121013558.8869-1-x-fn-spp@sl.ntt-tx.co.jp>
2018-11-21  1:35 ` [spp] [PATCH 01/23] spp_vf: fix invalid code for max chars x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 02/23] spp_vf: move common source and header files x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 03/23] spp_vf: change include path x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 04/23] spp_vf: update Makefile for common files x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 05/23] spp_vf: move functions to common directory x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 06/23] spp_vf: move defines to common dir x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 07/23] spp_vf: move functions for decode " x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 08/23] spp_vf: move defines " x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 09/23] spp_vf: move functions to command_proc.c x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 10/23] spp_vf: add management data registration x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 11/23] spp_vf: change reference of management data x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 12/23] spp_vf: change return values to explain result x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 13/23] spp_vf: define terms of commands as consts x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 14/23] spp_vf: remove unnecessary includes x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 15/23] spp_vf: add include header files x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 16/23] spp_vf: update comments for header file x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 17/23] spp_vf: update makefile of spp_vf x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 18/23] spp_vf: add check num of ports before forwarding x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 19/23] spp_vf: add flag for classifier table x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 20/23] spp_vf: add checking the number of ports x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 21/23] spp_vf: add vlantag command check flag x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 22/23] spp_vf: simplify changing VLAN tag x-fn-spp
2018-11-21  1:35 ` [spp] [PATCH 23/23] spp_vf: add SPP_VF_MODULE preprocessor directive x-fn-spp

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).