From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 33C557E7E for ; Fri, 24 Oct 2014 12:56:18 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 24 Oct 2014 04:04:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="405330319" Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by FMSMGA003.fm.intel.com with ESMTP; 24 Oct 2014 03:56:59 -0700 Received: from irsmsx107.ger.corp.intel.com (163.33.3.99) by IRSMSX104.ger.corp.intel.com (163.33.3.159) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 24 Oct 2014 12:04:44 +0100 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.56]) by IRSMSX107.ger.corp.intel.com ([169.254.10.21]) with mapi id 14.03.0195.001; Fri, 24 Oct 2014 12:04:44 +0100 From: "Ananyev, Konstantin" To: "dev@dpdk.org" Thread-Topic: [PATCH v5 3/3] ethdev: fix wrong error return refere to API definition Thread-Index: AQHP708d/kqYZhuLy0yRJPTJBp5XmJw/EXYQ Date: Fri, 24 Oct 2014 11:04:44 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772582139EBDC@IRSMSX105.ger.corp.intel.com> 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> In-Reply-To: <1414130090-17910-4-git-send-email-y> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] 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: Fri, 24 Oct 2014 10:56:18 -0000 > -----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 Lar= a Guarch, Pablo; Liang, Cunming > Subject: [PATCH v5 3/3] ethdev: fix wrong error return refere to API defi= nition >=20 > From: Cunming Liang >=20 > Per definition, rte_eth_rx_burst/rte_eth_tx_burst/rte_eth_rx_queue_count = 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. >=20 > Signed-off-by: Cunming Liang > --- > lib/librte_ether/rte_ethdev.c | 10 +++++++--- > 1 files changed, 7 insertions(+), 3 deletions(-) >=20 > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.= 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 onl= y */ > #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]; >=20 > - 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 qu= eue_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); > } There are few things that worry me with that approach: 1. Different behaviour of rte_eth_rx_burst/rte_eth_tx_burst for RTE_LIBRT= E_ETHDEV_DEBUG switched on/off. So application might need to differentiate its code depending on RTE_LIBRT= E_ETHDEV_DEBUG value. 2. Even for RTE_LIBRTE_ETHDEV_DEBUG is on the behaviour of rte_eth_rx_burst= / rte_eth_tx_burst will be inconsistent: It sets rte_errno if dev->rx_pkt_burst =3D=3D NULL, but doesn't do the same= for other error conditions: When port_id or queue_id is invalid. 3. Modifying FUNC_PTR_OR_ERR_RET() to set rte_errno, we make behaviour of o= ther rte_ethdev functions inconsistent too: Now for some error conditions they do set rte_errno, for others they don't. 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 l= ike: - FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, -ENOTSUP); + FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0); I think, that just error logging is enough here. =20 Konstantin >=20 > -- > 1.7.4.1