#include <stdlib.h>
#include <stdint.h>
#include <string.h>
-#include <stdarg.h>
#include <unistd.h>
#include <pthread.h>
-#include <syslog.h>
#include <getopt.h>
#include <sys/file.h>
#include <dirent.h>
#include <errno.h>
#include <limits.h>
#include <sys/mman.h>
-#include <sys/queue.h>
#include <sys/stat.h>
#if defined(RTE_ARCH_X86)
#include <sys/io.h>
#endif
#include <linux/version.h>
-#include <rte_compat.h>
#include <rte_common.h>
#include <rte_debug.h>
#include <rte_memory.h>
#include <rte_launch.h>
#include <rte_eal.h>
#include <rte_errno.h>
-#include <rte_per_lcore.h>
#include <rte_lcore.h>
#include <rte_service_component.h>
#include <rte_log.h>
-#include <rte_random.h>
-#include <rte_cycles.h>
#include <rte_string_fns.h>
#include <rte_cpuflags.h>
-#include <rte_interrupts.h>
#include <rte_bus.h>
-#include <rte_dev.h>
-#include <rte_devargs.h>
#include <rte_version.h>
#include <malloc_heap.h>
#include <rte_vfio.h>
/* used by rte_rdtsc() */
int rte_cycles_vmware_tsc_map;
-static const char *default_runtime_dir = "/var/run";
-
-int
-eal_create_runtime_dir(void)
-{
- const char *directory = default_runtime_dir;
- const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
- const char *fallback = "/tmp";
- char run_dir[PATH_MAX];
- char tmp[PATH_MAX];
- int ret;
-
- if (getuid() != 0) {
- /* try XDG path first, fall back to /tmp */
- if (xdg_runtime_dir != NULL)
- directory = xdg_runtime_dir;
- else
- directory = fallback;
- }
- /* create DPDK subdirectory under runtime dir */
- ret = snprintf(tmp, sizeof(tmp), "%s/dpdk", directory);
- if (ret < 0 || ret == sizeof(tmp)) {
- RTE_LOG(ERR, EAL, "Error creating DPDK runtime path name\n");
- return -1;
- }
-
- /* create prefix-specific subdirectory under DPDK runtime dir */
- ret = snprintf(run_dir, sizeof(run_dir), "%s/%s",
- tmp, eal_get_hugefile_prefix());
- if (ret < 0 || ret == sizeof(run_dir)) {
- RTE_LOG(ERR, EAL, "Error creating prefix-specific runtime path name\n");
- return -1;
- }
-
- /* create the path if it doesn't exist. no "mkdir -p" here, so do it
- * step by step.
- */
- ret = mkdir(tmp, 0700);
- if (ret < 0 && errno != EEXIST) {
- RTE_LOG(ERR, EAL, "Error creating '%s': %s\n",
- tmp, strerror(errno));
- return -1;
- }
-
- ret = mkdir(run_dir, 0700);
- if (ret < 0 && errno != EEXIST) {
- RTE_LOG(ERR, EAL, "Error creating '%s': %s\n",
- run_dir, strerror(errno));
- return -1;
- }
-
- if (eal_set_runtime_dir(run_dir, sizeof(run_dir)))
- return -1;
-
- return 0;
-}
int
eal_clean_runtime_dir(void)
return -1;
}
-/* parse a sysfs (or other) file containing one integer value */
-int
-eal_parse_sysfs_value(const char *filename, unsigned long *val)
-{
- FILE *f;
- char buf[BUFSIZ];
- char *end = NULL;
-
- if ((f = fopen(filename, "r")) == NULL) {
- RTE_LOG(ERR, EAL, "%s(): cannot open sysfs value %s\n",
- __func__, filename);
- return -1;
- }
-
- if (fgets(buf, sizeof(buf), f) == NULL) {
- RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n",
- __func__, filename);
- fclose(f);
- return -1;
- }
- *val = strtoul(buf, &end, 0);
- if ((buf[0] == '\0') || (end == NULL) || (*end != '\n')) {
- RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs value %s\n",
- __func__, filename);
- fclose(f);
- return -1;
- }
- fclose(f);
- return 0;
-}
-
/* create memory configuration in shared/mmap memory. Take out
* a write lock on the memsegs, so we can auto-detect primary/secondary.
char * arg[RTE_MAX_NUMA_NODES];
char *end;
int arg_num, i, len;
- uint64_t total_mem = 0;
len = strnlen(strval, SOCKET_MEM_STRLEN);
if (len == SOCKET_MEM_STRLEN) {
(arg[i][0] == '\0') || (end == NULL) || (*end != '\0'))
return -1;
val <<= 20;
- total_mem += val;
socket_arg[i] = val;
}
RTE_LOG(ERR, EAL, "Could not store hugepage directory\n");
else {
/* free old hugepage dir */
- if (internal_conf->hugepage_dir != NULL)
- free(internal_conf->hugepage_dir);
+ free(internal_conf->hugepage_dir);
internal_conf->hugepage_dir = hdir;
}
break;
RTE_LOG(ERR, EAL, "Could not store file prefix\n");
else {
/* free old prefix */
- if (internal_conf->hugefile_prefix != NULL)
- free(internal_conf->hugefile_prefix);
+ free(internal_conf->hugefile_prefix);
internal_conf->hugefile_prefix = prefix;
}
break;
RTE_LOG(ERR, EAL, "Could not store mbuf pool ops name\n");
else {
/* free old ops name */
- if (internal_conf->user_mbuf_pool_ops_name !=
- NULL)
- free(internal_conf->user_mbuf_pool_ops_name);
+ free(internal_conf->user_mbuf_pool_ops_name);
internal_conf->user_mbuf_pool_ops_name =
ops_name;
rte_eal_init_alert("Cannot clear runtime directory");
return -1;
}
- if (!internal_conf->no_telemetry) {
+ if (rte_eal_process_type() == RTE_PROC_PRIMARY && !internal_conf->no_telemetry) {
int tlog = rte_log_register_type_and_pick_level(
"lib.telemetry", RTE_LOG_WARNING);
if (tlog < 0)
struct internal_config *internal_conf =
eal_get_internal_configuration();
- if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+ if (rte_eal_process_type() == RTE_PROC_PRIMARY &&
+ internal_conf->hugepage_file.unlink_existing)
rte_memseg_walk(mark_freeable, NULL);
+
rte_service_finalize();
+#ifdef VFIO_PRESENT
+ vfio_mp_sync_cleanup();
+#endif
rte_mp_channel_cleanup();
/* after this point, any DPDK pointers will become dangling */
rte_eal_memory_detach();
+ eal_mp_dev_hotplug_cleanup();
+ rte_eal_malloc_heap_cleanup();
+ rte_eal_alarm_cleanup();
rte_trace_save();
eal_trace_fini();
eal_cleanup_config(internal_conf);
+ rte_eal_log_cleanup();
return 0;
}