From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Cc: Elad Persiko <eladpe@mellanox.com>
Subject: [dpdk-dev] [PATCH v2 5/5] app/testpmd: request device removal interrupt
Date: Tue, 18 Apr 2017 14:17:42 +0200 [thread overview]
Message-ID: <f6d3c60a3d01970030e86d630168c5a0e018b772.1492517222.git.gaetan.rivet@6wind.com> (raw)
In-Reply-To: <cover.1492517222.git.gaetan.rivet@6wind.com>
In-Reply-To: <cover.1492517222.git.gaetan.rivet@6wind.com>
Enable device removal event for PMD supporting it.
Add the --no-rmv-interrupt parameter to explicitly disable it.
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
Signed-off-by: Elad Persiko <eladpe@mellanox.com>
---
app/test-pmd/parameters.c | 4 ++++
app/test-pmd/testpmd.c | 43 +++++++++++++++++++++++++++++++++++++++++++
app/test-pmd/testpmd.h | 1 +
3 files changed, 48 insertions(+)
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index c79c349..7efd718 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -201,6 +201,7 @@ usage(char* progname)
printf(" --disable-link-check: disable check on link status when "
"starting/stopping ports.\n");
printf(" --no-lsc-interrupt: disable link status change interrupt.\n");
+ printf(" --no-rmv-interrupt: disable device removal interrupt.");
}
#ifdef RTE_LIBRTE_CMDLINE
@@ -570,6 +571,7 @@ launch_args_parse(int argc, char** argv)
{ "txpkts", 1, 0, 0 },
{ "disable-link-check", 0, 0, 0 },
{ "no-lsc-interrupt", 0, 0, 0 },
+ { "no-rmv-interrupt", 0, 0, 0 },
{ 0, 0, 0, 0 },
};
@@ -1002,6 +1004,8 @@ launch_args_parse(int argc, char** argv)
no_link_check = 1;
if (!strcmp(lgopts[opt_idx].name, "no-lsc-interrupt"))
lsc_interrupt = 0;
+ if (!strcmp(lgopts[opt_idx].name, "no-rmv-interrupt"))
+ rmv_interrupt = 0;
break;
case 'h':
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 5f94393..a6f59ba 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -59,6 +59,7 @@
#include <rte_memzone.h>
#include <rte_launch.h>
#include <rte_eal.h>
+#include <rte_alarm.h>
#include <rte_per_lcore.h>
#include <rte_lcore.h>
#include <rte_atomic.h>
@@ -276,6 +277,11 @@ uint8_t no_link_check = 0; /* check by default */
uint8_t lsc_interrupt = 1; /* enabled by default */
/*
+ * Enable device removal notification.
+ */
+uint8_t rmv_interrupt = 1; /* enabled by default */
+
+/*
* NIC bypass mode configuration options.
*/
#ifdef RTE_NIC_BYPASS
@@ -1757,6 +1763,29 @@ check_all_ports_link_status(uint32_t port_mask)
}
}
+static void
+rmv_event_callback(void *arg)
+{
+ struct rte_eth_dev *dev;
+ struct rte_devargs *da;
+ char name[32] = "";
+ uint8_t port_id = (intptr_t)arg;
+
+ RTE_ETH_VALID_PORTID_OR_RET(port_id);
+ dev = &rte_eth_devices[port_id];
+ da = dev->device->devargs;
+
+ stop_port(port_id);
+ close_port(port_id);
+ if (da->type == RTE_DEVTYPE_VIRTUAL)
+ snprintf(name, sizeof(name), "%s", da->virt.drv_name);
+ else if (da->type == RTE_DEVTYPE_WHITELISTED_PCI)
+ rte_eal_pci_device_name(&da->pci.addr, name, sizeof(name));
+ printf("removing device %s\n", name);
+ rte_eal_dev_detach(name);
+ dev->state = RTE_ETH_DEV_UNUSED;
+}
+
/* This function is used by the interrupt thread */
static void
eth_event_callback(uint8_t port_id, enum rte_eth_event_type type, void *param)
@@ -1783,6 +1812,16 @@ eth_event_callback(uint8_t port_id, enum rte_eth_event_type type, void *param)
event_desc[type]);
fflush(stdout);
}
+
+ switch (type) {
+ case RTE_ETH_EVENT_INTR_RMV:
+ if (rte_eal_alarm_set(100000,
+ rmv_event_callback, (void *)(intptr_t)port_id))
+ fprintf(stderr, "Could not set up deferred device removal\n");
+ break;
+ default:
+ break;
+ }
}
static int
@@ -1942,6 +1981,10 @@ init_port_config(void)
(rte_eth_devices[pid].data->dev_flags &
RTE_ETH_DEV_INTR_LSC))
port->dev_conf.intr_conf.lsc = 1;
+ if (rmv_interrupt &&
+ (rte_eth_devices[pid].data->dev_flags &
+ RTE_ETH_DEV_INTR_RMV))
+ port->dev_conf.intr_conf.rmv = 1;
}
}
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 62f89e6..a9ff07e 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -306,6 +306,7 @@ extern uint8_t mp_anon; /**< set by "--mp-anon" parameter */
extern uint8_t no_link_check; /**<set by "--disable-link-check" parameter */
extern volatile int test_done; /* stop packet forwarding when set to 1. */
extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
+extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */
#ifdef RTE_NIC_BYPASS
extern uint32_t bypass_timeout; /**< Store the NIC bypass watchdog timeout */
--
2.1.4
next prev parent reply other threads:[~2017-04-18 12:18 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-03 15:40 [dpdk-dev] [PATCH 0/5] add device removal event Gaetan Rivet
2017-03-03 15:40 ` [dpdk-dev] [PATCH 1/5] ethdev: introduce " Gaetan Rivet
2017-03-03 15:40 ` [dpdk-dev] [PATCH 2/5] net/mlx4: device removal event support Gaetan Rivet
2017-03-03 15:40 ` [dpdk-dev] [PATCH 3/5] app/testpmd: generic event handler Gaetan Rivet
2017-03-03 15:40 ` [dpdk-dev] [PATCH 4/5] app/testpmd: request link status interrupt Gaetan Rivet
2017-03-03 15:40 ` [dpdk-dev] [PATCH 5/5] app/testpmd: request device removal interrupt Gaetan Rivet
2017-03-23 10:24 ` [dpdk-dev] [PATCH 0/5] add device removal event Gaetan Rivet
2017-04-18 12:17 ` [dpdk-dev] [PATCH v2 " Gaetan Rivet
2017-04-18 12:17 ` [dpdk-dev] [PATCH v2 1/5] ethdev: introduce " Gaetan Rivet
2017-04-21 14:59 ` Ferruh Yigit
2017-04-25 9:05 ` Gaëtan Rivet
2017-05-02 7:35 ` Jan Blunck
2017-05-02 9:18 ` Thomas Monjalon
2017-05-02 12:20 ` Gaëtan Rivet
2017-04-18 12:17 ` [dpdk-dev] [PATCH v2 2/5] net/mlx4: device removal event support Gaetan Rivet
2017-04-18 12:17 ` [dpdk-dev] [PATCH v2 3/5] app/testpmd: generic event handler Gaetan Rivet
2017-04-18 12:17 ` [dpdk-dev] [PATCH v2 4/5] app/testpmd: request link status interrupt Gaetan Rivet
2017-04-21 14:55 ` Ferruh Yigit
2017-04-25 9:07 ` Gaëtan Rivet
2017-04-25 9:40 ` Ferruh Yigit
2017-04-25 10:10 ` [dpdk-dev] [PATCH 1/3] doc: fix missing backquotes Gaetan Rivet
2017-04-25 10:10 ` [dpdk-dev] [PATCH 2/3] doc: add device removal event to release note Gaetan Rivet
2017-04-25 10:10 ` [dpdk-dev] [PATCH 3/3] doc: add lsc and rmv interrupt to testpmd user guide Gaetan Rivet
2017-04-25 10:18 ` [dpdk-dev] [PATCH v2 1/4] doc: fix missing backquotes Gaetan Rivet
2017-04-25 10:18 ` [dpdk-dev] [PATCH v2 2/4] doc: add device removal event to release note Gaetan Rivet
2017-04-26 14:59 ` Mcnamara, John
2017-04-25 10:18 ` [dpdk-dev] [PATCH v2 3/4] doc: add LSC and RMV interrupt to testpmd user guide Gaetan Rivet
2017-04-26 15:00 ` Mcnamara, John
2017-04-25 10:18 ` [dpdk-dev] [PATCH v2 4/4] devtools: add git log checks for rmv Gaetan Rivet
2017-04-26 15:01 ` Mcnamara, John
2017-04-30 22:28 ` Thomas Monjalon
2017-04-26 14:58 ` [dpdk-dev] [PATCH v2 1/4] doc: fix missing backquotes Mcnamara, John
2017-04-30 22:30 ` Thomas Monjalon
2017-04-18 12:17 ` Gaetan Rivet [this message]
2017-04-20 22:45 ` [dpdk-dev] [PATCH v2 0/5] add device removal event 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=f6d3c60a3d01970030e86d630168c5a0e018b772.1492517222.git.gaetan.rivet@6wind.com \
--to=gaetan.rivet@6wind.com \
--cc=dev@dpdk.org \
--cc=eladpe@mellanox.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).