From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 83811A0524; Tue, 13 Apr 2021 10:58:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0BA45160CE9; Tue, 13 Apr 2021 10:58:20 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by mails.dpdk.org (Postfix) with ESMTP id 89997160CE7 for ; Tue, 13 Apr 2021 10:58:18 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 50D951A1C; Tue, 13 Apr 2021 04:58:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 13 Apr 2021 04:58:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm3; bh= 9uHkjYIZ00HbDFAHgTU9XBnJo+tEXwQSZWXb4f/+T5s=; b=csGeHKku0YaUooSZ hR5QOqKpzUGtUOwjYIBjLrfgOQbBFnrJFFiMDt+PonEAtHobi3javFdEC+JnRb4u hpVqJnIax9Vtwntn1b2xwzLixKyJH1q8ClR5jSO6U9VOblX5vzPXcBFwNdQKwtSC i4SD/EfK2cw+gB9KB47Am4wX5q6Udws7v4FsbxxkGj5rzYp57x57BrkreR4uHw4+ oDz1NR9AVe/p0snZr5ytbi9JWLXMGYF9hLa/EhTWtBct9Dx33Or9IMBMImr1+57s DDBia0VqjbXrkzmq94aPZH2nCJTIYeuxHhnFqcgVXljn5J1iQf7Th0q6ZrFmPKwW SulEYQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=9uHkjYIZ00HbDFAHgTU9XBnJo+tEXwQSZWXb4f/+T 5s=; b=JTMqY5h20qKUpzKZGjOdcUJkRC+MkeO5QoiG6nQie5bEy1Zxjc8zGa+M6 zsX3rPtNYdLVBfK4P31BiXgraFwmR8JuWDSoIcrMOa8eR0G0oLSjPAKMAOsThDng xiLq6pFwH/hPCJWudepk2X3ee6U5iXexvPAbQ/6txTouIZcmFyyNcvaOWyPa8Mau NdZ5oBjJ4OfcXuNHoEEsM1ZcCE7TTcnEGduhY+MRicnzouBw72V7DcpbRSBjDHJx ZwhGaZfZ7TOVKPElZJC0r0/EWrdRLGbPJGqyotsc/C6BU2CR5SlpsRGiMGTRs4Kl HYgATlWgc17YE2JWOhUMECk8gEIng== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudekledguddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkfgjfhgggfgtsehtufertddttddvnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepudeggfdvfeduffdtfeeglefghfeukefgfffhueejtdetuedtjeeu ieeivdffgeehnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id CD83D1080067; Tue, 13 Apr 2021 04:58:14 -0400 (EDT) From: Thomas Monjalon To: Andrew Rybchenko Cc: "Min Hu (Connor)" , dev@dpdk.org, ferruh.yigit@intel.com Date: Tue, 13 Apr 2021 10:58:13 +0200 Message-ID: <1950956.V83Gbnrlgs@thomas> In-Reply-To: References: <1618046334-39857-1-git-send-email-humin29@huawei.com> <1618284134-26152-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v2] ethdev: add sanity checks in control APIs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 13/04/2021 10:44, Andrew Rybchenko: > On 4/13/21 6:22 AM, Min Hu (Connor) wrote: > > @@ -678,6 +684,9 @@ rte_eth_dev_owner_set(const uint16_t port_id, > > { > > int ret; > > > > + if (owner == NULL) > > + return -EINVAL; > > + > > Here and in many-many cases below I think the order of checks > is important in cases when different error codes are returned. > When there is no any very good reasons why arguments should > be checked in different order, arguments should be checked in > order specified in function prototype. In this cases (and many > cases below), port_id should be checked first. > > In this particular case it means that the pointer check > should be done in a static helper function. > > One more point is error logging in the case of failure. > Right now I'd use RTE_ETHDEV_LOG(ERR, ...). May be later we'll > find out that some of messages should be made INFO or DEBUG. > Something like: > RTE_ETHDEV_LOG(ERR, "Failed to set ethdev port %u owner to NULL\n", > port_id); > > I'm not 100% sure in format, but my requirements are: > - log messages should be unique > - log messages should be human readable (i.e. I'd avoid > usage of function name) > - log messages should provide enough information to understand > what went wrong and provide context (basically it correlates > with uniqueness requirement) > > @Thomas, @Ferruh, what do you think? It would be good if we > reach an argement before mass changes are done? I agree with all your comments Andrew. > > @@ -2491,6 +2515,12 @@ rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt) > > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_done_cleanup, -ENOTSUP); > > > > + if (queue_id >= dev->data->nb_tx_queues) { > > + RTE_ETHDEV_LOG(ERR, "Queue id should be < %u.", > > + dev->data->nb_tx_queues); > > + return -EINVAL; > > + } > > + > > I'm not 100% sure that it is a control path. Indeed it can be used in the data path of some algorithms.