From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30081.outbound.protection.outlook.com [40.107.3.81]) by dpdk.org (Postfix) with ESMTP id 020851D9E; Tue, 22 May 2018 12:19:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+5SDPJrKe6NZ4F7FDX6wrNltM/YAyQqHOa5aB7pYe8k=; b=AZPIjQXT6SYL45bQHekHNlMxastbPfjuB9gFr1SwEjibs6hkI0vUqyfmWRJ8aXqrksOBofe8x+PQWQphFYrXBKz0SbO0oajfVLWrEZHZF6JomtBxt5vS2oSmn/h6Sd8pHW5dfIAmXFau/6JLloDWqIlVhlvUQOBmZe5H7ckkjoM= Received: from VI1PR0501MB2608.eurprd05.prod.outlook.com (10.168.137.20) by VI1PR0501MB2320.eurprd05.prod.outlook.com (10.169.135.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.776.16; Tue, 22 May 2018 10:19:14 +0000 Received: from VI1PR0501MB2608.eurprd05.prod.outlook.com ([fe80::1035:58f9:b94c:2180]) by VI1PR0501MB2608.eurprd05.prod.outlook.com ([fe80::1035:58f9:b94c:2180%18]) with mapi id 15.20.0776.015; Tue, 22 May 2018 10:19:14 +0000 From: Matan Azrad To: =?iso-8859-1?Q?Ga=EBtan_Rivet?= CC: "dev@dpdk.org" , Ophir Munk , "stable@dpdk.org" Thread-Topic: [PATCH v2 1/2] net/failsafe: fix removed sub-device cleanup Thread-Index: AQHT8armzudxZEqf3U6TKovCIcr1G6Q7hjJA Date: Tue, 22 May 2018 10:19:14 +0000 Message-ID: References: <1526583136-21680-1-git-send-email-matan@mellanox.com> <1526932084-1120-1-git-send-email-matan@mellanox.com> <20180522085656.bx3r3e4c6lz4xwlp@bidouze.vm.6wind.com> In-Reply-To: <20180522085656.bx3r3e4c6lz4xwlp@bidouze.vm.6wind.com> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0501MB2320; 7:Fb8RbXK7UoCbWRlLT4iGkAMaSL01izstFnoMbXG8l2TszZyzd8KBfVa8BGfBC8z3LxNNSnPRhVkPDlsJrhvPE502hl2BVAqO4fyzyY5jWd3eZmhNh52DZzTXv1BASTq8n/o+sEPDZjzZlLInZMfs5jq9GSwoKVqife9zCQrKkNLcVLFKWY/xFq+JDkPylRoKiPsX1DL2y9mmNr9q6cQ8FUIcwmxDVV19Czk+VHgMxOzw4/aKeVH4UHkgfrjKWQHy x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2320; x-ms-traffictypediagnostic: VI1PR0501MB2320: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231254)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2320; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2320; x-forefront-prvs: 0680FADD48 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(39860400002)(376002)(396003)(366004)(39380400002)(199004)(189003)(8676002)(81156014)(74316002)(6916009)(3280700002)(6116002)(106356001)(7736002)(2906002)(478600001)(105586002)(305945005)(3846002)(33656002)(2900100001)(8936002)(229853002)(3660700001)(97736004)(81166006)(54906003)(55016002)(7696005)(68736007)(99286004)(25786009)(5250100002)(76176011)(4326008)(6246003)(26005)(486006)(5660300001)(11346002)(316002)(6506007)(53936002)(14454004)(59450400001)(6436002)(66066001)(102836004)(446003)(86362001)(9686003)(186003)(476003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2320; H:VI1PR0501MB2608.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:3; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: bGnMx9d9Ke+RbcLn4pQ5VKa0/6mx0O9YOKiJuduC5tN2SdPZAdObbf4GwALzuklqN2h1rubpLWuZ403ZAS1ItrnMGKiCupuWxomp7kIj8HPypiLrsV5aU8+j1BcoCdQq47DA5V5FUhrRtg0khCHO5N7kvk4NVTrf4g5kwQbgpP/VZ2R2Oh+NGOOBv/bMTnam spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: a62484c1-8c74-4471-85ad-08d5bfcd780b X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: a62484c1-8c74-4471-85ad-08d5bfcd780b X-MS-Exchange-CrossTenant-originalarrivaltime: 22 May 2018 10:19:14.4921 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2320 Subject: Re: [dpdk-stable] [PATCH v2 1/2] net/failsafe: fix removed sub-device cleanup X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 May 2018 10:19:18 -0000 Hi Gaetan From: Ga=EBtan Rivet > Hello Matan, >=20 > On Mon, May 21, 2018 at 07:48:03PM +0000, Matan Azrad wrote: > > The fail-safe PMD registers to RMV event for each removable sub-device > > port in order to cleanup the sub-device resources and switch the Tx > > sub-device directly when it is plugged-out. > > > > During removal time, the fail-safe PMD stops and closes the sub-device > > but it doesn't unregister the LSC and RMV callbacks of the sub-device > > port. > > > > It can lead the callbacks to be called for a port which is no more > > associated with the fail-safe sub-device, because there is not a > > guarantee that a sub-device gets the same port ID for each plug-in > > process. This port, for example, may belong to another sub-device of a > > different fail-safe device. > > > > Unregister the LSC and RMV callbacks for sub-devices which are not > > used. > > > > Fixes: 598fb8aec6f6 ("net/failsafe: support device removal") > > Cc: stable@dpdk.org > > > > Signed-off-by: Matan Azrad > > --- > > drivers/net/failsafe/failsafe_ether.c | 22 ++++++++++++++++++++++ > > drivers/net/failsafe/failsafe_ops.c | 5 +++++ > > drivers/net/failsafe/failsafe_private.h | 5 +++++ > > 3 files changed, 32 insertions(+) > > > > V2: > > Improve the commit log and add code comments for the new sub-dev fields > (Ophir suggestion). > > > > > > diff --git a/drivers/net/failsafe/failsafe_ether.c > > b/drivers/net/failsafe/failsafe_ether.c > > index 733e95d..2bbee82 100644 > > --- a/drivers/net/failsafe/failsafe_ether.c > > +++ b/drivers/net/failsafe/failsafe_ether.c > > @@ -260,6 +260,7 @@ > > sdev->state =3D DEV_ACTIVE; > > /* fallthrough */ > > case DEV_ACTIVE: > > + failsafe_eth_dev_unregister_callbacks(sdev); > > rte_eth_dev_close(PORT_ID(sdev)); > > sdev->state =3D DEV_PROBED; > > /* fallthrough */ > > @@ -321,6 +322,27 @@ > > } > > > > void > > +failsafe_eth_dev_unregister_callbacks(struct sub_device *sdev) { > > + if (sdev =3D=3D NULL) > > + return; > > + if (sdev->rmv_callback) { > > + rte_eth_dev_callback_unregister(PORT_ID(sdev), > > + RTE_ETH_EVENT_INTR_RMV, > > + failsafe_eth_rmv_event_callback, > > + sdev); > > + sdev->rmv_callback =3D 0; >=20 > I agree with Ophir here, either the return value should not be ignored, a= nd > rmv_callback should only be set to 0 on success, or a proper justificatio= n (and > an accompanying comment) should be given. >=20 > The issue I could see is that even on error, there won't be a process to = try again > unregistering the callback. >=20 > Maybe this could be added in failsafe_dev_remove()? Something like >=20 > FOREACH_SUBDEV(sdev, i, dev) { > if (sdev->rmv_callback && sdev->state <=3D DEV_PROBED) > if (rte_eth_dev_callback_unregister(...) =3D=3D 0) > sdev->rmv_callback =3D 0; > /* same for lsc_callback */ > } >=20 > Does it make sense to you? Do you think this is necessary, or should we i= gnore > this? The RMV\LSC event callbacks are called from the host thread and also the re= moval process is running from the host thread so I think EAGAIN is not expe= cted in the removal time. Other error (EINVAL) may return again every attempt and probably points to = another critical issue. Is a code comment for the above enough? Or you think we still need to check= it? > Thanks, > -- > Ga=EBtan Rivet > 6WIND