From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 9F0767F07 for ; Mon, 27 Oct 2014 01:51:53 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 26 Oct 2014 18:00:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,792,1406617200"; d="scan'208";a="621077271" Received: from pgsmsx101.gar.corp.intel.com ([10.221.44.78]) by fmsmga002.fm.intel.com with ESMTP; 26 Oct 2014 18:00:30 -0700 Received: from pgsmsx106.gar.corp.intel.com (10.221.44.98) by PGSMSX101.gar.corp.intel.com (10.221.44.78) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 27 Oct 2014 08:59:00 +0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by pgsmsx106.gar.corp.intel.com (10.221.44.98) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 27 Oct 2014 08:59:00 +0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.156]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.44]) with mapi id 14.03.0195.001; Mon, 27 Oct 2014 08:58:59 +0800 From: "Liang, Cunming" To: "Ananyev, Konstantin" , "dev@dpdk.org" Thread-Topic: [PATCH v5 3/3] ethdev: fix wrong error return refere to API definition Thread-Index: AQHP708dBo4fgaqTsE2WMsT0uMSYX5w+j+cAgASTwfA= Date: Mon, 27 Oct 2014 00:58:58 +0000 Message-ID: References: <1414129180-17669-1-git-send-email-cunming.liang@intel.com> <1414130090-17910-1-git-send-email-y> <1414130090-17910-4-git-send-email-y> <2601191342CEEE43887BDE71AB9772582139EBDC@IRSMSX105.ger.corp.intel.com> In-Reply-To: <2601191342CEEE43887BDE71AB9772582139EBDC@IRSMSX105.ger.corp.intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v5 3/3] ethdev: fix wrong error return refere to API definition X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Oct 2014 00:51:54 -0000 Ok, I'll roll back to v4. > -----Original Message----- > From: Ananyev, Konstantin > Sent: Friday, October 24, 2014 7:05 PM > To: dev@dpdk.org > Cc: nhorman@tuxdriver.com; Richardson, Bruce; De Lara Guarch, Pablo; Lian= g, > Cunming > Subject: RE: [PATCH v5 3/3] ethdev: fix wrong error return refere to API = definition >=20 >=20 >=20 > > -----Original Message----- > > From: y@ecsmtp.sh.intel.com [mailto:y@ecsmtp.sh.intel.com] > > Sent: Friday, October 24, 2014 6:55 AM > > To: dev@dpdk.org > > Cc: nhorman@tuxdriver.com; Richardson, Bruce; Ananyev, Konstantin; De L= ara > Guarch, Pablo; Liang, Cunming > > Subject: [PATCH v5 3/3] ethdev: fix wrong error return refere to API de= finition > > > > From: Cunming Liang > > > > Per definition, rte_eth_rx_burst/rte_eth_tx_burst/rte_eth_rx_queue_coun= t > returns the packet number. > > When RTE_LIBRTE_ETHDEV_DEBUG turns on, retval of FUNC_PTR_OR_ERR_RTE > was set to -ENOTSUP. > > It makes confusing. > > The patch always return 0 no matter no packet or there's error. > > Meanwhile set errno in such kind of checking. > > > > Signed-off-by: Cunming Liang > > --- > > lib/librte_ether/rte_ethdev.c | 10 +++++++--- > > 1 files changed, 7 insertions(+), 3 deletions(-) > > > > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethde= v.c > > index 50f10d9..6675f28 100644 > > --- a/lib/librte_ether/rte_ethdev.c > > +++ b/lib/librte_ether/rte_ethdev.c > > @@ -81,12 +81,14 @@ > > /* Macros for checking for restricting functions to primary instance o= nly */ > > #define PROC_PRIMARY_OR_ERR_RET(retval) do { \ > > if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) { \ > > + rte_errno =3D -E_RTE_SECONDARY; \ > > PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \ > > return (retval); \ > > } \ > > } while(0) > > #define PROC_PRIMARY_OR_RET() do { \ > > if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) { \ > > + rte_errno =3D -E_RTE_SECONDARY; \ > > PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \ > > return; \ > > } \ > > @@ -95,12 +97,14 @@ > > /* Macros to check for invlaid function pointers in dev_ops structure = */ > > #define FUNC_PTR_OR_ERR_RET(func, retval) do { \ > > if ((func) =3D=3D NULL) { \ > > + rte_errno =3D -ENOTSUP; \ > > PMD_DEBUG_TRACE("Function not supported\n"); \ > > return (retval); \ > > } \ > > } while(0) > > #define FUNC_PTR_OR_RET(func) do { \ > > if ((func) =3D=3D NULL) { \ > > + rte_errno =3D -ENOTSUP; \ > > PMD_DEBUG_TRACE("Function not supported\n"); \ > > return; \ > > } \ > > @@ -2530,7 +2534,7 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t > queue_id, > > return 0; > > } > > dev =3D &rte_eth_devices[port_id]; > > - FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, -ENOTSUP); > > + FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0); > > if (queue_id >=3D dev->data->nb_rx_queues) { > > PMD_DEBUG_TRACE("Invalid RX queue_id=3D%d\n", queue_id); > > return 0; > > @@ -2551,7 +2555,7 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t > queue_id, > > } > > dev =3D &rte_eth_devices[port_id]; > > > > - FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, -ENOTSUP); > > + FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0); > > if (queue_id >=3D dev->data->nb_tx_queues) { > > PMD_DEBUG_TRACE("Invalid TX queue_id=3D%d\n", queue_id); > > return 0; > > @@ -2570,7 +2574,7 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t > queue_id) > > return 0; > > } > > dev =3D &rte_eth_devices[port_id]; > > - FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP); > > + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0); > > return (*dev->dev_ops->rx_queue_count)(dev, queue_id); > > } >=20 > There are few things that worry me with that approach: >=20 > 1. Different behaviour of rte_eth_rx_burst/rte_eth_tx_burst for > RTE_LIBRTE_ETHDEV_DEBUG switched on/off. > So application might need to differentiate its code depending on > RTE_LIBRTE_ETHDEV_DEBUG value. >=20 > 2. Even for RTE_LIBRTE_ETHDEV_DEBUG is on the behaviour of rte_eth_rx_bur= st/ > rte_eth_tx_burst will be inconsistent: > It sets rte_errno if dev->rx_pkt_burst =3D=3D NULL, but doesn't do the sa= me for other > error conditions: > When port_id or queue_id is invalid. >=20 > 3. Modifying FUNC_PTR_OR_ERR_RET() to set rte_errno, we make behaviour of > other rte_ethdev functions inconsistent too: > Now for some error conditions they do set rte_errno, for others they don'= t. >=20 > So if it would be me, I'll just: > - leave FUNC_PTR_OR_*_RET unmodified. > - changes rte_eth_rx_burst/tx_burst for RTE_LIBRTE_ETHDEV_DEBUG something > like: >=20 > - FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, -ENOTSUP); > + FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0); >=20 > I think, that just error logging is enough here. >=20 > Konstantin >=20 > > > > -- > > 1.7.4.1