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] shared/sec: rename func spp_format_port_string
Date: Thu, 27 Jun 2019 13:41:05 +0900	[thread overview]
Message-ID: <20190627044105.15058-1-yasufum.o@gmail.com> (raw)

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

Rename spp_format_port_string() used for making string of resource UID
such as "ring:0" to sppwk_port_uid().

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 .../secondary/spp_worker_th/cmd_parser.c      | 18 +++++++++---------
 .../spp_worker_th/cmd_res_formatter.c         |  8 ++++----
 .../secondary/spp_worker_th/cmd_utils.c       | 19 ++++++++-----------
 .../secondary/spp_worker_th/cmd_utils.h       | 19 +++++++++----------
 src/vf/classifier_mac.c                       |  5 ++---
 src/vf/vf_cmd_runner.c                        |  2 +-
 6 files changed, 33 insertions(+), 38 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index 32903c3..7933ed2 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -152,18 +152,18 @@ parse_resource_uid(const char *res_uid,
 	 * TODO(yasufum) consider this checking of zero value is recommended
 	 * way, or should be changed.
 	 */
-	if (strncmp(res_uid, SPP_IFTYPE_NIC_STR ":",
-			strlen(SPP_IFTYPE_NIC_STR)+1) == 0) {
+	if (strncmp(res_uid, SPPWK_PHY_STR ":",
+			strlen(SPPWK_PHY_STR)+1) == 0) {
 		ptype = PHY;
-		iface_no_str = &res_uid[strlen(SPP_IFTYPE_NIC_STR)+1];
-	} else if (strncmp(res_uid, SPP_IFTYPE_VHOST_STR ":",
-			strlen(SPP_IFTYPE_VHOST_STR)+1) == 0) {
+		iface_no_str = &res_uid[strlen(SPPWK_PHY_STR)+1];
+	} else if (strncmp(res_uid, SPPWK_VHOST_STR ":",
+			strlen(SPPWK_VHOST_STR)+1) == 0) {
 		ptype = VHOST;
-		iface_no_str = &res_uid[strlen(SPP_IFTYPE_VHOST_STR)+1];
-	} else if (strncmp(res_uid, SPP_IFTYPE_RING_STR ":",
-			strlen(SPP_IFTYPE_RING_STR)+1) == 0) {
+		iface_no_str = &res_uid[strlen(SPPWK_VHOST_STR)+1];
+	} else if (strncmp(res_uid, SPPWK_RING_STR ":",
+			strlen(SPPWK_RING_STR)+1) == 0) {
 		ptype = RING;
-		iface_no_str = &res_uid[strlen(SPP_IFTYPE_RING_STR)+1];
+		iface_no_str = &res_uid[strlen(SPPWK_RING_STR)+1];
 	} else {
 		RTE_LOG(ERR, WK_CMD_PARSER, "Unexpected port type in '%s'.\n",
 				res_uid);
diff --git a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
index 820df8f..c18f8e5 100644
--- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
+++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
@@ -226,7 +226,7 @@ append_port_block(char **output, const struct sppwk_port_idx *port,
 		return SPP_RET_NG;
 	}
 
-	spp_format_port_string(port_str, port->iface_type, port->iface_no);
+	sppwk_port_uid(port_str, port->iface_type, port->iface_no);
 	ret = append_json_str_value(&tmp_buff, "port", port_str);
 	if (unlikely(ret < SPP_RET_OK))
 		return SPP_RET_NG;
@@ -534,13 +534,13 @@ add_interface(const char *name, char **output,
 		return SPP_RET_NG;
 	}
 
-	if (strcmp(name, SPP_IFTYPE_NIC_STR) == 0)
+	if (strcmp(name, SPPWK_PHY_STR) == 0)
 		ret = append_interface_array(&tmp_buff, PHY);
 
-	else if (strcmp(name, SPP_IFTYPE_VHOST_STR) == 0)
+	else if (strcmp(name, SPPWK_VHOST_STR) == 0)
 		ret = append_interface_array(&tmp_buff, VHOST);
 
-	else if (strcmp(name, SPP_IFTYPE_RING_STR) == 0)
+	else if (strcmp(name, SPPWK_RING_STR) == 0)
 		ret = append_interface_array(&tmp_buff, RING);
 
 	if (unlikely(ret < SPP_RET_OK)) {
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.c b/src/shared/secondary/spp_worker_th/cmd_utils.c
index 894f559..a4d8031 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.c
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.c
@@ -733,29 +733,26 @@ update_lcore_info(void)
 	}
 }
 
-/**
- * Generate a formatted string of combination from interface type and
- * number and assign to given 'port'
- */
-int spp_format_port_string(char *port, enum port_type iface_type, int iface_no)
+/* Return port uid such as `phy:0`, `ring:1` or so. */
+int sppwk_port_uid(char *port_uid, enum port_type p_type, int iface_no)
 {
-	const char *iface_type_str;
+	const char *p_type_str;
 
-	switch (iface_type) {
+	switch (p_type) {
 	case PHY:
-		iface_type_str = SPP_IFTYPE_NIC_STR;
+		p_type_str = SPPWK_PHY_STR;
 		break;
 	case RING:
-		iface_type_str = SPP_IFTYPE_RING_STR;
+		p_type_str = SPPWK_RING_STR;
 		break;
 	case VHOST:
-		iface_type_str = SPP_IFTYPE_VHOST_STR;
+		p_type_str = SPPWK_VHOST_STR;
 		break;
 	default:
 		return SPP_RET_NG;
 	}
 
-	sprintf(port, "%s:%d", iface_type_str, iface_no);
+	sprintf(port_uid, "%s:%d", p_type_str, iface_no);
 
 	return SPP_RET_OK;
 }
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.h b/src/shared/secondary/spp_worker_th/cmd_utils.h
index 7e5cda3..69e0a69 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.h
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.h
@@ -27,9 +27,9 @@
 #define SPPWK_TYPE_NONE_STR "unuse"
 
 /** Identifier string for each interface */
-#define SPP_IFTYPE_NIC_STR   "phy"
-#define SPP_IFTYPE_VHOST_STR "vhost"
-#define SPP_IFTYPE_RING_STR  "ring"
+#define SPPWK_PHY_STR "phy"
+#define SPPWK_VHOST_STR "vhost"
+#define SPPWK_RING_STR "ring"
 
 /** Waiting time for checking update (not used for spp_pcap). */
 #define SPP_CHANGE_UPDATE_INTERVAL 10  /* micro sec */
@@ -484,16 +484,15 @@ int update_port_info(void);
 void update_lcore_info(void);
 
 /**
- * Port type to string.
+ * Return port uid such as `phy:0`, `ring:1` or so.
  *
- * @param port String of port type to be converted.
- * @param iface_type Interface type.
- * @param iface_no Interface number.
- * @retval SPP_RET_OK If succeeded.
- * @retval SPP_RET_NG If failed.
+ * @param[in,out] port_uid String of port type to be converted.
+ * @param[in] iface_type Interface type such as PHY or so.
+ * @param[in] iface_no Interface number.
+ * @return SPP_RET_OK If succeeded, or SPP_RET_NG if failed.
  */
 int
-spp_format_port_string(char *port, enum port_type iface_type, int iface_no);
+sppwk_port_uid(char *port_uid, enum port_type iface_type, int iface_no);
 
 /**
  * Change string of MAC address to int64.
diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index 9c4bedf..a1d6ba4 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -211,7 +211,7 @@ log_classification(
 	if (clsd_idx < 0)
 		snprintf(iface_str, sizeof(iface_str), "%ld", clsd_idx);
 	else
-		spp_format_port_string(iface_str,
+		sppwk_port_uid(iface_str,
 				clsd_data[clsd_idx].iface_type,
 				clsd_data[clsd_idx].iface_no_global);
 
@@ -248,8 +248,7 @@ log_entry(
 	if (clsd_idx < 0)
 		snprintf(iface_str, sizeof(iface_str), "%ld", clsd_idx);
 	else
-		spp_format_port_string(
-				iface_str,
+		sppwk_port_uid(iface_str,
 				clsd_data[clsd_idx].iface_type,
 				clsd_data[clsd_idx].iface_no_global);
 
diff --git a/src/vf/vf_cmd_runner.c b/src/vf/vf_cmd_runner.c
index bab04ed..e9388e0 100644
--- a/src/vf/vf_cmd_runner.c
+++ b/src/vf/vf_cmd_runner.c
@@ -572,7 +572,7 @@ append_classifier_element_value(
 		return ret;
 	}
 
-	spp_format_port_string(port_str, port->iface_type, port->iface_no);
+	sppwk_port_uid(port_str, port->iface_type, port->iface_no);
 
 	ret = append_json_str_value(&tmp_buff, "type",
 			CLS_TYPE_A_LIST[cls_type]);
-- 
2.17.1


                 reply	other threads:[~2019-06-27  4:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20190627044105.15058-1-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).