[spp] [PATCH 10/11] shared/sec: refactor getting classifier status

yasufum.o at gmail.com yasufum.o at gmail.com
Mon Jun 24 04:25:03 CEST 2019


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

This update is to rename spp_classifier_get_component_status() to
get_classifier_status() to simplify, and revise vars and log messages
for refactoring.

Signed-off-by: Yasufumi Ogawa <yasufum.o at gmail.com>
---
 .../secondary/spp_worker_th/cmd_runner.c      | 12 +++----
 src/shared/secondary/spp_worker_th/vf_deps.h  |  8 ++---
 src/vf/classifier_mac.c                       | 22 ++++++------
 src/vf/spp_forward.c                          | 35 +++++++++----------
 4 files changed, 36 insertions(+), 41 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_runner.c b/src/shared/secondary/spp_worker_th/cmd_runner.c
index a768575..856e79e 100644
--- a/src/shared/secondary/spp_worker_th/cmd_runner.c
+++ b/src/shared/secondary/spp_worker_th/cmd_runner.c
@@ -532,15 +532,11 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
 			comp_info = (comp_info_base + core->id[cnt]);
 #ifdef SPP_VF_MODULE
 			if (comp_info->wk_type == SPPWK_TYPE_CLS) {
-				ret = spp_classifier_get_component_status(
-						lcore_id,
-						core->id[cnt],
-						params);
+				ret = get_classifier_status(lcore_id,
+						core->id[cnt], params);
 			} else {
-				ret = spp_forward_get_component_status(
-						lcore_id,
-						core->id[cnt],
-						params);
+				ret = get_forwarder_status(lcore_id,
+						core->id[cnt], params);
 			}
 #endif /* SPP_VF_MODULE */
 #ifdef SPP_MIRROR_MODULE
diff --git a/src/shared/secondary/spp_worker_th/vf_deps.h b/src/shared/secondary/spp_worker_th/vf_deps.h
index 3ae4fc9..fb34215 100644
--- a/src/shared/secondary/spp_worker_th/vf_deps.h
+++ b/src/shared/secondary/spp_worker_th/vf_deps.h
@@ -79,7 +79,7 @@ int spp_classifier_mac_iterate_table(
 		struct spp_iterate_classifier_table_params *params);
 
 /**
- * classifier get component status.
+ * Get classifier status.
  *
  * @param[in] lcore_id Lcore ID for classifier.
  * @param[in] id Unique component ID.
@@ -87,11 +87,11 @@ int spp_classifier_mac_iterate_table(
  * @retval SPP_RET_OK If succeeded.
  * @retval SPP_RET_NG If failed.
  */
-int spp_classifier_get_component_status(unsigned int lcore_id, int id,
+int get_classifier_status(unsigned int lcore_id, int id,
 		struct spp_iterate_core_params *params);
 
 /**
- * Merge/Forward get component status
+ * Get forwarder status.
  *
  * @param lcore_id Lcore ID for forwarder and merger.
  * @param id Unique component ID.
@@ -99,7 +99,7 @@ int spp_classifier_get_component_status(unsigned int lcore_id, int id,
  * @retval SPP_RET_OK If succeeded.
  * @retval SPP_RET_NG If failed.
  */
-int spp_forward_get_component_status(unsigned int lcore_id, int id,
+int get_forwarder_status(unsigned int lcore_id, int id,
 		struct spp_iterate_core_params *params);
 
 #endif  /* _SPPWK_TH_VF_DEPS_H_ */
diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index f6074e4..9023a69 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -803,29 +803,29 @@ spp_classifier_mac_do(int id)
 
 /* classifier iterate component information */
 int
-spp_classifier_get_component_status(
-		unsigned int lcore_id, int id,
+get_classifier_status(unsigned int lcore_id, int id,
 		struct spp_iterate_core_params *params)
 {
 	int ret = SPP_RET_NG;
-	int i, nof_tx, nof_rx = 0;  /* Num of RX and TX ports. */
+	int i;
+	int nof_tx, nof_rx = 0;  /* Num of RX and TX ports. */
 	struct management_info *mng_info;
 	struct cls_comp_info *cmp_info;
-	struct cls_port_info *clsd_data;
+	struct cls_port_info *port_info;
 	struct sppwk_port_idx rx_ports[RTE_MAX_ETHPORTS];
 	struct sppwk_port_idx tx_ports[RTE_MAX_ETHPORTS];
 
 	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",
+				"Classifier is not used "
+				"(comp_id=%d, lcore_id=%d, type=%d).\n",
 				id, lcore_id, SPPWK_TYPE_CLS);
 		return SPP_RET_NG;
 	}
 
 	cmp_info = mng_info->cmp_infos + mng_info->ref_index;
-	clsd_data = cmp_info->tx_ports_i;
+	port_info = cmp_info->tx_ports_i;
 
 	memset(rx_ports, 0x00, sizeof(rx_ports));
 	if (cmp_info->rx_port_i.iface_type != UNDEF) {
@@ -837,14 +837,14 @@ spp_classifier_get_component_status(
 	memset(tx_ports, 0x00, sizeof(tx_ports));
 	nof_tx = cmp_info->nof_tx_ports;
 	for (i = 0; i < nof_tx; i++) {
-		tx_ports[i].iface_type = clsd_data[i].iface_type;
-		tx_ports[i].iface_no   = clsd_data[i].iface_no_global;
+		tx_ports[i].iface_type = port_info[i].iface_type;
+		tx_ports[i].iface_no = port_info[i].iface_no_global;
 	}
 
 	/* Set the information with the function specified by the command. */
+	/* TODO(yasufum) rename `element_proc` */
 	ret = (*params->element_proc)(
-		params, lcore_id,
-		cmp_info->name, SPPWK_TYPE_CLS_STR,
+		params, lcore_id, cmp_info->name, SPPWK_TYPE_CLS_STR,
 		nof_rx, rx_ports, nof_tx, tx_ports);
 	if (unlikely(ret != SPP_RET_OK))
 		return SPP_RET_NG;
diff --git a/src/vf/spp_forward.c b/src/vf/spp_forward.c
index 7746d40..3d40951 100644
--- a/src/vf/spp_forward.c
+++ b/src/vf/spp_forward.c
@@ -182,50 +182,49 @@ spp_forward(int id)
 	return SPP_RET_OK;
 }
 
-/* Merge/Forward get component status */
+/* Get forwarder status */
 int
-spp_forward_get_component_status(
-		unsigned int lcore_id, int id,
+get_forwarder_status(unsigned int lcore_id, int id,
 		struct spp_iterate_core_params *params)
 {
 	int ret = SPP_RET_NG;
 	int cnt;
 	const char *component_type = NULL;
-	struct forward_info *info = &g_forward_info[id];
-	struct forward_path *path = &info->path[info->ref_index];
+	struct forward_info *fwd_info = &g_forward_info[id];
+	struct forward_path *fwd_path = &fwd_info->path[fwd_info->ref_index];
 	struct sppwk_port_idx rx_ports[RTE_MAX_ETHPORTS];
 	struct sppwk_port_idx tx_ports[RTE_MAX_ETHPORTS];
 
-	if (unlikely(path->wk_type == SPPWK_TYPE_NONE)) {
+	if (unlikely(fwd_path->wk_type == SPPWK_TYPE_NONE)) {
 		RTE_LOG(ERR, FORWARD,
-				"Component[%d] Not used. "
-				"(status)(core = %d, type = %d)\n",
-				id, lcore_id, path->wk_type);
+				"Forwarder is not used. "
+				"(id=%d, lcore=%d, type=%d).\n",
+				id, lcore_id, fwd_path->wk_type);
 		return SPP_RET_NG;
 	}
 
-	if (path->wk_type == SPPWK_TYPE_MRG)
+	if (fwd_path->wk_type == SPPWK_TYPE_MRG)
 		component_type = SPPWK_TYPE_MRG_STR;
 	else
 		component_type = SPPWK_TYPE_FWD_STR;
 
 	memset(rx_ports, 0x00, sizeof(rx_ports));
-	for (cnt = 0; cnt < path->num_rx; cnt++) {
-		rx_ports[cnt].iface_type = path->ports[cnt].rx.iface_type;
-		rx_ports[cnt].iface_no   = path->ports[cnt].rx.iface_no;
+	for (cnt = 0; cnt < fwd_path->num_rx; cnt++) {
+		rx_ports[cnt].iface_type = fwd_path->ports[cnt].rx.iface_type;
+		rx_ports[cnt].iface_no = fwd_path->ports[cnt].rx.iface_no;
 	}
 
 	memset(tx_ports, 0x00, sizeof(tx_ports));
-	for (cnt = 0; cnt < path->num_tx; cnt++) {
-		tx_ports[cnt].iface_type = path->ports[cnt].tx.iface_type;
-		tx_ports[cnt].iface_no   = path->ports[cnt].tx.iface_no;
+	for (cnt = 0; cnt < fwd_path->num_tx; cnt++) {
+		tx_ports[cnt].iface_type = fwd_path->ports[cnt].tx.iface_type;
+		tx_ports[cnt].iface_no = fwd_path->ports[cnt].tx.iface_no;
 	}
 
 	/* Set the information with the function specified by the command. */
 	ret = (*params->element_proc)(
 		params, lcore_id,
-		path->name, component_type,
-		path->num_rx, rx_ports, path->num_tx, tx_ports);
+		fwd_path->name, component_type,
+		fwd_path->num_rx, rx_ports, fwd_path->num_tx, tx_ports);
 	if (unlikely(ret != SPP_RET_OK))
 		return SPP_RET_NG;
 
-- 
2.17.1



More information about the spp mailing list