From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by dpdk.org (Postfix) with ESMTP id AF0842BB1 for ; Tue, 18 Apr 2017 14:18:01 +0200 (CEST) Received: by mail-wm0-f52.google.com with SMTP id w64so54804092wma.0 for ; Tue, 18 Apr 2017 05:18:01 -0700 (PDT) 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 :in-reply-to:references; bh=umgWP9dvuwuXlTqEF5Zwp9P8iEvYbEP7a17KXquC/zw=; b=wjD2saomCYEKKkrwcdyoc5BK0k45+qD0CoYeoVLXuqZteWNdERQLnxR0alGXhtbl3+ X1/wirCmP9SBlvQs4unAFv2pn3Knaj120W3N/ozUfuc6oOJEsnvsrjOwfx3mD5EvpLd5 tcbJ/ksx4DOrip5EFNZ2Dpdqaiwn2ryxFuFmLa36Xj7JzjhowaZwufjMDaG+fwpglgJ1 ET4B+kvwm50gHAsJAcOBSvxB+tjbz/0XinvcL/c4RJLiZ0USlQKmAAQkBqMeOXongM+4 gls/rEInP11i1zMzLWnhIXHweSHcAYBNXHyjLWH+MzYWrnTZbco/3S50YSWMMaLA7EA6 sL3g== 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:in-reply-to:references; bh=umgWP9dvuwuXlTqEF5Zwp9P8iEvYbEP7a17KXquC/zw=; b=CDtLc/WWJs/1+IuNqAVRi7j1/F7sQl9gqsgOcsg3LFMIsz0oDPiSfYecIA2u7gyq5g Uz3Tex7VuG98LUg2FqZO8XNXSgs3eBHN6sK0EthpxbHBvAjiwV+UZG1xX2YdFcFYO50A O2Mv19+xEXpbGTTz/nFKrGMYTFYqYgO7IjFXMOnpdmpPCVUrT8KCxVSwTJw3ATR1o9pT XhQ29eGW+bZPiKtpJZNQpk++rSmCCeVep9G5mWFzlwGd5jv5ousSO1krnAIDkhNGCeqs KfwvI4w+UmhXkxT7kJtkqicjxGTlT2OQKhOeEK6wid/9hA4lHpiFv48p8RI/vyMSIzas rA0w== X-Gm-Message-State: AN3rC/69lHkOngLlanmrPBbL+pa/Za02HwE4EthtDJi2XwXQyxWQ/JGE BQvDX+XugfcoLSbw2NQ= X-Received: by 10.28.229.145 with SMTP id c139mr13619676wmh.107.1492517881060; Tue, 18 Apr 2017 05:18:01 -0700 (PDT) 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 u23sm4266024wmu.16.2017.04.18.05.17.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Apr 2017 05:18:00 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Elad Persiko Date: Tue, 18 Apr 2017 14:17:42 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 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: Tue, 18 Apr 2017 12:18:02 -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 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 #include #include +#include #include #include #include @@ -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; /**