From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8E4DBA034E; Thu, 23 Apr 2020 17:18:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6CBDD1C2F8; Thu, 23 Apr 2020 17:18:42 +0200 (CEST) Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by dpdk.org (Postfix) with ESMTP id 2EBD51C1DA for ; Thu, 23 Apr 2020 17:18:41 +0200 (CEST) Received: by mail-lf1-f65.google.com with SMTP id 131so5036820lfh.11 for ; Thu, 23 Apr 2020 08:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ama14jX8PSUUxzYm7FEWfun4B5xWmFB53VwzoEnUWlc=; b=DGKzhqzbw7TsQquckPWFHpFAgfuYdhcDgBe5c7TASfzBe/BsTYkV/NZbadcQTUADQt pXT9Z8DYrIMHDz5VemBgV1AeGctIi3XJ+ip0gIJptxDRd1QSjBoQsrtTv1cKf2NWDzmN EwcJ6s8fxkytajKkwMM/tjyRVKXMXfpYsJNAwm0rtsE4DMt1z39mQzmMqe41aIAfzYuS Ns6Ege3Z2/a/SNygW5FEuLE7mEKPLNpMktDBmgOgt8Q4bwEj6ASrktk4Fj4oVkxK52ri dxQg2SZHCpKUiw49Gj5fAygk4p4xl3mE6sllwKvt4PENvgjzDXLkRyBHssL+NjzR2Tot U60Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ama14jX8PSUUxzYm7FEWfun4B5xWmFB53VwzoEnUWlc=; b=skA1b8S3zhOMIh+gmI4olsGzjNS0nemWdRnOZQy8516b6J/LAaesc54Bc5w/bEq3+g 8LYznH1YkKqbboBwFInZiBB+BB4HGr5SH937QmO6d3nHvs5uDxLvs9ctaypgcu5fa4SL xXe8gOoBjCH3SV+3OgzNk1KH22y6QTkIGswQ4oVTWAjsWPK6M/n/5yo/7LE9H/M/g7lJ uQ+4/W5M99TCHoQdogaKWDZJ6NEymdO3f6NebRFlO62hwSyBtEOj7KtaXppcj0BSrR4p qP+uSTNsJdKXUB1Y8iQ4YystuElMUarOfXBRVTnRgHZaB9BimRPmWuhE3eW97wHhl6kh QDvA== X-Gm-Message-State: AGi0PuYVVIh0oItPGDX7I0iY0J9LpdLKHZm0SMqrjEaG0UKbwfwv04Oq 2EwZKvaDVUlNenjl7H7/EIg= X-Google-Smtp-Source: APiQypI7eKgbetHca9C7Qsw2fxkYm8CO2PQU4HeuoPBWxAaFyDpeIf9vcTQ7669nQ76Mf6zwFpeOBw== X-Received: by 2002:ac2:58cb:: with SMTP id u11mr2733171lfo.185.1587655120683; Thu, 23 Apr 2020 08:18:40 -0700 (PDT) Received: from Sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id i123sm2096514lji.69.2020.04.23.08.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 08:18:39 -0700 (PDT) Date: Thu, 23 Apr 2020 18:18:38 +0300 From: Dmitry Kozlyuk To: Fady Bader Cc: dev@dpdk.org, thomas@monjalon.net, talshn@mellanox.com, dmitry.koziuk@gmail.com, harini.ramakrishnan@microsoft.com, ocardona@microsoft.com, anand.rawat@intel.com, ranjit.menon@intel.com Message-ID: <20200423181838.7e37c6c9@Sovereign> In-Reply-To: <20200423144350.4016-3-fady@mellanox.com> References: <20200423144350.4016-1-fady@mellanox.com> <20200423144350.4016-3-fady@mellanox.com> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 2/2] timer: support EAL functions on Windows 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 2020-04-23 17:43 GMT+0300 Fady Bader wrote: [snip] > diff --git a/lib/librte_eal/windows/eal_timer.c b/lib/librte_eal/windows/eal_timer.c > new file mode 100644 > index 000000000..73eaff948 > --- /dev/null > +++ b/lib/librte_eal/windows/eal_timer.c > @@ -0,0 +1,67 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright 2020 Mellanox Technologies, Ltd > + */ > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* The frequency of the RDTSC timer resolution */ > +static uint64_t eal_tsc_resolution_hz; > + > +void > +rte_delay_us_sleep(unsigned int us) > +{ > + LONGLONG ns = us * 1000; > + HANDLE timer; > + LARGE_INTEGER liDueTime; Shouldn't Windows code follow DPDK naming conventions? > + /* create waitable timer */ > + timer = CreateWaitableTimer(NULL, TRUE, NULL); > + if(!timer){ Missing spaces. There are more styling issues below that could be detected by running ./devtools/checkpatches.sh. > + /* didnt find any better errno val */ > + rte_errno = EINVAL; > + return; ENOMEM probably indicates lack of resources better. EINVAL usually implies wrong arguments to the function. You can also use RTE_WIN32_LOG_ERR() here to log exact error code on debug level. > + } > + > + /* set us microseconds time for timer */ > + liDueTime.QuadPart = -ns; Timeout is neither in microseconds, nor in nanoseconds, it's in 100-nanosecond intervals. > + if(!SetWaitableTimer(timer, &liDueTime, 0, NULL, NULL, FALSE)){ > + CloseHandle(timer); > + /* didnt find any better errno val */ > + rte_errno = EFAULT; And here, EINVAL is probably better, because result depends on function argument and this probably will be the most frequent source of errors. > + return; > + } > + /* start wait for timer for us microseconds */ > + WaitForSingleObject(timer, INFINITE); > + CloseHandle(timer); > +} [snip] > diff --git a/lib/librte_eal/windows/include/rte_os.h b/lib/librte_eal/windows/include/rte_os.h > index 62805a307..951a14d72 100644 > --- a/lib/librte_eal/windows/include/rte_os.h > +++ b/lib/librte_eal/windows/include/rte_os.h > @@ -24,6 +24,8 @@ extern "C" { > #define PATH_MAX _MAX_PATH > #endif > > +#define sleep(x) Sleep(1000 * x) It's better to enclose "x" in parentheses or to use inline function. -- Dmitry Kozlyuk