1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2014 Intel Corporation 3 */ 4 5 #include <unistd.h> 6 #include <sys/sysctl.h> 7 8 #include <rte_log.h> 9 #include <rte_eal.h> 10 #include <rte_lcore.h> 11 #include <rte_common.h> 12 #include <rte_debug.h> 13 14 #include "eal_private.h" 15 #include "eal_thread.h" 16 17 /* No topology information available on FreeBSD including NUMA info */ 18 unsigned eal_cpu_core_id(__rte_unused unsigned lcore_id)19eal_cpu_core_id(__rte_unused unsigned lcore_id) 20 { 21 return 0; 22 } 23 24 static int eal_get_ncpus(void)25eal_get_ncpus(void) 26 { 27 static int ncpu = -1; 28 int mib[2] = {CTL_HW, HW_NCPU}; 29 size_t len = sizeof(ncpu); 30 31 if (ncpu < 0) { 32 sysctl(mib, 2, &ncpu, &len, NULL, 0); 33 EAL_LOG(INFO, "Sysctl reports %d cpus", ncpu); 34 } 35 return ncpu; 36 } 37 38 unsigned eal_cpu_socket_id(__rte_unused unsigned cpu_id)39eal_cpu_socket_id(__rte_unused unsigned cpu_id) 40 { 41 return 0; 42 } 43 44 /* Check if a cpu is present by the presence of the 45 * cpu information for it. 46 */ 47 int eal_cpu_detected(unsigned lcore_id)48eal_cpu_detected(unsigned lcore_id) 49 { 50 const unsigned ncpus = eal_get_ncpus(); 51 return lcore_id < ncpus; 52 } 53