DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jeff Guo <jia.guo@intel.com>
To: bernard.iremonger@intel.com, wenzhuo.lu@intel.com,
	shahafs@mellanox.com, thomas@monjalon.net, matan@mellanox.com
Cc: ferruh.yigit@intel.com, konstantin.ananyev@intel.com,
	dev@dpdk.org, jia.guo@intel.com, stephen@networkplumber.org,
	gaetan.rivet@6wind.com, qi.z.zhang@intel.com,
	arybchenko@solarflare.com, bruce.richardson@intel.com,
	shaopeng.he@intel.com, anatoly.burakov@intel.com
Subject: [dpdk-dev] [PATCH 3/3] testpmd: remove device detach into eal
Date: Fri, 14 Dec 2018 15:45:40 +0800	[thread overview]
Message-ID: <1544773540-89825-4-git-send-email-jia.guo@intel.com> (raw)
In-Reply-To: <1544773540-89825-1-git-send-email-jia.guo@intel.com>

Assume that eal detect the removal event and handle hot-unplug, so device
detach should be located in eal framework, the sequence should be eal
detect and handle hot-unplug event at first, then eal notify app to finish
pre-detach prepare, such as stop forwarding and clean ports, finally device
be detached safely in eal. This patch aim to remove the invoke of device
detach from app callback to eal device event handler.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 app/test-pmd/testpmd.c                |  1 -
 drivers/bus/pci/pci_common.c          |  7 +++++++
 lib/librte_eal/linuxapp/eal/eal_dev.c | 16 +++++++++++++++-
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index bd44b21..f15035c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2538,7 +2538,6 @@ rmv_port_callback(void *arg)
 	stop_port(port_id);
 	no_link_check = org_no_link_check;
 	close_port(port_id);
-	detach_port_device(port_id);
 	if (need_to_start)
 		start_packet_forwarding(0);
 }
diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index 6276e5d..565f8cf 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -465,6 +465,13 @@ pci_hot_unplug_handler(struct rte_device *dev)
 		 */
 		rte_dev_event_callback_process(dev->name,
 					       RTE_DEV_EVENT_REMOVE);
+		ret = rte_dev_remove(dev);
+		if (ret) {
+			RTE_LOG(ERR, EAL, "Failed to remove device %s\n",
+				dev->name);
+			return -1;
+		}
+		RTE_LOG(INFO, EAL, "Success to remove device %s\n", dev->name);
 		break;
 #endif
 	case RTE_KDRV_IGB_UIO:
diff --git a/lib/librte_eal/linuxapp/eal/eal_dev.c b/lib/librte_eal/linuxapp/eal/eal_dev.c
index 2830c86..f4a75f8 100644
--- a/lib/librte_eal/linuxapp/eal/eal_dev.c
+++ b/lib/librte_eal/linuxapp/eal/eal_dev.c
@@ -275,8 +275,22 @@ dev_uev_handler(__rte_unused void *param)
 					"for device (%s)\n", dev->name);
 			}
 			rte_spinlock_unlock(&failure_handle_lock);
+
+			rte_dev_event_callback_process(uevent.devname,
+						       uevent.type);
+			ret = rte_dev_remove(dev);
+			if (ret) {
+				RTE_LOG(ERR, EAL,
+					"Failed to remove device %s\n",
+					dev->name);
+				return;
+			}
+			RTE_LOG(INFO, EAL, "Success to remove device %s\n",
+				dev->name);
+		} else {
+			rte_dev_event_callback_process(uevent.devname,
+						       uevent.type);
 		}
-		rte_dev_event_callback_process(uevent.devname, uevent.type);
 	}
 
 	return;
-- 
2.7.4

  parent reply	other threads:[~2018-12-14  7:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-14  7:45 [dpdk-dev] [PATCH 0/3] use a common eal device event for hot-unplug Jeff Guo
2018-12-14  7:45 ` [dpdk-dev] [PATCH 1/3] eal: add --dev-hotplug option Jeff Guo
2018-12-17 10:15   ` David Marchand
2018-12-29  4:06     ` Jeff Guo
2019-01-02 14:46       ` David Marchand
2018-12-14  7:45 ` [dpdk-dev] [PATCH 2/3] ethdev: remove ethdev rmv interrupt Jeff Guo
2018-12-14  7:45 ` Jeff Guo [this message]
2019-04-08 14:10 ` [dpdk-dev] [PATCH 0/3] use a common eal device event for hot-unplug Iremonger, Bernard
2019-04-08 14:10   ` Iremonger, Bernard
2023-06-09 17:18 ` Stephen Hemminger

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=1544773540-89825-4-git-send-email-jia.guo@intel.com \
    --to=jia.guo@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=arybchenko@solarflare.com \
    --cc=bernard.iremonger@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=gaetan.rivet@6wind.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=matan@mellanox.com \
    --cc=qi.z.zhang@intel.com \
    --cc=shahafs@mellanox.com \
    --cc=shaopeng.he@intel.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    --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).