From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=wx6OsQW0N/ozE6+HXBAxkVLAZAxyH0tsMqPLkxoQbt8=; b=QVrrGF6ap7k+ZRa4PuPOPIlfsUaMEa+QNQfjdEH1lgKE2Cne8syqsM2GMPNCWcHzAM i6dvnqYI7sDN9FuGgzjr2PleuFmHQQvE3tlhD6MY356oJXVrdpY/wkQjbTl3Zld4aYJ+ g29ExMw8LU2L1LqcXjkNVDzeurWvCCPPvVwV7CT8DwV7F2a56qbjlUcaxcHms+EepqG9 otP9qdq+UvHZdNPCnwoN9UloFTpXhB+EmB2VaL9KwbQ/ODEA/8BtTsr7CYMX3e9f2dzl lrAnSD6Nesu4N9GLP+scWcL9+GxPQCGeWFuAf72IngBLXbZvXdcfLhld/lPScI90vF7L b6PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=wx6OsQW0N/ozE6+HXBAxkVLAZAxyH0tsMqPLkxoQbt8=; b=mtsTW9C3rPt9GiadkbgHhHT6JOQhcBf315eB3mB2u1uuD8MweFUwz8J4mtjgIg6K6p L3IIZog4+pa+Pm6qzzajY6D2OD15ET4DWEQukHmu7inq3QAozO3TC37NI3oMRqyj3Use WnbRfL4i6GmTdCBE9WIb7RDksSbbE4LQCqYlprW3Llmde08edg4DJ7Ok9sabN85jkY8U 1ICYwDdvWGPpjd8kOtPOsSAadfaTONaJJk+hSKyhz9TsliIKiG572mMD4EIKPbtB/xDK TYY7p281OJwFOkJ3VJDmy/MMJUJQUhujZRIPxHMACZA7KBJ1eVkQszM3m296eYjvuLak larQ== X-Gm-Message-State: AKaTC03kneZtOpAgjemtx5AE757I0HgITQCxzJycysEFVfwFJ9e6ZLW+quPGXbE+Sx9NtdGH X-Received: by 10.195.18.201 with SMTP id go9mr2258997wjd.200.1479992703495; Thu, 24 Nov 2016 05:05:03 -0800 (PST) Received: from 2a01cb0c08e311000226b0fffeed02fc.ipv6.abo.wanadoo.fr (2a01cb0c08e311000226b0fffeed02fc.ipv6.abo.wanadoo.fr. [2a01:cb0c:8e3:1100:226:b0ff:feed:2fc]) by smtp.gmail.com with ESMTPSA id d8sm8122113wmi.21.2016.11.24.05.05.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Nov 2016 05:05:02 -0800 (PST) Message-ID: <1479992702.31853.9.camel@6wind.com> From: Olivier Matz To: Ferruh Yigit , dev@dpdk.org Cc: thomas.monjalon@6wind.com, konstantin.ananyev@intel.com, wenzhuo.lu@intel.com, helin.zhang@intel.com Date: Thu, 24 Nov 2016 14:05:02 +0100 In-Reply-To: <174b8455-3806-26a1-38bd-edb756c101d0@intel.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> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.2-1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [RFC 2/9] ethdev: move queue id check in generic layer 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: Thu, 24 Nov 2016 13:05:04 -0000 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