[PATCH v19 02/13] net/sxe: add ethdev probe and remove

Stephen Hemminger stephen at networkplumber.org
Sat Mar 21 18:18:59 CET 2026


On Sat, 14 Mar 2026 16:51:54 +0800
liujie5 at linkdatatechnology.com wrote:

> diff --git a/drivers/net/sxe/base/sxe_common.c b/drivers/net/sxe/base/sxe_common.c
> new file mode 100644
> index 0000000000..8f3e80fae3
> --- /dev/null
> +++ b/drivers/net/sxe/base/sxe_common.c
> @@ -0,0 +1,45 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright (C), 2022, Linkdata Technology Co., Ltd.
> + */
> +
> +#include <pthread.h>
> +#include <sys/time.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <rte_common.h>
> +#include <rte_cycles.h>
> +#include <time.h>
> +#include "sxe_types.h"
> +#include "sxe_common.h"
> +
> +#define SXE_SEC_TO_MS(sec) ((sec) * 1000ULL)
> +
> +#define SXE_NSEC_PER_MS		  1000000
> +
> +RTE_ATOMIC(uint64_t) sxe_trace_id;

Could this be static.

> +
> +u64 sxe_time_get_real_ms(void)
> +{
> +	u64 ms = 0;
> +	struct timespec ts;
> +	s32 ret = clock_gettime(CLOCK_MONOTONIC, &ts);

If you are only looking at ms then you might be able to CLOCK_MONOTONIC_COARSE

> +	if (ret < 0)
> +		goto l_end;

Could be simpler as:

	if (unlikely(clockgettime(CLOCK_MONOTONIC, &ts) < 0))
		return 0;

> +
> +	ms = SXE_SEC_TO_MS(ts.tv_sec) + ts.tv_nsec / SXE_NSEC_PER_MS;
> +
> +l_end:
> +	return ms;
> +}
> +
> +void sxe_trace_id_gen(void)
> +{
> +	sxe_trace_id = 0;
> +	return;
> +}

Return statement is unnecessary here


> +u64 sxe_trace_id_get(void)
> +{
> +	return rte_atomic_fetch_add_explicit((uint64_t __rte_atomic *)&sxe_trace_id,
> +			1, rte_memory_order_relaxed);
> +}

The cast should not be necessary.


More information about the dev mailing list