From patchwork Fri May 8 03:59:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69969 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D8010A00C5; Fri, 8 May 2020 05:59:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 14CCC1DC19; Fri, 8 May 2020 05:59:21 +0200 (CEST) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id 8AF7F1DC11 for ; Fri, 8 May 2020 05:59:19 +0200 (CEST) Received: by mail-pg1-f195.google.com with SMTP id d22so264185pgk.3 for ; Thu, 07 May 2020 20:59:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6KpId3oyoj9E0BT2NM7FCzfwA99QZCH5r3w7pJfi4Tg=; b=JIU65oAxvhx56QfOz8Cb5ldA3FRLqskQW7RYeSvSt+R5Ox/TZpKzTFF7YAEiXxYZUt QIcjByOdRaobWMyR5vU/keCHLWmBntvLbxSfgumiRJonY4zck/CHp6cqik3vRM2lx/qg PS0C4NKiyRi1rb5hBfH5b2ABSVCQf1PynuYApmP+dWToa6/EVwyN6lJb8K16y5Z4HdZT wRm8bK1OqnDveHpXoVlWiVFyOwpUa80aMxPsrTdFDkqhzlrG4fehQttpsJWIEmgeSP0x b5MU/g8KJ0C2hL6ArP67vqUCjQukc9/poqWRh3S86eYGHq3kMoQdqnWq2tnKq+XYNGOt Pl/Q== 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:mime-version:content-transfer-encoding; bh=6KpId3oyoj9E0BT2NM7FCzfwA99QZCH5r3w7pJfi4Tg=; b=bf9PTAYKho5qkpCLe27Kz0olLMrAKBjejnc5cFV+gzjkLMCsMWPKBCX/YMWJnGYrsP tIwFyDrfeYAhKPSPvw/gQQ7it9SR9QPHO2Y/AUS5/JDTf3ev3QNPiREesddAaLiT7QfC nlidadis6UK+xu3Gdb5c5QaWgCsSAUK4OvM0BZJivcTl4Vydx678IoHBj2wyAvgNaWwA AUcE04Gg2sqQuJhRHIKu35m4X19CPb0en4Cox33VfcB5x+drxnKlHwlgsTP1x63yI/+U CF6GCpNFr2R6JnyDmPvU57GguLlSJ+5gYvvQhdMvcwm+vIxhGqs3fR0i4uL50aVbSfd1 ogNw== X-Gm-Message-State: AGi0PuaAqdQqDhBAGuWOiSSXrGh3CVnAPXEFqGg1b2pMJJOrSfbK93le ByyYjiK6Uji6ImL+uFaNHoMZ7eAbCPBBXw== X-Google-Smtp-Source: APiQypKzVWB2muUB2pksNwddXeGfe3hedVsExHpEGkl64YbE2h8tE6YmHscReUcAVMTGgFk4mjEmsw== X-Received: by 2002:a62:844c:: with SMTP id k73mr678272pfd.235.1588910357989; Thu, 07 May 2020 20:59:17 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id fv14sm1130694pjb.47.2020.05.07.20.59.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2020 20:59:14 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 7 May 2020 20:59:04 -0700 Message-Id: <20200508035906.18359-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200508035906.18359-1-stephen@networkplumber.org> References: <20200508035906.18359-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC 1/3] eal/hotplug: allow monitor to be setup by multiple places 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In some cases, a device or infrastructure may want to enable hotplug but application may also try and start hotplug as well. Therefore change the monitor_started from a boolean into a reference count. Signed-off-by: Stephen Hemminger --- lib/librte_eal/linux/eal_dev.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/librte_eal/linux/eal_dev.c b/lib/librte_eal/linux/eal_dev.c index 83c9cd660754..4d1c08f4c258 100644 --- a/lib/librte_eal/linux/eal_dev.c +++ b/lib/librte_eal/linux/eal_dev.c @@ -23,8 +23,11 @@ #include "eal_private.h" -static struct rte_intr_handle intr_handle = {.fd = -1 }; -static bool monitor_started; +static struct rte_intr_handle intr_handle = { + .type = RTE_INTR_HANDLE_DEV_EVENT, + .fd = -1, +}; +static uint32_t monitor_refcount; static bool hotplug_handle; #define EAL_UEV_MSG_LEN 4096 @@ -290,7 +293,7 @@ rte_dev_event_monitor_start(void) { int ret; - if (monitor_started) + if (__atomic_fetch_add(&monitor_refcount, 1, __ATOMIC_RELAXED)) return 0; ret = dev_uev_socket_fd_create(); @@ -299,7 +302,6 @@ rte_dev_event_monitor_start(void) return -1; } - intr_handle.type = RTE_INTR_HANDLE_DEV_EVENT; ret = rte_intr_callback_register(&intr_handle, dev_uev_handler, NULL); if (ret) { @@ -307,8 +309,6 @@ rte_dev_event_monitor_start(void) return -1; } - monitor_started = true; - return 0; } @@ -317,7 +317,7 @@ rte_dev_event_monitor_stop(void) { int ret; - if (!monitor_started) + if (__atomic_sub_fetch(&monitor_refcount, 1, __ATOMIC_RELAXED)) return 0; ret = rte_intr_callback_unregister(&intr_handle, dev_uev_handler, @@ -329,7 +329,6 @@ rte_dev_event_monitor_stop(void) close(intr_handle.fd); intr_handle.fd = -1; - monitor_started = false; return 0; } From patchwork Fri May 8 03:59:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69970 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DBEE7A00C5; Fri, 8 May 2020 05:59:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 684221DC27; Fri, 8 May 2020 05:59:22 +0200 (CEST) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id DE5851DC11 for ; Fri, 8 May 2020 05:59:20 +0200 (CEST) Received: by mail-pg1-f195.google.com with SMTP id b8so246425pgi.11 for ; Thu, 07 May 2020 20:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tP+lLDysTL0Pya5smLg3aRZ0hdkebx+L5jBRYitmnq4=; b=z0bfdA8XLjdcAsh4IK48c2wol9n78rw69WPI1rN8pmahJrFMCDqXfOU6SBCwi9/tZV Y0e2U7G4cHWD2n/J+ngMV8Pt31SRDxeG9cqoUv/CA54S2wtOmGqg3KINmJmCBNkdjKsa WZ3O6hvSPJCuACVtJUOL8AcBcQm4IWfomn92BM+n3JZisEx4D5lwcauT6ntOtoySb4aY ZnicESb3iDVjBcTl97E2PO9M3Jms8F4X203xhHhXzYiu8cZgFroA0ETYarWE8dQBkgKC 1U+aYnxieLcJMPU9EU/tkaDPqpVtI7jtpNjUv/q7Cskx6Bms1hoAIaKjFqtYabK8/X9h cawA== 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:mime-version:content-transfer-encoding; bh=tP+lLDysTL0Pya5smLg3aRZ0hdkebx+L5jBRYitmnq4=; b=DqXYAqFKPkmUBeGKcTremeFYmPbJqF2YYt0hZw8GWcQ2H7ZeiGAhJ13rPpR6wEcJ7S oWVDYRJhDZ80ekFiHTZgKHguc/T0NH26bLKMEc2hsisPQvHMQzpcEo93OFkF4paeWv5C gCStZSikkqeRIZHKS8b7hcj92FFA7FpYUfTQjWuLoh31/Y/euF04ZJS+6VHa8w63oPdM 5jvXs6/UApe4oaCSJn0e4X5z5+VPBma6DXBdf+kJjUcl7d1ia4bF9sMPuuPwJL0vbyDP pje9EM/E0wFYET/0lnEHGIKzuMKwNkS4pniwBJbpihPyUa2w/zflZ5K4uEJ4OPT/bYE2 mhCQ== X-Gm-Message-State: AGi0PubUpcI9L/anNFDXiA1U4ALPbOGIf8atnbdHdNASD6JEybj2mW/w MZyUAhVwUWKxKqFUvyO7H5lQScpmIxhdLA== X-Google-Smtp-Source: APiQypJ5yOsc7Pd5JL9H6i8dwOjCRPdjZ57I11oXg6UA8+g3V8M8O4e0MnCwnp3c3GUvzZvUXlZ3HA== X-Received: by 2002:a62:1985:: with SMTP id 127mr660456pfz.175.1588910359616; Thu, 07 May 2020 20:59:19 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id fv14sm1130694pjb.47.2020.05.07.20.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2020 20:59:18 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 7 May 2020 20:59:05 -0700 Message-Id: <20200508035906.18359-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200508035906.18359-1-stephen@networkplumber.org> References: <20200508035906.18359-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC 2/3] net/vdev_netvsc: automatically enable hotplug support 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In Hyper-V/Azure with accelerated networking the VF device maybe added or removed at anytime. Automatically enable hotplug support (in case application has forgot to). Signed-off-by: Stephen Hemminger --- drivers/net/vdev_netvsc/vdev_netvsc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c index 9ed74a1d6a2e..f99909ad800f 100644 --- a/drivers/net/vdev_netvsc/vdev_netvsc.c +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c @@ -729,6 +729,7 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev) if (kvargs) rte_kvargs_free(kvargs); ++vdev_netvsc_ctx_inst; + rte_dev_event_monitor_start(); return 0; } @@ -749,7 +750,10 @@ vdev_netvsc_vdev_remove(__rte_unused struct rte_vdev_device *dev) { if (--vdev_netvsc_ctx_inst) return 0; + rte_eal_alarm_cancel(vdev_netvsc_alarm, NULL); + rte_dev_event_monitor_stop(); + while (!LIST_EMPTY(&vdev_netvsc_ctx_list)) { struct vdev_netvsc_ctx *ctx = LIST_FIRST(&vdev_netvsc_ctx_list); From patchwork Fri May 8 03:59:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69971 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 32532A00C5; Fri, 8 May 2020 05:59:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 36F341DC5A; Fri, 8 May 2020 05:59:24 +0200 (CEST) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id B792B1DC37 for ; Fri, 8 May 2020 05:59:22 +0200 (CEST) Received: by mail-pf1-f195.google.com with SMTP id x15so273015pfa.1 for ; Thu, 07 May 2020 20:59:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GnTOqG+DF8HIeT+1HdR98H24KAboY8LQKGLinJ5Mc4I=; b=i6sDeIpOAGEdKUtRtNUr6LlC9L9a2hc/+CTW01T//SUDFVccJw4UbmT3kgyzoelOBr vMCZbWvw2StJTaI3r+tIH7bh1YgY1jeCNTeuDWqqy7x26iY1wdlFK8kKuDN98VgZKaI2 lXL5YFWRsRucHTb7fYkQ4RUsDG+9xYuUe2+0NQ+ZFq/tVe+GAfDFzLC1NN2AuUECriNc 9Ad4Yaux/H7C+MSiJmI+9ggzR4zMMB2GsEb8v1QStmKI1myrcprzjORsIBsPmKlFEFtE Pl3NxQ0ZGjw+m2F6H0vRE+bxqKswKbwM/Lszn5krPkMYsI+SHqGujUgPIwWEC66jOCe6 bF2g== 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:mime-version:content-transfer-encoding; bh=GnTOqG+DF8HIeT+1HdR98H24KAboY8LQKGLinJ5Mc4I=; b=ugjYr9gtjMIjVBxgMqzoFmt6huKoKVpXSHvLIuyStzpHiOUzsxH32KUrsqSqZg/sai KFL6g6JlM3ui0ZG8e5aWCsQE8WRHXbs4lDFzPGpE27ye9BbnVFhGBeUEqbceBicFdVv8 AF5YDqcNf20khb7RnRNt7DvRPU3ozM7MXW6edM2Q5RrzrBxcJ1Z99aZGt5UdWJ05F7mt CPFff0nSkrS5K/DuRirXGZvImAo5Q4DJ4AHINyvTpCr8PepUeEfBjhW7fW6Al5zEPPqa NsHseVmSo2gLJeOl8G1GXCT5DGVTPIFg8Exf4Q3s5radZn0h+2eGgHhHrucIC7lurLAT zwKg== X-Gm-Message-State: AGi0Pua/m7ICMrpG0/KoAYi3k43P58c/JwNiYS8pnm1LuI6AEk7vUkgL 602ErYl1qYpB7Y5ZQB5qRMMy9vQOuRFxbg== X-Google-Smtp-Source: APiQypLdfXktjYKNV8ty+S6yEfdZ8DECRZGCdUSQIouzlA5PnI5bf3AIpeiUsp44T7GcyfXo/vfcAw== X-Received: by 2002:a62:3383:: with SMTP id z125mr685613pfz.271.1588910361427; Thu, 07 May 2020 20:59:21 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id fv14sm1130694pjb.47.2020.05.07.20.59.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2020 20:59:20 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 7 May 2020 20:59:06 -0700 Message-Id: <20200508035906.18359-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200508035906.18359-1-stephen@networkplumber.org> References: <20200508035906.18359-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC 3/3] net/netvsc: automatically enable hotplug support 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In Hyper-V/Azure with accelerated networking the VF device maybe added or removed at anytime. Automatically enable hotplug support (in case application has forgot to). Signed-off-by: Stephen Hemminger --- drivers/net/netvsc/hn_ethdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 05f1a25a1abc..cf10fc24b37b 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -1074,8 +1074,10 @@ static int eth_hn_probe(struct rte_vmbus_driver *drv __rte_unused, ret = eth_hn_dev_init(eth_dev); if (ret) eth_dev_vmbus_release(eth_dev); - else + else { rte_eth_dev_probing_finish(eth_dev); + rte_dev_event_monitor_stop(); + } return ret; } @@ -1096,6 +1098,7 @@ static int eth_hn_remove(struct rte_vmbus_device *dev) return ret; eth_dev_vmbus_release(eth_dev); + rte_dev_event_monitor_stop(); return 0; }