From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by dpdk.org (Postfix) with ESMTP id 1C5E720F for ; Tue, 17 Nov 2015 16:53:13 +0100 (CET) Received: by pacdm15 with SMTP id dm15so12451363pac.3 for ; Tue, 17 Nov 2015 07:53:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber_org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=mv4GowTB8NLBzVeNh3VJbqVqc/9J0S9IwEv2YmcLYnQ=; b=PZI1uwuSokVds3+VNe9ZpDMjgwNG6g6zOlqf1bFy0T34QaNVU1WDdCqQg/M3G7eJL6 k5LNSAS4F5PGMjT8jmUwrCCSdlS3owqmkj/ei9hN/dVy2vXC1lh5PChdUMD501rjIsnz L7xP8+3LC5qrxj0dOr5Au9i6LLIxHUsK2gcrTPVTNtBL7RCdbY69u6otKdC/H7hg4Wnz H9eLF54ov4A1R3NjRkxdQyUQlK+LF79BMjkKEJ4wiXRv0yeBLRcJsNUvZL4wrp+eVLPR nJzHMLpUBe2ZIBIC8tITi7SxAwpWtbECubk/e613Jpr639EgdbeNfN3UmpQgdRj2+76G CvWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=mv4GowTB8NLBzVeNh3VJbqVqc/9J0S9IwEv2YmcLYnQ=; b=mIWj8Otvc/lr8XtmTJcb+meuM0PTEnF/h/qqW6GIteeqOjcIGxhIdNMrAJmRFW3MII yP2FEKeluJgNxLO3J+a+tZLgOEaY2zgkOhfnq4QuOuGVG434LZu4ntb3Nm8sDbuW0In3 Xjhivuh7y66O4B/tyi4EF2+c3jSPUZ8aQp1QM8TzZ/x1SmU4yBVmBWfjkhFkehdmpOqB 1ZgAVi95LqI16edFub9N21ntkAawT5nRyx1Xf+oseiEaeIKz2ArvhrL9XJp6e3ZSroHH 3zp5LnSwgWKaswRFOqUDhVj6DlVypn+dbcCovLRDce7jD/O7QGH4h8YGyBOU7hCzn53M R1lA== X-Gm-Message-State: ALoCoQlncEEBSC/DjGkojQsW0FpZ+nifH1r9l0cXpMk3qlDNNEB2q0+FacY9HnwU/Js3fp+wgl7h X-Received: by 10.66.150.228 with SMTP id ul4mr24029454pab.15.1447775592487; Tue, 17 Nov 2015 07:53:12 -0800 (PST) Received: from samsung9 (ip-64-134-231-5.public.wayport.net. [64.134.231.5]) by smtp.gmail.com with ESMTPSA id j5sm33183208pbq.74.2015.11.17.07.53.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Nov 2015 07:53:12 -0800 (PST) Date: Tue, 17 Nov 2015 07:53:09 -0800 From: Stephen Hemminger To: Bruce Richardson Message-ID: <20151117075309.7f05dc3a@samsung9> In-Reply-To: <1447762867-32124-3-git-send-email-bruce.richardson@intel.com> References: <1446552059-5446-1-git-send-email-bruce.richardson@intel.com> <1447762867-32124-1-git-send-email-bruce.richardson@intel.com> <1447762867-32124-3-git-send-email-bruce.richardson@intel.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v4 2/2] ethdev: add sanity checks to functions 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: Tue, 17 Nov 2015 15:53:13 -0000 On Tue, 17 Nov 2015 12:21:07 +0000 Bruce Richardson wrote: > The functions rte_eth_rx_queue_count and rte_eth_descriptor_done are > supported by very few PMDs. Therefore, it is best to check for support > for the functions in the ethdev library, so as to avoid run-time crashes > at run-time if the application goes to use those APIs. Similarly, the > port parameter should also be checked for validity. > > Signed-off-by: Bruce Richardson > > --- > lib/librte_ether/rte_ethdev.h | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h > index a00cd46..028be59 100644 > --- a/lib/librte_ether/rte_ethdev.h > +++ b/lib/librte_ether/rte_ethdev.h > @@ -2533,16 +2533,16 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id, > * @param queue_id > * The queue id on the specific port. > * @return > - * The number of used descriptors in the specific queue. > + * The number of used descriptors in the specific queue, or: > + * (-EINVAL) if *port_id* is invalid > + * (-ENOTSUP) if the device does not support this function > */ > -static inline uint32_t > +static inline int > rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id) > { > struct rte_eth_dev *dev = &rte_eth_devices[port_id]; > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG > - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0); > - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0); > -#endif > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP); > return (*dev->dev_ops->rx_queue_count)(dev, queue_id); > } > > @@ -2559,15 +2559,14 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id) > * - (1) if the specific DD bit is set. > * - (0) if the specific DD bit is not set. > * - (-ENODEV) if *port_id* invalid. > + * - (-ENOTSUP) if the device does not support this function > */ > static inline int > rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset) > { > struct rte_eth_dev *dev = &rte_eth_devices[port_id]; > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP); > -#endif > return (*dev->dev_ops->rx_descriptor_done)( \ > dev->data->rx_queues[queue_id], offset); > } This breaks ABI since older application built with debug will try and find the shared library entry for the routine.