Soft Patch Panel
 help / color / mirror / Atom feed
From: Yasufumi Ogawa <yasufum.o@gmail.com>
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 6/6] spp_vf: rename spp_classifier_mac_do
Date: Fri,  2 Aug 2019 18:33:58 +0900	[thread overview]
Message-ID: <20190802093358.13696-7-yasufum.o@gmail.com> (raw)
In-Reply-To: <20190802093358.13696-1-yasufum.o@gmail.com>

Function spp_classifier_mac_do() is for classification incoming packets
on each of threads, but the name is not intuitive. This udpate is to
rename this function simply to classify_packets().

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/vf/classifier.c | 37 ++++++++++++++-----------------------
 src/vf/classifier.h | 10 ++++------
 src/vf/spp_vf.c     |  2 +-
 3 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/src/vf/classifier.c b/src/vf/classifier.c
index 233c780..b85dd79 100644
--- a/src/vf/classifier.c
+++ b/src/vf/classifier.c
@@ -87,7 +87,7 @@ uninit_classifier(struct cls_mng_info *mng_info)
 	memset(mng_info, 0, sizeof(struct cls_mng_info));
 }
 
-/* initialize classifier information. */
+/* Initialize classifier information. */
 void
 init_classifier_info(int comp_id)
 {
@@ -445,7 +445,7 @@ uninit_component_info(struct cls_comp_info *comp_info)
 
 /* transmit packet to one destination. */
 static inline void
-transmit_packet(struct cls_port_info *clsd_data)
+transmit_packets(struct cls_port_info *clsd_data)
 {
 	int i;
 	uint16_t n_tx;
@@ -488,7 +488,7 @@ transmit_all_packet(struct cls_comp_info *cmp_info)
 					"nof_pkts=%hu\n",
 					i,
 					clsd_data_tx[i].nof_pkts);
-			transmit_packet(&clsd_data_tx[i]);
+			transmit_packets(&clsd_data_tx[i]);
 		}
 	}
 }
@@ -510,7 +510,7 @@ push_packet(struct rte_mbuf *pkt, struct cls_port_info *clsd_data)
 				clsd_data->iface_no,
 				clsd_data->ethdev_port_id,
 				clsd_data->nof_pkts);
-		transmit_packet(clsd_data);
+		transmit_packets(clsd_data);
 	}
 }
 
@@ -634,12 +634,8 @@ select_classified_index(const struct rte_mbuf *pkt,
 	return mac_cls->default_cls_idx;
 }
 
-/*
- * classify packet by destination mac address,
- * and transmit packet (conditional).
- */
 static inline void
-classify_packet(struct rte_mbuf **rx_pkts, uint16_t n_rx,
+_classify_packets(struct rte_mbuf **rx_pkts, uint16_t n_rx,
 		struct cls_comp_info *cmp_info,
 		struct cls_port_info *clsd_data)
 {
@@ -669,6 +665,7 @@ classify_packet(struct rte_mbuf **rx_pkts, uint16_t n_rx,
 	}
 }
 
+/* TODO(yasufum) Revise this comment and name of func. */
 /* change update index at classifier management information */
 static inline void
 change_classifier_index(struct cls_mng_info *mng_info, int id)
@@ -738,13 +735,13 @@ update_classifier(struct sppwk_comp_info *wk_comp_info)
 	return SPPWK_RET_OK;
 }
 
-/* classifier(mac address) thread function. */
+/* Classify incoming packets on a thread of given `comp_id`. */
 int
-spp_classifier_mac_do(int id)
+classify_packets(int comp_id)
 {
 	int i;
 	int n_rx;
-	struct cls_mng_info *mng_info = cls_mng_info_list + id;
+	struct cls_mng_info *mng_info = cls_mng_info_list + comp_id;
 	struct cls_comp_info *cmp_info = NULL;
 	struct rte_mbuf *rx_pkts[MAX_PKT_BURST];
 
@@ -756,23 +753,18 @@ spp_classifier_mac_do(int id)
 			US_PER_S * DRAIN_TX_PACKET_INTERVAL;
 
 	/* change index of update classifier management information */
-	change_classifier_index(mng_info, id);
+	change_classifier_index(mng_info, comp_id);
 
 	cmp_info = mng_info->cmp_infos + mng_info->ref_index;
 	clsd_data_rx = &cmp_info->rx_port_i;
 	clsd_data_tx = cmp_info->tx_ports_i;
 
-	/**
-	 * decide classifier information of the current cycle If at least,
-	 * one rx port, one tx port and one classifier_table exist, then start
-	 * classifying. If not, stop classifying.
-	 */
+	/* Check if it is ready to do classifying. */
 	if (!(clsd_data_rx->iface_type != UNDEF &&
 			cmp_info->nof_tx_ports >= 1 &&
 			cmp_info->mac_addr_entry == 1))
 		return SPPWK_RET_OK;
 
-	/* drain tx packets, if buffer is not filled for interval */
 	cur_tsc = rte_rdtsc();
 	if (unlikely(cur_tsc - prev_tsc > drain_tsc)) {
 		for (i = 0; i < cmp_info->nof_tx_ports; i++) {
@@ -784,7 +776,7 @@ spp_classifier_mac_do(int id)
 					"nof_pkts=%hu, interval=%lu\n",
 					i, clsd_data_tx[i].nof_pkts,
 					cur_tsc - prev_tsc);
-				transmit_packet(&clsd_data_tx[i]);
+				transmit_packets(&clsd_data_tx[i]);
 		}
 		prev_tsc = cur_tsc;
 	}
@@ -792,7 +784,7 @@ spp_classifier_mac_do(int id)
 	if (clsd_data_rx->iface_type == UNDEF)
 		return SPPWK_RET_OK;
 
-	/* retrieve packets */
+	/* Retrieve packets */
 #ifdef SPP_RINGLATENCYSTATS_ENABLE
 	n_rx = sppwk_eth_vlan_ring_stats_rx_burst(clsd_data_rx->ethdev_port_id,
 			clsd_data_rx->iface_type, clsd_data_rx->iface_no,
@@ -804,8 +796,7 @@ spp_classifier_mac_do(int id)
 	if (unlikely(n_rx == 0))
 		return SPPWK_RET_OK;
 
-	/* classify and interval that transmit burst packet */
-	classify_packet(rx_pkts, n_rx, cmp_info, clsd_data_tx);
+	_classify_packets(rx_pkts, n_rx, cmp_info, clsd_data_tx);
 
 	return SPPWK_RET_OK;
 }
diff --git a/src/vf/classifier.h b/src/vf/classifier.h
index 69cbb88..0f28a51 100644
--- a/src/vf/classifier.h
+++ b/src/vf/classifier.h
@@ -34,19 +34,17 @@ int init_cls_mng_info(void);
  *  The unique component ID.
  *
  */
-void init_classifier_info(int component_id);
+void init_classifier_info(int comp_id);
 
 
 /**
- * classifier(mac address) thread function.
- *
- * @param id
- *  The unique component ID.
+ * Classify incoming packets.
  *
+ * @param id Component ID.
  * @retval SPPWK_RET_OK succeeded.
  * @retval SPPWK_RET_NG failed.
  */
-int spp_classifier_mac_do(int id);
+int classify_packets(int comp_id);
 
 /**
  * classifier(mac address) iterate classifier table.
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index b2f2af4..a86acec 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -177,7 +177,7 @@ slave_main(void *arg __attribute__ ((unused)))
 			if (spp_get_component_type(core->id[cnt]) ==
 					SPPWK_TYPE_CLS) {
 				/* Component type for classifier. */
-				ret = spp_classifier_mac_do(core->id[cnt]);
+				ret = classify_packets(core->id[cnt]);
 				if (unlikely(ret != 0))
 					break;
 			} else {
-- 
2.17.1


      parent reply	other threads:[~2019-08-02  9:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02  9:33 [spp] [PATCH 0/6] Refactor classifier of spp_vf Yasufumi Ogawa
2019-08-02  9:33 ` [spp] [PATCH 1/6] spp_vf: rename file classifier_mac Yasufumi Ogawa
2019-08-02  9:33 ` [spp] [PATCH 2/6] spp_vf: rename func spp_classifier_mac_init Yasufumi Ogawa
2019-08-02  9:33 ` [spp] [PATCH 3/6] spp_vf: remove no meaning int variables Yasufumi Ogawa
2019-08-02  9:33 ` [spp] [PATCH 4/6] spp_vf: rename management_info to cls_mng_info Yasufumi Ogawa
2019-08-02  9:33 ` [spp] [PATCH 5/6] spp_vf: refactor variables in classifier.c Yasufumi Ogawa
2019-08-02  9:33 ` Yasufumi Ogawa [this message]

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