From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id DD93E2E8A for ; Mon, 30 Jan 2017 19:38:01 +0100 (CET) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 20F784F5; Mon, 30 Jan 2017 18:38:02 +0000 (UTC) Received: from dhcp-25-97.bos.redhat.com (dhcp-25-172.bos.redhat.com [10.18.25.172]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0UIc1a3000793 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 30 Jan 2017 13:38:01 -0500 From: Aaron Conole To: Stephen Hemminger Cc: Bruce Richardson , dev@dpdk.org References: <1485529023-5486-1-git-send-email-aconole@redhat.com> <1485529023-5486-26-git-send-email-aconole@redhat.com> <20170127083346.2bf55801@xeon-e3> <20170127164739.GB82692@bricha3-MOBL3.ger.corp.intel.com> <20170127093729.5cef9138@xeon-e3> Date: Mon, 30 Jan 2017 13:38:00 -0500 In-Reply-To: <20170127093729.5cef9138@xeon-e3> (Stephen Hemminger's message of "Fri, 27 Jan 2017 09:37:29 -0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 30 Jan 2017 18:38:02 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH 25/25] rte_eal_init: add info about rte_errno codes X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jan 2017 18:38:02 -0000 Stephen Hemminger writes: > On Fri, 27 Jan 2017 16:47:40 +0000 > Bruce Richardson wrote: > >> On Fri, Jan 27, 2017 at 08:33:46AM -0800, Stephen Hemminger wrote: >> > On Fri, 27 Jan 2017 09:57:03 -0500 >> > Aaron Conole wrote: >> > >> > > diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h >> > > index 03fee50..46e427f 100644 >> > > --- a/lib/librte_eal/common/include/rte_eal.h >> > > +++ b/lib/librte_eal/common/include/rte_eal.h >> > > @@ -159,7 +159,29 @@ int rte_eal_iopl_init(void); >> > > * function call and should not be further interpreted by the >> > > * application. The EAL does not take any ownership of the memory used >> > > * for either the argv array, or its members. >> > > - * - On failure, a negative error value. >> > > + * - On failure, -1 and rte_errno is set to a value indicating the cause >> > > + * for failure. >> > > + * >> > > + * The error codes returned via rte_errno: >> > > + * EACCES indicates a permissions issue. >> > > + * >> > > + * EAGAIN indicates either a bus or system resource was not available, >> > > + * try again. >> > > + * >> > > + * EALREADY indicates that the rte_eal_init function has already been >> > > + * called, and cannot be called again. >> > > + * >> > > + * EINVAL indicates invalid parameters were passed as argv/argc. >> > > + * >> > > + * EIO indicates failure to setup the logging handlers. This is usually >> > > + * caused by an out-of-memory condition. >> > > + * >> > > + * ENODEV indicates memory setup issues. >> > > + * >> > > + * ENOTSUP indicates that the EAL cannot initialize on this system. >> > > + * >> > > + * EUNATCH indicates that the PCI bus is either not present, or is not >> > > + * readable by the eal. >> > > */ >> > > int rte_eal_init(int argc, char **argv); >> > >> > Why use rte_errno? >> > Most DPDK calls just return negative value on error which >> > corresponds to error number. >> > Are you trying to keep ABI compatibility? Doesn't make sense >> > because before all these >> > errors were panic's no working application is going to care. >> >> Either will work, but I actually prefer this way. I view using rte_errno >> to be better as it can work in just about all cases, including with >> functions which return pointers. This allows you to have a standard >> method across all functions for returning error codes, and it only >> requires a single sentinal value to indicate error, rather than using a >> whole range of values. > > The problem is DPDK is getting more inconsistent on how this is done. > As long as error returns are always same as kernel/glibc errno's it really doesn't > matter much which way the value is returned from a technical point of view > but the inconsistency is sure to be a usability problem and source of errors. I am using rte_errno here because I assumed it was the preferred method. In fact, looking at some recently contributed modules (for instance pdump), it seems that folks are using it. I'm not really sure the purpose of having rte_errno if it isn't used, so it'd be helpful to know if there's some consensus on reflecting errors via this variable, or on returning error codes. Whichever is the more consistent with the way the DPDK project does things, I'm game :). Thanks for the thoughts, and review.