From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20053.outbound.protection.outlook.com [40.107.2.53]) by dpdk.org (Postfix) with ESMTP id 205817CC8; Wed, 16 Aug 2017 16:17:19 +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; bh=1drpQgCdUbirL4c5vOXzgt26lj7aPNE6H8z+5kjPPRQ=; b=iMU/asywbz03k8cRd4DxzzCkT1o/GjOySUp1g8Eo9mdlw1xHKQFl9yIDBBnWE3YkXPFqb5ML1k67ITg1/t1YCgoH3wgFdMypBC8f/srqhhwwVYibthD0fCUxk6Tgl8aIz/dwSt9I3pFy8AwTfytS/vbym0OJ3jKtm7aBb2TLqg4= Received: from VI1PR05MB3149.eurprd05.prod.outlook.com (10.170.237.142) by VI1PR05MB3152.eurprd05.prod.outlook.com (10.170.237.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1341.21; Wed, 16 Aug 2017 14:17:16 +0000 Received: from VI1PR05MB3149.eurprd05.prod.outlook.com ([fe80::8450:1a86:2dd0:82c2]) by VI1PR05MB3149.eurprd05.prod.outlook.com ([fe80::8450:1a86:2dd0:82c2%13]) with mapi id 15.01.1341.020; Wed, 16 Aug 2017 14:17:16 +0000 From: Shahaf Shuler To: =?iso-8859-1?Q?Ga=EBtan_Rivet?= CC: Thomas Monjalon , "dev@dpdk.org" , "stable@dpdk.org" Thread-Topic: [PATCH] ethdev: fix device state on close Thread-Index: AQHTFo0Eom7jHIBJrESDD1xInahTyKKHBDHA Date: Wed, 16 Aug 2017 14:17:16 +0000 Message-ID: References: <20170816114308.165850-1-shahafs@mellanox.com> <20170816124130.GL8124@bidouze.vm.6wind.com> In-Reply-To: <20170816124130.GL8124@bidouze.vm.6wind.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=shahafs@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR05MB3152; 6:sW5Bl32tbbWHQDe02JF6FVqcjTTw5pAX1CWZ0H/lVf5Js+Fse19oPBB1K15AiVKfgWZMSfLJhX/SMFPHaiinHaTdlIbasT2O5BUFEMOE8RuvirbBovKIAsaNkQGIK0wxb0TzXiPzgOcZdyfru1+RCYoB2U216SI5IkvG1MXmc+sD+K8t2pqBniVDJZxiwdRfGcs8q/B/le5LazvkJfXm7MFiSV8TOEy92SFTB8NhkwT2q/ioUmZX64DJxemd542+vWRxvWOqps5PFhDQ56qv29gyMIuj+P2+qEpnQT0qmGUMRaUuYoaWQaY59MDaMoN04pFzSkjhQ+DPXwO7Xg58yQ==; 5:709a/TQKPRONcSjCfk9LSmxOk/Kg+ymmXLduuP5KNEI7Ao62CBCx0bEs+UNWqihFBMkGa0rVxeBkLYTs4ChAtPxHnmOXLH1DWC2tgrOyH+vgEBjTtoq+hmsUv9w65VNpA8ZIrJyQsVtVXilXhCUG+g==; 24:r/XCUAMwTvB+RxqFuiQdHUqCt2BBS9ni4l+N8lowvLM7sEe13pqBAQi5HwUM15AyIK5W9cGpeOI/ppm71AKyk+tH50NtPCYO0FrtIgpPk4Q=; 7:AynTRvElk0Lr6bilKxhUhWFhhcfltTRyxhHIWYkqzboW5lStAFc587u0ssV0Mv1S73ZxHheO+ttnnWy/t4S0LZfVzZA8bUYJ0ydUfXjdyYPchESN4Y4d4KP0BR1jZeKzi4SJOFaBC5LIrvZ00Ufd/hYOlz4q91bBeWg9ZG1CZBoPqeFLgDpW9Uq5iFhk5myp2guI0HChAtsfvP95W8XQ80/odY0KXrvDaI15DC3h0yM= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-ms-office365-filtering-correlation-id: f84b2ad3-71ee-4d67-2b8e-08d4e4b17f7a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:VI1PR05MB3152; x-ms-traffictypediagnostic: VI1PR05MB3152: x-exchange-antispam-report-test: UriScan:(155532106045638); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123558100)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR05MB3152; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR05MB3152; x-forefront-prvs: 0401647B7F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(189002)(199003)(377454003)(24454002)(97736004)(2900100001)(5890100001)(5250100002)(478600001)(81156014)(8676002)(8936002)(81166006)(7696004)(25786009)(7736002)(305945005)(14454004)(68736007)(4326008)(229853002)(105586002)(6246003)(6506006)(106356001)(3280700002)(54356999)(76176999)(50986999)(110136004)(54906002)(9686003)(86362001)(6116002)(3846002)(55016002)(99286003)(3660700001)(2906002)(102836003)(33656002)(53936002)(5660300001)(66066001)(74316002)(189998001)(2950100002)(6916009)(6436002)(101416001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB3152; H:VI1PR05MB3149.eurprd05.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:3; A:1; LANG:en; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Aug 2017 14:17:16.4358 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB3152 Subject: Re: [dpdk-stable] [PATCH] ethdev: fix device state on close 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: Wed, 16 Aug 2017 14:17:19 -0000 Wednesday, August 16, 2017 3:42 PM, Ga=EBtan Rivet: > On Wed, Aug 16, 2017 at 02:43:08PM +0300, Shahaf Shuler wrote: > > Currently device state moves between ATTACHED when device was > > successfully probed to UNUSED when device is detached or released. > > > > The device state following rte_eth_dev_close() operation is inconsist, > > The device is still in ATTACHED state, however it cannot be used in > > any way till it will be probed again. > > > > Fixing it by changing the state to UNUSED. > > >=20 > You are right that simply closing the device leaves it in a unusable stat= e. >=20 > However it seems to be by design. > Most drivers call `rte_eth_dev_release_port` when being removed, which > sets the state to RTE_ETH_DEV_UNUSED. >=20 > If I'm not mistaken, the API of rte_eth_dev_close is that the only availa= ble > action should then be to detach the driver. At least PCI and vdev buses > expects a `remove` callback from their driver, which can be called by the= user > (previously using specific API like `rte_eal_vdev_uninit` for example, no= w > using `rte_eal_hotplug_remove` or `rte_eth_dev_detach` from the ether > layer). >=20 > So, it seems that this burden lies with the driver which should call the = proper > API when removing their device. Even though it is reasonable for driver to call the rte_eth_dev_port_releas= e, I still think the ethdev layer should protect from such bad behavior fro= m the application side. It is more robust than counting on the different PMD to implement such rele= ase.=20 >=20 > Maybe Thomas will have a better insight about the scope of the > `rte_eth_dev_close` function. But IMO the API is respected. > After all, until the proper `dev_detach` function is called, the device i= s still > attached, even if closed. >=20 > If you disagree, there might possibly be an argument to make about either > adding finer-grained device states or streamlining the API. This is howev= er a > discussion about API design and not about its implementation anymore. Well my first thought when I created this patch was to add fine-grained dev= ice states. However then I read the commit log which changed the device sta= tes, specifically : " "DEV_DETACHED" is renamed "RTE_ETH_DEV_UNUSED" to better reflect that the emptiness of a slot is not necessarily the result of detaching a device." Which convince me to reuse the UNUSED state to reflect that this device can= not longer be used (even though it is still attached).=20 >=20 > > Fixes: d52268a8b24b ("ethdev: expose device states") > > Cc: gaetan.rivet@6wind.com > > Cc: stable@dpdk.org > > > > Signed-off-by: Shahaf Shuler > > --- > > lib/librte_ether/rte_ethdev.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/lib/librte_ether/rte_ethdev.c > > b/lib/librte_ether/rte_ethdev.c index 0597641ee..98d9e929c 100644 > > --- a/lib/librte_ether/rte_ethdev.c > > +++ b/lib/librte_ether/rte_ethdev.c > > @@ -992,6 +992,8 @@ rte_eth_dev_close(uint8_t port_id) > > dev->data->nb_tx_queues =3D 0; > > rte_free(dev->data->tx_queues); > > dev->data->tx_queues =3D NULL; > > + > > + dev->state =3D RTE_ETH_DEV_UNUSED; > > } > > > > int > > -- > > 2.12.0 > > >=20 > -- > Ga=EBtan Rivet > 6WIND