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 A503BA04BB; Tue, 6 Oct 2020 11:43:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 77E442E81; Tue, 6 Oct 2020 11:43:33 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 9492A37B7 for ; Tue, 6 Oct 2020 11:43:31 +0200 (CEST) IronPort-SDR: dZsxjDkFiHXdKEp2I7WiLV9uKMY/iAetWxC4XJP1bSax8c4YQP1xrZdPj7VSBWQvEIldD6eP0B 8okmqlrRoQoA== X-IronPort-AV: E=McAfee;i="6000,8403,9765"; a="181874050" X-IronPort-AV: E=Sophos;i="5.77,342,1596524400"; d="scan'208";a="181874050" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2020 02:43:29 -0700 IronPort-SDR: CTXbv/ohKhYXB+0fuCvvqbXkQTK+TWYhgORqZAQ+4CJwY9ERSUzdc7fad1Vp60Rj0l96f0+P/i Jh4Nz99x/t/A== X-IronPort-AV: E=Sophos;i="5.77,342,1596524400"; d="scan'208";a="342167358" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.241.102]) ([10.213.241.102]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2020 02:43:25 -0700 To: Thomas Monjalon , dev@dpdk.org Cc: 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 References: <20200913220711.3768597-1-thomas@monjalon.net> <20201005170820.1018715-1-thomas@monjalon.net> <20201005170820.1018715-4-thomas@monjalon.net> From: Ferruh Yigit Message-ID: <1910c28d-bdab-29c4-a43a-66409f1c7b61@intel.com> Date: Tue, 6 Oct 2020 10:43:22 +0100 MIME-Version: 1.0 In-Reply-To: <20201005170820.1018715-4-thomas@monjalon.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit 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" 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;