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 7F69AA04BE; Sun, 6 Sep 2020 14:38:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 69DC52BAB; Sun, 6 Sep 2020 14:38:27 +0200 (CEST) Received: from nat-hk.nvidia.com (nat-hk.nvidia.com [203.18.50.4]) by dpdk.org (Postfix) with ESMTP id CE3B829AC for ; Sun, 6 Sep 2020 14:38:25 +0200 (CEST) Received: from hkpgpgate101.nvidia.com (Not Verified[10.18.92.77]) by nat-hk.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Sun, 06 Sep 2020 20:38:24 +0800 Received: from HKMAIL104.nvidia.com ([10.18.16.13]) by hkpgpgate101.nvidia.com (PGP Universal service); Sun, 06 Sep 2020 05:38:24 -0700 X-PGP-Universal: processed; by hkpgpgate101.nvidia.com on Sun, 06 Sep 2020 05:38:24 -0700 Received: from HKMAIL103.nvidia.com (10.18.16.12) by HKMAIL104.nvidia.com (10.18.16.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sun, 6 Sep 2020 12:38:24 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.174) by HKMAIL103.nvidia.com (10.18.16.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Sun, 6 Sep 2020 12:38:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R5mSPMxdg8C4Ww+7M18tumCPw09veEqCddRiAbKpHReIP6sBRHxiRnZlRME00fw0+S9gI5eTKekbf59YPhpXhBz5DVRL47ut3dVZYgXuyJWHsZIU4hUrbv6XhGKJW0g5opqQ5rBmxWsM7b9qIbWrCnl2ZpEmUQh4N8oinVEtg1iRacx3rQtHNqY4vfrUF4Y826IIQQPG3tSo6emuWX7fyizctPa0A0raWTy+gERYtnIZM6OCV0NYcsvOzaM7tJUc22yjWKI9jsXv0ss1bVS9vIDwNIGHGSnuz0KooiiqlhA29W5Qf08A+LxvJZPPWfdb6B+1SKwY3WR4v7cwi6FApA== 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=+33fX5xrAIVgybWobD43nO7plLH6ms5TOHgpv+ZLsqA=; b=fR8S9TKqXxFmb3ex9GjKXuSoEU3lIE6NmRnz9RCdM33G1ryt/sWBHo7Ud5hS3lgrTv2M+IK/TNH+gRfcdQ+2rJDshZsvhCBRHYEf6Ym/Z+Vc5KVrfJZ2JBOLGEpCXlLI+/OWnBd/Pxoh9SpxGZ9d0uHQADQ7KP4C/HmRyw8O3Q/XEDtqFvrj9BQsyagvBghLDu68Fhxr1RUL1g/2fa+LtrzpqWXvGK8EAQL1+oCMY3olzMAwhXwaqErCrfbrM2hYJUsLKC2I1HSY2iHTnEFdNk6JvWLm+0Se8kE/tohzAo11cX0UE0IATEWAlWzLB3L7UCWkCJ3QZVMbhuqKa3LSDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none Received: from MW2PR12MB2492.namprd12.prod.outlook.com (2603:10b6:907:8::19) by MWHPR1201MB0077.namprd12.prod.outlook.com (2603:10b6:301:55::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.17; Sun, 6 Sep 2020 12:38:18 +0000 Received: from MW2PR12MB2492.namprd12.prod.outlook.com ([fe80::693f:4ec4:caa9:ac9c]) by MW2PR12MB2492.namprd12.prod.outlook.com ([fe80::693f:4ec4:caa9:ac9c%5]) with mapi id 15.20.3348.019; Sun, 6 Sep 2020 12:38:18 +0000 From: Matan Azrad 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: AQHWdlG24qWNyHlAOEybBXKlGbQAbKlbnKzA Date: Sun, 6 Sep 2020 12:38:18 +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: authentication-results: networkplumber.org; dkim=none (message not signed) header.d=none;networkplumber.org; dmarc=none action=none header.from=nvidia.com; x-originating-ip: [77.126.81.41] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 61914e76-48eb-4899-d60c-08d85261bb85 x-ms-traffictypediagnostic: MWHPR1201MB0077: x-microsoft-antispam-prvs: x-ms-exchange-transport-forked: True x-ms-oob-tlc-oobclassifiers: OLM:26; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Z/DXFxUmkGdSo5QAtaRwDgSzjmY0W5lB0U7pj9P/O86oE21+f3sw0NpX8bLlbvAKEomjqWBb6JPgUr30dgNIj6l3POxlMTcLaHylTrXs1MLBwUxePxFsTIXzts/Knj2zZWc3XEWa5fstfUtIkOfpTofyr8uMmdsM/yhIhzf87g+izTT3wUay+k6Zce9YnGYGQX62DTubzX9FFguP5Pu/ELhE3u8YqYFNny+SOBMz10VBMHfJW5RMeLESEuKcUrR4xKlcMFzf0qr6e4XI0/4EMeTfbA+o3TXd70fyT5K5BtCFoMoe9pCqGZ7kN/td1SyKX9FxSoTDfRmuecaOPmd5WA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW2PR12MB2492.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(39860400002)(346002)(136003)(376002)(2906002)(110136005)(83380400001)(86362001)(478600001)(316002)(26005)(6506007)(186003)(7696005)(8936002)(33656002)(5660300002)(52536014)(76116006)(66946007)(66476007)(66556008)(9686003)(64756008)(55016002)(66446008)(71200400001)(4326008); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: vVA/VASH/nOHdvVUcVVkC8h4kyME3v1hXHNMlJX/WxNuWfQSMqMRbSMp18eGwdhnZGjh7Ow/WNPyegKpQDx8BEvGr7QrwTR41Pv8JKZfe0eokGBSdlMVx9A18155m+YpzAS1F3LaVkCFPCzHuiJdlE9/pX7VKvkjcDOZSF52TTnYiTxob5Q2A828NdM0LOSdylivTyMARYAYcy/9KdrDcpZbxUDGXedEgBCwzivLXCcslcJWrIfO3GxA8PNa9kT33s3AQJTU8vW6yKkJ/JH/ZT32BgB115D0h7kNUFcDw5syJrjK64PPBDq+gkn/Y90l56n5a55OZOsxsM80q+kk+qSwbP56FyRVjbF4jVF52rPXtvCDDnyKUw0ZkIsLigswHjlhYHjYMH8E0BE1Yvbbb7ZcOef4hI826mebeVOazg2zAX9iLfftiuvKoS4m49uUnFU0uV3D65JtnisCyLHw3EXTwCXxtBfO4SShqvqj5GazP8osF8/EaKFARqdn0RsxGyGzbm5Vp25aXbpZ86hwAHWOAoXYfCMHf7QKIbWPTmEtxC8Zx802/1seMqIFnMqLwPu/KvStOrvQj2/rBrJSqW8/C/xdJNJKGkwMLgNmeJBt4XXnbyGO6jojUL6QfDWdVuehxakGueSPKXgKfy08vw== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW2PR12MB2492.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61914e76-48eb-4899-d60c-08d85261bb85 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Sep 2020 12:38:18.1182 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: cgrxs+l4aGNczQUYzJrHNWvlDp3tKKxV+LPxIDrc/Vyo1ceMXGtoMfGCeS8IMmgD8oZbir32vJ83mB/lN/Xq+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0077 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1599395904; bh=+33fX5xrAIVgybWobD43nO7plLH6ms5TOHgpv+ZLsqA=; h=X-PGP-Universal:ARC-Seal:ARC-Message-Signature: ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic: Thread-Index:Date:Message-ID:References:In-Reply-To: Accept-Language:Content-Language:X-MS-Has-Attach: X-MS-TNEF-Correlator:authentication-results:x-originating-ip: x-ms-publictraffictype:x-ms-office365-filtering-correlation-id: x-ms-traffictypediagnostic:x-microsoft-antispam-prvs: x-ms-exchange-transport-forked:x-ms-oob-tlc-oobclassifiers: x-ms-exchange-senderadcheck:x-microsoft-antispam: x-microsoft-antispam-message-info:x-forefront-antispam-report: x-ms-exchange-antispam-messagedata:Content-Type: Content-Transfer-Encoding:MIME-Version: X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-AuthSource: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-originalarrivaltime: X-MS-Exchange-CrossTenant-fromentityheader: X-MS-Exchange-CrossTenant-id:X-MS-Exchange-CrossTenant-mailboxtype: X-MS-Exchange-CrossTenant-userprincipalname: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg; b=BK6KdOTaB/MYFXJJXYJTs0wMeOARnq2wEmcjfYvrj39WU76hzYOO54OA3FDO3eGDo ujvrjiP43/wWqmMqzNDoWHansBNLu8kFBSoBMmvQyglTvRmsOQ6NAM0YoFgHG0K63N l5d2s83yJJ10TsN3n1M9ZC2n0lF5N8cJ3jVitjLX7IHx6xKFe7cE3a3yzlKaLw0dTk PXqXaZILn8q+axx4fiCg09crMGTX/8IhVBRVuOKwcCycG/A2se0yk3JN+UHgYdnFBX NCcKdUs4562FXLc1aBwV5lX/VLL9N3GBQcfeA2YstdWv9Mi5gc9zmYtn9XGHoKCi9j 84AuuvmD7EBcQ== 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" Hi Stephen From: Stephen Hemminger: > 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. >=20 > 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. As I know, the vdev_netvsc driver doesn't call to failsafe if the PCI devic= e is not detected by the readlink command(considered as removed)... Am I missing something? > > 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(-) >=20 > 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 argument= s. */ > 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 p= ipe. */ > 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; > + The file code convention is to use blank lines in blocks only after variabl= es declarations. > + 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_nam= e, > - 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; >=20 > + /* 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_prob= e, 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->yiel= d, 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