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] spp_nfv: parse port type and ID while init ports
Date: Tue, 16 Jul 2019 21:33:48 +0900	[thread overview]
Message-ID: <20190716123348.41041-1-yasufum.o@gmail.com> (raw)

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

Spp_nfv initialize shared ports managed by spp_primary as PHY type.
However, it might be other types if spp_primary is launched with
`--vdev` option, and it should be initialized with correct port type
and ID.

This update is to fix the issue by using parse_dev_name() which is added
in the previous patch.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/nfv/commands.h   |  2 +-
 src/nfv/main.c       | 24 +++++++++++++++++++++---
 src/nfv/nfv_status.c | 16 ++++++++++++++++
 3 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/src/nfv/commands.h b/src/nfv/commands.h
index 7bdbdff..06159ad 100644
--- a/src/nfv/commands.h
+++ b/src/nfv/commands.h
@@ -151,7 +151,7 @@ static int
 parse_command(char *str)
 {
 	uint16_t dev_id;
-	char dev_name[RTE_DEV_NAME_MAX_LEN];
+	char dev_name[RTE_DEV_NAME_MAX_LEN] = { 0 };
 
 	char *token_list[MAX_PARAMETER] = {NULL};
 	int cli_id;
diff --git a/src/nfv/main.c b/src/nfv/main.c
index 9117d9b..eb25d13 100644
--- a/src/nfv/main.c
+++ b/src/nfv/main.c
@@ -194,7 +194,10 @@ main(int argc, char *argv[])
 	unsigned int i;
 	int flg_exit;  // used as res of parse_command() to exit if -1
 	int ret;
-	char log_msg[1024] = {'\0'};  /* temporary log message */
+	char dev_name[RTE_DEV_NAME_MAX_LEN] = { 0 };
+	int port_type;
+	int nof_phy_port = 0;
+	char log_msg[1024] = { 0 };  /* temporary log message */
 
 	ret = rte_eal_init(argc, argv);
 	if (ret < 0)
@@ -246,11 +249,26 @@ main(int argc, char *argv[])
 		if (!rte_eth_dev_is_valid_port(i))
 			continue;
 
+		int port_id;
+		rte_eth_dev_get_name_by_port(i, dev_name);
+		ret = parse_dev_name(dev_name, &port_type, &port_id);
+		if (ret < 0)
+			RTE_LOG(ERR, SPP_NFV, "Failed to parse dev_name.");
+		if (port_type == PHY) {
+			port_id = nof_phy_port;
+			nof_phy_port++;
+		}
+
 		/* Update ports_fwd_array with phy port. */
 		ports_fwd_array[i].in_port_id = i;
-		port_map[i].port_type = PHY;
-		port_map[i].id = i;
+		port_map[i].port_type = port_type;
+		port_map[i].id = port_id;
 		port_map[i].stats = &ports->port_stats[i];
+
+		/* TODO(yasufum) convert from int of port_type to char */
+		RTE_LOG(DEBUG, SPP_NFV, "Add port, type: %d, id: %d\n",
+				port_type, port_id);
+
 	}
 
 	/* Inspect lcores in use. */
diff --git a/src/nfv/nfv_status.c b/src/nfv/nfv_status.c
index c40d0b4..a092fac 100644
--- a/src/nfv/nfv_status.c
+++ b/src/nfv/nfv_status.c
@@ -111,6 +111,10 @@ append_port_info_json(char *str,
 			sprintf(str + strlen(str), "\"nullpmd:%u\",",
 					port_map[i].id);
 			break;
+		case TAP:
+			sprintf(str + strlen(str), "\"tap:%u\",",
+					port_map[i].id);
+			break;
 		case UNDEF:
 			/* TODO(yasufum) Need to remove print for undefined ? */
 			sprintf(str + strlen(str), "\"udf\",");
@@ -191,6 +195,12 @@ append_patch_info_json(char *str,
 					"\"nullpmd:%u\",",
 					port_map[i].id);
 			break;
+		case TAP:
+			RTE_LOG(INFO, SHARED, "Type: TAP\n");
+			sprintf(patch_str + strlen(patch_str),
+					"\"tap:%u\",",
+					port_map[i].id);
+			break;
 		case UNDEF:
 			RTE_LOG(INFO, SHARED, "Type: UDF\n");
 			/* TODO(yasufum) Need to remove print for undefined ? */
@@ -241,6 +251,12 @@ append_patch_info_json(char *str,
 						"\"nullpmd:%u\"",
 						port_map[j].id);
 				break;
+			case TAP:
+				RTE_LOG(INFO, SHARED, "Type: TAP\n");
+				sprintf(patch_str + strlen(patch_str),
+						"\"tap:%u\"",
+						port_map[j].id);
+				break;
 			case UNDEF:
 				RTE_LOG(INFO, SHARED, "Type: UDF\n");
 				/*
-- 
2.17.1


                 reply	other threads:[~2019-07-16 12:33 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=20190716123348.41041-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).