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 23829A0C4B; Tue, 9 Nov 2021 03:02:46 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE92240E03; Tue, 9 Nov 2021 03:02:45 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 950F340687 for ; Tue, 9 Nov 2021 03:02:44 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1059) id B781520B9D59; Mon, 8 Nov 2021 18:02:43 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B781520B9D59 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1636423363; bh=KyKGw91buyYugK+fXqDo/npotqpo6ZsMjhO3v98FBlY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KJ1Tqr2otfbeY8dTh9w9Hb7GJCtfvX5h/JZcVCDk1D7Adf2PNltmczlZ1MLrAONEr 6ypNjLBbL7FodC/7aFL5XfV6l4sWlOa7mQSVxFeeG7J46Dp7aRNpFjysxIG7b2lVRe MDpUpFoewgIsvIq628LVM3NPVK6oeTp1cCGWImbU= Date: Mon, 8 Nov 2021 18:02:43 -0800 From: Narcisa Ana Maria Vasile To: Thomas Monjalon Cc: dev@dpdk.org, dmitry.kozliuk@gmail.com, khot@microsoft.com, navasile@microsoft.com, dmitrym@microsoft.com, roretzla@microsoft.com, talshn@nvidia.com, ocardona@microsoft.com, bruce.richardson@intel.com, david.marchand@redhat.com, pallavi.kadam@intel.com Message-ID: <20211109020243.GC12569@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1633732841-17873-1-git-send-email-navasile@linux.microsoft.com> <1633765318-28356-1-git-send-email-navasile@linux.microsoft.com> <1633765318-28356-4-git-send-email-navasile@linux.microsoft.com> <2707621.neF2WRQu8d@thomas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2707621.neF2WRQu8d@thomas> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [dpdk-dev] [PATCH v16 3/9] eal/windows: translate Windows errors to errno-style errors 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 Tue, Oct 12, 2021 at 06:16:19PM +0200, Thomas Monjalon wrote: > 09/10/2021 09:41, Narcisa Ana Maria Vasile: > > From: Narcisa Vasile > > > > Add function to translate Windows error codes to > > errno-style error codes. The possible return values are chosen > > so that we have as much semantical compatibility between platforms as > > possible. > > > > Signed-off-by: Narcisa Vasile > > --- > > lib/eal/common/rte_thread.c | 6 +-- > > lib/eal/include/rte_thread.h | 5 +- > > lib/eal/windows/rte_thread.c | 95 +++++++++++++++++++++++++++--------- > > 3 files changed, 76 insertions(+), 30 deletions(-) > > > > diff --git a/lib/eal/common/rte_thread.c b/lib/eal/common/rte_thread.c > > index e1a4d7eae4..27ad1c7eb0 100644 > > --- a/lib/eal/common/rte_thread.c > > +++ b/lib/eal/common/rte_thread.c > > @@ -47,7 +47,7 @@ rte_thread_attr_init(rte_thread_attr_t *attr) > > > > int > > rte_thread_attr_set_affinity(rte_thread_attr_t *thread_attr, > > - rte_cpuset_t *cpuset) > > + rte_cpuset_t *cpuset) > > { > > RTE_VERIFY(thread_attr != NULL); > > RTE_VERIFY(cpuset != NULL); > > @@ -59,7 +59,7 @@ rte_thread_attr_set_affinity(rte_thread_attr_t *thread_attr, > > > > int > > rte_thread_attr_get_affinity(rte_thread_attr_t *thread_attr, > > - rte_cpuset_t *cpuset) > > + rte_cpuset_t *cpuset) > > { > > RTE_VERIFY(thread_attr != NULL); > > RTE_VERIFY(cpuset != NULL); > > @@ -71,7 +71,7 @@ rte_thread_attr_get_affinity(rte_thread_attr_t *thread_attr, > > > > int > > rte_thread_attr_set_priority(rte_thread_attr_t *thread_attr, > > - enum rte_thread_priority priority) > > + enum rte_thread_priority priority) > > Above are unrelated changes. > Thanks, will fix! > > --- a/lib/eal/windows/rte_thread.c > > +++ b/lib/eal/windows/rte_thread.c > > @@ -13,6 +13,54 @@ struct eal_tls_key { > > DWORD thread_index; > > }; > > > > +/* Translates the most common error codes related to threads */ > > +static int > > +thread_translate_win32_error(DWORD error) > > So you decide to adopt POSIX error codes for the DPDK API. OK > > > +{ > > + switch (error) { > > + case ERROR_SUCCESS: > > + return 0; > > + > > + case ERROR_INVALID_PARAMETER: > > + return EINVAL; > > + > > + case ERROR_INVALID_HANDLE: > > + return EFAULT; > > + > > + case ERROR_NOT_ENOUGH_MEMORY: > > + /* FALLTHROUGH */ > > + case ERROR_NO_SYSTEM_RESOURCES: > > + return ENOMEM; > > + > > + case ERROR_PRIVILEGE_NOT_HELD: > > + /* FALLTHROUGH */ > > + case ERROR_ACCESS_DENIED: > > + return EACCES; > > + > > + case ERROR_ALREADY_EXISTS: > > + return EEXIST; > > + > > + case ERROR_POSSIBLE_DEADLOCK: > > + return EDEADLK; > > + > > + case ERROR_INVALID_FUNCTION: > > + /* FALLTHROUGH */ > > + case ERROR_CALL_NOT_IMPLEMENTED: > > + return ENOSYS; > > + } > > + > > + return EINVAL; > > +} > [...] > > rte_thread_key_create(rte_thread_key *key, > > __rte_unused void (*destructor)(void *)) > > { > > + int ret; > > + > > *key = malloc(sizeof(**key)); > > if ((*key) == NULL) { > > RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n"); > > - rte_errno = ENOMEM; > > - return -1; > > + return ENOMEM; > > } > > Why this change? rte_errno and negative error code are good. > This error could have been handled using rte_errno and negative return, but for consistency, a positive error number is returned. As different platforms have different error codes, the approach here is to translate the Windows error to POSIX-style ones to have uniformity over the values returned. All functions in this thread module return the possible error through the return value. >