From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 018AEA04AF; Wed, 19 Aug 2020 19:53:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0DA621C002; Wed, 19 Aug 2020 19:53:46 +0200 (CEST) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id 0875EAAD5 for ; Wed, 19 Aug 2020 19:53:43 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id f193so12052573pfa.12 for ; Wed, 19 Aug 2020 10:53:43 -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:mime-version :content-transfer-encoding; bh=655a5T7mwjK8E8LCZ/xglDnnIJ5v5fvUj/Z438pAgs4=; b=sp9bUlDu5TyVysjA12/rPGvOO0faSIc5Ty4wipcT3fMaK2cdiH1weWy2n+Wl6E77VT Cf9keKtJ/uzfL9iw6ejc5O7w6nq6FyLfc2HBBJchnE1kt/Gflvkg0dCc7H9gi3d4gsk0 UBZLLkfZEqPlqiblFTRxk4NepRDy541GRDYMu/OUQxk4Oa8N0p13kpcOdA2Txej/nOgc FExIoBRtjaT/N44RgKKbTkRO6EwPq7a5cGLuL6MT1fw+qiawugo23dfoHRgjjkKkOYOC AcVbt+M2cN2NLcjS3ro0ErZ8YM8Jo1xXzttBb2NR0XQmfO91xZJdI37Sc8bXt9ZF2AZo DOnA== 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:mime-version :content-transfer-encoding; bh=655a5T7mwjK8E8LCZ/xglDnnIJ5v5fvUj/Z438pAgs4=; b=ud7VqlHPJBGbqWzG12SOpil/QNZNi8xyypUiLbJm8IZzP6RkgOV6tpMXnfU88+hjvD uI0gHQwc5M7YVRhHVAIby35QDehym3jaCj+qdydj+PObcUru7+jz7XNQEGv93Jlre+XL v5/3dTJGMQgd2aS9FR6gYymPzgUwlAwUKERJWXnanSFtLA39OWp1usH/YoMDVbt6BxyG DXHE30s6wOOz548olr9YnSzztxnBIMPKLwGqozo1gjEl+/zRg6BVhTY7PFhsy34RDSge j8KTJqwbyyxX/xJO5PzDSbmOH/IZaoTAlqyScVu91FgRGhKQZ6WfL+Aljd3ZvUc3g/TJ gl+A== X-Gm-Message-State: AOAM531aK5WvDaF9nRI4IWLq6YGlYJWzvnZ84HkQON4mPzlZveC6z1F4 Q2+PM9imdA8Q5f+QZr6XAwYepg== X-Google-Smtp-Source: ABdhPJwMRvoeTKagIUF+BIJaRD9AZS0K0pC13MjyPkW1cm9z/6X80s/BMzN9PaXnFUmEoozwYLn8kw== X-Received: by 2002:a63:df10:: with SMTP id u16mr17017023pgg.437.1597859622915; Wed, 19 Aug 2020 10:53:42 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id n12sm28865219pfo.119.2020.08.19.10.53.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 10:53:41 -0700 (PDT) From: Stephen Hemminger To: matan@mellanox.com, grive@u246.net Cc: dev@dpdk.org, Stephen Hemminger Date: Wed, 19 Aug 2020 10:53:33 -0700 Message-Id: <20200819175333.19601-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] net/vdev_netvsc: handle removal of associated pci device 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" The vdev_netvsc was not detecting when the associated PCI device (SRIOV) was removed. Because of that it would keep feeding the same (removed) device to failsafe PMD which would then unsuccessfully try and probe for it. Change to use a mark/sweep method to detect that PCI device was removed, and also only tell failsafe about new PCI devices. Vdev_netvsc does not have to keep stuffing the pipe with the same already existing PCI device. Fixes: e7dc5d7becc5 ("net/vdev_netvsc: implement core functionality") Cc: matan@mellanox.com, stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/net/vdev_netvsc/vdev_netvsc.c | 39 +++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c index 1ecb0b3e6a34..80a3158012ce 100644 --- a/drivers/net/vdev_netvsc/vdev_netvsc.c +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c @@ -66,6 +66,7 @@ struct vdev_netvsc_ctx { char devargs[256]; /**< Fail-safe device arguments. */ char if_name[IF_NAMESIZE]; /**< NetVSC netdevice name. */ unsigned int if_index; /**< NetVSC netdevice index. */ + int pci_found; /**< Device detection */ struct rte_ether_addr if_addr; /**< NetVSC MAC address. */ int pipe[2]; /**< Fail-safe communication pipe. */ char yield[256]; /**< PCI sub-device arguments. */ @@ -405,11 +406,18 @@ vdev_netvsc_device_probe(const struct if_nameindex *iface, len = strlen(addr); if (!len) return 0; + + ctx->pci_found = 1; + + /* Skip if this is same device already sent to failsafe */ + if (strcmp(addr, ctx->yield) == 0) + return 0; + + DRV_LOG(DEBUG, "associating PCI device \"%s\" with NetVSC" + " interface \"%s\" (index %u)", addr, ctx->if_name, + ctx->if_index); + /* Send PCI device argument to fail-safe PMD instance. */ - if (strcmp(addr, ctx->yield)) - DRV_LOG(DEBUG, "associating PCI device \"%s\" with NetVSC" - " interface \"%s\" (index %u)", addr, ctx->if_name, - ctx->if_index); memmove(buf, addr, len + 1); addr = buf; buf[len] = '\n'; @@ -452,12 +460,33 @@ vdev_netvsc_alarm(__rte_unused void *arg) struct vdev_netvsc_ctx *ctx; int ret; + /* 1st pass: clear PCI flag on all devices */ + LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry) { + ctx->pci_found = 0; + } + + /* 2nd pass: scan all system devices to look for changes to this device */ LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry) { ret = vdev_netvsc_foreach_iface(vdev_netvsc_device_probe, 0, ctx); - if (ret < 0) + + if (ret < 0) { + DRV_LOG(NOTICE, "can not scan devices for %s\n", + ctx->if_name); break; + } } + + /* 3rd pass: detect PCI removal */ + LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry) { + if (!ctx->pci_found && ctx->yield[0]) { + DRV_LOG(DEBUG, "disassociating PCI device \"%s\" from NetVSC" + " interface \"%s\" (index %u)", ctx->yield, ctx->if_name, + ctx->if_index); + ctx->yield[0] = '\0'; + } + } + if (!vdev_netvsc_ctx_count) return; ret = rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000, -- 2.27.0