Soft Patch Panel
 help / color / Atom feed
From: yasufum.o@gmail.com
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 09/11] shared/sec: refactor updating forwarder
Date: Mon, 24 Jun 2019 11:25:02 +0900
Message-ID: <20190624022504.18752-10-yasufum.o@gmail.com> (raw)
In-Reply-To: <20190624022504.18752-1-yasufum.o@gmail.com>

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

Rename spp_forward_update() to update_forwarder(), and revise
vars and log messages for refactoring.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 .../secondary/spp_worker_th/cmd_utils.c       |  2 +-
 src/shared/secondary/spp_worker_th/vf_deps.h  |  6 +-
 src/vf/spp_forward.c                          | 70 +++++++++----------
 3 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.c b/src/shared/secondary/spp_worker_th/cmd_utils.c
index d5faa35..709c3da 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.c
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.c
@@ -893,7 +893,7 @@ update_comp_info(void)
 		if (comp_info->wk_type == SPPWK_TYPE_CLS)
 			ret = update_classifier(comp_info);
 		else
-			ret = spp_forward_update(comp_info);
+			ret = update_forwarder(comp_info);
 #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 8d3cd81..3ae4fc9 100644
--- a/src/shared/secondary/spp_worker_th/vf_deps.h
+++ b/src/shared/secondary/spp_worker_th/vf_deps.h
@@ -54,13 +54,13 @@ free_mac_classifier(struct mac_classifier *mac_clf)
 }
 
 /**
- * classifier(mac address) update component info.
+ * Update classifier info.
  *
  * @param comp_info Pointer to internal data of classifier.
  * @retval SPP_RET_OK If succeeded.
  * @retval SPP_RET_NG If failed.
  */
-int update_classifier(struct sppwk_comp_info *comp_info);
+int update_classifier(struct sppwk_comp_info *wk_comp_info);
 
 /**
  * Update forwarder info.
@@ -69,7 +69,7 @@ int update_classifier(struct sppwk_comp_info *comp_info);
  * @retval SPP_RET_OK If succeeded.
  * @retval SPP_RET_NG If failed.
  */
-int spp_forward_update(struct sppwk_comp_info *component);
+int update_forwarder(struct sppwk_comp_info *wk_comp_info);
 
 void init_classifier_info(int component_id);
 
diff --git a/src/vf/spp_forward.c b/src/vf/spp_forward.c
index 909f084..7746d40 100644
--- a/src/vf/spp_forward.c
+++ b/src/vf/spp_forward.c
@@ -51,64 +51,64 @@ spp_forward_init(void)
 
 /* Update forward info */
 int
-spp_forward_update(struct sppwk_comp_info *component)
+update_forwarder(struct sppwk_comp_info *comp_info)
 {
 	int cnt = 0;
-	int nof_rx = component->nof_rx;
-	int nof_tx = component->nof_tx;
+	int nof_rx = comp_info->nof_rx;
+	int nof_tx = comp_info->nof_tx;
 	int max = (nof_rx > nof_tx)?nof_rx*nof_tx:nof_tx;
-	struct forward_info *info = &g_forward_info[component->comp_id];
-	struct forward_path *path = &info->path[info->upd_index];
-
-	/* Forward component allows only one receiving port. */
-	if ((component->wk_type == SPPWK_TYPE_FWD) &&
+	struct forward_info *fwd_info = &g_forward_info[comp_info->comp_id];
+	/* TODO(yasufum) rename `path` of struct forward_path. */
+	struct forward_path *fwd_path = &fwd_info->path[fwd_info->upd_index];
+
+	/**
+	 * Check num of RX and TX ports because forwarder has just a set of
+	 * RX and TX.
+	 */
+	if ((comp_info->wk_type == SPPWK_TYPE_FWD) &&
 			unlikely(nof_rx > 1)) {
 		RTE_LOG(ERR, FORWARD,
-			"Component[%d] Setting error. (type = %d, rx = %d)\n",
-			component->comp_id, component->wk_type, nof_rx);
+			"Invalid forwarder type or num of RX ports "
+			"(id=%d, type=%d, nof_rx=%d).\n",
+			comp_info->comp_id, comp_info->wk_type, nof_rx);
 		return SPP_RET_NG;
 	}
-
-	/* Component allows only one transmit port. */
 	if (unlikely(nof_tx != 0) && unlikely(nof_tx != 1)) {
 		RTE_LOG(ERR, FORWARD,
-			"Component[%d] Setting error. (type = %d, tx = %d)\n",
-			component->comp_id, component->wk_type, nof_tx);
+			"Invalid forwarder type or num of TX ports "
+			"(id=%d, type=%d, nof_tx=%d).\n",
+			comp_info->comp_id, comp_info->wk_type, nof_tx);
 		return SPP_RET_NG;
 	}
 
-	memset(path, 0x00, sizeof(struct forward_path));
+	memset(fwd_path, 0x00, sizeof(struct forward_path));
 
 	RTE_LOG(INFO, FORWARD,
-			"Component[%d] Start update component. "
-			"(name = %s, type = %d)\n",
-			component->comp_id,
-			component->name,
-			component->wk_type);
-
-	memcpy(&path->name, component->name, STR_LEN_NAME);
-	path->wk_type = component->wk_type;
-	path->num_rx = component->nof_rx;
-	path->num_tx = component->nof_tx;
+			"Start updating forwarder (id=%d, name=%s, type=%d)\n",
+			comp_info->comp_id, comp_info->name,
+			comp_info->wk_type);
+
+	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;
 	for (cnt = 0; cnt < nof_rx; cnt++)
-		memcpy(&path->ports[cnt].rx, component->rx_ports[cnt],
+		memcpy(&fwd_path->ports[cnt].rx, comp_info->rx_ports[cnt],
 				sizeof(struct sppwk_port_info));
 
-	/* Transmit port is set according with larger nof_rx / nof_tx. */
+	/* TX port is set according with larger nof_rx / nof_tx. */
 	for (cnt = 0; cnt < max; cnt++)
-		memcpy(&path->ports[cnt].tx, component->tx_ports[0],
+		memcpy(&fwd_path->ports[cnt].tx, comp_info->tx_ports[0],
 				sizeof(struct sppwk_port_info));
 
-	info->upd_index = info->ref_index;
-	while (likely(info->ref_index == info->upd_index))
+	fwd_info->upd_index = fwd_info->ref_index;
+	while (likely(fwd_info->ref_index == fwd_info->upd_index))
 		rte_delay_us_block(SPP_CHANGE_UPDATE_INTERVAL);
 
 	RTE_LOG(INFO, FORWARD,
-			"Component[%d] Complete update component. "
-			"(name = %s, type = %d)\n",
-			component->comp_id,
-			component->name,
-			component->wk_type);
+			"Done update forwarder. (id=%d, name=%s, type=%d)\n",
+			comp_info->comp_id, comp_info->name,
+			comp_info->wk_type);
 
 	return SPP_RET_OK;
 }
-- 
2.17.1


  parent reply index

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24  2:24 [spp] [PATCH 00/11] Refactor libs for classifier in spp_vf yasufum.o
2019-06-24  2:24 ` [spp] [PATCH 01/11] shared/sec: refactor defines of VLAN " yasufum.o
2019-06-24  2:24 ` [spp] [PATCH 02/11] shared/sec: rename struct mac_classification yasufum.o
2019-06-24  2:24 ` [spp] [PATCH 03/11] shared/sec: refactor comments in vf_deps.h yasufum.o
2019-06-24  2:24 ` [spp] [PATCH 04/11] shared/sec: rename struct classified_data yasufum.o
2019-06-24  2:24 ` [spp] [PATCH 05/11] shared/sec: revise usage of term component_info yasufum.o
2019-06-24  2:24 ` [spp] [PATCH 06/11] shared/sec: revise members of struct cls_port_info yasufum.o
2019-06-24  2:25 ` [spp] [PATCH 07/11] shared/sec: rename func free_mac_classification yasufum.o
2019-06-24  2:25 ` [spp] [PATCH 08/11] shared/sec: refactor updating classifier info yasufum.o
2019-06-24  2:25 ` yasufum.o [this message]
2019-06-24  2:25 ` [spp] [PATCH 10/11] shared/sec: refactor getting classifier status yasufum.o
2019-06-24  2:25 ` [spp] [PATCH 11/11] shared/sec: refactor setup cls table stat in JSON yasufum.o

Reply instructions:

You may reply publically 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=20190624022504.18752-10-yasufum.o@gmail.com \
    --to=yasufum.o@gmail.com \
    --cc=ferruh.yigit@intel.com \
    --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

Soft Patch Panel

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/spp/0 spp/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 spp spp/ http://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


AGPL code for this site: git clone https://public-inbox.org/ public-inbox