From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier Matz Subject: Re: [RFC 2/9] ethdev: move queue id check in generic layer Date: Thu, 24 Nov 2016 14:05:02 +0100 Message-ID: <1479992702.31853.9.camel@6wind.com> References: <1479981261-19512-1-git-send-email-olivier.matz@6wind.com> <1479981261-19512-3-git-send-email-olivier.matz@6wind.com> <174b8455-3806-26a1-38bd-edb756c101d0@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Cc: thomas.monjalon@6wind.com, konstantin.ananyev@intel.com, wenzhuo.lu@intel.com, helin.zhang@intel.com To: Ferruh Yigit , dev@dpdk.org Return-path: Received: from mail-wj0-f174.google.com (mail-wj0-f174.google.com [209.85.210.174]) by dpdk.org (Postfix) with ESMTP id 29A0F2BAC for ; Thu, 24 Nov 2016 14:05:03 +0100 (CET) Received: by mail-wj0-f174.google.com with SMTP id v7so33088578wjy.2 for ; Thu, 24 Nov 2016 05:05:03 -0800 (PST) In-Reply-To: <174b8455-3806-26a1-38bd-edb756c101d0@intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Ferruh, On Thu, 2016-11-24 at 10:59 +0000, Ferruh Yigit wrote: > On 11/24/2016 9:54 AM, Olivier Matz wrote: > > The check of queue_id is done in all drivers implementing > > rte_eth_rx_queue_count(). Factorize this check in the generic > > function. > > > > Note that the nfp driver was doing the check differently, which > > could > > induce crashes if the queue index was too big. > > > > By the way, also move the is_supported test before the port valid > > and > > queue valid test. > > > > PR=52423 > > Signed-off-by: Olivier Matz > > Acked-by: Ivan Boule > > --- > > <...> > > > diff --git a/lib/librte_ether/rte_ethdev.h > > b/lib/librte_ether/rte_ethdev.h > > index c3edc23..9551cfd 100644 > > --- a/lib/librte_ether/rte_ethdev.h > > +++ b/lib/librte_ether/rte_ethdev.h > > @@ -2693,7 +2693,7 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t > > queue_id, > >   *  The queue id on the specific port. > >   * @return > >   *  The number of used descriptors in the specific queue, or: > > - *     (-EINVAL) if *port_id* is invalid > > + *     (-EINVAL) if *port_id* or *queue_id* is invalid > >   *     (-ENOTSUP) if the device does not support this function > >   */ > >  static inline int > > @@ -2701,8 +2701,10 @@ rte_eth_rx_queue_count(uint8_t port_id, > > uint16_t queue_id) > >  { > >   struct rte_eth_dev *dev = &rte_eth_devices[port_id]; > >   > > - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); > >   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, > > -ENOTSUP); > > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); > > Doing port validity check before accessing dev->dev_ops- > >rx_queue_count > can be good idea. > > What about validating port_id even before accessing > rte_eth_devices[port_id]? > oops right, we should not move this line, it's stupid... Thanks for the feedback, Olivier