DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Wenzhuo Lu <wenzhuo.lu@intel.com>, Jingjing Wu <jingjing.wu@intel.com>
Cc: dev@dpdk.org, stable@dpdk.org
Subject: [dpdk-dev] [PATCH 4/6] app/testpmd: fix synchronic port hotplug
Date: Thu,  3 May 2018 10:31:46 +0000	[thread overview]
Message-ID: <1525343508-29487-5-git-send-email-matan@mellanox.com> (raw)
In-Reply-To: <1525343508-29487-1-git-send-email-matan@mellanox.com>

When the user uses the synchronic hot-plug commands, attach\detach, in
order to insert\remove a port from the system, the forward ports list
update is missed in the current implementation.

Thus, an invalid port may be used for data-path in case of detach
because the detached port was not removed from the forward port list.

In addition, a new port is not used for data-path in case of attach, as the
default behavior of Testpmd, because the attached port was not inserted
to the forward port list.

Update the forward port list in the above cases to allow the correct
port usage for data-path in the next packet forwarding start.

Fixes: edab33b1c01d ("app/testpmd: support port hotplug")
Cc: stable@dpdk.org

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 app/test-pmd/testpmd.c | 29 +++++++++++++++++++++++++++++
 app/test-pmd/testpmd.h |  1 +
 2 files changed, 30 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 1d3ede1..35f97f0 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1215,6 +1215,31 @@ static void eth_dev_event_callback(char *device_name,
 }
 
 /*
+ * Update the forward ports list.
+ */
+void
+update_fwd_ports(portid_t new_pid)
+{
+	unsigned int i;
+	unsigned int new_nb_fwd_ports = 0;
+	int move = 0;
+
+	for (i = 0; i < nb_fwd_ports; ++i) {
+		if (port_id_is_invalid(fwd_ports_ids[i], DISABLED_WARN))
+			move = 1;
+		else if (move)
+			fwd_ports_ids[new_nb_fwd_ports++] = fwd_ports_ids[i];
+		else
+			new_nb_fwd_ports++;
+	}
+	if (new_pid < RTE_MAX_ETHPORTS)
+		fwd_ports_ids[new_nb_fwd_ports++] = new_pid;
+
+	nb_fwd_ports = new_nb_fwd_ports;
+	nb_cfg_ports = new_nb_fwd_ports;
+}
+
+/*
  * Launch packet forwarding configuration.
  */
 void
@@ -1934,6 +1959,8 @@ static void eth_dev_event_callback(char *device_name,
 
 	ports[pi].port_status = RTE_PORT_STOPPED;
 
+	update_fwd_ports(pi);
+
 	printf("Port %d is attached. Now total ports is %d\n", pi, nb_ports);
 	printf("Done\n");
 }
@@ -1960,6 +1987,8 @@ static void eth_dev_event_callback(char *device_name,
 
 	nb_ports = rte_eth_dev_count_avail();
 
+	update_fwd_ports(RTE_MAX_ETHPORTS);
+
 	printf("Port '%s' is detached. Now total ports is %d\n",
 			name, nb_ports);
 	printf("Done\n");
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 8dfd574..ee781d6 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -596,6 +596,7 @@ unsigned int parse_item_list(char* str, const char* item_name,
 void set_def_fwd_config(void);
 void reconfig(portid_t new_port_id, unsigned socket_id);
 int init_fwd_streams(void);
+void update_fwd_ports(portid_t new_pid);
 
 void set_fwd_eth_peer(portid_t port_id, char *peer_addr);
 
-- 
1.9.5

  parent reply	other threads:[~2018-05-03 10:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03 10:31 [dpdk-dev] [PATCH 0/6] Testpmd: fix " Matan Azrad
2018-05-03 10:31 ` [dpdk-dev] [PATCH 1/6] app/testpmd: fix valid ports prints Matan Azrad
2018-05-03 10:31 ` [dpdk-dev] [PATCH 2/6] app/testpmd: fix forward ports update Matan Azrad
2018-05-03 10:31 ` [dpdk-dev] [PATCH 3/6] app/testpmd: fix forward ports Rx flush Matan Azrad
2018-05-03 10:31 ` Matan Azrad [this message]
2018-05-03 10:31 ` [dpdk-dev] [PATCH 5/6] app/testpmd: fix removed device link status asking Matan Azrad
2018-05-03 10:31 ` [dpdk-dev] [PATCH 6/6] app/testpmd: fix asynchronic port removal Matan Azrad
2018-05-14  2:22 ` [dpdk-dev] [PATCH 0/6] Testpmd: fix port hotplug Thomas Monjalon

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=1525343508-29487-5-git-send-email-matan@mellanox.com \
    --to=matan@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=stable@dpdk.org \
    --cc=wenzhuo.lu@intel.com \
    /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).