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 7FA97A04BB; Tue, 6 Oct 2020 12:57:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D748E11A4; Tue, 6 Oct 2020 12:57:27 +0200 (CEST) Received: from new2-smtp.messagingengine.com (new2-smtp.messagingengine.com [66.111.4.224]) by dpdk.org (Postfix) with ESMTP id A866E1023 for ; Tue, 6 Oct 2020 12:57:25 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 574D65802D4; Tue, 6 Oct 2020 06:57:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 06 Oct 2020 06:57:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm2; bh= BXY3HMPle1iyevmTxzHmfoAREuIR7scuw6MX4NhOIaM=; b=J3M6yxBUN7GF3308 U5kvSsWQCA+e3rJNMKqfQYG+bpPKAAChz6zXw3rk+vW8jmRwdfYZAOZh0OALd3X1 IHPgaKldm781C95O0WNQMB1SqA6Db5o3ONbMKbtzhPl5fLUJT+HoiSxZAuACb63E zkPwvlHhfTXwe0K7WvEs0syvYLgRO8cj6WBfRl0YkHL2X9aABXO3xfYS9vMBZX2G Kmd0t2thwT+DtBA9sXP8IdKo7b0m6//bQ8GAoCioEhNuvnlH0hojEYOyrBWblU6q /G25O2mNKMIopj2Ey3tEGMttDeqvYA9EtHZl1ZhNxprpS5cV1X9QA6qTrT+3g4O3 GyvZlw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=BXY3HMPle1iyevmTxzHmfoAREuIR7scuw6MX4NhOI aM=; b=QOuSWH78utyiGxSeacV1IDifS2Oi6UYdh53BiT2UkPXBMgT1V8JMbaojt 8FO8BfQfQ7MmRfsF1Xvz/ZpdCdORu+NfyPKmFyuu4uAcpdQCjgSYSrtPXhpuUP3h jgYJSOI2dyVjAid+63dEQ5E8zLkN0LqxCzKKbPMyJSbIJ/u7KmBzbobX5Z5YqdB9 fkzVvj7c4HbT461j9PYjO2QR4i7HypJEPJMQ67dzAEIkbIwOe4wePuT5E1iGPAqO xfF/yF46uQnDgk5sEe616zZdmI8tqu7waEmEV/xkL5Z3m34tSH7p/B0Rr/ZrMkR9 dAUT183NJdQ2MImDQLEGAezPoFTJQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrgeeggdefgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedugefgvdefudfftdefgeelgffhueekgfffhfeujedtteeutdejueei iedvffegheenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvth X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 2EEE43064682; Tue, 6 Oct 2020 06:57:20 -0400 (EDT) From: Thomas Monjalon To: Ferruh Yigit Cc: dev@dpdk.org, arybchenko@solarflare.com, Liron Himi , Stephen Hemminger , Ray Kinsella , Neil Horman , Rahul Lakkireddy , Gaetan Rivet , Jakub Grajciar , Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko , Zyta Szpak , Stephen Hemminger , "K. Y. Srinivasan" , Haiyang Zhang , Long Li , Maxime Coquelin , Chenbo Xia , Zhihong Wang Date: Tue, 06 Oct 2020 12:57:18 +0200 Message-ID: <1850948.foQ0BKb2Qe@thomas> In-Reply-To: <1910c28d-bdab-29c4-a43a-66409f1c7b61@intel.com> References: <20200913220711.3768597-1-thomas@monjalon.net> <20201005170820.1018715-4-thomas@monjalon.net> <1910c28d-bdab-29c4-a43a-66409f1c7b61@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v4 3/3] ethdev: allow close function to return an error 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" 06/10/2020 11:43, Ferruh Yigit: > On 10/5/2020 6:08 PM, Thomas Monjalon wrote: > > The API function rte_eth_dev_close() was returning void. > > The return type is changed to int for notifying of errors. > > > > If an error happens during a close operation, > > the status of the port is undefined, > > a maximum of resources having been freed. > > > > Signed-off-by: Thomas Monjalon > > Reviewed-by: Liron Himi > > Acked-by: Stephen Hemminger > > <...> > > > -void > > +int > > rte_eth_dev_close(uint16_t port_id) > > { > > struct rte_eth_dev *dev; > > + int firsterr, binerr; > > + int *lasterr = &firsterr; > > > > - RTE_ETH_VALID_PORTID_OR_RET(port_id); > > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); > > dev = &rte_eth_devices[port_id]; > > > > - RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_close); > > - (*dev->dev_ops->dev_close)(dev); > > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_close, -ENOTSUP); > > + *lasterr = (*dev->dev_ops->dev_close)(dev); > > + if (*lasterr != 0) > > + lasterr = &binerr; > > > > rte_ethdev_trace_close(port_id); > > - rte_eth_dev_release_port(dev); > > + *lasterr = rte_eth_dev_release_port(dev); > > + > > + return firsterr; > > } > > This may be personal taste but above error handling looks like unnecessary > complex, what do you think something like below: > > close_err = (*dev->dev_ops->dev_close)(dev); > release_err = rte_eth_dev_release_port(dev); > return close_err ? close_err : release_err; This is what I did first. Then thought about this "elegant" handling. The pointer solution is just one more line and is more future proof. I'm fine with any choice. Andrew?