diff --git a/config/meson.build b/config/meson.build index c02802c18e..dd5ddd6667 100644 --- a/config/meson.build +++ b/config/meson.build @@ -176,6 +176,11 @@ if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep) dpdk_extra_ldflags += '-lpcap' endif +if is_freebsd + add_project_link_arguments('-L/usr/local/lib/libtopo', language: 'c') + add_project_link_arguments('-ltopo', language: 'c') +endif + # for clang 32-bit compiles we need libatomic for 64-bit atomic ops if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false atomic_dep = cc.find_library('atomic', required: true) diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c index d6ea023750..7a8abc2d2b 100644 --- a/lib/librte_eal/freebsd/eal.c +++ b/lib/librte_eal/freebsd/eal.c @@ -20,6 +20,8 @@ #include #include +#include + #include #include #include @@ -696,6 +698,12 @@ rte_eal_init(int argc, char **argv) /* set log level as early as possible */ eal_log_level_parse(argc, argv); + if (topo_init(1, 1) != 0) { + rte_eal_init_alert("Cannot init libtopo."); + rte_errno = ENOTSUP; + return -1; + } + if (rte_eal_cpu_init() < 0) { rte_eal_init_alert("Cannot detect lcores."); rte_errno = ENOTSUP; diff --git a/lib/librte_eal/freebsd/eal_hugepage_info.c b/lib/librte_eal/freebsd/eal_hugepage_info.c index 2e3e9e40f7..3f64ab905b 100644 --- a/lib/librte_eal/freebsd/eal_hugepage_info.c +++ b/lib/librte_eal/freebsd/eal_hugepage_info.c @@ -50,15 +50,6 @@ create_shared_memory(const char *filename, const size_t mem_size) return map_shared_memory(filename, mem_size, O_RDWR | O_CREAT); } -#define NEXT_CPU_NULL -1; -static inline int -cmask_get_next_cpu(uint64_t *mask) -{ - int ffs = ffsll(*mask); - *mask &= ~(1ul << (ffs - 1)); - return ffs - 1; -} - static inline int cmask_get_num_cpus(const uint64_t mask) { diff --git a/lib/librte_eal/freebsd/eal_lcore.c b/lib/librte_eal/freebsd/eal_lcore.c index 9ceafaedf2..2a7d74ef55 100644 --- a/lib/librte_eal/freebsd/eal_lcore.c +++ b/lib/librte_eal/freebsd/eal_lcore.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -25,33 +26,13 @@ eal_cpu_core_id(unsigned lcore_id) static int eal_get_ncpus(void) { - static int ncpu = -1; - int mib[2] = {CTL_HW, HW_NCPU}; - size_t len = sizeof(ncpu); - - if (ncpu < 0) { - sysctl(mib, 2, &ncpu, &len, NULL, 0); - RTE_LOG(INFO, EAL, "Sysctl reports %d cpus\n", ncpu); - } - return ncpu; + return topo_num_core(); } unsigned eal_cpu_socket_id(unsigned cpu_id) { - int error; - int domain; - size_t domain_sz = sizeof(domain); - - char sysctl_str[32]; - snprintf(sysctl_str, sizeof(sysctl_str), "dev.cpu.%d.%%domain", cpu_id); - - error = sysctlbyname(sysctl_str, &domain, &domain_sz, NULL, 0); - if (error < 0) { - RTE_LOG(WARNING, EAL, "Failed to get socket id for core %u, returning 0...\n", cpu_id); - domain = 0; - } - return domain; + return topo_core_to_numa(cpu_id); } /* Check if a cpu is present by the presence of the diff --git a/lib/librte_eal/freebsd/meson.build b/lib/librte_eal/freebsd/meson.build index e10fd8a16d..231d1b682d 100644 --- a/lib/librte_eal/freebsd/meson.build +++ b/lib/librte_eal/freebsd/meson.build @@ -19,3 +19,5 @@ sources += files( ) deps += ['kvargs', 'telemetry'] +dpdk_extra_ldflags += '-ltopo' +cflags += [ '-I/usr/local/include' ] \ No newline at end of file diff --git a/meson_options.txt b/meson_options.txt index e384e6dbb2..945fa629e5 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -24,9 +24,9 @@ option('machine', type: 'string', value: 'native', description: 'set the target machine type') option('max_ethports', type: 'integer', value: 32, description: 'maximum number of Ethernet devices') -option('max_lcores', type: 'integer', value: 128, +option('max_lcores', type: 'integer', value: 256, description: 'maximum number of cores/threads supported by EAL') -option('max_numa_nodes', type: 'integer', value: 4, +option('max_numa_nodes', type: 'integer', value: 16, description: 'maximum number of NUMA nodes supported by EAL') option('enable_trace_fp', type: 'boolean', value: false, description: 'enable fast path trace points.')