[PATCH v1 01/25] drivers/net: introduce a new PMD driver
Yanling Song
songyl at ramaxel.com
Wed Dec 22 01:54:00 CET 2021
On Sun, 19 Dec 2021 11:40:31 -0800
Stephen Hemminger <stephen at networkplumber.org> wrote:
> 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.
>
OK. #ifdef will be removed in the next version.
>
> +
> +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.
>
I did not get your point: CLOCK_MONOTONIC is more accurate than
CLOCK_MONOTONIC_COARSE, right?
>
> +#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)
OK. Will be changed in the next version.
More information about the dev
mailing list