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 6/6] app/testpmd: fix asynchronic port removal
Date: Thu,  3 May 2018 10:31:48 +0000	[thread overview]
Message-ID: <1525343508-29487-7-git-send-email-matan@mellanox.com> (raw)
In-Reply-To: <1525343508-29487-1-git-send-email-matan@mellanox.com>

When a removable device is plugged-out, a RMV interrupt is invoked and
the application can catch the event in order to stop the device
management.

The Testpmd wrong behavior in this case is to detach the removed device
using the EAL detach API.

The EAL API does not invalidate the ethdev port and the port keeps
appearing as valid from the ethdev point of view.

Thus, the next operations for the ethtev port X may trigger an invalid
rte_device access. For example, calling "show port info X" may cause
segfault.

Moreover, the removed port is not removed from the Testpmd data-path
structures. Therefore, the invalid device may still be used by the
Testpmd data-path.

Call the Testpmd detach_port() function which uses the ethdev detach
API, and prepare the Testpmd forward ports database for a new
forwarding session without the detached port.

Fixes: 284c908cc588 ("app/testpmd: request device removal interrupt")
Cc: stable@dpdk.org

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 app/test-pmd/testpmd.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 33a9e96..2edf644 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2096,21 +2096,23 @@ struct pmd_test_command {
 static void
 rmv_event_callback(void *arg)
 {
+	int need_to_start = 0;
 	int org_no_link_check = no_link_check;
-	struct rte_eth_dev *dev;
 	portid_t port_id = (intptr_t)arg;
 
 	RTE_ETH_VALID_PORTID_OR_RET(port_id);
-	dev = &rte_eth_devices[port_id];
 
+	if (!test_done && port_is_forwarding(port_id)) {
+		need_to_start = 1;
+		stop_packet_forwarding();
+	}
 	no_link_check = 1;
 	stop_port(port_id);
 	no_link_check = org_no_link_check;
 	close_port(port_id);
-	printf("removing device %s\n", dev->device->name);
-	if (rte_eal_dev_detach(dev->device))
-		TESTPMD_LOG(ERR, "Failed to detach device %s\n",
-			dev->device->name);
+	detach_port(port_id);
+	if (need_to_start)
+		start_packet_forwarding(0);
 }
 
 /* This function is used by the interrupt thread */
-- 
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 port hotplug 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 ` [dpdk-dev] [PATCH 4/6] app/testpmd: fix synchronic port hotplug Matan Azrad
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 ` Matan Azrad [this message]
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-7-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).