#include <rte_dev.h>
#include <rte_devargs.h>
#include <rte_version.h>
-#include <rte_atomic.h>
#include <malloc_heap.h>
#include <rte_vfio.h>
#include <rte_telemetry.h>
}
if (rte_eal_config_reattach() < 0)
return -1;
+ if (!__rte_mp_enable()) {
+ RTE_LOG(ERR, EAL, "Primary process refused secondary attachment\n");
+ return -1;
+ }
eal_mcfg_update_internal();
break;
case RTE_PROC_AUTO:
int socket_id;
const struct rte_config *config = rte_eal_get_configuration();
- socket_id = rte_lcore_to_socket_id(config->master_lcore);
+ socket_id = rte_lcore_to_socket_id(config->main_lcore);
if (rte_memseg_list_walk(check_socket, &socket_id) == 0)
- RTE_LOG(WARNING, EAL, "WARNING: Master core has no memory on local socket!\n");
+ RTE_LOG(WARNING, EAL, "WARNING: Main core has no memory on local socket!\n");
}
static int
{
int i, fctret, ret;
pthread_t thread_id;
- static rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);
+ static uint32_t run_once;
+ uint32_t has_run = 0;
const char *p;
static char logid[PATH_MAX];
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
return -1;
}
- if (!rte_atomic32_test_and_set(&run_once)) {
+ if (!__atomic_compare_exchange_n(&run_once, &has_run, 1, 0,
+ __ATOMIC_RELAXED, __ATOMIC_RELAXED)) {
rte_eal_init_alert("already called initialization.");
rte_errno = EALREADY;
return -1;
if (fctret < 0) {
rte_eal_init_alert("Invalid 'command line' arguments.");
rte_errno = EINVAL;
- rte_atomic32_clear(&run_once);
+ __atomic_store_n(&run_once, 0, __ATOMIC_RELAXED);
return -1;
}
if (eal_plugins_init() < 0) {
rte_eal_init_alert("Cannot init plugins");
rte_errno = EINVAL;
- rte_atomic32_clear(&run_once);
+ __atomic_store_n(&run_once, 0, __ATOMIC_RELAXED);
return -1;
}
if (eal_option_device_parse()) {
rte_errno = ENODEV;
- rte_atomic32_clear(&run_once);
+ __atomic_store_n(&run_once, 0, __ATOMIC_RELAXED);
return -1;
}
if (rte_bus_scan()) {
rte_eal_init_alert("Cannot scan the buses for devices");
rte_errno = ENODEV;
- rte_atomic32_clear(&run_once);
+ __atomic_store_n(&run_once, 0, __ATOMIC_RELAXED);
return -1;
}
*/
iova_mode = RTE_IOVA_VA;
RTE_LOG(DEBUG, EAL, "Physical addresses are unavailable, selecting IOVA as VA mode.\n");
-#if defined(RTE_LIBRTE_KNI) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
+#if defined(RTE_LIB_KNI) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
} else if (rte_eal_check_module("rte_kni") == 1) {
iova_mode = RTE_IOVA_PA;
RTE_LOG(DEBUG, EAL, "KNI is loaded, selecting IOVA as PA mode for better KNI performance.\n");
RTE_LOG(DEBUG, EAL, "IOMMU is not available, selecting IOVA as PA mode.\n");
}
}
-#if defined(RTE_LIBRTE_KNI) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
+#if defined(RTE_LIB_KNI) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
/* Workaround for KNI which requires physical address to work
* in kernels < 4.10
*/
if (ret < 0) {
rte_eal_init_alert("Cannot get hugepage information.");
rte_errno = EACCES;
- rte_atomic32_clear(&run_once);
+ __atomic_store_n(&run_once, 0, __ATOMIC_RELAXED);
return -1;
}
}
if (rte_eal_log_init(logid, internal_conf->syslog_facility) < 0) {
rte_eal_init_alert("Cannot init logging.");
rte_errno = ENOMEM;
- rte_atomic32_clear(&run_once);
+ __atomic_store_n(&run_once, 0, __ATOMIC_RELAXED);
return -1;
}
if (rte_eal_vfio_setup() < 0) {
rte_eal_init_alert("Cannot init VFIO");
rte_errno = EAGAIN;
- rte_atomic32_clear(&run_once);
+ __atomic_store_n(&run_once, 0, __ATOMIC_RELAXED);
return -1;
}
#endif
eal_check_mem_on_local_socket();
- eal_thread_init_master(config->master_lcore);
-
- ret = eal_thread_dump_affinity(cpuset, sizeof(cpuset));
+ if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
+ &lcore_config[config->main_lcore].cpuset) != 0) {
+ rte_eal_init_alert("Cannot set affinity");
+ rte_errno = EINVAL;
+ return -1;
+ }
+ __rte_thread_init(config->main_lcore,
+ &lcore_config[config->main_lcore].cpuset);
- RTE_LOG(DEBUG, EAL, "Master lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
- config->master_lcore, (uintptr_t)thread_id, cpuset,
+ ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
+ RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
+ config->main_lcore, (uintptr_t)thread_id, cpuset,
ret == 0 ? "" : "...");
- RTE_LCORE_FOREACH_SLAVE(i) {
+ RTE_LCORE_FOREACH_WORKER(i) {
/*
- * create communication pipes between master thread
+ * create communication pipes between main thread
* and children
*/
- if (pipe(lcore_config[i].pipe_master2slave) < 0)
+ if (pipe(lcore_config[i].pipe_main2worker) < 0)
rte_panic("Cannot create pipe\n");
- if (pipe(lcore_config[i].pipe_slave2master) < 0)
+ if (pipe(lcore_config[i].pipe_worker2main) < 0)
rte_panic("Cannot create pipe\n");
lcore_config[i].state = WAIT;
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
- "lcore-slave-%d", i);
+ "lcore-worker-%d", i);
ret = rte_thread_setname(lcore_config[i].thread_id,
thread_name);
if (ret != 0)
RTE_LOG(DEBUG, EAL,
"Cannot set name for lcore thread\n");
+
+ ret = pthread_setaffinity_np(lcore_config[i].thread_id,
+ sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
+ if (ret != 0)
+ rte_panic("Cannot set affinity\n");
}
/*
- * Launch a dummy function on all slave lcores, so that master lcore
+ * Launch a dummy function on all worker lcores, so that main lcore
* knows they are all ready when this function returns.
*/
- rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
+ rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MAIN);
rte_eal_mp_wait_lcore();
/* initialize services so vdevs register service during bus_probe. */
ret = rte_service_init();
if (ret) {
rte_eal_init_alert("rte_service_init() failed");
- rte_errno = ENOEXEC;
+ rte_errno = -ret;
return -1;
}
*/
ret = rte_service_start_with_defaults();
if (ret < 0 && ret != -ENOTSUP) {
- rte_errno = ENOEXEC;
+ rte_errno = -ret;
return -1;
}
if (!internal_conf->no_telemetry) {
const char *error_str = NULL;
if (rte_telemetry_init(rte_eal_get_runtime_dir(),
+ rte_version(),
&internal_conf->ctrl_cpuset, &error_str)
!= 0) {
rte_eal_init_alert(error_str);
rte_memseg_walk(mark_freeable, NULL);
rte_service_finalize();
rte_mp_channel_cleanup();
+ /* after this point, any DPDK pointers will become dangling */
+ rte_eal_memory_detach();
rte_trace_save();
eal_trace_fini();
eal_cleanup_config(internal_conf);