From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by dpdk.org (Postfix) with ESMTP id E61ADF8C0 for ; Fri, 3 Mar 2017 16:40:38 +0100 (CET) Received: by mail-wm0-f41.google.com with SMTP id n11so18289458wma.1 for ; Fri, 03 Mar 2017 07:40:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qNduFlWb91kNHqJt1Iu9e6JrryyrhzIbaCHv9q8nAWQ=; b=KxSE24qdt/zBHtZ5VyqEGKbBCBGF54is3d0WTv+c88u5u/B4XcDFa09qXuzMPrWlu5 IswQICgMnlmnj1WH9Tf+84/v0zBLWv8ure6v6yWem8ELIxM8T3A2oI/U/UjBFF0GUsnv nnPd+M2kTr4WZ+0gj4ccVGuzjLgc78uGIiJxNz43+MutuT1hvUfE6Gf40ktO4wp8o3L8 DsLIHBy9wMrFKuIQjcs0N1ciIMP4W1jiJXUqB1vr4IeZAdEnck2Itiue1LoORr7bsmaI 4otLJJRSS8HSzFlXENI3OO2rzR6V2FW2iW9sVVp/hIz9j+mnbfkrMgOUdKRLo+/oQb+r wfsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qNduFlWb91kNHqJt1Iu9e6JrryyrhzIbaCHv9q8nAWQ=; b=avfxBdsGwdSa/zmgSnl67yQzqKzzZd50teoXzOMY+6smr6yrvPg3hHf5niD7upQr3D VdY9H88LMTOakxmoFDZV1LYzjzuMsuXqaOh07pMLWj0QEADJ6pHmbNoGMW0GJhiXG+gN ERjLHdbB30hNFZP6iu44RwQ1m0iRCj5/5h6H7bh2QEgd9oQ0gRFJwO02Lubrf+WSHwuO OXjUPisM9L11NxK477HFTJPl3TbjHFl9HHLnW7xWYQQ3fO9ofdyqcfmcAq/Y8gILH1PL Zf6eCaO0UjVa+f2zwTML6p4x9MfDRb6ZsAt8D+6bDUpjTOkyktjijXzv608LvxyyBUFM EMFw== X-Gm-Message-State: AMke39mHou7Fi/N4rhYWq95nYR9Hpqhhci8WSCzVu3koUWGuFpHtDqINu9b6ItN2AwcXERnD X-Received: by 10.28.104.6 with SMTP id d6mr3549738wmc.79.1488555638475; Fri, 03 Mar 2017 07:40:38 -0800 (PST) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id i15sm3486899wmf.21.2017.03.03.07.40.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Mar 2017 07:40:37 -0800 (PST) From: Gaetan Rivet To: dev@dpdk.org Cc: Elad Persiko Date: Fri, 3 Mar 2017 16:40:23 +0100 Message-Id: <75df3898f75996c4ca2da9293d4815f27504fa59.1488550971.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH 5/5] app/testpmd: request device removal interrupt X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Mar 2017 15:40:39 -0000 Enable device removal event for PMD supporting it. Add the --no-rmv-interrupt parameter to explicitly disable it. Signed-off-by: Gaetan Rivet Signed-off-by: Elad Persiko --- 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 89231be..792e2e9 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -197,6 +197,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 @@ -563,6 +564,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 }, }; @@ -982,6 +984,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 8bd1285..de1bb12 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -268,6 +269,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 @@ -1709,6 +1715,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) @@ -1735,6 +1764,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 @@ -1905,6 +1944,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 77fa7ee..85d3e82 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; /**