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 4A231A0548; Thu, 22 Apr 2021 23:54:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 10265410DB; Thu, 22 Apr 2021 23:54:57 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9B13040F35 for ; Thu, 22 Apr 2021 23:54:55 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1061) id D68FA20B8001; Thu, 22 Apr 2021 14:54:54 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D68FA20B8001 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1619128494; bh=ZCsUEVbLVmzeUV1KMTJhYuCtpRFbRYCLt2AeQGD+x7k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=izp10QNd7GbseysmtZryfpfMLA+9e4BO7ngKTh6nTwJlGjFDSR/WRnakh2XC+HY+g kAz/VLIe3FRWax0dWAuyE0TiK8Ioyvrse91bSp5EIQi0penEYvZYiR2DjxSVw0331O nH2b19eGZ5L4ip4jbQSpJ8JTv3JWtSeRFkQIvrKA= Date: Thu, 22 Apr 2021 14:54:54 -0700 From: Jie Zhou To: "Ananyev, Konstantin" Cc: "dev@dpdk.org" , "dmitry.kozliuk@gmail.com" , "Li, Xiaoyun" , "roretzla@microsoft.com" , "Kadam, Pallavi" , "thomas@monjalon.net" , "Richardson, Bruce" , "Yigit, Ferruh" Message-ID: <20210422215454.GA7096@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1618595864-27839-1-git-send-email-jizh@linux.microsoft.com> <1618874400-26819-1-git-send-email-jizh@linux.microsoft.com> <1618874400-26819-6-git-send-email-jizh@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [dpdk-dev] [PATCH v6 05/10] app/testpmd: add clock_gettime_monotonic 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, Apr 20, 2021 at 09:09:52AM +0000, Ananyev, Konstantin wrote: > > > > > > Add clock_gettime_monotonic for testpmd on Windows > > > > Signed-off-by: Jie Zhou > > Signed-off-by: Jie Zhou > > --- > > app/test-pmd/config.c | 33 ++++++++++++++++++++++++++++++++- > > 1 file changed, 32 insertions(+), 1 deletion(-) > > > > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > > index ef0b9784d..a5f8fec5b 100644 > > --- a/app/test-pmd/config.c > > +++ b/app/test-pmd/config.c > > @@ -63,6 +63,12 @@ > > > > #define NS_PER_SEC 1E9 > > > > +#ifdef RTE_EXEC_ENV_WINDOWS > > +#define _clock_gettime_monotonic(cur_time) clock_gettime_monotonic(&cur_time) > > +#else > > +#define _clock_gettime_monotonic(cur_time) clock_gettime(CLOCK_TYPE_ID, &cur_time) > > +#endif > > + > > static char *flowtype_to_str(uint16_t flow_type); > > > > static const struct { > > @@ -170,6 +176,27 @@ print_ethaddr(const char *name, struct rte_ether_addr *eth_addr) > > printf("%s%s", name, buf); > > } > > > > +#ifdef RTE_EXEC_ENV_WINDOWS > > Do we really need to pollute testpmd code with all these ifdefs? > Might be better to move it into a separate .h? Thanks Konstantin for the suggestion. In V7 move this into config.h, together with the NS_PER_SEC def etc. > > > +static int > > +clock_gettime_monotonic(struct timespec *tp) > > +{ > > + LARGE_INTEGER pf, pc; > > + LONGLONG nsec; > > + > > + if (QueryPerformanceFrequency(&pf) == 0) > > + return -1; > > + > > + if (QueryPerformanceCounter(&pc) == 0) > > + return -1; > > + > > + nsec = pc.QuadPart * NS_PER_SEC / pf.QuadPart; > > + tp->tv_sec = nsec / NS_PER_SEC; > > + tp->tv_nsec = nsec - tp->tv_sec * NS_PER_SEC; > > + > > + return 0; > > +} > > +#endif > > +