From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50088.outbound.protection.outlook.com [40.107.5.88]) by dpdk.org (Postfix) with ESMTP id D0E991B22A; Mon, 21 May 2018 20:13:54 +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=RDgvAGBo2dYp4IPDyr+0SZXebZBGMAidTJAnuKSNON8=; b=u4T+uFey/w+soZqysNuEPIE8w6VcKrUTu35y3Mdw2XXwJmTb8pOKEy0Cu4ldj9e3QE8CU9XjM1i20eyWNcKrRXGiDoYVXExphuHH7kB9m4bHUp7gDwA8OxUwpCSJdYQV4tcpjIweiLYzeqrwBXZ6bAym+PbSO5M2x3s7dHxxlNY= Received: from HE1PR0501MB2314.eurprd05.prod.outlook.com (10.168.34.19) by HE1PR0501MB2617.eurprd05.prod.outlook.com (10.172.130.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.776.16; Mon, 21 May 2018 18:13:52 +0000 Received: from HE1PR0501MB2314.eurprd05.prod.outlook.com ([fe80::1071:70d0:eac1:5d97]) by HE1PR0501MB2314.eurprd05.prod.outlook.com ([fe80::1071:70d0:eac1:5d97%18]) with mapi id 15.20.0776.015; Mon, 21 May 2018 18:13:52 +0000 From: Ophir Munk To: Matan Azrad , Gaetan Rivet CC: "dev@dpdk.org" , "stable@dpdk.org" , "Thomas Monjalon" Thread-Topic: [dpdk-dev] [PATCH 1/2] net/failsafe: fix removed sub-device cleanup Thread-Index: AQHT7hA87R4QkK0QNkmcPeF6m5e8O6Q6dFKQ Date: Mon, 21 May 2018 18:13:52 +0000 Message-ID: References: <1526583136-21680-1-git-send-email-matan@mellanox.com> In-Reply-To: <1526583136-21680-1-git-send-email-matan@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; HE1PR0501MB2617; 7:ZOCxnwAVqYU4ROA6GfPktNGittVBjmo9obqkiTnxkvOdin4cZiWUq+bRBnXyQKHknyss0AS8dePPxgcKZ3qZWxpLKdpsud6UF/5sAAICUOzoHr7WToCM9vpl2j+ph32d74tXMgf5g9cIcl6NdsNXoOWTTls9uN7cpBLzyX/taqT0deZJdtKVSbG9mhaSLqrcp0mzBmmjB8raVP12zwK0rg/xCr7TNnMwerNofguJlz6RMGKbh/xsXSUKBy6sMZiN 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)(2017052603328)(7153060)(7193020); SRVR:HE1PR0501MB2617; x-ms-traffictypediagnostic: HE1PR0501MB2617: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr 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)(5005006)(8121501046)(3002001)(10201501046)(3231254)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:HE1PR0501MB2617; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0501MB2617; x-forefront-prvs: 06793E740F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39380400002)(396003)(366004)(376002)(39860400002)(346002)(199004)(189003)(13464003)(6116002)(446003)(11346002)(8676002)(106356001)(486006)(2906002)(33656002)(305945005)(5660300001)(7736002)(53936002)(4326008)(99286004)(476003)(105586002)(3846002)(55016002)(7696005)(76176011)(9686003)(74316002)(229853002)(3660700001)(2900100001)(5250100002)(68736007)(25786009)(3280700002)(6436002)(102836004)(97736004)(478600001)(110136005)(26005)(6246003)(6506007)(53546011)(81166006)(81156014)(59450400001)(66066001)(86362001)(54906003)(8936002)(14454004)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0501MB2617; H:HE1PR0501MB2314.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: K9wD9nzYqYPLrWC7rTl9RnPIxlTC4n044WrP0Tf1p5d53+FBWeIh0YTO+fHe848347YQFZ9JbMqPFC1D7YYRRXS/svFz8jusTo4FDe3JvaJbqpfFnLOvcDV9lMQLmgDSey705HWg17lLcE9/wYI0CErU1Wue9xnNnUndU4kLfy7KENHjgOYwAS86qoTAYa0N spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: ba8ce5dc-6c8f-47ad-0006-08d5bf469bb9 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba8ce5dc-6c8f-47ad-0006-08d5bf469bb9 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2018 18:13:52.3533 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2617 Subject: Re: [dpdk-dev] [PATCH 1/2] net/failsafe: fix removed sub-device cleanup 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: , X-List-Received-Date: Mon, 21 May 2018 18:13:55 -0000 Hi, Please find comments inline. > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Matan Azrad > Sent: Thursday, May 17, 2018 9:52 PM > To: Gaetan Rivet > Cc: dev@dpdk.org; stable@dpdk.org > Subject: [dpdk-dev] [PATCH 1/2] net/failsafe: fix removed sub-device clea= nup >=20 > 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. >=20 > In the removal time, the fail-safe PMD stops and closes the sub-device bu= t it During removal time... > doesn't unregister the LSC and RMV callbacks of the sub-device port. >=20 > It can lead the callbacks to be called for a port which is no more associ= ated > to the fail-safe sub-device, because there is not a guaranty that a sub-d= evice associated with........ guarantee that > gets the same port ID for each plug-in process. This port, for example, m= ay > belong to another sub-device of a different fail-safe device. >=20 > Unregister the LSC and RMV callbacks for sub-devices which are not used. >=20 > Fixes: 598fb8aec6f6 ("net/failsafe: support device removal") > Cc: stable@dpdk.org >=20 > 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 | 3 +++ > 3 files changed, 30 insertions(+) >=20 > 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 @@ > } >=20 > 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); Please justify ignoring returned error from rte_eth_dev_callback_unregister= call.=20 I have noticed that this call returned error is ignored in other places in = code (failsafe.c)...but if for example the callback returns with -EAGAIN sh= ouldn't you try again to unregister? Need to avoid a case where the callback is still registered, while rmv_call= back is assigned to 0 > + sdev->rmv_callback =3D 0; > + } > + if (sdev->lsc_callback) { > + rte_eth_dev_callback_unregister(PORT_ID(sdev), > + RTE_ETH_EVENT_INTR_LSC, > + failsafe_eth_lsc_event_callback, > + sdev); Same comment here regarding the returned error from rte_eth_dev_callback_un= register call and lsc_event_callback. > + sdev->lsc_callback =3D 0; > + } > +} > + > +void > failsafe_dev_remove(struct rte_eth_dev *dev) { > struct sub_device *sdev; > diff --git a/drivers/net/failsafe/failsafe_ops.c > b/drivers/net/failsafe/failsafe_ops.c > index d04277b..e0570b6 100644 > --- a/drivers/net/failsafe/failsafe_ops.c > +++ b/drivers/net/failsafe/failsafe_ops.c > @@ -146,6 +146,8 @@ > if (ret) > WARN("Failed to register RMV callback for > sub_device %d", > SUB_ID(sdev)); > + else > + sdev->rmv_callback =3D 1; > } > dev->data->dev_conf.intr_conf.rmv =3D 0; > if (lsc_interrupt) { > @@ -156,6 +158,8 @@ > if (ret) > WARN("Failed to register LSC callback for > sub_device %d", > SUB_ID(sdev)); > + else > + sdev->lsc_callback =3D 1; > } > dev->data->dev_conf.intr_conf.lsc =3D lsc_enabled; > sdev->state =3D DEV_ACTIVE; > @@ -282,6 +286,7 @@ > PRIV(dev)->state =3D DEV_ACTIVE - 1; > FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { > DEBUG("Closing sub_device %d", i); > + failsafe_eth_dev_unregister_callbacks(sdev); DEBUG("Closing...") message should be in its right place just before closin= g sdev (next line). > rte_eth_dev_close(PORT_ID(sdev)); > sdev->state =3D DEV_ACTIVE - 1; > } > diff --git a/drivers/net/failsafe/failsafe_private.h > b/drivers/net/failsafe/failsafe_private.h > index 7e6a3f8..3222653 100644 > --- a/drivers/net/failsafe/failsafe_private.h > +++ b/drivers/net/failsafe/failsafe_private.h > @@ -119,6 +119,8 @@ struct sub_device { > volatile unsigned int remove:1; > /* flow isolation state */ > int flow_isolated:1; > + unsigned int rmv_callback:1; > + unsigned int lsc_callback:1; Nit-pick: please consider adding a description for rmv_callback and lsc_cal= lback similar to the other fields in this struct. > }; >=20 > struct fs_priv { > @@ -211,6 +213,7 @@ uint16_t failsafe_tx_burst_fast(void *txq, > /* ETH_DEV */ >=20 > int failsafe_eth_dev_state_sync(struct rte_eth_dev *dev); > +void failsafe_eth_dev_unregister_callbacks(struct sub_device *sdev); > void failsafe_dev_remove(struct rte_eth_dev *dev); void > failsafe_stats_increment(struct rte_eth_stats *to, > struct rte_eth_stats *from); > -- > 1.9.5