diff --git a/lib/Makefile b/lib/Makefile index edec7d06c..c366dcbae 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -92,6 +92,13 @@ HOST_CFLAGS+= -DFF_KNI endif HOST_CFLAGS+= ${DPDK_CFLAGS} + +ifneq ($(MAKECMDGOALS),clean) +HAVE_RTE_TIMER_META_INIT := $(shell printf '#include \nvoid (*fn)(void) = rte_timer_meta_init;\n' | $(CC) -x c $(shell $(PKGCONF) --cflags libdpdk) -fsyntax-only - >/dev/null 2>&1 && echo 1 || echo 0) +ifeq ($(HAVE_RTE_TIMER_META_INIT),1) +HOST_CFLAGS+= -DHAVE_RTE_TIMER_META_INIT +endif +endif HOST_CFLAGS+= ${CONF_CFLAGS} ifdef FF_FDIR diff --git a/lib/ff_dpdk_if.c b/lib/ff_dpdk_if.c index c6c43b6e3..9efeab748 100644 --- a/lib/ff_dpdk_if.c +++ b/lib/ff_dpdk_if.c @@ -1547,8 +1547,22 @@ init_clock(void) return 0; } - rte_timer_subsystem_init(); + int timer_rc = rte_timer_subsystem_init(); + if (timer_rc != 0 && timer_rc != -EALREADY) { + rte_exit(EXIT_FAILURE, "timer subsystem initialization failed: %d\n", + timer_rc); + } +#ifdef HAVE_RTE_TIMER_META_INIT rte_timer_meta_init(); +#else + /* Unmodified upstream DPDK does not provide F-Stack's rte_timer_meta_init(). + * Fail fast if secondary process or graceful_reload is requested. */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY || + ff_global_cfg.dpdk.graceful_reload) { + rte_exit(EXIT_FAILURE, + "secondary process and graceful_reload require F-Stack bundled DPDK\n"); + } +#endif uint64_t hz = rte_get_timer_hz(); uint64_t intrs = US_PER_S / ff_global_cfg.freebsd.hz; uint64_t tsc = (hz + US_PER_S - 1) / US_PER_S * intrs;