From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9B41CA0555; Fri, 3 Jun 2022 09:42:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 37F0640691; Fri, 3 Jun 2022 09:42:27 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by mails.dpdk.org (Postfix) with ESMTP id 5273C4021E; Fri, 3 Jun 2022 09:42:26 +0200 (CEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 205DF3200907; Fri, 3 Jun 2022 03:42:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 03 Jun 2022 03:42:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1654242143; x= 1654328543; bh=rOvEETkxgE8y8ug9s4r9rumNmkSDdTmz9rdDWlKbXOY=; b=P v04mRp8GWBxHwt0bWXiIBAJGLsrnDwVN4SpgyZ3w3dy8FVaNleb1YOvxLzzDMrJB oGZTY9e3psbb8EFhif15Htcw0i5LQJ9VGo1pIe5EDSAJ5jn7RrXNEynWBOrRulba WewfAFhoEA/4Eu7zX3pB+X9YSLg9z81AgLjdNtkJ1iJg2VEL6hl9uXbUwPcedULf +grQar1tbiMU7FeBxRJr7QnWfjYFwroLJzOrKB4qzeeJTxoBIosUJzE2gpEZkGOi 0uVA0SmyM/Q/vPl1tys4L8xTUKIXdSoN+vyON+BKEtvPnEu1qyrr4zB80FuvMYXP 3NYN9e0klA9lPrqcbk/lg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1654242143; x= 1654328543; bh=rOvEETkxgE8y8ug9s4r9rumNmkSDdTmz9rdDWlKbXOY=; b=v Th/b7qo4eFAtmLPatWiUVhQPyZdjoD0njS+cO+9FBIuYAVtCaNgzj63s9g7RORN7 j3d/ymhjJL9gIheuaN8yohjheD3xI77rep2fpGEtrD0fJ09ObMEUNx262j6AEs/b 1T/fyeiNqbXQRfghcxzcoXiJWK0oe3R1r83ZkN+WmaeIsb8WJaTx7ec3ehyLyDWg 6fawDYU549xinT9TClB+Jw5huAtTaQalQd55yPyDQx92mmYnH9zPERQg9DKzTxCh ITEpAXxgiqyOCLotFGN4v/hyNHLfjJBCirMuCGT7iAke3mKWsCFyXhEVNkgaACnV qE90JMwUHOzSQ0FvC3ZQQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrleehgdduvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkjghfggfgtgesthhqredttddtjeenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpeegtddtleejjeegffekkeektdejvedtheevtdekiedvueeuvdei uddvleevjeeujeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 3 Jun 2022 03:42:21 -0400 (EDT) From: Thomas Monjalon To: Ferruh Yigit , "Min Hu (Connor)" , Ferruh Yigit , Andrew Rybchenko , David Marchand , "lihuisong (C)" Cc: dev , dpdk stable , Bruce Richardson Subject: Re: [PATCH] ethdev: fix push new event Date: Fri, 03 Jun 2022 09:42:18 +0200 Message-ID: <2511545.Lt9SDvczpP@thomas> In-Reply-To: References: <20220521065549.33451-1-humin29@huawei.com> <11bac61b-87c4-ce18-2744-ae5bb4d45253@xilinx.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 02/06/2022 13:24, lihuisong (C): >=20 > =E5=9C=A8 2022/5/30 19:10, Ferruh Yigit =E5=86=99=E9=81=93: > > On 5/30/2022 9:28 AM, Thomas Monjalon wrote: > >> [CAUTION: External Email] > >> > >> 28/05/2022 10:53, lihuisong (C): > >>> > >>> =E5=9C=A8 2022/5/23 22:36, Thomas Monjalon =E5=86=99=E9=81=93: > >>>> 23/05/2022 11:51, David Marchand: > >>>>> On Sat, May 21, 2022 at 8:57 AM Min Hu=20 > >>>>> (Connor) wrote: > >>>>>> From: Huisong Li > >>>>>> > >>>>>> The 'state' in struct rte_eth_dev may be used to update some=20 > >>>>>> information > >>>>>> when app receive these events. For example, when app receives a=20 > >>>>>> new event, > >>>>>> app may get the socket id of this port by calling=20 > >>>>>> rte_eth_dev_socket_id to > >>>>>> setup the attached port. The 'state' is used in=20 > >>>>>> rte_eth_dev_socket_id. > >>>>>> > >>>>>> If the state isn't modified to RTE_ETH_DEV_ATTACHED before=20 > >>>>>> pushing the new > >>>>>> event, app will get the socket id failed. So this patch moves=20 > >>>>>> pushing event > >>>>>> operation after the state updated. > >>>>>> > >>>>>> Fixes: 99a2dd955fba ("lib: remove librte_ prefix from directory=20 > >>>>>> names") > >>>>> A patch moving code is unlikely to be at fault. > >>>>> > >>>>> > >>>>> Looking at the patch which moved those notifications in this point = of > >>>>> the code, the state update was pushed after the notification on > >>>>> purpose. > >>>>> See be8cd210379a ("ethdev: fix port probing notification") > >>>>> > >>>>> ethdev: fix port probing notification > >>>>> > >>>>> The new device was notified as soon as it was allocated. > >>>>> It leads to use a device which is not yet initialized. > >>>>> > >>>>> The notification must be published after the initialization=20 > >>>>> is done > >>>>> by the PMD, but before the state is changed, in order to let > >>>>> notified entities taking ownership before general availabilit= y. > >>>>> > >>>>> > >>>>> Do we need an intermediate state during probing? > >>>> Possibly. Currently we have only 3 states: > >>>> RTE_ETH_DEV_UNUSED > >>>> RTE_ETH_DEV_ATTACHED > >>>> RTE_ETH_DEV_REMOVED > >>>> > >>>> We may add RTE_ETH_DEV_ALLOCATED just before calling > >>>> rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_NEW, NULL); > >>>> Then we would need to check against RTE_ETH_DEV_ALLOCATED > >>>> in some ethdev functions. > >>>> > >>> Hi, Thomas, > >>> > >>> Do you mean that we need to modify some funcions like following? > >>> > >>> int rte_eth_dev_is_valid_port(uint16_t port_id) > >>> { > >>> if (port_id >=3D RTE_MAX_ETHPORTS || > >>> (rte_eth_devices[port_id].state !=3D *RTE_ETH_DEV_ALLOCATED= *)) > >>> return 0; > > > > Won't this mark ATTACHED devices as invalid? > Yes, You are right. >=20 > > If the state flow will be as UNUSED -> ALLOCATED -> ATTACHED, above=20 > > check should be against 'ATTACHED' I think. It should validate both ALLOCATED and ATTACHED. > If these check is against 'ATTACHED', it goes back to the issue this=20 > patch mentioned. >=20 > The failsafe PMD applications expect sending event before device state=20 > set to 'ATTACHED'. > But other applications expect the device with 'ATTACHED' state before=20 > send event. > They are in conflict with each other. So we can't solve this issue by=20 > adding an > 'RTE_ETH_DEV_ALLOCATED' state.