[PATCH v1 01/25] drivers/net: introduce a new PMD driver
Stephen Hemminger
stephen at networkplumber.org
Sun Dec 19 20:40:31 CET 2021
On Sat, 18 Dec 2021 10:51:28 +0800
Yanling Song <songyl at ramaxel.com> 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)
More information about the dev
mailing list