Soft Patch Panel
 help / color / mirror / Atom feed
From: yasufum.o@gmail.com
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 03/11] shared/sec: refactor comments in vf_deps.h
Date: Mon, 24 Jun 2019 11:24:56 +0900	[thread overview]
Message-ID: <20190624022504.18752-4-yasufum.o@gmail.com> (raw)
In-Reply-To: <20190624022504.18752-1-yasufum.o@gmail.com>

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

This update is to revise comments and format in `vf_deps.h` for
refactoring.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/shared/secondary/spp_worker_th/vf_deps.h | 81 +++++++-------------
 src/vf/classifier_mac.c                      | 67 +++++++---------
 2 files changed, 53 insertions(+), 95 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/vf_deps.h b/src/shared/secondary/spp_worker_th/vf_deps.h
index c6016b8..3e8fc01 100644
--- a/src/shared/secondary/spp_worker_th/vf_deps.h
+++ b/src/shared/secondary/spp_worker_th/vf_deps.h
@@ -21,24 +21,15 @@ struct mac_classifier {
 };
 
 /* classified data (destination port, target packets, etc) */
+/* TODO(yasufum) rename `classified_data`. */
+/* TODO(yasufum) confirm what `iface_no_global` does mean? */
 struct classified_data {
-	/* interface type (see "enum port_type") */
-	enum port_type  iface_type;
-
-	/* index of ports handled by classifier */
-	int             iface_no;
-
-	/* id for interface generated by spp_vf */
-	int             iface_no_global;
-
-	/* port id generated by DPDK */
-	uint16_t        port;
-
-	/* the number of packets in pkts[] */
-	uint16_t        num_pkt;
-
-	/* packet array to be classified */
-	struct rte_mbuf *pkts[MAX_PKT_BURST];
+	enum port_type iface_type;
+	int iface_no;   /* Index of ports handled by classifier. */
+	int iface_no_global;  /* ID for interface generated by spp_vf */
+	uint16_t port;  /* Ethdev port ID. */
+	uint16_t nof_pkts;  /* Number of packets in pkts[]. */
+	struct rte_mbuf *pkts[MAX_PKT_BURST];  /* packets to be classified. */
 };
 
 /* classifier component information */
@@ -71,24 +62,18 @@ free_mac_classification(struct mac_classifier *mac_cls)
 /**
  * classifier(mac address) update component info.
  *
- * @param component_info
- *  The pointer to struct sppwk_comp_info.@n
- *  The data for updating the internal data of classifier.
- *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
+ * @param comp_info Pointer to internal data of classifier.
+ * @retval SPP_RET_OK If succeeded.
+ * @retval SPP_RET_NG If failed.
  */
-int spp_classifier_mac_update(struct sppwk_comp_info *component_info);
+int spp_classifier_mac_update(struct sppwk_comp_info *comp_info);
 
 /**
- * Update forward info
- *
- * @param component
- *  The pointer to struct sppwk_comp_info.@n
- *  The data for updating the internal data of forwarder and merger.
+ * Update forwarder info.
  *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
+ * @param component Pointer to data of forwarder and merger.
+ * @retval SPP_RET_OK If succeeded.
+ * @retval SPP_RET_NG If failed.
  */
 int spp_forward_update(struct sppwk_comp_info *component);
 
@@ -102,17 +87,11 @@ int spp_classifier_mac_iterate_table(
 /**
  * classifier get component status.
  *
- *
- * @param lcore_id
- *  The logical core ID for classifier.
- * @param id
- *  The unique component ID.
- * @param params
- *  The pointer to struct spp_iterate_core_params.@n
- *  Detailed data of classifier status.
- *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
+ * @param[in] lcore_id Lcore ID for classifier.
+ * @param[in] id Unique component ID.
+ * @param[in,out] params Pointer to detailed data of classifier status.
+ * @retval SPP_RET_OK If succeeded.
+ * @retval SPP_RET_NG If failed.
  */
 int spp_classifier_get_component_status(unsigned int lcore_id, int id,
 		struct spp_iterate_core_params *params);
@@ -120,19 +99,13 @@ int spp_classifier_get_component_status(unsigned int lcore_id, int id,
 /**
  * Merge/Forward get component status
  *
- * @param lcore_id
- *  The logical core ID for forwarder and merger.
- * @param id
- *  The unique component ID.
- * @param params
- *  The pointer to struct spp_iterate_core_params.@n
- *  Detailed data of forwarder/merger status.
- *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
+ * @param lcore_id Lcore ID for forwarder and merger.
+ * @param id Unique component ID.
+ * @param params Pointer detailed data of forwarder and merger status.
+ * @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 spp_forward_get_component_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 5398d25..cd0c546 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -342,7 +342,7 @@ init_component_info(struct component_info *cmp_info,
 		clsd_data_rx->iface_no = 0;
 		clsd_data_rx->iface_no_global = 0;
 		clsd_data_rx->port = 0;
-		clsd_data_rx->num_pkt = 0;
+		clsd_data_rx->nof_pkts = 0;
 	} else {
 		clsd_data_rx->iface_type =
 			component_info->rx_ports[0]->iface_type;
@@ -351,7 +351,7 @@ init_component_info(struct component_info *cmp_info,
 			component_info->rx_ports[0]->iface_no;
 		clsd_data_rx->port =
 			component_info->rx_ports[0]->ethdev_port_id;
-		clsd_data_rx->num_pkt = 0;
+		clsd_data_rx->nof_pkts = 0;
 	}
 
 	/* set tx */
@@ -366,7 +366,7 @@ init_component_info(struct component_info *cmp_info,
 		clsd_data_tx[i].iface_no        = i;
 		clsd_data_tx[i].iface_no_global = tx_port->iface_no;
 		clsd_data_tx[i].port            = tx_port->ethdev_port_id;
-		clsd_data_tx[i].num_pkt         = 0;
+		clsd_data_tx[i].nof_pkts = 0;
 
 		if (tx_port->cls_attrs.mac_addr == 0)
 			continue;
@@ -457,19 +457,19 @@ transmit_packet(struct classified_data *clsd_data)
 
 	/* transmit packets */
 	n_tx = spp_eth_tx_burst(clsd_data->port, 0,
-			clsd_data->pkts, clsd_data->num_pkt);
+			clsd_data->pkts, clsd_data->nof_pkts);
 
 	/* free cannot transmit packets */
-	if (unlikely(n_tx != clsd_data->num_pkt)) {
-		for (i = n_tx; i < clsd_data->num_pkt; i++)
+	if (unlikely(n_tx != clsd_data->nof_pkts)) {
+		for (i = n_tx; i < clsd_data->nof_pkts; i++)
 			rte_pktmbuf_free(clsd_data->pkts[i]);
 		RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC,
 				"drop packets(tx). num=%hu, ethdev_port_id=%hu\n",
-				(uint16_t)(clsd_data->num_pkt - n_tx),
+				(uint16_t)(clsd_data->nof_pkts - n_tx),
 				clsd_data->port);
 	}
 
-	clsd_data->num_pkt = 0;
+	clsd_data->nof_pkts = 0;
 }
 
 /* transmit packet to one destination. */
@@ -480,13 +480,13 @@ transmit_all_packet(struct component_info *cmp_info)
 	struct classified_data *clsd_data_tx = cmp_info->classified_data_tx;
 
 	for (i = 0; i < cmp_info->n_classified_data_tx; i++) {
-		if (unlikely(clsd_data_tx[i].num_pkt != 0)) {
+		if (unlikely(clsd_data_tx[i].nof_pkts != 0)) {
 			RTE_LOG(INFO, SPP_CLASSIFIER_MAC,
 					"transmit all packets (drain). "
 					"index=%d, "
-					"num_pkt=%hu\n",
+					"nof_pkts=%hu\n",
 					i,
-					clsd_data_tx[i].num_pkt);
+					clsd_data_tx[i].nof_pkts);
 			transmit_packet(&clsd_data_tx[i]);
 		}
 	}
@@ -496,19 +496,19 @@ transmit_all_packet(struct component_info *cmp_info)
 static inline void
 push_packet(struct rte_mbuf *pkt, struct classified_data *clsd_data)
 {
-	clsd_data->pkts[clsd_data->num_pkt++] = pkt;
+	clsd_data->pkts[clsd_data->nof_pkts++] = pkt;
 
 	/* transmit packet, if buffer is filled */
-	if (unlikely(clsd_data->num_pkt == MAX_PKT_BURST)) {
+	if (unlikely(clsd_data->nof_pkts == MAX_PKT_BURST)) {
 		RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC,
 				"transmit packets (buffer is filled). "
 				"iface_type=%d, iface_no={%d,%d}, "
-				"tx_port=%hu, num_pkt=%hu\n",
+				"tx_port=%hu, nof_pkts=%hu\n",
 				clsd_data->iface_type,
 				clsd_data->iface_no_global,
 				clsd_data->iface_no,
 				clsd_data->port,
-				clsd_data->num_pkt);
+				clsd_data->nof_pkts);
 		transmit_packet(clsd_data);
 	}
 }
@@ -679,14 +679,12 @@ change_classifier_index(struct management_info *mng_info, int id)
 									0, 0);
 
 		/* Transmit all packets for switching the using data. */
-		transmit_all_packet(mng_info->cmp_infos +
-				mng_info->ref_index);
+		transmit_all_packet(mng_info->cmp_infos + mng_info->ref_index);
 
 		RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC,
 				"Core[%u] Change update index.\n", id);
 		mng_info->ref_index =
-				(mng_info->upd_index + 1) %
-				NOF_CLS_INFO;
+				(mng_info->upd_index + 1) % NOF_CLS_INFO;
 	}
 }
 
@@ -695,7 +693,6 @@ int
 spp_classifier_mac_init(void)
 {
 	memset(g_mng_infos, 0, sizeof(g_mng_infos));
-
 	return 0;
 }
 
@@ -778,13 +775,13 @@ spp_classifier_mac_do(int id)
 	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))
+			if (likely(clsd_data_tx[i].nof_pkts == 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,
+					"nof_pkts=%hu, interval=%lu\n",
+					i, clsd_data_tx[i].nof_pkts,
 					cur_tsc - prev_tsc);
 				transmit_packet(&clsd_data_tx[i]);
 		}
@@ -889,18 +886,13 @@ mac_classification_iterate_table(
 				SPP_DEFAULT_CLASSIFIED_SPEC_STR,
 				cmp_info, clsd_data);
 
-		(*params->element_proc)(
-				params,
-				type,
-				vid,
-				SPP_DEFAULT_CLASSIFIED_SPEC_STR,
-				&port);
+		(*params->element_proc)(params, type, vid,
+				SPP_DEFAULT_CLASSIFIED_SPEC_STR, &port);
 	}
 
 	next = 0;
 	while (1) {
-		ret = rte_hash_iterate(mac_cls->cls_tbl,
-				&key, &data, &next);
+		ret = rte_hash_iterate(mac_cls->cls_tbl, &key, &data, &next);
 
 		if (unlikely(ret < 0))
 			break;
@@ -913,11 +905,7 @@ mac_classification_iterate_table(
 
 		LOG_ENT((long)data, vid, mac_addr_str, cmp_info, clsd_data);
 
-		(*params->element_proc)(
-				params,
-				type,
-				vid,
-				mac_addr_str,
+		(*params->element_proc)(params, type, vid, mac_addr_str,
 				&port);
 	}
 }
@@ -947,12 +935,9 @@ spp_classifier_mac_iterate_table(
 			if (cmp_info->mac_classifications[n] == NULL)
 				continue;
 
-			mac_classification_iterate_table(
-					params,
-					(uint16_t)n,
+			mac_classification_iterate_table(params, (uint16_t) n,
 					cmp_info->mac_classifications[n],
-					cmp_info,
-					clsd_data);
+					cmp_info, clsd_data);
 		}
 	}
 
-- 
2.17.1


  parent reply	other threads:[~2019-06-24  2:25 UTC|newest]

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 ` yasufum.o [this message]
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 ` [spp] [PATCH 09/11] shared/sec: refactor updating forwarder yasufum.o
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 publicly 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-4-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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).