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 309F9A04BE; Sun, 6 Sep 2020 10:11:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 97CAE2BF1; Sun, 6 Sep 2020 10:11:22 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2112.outbound.protection.outlook.com [40.107.220.112]) by dpdk.org (Postfix) with ESMTP id 4DD8B2BAB for ; Sun, 6 Sep 2020 10:11:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iB3hG+FtEv9wI44eLFYtTGj5ZOMmZjTHQMDgxcBFL2njQuY6TAQ03q60P4LmULAsWTqQeD+pjaatqAt8pn7G85YY1sjDTE/KBHgrcNCq9JUJUTHIqlE8lGIq2NowcH/FafuGYnicGxeiNvx7eIwUjIM2IV4XmFVF6CxTOlIKeiEHZw3+yiCo9BDwT6iCWAH8Lf0c3Pm3a/5+194FpT7nPM7VyrQU5nMzSucUXiXmjclQ8UgPwVYhKP6n6uL99vCiSrz7e66MzYMTNzPEU3rONGXTSTlAHJZ/1VG80Z2g2Ar4z9gC2I4aIv12ooXwOjoaGN8f2FIbF34xOK89oayipw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q+Dy8EQQjZg0cv9FOhi1nVns6FuiEZK4DlGyIGb8VaA=; b=iVlt86Si7Cbx4o1CNj04AGXkLQmwSxFDvnFFawBLXo4JDiAq2cxAkbj6FsHDBeI3uAl8RcjHuarD6vKHuMQZa0vYWGQzZxtGjImuEzD9zsE9X1iPDXExfo6uuL8Fy523rKczOI6PssZdKDT/km/DP9gGqS9NdCzt3TZYQolz66YKauK73Tc917MHNCde89cDKkfXHH/JZrDv7os3tntCShh9dW4OWD8/YwEVWcRFNgiPqadkwcAG1fZA0oD7iedj2P+1M+iFINUp95m8zg6ZP/IgU/1+1MVl5yQBH1eE4Sof+Rqvqqyc2kdXCogyW7cbWHBSez1eHsxs9c59X/t2wQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q+Dy8EQQjZg0cv9FOhi1nVns6FuiEZK4DlGyIGb8VaA=; b=ioQlSa9omy82/7OBjRtap51rAWCBRzQMhnhoZQevfF3bBHRIk7tkKe+s12KDUZLrhXHSjnk1hpFJzYdn1XzeEfiMve58U/Y2/+bpt7t40jQIScaYWxddW5rCSPYo57WbdOc7VteVEN8ms8lG62kT1p4SElQrqfkk5JBqPInvtT4= Received: from MN2PR21MB1166.namprd21.prod.outlook.com (2603:10b6:208:fe::31) by MN2PR21MB1229.namprd21.prod.outlook.com (2603:10b6:208:3b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.0; Sun, 6 Sep 2020 08:11:17 +0000 Received: from MN2PR21MB1166.namprd21.prod.outlook.com ([fe80::b13e:e9b3:6456:375a]) by MN2PR21MB1166.namprd21.prod.outlook.com ([fe80::b13e:e9b3:6456:375a%3]) with mapi id 15.20.3370.011; Sun, 6 Sep 2020 08:11:17 +0000 From: Long Li To: Stephen Hemminger , "matan@mellanox.com" , "grive@u246.net" CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] net/vdev_netvsc: handle removal of associated pci device Thread-Index: AQHWdlGx9Qg5b0xgqE6hLdjktHnvw6lbXbfA Date: Sun, 6 Sep 2020 08:11:17 +0000 Message-ID: References: <20200819175333.19601-1-stephen@networkplumber.org> In-Reply-To: <20200819175333.19601-1-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=8ebfdf65-e92b-490d-9c45-d8cd3cb385b6; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2020-09-06T08:10:26Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: networkplumber.org; dkim=none (message not signed) header.d=none;networkplumber.org; dmarc=none action=none header.from=microsoft.com; x-originating-ip: [2001:4898:80e8:b:ede3:db5c:c6fe:798] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: a28ebf31-7ee8-4f10-2527-08d8523c6e83 x-ms-traffictypediagnostic: MN2PR21MB1229: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:31; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: JuiNUGbDX47ZAXU3gv1fwprnnk6iKXdybiPDdrOuQ6oheuDVC3cIOxURXo6+lcISSKFqIkW0bMrWorvlG6so0lgT0thahBFYc4FCbmuSTuSljpFwOOO/F0CLPKz+ui100c9V53KzqOK2/GPtSlhm7QvBxLGAyTwo6v9LunFq8p6mh6AW+0L39JGW/phxjHLbK78laVpWpc6s/7645Qv1muMfQYAkBzL3DDnQZ/tr9ekeaFGypQn/yHISStEa2k1haEtlNwGNpbmVBF2gCpWAaj+IBh3uSJtgfIpYpBATvi6NHlxEv0ymOun1oiweOf+8vZNfPexJDf43h1BUNAXzcds6S5xIT//mT7BOIVMoe+8jqJJfwRZRiU9zFcBzCUJs x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR21MB1166.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(136003)(346002)(376002)(396003)(2906002)(33656002)(8936002)(55016002)(4326008)(7696005)(478600001)(9686003)(8990500004)(71200400001)(316002)(86362001)(64756008)(83380400001)(6506007)(82950400001)(52536014)(66476007)(110136005)(66446008)(10290500003)(66946007)(66556008)(82960400001)(76116006)(5660300002)(186003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: 5jOigmeWbZrJDanHG9AGrun+moIXJKFDekmFYQ8VA3vKC9mDA0ruAejXpwtSDU/6/rDVZOYkssQF+oLhfBqwvcnwQVsLzQ2eXYN0lyCeMCumWHGHpg+F6RxzNc6CYsc0HJF4rLMIwUxGFuSMnkUsbNCImmg/SuBMxEuODgfdPh9rrZU+SfrQcZyo3cyt/JICz0xFtk7zV/m+bIguk3lLAq3sOaiLxaDf0eOos0eNigvycbud3eXUk0ifwc8maEVaGxb3FfgJgH1P+dS3qUAraXpLxEA5avkHKNxFWnPawyFt31/7JvcMqGYXyXMpgYIPLs3XYXMUeiDo7Mw93CGo0klZfAkthaggQywwS6WLfduTKKxccNaZkJR2vLReq6rO6Xyi5et0uHulvFiMGrUpepMaEyBxX+GOmaMqNs/B0u8WXxd2K1mX76HaWbpYKU+6y35mWeEnLGoP0CYmEVqsYEF0+oSCmRZD6tSzdpoGwUytB5ef4MWeVdml974VB56cQLzpVr9XlXaLknqmYW0lvO3QIxNVTtvsjRfWXesf6Ud3OF0VtAb0RALvII20KhvhwaZnevi7IWwXnYpA2Ybhsuqvd85g6mw/9vuhA/Yu8c/cIUNYG+j1+5obm+So5fPY8hIBEeYKBNfRZg08dfOgB2ws07dbcIqUUdtNSfbKjOwz6zvrB0uMQcZvEBgOmqpnHu4KuTFu0qmOvTgUrhs7OQ== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR21MB1166.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a28ebf31-7ee8-4f10-2527-08d8523c6e83 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Sep 2020 08:11:17.8119 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: uW8GXKhLO43ggONQCiU00ymDvvxWw3sJ+lsQ7XUsqY4repOiyPSGW5IL2ioLBpABrWdWZNAVS4+RMSOVDFGQww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR21MB1229 Subject: Re: [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" >Subject: [dpdk-dev] [PATCH] net/vdev_netvsc: handle removal of associated >pci device > >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 Reviewed-by: Long Li >--- > 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 =3D strlen(addr); > if (!len) > return 0; >+ >+ ctx->pci_found =3D 1; >+ >+ /* Skip if this is same device already sent to failsafe */ >+ if (strcmp(addr, ctx->yield) =3D=3D 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 =3D buf; > buf[len] =3D '\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 =3D 0; >+ } >+ >+ /* 2nd pass: scan all system devices to look for changes to this >+device */ > LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry) { > ret =3D >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] =3D '\0'; >+ } >+ } >+ > if (!vdev_netvsc_ctx_count) > return; > ret =3D rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000, >-- >2.27.0