Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 09/10] spp_pcap: rename spp_get_core_status
Date: Fri, 31 May 2019 17:52:41 +0900	[thread overview]
Message-ID: <1559292762-27042-10-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <1559292762-27042-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp>

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

Revise misleading function names in spp_pcap, spp_get_core_status() and
spp_pcap_get_core_status(). First one is to get lcore status actually,
but second one is to thread info on the lcore and the name is not
appropriate. This update is to rename first one to be more specific.
The second one is to be revise in the next patch.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/pcap/cmd_runner.c |  2 +-
 src/pcap/cmd_utils.c  |  4 ++--
 src/pcap/cmd_utils.h  | 28 +++++++++++-----------------
 src/pcap/spp_pcap.c   | 21 ++++++++++-----------
 4 files changed, 24 insertions(+), 31 deletions(-)

diff --git a/src/pcap/cmd_runner.c b/src/pcap/cmd_runner.c
index 3080242..f94deea 100644
--- a/src/pcap/cmd_runner.c
+++ b/src/pcap/cmd_runner.c
@@ -79,7 +79,7 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
 	int lcore_id;
 
 	RTE_LCORE_FOREACH_SLAVE(lcore_id) {
-		if (spp_get_core_status(lcore_id) == SPP_CORE_UNUSE)
+		if (sppwk_get_lcore_status(lcore_id) == SPP_CORE_UNUSE)
 			continue;
 
 		ret = spp_pcap_get_core_status(lcore_id, params);
diff --git a/src/pcap/cmd_utils.c b/src/pcap/cmd_utils.c
index 084b3ca..726ad9e 100644
--- a/src/pcap/cmd_utils.c
+++ b/src/pcap/cmd_utils.c
@@ -63,9 +63,9 @@ add_ring_pmd(int ring_id)
 	return ring_port_id;
 }
 
-/* Get core status */
+/* Get status of lcore of given ID from global management info. */
 enum sppwk_lcore_status
-spp_get_core_status(unsigned int lcore_id)
+sppwk_get_lcore_status(unsigned int lcore_id)
 {
 	return (g_mng_data_addr.p_core_info + lcore_id)->status;
 }
diff --git a/src/pcap/cmd_utils.h b/src/pcap/cmd_utils.h
index 8487c23..5528e00 100644
--- a/src/pcap/cmd_utils.h
+++ b/src/pcap/cmd_utils.h
@@ -186,6 +186,7 @@ struct core_mng_info {
 	volatile enum sppwk_lcore_status status;
 };
 
+/* TODO(yasufum) refactor name of func and vars, and comments. */
 struct spp_iterate_core_params;
 /**
  * definition of iterated core element procedure function
@@ -203,6 +204,7 @@ typedef int (*spp_iterate_core_element_proc)(
 		const int num_tx,
 		const struct sppwk_port_idx *tx_ports);
 
+/* TODO(yasufum) refactor name of func and vars, and comments. */
 /**
  * iterate core table parameters which is
  * used when listing core table content
@@ -228,36 +230,28 @@ struct spp_iterate_core_params {
 int add_ring_pmd(int ring_id);
 
 /**
- * Get core status
+ * Get status of lcore of given ID from global management info.
  *
- * @param lcore_id
- *  Logical core ID.
- *
- * @return
- *  Status of specified logical core.
+ * @param[in] lcore_id Logical core ID.
+ * @return Status of specified logical core.
  */
-enum sppwk_lcore_status spp_get_core_status(unsigned int lcore_id);
+enum sppwk_lcore_status sppwk_get_lcore_status(unsigned int lcore_id);
 
 /**
  * Run check_core_status() for SPP_CORE_STATUS_CHECK_MAX times with
  * interval time (1sec)
  *
- * @param status
- *  wait check status.
- *
- * @retval 0  succeeded.
- * @retval -1 failed.
+ * @param status Wait check status.
+ * @retval 0  If succeeded.
+ * @retval -1 If failed.
  */
 int check_core_status_wait(enum sppwk_lcore_status status);
 
 /**
  * Set core status
  *
- * @param lcore_id
- *  Logical core ID.
- * @param status
- *  set status.
- *
+ * @param lcore_id Logical core ID.
+ * @param status Set status.
  */
 void set_core_status(unsigned int lcore_id, enum sppwk_lcore_status status);
 
diff --git a/src/pcap/spp_pcap.c b/src/pcap/spp_pcap.c
index a7f95e9..dec3f37 100644
--- a/src/pcap/spp_pcap.c
+++ b/src/pcap/spp_pcap.c
@@ -322,8 +322,6 @@ parse_args(int argc, char *argv[])
 	g_pcap_option.fsize_limit = DEFAULT_FILE_LIMIT;
 
 	/* Check options of application */
-	optind = 0;
-	opterr = 0;
 	while ((opt = getopt_long(argc, argvopt, "c:s:", lgopts,
 			&option_index)) != EOF) {
 		switch (opt) {
@@ -396,18 +394,22 @@ parse_args(int argc, char *argv[])
 	return SPPWK_RET_OK;
 }
 
-/* Pcap get core status */
+/* TODO(yasufum) refactor name of func and vars, and comments. */
+/**
+ * Get each of attrs such as name, type or nof ports of a thread on a lcore.
+ * MEMO: This func is not for getting core status, but thread info actually.
+ */
 int
 spp_pcap_get_core_status(
 		unsigned int lcore_id,
 		struct spp_iterate_core_params *params)
 {
-	int ret = SPPWK_RET_NG;
 	char role_type[8];
 	struct pcap_mng_info *info = &g_pcap_info[lcore_id];
 	char name[PCAP_FPATH_STRLEN + PCAP_FDATE_STRLEN];
 	struct sppwk_port_idx rx_ports[1];
 	int rx_num = 0;
+	int res;
 
 	RTE_LOG(DEBUG, SPP_PCAP, "status core[%d]\n", lcore_id);
 	if (info->type == PCAP_RECEIVE) {
@@ -426,13 +428,10 @@ spp_pcap_get_core_status(
 		strcpy(role_type, "write");
 	}
 
-
-	/* Set the information with the function specified by the command. */
-	ret = (*params->element_proc)(
-		params, lcore_id,
-		name, role_type,
+	/* Set information with specified by the command. */
+	res = (*params->element_proc)(params, lcore_id, name, role_type,
 		rx_num, rx_ports, 0, NULL);
-	if (unlikely(ret != 0))
+	if (unlikely(res != 0))
 		return SPPWK_RET_NG;
 
 	return SPPWK_RET_OK;
@@ -915,7 +914,7 @@ slave_main(void *arg __attribute__ ((unused)))
 	set_core_status(lcore_id, SPP_CORE_IDLE);
 
 	while (1) {
-		if (spp_get_core_status(lcore_id) == SPP_CORE_STOP_REQUEST) {
+		if (sppwk_get_lcore_status(lcore_id) == SPP_CORE_STOP_REQUEST) {
 			if (pcap_info->status == SPP_CAPTURE_IDLE)
 				break;
 			if (pcap_info->type == PCAP_RECEIVE)
-- 
2.17.1


  parent reply	other threads:[~2019-05-31  8:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31  8:52 [spp] [PATCH 00/10] Refactor cmd parser in spp_pcap ogawa.yasufumi
2019-05-31  8:52 ` [spp] [PATCH 01/10] spp_pcap: rename enum spp_command_type ogawa.yasufumi
2019-05-31  8:52 ` [spp] [PATCH 02/10] spp_pcap: rename struct spp_command ogawa.yasufumi
2019-05-31  8:52 ` [spp] [PATCH 03/10] spp_pcap: revise command response codes ogawa.yasufumi
2019-05-31  8:52 ` [spp] [PATCH 04/10] spp_pcap: revise parser functions ogawa.yasufumi
2019-05-31  8:52 ` [spp] [PATCH 05/10] spp_pcap: refactor func for splitting cmd tokens ogawa.yasufumi
2019-05-31  8:52 ` [spp] [PATCH 06/10] spp_pcap: revise log msgs in parser func ogawa.yasufumi
2019-05-31  8:52 ` [spp] [PATCH 07/10] spp_pcap: remove unused string list ogawa.yasufumi
2019-05-31  8:52 ` [spp] [PATCH 08/10] spp_pcap: refactor comments of spp_pcap ogawa.yasufumi
2019-05-31  8:52 ` ogawa.yasufumi [this message]
2019-05-31  8:52 ` [spp] [PATCH 10/10] spp_pcap: revise name of vars for parser error ogawa.yasufumi

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=1559292762-27042-10-git-send-email-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --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).