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 69DD9A0C3F; Thu, 15 Apr 2021 14:43:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 12E711621A3; Thu, 15 Apr 2021 14:43:02 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 30461162135 for ; Thu, 15 Apr 2021 14:43:01 +0200 (CEST) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 96A837F40D; Thu, 15 Apr 2021 15:43:00 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 96A837F40D DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1618490580; bh=pztPogQH+chEHNrpFdPGytALqNExnNFlt4bbk7VqrS4=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=WDsAJRCMoNEtdaVWPc3pJmSF4ENsiflMTE6pyGk6psaidwhI3T27XlLrQgym9NE7R gCKMnK7EuZANVmWMuWOVm6FAHVZdGVy/QBn1qgrvmzRC3gCE8LVa1kgI1ig2ZmhwT9 aw+E2fLAL3/x983W5dzq5gHFlObhZjn9IabKQ6Kc= To: Thomas Monjalon Cc: "Min Hu (Connor)" , dev@dpdk.org, ferruh.yigit@intel.com References: <1618046334-39857-1-git-send-email-humin29@huawei.com> <2252218.jVnlyW2HoW@thomas> <2363949.PJJJZldJTC@thomas> From: Andrew Rybchenko Organization: OKTET Labs Message-ID: <5f169a6e-9e45-f842-bdd9-0f2ad4aa9607@oktetlabs.ru> Date: Thu, 15 Apr 2021 15:43:00 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <2363949.PJJJZldJTC@thomas> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v4] 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" On 4/15/21 3:20 PM, Thomas Monjalon wrote: > 15/04/2021 14:03, Andrew Rybchenko: >> On 4/15/21 2:57 PM, Thomas Monjalon wrote: >>> 15/04/2021 10:15, Andrew Rybchenko: >>>>> RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP); >>>> In theory, the first argument is sufficient to make the ops >>>> check, but I think it is the right solution to keep it as is >>>> since current tendency is to check operation support when >>>> driver callback is really required and we're going to use it. >>>> However, if we do it just after port_id check, we'll have a >>>> way to check for callback support without any side effects >>>> if we provide invalid argument value. I.e. if -ENOTSUP is >>>> returned, callback is not supported, if -EINVAL, callback is >>>> supported (but argument is invalid and nothing done). >>>> However, it looks a bit fragile and not always possible. >>>> Thoughts on it are welcome. >>> Sorry I don't understand it fully. >>> You say we should check for ENOTSUP at the very beginning? >> >> I'm just trying to consider it and understand if it would be >> right or wrong. > > I think it's better to check things when they are required. > If the application does not give the right parameter, > it won't be caught until a supporting device will be used. > > If the appplication gives the wrong parameter on purpose, > because it won't be supported, then it's better not calling the function. > OK, makes sense.