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 7C34AA034C; Sun, 19 Dec 2021 20:40:37 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A998F40395; Sun, 19 Dec 2021 20:40:36 +0100 (CET) Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by mails.dpdk.org (Postfix) with ESMTP id 7F03540140 for ; Sun, 19 Dec 2021 20:40:35 +0100 (CET) Received: by mail-pf1-f176.google.com with SMTP id t19so559522pfg.9 for ; Sun, 19 Dec 2021 11:40:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9vHcQ9wnyQSlzaKYMPeLL/h2kbqNHa80nz7hMfI+zPc=; b=hfKrqat8eCDQgOhg4TACNuQhb894LnE9BDq0d9wK/tsosprWTUDtFGhFeHrO0A3SZn 7StBiUOgz8HAqFePDC7hw3x/PZexihfOm+mgGMANy6d+YfiZ64gE0csEzsl1iZBbE6h9 ObvqtWdh61FgA//MIa5GCfhxVu/aXq3BTFmYTBVF1m4UGj3LVh33gjM2RaZSfnDw84h/ zRFjHhVm2Z333NJQvTv0YKBzCAt5UhGjTKRieOG/Mh9xo6qcM+L3XcAnGfBuNs4g1Dwt 68oU+e4dw8ixuBs4YOp5ps2m7251uRbQoGL+sGhKkZuze4cbRW46Bqie6MOq6TH4iCSs 7g9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9vHcQ9wnyQSlzaKYMPeLL/h2kbqNHa80nz7hMfI+zPc=; b=SAwUcRli2nAhHoCoM9coB8Qi/WzoNkENlsv3e2j4EXlgLjAHN/VPpMt6+Sty+MQbTK S6YF3XXi8q8KV4oK7sqXF0YUlRYOVDJE6wt1+ogyF9zXf/13I2oYCWXNeOZ9ZLDWmG5O o3vHieGaxvcOnh8F9AaIa0oJrbt+bc37P20BZlJ+DgU5QfwUYAjf4b1vpkuQ9+GHnFaC Q8jmYLcqLIg/eSIsgXW49prtnwvZqNmVft5hUHbLcpVJeQVz8IgbRCiutuWpZCjWy3BI SEdUeC4bmXOkw06yzZMXe+jQMoPt9EHsphZZSiP0ksV7aiVjl1kyJjJ6z/TAS86xduKE i8UQ== X-Gm-Message-State: AOAM532mVhNk/wFL9yzrS2SIMh8THyvyiVdKI/GUdHz+RdvZulJP126l lNUG4MkhdkFKWXcZ1Zx8norhCw== X-Google-Smtp-Source: ABdhPJy2ly6WEK8WIunwhtsVOVWStdM/jzITSc4ONJ3mA+noiAqA9Vt9EdfzoMNic9pYz4ooFbIvfA== X-Received: by 2002:a63:ef4f:: with SMTP id c15mr11732002pgk.322.1639942834522; Sun, 19 Dec 2021 11:40:34 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id q2sm3252393pfu.66.2021.12.19.11.40.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Dec 2021 11:40:34 -0800 (PST) Date: Sun, 19 Dec 2021 11:40:31 -0800 From: Stephen Hemminger To: Yanling Song Cc: , , , Subject: Re: [PATCH v1 01/25] drivers/net: introduce a new PMD driver Message-ID: <20211219114031.146a4c1e@hermes.local> In-Reply-To: <913359f582b165a3fcfe5efbd4dab76476690a53.1639636621.git.songyl@ramaxel.com> References: <913359f582b165a3fcfe5efbd4dab76476690a53.1639636621.git.songyl@ramaxel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Sat, 18 Dec 2021 10:51:28 +0800 Yanling Song wrote: > +#ifdef CLOCK_MONOTONIC_RAW /* Defined in glibc bits/time.h */ > +#define CLOCK_TYPE CLOCK_MONOTONIC_RAW > +#else > +#define CLOCK_TYPE CLOCK_MONOTONIC > +#endif CLOCK_MONOTONIC_RAW was defined in Linux.2.6.28 DPDK does not support any kernels that old, so the #ifdef is not needed. + +static inline unsigned long clock_gettime_ms(void) +{ + struct timespec tv; + + (void)clock_gettime(CLOCK_TYPE, &tv); + + return (unsigned long)tv.tv_sec * SPNIC_S_TO_MS_UNIT + + (unsigned long)tv.tv_nsec / SPNIC_S_TO_NS_UNIT; +} If all you want is jiffie accuracy, you could use CLOCK_MONOTONIC_COARSE. +#define jiffies clock_gettime_ms() +#define msecs_to_jiffies(ms) (ms) +#define time_before(now, end) ((now) < (end)) Does that simple version of the macro work right if jiffies wraps around? Less of an issue on 64 bit platforms... The kernel version is effectively. #define time_before(now, end) ((long)((now) - (end)) < 0)