Soft Patch Panel
 help / color / Atom feed
* [spp] [PATCH] shared/sec: rename func spp_format_port_string
@ 2019-06-27  4:41 yasufum.o
  0 siblings, 0 replies; only message in thread
From: yasufum.o @ 2019-06-27  4:41 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-27  4:41 [spp] [PATCH] shared/sec: rename func spp_format_port_string yasufum.o

Soft Patch Panel

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/spp/0 spp/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 spp spp/ http://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


AGPL code for this site: git clone https://public-inbox.org/ public-inbox