[spp] [PATCH 3/5] spp_vf: move classifier component init

x-fn-spp at sl.ntt-tx.co.jp x-fn-spp at sl.ntt-tx.co.jp
Tue Feb 5 12:47:40 CET 2019


From: Hideyuki Yamashita <yamashita.hideyuki at 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 at po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki at 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 27e2355..f1a3049 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



More information about the spp mailing list