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 2/5] shared/sec: rename funcs start with dump
Date: Mon, 24 Jun 2019 11:23:22 +0900	[thread overview]
Message-ID: <20190624022325.18695-3-yasufum.o@gmail.com> (raw)
In-Reply-To: <20190624022325.18695-1-yasufum.o@gmail.com>

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

Functions have prefix `dump_` do DEBUG logging actually, so the term
of prefix is vague and not describing the feature exactly. This update
is to change the prefix to `log_` to be explicitly doing just logging.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 .../secondary/spp_worker_th/cmd_utils.c       | 66 +++++++++----------
 .../secondary/spp_worker_th/cmd_utils.h       | 27 ++++----
 2 files changed, 44 insertions(+), 49 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.c b/src/shared/secondary/spp_worker_th/cmd_utils.c
index 07d6a2a..7f0a1ce 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.c
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.c
@@ -34,38 +34,30 @@ struct mng_data_info {
 	unsigned int main_lcore_id;
 };
 
-/* Declare global variables */
 /* Logical core ID for main process */
 static struct mng_data_info g_mng_data;
 
-/**
- * Make a hexdump of an array data in every 4 byte.
- * This function is used to dump core_info or component info.
- */
+/* Hexdump `addr` for logging, used for core_info or component info. */
 void
-dump_buff(const char *name, const void *addr, const size_t size)
+log_hexdumped(const char *obj_name, const void *obj_addr, const size_t size)
 {
-	size_t cnt = 0;
-	size_t max = (size / sizeof(unsigned int)) +
+	size_t cnt;
+	size_t max_cnt = (size / sizeof(unsigned int)) +
 			((size % sizeof(unsigned int)) != 0);
-	const uint32_t *buff = addr;
+	const uint32_t *buf = obj_addr;
 
-	if ((name != NULL) && (name[0] != '\0'))
-		RTE_LOG(DEBUG, APP, "dump buff. (%s)\n", name);
+	if ((obj_name != NULL) && (obj_name[0] != '\0'))
+		RTE_LOG(DEBUG, APP, "Name of dumped buf: %s.\n", obj_name);
 
-	for (cnt = 0; cnt < max; cnt += 16) {
+	for (cnt = 0; cnt < max_cnt; cnt += 16) {
 		RTE_LOG(DEBUG, APP, "[%p]"
-				" %08x %08x %08x %08x %08x %08x %08x %08x"
-				" %08x %08x %08x %08x %08x %08x %08x %08x",
-				&buff[cnt],
-				buff[cnt+0], buff[cnt+1],
-				buff[cnt+2], buff[cnt+3],
-				buff[cnt+4], buff[cnt+5],
-				buff[cnt+6], buff[cnt+7],
-				buff[cnt+8], buff[cnt+9],
-				buff[cnt+10], buff[cnt+11],
-				buff[cnt+12], buff[cnt+13],
-				buff[cnt+14], buff[cnt+15]);
+			" %08x %08x %08x %08x %08x %08x %08x %08x"
+			" %08x %08x %08x %08x %08x %08x %08x %08x",
+			&buf[cnt],
+			buf[cnt+0], buf[cnt+1], buf[cnt+2], buf[cnt+3],
+			buf[cnt+4], buf[cnt+5], buf[cnt+6], buf[cnt+7],
+			buf[cnt+8], buf[cnt+9], buf[cnt+10], buf[cnt+11],
+			buf[cnt+12], buf[cnt+13], buf[cnt+14], buf[cnt+15]);
 	}
 }
 
@@ -288,7 +280,7 @@ get_sppwk_port(enum port_type iface_type, int iface_no)
 
 /* Dump of core information */
 void
-dump_core_info(const struct core_mng_info *core_info)
+log_core_info(const struct core_mng_info *core_info)
 {
 	char str[SPP_NAME_STR_LEN];
 	const struct core_mng_info *info = NULL;
@@ -300,16 +292,18 @@ dump_core_info(const struct core_mng_info *core_info)
 				info->ref_index, info->upd_index);
 
 		memset(str, 0x00, SPP_NAME_STR_LEN);
-		dump_buff(str, info->core[0].id, sizeof(int)*info->core[0].num);
+		log_hexdumped(str, info->core[0].id,
+				sizeof(int)*info->core[0].num);
 
 		sprintf(str, "core[%d]-1 num=%d", lcore_id, info->core[1].num);
-		dump_buff(str, info->core[1].id, sizeof(int)*info->core[1].num);
+		log_hexdumped(str, info->core[1].id,
+				sizeof(int)*info->core[1].num);
 	}
 }
 
 /* Dump of component information */
 void
-dump_component_info(const struct sppwk_comp_info *comp_info)
+log_component_info(const struct sppwk_comp_info *comp_info)
 {
 	char str[SPP_NAME_STR_LEN];
 	const struct sppwk_comp_info *tmp_ci = NULL;
@@ -326,19 +320,19 @@ dump_component_info(const struct sppwk_comp_info *comp_info)
 
 		sprintf(str, "component[%d] rx=%d", cnt,
 				tmp_ci->nof_rx);
-		dump_buff(str, tmp_ci->rx_ports,
+		log_hexdumped(str, tmp_ci->rx_ports,
 			sizeof(struct sppwk_port_info *)*tmp_ci->nof_rx);
 
 		sprintf(str, "component[%d] tx=%d", cnt,
 				tmp_ci->nof_tx);
-		dump_buff(str, tmp_ci->tx_ports,
+		log_hexdumped(str, tmp_ci->tx_ports,
 			sizeof(struct sppwk_port_info *)*tmp_ci->nof_tx);
 	}
 }
 
 /* Dump of interface information */
 void
-dump_interface_info(const struct iface_info *iface_info)
+log_interface_info(const struct iface_info *iface_info)
 {
 	const struct sppwk_port_info *port = NULL;
 	int cnt = 0;
@@ -389,7 +383,7 @@ dump_interface_info(const struct iface_info *iface_info)
 
 /* Dump of all management information */
 void
-dump_all_mng_info(
+log_all_mng_info(
 		const struct core_mng_info *core,
 		const struct sppwk_comp_info *component,
 		const struct iface_info *interface)
@@ -397,9 +391,9 @@ dump_all_mng_info(
 	if (rte_log_get_global_level() < RTE_LOG_DEBUG)
 		return;
 
-	dump_core_info(core);
-	dump_component_info(component);
-	dump_interface_info(interface);
+	log_core_info(core);
+	log_component_info(component);
+	log_interface_info(interface);
 }
 
 /* Copy management information */
@@ -446,7 +440,7 @@ copy_mng_info(
 void
 backup_mng_info(struct cancel_backup_info *backup)
 {
-	dump_all_mng_info(g_mng_data.p_core_info,
+	log_all_mng_info(g_mng_data.p_core_info,
 			g_mng_data.p_component_info,
 			g_mng_data.p_iface_info);
 	copy_mng_info(backup->core, backup->component, &backup->interface,
@@ -454,7 +448,7 @@ backup_mng_info(struct cancel_backup_info *backup)
 			g_mng_data.p_component_info,
 			g_mng_data.p_iface_info,
 			COPY_MNG_FLG_ALLCOPY);
-	dump_all_mng_info(backup->core, backup->component, &backup->interface);
+	log_all_mng_info(backup->core, backup->component, &backup->interface);
 	memset(g_mng_data.p_change_core, 0x00,
 				sizeof(int)*RTE_MAX_LCORE);
 	memset(g_mng_data.p_change_component, 0x00,
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.h b/src/shared/secondary/spp_worker_th/cmd_utils.h
index 4cecfdd..65a66b8 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.h
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.h
@@ -297,13 +297,14 @@ struct spp_iterate_classifier_table_params {
 };
 
 /**
- * Make a hexdump of an array data in every 4 byte
+ * Hexdump `addr` for logging, used for core_info or component info.
  *
- * @param name Dumped name.
- * @param addr Dumped address.
- * @param size Dumped byte size.
+ * @param name Name of object to be dumped.
+ * @param addr Address of dumped value.
+ * @param size Size of dumped value.
  */
-void dump_buff(const char *name, const void *addr, const size_t size);
+void log_hexdumped(const char *obj_name, const void *obj_addr,
+		const size_t size);
 
 /**
  * Add ring pmd for owned proccess or thread.
@@ -376,17 +377,17 @@ void stop_process(int signal);
 struct sppwk_port_info *
 get_sppwk_port(enum port_type iface_type, int iface_no);
 
-/* Dump of core information */
-void dump_core_info(const struct core_mng_info *core_info);
+/* Output log message for core information */
+void log_core_info(const struct core_mng_info *core_info);
 
-/* Dump of component information */
-void dump_component_info(const struct sppwk_comp_info *component_info);
+/* Output log message for component information */
+void log_component_info(const struct sppwk_comp_info *component_info);
 
-/* Dump of interface information */
-void dump_interface_info(const struct iface_info *iface_info);
+/* Output log message for interface information */
+void log_interface_info(const struct iface_info *iface_info);
 
-/* Dump of all management information */
-void dump_all_mng_info(
+/* Output log message for all management information */
+void log_all_mng_info(
 		const struct core_mng_info *core,
 		const struct sppwk_comp_info *component,
 		const struct iface_info *interface);
-- 
2.17.1


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

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24  2:23 [spp] [PATCH 0/5] Revising logs and comments in shared yasufum.o
2019-06-24  2:23 ` [spp] [PATCH 1/5] shared/sec: revise comments in cmd_utils.h yasufum.o
2019-06-24  2:23 ` yasufum.o [this message]
2019-06-24  2:23 ` [spp] [PATCH 3/5] shared/sec: revise member of struct for interface yasufum.o
2019-06-24  2:23 ` [spp] [PATCH 4/5] shared/sec: rename defines for length of str yasufum.o
2019-06-24  2:23 ` [spp] [PATCH 5/5] shared/sec: add prefix to defines of worker types 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=20190624022325.18695-3-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).