Soft Patch Panel
 help / color / mirror / Atom feed
* [spp] [PATCH v2 1/5] spp_vf: remove while loop in classifier_mac
       [not found] <20190212091614.24285-1-x-fn-spp@sl.ntt-tx.co.jp>
@ 2019-02-12  9:16 ` x-fn-spp
  2019-02-12  9:16 ` [spp] [PATCH v2 2/5] spp_vf: change to handle multiples component x-fn-spp
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: x-fn-spp @ 2019-02-12  9:16 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

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

So far, spp_classifier_mac_do() has while loop and it does not return
until the classifier component is requested to stop and thus the worker
thread can not execute packet processing for forwarder/merger.
To introduce core-sharing, this patch removes the while loop
to make classifier not occupy assigned core.

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_vf.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index b98444d..bdc4c10 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2017-2018 Nippon Telegraph and Telephone Corporation
+ * Copyright(c) 2017-2019 Nippon Telegraph and Telephone Corporation
  */
 
 #include <netinet/in.h>
@@ -209,21 +209,18 @@ slave_main(void *arg __attribute__ ((unused)))
 			core = get_core_info(lcore_id);
 		}
 
+		/* It is for processing multiple components. */
 		for (cnt = 0; cnt < core->num; cnt++) {
-			if (spp_get_component_type(lcore_id) ==
+			if (spp_get_component_type(core->id[cnt]) ==
 					SPP_COMPONENT_CLASSIFIER_MAC) {
-				/* Classifier loops inside the function. */
 				ret = spp_classifier_mac_do(core->id[cnt]);
-				break;
+				if (unlikely(ret != 0))
+					break;
+			} else {
+				ret = spp_forward(core->id[cnt]);
+				if (unlikely(ret != 0))
+					break;
 			}
-
-			/*
-			 * Forward / Merge returns at once.
-			 * It is for processing multiple components.
-			 */
-			ret = spp_forward(core->id[cnt]);
-			if (unlikely(ret != 0))
-				break;
 		}
 		if (unlikely(ret != 0)) {
 			RTE_LOG(ERR, APP, "Core[%d] Component Error. "
-- 
2.17.1

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

* [spp] [PATCH v2 2/5] spp_vf: change to handle multiples component
       [not found] <20190212091614.24285-1-x-fn-spp@sl.ntt-tx.co.jp>
  2019-02-12  9:16 ` [spp] [PATCH v2 1/5] spp_vf: remove while loop in classifier_mac x-fn-spp
@ 2019-02-12  9:16 ` x-fn-spp
  2019-02-12  9:16 ` [spp] [PATCH v2 3/5] spp_vf: move classifier component init x-fn-spp
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: x-fn-spp @ 2019-02-12  9:16 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

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

So far, slave_main assumes that only one component is assigned for one
core. However there is a case when multiples component are assigned
for one core in core-sharing usecase to reduce cpu core consumption.
This patch changes to handle multiples component per core in
slave_main 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 | 108 ++++++++++++++--------------------------
 src/vf/spp_vf.c         |   3 ++
 2 files changed, 41 insertions(+), 70 deletions(-)

diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index cfaf96a..aac235f 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2017-2018 Nippon Telegraph and Telephone Corporation
+ * Copyright(c) 2017-2019 Nippon Telegraph and Telephone Corporation
  */
 
 #include <unistd.h>
@@ -774,7 +774,7 @@ classify_packet(struct rte_mbuf **rx_pkts, uint16_t n_rx,
 
 /* change update index at classifier management information */
 static inline void
-change_update_index(struct management_info *mng_info, int id)
+change_classifier_index(struct management_info *mng_info, int id)
 {
 	if (unlikely(mng_info->ref_index ==
 			mng_info->upd_index)) {
@@ -815,11 +815,6 @@ spp_classifier_mac_update(struct spp_component_info *component_info)
 	RTE_LOG(INFO, SPP_CLASSIFIER_MAC,
 			"Component[%u] Start update component.\n", id);
 
-	/* wait until no longer access the new update side */
-	while (likely(mng_info->ref_index ==
-			mng_info->upd_index))
-		rte_delay_us_block(CHANGE_UPDATE_INDEX_WAIT_INTERVAL);
-
 	cmp_info = mng_info->cmp_infos + mng_info->upd_index;
 
 	/* initialize update side classifier information */
@@ -833,6 +828,7 @@ spp_classifier_mac_update(struct spp_component_info *component_info)
 
 	/* change index of reference side */
 	mng_info->upd_index = mng_info->ref_index;
+	mng_info->is_used = 1;
 
 	/* wait until no longer access the new update side */
 	while (likely(mng_info->ref_index ==
@@ -852,10 +848,8 @@ spp_classifier_mac_update(struct spp_component_info *component_info)
 int
 spp_classifier_mac_do(int id)
 {
-	int ret = SPP_RET_NG;
 	int i;
 	int n_rx;
-	unsigned int lcore_id = rte_lcore_id();
 	struct management_info *mng_info = g_mng_infos + id;
 	struct component_info *cmp_info = NULL;
 	struct rte_mbuf *rx_pkts[MAX_PKT_BURST];
@@ -867,76 +861,50 @@ spp_classifier_mac_do(int id)
 	const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) /
 			US_PER_S * DRAIN_TX_PACKET_INTERVAL;
 
-	/* initialize */
-	ret = init_classifier(mng_info);
-	if (unlikely(ret != SPP_RET_OK)) {
-		uninit_classifier(mng_info);
-		return ret;
-	}
+	/* change index of update classifier management information */
+	change_classifier_index(mng_info, id);
 
-	while (likely(spp_get_core_status(lcore_id) == SPP_CORE_FORWARD) &&
-		    likely(spp_check_core_update(lcore_id) == SPP_RET_NG)) {
-		/* change index of update side */
-		change_update_index(mng_info, id);
-
-		/**
-		 * 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;
+	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 &&
+	/**
+	 * 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.
+	 */
+	if (!(clsd_data_rx->iface_type != UNDEF &&
+			cmp_info->n_classified_data_tx >= 1 &&
 				cmp_info->mac_addr_entry == 1))
-			continue;
+		return SPP_RET_OK;
 
-		/* drain tx packets, if buffer is not filled for interval */
-		cur_tsc = rte_rdtsc();
-		if (unlikely(cur_tsc - prev_tsc > drain_tsc)) {
-			for (i = 0; i < cmp_info->n_classified_data_tx;
-					i++) {
-				if (likely(clsd_data_tx[i].num_pkt == 0))
-					continue;
-
-				RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC,
-						"transmit packets (drain). "
-						"index=%d, "
-						"num_pkt=%hu, "
-						"interval=%lu\n",
-						i,
-						clsd_data_tx[i].num_pkt,
-						cur_tsc - prev_tsc);
+	/* drain tx packets, if buffer is not filled for interval */
+	cur_tsc = rte_rdtsc();
+	if (unlikely(cur_tsc - prev_tsc > drain_tsc)) {
+		for (i = 0; i < cmp_info->n_classified_data_tx; i++) {
+			if (likely(clsd_data_tx[i].num_pkt == 0))
+				continue;
+
+			RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC,
+					"transmit packets (drain). index=%d, "
+					"num_pkt=%hu, interval=%lu\n",
+					i, clsd_data_tx[i].num_pkt,
+					cur_tsc - prev_tsc);
 				transmit_packet(&clsd_data_tx[i]);
-			}
-			prev_tsc = cur_tsc;
 		}
-
-		if (clsd_data_rx->iface_type == UNDEF)
-			continue;
-
-		/* retrieve packets */
-		n_rx = spp_eth_rx_burst(clsd_data_rx->port, 0,
-				rx_pkts, MAX_PKT_BURST);
-		if (unlikely(n_rx == 0))
-			continue;
-
-		/* classify and transmit (filled) */
-		classify_packet(rx_pkts, n_rx, cmp_info, clsd_data_tx);
+		prev_tsc = cur_tsc;
 	}
 
-	/* just in case */
-	change_update_index(mng_info, id);
+	if (clsd_data_rx->iface_type == UNDEF)
+		return SPP_RET_OK;
+
+	/* retrieve packets */
+	n_rx = spp_eth_rx_burst(clsd_data_rx->port, 0, rx_pkts, MAX_PKT_BURST);
+	if (unlikely(n_rx == 0))
+		return SPP_RET_OK;
 
-	/* uninitialize */
-	uninit_classifier(mng_info);
+	/* classify and interval that transmit burst packet */
+	classify_packet(rx_pkts, n_rx, cmp_info, clsd_data_tx);
 
 	return SPP_RET_OK;
 }
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index bdc4c10..aa60bec 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -211,12 +211,15 @@ slave_main(void *arg __attribute__ ((unused)))
 
 		/* It is for processing multiple components. */
 		for (cnt = 0; cnt < core->num; cnt++) {
+			/* Component classification to call a function. */
 			if (spp_get_component_type(core->id[cnt]) ==
 					SPP_COMPONENT_CLASSIFIER_MAC) {
+				/* Component type for classifier. */
 				ret = spp_classifier_mac_do(core->id[cnt]);
 				if (unlikely(ret != 0))
 					break;
 			} else {
+				/* Component type for forward or merge. */
 				ret = spp_forward(core->id[cnt]);
 				if (unlikely(ret != 0))
 					break;
-- 
2.17.1

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

* [spp] [PATCH v2 3/5] spp_vf: move classifier component init
       [not found] <20190212091614.24285-1-x-fn-spp@sl.ntt-tx.co.jp>
  2019-02-12  9:16 ` [spp] [PATCH v2 1/5] spp_vf: remove while loop in classifier_mac x-fn-spp
  2019-02-12  9:16 ` [spp] [PATCH v2 2/5] spp_vf: change to handle multiples component x-fn-spp
@ 2019-02-12  9:16 ` x-fn-spp
  2019-02-12  9:16 ` [spp] [PATCH v2 4/5] spp_vf: remove to check unused cores no needed x-fn-spp
  2019-02-12  9:16 ` [spp] [PATCH v2 5/5] spp_vf: change retrieve component type x-fn-spp
  4 siblings, 0 replies; 5+ messages in thread
From: x-fn-spp @ 2019-02-12  9:16 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

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

So far, initialization of classifier component is called before
while loop in spp_classifier_mac_do(). However, when introducing
core sharing, spp_classifier_mac_do() does not loop and initialization
of classifier component should be moved.

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      | 52 +++++++-----------------------------
 src/vf/classifier_mac.h      | 11 +++++++-
 src/vf/common/command_proc.c |  9 ++++++-
 3 files changed, 28 insertions(+), 44 deletions(-)

diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index aac235f..f8f06fa 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -469,48 +469,6 @@ init_component_info(struct component_info *cmp_info,
 	return SPP_RET_OK;
 }
 
-/* initialize classifier. */
-static int
-init_classifier(struct management_info *mng_info)
-{
-	int ret = SPP_RET_NG;
-	struct spp_component_info component_info;
-
-	memset(mng_info, 0, sizeof(struct management_info));
-	/*
-	 * Set the same value for "ref_index" and "upd_index"
-	 * so that it will not be changed from others during initialization,
-	 * and update "upd_index" after initialization is completed.
-	 * Therefore, this setting is consciously described.
-	 */
-	mng_info->ref_index = 0;
-	mng_info->upd_index = 0;
-	memset(&component_info, 0x00, sizeof(component_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");
-#endif
-
-	/* populate the classifier information at reference */
-	ret = init_component_info(&mng_info->
-			cmp_infos[mng_info->ref_index], &component_info);
-	if (unlikely(ret != SPP_RET_OK)) {
-		RTE_LOG(ERR, SPP_CLASSIFIER_MAC,
-				"Cannot initialize classifier mac table. "
-				"ret=%d\n", ret);
-		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 SPP_RET_OK;
-}
-
 /* free mac classification instance. */
 static inline void
 free_mac_classification(struct mac_classification *mac_cls)
@@ -803,6 +761,16 @@ spp_classifier_mac_init(void)
 	return 0;
 }
 
+/* initialize classifier information. */
+void
+init_classifier_info(int component_id)
+{
+	struct management_info *mng_info = NULL;
+
+	mng_info = g_mng_infos + component_id;
+	uninit_classifier(mng_info);
+}
+
 /* classifier(mac address) update component info. */
 int
 spp_classifier_mac_update(struct spp_component_info *component_info)
diff --git a/src/vf/classifier_mac.h b/src/vf/classifier_mac.h
index ba25e75..1671ff0 100644
--- a/src/vf/classifier_mac.h
+++ b/src/vf/classifier_mac.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2017-2018 Nippon Telegraph and Telephone Corporation
+ * Copyright(c) 2017-2019 Nippon Telegraph and Telephone Corporation
  */
 
 #ifndef _CLASSIFIER_MAC_H_
@@ -27,6 +27,15 @@ struct spp_iterate_classifier_table_params;
  */
 int spp_classifier_mac_init(void);
 
+/**
+ * initialize classifier information.
+ *
+ * @param component_id
+ *  The unique component ID.
+ *
+ */
+void init_classifier_info(int component_id);
+
 /**
  * classifier(mac address) update component info.
  *
diff --git a/src/vf/common/command_proc.c b/src/vf/common/command_proc.c
index 3011873..3f44174 100644
--- a/src/vf/common/command_proc.c
+++ b/src/vf/common/command_proc.c
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2017-2018 Nippon Telegraph and Telephone Corporation
+ * Copyright(c) 2017-2019 Nippon Telegraph and Telephone Corporation
  */
 
 #include <unistd.h>
@@ -303,6 +303,13 @@ spp_update_component(
 
 		info = (core_info + tmp_lcore_id);
 		core = &info->core[info->upd_index];
+
+#ifdef SPP_VF_MODULE
+		/* initialize classifier information */
+		if (component->type == SPP_COMPONENT_CLASSIFIER_MAC)
+			init_classifier_info(component_id);
+#endif /* SPP_VF_MODULE */
+
 		ret_del = del_component_info(component_id,
 				core->num, core->id);
 		if (ret_del >= 0)
-- 
2.17.1

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

* [spp] [PATCH v2 4/5] spp_vf: remove to check unused cores no needed
       [not found] <20190212091614.24285-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (2 preceding siblings ...)
  2019-02-12  9:16 ` [spp] [PATCH v2 3/5] spp_vf: move classifier component init x-fn-spp
@ 2019-02-12  9:16 ` x-fn-spp
  2019-02-12  9:16 ` [spp] [PATCH v2 5/5] spp_vf: change retrieve component type x-fn-spp
  4 siblings, 0 replies; 5+ messages in thread
From: x-fn-spp @ 2019-02-12  9:16 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

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

Checking unused core is no needed anymore after core sharing feature
is introduced. This patch removes `type` from struct `core_info` which
is used for checking unused or not.

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  | 13 +------------
 src/vf/common/command_proc.c | 10 ----------
 src/vf/common/spp_proc.c     | 14 +++++---------
 src/vf/common/spp_proc.h     |  4 +---
 4 files changed, 7 insertions(+), 34 deletions(-)

diff --git a/src/vf/common/command_dec.c b/src/vf/common/command_dec.c
index 61dd4f4..4c3e62a 100644
--- a/src/vf/common/command_dec.c
+++ b/src/vf/common/command_dec.c
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2017-2018 Nippon Telegraph and Telephone Corporation
+ * Copyright(c) 2017-2019 Nippon Telegraph and Telephone Corporation
  */
 
 #include <unistd.h>
@@ -94,17 +94,6 @@ 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 *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;
-}
-
 /* Check mac address used on the port for registering or removing */
 static int
 spp_check_classid_used_port(
diff --git a/src/vf/common/command_proc.c b/src/vf/common/command_proc.c
index 3f44174..06e50e6 100644
--- a/src/vf/common/command_proc.c
+++ b/src/vf/common/command_proc.c
@@ -270,12 +270,6 @@ spp_update_component(
 		}
 
 		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 = (component_info + component_id);
 		memset(component, 0x00, sizeof(struct spp_component_info));
@@ -284,7 +278,6 @@ spp_update_component(
 		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;
@@ -316,9 +309,6 @@ spp_update_component(
 			/* If deleted, decrement number. */
 			core->num--;
 
-		if (core->num == 0)
-			core->type = SPP_COMPONENT_UNUSE;
-
 		ret = SPP_RET_OK;
 		*(change_component + component_id) = 0;
 		break;
diff --git a/src/vf/common/spp_proc.c b/src/vf/common/spp_proc.c
index 9a118bd..cf0d760 100644
--- a/src/vf/common/spp_proc.c
+++ b/src/vf/common/spp_proc.c
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
+ * Copyright(c) 2018-2019 Nippon Telegraph and Telephone Corporation
  */
 
 #include <unistd.h>
@@ -290,15 +290,11 @@ dump_core_info(const struct core_mng_info *core_info)
 				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);
+		memset(str, 0x00, SPP_NAME_STR_LEN);
+		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);
+		sprintf(str, "core[%d]-1 num=%d", lcore_id, info->core[1].num);
+		dump_buff(str, info->core[1].id, sizeof(int)*info->core[1].num);
 	}
 }
 
diff --git a/src/vf/common/spp_proc.h b/src/vf/common/spp_proc.h
index 2fc8cc2..8112af3 100644
--- a/src/vf/common/spp_proc.h
+++ b/src/vf/common/spp_proc.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
+ * Copyright(c) 2018-2019 Nippon Telegraph and Telephone Corporation
  */
 
 #ifndef _SPP_PROC_H_
@@ -244,8 +244,6 @@ struct iface_info {
 
 /* 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 */
 };
-- 
2.17.1

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

* [spp] [PATCH v2 5/5] spp_vf: change retrieve component type
       [not found] <20190212091614.24285-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (3 preceding siblings ...)
  2019-02-12  9:16 ` [spp] [PATCH v2 4/5] spp_vf: remove to check unused cores no needed x-fn-spp
@ 2019-02-12  9:16 ` x-fn-spp
  4 siblings, 0 replies; 5+ messages in thread
From: x-fn-spp @ 2019-02-12  9:16 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

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

So far, component which is assigned for a core is retrieved from
member type of core_info. However member type is removed from
core_info. So such information can be retrieved from referring
spp_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/common/command_dec.c  | 17 +++---------
 src/vf/common/command_proc.c | 52 +++++++++++++++++++-----------------
 src/vf/common/spp_proc.c     |  9 ++++---
 src/vf/common/spp_proc.h     | 22 ++++-----------
 4 files changed, 42 insertions(+), 58 deletions(-)

diff --git a/src/vf/common/command_dec.c b/src/vf/common/command_dec.c
index 4c3e62a..9523ab9 100644
--- a/src/vf/common/command_dec.c
+++ b/src/vf/common/command_dec.c
@@ -408,31 +408,22 @@ static int
 decode_component_type_value(void *output, const char *arg_val,
 				int allow_override __attribute__ ((unused)))
 {
-	enum spp_component_type org_type, set_type;
+	enum spp_component_type comp_type;
 	struct spp_command_component *component = output;
 
 	/* "stop" has no type parameter. */
 	if (component->action != SPP_CMD_ACTION_START)
 		return SPP_RET_OK;
 
-	set_type = spp_convert_component_type(arg_val);
-	if (unlikely(set_type <= 0)) {
+	comp_type = spp_convert_component_type(arg_val);
+	if (unlikely(comp_type <= 0)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Unknown component type. val=%s\n",
 				arg_val);
 		return SPP_RET_NG;
 	}
 
-	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",
-				arg_val, org_type, set_type);
-		return SPP_RET_NG;
-	}
-
-	component->type = set_type;
+	component->type = comp_type;
 	return SPP_RET_OK;
 }
 
diff --git a/src/vf/common/command_proc.c b/src/vf/common/command_proc.c
index 06e50e6..0f99827 100644
--- a/src/vf/common/command_proc.c
+++ b/src/vf/common/command_proc.c
@@ -235,15 +235,15 @@ spp_update_component(
 	int ret_del = -1;
 	int component_id = 0;
 	unsigned int tmp_lcore_id = 0;
-	struct spp_component_info *component = NULL;
+	struct spp_component_info *comp_info = NULL;
 	struct core_info *core = NULL;
 	struct core_mng_info *info = NULL;
-	struct spp_component_info *component_info = NULL;
+	struct spp_component_info *comp_info_base = 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,
+	spp_get_mng_data_addr(NULL, NULL, &comp_info_base, &core_info,
 				&change_core, &change_component, NULL);
 
 	switch (action) {
@@ -271,12 +271,12 @@ spp_update_component(
 
 		core = &info->core[info->upd_index];
 
-		component = (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;
+		comp_info = (comp_info_base + component_id);
+		memset(comp_info, 0x00, sizeof(struct spp_component_info));
+		strcpy(comp_info->name, name);
+		comp_info->type		= type;
+		comp_info->lcore_id	= lcore_id;
+		comp_info->component_id	= component_id;
 
 		core->id[core->num] = component_id;
 		core->num++;
@@ -290,16 +290,16 @@ spp_update_component(
 		if (component_id < 0)
 			return SPP_RET_OK;
 
-		component = (component_info + component_id);
-		tmp_lcore_id = component->lcore_id;
-		memset(component, 0x00, sizeof(struct spp_component_info));
+		comp_info = (comp_info_base + component_id);
+		tmp_lcore_id = comp_info->lcore_id;
+		memset(comp_info, 0x00, sizeof(struct spp_component_info));
 
 		info = (core_info + tmp_lcore_id);
 		core = &info->core[info->upd_index];
 
 #ifdef SPP_VF_MODULE
 		/* initialize classifier information */
-		if (component->type == SPP_COMPONENT_CLASSIFIER_MAC)
+		if (comp_info->type == SPP_COMPONENT_CLASSIFIER_MAC)
 			init_classifier_info(component_id);
 #endif /* SPP_VF_MODULE */
 
@@ -334,11 +334,11 @@ spp_update_port(enum spp_command_action action,
 	int ret_del = -1;
 	int component_id = 0;
 	int cnt = 0;
-	struct spp_component_info *component = NULL;
+	struct spp_component_info *comp_info = NULL;
 	struct spp_port_info *port_info = NULL;
 	int *num = NULL;
 	struct spp_port_info **ports = NULL;
-	struct spp_component_info *component_info = NULL;
+	struct spp_component_info *comp_info_base = NULL;
 	int *change_component = NULL;
 
 	component_id = spp_get_component_id(name);
@@ -347,17 +347,16 @@ spp_update_port(enum spp_command_action action,
 				"(component = %s)\n", name);
 		return SPP_RET_NG;
 	}
-
 	spp_get_mng_data_addr(NULL, NULL,
-			&component_info, NULL, NULL, &change_component, NULL);
-	component = (component_info + component_id);
+			&comp_info_base, NULL, NULL, &change_component, NULL);
+	comp_info = (comp_info_base + 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;
+		num = &comp_info->num_rx_port;
+		ports = comp_info->rx_ports;
 	} else {
-		num = &component->num_tx_port;
-		ports = component->tx_ports;
+		num = &comp_info->num_tx_port;
+		ports = comp_info->tx_ports;
 	}
 
 	switch (action) {
@@ -471,6 +470,8 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
 	int ret;
 	int lcore_id, cnt;
 	struct core_info *core = NULL;
+	struct spp_component_info *comp_info_base = NULL;
+	struct spp_component_info *comp_info = NULL;
 
 	RTE_LCORE_FOREACH_SLAVE(lcore_id) {
 		if (spp_get_core_status(lcore_id) == SPP_CORE_UNUSE)
@@ -493,8 +494,11 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
 		}
 
 		for (cnt = 0; cnt < core->num; cnt++) {
+			spp_get_mng_data_addr(NULL, NULL, &comp_info_base,
+							NULL, NULL, NULL, NULL);
+			comp_info = (comp_info_base + core->id[cnt]);
 #ifdef SPP_VF_MODULE
-			if (core->type == SPP_COMPONENT_CLASSIFIER_MAC) {
+			if (comp_info->type == SPP_COMPONENT_CLASSIFIER_MAC) {
 				ret = spp_classifier_get_component_status(
 						lcore_id,
 						core->id[cnt],
@@ -516,7 +520,7 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
 				RTE_LOG(ERR, APP, "Cannot iterate core "
 						"information. "
 						"(core = %d, type = %d)\n",
-						lcore_id, core->type);
+						lcore_id, comp_info->type);
 				return SPP_RET_NG;
 			}
 		}
diff --git a/src/vf/common/spp_proc.c b/src/vf/common/spp_proc.c
index cf0d760..803e498 100644
--- a/src/vf/common/spp_proc.c
+++ b/src/vf/common/spp_proc.c
@@ -607,12 +607,13 @@ del_vhost_sockfile(struct spp_port_info *vhost)
 	}
 }
 
-/* Get component type of target core */
+/* Get component type of target component_info */
 enum spp_component_type
-spp_get_component_type(unsigned int lcore_id)
+spp_get_component_type(int id)
 {
-	struct core_mng_info *info = (g_mng_data_addr.p_core_info + lcore_id);
-	return info->core[info->ref_index].type;
+	struct spp_component_info *component_info =
+				(g_mng_data_addr.p_component_info + id);
+	return component_info->type;
 }
 
 /* Get core ID of target component */
diff --git a/src/vf/common/spp_proc.h b/src/vf/common/spp_proc.h
index 8112af3..734c604 100644
--- a/src/vf/common/spp_proc.h
+++ b/src/vf/common/spp_proc.h
@@ -380,15 +380,15 @@ int spp_vf_add_vhost_pmd(int index, int client);
 enum spp_core_status spp_get_core_status(unsigned int lcore_id);
 
 /**
- * Get component type of target core
+ * Get component type of target component_info
  *
- * @param lcore_id
- *  Logical core ID.
+ * @param id
+ *  component ID.
  *
  * @return
- *  Type of component executed on specified logical core
+ *  Type of component executed
  */
-enum spp_component_type spp_get_component_type(unsigned int lcore_id);
+enum spp_component_type spp_get_component_type(int id);
 
 /**
  * Run check_core_status() for SPP_CORE_STATUS_CHECK_MAX times with
@@ -489,18 +489,6 @@ void print_ring_latency_stats(void);
 /* 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
  *
-- 
2.17.1

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

end of thread, other threads:[~2019-02-12  9:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20190212091614.24285-1-x-fn-spp@sl.ntt-tx.co.jp>
2019-02-12  9:16 ` [spp] [PATCH v2 1/5] spp_vf: remove while loop in classifier_mac x-fn-spp
2019-02-12  9:16 ` [spp] [PATCH v2 2/5] spp_vf: change to handle multiples component x-fn-spp
2019-02-12  9:16 ` [spp] [PATCH v2 3/5] spp_vf: move classifier component init x-fn-spp
2019-02-12  9:16 ` [spp] [PATCH v2 4/5] spp_vf: remove to check unused cores no needed x-fn-spp
2019-02-12  9:16 ` [spp] [PATCH v2 5/5] spp_vf: change retrieve component type 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).