aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-dpdk/odp_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'platform/linux-dpdk/odp_init.c')
-rw-r--r--platform/linux-dpdk/odp_init.c199
1 files changed, 105 insertions, 94 deletions
diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c
index 3ae981b68..329252f9c 100644
--- a/platform/linux-dpdk/odp_init.c
+++ b/platform/linux-dpdk/odp_init.c
@@ -9,16 +9,19 @@
#include <odp/api/init.h>
#include <odp/api/shared_memory.h>
+
+#include <odp/api/plat/thread_inlines.h>
+
#include <odp_debug_internal.h>
+#include <odp_global_data.h>
#include <odp_init_internal.h>
-#include <odp_schedule_if.h>
#include <odp_libconfig_internal.h>
-#include <odp/api/plat/thread_inlines.h>
+#include <odp_schedule_if.h>
#include <odp_shm_internal.h>
+
#include <string.h>
#include <stdio.h>
#include <unistd.h>
-#include <ctype.h>
#include <inttypes.h>
#include <rte_config.h>
@@ -59,6 +62,15 @@ enum init_stage {
odp_global_data_ro_t odp_global_ro;
odp_global_data_rw_t *odp_global_rw;
+/* Global function pointers for inline header usage. The values are written
+ * during odp_init_global() (enables process mode support). */
+#include <odp/visibility_begin.h>
+
+odp_log_func_t ODP_PRINTF_FORMAT(2, 3) _odp_log_fn;
+odp_abort_func_t _odp_abort_fn;
+
+#include <odp/visibility_end.h>
+
/* odp_init_local() call status */
static __thread uint8_t init_local_called;
@@ -124,7 +136,7 @@ static int read_pci_config(char **pci_cmd)
/* Buffer to concatenate list of '-w/-b <pci addr>' strings */
buf = malloc(pci_count * (str_size + 3));
if (buf == NULL) {
- ODP_ERR("PCI config buffer alloc fail\n");
+ _ODP_ERR("PCI config buffer alloc fail\n");
return -1;
}
@@ -136,7 +148,7 @@ static int read_pci_config(char **pci_cmd)
strcat(buf, addr_str);
}
- ODP_PRINT(" %s: %s\n\n", pci_str[i], buf);
+ _ODP_PRINT(" %s: %s\n\n", pci_str[i], buf);
/* No need to read blacklist if whitelist is defined */
*pci_cmd = buf;
@@ -158,7 +170,7 @@ static int read_eal_cmdstr(char **eal_cmd)
buf = malloc(length);
if (buf == NULL) {
- ODP_ERR("DPDK EAL command string buffer alloc fail\n");
+ _ODP_ERR("DPDK EAL command string buffer alloc fail\n");
return -1;
}
@@ -167,7 +179,7 @@ static int read_eal_cmdstr(char **eal_cmd)
return -1;
}
- ODP_PRINT(" %s: %s\n\n", dpdk_str, buf);
+ _ODP_PRINT(" %s: %s\n\n", dpdk_str, buf);
*eal_cmd = buf;
return length;
@@ -182,16 +194,16 @@ static int _odp_init_dpdk(const char *cmdline)
int val = 0;
char *pci_cmd = NULL, *eal_cmd = NULL;
- ODP_PRINT("DPDK config:\n");
+ _ODP_PRINT("DPDK config:\n");
str = "dpdk.process_mode_memory_mb";
if (!_odp_libconfig_lookup_int(str, &val)) {
- ODP_ERR("Config option '%s' not found.\n", str);
+ _ODP_ERR("Config option '%s' not found.\n", str);
return -1;
}
mem_prealloc = val;
- ODP_PRINT(" %s: %" PRIu32 "\n", str, mem_prealloc);
+ _ODP_PRINT(" %s: %" PRIu32 "\n", str, mem_prealloc);
if (cmdline == NULL) {
cmdline = getenv("ODP_PLATFORM_PARAMS");
@@ -201,14 +213,14 @@ static int _odp_init_dpdk(const char *cmdline)
pcicmdlen = read_pci_config(&pci_cmd);
if (pcicmdlen < 0) {
- ODP_ERR("Error reading PCI config\n");
+ _ODP_ERR("Error reading PCI config\n");
return -1;
}
/* Read any additional EAL command string from config */
ealcmdlen = read_eal_cmdstr(&eal_cmd);
if (ealcmdlen < 0) {
- ODP_ERR("Error reading additional DPDK EAL command string\n");
+ _ODP_ERR("Error reading additional DPDK EAL command string\n");
if (pci_cmd != NULL)
free(pci_cmd);
return -1;
@@ -249,18 +261,18 @@ static int _odp_init_dpdk(const char *cmdline)
dpdk_argc = rte_strsplit(full_cmdline, strlen(full_cmdline), dpdk_argv,
dpdk_argc, ' ');
for (i = 0; i < dpdk_argc; ++i)
- ODP_DBG("arg[%d]: %s\n", i, dpdk_argv[i]);
+ _ODP_DBG("arg[%d]: %s\n", i, dpdk_argv[i]);
fflush(stdout);
i = rte_eal_init(dpdk_argc, dpdk_argv);
if (i < 0) {
- ODP_ERR("Cannot init the Intel DPDK EAL!\n");
+ _ODP_ERR("Cannot init the Intel DPDK EAL!\n");
return -1;
} else if (i + 1 != dpdk_argc) {
- ODP_DBG("Some DPDK args were not processed!\n");
- ODP_DBG("Passed: %d Consumed %d\n", dpdk_argc, i + 1);
+ _ODP_DBG("Some DPDK args were not processed!\n");
+ _ODP_DBG("Passed: %d Consumed %d\n", dpdk_argc, i + 1);
}
- ODP_DBG("rte_eal_init OK\n");
+ _ODP_DBG("rte_eal_init OK\n");
/* Reset to 0 to force getopt() internal initialization routine */
optind = 0;
@@ -283,7 +295,7 @@ static int global_rw_data_init(void)
odp_global_rw = odp_shm_addr(shm);
if (odp_global_rw == NULL) {
- ODP_ERR("Global RW data shm reserve failed.\n");
+ _ODP_ERR("Global RW data shm reserve failed.\n");
return -1;
}
@@ -298,12 +310,12 @@ static int global_rw_data_term(void)
shm = odp_shm_lookup("_odp_global_rw_data");
if (shm == ODP_SHM_INVALID) {
- ODP_ERR("Unable to find global RW data shm.\n");
+ _ODP_ERR("Unable to find global RW data shm.\n");
return -1;
}
if (odp_shm_free(shm)) {
- ODP_ERR("Global RW data shm free failed.\n");
+ _ODP_ERR("Global RW data shm free failed.\n");
return -1;
}
@@ -318,126 +330,126 @@ static int term_global(enum init_stage stage)
case ALL_INIT:
case DMA_INIT:
if (_odp_dma_term_global()) {
- ODP_ERR("ODP DMA term failed.\n");
+ _ODP_ERR("ODP DMA term failed.\n");
rc = -1;
}
/* Fall through */
case IPSEC_INIT:
if (_odp_ipsec_term_global()) {
- ODP_ERR("ODP IPsec term failed.\n");
+ _ODP_ERR("ODP IPsec term failed.\n");
rc = -1;
}
/* Fall through */
case IPSEC_SAD_INIT:
if (_odp_ipsec_sad_term_global()) {
- ODP_ERR("ODP IPsec SAD term failed.\n");
+ _ODP_ERR("ODP IPsec SAD term failed.\n");
rc = -1;
}
/* Fall through */
case IPSEC_EVENTS_INIT:
if (_odp_ipsec_events_term_global()) {
- ODP_ERR("ODP IPsec events term failed.\n");
+ _ODP_ERR("ODP IPsec events term failed.\n");
rc = -1;
}
/* Fall through */
case NAME_TABLE_INIT:
if (_odp_int_name_tbl_term_global()) {
- ODP_ERR("Name table term failed.\n");
+ _ODP_ERR("Name table term failed.\n");
rc = -1;
}
/* Fall through */
case TRAFFIC_MNGR_INIT:
if (_odp_tm_term_global()) {
- ODP_ERR("TM term failed.\n");
+ _ODP_ERR("TM term failed.\n");
rc = -1;
}
/* Fall through */
case CLASSIFICATION_INIT:
if (_odp_classification_term_global()) {
- ODP_ERR("ODP classification term failed.\n");
+ _ODP_ERR("ODP classification term failed.\n");
rc = -1;
}
/* Fall through */
case COMP_INIT:
if (_odp_comp_term_global()) {
- ODP_ERR("ODP comp term failed.\n");
+ _ODP_ERR("ODP comp term failed.\n");
rc = -1;
}
/* Fall through */
case CRYPTO_INIT:
if (_odp_crypto_term_global()) {
- ODP_ERR("ODP crypto term failed.\n");
+ _ODP_ERR("ODP crypto term failed.\n");
rc = -1;
}
/* Fall through */
case TIMER_INIT:
if (_odp_timer_term_global()) {
- ODP_ERR("ODP timer term failed.\n");
+ _ODP_ERR("ODP timer term failed.\n");
rc = -1;
}
/* Fall through */
case PKTIO_INIT:
if (_odp_pktio_term_global()) {
- ODP_ERR("ODP pktio term failed.\n");
+ _ODP_ERR("ODP pktio term failed.\n");
rc = -1;
}
/* Fall through */
case SCHED_INIT:
if (_odp_schedule_term_global()) {
- ODP_ERR("ODP schedule term failed.\n");
+ _ODP_ERR("ODP schedule term failed.\n");
rc = -1;
}
/* Fall through */
case QUEUE_INIT:
if (_odp_queue_term_global()) {
- ODP_ERR("ODP queue term failed.\n");
+ _ODP_ERR("ODP queue term failed.\n");
rc = -1;
}
/* Fall through */
case STASH_INIT:
if (_odp_stash_term_global()) {
- ODP_ERR("ODP stash term failed.\n");
+ _ODP_ERR("ODP stash term failed.\n");
rc = -1;
}
/* Fall through */
case POOL_INIT:
if (_odp_pool_term_global()) {
- ODP_ERR("ODP buffer pool term failed.\n");
+ _ODP_ERR("ODP buffer pool term failed.\n");
rc = -1;
}
/* Fall through */
case THREAD_INIT:
if (_odp_thread_term_global()) {
- ODP_ERR("ODP thread term failed.\n");
+ _ODP_ERR("ODP thread term failed.\n");
rc = -1;
}
/* Fall through */
case HASH_INIT:
if (_odp_hash_term_global()) {
- ODP_ERR("ODP hash term failed.\n");
+ _ODP_ERR("ODP hash term failed.\n");
rc = -1;
}
/* Fall through */
case GLOBAL_RW_DATA_INIT:
if (global_rw_data_term()) {
- ODP_ERR("ODP global RW data term failed.\n");
+ _ODP_ERR("ODP global RW data term failed.\n");
rc = -1;
}
/* Fall through */
@@ -446,21 +458,21 @@ static int term_global(enum init_stage stage)
case FDSERVER_INIT:
case ISHM_INIT:
if (_odp_shm_term_global()) {
- ODP_ERR("ODP shm term failed.\n");
+ _ODP_ERR("ODP shm term failed.\n");
rc = -1;
}
/* Fall through */
case SYSINFO_INIT:
if (_odp_system_info_term()) {
- ODP_ERR("ODP system info term failed.\n");
+ _ODP_ERR("ODP system info term failed.\n");
rc = -1;
}
/* Fall through */
case TIME_INIT:
if (_odp_time_term_global()) {
- ODP_ERR("ODP time term failed.\n");
+ _ODP_ERR("ODP time term failed.\n");
rc = -1;
}
/* Fall through */
@@ -469,14 +481,14 @@ static int term_global(enum init_stage stage)
/* Fall through */
case CPUMASK_INIT:
if (_odp_cpumask_term_global()) {
- ODP_ERR("ODP cpumask term failed.\n");
+ _ODP_ERR("ODP cpumask term failed.\n");
rc = -1;
}
/* Fall through */
case LIBCONFIG_INIT:
if (_odp_libconfig_term_global()) {
- ODP_ERR("ODP runtime config term failed.\n");
+ _ODP_ERR("ODP runtime config term failed.\n");
rc = -1;
}
/* Fall through */
@@ -496,24 +508,23 @@ int odp_init_global(odp_instance_t *instance,
memset(&odp_global_ro, 0, sizeof(odp_global_data_ro_t));
odp_global_ro.main_pid = getpid();
-
- odp_global_ro.log_fn = odp_override_log;
- odp_global_ro.abort_fn = odp_override_abort;
+ _odp_log_fn = odp_override_log;
+ _odp_abort_fn = odp_override_abort;
odp_init_param_init(&odp_global_ro.init_param);
if (params != NULL) {
odp_global_ro.init_param = *params;
if (params->log_fn != NULL)
- odp_global_ro.log_fn = params->log_fn;
+ _odp_log_fn = params->log_fn;
if (params->abort_fn != NULL)
- odp_global_ro.abort_fn = params->abort_fn;
+ _odp_abort_fn = params->abort_fn;
if (params->mem_model == ODP_MEM_MODEL_PROCESS)
odp_global_ro.shm_single_va = 1;
}
if (_odp_libconfig_init_global()) {
- ODP_ERR("ODP runtime config init failed.\n");
+ _ODP_ERR("ODP runtime config init failed.\n");
goto init_failed;
}
stage = LIBCONFIG_INIT;
@@ -521,144 +532,144 @@ int odp_init_global(odp_instance_t *instance,
disable_features(&odp_global_ro, params);
if (_odp_cpumask_init_global(params)) {
- ODP_ERR("ODP cpumask init failed.\n");
+ _ODP_ERR("ODP cpumask init failed.\n");
goto init_failed;
}
stage = CPUMASK_INIT;
if (_odp_cpu_cycles_init_global()) {
- ODP_ERR("ODP cpu cycle init failed.\n");
+ _ODP_ERR("ODP cpu cycle init failed.\n");
goto init_failed;
}
stage = CPU_CYCLES_INIT;
if (_odp_init_dpdk((const char *)platform_params)) {
- ODP_ERR("ODP dpdk init failed.\n");
+ _ODP_ERR("ODP dpdk init failed.\n");
return -1;
}
if (_odp_time_init_global()) {
- ODP_ERR("ODP time init failed.\n");
+ _ODP_ERR("ODP time init failed.\n");
goto init_failed;
}
stage = TIME_INIT;
if (_odp_system_info_init()) {
- ODP_ERR("ODP system_info init failed.\n");
+ _ODP_ERR("ODP system_info init failed.\n");
goto init_failed;
}
stage = SYSINFO_INIT;
if (_odp_shm_init_global(params)) {
- ODP_ERR("ODP shm init failed.\n");
+ _ODP_ERR("ODP shm init failed.\n");
goto init_failed;
}
stage = ISHM_INIT;
if (global_rw_data_init()) {
- ODP_ERR("ODP global RW data init failed.\n");
+ _ODP_ERR("ODP global RW data init failed.\n");
goto init_failed;
}
stage = GLOBAL_RW_DATA_INIT;
if (_odp_hash_init_global()) {
- ODP_ERR("ODP hash init failed.\n");
+ _ODP_ERR("ODP hash init failed.\n");
goto init_failed;
}
stage = HASH_INIT;
if (_odp_thread_init_global()) {
- ODP_ERR("ODP thread init failed.\n");
+ _ODP_ERR("ODP thread init failed.\n");
goto init_failed;
}
stage = THREAD_INIT;
if (_odp_pool_init_global()) {
- ODP_ERR("ODP pool init failed.\n");
+ _ODP_ERR("ODP pool init failed.\n");
goto init_failed;
}
stage = POOL_INIT;
if (_odp_stash_init_global()) {
- ODP_ERR("ODP stash init failed.\n");
+ _ODP_ERR("ODP stash init failed.\n");
goto init_failed;
}
stage = STASH_INIT;
if (_odp_queue_init_global()) {
- ODP_ERR("ODP queue init failed.\n");
+ _ODP_ERR("ODP queue init failed.\n");
goto init_failed;
}
stage = QUEUE_INIT;
if (_odp_schedule_init_global()) {
- ODP_ERR("ODP schedule init failed.\n");
+ _ODP_ERR("ODP schedule init failed.\n");
goto init_failed;
}
stage = SCHED_INIT;
if (_odp_pktio_init_global()) {
- ODP_ERR("ODP packet io init failed.\n");
+ _ODP_ERR("ODP packet io init failed.\n");
goto init_failed;
}
stage = PKTIO_INIT;
if (_odp_timer_init_global(params)) {
- ODP_ERR("ODP timer init failed.\n");
+ _ODP_ERR("ODP timer init failed.\n");
goto init_failed;
}
stage = TIMER_INIT;
if (_odp_crypto_init_global()) {
- ODP_ERR("ODP crypto init failed.\n");
+ _ODP_ERR("ODP crypto init failed.\n");
goto init_failed;
}
stage = CRYPTO_INIT;
if (_odp_comp_init_global()) {
- ODP_ERR("ODP comp init failed.\n");
+ _ODP_ERR("ODP comp init failed.\n");
goto init_failed;
}
stage = COMP_INIT;
if (_odp_classification_init_global()) {
- ODP_ERR("ODP classification init failed.\n");
+ _ODP_ERR("ODP classification init failed.\n");
goto init_failed;
}
stage = CLASSIFICATION_INIT;
if (_odp_tm_init_global()) {
- ODP_ERR("ODP traffic manager init failed\n");
+ _ODP_ERR("ODP traffic manager init failed\n");
goto init_failed;
}
stage = TRAFFIC_MNGR_INIT;
if (_odp_int_name_tbl_init_global()) {
- ODP_ERR("ODP name table init failed\n");
+ _ODP_ERR("ODP name table init failed\n");
goto init_failed;
}
stage = NAME_TABLE_INIT;
if (_odp_ipsec_events_init_global()) {
- ODP_ERR("ODP IPsec events init failed.\n");
+ _ODP_ERR("ODP IPsec events init failed.\n");
goto init_failed;
}
stage = IPSEC_EVENTS_INIT;
if (_odp_ipsec_sad_init_global()) {
- ODP_ERR("ODP IPsec SAD init failed.\n");
+ _ODP_ERR("ODP IPsec SAD init failed.\n");
goto init_failed;
}
stage = IPSEC_SAD_INIT;
if (_odp_ipsec_init_global()) {
- ODP_ERR("ODP IPsec init failed.\n");
+ _ODP_ERR("ODP IPsec init failed.\n");
goto init_failed;
}
stage = IPSEC_INIT;
if (_odp_dma_init_global()) {
- ODP_ERR("ODP DMA init failed.\n");
+ _ODP_ERR("ODP DMA init failed.\n");
goto init_failed;
}
stage = DMA_INIT;
@@ -676,7 +687,7 @@ init_failed:
int odp_term_global(odp_instance_t instance)
{
if (instance != (odp_instance_t)odp_global_ro.main_pid) {
- ODP_ERR("Bad instance.\n");
+ _ODP_ERR("Bad instance.\n");
return -1;
}
return term_global(ALL_INIT);
@@ -692,42 +703,42 @@ static int term_local(enum init_stage stage)
case SCHED_INIT:
if (_odp_sched_fn->term_local()) {
- ODP_ERR("ODP schedule local term failed.\n");
+ _ODP_ERR("ODP schedule local term failed.\n");
rc = -1;
}
/* Fall through */
case QUEUE_INIT:
if (_odp_queue_fn->term_local()) {
- ODP_ERR("ODP queue local term failed.\n");
+ _ODP_ERR("ODP queue local term failed.\n");
rc = -1;
}
/* Fall through */
case POOL_INIT:
if (_odp_pool_term_local()) {
- ODP_ERR("ODP buffer pool local term failed.\n");
+ _ODP_ERR("ODP buffer pool local term failed.\n");
rc = -1;
}
/* Fall through */
case CRYPTO_INIT:
if (_odp_crypto_term_local()) {
- ODP_ERR("ODP crypto local term failed.\n");
+ _ODP_ERR("ODP crypto local term failed.\n");
rc = -1;
}
/* Fall through */
case RANDOM_INIT:
if (_odp_random_term_local()) {
- ODP_ERR("ODP random local term failed.\n");
+ _ODP_ERR("ODP random local term failed.\n");
rc = -1;
}
/* Fall through */
case TIMER_INIT:
if (_odp_timer_term_local()) {
- ODP_ERR("ODP timer local term failed.\n");
+ _ODP_ERR("ODP timer local term failed.\n");
rc = -1;
}
/* Fall through */
@@ -735,7 +746,7 @@ static int term_local(enum init_stage stage)
case THREAD_INIT:
rc_thd = _odp_thread_term_local();
if (rc_thd < 0) {
- ODP_ERR("ODP thread local term failed.\n");
+ _ODP_ERR("ODP thread local term failed.\n");
rc = -1;
} else {
if (!rc)
@@ -745,7 +756,7 @@ static int term_local(enum init_stage stage)
case ISHM_INIT:
if (_odp_shm_term_local()) {
- ODP_ERR("ODP shm local term failed.\n");
+ _ODP_ERR("ODP shm local term failed.\n");
rc = -1;
}
/* Fall through */
@@ -762,67 +773,67 @@ int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type)
enum init_stage stage = NO_INIT;
if (instance != (odp_instance_t)odp_global_ro.main_pid) {
- ODP_ERR("Bad instance.\n");
+ _ODP_ERR("Bad instance.\n");
goto init_fail;
}
/* Detect if odp_init_local() has been already called from this thread */
if (getpid() == odp_global_ro.main_pid && init_local_called) {
- ODP_ERR("%s() called multiple times by the same thread\n", __func__);
+ _ODP_ERR("%s() called multiple times by the same thread\n", __func__);
goto init_fail;
}
init_local_called = 1;
if (_odp_shm_init_local()) {
- ODP_ERR("ODP shm local init failed.\n");
+ _ODP_ERR("ODP shm local init failed.\n");
goto init_fail;
}
stage = ISHM_INIT;
if (_odp_thread_init_local(thr_type)) {
- ODP_ERR("ODP thread local init failed.\n");
+ _ODP_ERR("ODP thread local init failed.\n");
goto init_fail;
}
stage = THREAD_INIT;
if (_odp_pktio_init_local()) {
- ODP_ERR("ODP packet io local init failed.\n");
+ _ODP_ERR("ODP packet io local init failed.\n");
goto init_fail;
}
stage = PKTIO_INIT;
if (_odp_timer_init_local()) {
- ODP_ERR("ODP timer local init failed.\n");
+ _ODP_ERR("ODP timer local init failed.\n");
goto init_fail;
}
stage = TIMER_INIT;
if (_odp_random_init_local()) {
- ODP_ERR("ODP random local init failed.\n");
+ _ODP_ERR("ODP random local init failed.\n");
goto init_fail;
}
stage = RANDOM_INIT;
if (_odp_crypto_init_local()) {
- ODP_ERR("ODP crypto local init failed.\n");
+ _ODP_ERR("ODP crypto local init failed.\n");
goto init_fail;
}
stage = CRYPTO_INIT;
if (_odp_pool_init_local()) {
- ODP_ERR("ODP pool local init failed.\n");
+ _ODP_ERR("ODP pool local init failed.\n");
goto init_fail;
}
stage = POOL_INIT;
if (_odp_queue_fn->init_local()) {
- ODP_ERR("ODP queue local init failed.\n");
+ _ODP_ERR("ODP queue local init failed.\n");
goto init_fail;
}
stage = QUEUE_INIT;
if (_odp_sched_fn->init_local()) {
- ODP_ERR("ODP schedule local init failed.\n");
+ _ODP_ERR("ODP schedule local init failed.\n");
goto init_fail;
}
/* stage = SCHED_INIT; */
@@ -838,7 +849,7 @@ int odp_term_local(void)
{
/* Check that odp_init_local() has been called by this thread */
if (!init_local_called) {
- ODP_ERR("%s() called by a non-initialized thread\n", __func__);
+ _ODP_ERR("%s() called by a non-initialized thread\n", __func__);
return -1;
}
init_local_called = 0;