Soft Patch Panel
 help / color / mirror / Atom feed
* [spp] [PATCH] spp_vf: rename spp_forward.c to forwarder.c
@ 2019-06-24  8:40 yasufum.o
  0 siblings, 0 replies; only message in thread
From: yasufum.o @ 2019-06-24  8:40 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

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

This update is to rename files and functions defined in the files for
refactoring.

* `spp_forward.c` and `spp_forward.h` to `forwarder.c` and
  `forwarder.h`.

* spp_forward() to forward_packets().

* spp_forward_init() to init_forwarder().

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/vf/Makefile                       |  2 +-
 src/vf/{spp_forward.c => forwarder.c} | 35 +++++++++++++--------------
 src/vf/{spp_forward.h => forwarder.h} | 17 +++++++------
 src/vf/spp_vf.c                       |  6 ++---
 src/vf/vf_cmd_runner.c                |  2 +-
 5 files changed, 31 insertions(+), 31 deletions(-)
 rename src/vf/{spp_forward.c => forwarder.c} (88%)
 rename src/vf/{spp_forward.h => forwarder.h} (78%)

diff --git a/src/vf/Makefile b/src/vf/Makefile
index 83d1f14..1d6cb7c 100644
--- a/src/vf/Makefile
+++ b/src/vf/Makefile
@@ -15,7 +15,7 @@ SPP_SEC_DIR = ../shared/secondary
 SPP_WKT_DIR = ../shared/secondary/spp_worker_th
 
 # all source are stored in SRCS-y
-SRCS-y := spp_vf.c classifier_mac.c spp_forward.c
+SRCS-y := spp_vf.c classifier_mac.c forwarder.c
 SRCS-y += $(SPP_SEC_DIR)/string_buffer.c
 SRCS-y += $(SPP_SEC_DIR)/json_helper.c
 SRCS-y += $(SPP_SEC_DIR)/utils.c $(SPP_SEC_DIR)/add_port.c
diff --git a/src/vf/spp_forward.c b/src/vf/forwarder.c
similarity index 88%
rename from src/vf/spp_forward.c
rename to src/vf/forwarder.c
index 07031f7..4d99bfb 100644
--- a/src/vf/spp_forward.c
+++ b/src/vf/forwarder.c
@@ -4,7 +4,7 @@
 
 #include <rte_cycles.h>
 
-#include "spp_forward.h"
+#include "forwarder.h"
 #include "spp_vf.h"
 #include "shared/secondary/return_codes.h"
 #include "shared/secondary/spp_worker_th/vf_deps.h"
@@ -20,12 +20,11 @@ struct forward_rxtx {
 
 /* Information on the path used for forward. */
 struct forward_path {
-	char name[STR_LEN_NAME];    /* component name */
+	char name[STR_LEN_NAME];  /* Component name */
 	volatile enum sppwk_worker_type wk_type;
-	int num_rx;                     /* number of receive ports */
-	int num_tx;                     /* number of trans ports   */
-	struct forward_rxtx ports[RTE_MAX_ETHPORTS];
-					/* port used for transfer  */
+	int nof_rx;  /* Number of RX ports */
+	int nof_tx;  /* Number of TX ports */
+	struct forward_rxtx ports[RTE_MAX_ETHPORTS];  /* Set of RX and TX */
 };
 
 /* Information for forward. */
@@ -38,9 +37,9 @@ struct forward_info {
 
 struct forward_info g_forward_info[RTE_MAX_LCORE];
 
-/* Clear info */
+/* Clear g_forward_info, ref and update indices. */
 void
-spp_forward_init(void)
+init_forwarder(void)
 {
 	int cnt = 0;
 	memset(&g_forward_info, 0x00, sizeof(g_forward_info));
@@ -77,13 +76,13 @@ get_forwarder_status(unsigned int lcore_id, int id,
 		component_type = SPPWK_TYPE_FWD_STR;
 
 	memset(rx_ports, 0x00, sizeof(rx_ports));
-	for (cnt = 0; cnt < fwd_path->num_rx; cnt++) {
+	for (cnt = 0; cnt < fwd_path->nof_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 < fwd_path->num_tx; cnt++) {
+	for (cnt = 0; cnt < fwd_path->nof_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;
 	}
@@ -92,7 +91,7 @@ get_forwarder_status(unsigned int lcore_id, int id,
 	ret = (*params->element_proc)(
 		params, lcore_id,
 		fwd_path->name, component_type,
-		fwd_path->num_rx, rx_ports, fwd_path->num_tx, tx_ports);
+		fwd_path->nof_rx, rx_ports, fwd_path->nof_tx, tx_ports);
 	if (unlikely(ret != SPP_RET_OK))
 		return SPP_RET_NG;
 
@@ -140,8 +139,8 @@ update_forwarder(struct sppwk_comp_info *comp_info)
 
 	memcpy(&fwd_path->name, comp_info->name, STR_LEN_NAME);
 	fwd_path->wk_type = comp_info->wk_type;
-	fwd_path->num_rx = comp_info->nof_rx;
-	fwd_path->num_tx = comp_info->nof_tx;
+	fwd_path->nof_rx = comp_info->nof_rx;
+	fwd_path->nof_tx = comp_info->nof_tx;
 	for (cnt = 0; cnt < nof_rx; cnt++)
 		memcpy(&fwd_path->ports[cnt].rx, comp_info->rx_ports[cnt],
 				sizeof(struct sppwk_port_info));
@@ -177,13 +176,13 @@ change_forward_index(int id)
 	}
 }
 /**
- * Forwarding packets as forwarder or merger
+ * Forward packets as forwarder or merger.
  *
  * Behavior of forwarding is defined as core_info->type which is given
  * as an argument of void and typecasted to spp_config_info.
  */
 int
-spp_forward(int id)
+forward_packets(int id)
 {
 	int cnt, buf;
 	int nb_rx = 0;
@@ -200,15 +199,15 @@ spp_forward(int id)
 	/* Practice condition check */
 	if (path->wk_type == SPPWK_TYPE_MRG) {
 		/* merger */
-		if (!(path->num_tx == 1 && path->num_rx >= 1))
+		if (!(path->nof_tx == 1 && path->nof_rx >= 1))
 			return SPP_RET_OK;
 	} else {
 		/* forwarder */
-		if (!(path->num_tx == 1 && path->num_rx == 1))
+		if (!(path->nof_tx == 1 && path->nof_rx == 1))
 			return SPP_RET_OK;
 	}
 
-	for (cnt = 0; cnt < path->num_rx; cnt++) {
+	for (cnt = 0; cnt < path->nof_rx; cnt++) {
 		rx = &path->ports[cnt].rx;
 		tx = &path->ports[cnt].tx;
 
diff --git a/src/vf/spp_forward.h b/src/vf/forwarder.h
similarity index 78%
rename from src/vf/spp_forward.h
rename to src/vf/forwarder.h
index 37b1e3c..54a204b 100644
--- a/src/vf/spp_forward.h
+++ b/src/vf/forwarder.h
@@ -23,19 +23,20 @@
  * is specified by port command.
  */
 
-/** Clear info */
-void spp_forward_init(void);
+/* Clear g_forward_info, ref and update indices. */
+void init_forwarder(void);
 
 /**
- * Merge/Forward
+ * Forward packets as forwarder or merger.
  *
- * @param id
- *  The unique component ID.
+ * Behavior of forwarding is defined as core_info->type which is given
+ * as an argument of void and typecasted to spp_config_info.
  *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
+ * @param[in] id Unique component ID.
+ * @retval SPP_RET_OK If succeeded.
+ * @retval SPP_RET_NG If failed.
  */
-int spp_forward(int id);
+int forward_packets(int id);
 
 /**
  * Get forwarder status.
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index e55e3f0..7ba894e 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -9,7 +9,7 @@
 #include "spp_vf.h"
 #include "shared/secondary/spp_worker_th/cmd_utils.h"
 #include "classifier_mac.h"
-#include "spp_forward.h"
+#include "forwarder.h"
 #include "shared/secondary/return_codes.h"
 #include "shared/secondary/spp_worker_th/cmd_runner.h"
 #include "shared/secondary/spp_worker_th/cmd_parser.h"
@@ -221,7 +221,7 @@ slave_main(void *arg __attribute__ ((unused)))
 					break;
 			} else {
 				/* Component type for forward or merge. */
-				ret = spp_forward(core->id[cnt]);
+				ret = forward_packets(core->id[cnt]);
 				if (unlikely(ret != 0))
 					break;
 			}
@@ -296,7 +296,7 @@ main(int argc, char *argv[])
 		if (unlikely(ret_classifier_mac_init != SPP_RET_OK))
 			break;
 
-		spp_forward_init();
+		init_forwarder();
 		spp_port_ability_init();
 
 		/* Setup connection for accepting commands from controller */
diff --git a/src/vf/vf_cmd_runner.c b/src/vf/vf_cmd_runner.c
index 46d54b4..51f50a7 100644
--- a/src/vf/vf_cmd_runner.c
+++ b/src/vf/vf_cmd_runner.c
@@ -3,7 +3,7 @@
  */
 
 #include "classifier_mac.h"
-#include "spp_forward.h"
+#include "forwarder.h"
 #include "shared/secondary/return_codes.h"
 #include "shared/secondary/json_helper.h"
 #include "shared/secondary/spp_worker_th/cmd_parser.h"
-- 
2.17.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-06-24  8:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-24  8:40 [spp] [PATCH] spp_vf: rename spp_forward.c to forwarder.c yasufum.o

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