Soft Patch Panel
 help / color / mirror / Atom feed
From: x-fn-spp@sl.ntt-tx.co.jp
To: spp@dpdk.org
Subject: [spp] [PATCH 55/57] spp_vf: add display of status command
Date: Thu, 28 Dec 2017 13:56:02 +0900	[thread overview]
Message-ID: <201712280456.vBS4u8jS011162@imss03.silk.ntt-tx.co.jp> (raw)
In-Reply-To: <4aae78ff-3b6c-cdfe-a8b7-24ec08b73935@lab.ntt.co.jp>

From: Hiroyuki Nakamura <nakamura.hioryuki@po.ntt-tx.co.jp>

* Display client ID.
* Display information for each port.
* Display information for each core.

Signed-off-by: Kentaro Watanabe <watanabe.kentaro.z01@as.ntt-tx.co.jp>
Signed-off-by: Yasufum Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/spp_vf.py           |  25 ++++--
 src/vf/classifier_mac.c |  86 +++++++++++++++---
 src/vf/classifier_mac.h |  10 +++
 src/vf/command_dec.c    |   2 +-
 src/vf/command_proc.c   | 232 ++++++++++++++++++++++++++++++++++++++++++++++--
 src/vf/spp_forward.c    |  73 ++++++++++++---
 src/vf/spp_forward.h    |   8 +-
 src/vf/spp_vf.c         |  51 +++++++++++
 src/vf/spp_vf.h         |  30 +++++++
 9 files changed, 479 insertions(+), 38 deletions(-)

diff --git a/src/spp_vf.py b/src/spp_vf.py
index 505a142..a96b987 100755
--- a/src/spp_vf.py
+++ b/src/spp_vf.py
@@ -40,6 +40,7 @@ def connectionthread(name, client_id, conn, m2s, s2m):
     """Manage secondary process connections"""
 
     cmd_str = 'hello'
+    recv_str = 'recv'
 
     #infinite loop so that function do not terminate and thread do not end.
     while True:
@@ -60,12 +61,24 @@ def connectionthread(name, client_id, conn, m2s, s2m):
 
         #Receiving from secondary
         try:
-            data = conn.recv(2048) # 2048 stands for bytes of data to be received
-            if data:
-                s2m.put("recv:" + str(conn.fileno()) + ":" + "{" + data + "}")
-            else:
-                s2m.put("closing:" + str(conn))
+            recv_str = ""
+            while True:
+                data = conn.recv(1024) # 1024 stands for bytes of data to be received
+                if data:
+                    recv_str = recv_str + data
+                    if len(data) < 1024:
+                        break
+                else:
+                    break
+            if len(recv_str) > 0:
+                recv_str = "recv:" + str(conn.fileno()) + ":len:" + str(len(recv_str)) + ":\n{" + recv_str + "}\n"
+
+            if not data:
+                s2m.put(recv_str + "closing:" + str(conn))
                 break
+
+            #s2m.put("recv:" + str(conn.fileno()) + ":{" + recv_str + "}")
+            s2m.put(recv_str)
         except Exception, excep:
             print (str(excep))
             break
@@ -212,7 +225,7 @@ def primarythread(sock, main2primary, primary2main):
 
             #Receiving from primary
             try:
-                data = conn.recv(2048) # 2048 stands for bytes of data to be received
+                data = conn.recv(1024) # 1024 stands for bytes of data to be received
                 if data:
                     primary2main.put("recv:" + str(addr) + ":" + "{" + data + "}")
                 else:
diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index 937a8c0..2dc6071 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -67,21 +67,23 @@ static const size_t ETHER_ADDR_STR_BUF_SZ =
 struct classified_data {
 	enum port_type  if_type;              /* interface type (see "enum port_type") */
 	int             if_no;                /* index of ports handled by classifier  */
-	int             if_no_global;         /* interface number                      */
-	uint8_t         port;                 /* port number used by dpdk              */
+	int             if_no_global;         /* id for interface generated by spp_vf  */
+	uint8_t         port;                 /* id for port generated by DPDK         */
 	uint16_t        num_pkt;              /* the number of packets in pkts[]       */
 	struct rte_mbuf *pkts[MAX_PKT_BURST]; /* packet array to be classified         */
 };
 
 /* classifier information */
 struct classifier_mac_info {
-	struct rte_hash *classifier_table;
-	int num_active_classified;
-	int active_classifieds[RTE_MAX_ETHPORTS];
-	int default_classified;
-	int n_classified_data_tx;
-	struct classified_data classified_data_rx;
+	char name[SPP_NAME_STR_LEN];               /* component name                    */
+	struct rte_hash *classifier_table;         /* hash table keeps classifier_table */
+	int num_active_classified;                 /* number of valid classification    */
+	int active_classifieds[RTE_MAX_ETHPORTS];  /* index of valid classification     */
+	int default_classified;                    /* index of default classification   */
+	int n_classified_data_tx;                  /* number of transmission ports      */
+	struct classified_data classified_data_rx; /* recive port handled by classifier */
 	struct classified_data classified_data_tx[RTE_MAX_ETHPORTS];
+						/* transmission ports handled by classifier */
 };
 
 /* classifier management information */
@@ -126,7 +128,13 @@ init_classifier_info(struct classifier_mac_info *classifier_info,
 	classifier_info->num_active_classified = 0;
 	classifier_info->default_classified = -1;
 	classifier_info->n_classified_data_tx = component_info->num_tx_port;
-	if (component_info->num_rx_port != 0) {
+	if (component_info->num_rx_port == 0) {
+		classified_data_rx->if_type      = UNDEF;
+		classified_data_rx->if_no        = 0;
+		classified_data_rx->if_no_global = 0;
+		classified_data_rx->port         = 0;
+		classified_data_rx->num_pkt      = 0;
+	} else {
 		classified_data_rx->if_type      = component_info->rx_ports[0]->if_type;
 		classified_data_rx->if_no        = 0;
 		classified_data_rx->if_no_global = component_info->rx_ports[0]->if_no;
@@ -273,6 +281,8 @@ uninit_classifier(struct classifier_mac_mng_info *classifier_mng_info)
 		if (classifier_mng_info->info[i].classifier_table != NULL){
 			rte_hash_free(classifier_mng_info->info[i].classifier_table);
 			classifier_mng_info->info[i].classifier_table = NULL;
+			classifier_mng_info->ref_index = 0;
+			classifier_mng_info->upd_index = 0;
 		}
 	}
 }
@@ -478,6 +488,7 @@ spp_classifier_mac_update(struct spp_component_info *component_info)
 				"Cannot update classifer mac. ret=%d\n", ret);
 		return ret;
 	}
+	memcpy(classifier_info->name, component_info->name, SPP_NAME_STR_LEN);
 
 	/* change index of reference side */
 	classifier_mng_info->upd_index = classifier_mng_info->ref_index;
@@ -548,6 +559,9 @@ spp_classifier_mac_do(int id)
 			prev_tsc = cur_tsc;
 		}
 
+		if (classified_data_rx->if_type == UNDEF)
+			continue;
+
 		/* retrieve packets */
 		n_rx = rte_eth_rx_burst(classified_data_rx->port, 0,
 				rx_pkts, MAX_PKT_BURST);
@@ -573,8 +587,60 @@ spp_classifier_mac_do(int id)
 	return 0;
 }
 
+/* classifier iterate component information */
+int
+spp_classifier_component_info_iterate(unsigned int lcore_id, int id,
+		struct spp_iterate_core_params *params)
+{
+	int ret = -1;
+	int i, num_tx, num_rx = 0;
+	struct classifier_mac_mng_info *classifier_mng_info;
+	struct classifier_mac_info *classifier_info;
+	struct classified_data *classified_data;
+	struct spp_port_index rx_ports[RTE_MAX_ETHPORTS];
+	struct spp_port_index tx_ports[RTE_MAX_ETHPORTS];
+
+	classifier_mng_info = g_classifier_mng_info + id;
+	if (! is_used_mng_info(classifier_mng_info)) {
+		RTE_LOG(ERR, SPP_CLASSIFIER_MAC,
+				"Component[%d] Not used. (status)(core = %d, type = %d)\n",
+				id, lcore_id, SPP_COMPONENT_CLASSIFIER_MAC);
+		return -1;
+	}
+
+	classifier_info = classifier_mng_info->info + 
+			classifier_mng_info->ref_index;
+
+	classified_data = classifier_info->classified_data_tx;
+
+	memset(rx_ports, 0x00, sizeof(rx_ports));
+	if (classifier_info->classified_data_rx.if_type != UNDEF) {
+		num_rx = 1;
+		rx_ports[0].if_type = classifier_info->classified_data_rx.if_type;
+		rx_ports[0].if_no   = classifier_info->classified_data_rx.if_no_global;
+	}
+
+	memset(tx_ports, 0x00, sizeof(tx_ports));
+	num_tx = classifier_info->n_classified_data_tx;
+	for (i = 0; i < num_tx; i++) {
+		tx_ports[i].if_type = classified_data[i].if_type;
+		tx_ports[i].if_no   = classified_data[i].if_no_global;
+	}
+
+	/* Set the information with the function specified by the command. */
+	ret = (*params->element_proc)(
+		params->opaque, lcore_id,
+		classifier_info->name, SPP_TYPE_CLASSIFIER_MAC_STR,
+		num_rx, rx_ports, num_tx, tx_ports);
+	if (unlikely(ret != 0))
+		return -1;
+
+	return 0;
+}
+
 /* classifier(mac address) iterate classifier table. */
-int spp_classifier_mac_iterate_table(
+int
+spp_classifier_mac_iterate_table(
 		struct spp_iterate_classifier_table_params *params)
 {
 	int ret, i;
diff --git a/src/vf/classifier_mac.h b/src/vf/classifier_mac.h
index f182668..b38ce70 100644
--- a/src/vf/classifier_mac.h
+++ b/src/vf/classifier_mac.h
@@ -29,6 +29,16 @@ int spp_classifier_mac_update(struct spp_component_info *component_info);
  */
 int spp_classifier_mac_do(int id);
 
+/*
+ * classifier iterate component information
+ *
+ * @ret_val 0  succeeded.
+ * @ret_val -1 failed.
+ */
+int
+spp_classifier_component_info_iterate(unsigned int lcore_id, int id,
+		struct spp_iterate_core_params *params);
+
 /**
  * classifier(mac address) iterate classifier table.
  */
diff --git a/src/vf/command_dec.c b/src/vf/command_dec.c
index 166901c..56360e9 100644
--- a/src/vf/command_dec.c
+++ b/src/vf/command_dec.c
@@ -566,7 +566,7 @@ static struct decode_command_list command_list[] = {
 	{ "_get_client_id",   1, 1, NULL                            }, /* _get_client_id   */
 	{ "status",           1, 1, NULL                            }, /* status           */
 	{ "exit",             1, 1, NULL                            }, /* exit             */
-	{ "component",        3, 5, decode_comand_parameter_in_list }, /* port             */
+	{ "component",        3, 5, decode_comand_parameter_in_list }, /* component        */
 	{ "port",             5, 5, decode_comand_parameter_in_list }, /* port             */
 	{ "",                 0, 0, NULL                            }  /* termination      */
 };
diff --git a/src/vf/command_proc.c b/src/vf/command_proc.c
index 0a45874..6159e87 100644
--- a/src/vf/command_proc.c
+++ b/src/vf/command_proc.c
@@ -243,9 +243,191 @@ append_response_client_id_value(json_t *parent_obj)
 	return 0;
 }
 
+/* append client-id value */
+static int
+append_client_id_value(json_t *parent_obj)
+{
+	int ret = -1;
+	ret = json_object_set_new(parent_obj, "client-id",
+			json_integer(spp_get_client_id()));
+	if (unlikely(ret != 0))
+		return -1;
+
+	return 0;
+}
+
+/* append interface array */
+static int
+append_interface_array(json_t *parent_obj, const char *name,
+		const enum port_type type)
+{
+	int ret = -1;
+	int i = 0;
+	json_t *array_obj;
+	array_obj = json_array();
+	if (unlikely(array_obj == NULL))
+		return -1;
+
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
+		if (!spp_check_flush_port(type, i))
+			continue;
+
+		ret = json_array_append_new(array_obj, json_integer(i));
+		if (unlikely(ret != 0)) {
+			json_decref(array_obj);
+			return -1;
+		}
+	}
+
+	ret = json_object_set_new(parent_obj, name, array_obj);
+	if (unlikely(ret != 0)) {
+		json_decref(array_obj);
+		return -1;
+	}
+
+	return 0;
+}
+
+/* append interface value */
+static int
+append_interface_value(json_t *parent_obj)
+{
+	int ret = -1;
+	ret = append_interface_array(parent_obj, "phy", PHY);
+	if (unlikely(ret != 0))
+		return -1;
+
+	ret = append_interface_array(parent_obj, "vhost", VHOST);
+	if (unlikely(ret != 0))
+		return -1;
+
+	ret = append_interface_array(parent_obj, "ring", RING);
+	if (unlikely(ret != 0))
+		return -1;
+
+	return 0;
+}
+
+/* append port array */
+static int
+apeend_port_array(json_t *parent_obj, const char *name,
+		const int num, const struct spp_port_index *ports)
+{
+	int ret = -1;
+	int i = 0;
+	char port_str[64];
+	json_t *array_obj;
+	array_obj = json_array();
+	if (unlikely(array_obj == NULL))
+		return -1;
+
+	for (i = 0; i < num; i++) {
+		spp_format_port_string(port_str, ports[i].if_type,
+				ports[i].if_no);
+		ret = json_array_append_new(array_obj, json_string(port_str));
+		if (unlikely(ret != 0)) {
+			json_decref(array_obj);
+			return -1;
+		}
+	}
+
+	ret = json_object_set_new(parent_obj, name, array_obj);
+	if (unlikely(ret != 0)) {
+		json_decref(array_obj);
+		return -1;
+	}
+
+	return 0;
+}
+
+/* append core element value */
+static int
+append_core_element_value(
+		void *opaque, 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)
+{
+	int ret = -1;
+	json_t *parent_obj = (json_t *)opaque;
+	json_t *tab_obj;
+
+	tab_obj = json_object();
+	if (unlikely(tab_obj == NULL))
+		return -1;
+
+	ret = json_object_set_new(tab_obj, "core", json_integer(lcore_id));
+	if (unlikely(ret != 0)) {
+		json_decref(tab_obj);
+		return -1;
+	}
+
+	ret = json_object_set_new(tab_obj, "name", json_string(name));
+	if (unlikely(ret != 0)) {
+		json_decref(tab_obj);
+		return -1;
+	}
+
+	ret = json_object_set_new(tab_obj, "type", json_string(type));
+	if (unlikely(ret != 0)) {
+		json_decref(tab_obj);
+		return -1;
+	}
+
+	ret = apeend_port_array(tab_obj, "rx_port", num_rx, rx_ports);
+	if (unlikely(ret != 0)) {
+		json_decref(tab_obj);
+		return -1;
+	}
+
+	ret = apeend_port_array(tab_obj, "tx_port", num_tx, tx_ports);
+	if (unlikely(ret != 0)) {
+		json_decref(tab_obj);
+		return -1;
+	}
+
+	ret = json_array_append_new(parent_obj, tab_obj);
+	if (unlikely(ret != 0)) {
+		json_decref(tab_obj);
+		return -1;
+	}
+
+	return 0;
+}
+
+/* append core value */
+static int
+append_response_core_value(json_t *parent_obj)
+{
+	int ret = -1;
+	json_t *tab_obj;
+	struct spp_iterate_core_params itr_params;
+
+	tab_obj = json_array();
+	if (unlikely(tab_obj == NULL))
+		return -1;
+
+	itr_params.opaque = tab_obj;
+	itr_params.element_proc = append_core_element_value;
+
+	ret = spp_iterate_core_info(&itr_params);
+	if (unlikely(ret != 0)) {
+		json_decref(tab_obj);
+		return -1;
+	}
+
+	ret = json_object_set_new(parent_obj, "core", tab_obj);
+	if (unlikely(ret != 0)) {
+		json_decref(tab_obj);
+		return -1;
+	}
+
+	return 0;
+}
+
 /* append classifier element value */
-static
-int append_classifier_element_value(
+static int
+append_classifier_element_value(
 		void *opaque,
 		__rte_unused enum spp_classifier_type type,
 		const char *data,
@@ -265,12 +447,12 @@ int append_classifier_element_value(
 	return 0;
 }
 
-/* append info value(status response) to specified json object */
+/* append classifier_table value */
 static int 
-append_response_info_value(json_t *parent_obj)
+append_response_classifier_value(json_t *parent_obj)
 {
 	int ret = -1;
-	json_t *info_obj, *tab_obj;
+	json_t *tab_obj;
 	struct spp_iterate_classifier_table_params itr_params;
 
 	/* create classifier_table array */
@@ -287,16 +469,48 @@ append_response_info_value(json_t *parent_obj)
 		return -1;
 	}
 
+	ret = json_object_set_new(parent_obj, "classifier_table", tab_obj);
+	if (unlikely(ret != 0)) {
+		json_decref(tab_obj);
+		return -1;
+	}
+
+	return 0;
+}
+
+/* append info value(status response) to specified json object */
+static int 
+append_response_info_value(json_t *parent_obj)
+{
+	int ret = -1;
+	json_t *info_obj;
+
 	/* set classifier_table object in info object */
 	info_obj = json_object();
-	if (unlikely(info_obj == NULL)) {
-		json_decref(tab_obj);
+	if (unlikely(info_obj == NULL))
+		return -1;
+
+	ret = append_client_id_value(info_obj);
+	if (unlikely(ret != 0)) {
+		json_decref(info_obj);
 		return -1;
 	}
 
-	ret = json_object_set_new(info_obj, "classifier_table", tab_obj);
+	ret = append_interface_value(info_obj);
 	if (unlikely(ret != 0)) {
-		json_decref(tab_obj);
+		json_decref(info_obj);
+		return -1;
+	}
+
+	ret = append_response_core_value(info_obj);
+	if (unlikely(ret != 0)) {
+		json_decref(info_obj);
+		return -1;
+	}
+
+	ret = append_response_classifier_value(info_obj);
+	if (unlikely(ret != 0)) {
+		json_decref(info_obj);
 		return -1;
 	}
 
diff --git a/src/vf/spp_forward.c b/src/vf/spp_forward.c
index 8a0980a..dbe96dc 100644
--- a/src/vf/spp_forward.c
+++ b/src/vf/spp_forward.c
@@ -12,15 +12,19 @@ struct forward_rxtx {
 	struct spp_port_info tx;
 };
 
+/* Information on the path used for forward. */
 struct forward_path {
-	int num;
+	char name[SPP_NAME_STR_LEN];	/* component name          */
+	volatile enum spp_component_type type;	/* component type          */
+	int num;			/* number of receive ports */
 	struct forward_rxtx ports[RTE_MAX_ETHPORTS];
+					/* port used for transfer  */
 };
 
+/* Information for forward. */
 struct forward_info {
-	enum spp_component_type type;
-	volatile int ref_index;
-	volatile int upd_index;
+	volatile int ref_index;		/* index to reference area */
+	volatile int upd_index;		/* index to update area    */
 	struct forward_path path[SPP_INFO_AREA_MAX];
 };
 
@@ -42,8 +46,6 @@ spp_forward_init(void)
 static void
 clear_forward_info(int id)
 {
-	struct forward_info *info = &g_forward_info[id];
-	info->type = SPP_COMPONENT_UNUSE;
 	memset(&g_forward_info[id].path, 0x00, sizeof(struct forward_path));
 }
 
@@ -75,10 +77,11 @@ spp_forward_update(struct spp_component_info *component)
 	clear_forward_info(component->component_id);
 
 	RTE_LOG(INFO, FORWARD,
-			"Component[%d] Start update component. (type = %d)\n",
-			component->component_id, component->type);
+			"Component[%d] Start update component. (name = %s, type = %d)\n",
+			component->component_id, component->name, component->type);
 
-	info->type = component->type;
+	memcpy(&path->name, component->name, SPP_NAME_STR_LEN);
+	path->type = component->type;
 	path->num = component->num_rx_port;
 	for (cnt = 0; cnt < num_rx; cnt++)
 		memcpy(&path->ports[cnt].rx, component->rx_ports[cnt],
@@ -93,8 +96,9 @@ spp_forward_update(struct spp_component_info *component)
 	while(likely(info->ref_index == info->upd_index))
 		rte_delay_us_block(SPP_CHANGE_UPDATE_INTERVAL);
 
-	RTE_LOG(INFO, FORWARD, "Component[%d] Complete update component. (type = %d)\n",
-			component->component_id, component->type);
+	RTE_LOG(INFO, FORWARD,
+			"Component[%d] Complete update component. (name = %s, type = %d)\n",
+			component->component_id, component->name, component->type);
 
 	return 0;
 }
@@ -160,3 +164,50 @@ spp_forward(int id)
 	}
 	return 0;
 }
+
+/* Merge/Forward iterate component information */
+int
+spp_forward_core_info_iterate(unsigned int lcore_id, int id,
+		struct spp_iterate_core_params *params)
+{
+	int ret = -1;
+	int cnt, num_tx;
+	const char *component_type = NULL;
+	struct forward_info *info = &g_forward_info[id];
+	struct forward_path *path = &info->path[info->ref_index];
+	struct spp_port_index rx_ports[RTE_MAX_ETHPORTS];
+	struct spp_port_index tx_ports[RTE_MAX_ETHPORTS];
+
+	if (unlikely(path->type == SPP_COMPONENT_UNUSE)) {
+		RTE_LOG(ERR, FORWARD,
+				"Component[%d] Not used. (status)(core = %d, type = %d)\n",
+				id, lcore_id, path->type);
+		return -1;
+	}
+
+	if (path->type == SPP_COMPONENT_MERGE)
+		component_type = SPP_TYPE_MERGE_STR;
+	else
+		component_type = SPP_TYPE_FORWARD_STR;
+
+	memset(rx_ports, 0x00, sizeof(rx_ports));
+	for (cnt = 0; cnt < path->num; cnt++) {
+		rx_ports[cnt].if_type = path->ports[cnt].rx.if_type;
+		rx_ports[cnt].if_no   = path->ports[cnt].rx.if_no;
+	}
+
+	memset(tx_ports, 0x00, sizeof(tx_ports));
+	num_tx = (path->num > 0)?1:0;
+	tx_ports[0].if_type = path->ports[0].tx.if_type;
+	tx_ports[0].if_no   = path->ports[0].tx.if_no;
+
+	/* Set the information with the function specified by the command. */
+	ret = (*params->element_proc)(
+		params->opaque, lcore_id,
+		path->name, component_type,
+		path->num, rx_ports, num_tx, tx_ports);
+	if (unlikely(ret != 0))
+		return -1;
+
+	return 0;
+}
diff --git a/src/vf/spp_forward.h b/src/vf/spp_forward.h
index 729dbe8..ed0744d 100644
--- a/src/vf/spp_forward.h
+++ b/src/vf/spp_forward.h
@@ -1,11 +1,13 @@
 #ifndef __SPP_FORWARD_H__
 #define __SPP_FORWARD_H__
 
-
+/* Clear info */
 void spp_forward_init(void);
 
+/* Clear info for one element. */
 void spp_forward_init_info(int id);
 
+/* Update forward info */
 int spp_forward_update(struct spp_component_info *component);
 
 /*
@@ -13,4 +15,8 @@ int spp_forward_update(struct spp_component_info *component);
  */
 int spp_forward(int id);
 
+/* Merge/Forward iterate component information */
+int spp_forward_core_info_iterate(unsigned int lcore_id, int id,
+		struct spp_iterate_core_params *params);
+
 #endif /* __SPP_FORWARD_H__ */
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index d6eb7b2..f97c348 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -488,6 +488,7 @@ set_nic_interface(void)
 	}
 
 	for (nic_cnt = 0; nic_cnt < g_if_info.num_nic; nic_cnt++) {
+		g_if_info.nic[nic_cnt].if_type   = PHY;
 		g_if_info.nic[nic_cnt].dpdk_port = nic_cnt;
 	}
 
@@ -842,6 +843,16 @@ spp_check_added_port(enum port_type if_type, int if_no)
 }
 
 /*
+ * Check if port has been flushed.
+ */
+int
+spp_check_flush_port(enum port_type if_type, int if_no)
+{
+	struct spp_port_info *port = get_if_area(if_type, if_no);
+	return port->dpdk_port >= 0;
+}
+
+/*
  * Check if component is using port.
  */
 int
@@ -1068,6 +1079,7 @@ spp_update_component(
 		core->num++;
 		ret = SPP_RET_OK;
 		tmp_lcore_id = lcore_id;
+		g_change_component[component_id] = 1;
 		break;
 
 	case SPP_CMD_ACTION_STOP:
@@ -1091,6 +1103,7 @@ spp_update_component(
 			core->type = SPP_COMPONENT_UNUSE;
 
 		ret = SPP_RET_OK;
+		g_change_component[component_id] = 0;
 		break;
 
 	default:
@@ -1320,6 +1333,44 @@ spp_flush(void)
 	return SPP_RET_OK;
 }
 
+/* Iterate core infomartion */
+int
+spp_iterate_core_info(struct spp_iterate_core_params *params)
+{
+	int ret;
+	int core_cnt, cnt;
+	struct core_info *core = NULL;
+
+	for (core_cnt = 0; core_cnt < RTE_MAX_LCORE; core_cnt++) {
+		if (spp_get_core_status(core_cnt) == SPP_CORE_UNUSE)
+			continue;
+
+		core = get_core_info(core_cnt);
+		for (cnt = 0; cnt < core->num; cnt++) {
+			if (core->type == SPP_COMPONENT_CLASSIFIER_MAC) {
+				ret = spp_classifier_component_info_iterate(
+						core_cnt,
+						core->id[cnt],
+						params);
+			} else {
+				ret = spp_forward_core_info_iterate(
+						core_cnt,
+						core->id[cnt],
+						params);
+			}
+			if (unlikely(ret != 0)) {
+				RTE_LOG(ERR, APP, "Cannot iterate core information. "
+						"(core = %d, type = %d)\n",
+						core_cnt, 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)
diff --git a/src/vf/spp_vf.h b/src/vf/spp_vf.h
index 90a2886..9e846ef 100644
--- a/src/vf/spp_vf.h
+++ b/src/vf/spp_vf.h
@@ -3,6 +3,10 @@
 
 #include "common.h"
 
+#define SPP_TYPE_CLASSIFIER_MAC_STR "classifier_mac"
+#define SPP_TYPE_MERGE_STR          "merge"
+#define SPP_TYPE_FORWARD_STR        "forward"
+
 #define SPP_IFTYPE_NIC_STR   "phy"
 #define SPP_IFTYPE_VHOST_STR "vhost"
 #define SPP_IFTYPE_RING_STR  "ring"
@@ -162,6 +166,26 @@ int spp_update_port(
  */
 int spp_flush(void);
 
+/* definition of iterated core element procedure function */
+typedef int (*spp_iterate_core_element_proc)(
+		void *opaque,
+		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 {
+	void *opaque;
+	spp_iterate_core_element_proc element_proc;
+};
+
+/* Iterate core infomartion */
+int spp_iterate_core_info(struct spp_iterate_core_params *params);
+
 /* definition of iterated classifier element procedure function */
 typedef int (*spp_iterate_classifier_element_proc)(
 		void *opaque,
@@ -221,6 +245,12 @@ int spp_check_mac_used_port(uint64_t mac_addr, enum port_type if_type, int if_no
 int spp_check_added_port(enum port_type if_type, int if_no);
 
 /*
+ * Check if port has been flushed.
+ * RETURN : True if port has been flushed.
+ */
+int spp_check_flush_port(enum port_type if_type, int if_no);
+
+/*
  * Check if component is using port.
  * OK : match component ID
  * NG : SPP_RET_NG
-- 
1.9.1

  parent reply	other threads:[~2017-12-28  4:56 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-25  4:41 [spp] Proposal - spp_vf(SR-IOV like feature) addition to SPP Nakamura Hioryuki
2017-12-26  1:54 ` Yasufumi Ogawa
2017-12-28  4:55   ` [spp] [PATCH 01/57] spp_vf: add vf functions x-fn-spp
2017-12-28  8:49     ` Yasufumi Ogawa
2017-12-28  4:55   ` [spp] [PATCH 02/57] spp_vf: support multi process x-fn-spp
2018-02-07 16:50     ` Ferruh Yigit
2018-02-08  1:21       ` Yasufumi Ogawa
2018-02-08  6:44       ` [spp] [spp 02168] " Nakamura Hioryuki
2017-12-28  4:55   ` [spp] [PATCH 03/57] spp_vf: comment out check of using cores x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 04/57] spp_vf: modify classifier for upd command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 05/57] spp_vf: add procedure that mac address is null x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 06/57] spp_vf: change config format for upd command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 07/57] spp_vf: fix compiler warning in classifier_mac.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 08/57] spp_vf: modify data struct for upd command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 09/57] spp_vf: add functions of command acceptance x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 10/57] spp_vf: add command acceptance calling x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 11/57] spp_vf: fix compiler warning in command_proc.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 12/57] " x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 13/57] spp_vf: refactor command acceptance/decode x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 14/57] spp_vf: fix return value overwrite problem x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 15/57] spp_vf: initialize message buffer x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 16/57] spp_vf: add const keyword to parameter x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 17/57] spp_vf: fix wrong comparison operator x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 18/57] spp_vf: fix wrong variable to be assigned x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 19/57] spp_vf: refactor parsing server ip address x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 20/57] spp_vf: fix error in command decode x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 21/57] spp_vf: fix comparison operator in spp_vf.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 22/57] spp_vf: check upper limit to the number of process x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 23/57] spp_vf: display usage message x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 24/57] spp_vf: split command processing source file x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 25/57] spp_vf: add new log and line break x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 26/57] spp_vf: support get-process-id command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 27/57] spp_vf: update socket creation procedure x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 28/57] spp_vf: change log level and add line break x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 29/57] spp_vf: replace unsupported jansson api x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 30/57] spp_vf: change order of command result in json object x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 31/57] spp_vf: use prediction keywords x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 32/57] spp_vf: fix wrong comparison x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 33/57] spp_vf: update sending error status x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 34/57] spp_vf: modify conditional statement x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 35/57] spp_vf: add proc on receiving l2 multicast x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 36/57] spp_vf: extend limit on number of usable cores x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 37/57] spp_vf: add restart procedure for vhost client x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 38/57] spp_vf: fix classifier mbuf handling x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 39/57] spp_vf: add status command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 40/57] spp_vf: add output source information in error log x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 41/57] spp_vf: change function names x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 42/57] spp_vf: change how to request commands x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 43/57] spp_vf: update command decode procedure x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 44/57] spp_vf: remove debug log output procedures x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 45/57] spp_vf: improve command_decoder program code x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 46/57] spp_vf: fix a bug in status command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 47/57] spp_vf: add spp_vf.py instead of spp.py x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 48/57] spp_vf: refactor for commnets in spp_vf.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 49/57] spp_vf: refactor comments in classifier_mac.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 50/57] spp_vf: refactor comments in spp_forward.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 51/57] spp_vf: refactor for commnets in spp_config.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 52/57] spp_vf: refactor no self-explanatory comments x-fn-spp
2017-12-28  4:56   ` [spp] [PATCH 53/57] spp_vf: correct typo of function name x-fn-spp
2017-12-28  4:56   ` [spp] [PATCH 54/57] spp_vf: support new command x-fn-spp
2017-12-28  4:56   ` x-fn-spp [this message]
2017-12-28  4:56   ` [spp] [PATCH 56/57] spp_vf: fix status command x-fn-spp
2017-12-28  4:56   ` [spp] [PATCH 57/57] spp_vf: fix l2 multicast packet forwarding x-fn-spp
2018-01-15 11:04 ` [spp] Proposal - spp_vf(SR-IOV like feature) addition to SPP Ferruh Yigit
2018-01-16  5:16   ` [spp] [PATCH 01/30] doc: add setup guide x-fn-spp
2018-01-19  0:52     ` Yasufumi Ogawa
2018-01-22 14:37       ` Ferruh Yigit
2018-01-23  0:25         ` Yasufumi Ogawa
2018-01-16  5:16   ` [spp] [PATCH 02/30] doc: add how_to_use.md x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 03/30] doc: add config_manual.md x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 04/30] doc: add spp_vf.md x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 05/30] doc: revise spp_vf.md x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 06/30] doc: add config section x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 07/30] doc: update jp setup manual x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 08/30] doc: modify figure in spp_vf_overview x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 09/30] doc: fix " x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 10/30] doc: fix figure in overview x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 11/30] doc: add sample usage x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 12/30] doc: revice path descs x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 13/30] doc: add network configuration diagram x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 14/30] doc: update user account x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 15/30] doc: update descriptions for todo x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 16/30] doc: add description for explanation section x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 17/30] doc: add spp_sample_usage_svg in docs/spp_vf/ x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 18/30] doc: add explanation for terminating spp app x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 19/30] doc: add explanations on options of spp x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 20/30] doc: update description for the latest spp version x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 21/30] doc: update description on dpdk version x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 22/30] doc: fix vm setup procedure for network config x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 23/30] doc: update jansson installation procedure x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 24/30] doc: fix required network configuration x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 25/30] doc: add how to use vhost-user support x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 26/30] doc: add references to hugepages and isolcpus x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 27/30] doc: remove description on classifier_table x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 28/30] doc: fix typos and erros in texts x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 29/30] doc: update sample config section x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 30/30] doc: align figure title position x-fn-spp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201712280456.vBS4u8jS011162@imss03.silk.ntt-tx.co.jp \
    --to=x-fn-spp@sl.ntt-tx.co.jp \
    --cc=spp@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).