Soft Patch Panel
 help / color / mirror / Atom feed
* [spp] [PATCH] shared: support old desc of vdev tyep
@ 2019-07-30  7:29 yasufum.o
  0 siblings, 0 replies; only message in thread
From: yasufum.o @ 2019-07-30  7:29 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

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

In DPDK, vdev was described with prefix `eth` such as `eth_vhost0`,
but is changed to use `net` instead of `eth`. Because both of
prefixes are supported currently, SPP should also accept both.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/shared/common.c | 46 +++++++++++++++++++++++++--------------------
 src/shared/common.h | 13 ++++++++-----
 2 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/src/shared/common.c b/src/shared/common.c
index 6655f17..aa1486a 100644
--- a/src/shared/common.c
+++ b/src/shared/common.c
@@ -176,47 +176,53 @@ int parse_dev_name(char *dev_name, int *port_type, int *port_id)
 	int dev_name_len = strlen(dev_name);
 	int dev_str_len;
 
-	if (strncmp(dev_name, VDEV_PREFIX_RING,
-			strlen(VDEV_PREFIX_RING)) == 0) {
-		dev_str_len = strlen(VDEV_PREFIX_RING);
+	if (strncmp(dev_name, VDEV_ETH_RING,
+				strlen(VDEV_ETH_RING)) == 0 ||
+			strncmp(dev_name, VDEV_NET_RING,
+				strlen(VDEV_NET_RING)) == 0) {
+		dev_str_len = strlen(VDEV_NET_RING);
 		pid_len = dev_name_len - dev_str_len;
-		strncpy(pid_str, dev_name + strlen(VDEV_PREFIX_RING),
+		strncpy(pid_str, dev_name + strlen(VDEV_NET_RING),
 				pid_len);
 		*port_id = (int)strtol(pid_str, NULL, 10);
 		*port_type = RING;
 
-	} else if (strncmp(dev_name, VDEV_PREFIX_VHOST,
-			strlen(VDEV_PREFIX_VHOST)) == 0) {
-		dev_str_len = strlen(VDEV_PREFIX_VHOST);
+	} else if (strncmp(dev_name, VDEV_ETH_VHOST,
+				strlen(VDEV_ETH_VHOST)) == 0 ||
+			strncmp(dev_name, VDEV_NET_VHOST,
+				strlen(VDEV_NET_VHOST)) == 0) {
+		dev_str_len = strlen(VDEV_NET_VHOST);
 		pid_len = dev_name_len - dev_str_len;
-		strncpy(pid_str, dev_name + strlen(VDEV_PREFIX_VHOST),
+		strncpy(pid_str, dev_name + strlen(VDEV_NET_VHOST),
 				pid_len);
 		*port_id = (int)strtol(pid_str, NULL, 10);
 		*port_type = VHOST;
 
-	} else if (strncmp(dev_name, VDEV_PREFIX_PCAP,
-			strlen(VDEV_PREFIX_PCAP)) == 0) {
-		dev_str_len = strlen(VDEV_PREFIX_PCAP);
+	} else if (strncmp(dev_name, VDEV_PCAP,
+			strlen(VDEV_PCAP)) == 0) {
+		dev_str_len = strlen(VDEV_PCAP);
 		pid_len = dev_name_len - dev_str_len;
-		strncpy(pid_str, dev_name + strlen(VDEV_PREFIX_PCAP),
+		strncpy(pid_str, dev_name + strlen(VDEV_PCAP),
 				pid_len);
 		*port_id = (int)strtol(pid_str, NULL, 10);
 		*port_type = PCAP;
 
-	} else if (strncmp(dev_name, VDEV_PREFIX_TAP,
-			strlen(VDEV_PREFIX_TAP)) == 0) {
-		dev_str_len = strlen(VDEV_PREFIX_TAP);
+	} else if (strncmp(dev_name, VDEV_ETH_TAP,
+				strlen(VDEV_ETH_TAP)) == 0 ||
+			strncmp(dev_name, VDEV_NET_TAP,
+				strlen(VDEV_NET_TAP)) == 0) {
+		dev_str_len = strlen(VDEV_NET_TAP);
 		pid_len = dev_name_len - dev_str_len;
-		strncpy(pid_str, dev_name + strlen(VDEV_PREFIX_TAP),
+		strncpy(pid_str, dev_name + strlen(VDEV_NET_TAP),
 				pid_len);
 		*port_id = (int)strtol(pid_str, NULL, 10);
 		*port_type = TAP;
 
-	} else if (strncmp(dev_name, VDEV_PREFIX_NULL,
-			strlen(VDEV_PREFIX_NULL)) == 0) {
-		dev_str_len = strlen(VDEV_PREFIX_NULL);
+	} else if (strncmp(dev_name, VDEV_NULL,
+			strlen(VDEV_NULL)) == 0) {
+		dev_str_len = strlen(VDEV_NULL);
 		pid_len = dev_name_len - dev_str_len;
-		strncpy(pid_str, dev_name + strlen(VDEV_PREFIX_NULL),
+		strncpy(pid_str, dev_name + strlen(VDEV_NULL),
 				pid_len);
 		*port_id = (int)strtol(pid_str, NULL, 10);
 		*port_type = PCAP;
diff --git a/src/shared/common.h b/src/shared/common.h
index d51d6df..4d0dbe8 100644
--- a/src/shared/common.h
+++ b/src/shared/common.h
@@ -43,11 +43,14 @@
 #define RTE_MP_RX_DESC_DEFAULT 512
 #define RTE_MP_TX_DESC_DEFAULT 512
 
-#define VDEV_PREFIX_RING  "net_ring"
-#define VDEV_PREFIX_VHOST "eth_vhost"
-#define VDEV_PREFIX_PCAP  "net_pcap"
-#define VDEV_PREFIX_TAP   "net_tap"
-#define VDEV_PREFIX_NULL  "eth_null"
+#define VDEV_ETH_RING "eth_ring"
+#define VDEV_NET_RING "net_ring"
+#define VDEV_ETH_VHOST "eth_vhost"
+#define VDEV_NET_VHOST "net_vhost"
+#define VDEV_PCAP "net_pcap"
+#define VDEV_ETH_TAP "eth_tap"
+#define VDEV_NET_TAP "net_tap"
+#define VDEV_NULL "eth_null"
 
 
 /* Command. */
-- 
2.17.1


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

only message in thread, other threads:[~2019-07-30  7:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-30  7:29 [spp] [PATCH] shared: support old desc of vdev tyep yasufum.o

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