@@ -525,7 +525,7 @@ int main(int argc, char *argv[])
int core_count;
/* Init ODP before calling anything else */
- if (odp_init_global()) {
+ if (odp_init_global(NULL, NULL)) {
ODP_ERR("Error: ODP global init failed.\n");
exit(EXIT_FAILURE);
}
@@ -323,7 +323,7 @@ int main(int argc, char *argv[])
odp_pktio_t pktio;
/* Init ODP before calling anything else */
- if (odp_init_global()) {
+ if (odp_init_global(NULL, NULL)) {
ODP_ERR("Error: ODP global init failed.\n");
exit(EXIT_FAILURE);
}
@@ -951,7 +951,7 @@ int main(int argc, char *argv[])
memset(thread_tbl, 0, sizeof(thread_tbl));
- if (odp_init_global()) {
+ if (odp_init_global(NULL, NULL)) {
printf("ODP global init failed.\n");
return -1;
}
@@ -311,7 +311,7 @@ int main(int argc, char *argv[])
int core_count;
/* Init ODP before calling anything else */
- if (odp_init_global()) {
+ if (odp_init_global(NULL, NULL)) {
ODP_ERR("Error: ODP global init failed.\n");
exit(EXIT_FAILURE);
}
@@ -210,7 +210,7 @@ int main(int argc, char *argv[])
memset(thread_tbl, 0, sizeof(thread_tbl));
- if (odp_init_global()) {
+ if (odp_init_global(NULL, NULL)) {
printf("ODP global init failed.\n");
return -1;
}
@@ -67,13 +67,14 @@ __LIB__libodp_la_SOURCES = \
odp_buffer.c \
odp_buffer_pool.c \
../linux-generic/odp_coremask.c \
- odp_init.c \
+ ../linux-generic/odp_init.c \
odp_linux.c \
odp_packet.c \
odp_packet_dpdk.c \
../linux-generic/odp_packet_flags.c \
odp_packet_io.c \
../linux-generic/odp_packet_socket.c \
+ odp_platform.c \
odp_queue.c \
../linux-generic/odp_ring.c \
../linux-generic/odp_rwlock.c \
deleted file mode 100644
@@ -1,113 +0,0 @@
-/* Copyright (c) 2013, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp_init.h>
-#include <odp_internal.h>
-#include <odp_debug.h>
-#include <odp_packet_dpdk.h>
-
-int odp_init_dpdk(void)
-{
- int test_argc = 5;
- char *test_argv[6];
- int core_count, i, num_cores = 0;
- char core_mask[8];
-
- core_count = odp_sys_core_count();
- for (i = 0; i < core_count; i++)
- num_cores += (0x1 << i);
- sprintf(core_mask, "%x", num_cores);
-
- test_argv[0] = malloc(sizeof("odp_dpdk"));
- strcpy(test_argv[0], "odp_dpdk");
- test_argv[1] = malloc(sizeof("-c"));
- strcpy(test_argv[1], "-c");
- test_argv[2] = malloc(sizeof(core_mask));
- strcpy(test_argv[2], core_mask);
- test_argv[3] = malloc(sizeof("-n"));
- strcpy(test_argv[3], "-n");
- test_argv[4] = malloc(sizeof("3"));
- strcpy(test_argv[4], "3");
-
- if (rte_eal_init(test_argc, (char **)test_argv) < 0) {
- ODP_ERR("Cannot init the Intel DPDK EAL!");
- return -1;
- }
-
- if (rte_pmd_init_all() < 0) {
- ODP_ERR("Cannot init pmd\n");
- return -1;
- }
-
- if (rte_eal_pci_probe() < 0) {
- ODP_ERR("Cannot probe PCI\n");
- return -1;
- }
-
- return 0;
-}
-
-int odp_init_global(void)
-{
- odp_thread_init_global();
-
- odp_system_info_init();
-
- if (odp_init_dpdk()) {
- ODP_ERR("ODP dpdk init failed.\n");
- return -1;
- }
-
- if (odp_shm_init_global()) {
- ODP_ERR("ODP shm init failed.\n");
- return -1;
- }
-
- if (odp_buffer_pool_init_global()) {
- ODP_ERR("ODP buffer pool init failed.\n");
- return -1;
- }
-
- if (odp_queue_init_global()) {
- ODP_ERR("ODP queue init failed.\n");
- return -1;
- }
-
- if (odp_schedule_init_global()) {
- ODP_ERR("ODP schedule init failed.\n");
- return -1;
- }
-
- if (odp_pktio_init_global()) {
- ODP_ERR("ODP packet io init failed.\n");
- return -1;
- }
-
- if (odp_timer_init_global()) {
- ODP_ERR("ODP timer init failed.\n");
- return -1;
- }
-
- return 0;
-}
-
-
-int odp_init_local(int thr_id)
-{
- odp_thread_init_local(thr_id);
-
- if (odp_pktio_init_local()) {
- ODP_ERR("ODP packet io local init failed.\n");
- return -1;
- }
-
- if (odp_schedule_init_local()) {
- ODP_ERR("ODP schedule local init failed.\n");
- return -1;
- }
-
- return 0;
-}
new file mode 100644
@@ -0,0 +1,56 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp_init.h>
+#include <odp_internal.h>
+#include <odp_debug.h>
+#include <odp_packet_dpdk.h>
+
+int odp_init_platform(odp_global_platform_init_t *platform_params ODP_UNUSED)
+{
+ int test_argc = 5;
+ char *test_argv[6];
+ int core_count, i, num_cores = 0;
+ char core_mask[8];
+
+ core_count = odp_sys_core_count();
+ for (i = 0; i < core_count; i++)
+ num_cores += (0x1 << i);
+ sprintf(core_mask, "%x", num_cores);
+
+ test_argv[0] = malloc(sizeof("odp_dpdk"));
+ strcpy(test_argv[0], "odp_dpdk");
+ test_argv[1] = malloc(sizeof("-c"));
+ strcpy(test_argv[1], "-c");
+ test_argv[2] = malloc(sizeof(core_mask));
+ strcpy(test_argv[2], core_mask);
+ test_argv[3] = malloc(sizeof("-n"));
+ strcpy(test_argv[3], "-n");
+ test_argv[4] = malloc(sizeof("3"));
+ strcpy(test_argv[4], "3");
+
+ if (rte_eal_init(test_argc, (char **)test_argv) < 0) {
+ ODP_ERR("Cannot init the Intel DPDK EAL!");
+ return -1;
+ }
+
+ if (rte_pmd_init_all() < 0) {
+ ODP_ERR("Cannot init pmd\n");
+ return -1;
+ }
+
+ if (rte_eal_pci_probe() < 0) {
+ ODP_ERR("Cannot probe PCI\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int odp_crypto_init_global(void)
+{
+ return 0;
+}
@@ -62,6 +62,7 @@ __LIB__libodp_la_SOURCES = \
odp_packet_flags.c \
odp_packet_io.c \
odp_packet_socket.c \
+ odp_platform.c \
odp_queue.c \
odp_ring.c \
odp_rwlock.c \
@@ -23,23 +23,39 @@ extern "C" {
#include <odp_std_types.h>
+/**
+ * ODP initialisation
+ * Data that is required to initialize the ODP
+ * application, such as specifying a logging callback, the log level etc.
+ */
+typedef struct odp_global_init {
+} odp_global_init_t;
+/**
+ * ODP platform initialization
+ * Platform specific data. ODP does nothing with
+ * this data.
+ */
+typedef struct odp_global_platform_init {
+} odp_global_platform_init_t;
/**
- * Perform global ODP initalisation.
+ * Perform global ODP initialisation.
*
* This function must be called once before calling
* any other ODP API functions.
*
* @return 0 if successful
*/
-int odp_init_global(void);
+int odp_init_global(odp_global_init_t *params,
+ odp_global_platform_init_t *platform_params);
/**
- * Perform thread local ODP initalisation.
+ * Perform thread local ODP initialisation.
*
* All threads must call this function before calling
+ *
* any other ODP API functions.
* @param thr_id Thread id
* @return 0 if successful
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <odp_init.h>
/**
* @file
@@ -42,6 +43,8 @@ int odp_schedule_init_local(void);
int odp_timer_init_global(void);
int odp_timer_disarm_all(void);
+int odp_init_platform(odp_global_platform_init_t *platform_params);
+
#ifdef __cplusplus
}
#endif
@@ -8,13 +8,18 @@
#include <odp_internal.h>
#include <odp_debug.h>
-
-int odp_init_global(void)
+int odp_init_global(odp_global_init_t *params ODP_UNUSED,
+ odp_global_platform_init_t *platform_params ODP_UNUSED)
{
odp_thread_init_global();
odp_system_info_init();
+ if (odp_init_platform(platform_params)) {
+ ODP_ERR("ODP platform init failed.\n");
+ return -1;
+ }
+
if (odp_shm_init_global()) {
ODP_ERR("ODP shm init failed.\n");
return -1;
new file mode 100644
@@ -0,0 +1,14 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp_init.h>
+#include <odp_internal.h>
+#include <odp_debug.h>
+
+int odp_init_platform(odp_global_platform_init_t *platform_params ODP_UNUSED)
+{
+ return 0;
+}
@@ -70,12 +70,13 @@ __LIB__libodp_la_SOURCES = \
odp_buffer.c \
odp_buffer_pool.c \
../linux-generic/odp_coremask.c \
- odp_init.c \
+ ../linux-generic/odp_init.c \
../linux-generic/odp_linux.c \
odp_packet.c \
../linux-generic/odp_packet_flags.c \
odp_packet_io.c \
../linux-generic/odp_packet_socket.c \
+ odp_platform.c \
odp_queue.c \
../linux-generic/odp_ring.c \
../linux-generic/odp_rwlock.c \
deleted file mode 100644
@@ -1,153 +0,0 @@
-/* Copyright (c) 2013, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp_init.h>
-#include <odp_internal.h>
-#include <odp_debug.h>
-#include <configs/odp_config_platform.h>
-#include <ti_em_osal_core.h>
-#include <ti_em_osal_queue.h>
-#include <ti_em_rh.h>
-#include <odp_config.h>
-#include <odp_packet_internal.h>
-
-/*
- * Make region_configs[] global, because hw_config is saved in
- * ti_em_rh_init_global() and it references region_configs[].
- */
-static ti_em_osal_hw_region_config_t region_configs[TI_ODP_REGION_NUM];
-
-static int ti_init_hw_config(void)
-{
- ti_em_rh_hw_config_t hw_config;
- ti_em_osal_hw_region_config_t *reg_config;
- memset(&hw_config, 0, sizeof(ti_em_rh_hw_config_t));
-
- /* Set ODP initialization parameters */
- hw_config.private_free_queue_idx = MY_EM_PRIVATE_FREE_QUEUE_IDX;
- hw_config.hw_queue_base_idx = MY_EM_SCHED_QUEUE_IDX;
- hw_config.dma_idx = -1; /* not used */
- hw_config.dma_queue_base_idx = 0; /* not used */
- hw_config.device_id = MY_EM_DEVICE_ID;
- hw_config.process_id = MY_EM_PROCESS_ID;
- hw_config.chain_config_ptr = NULL;
- hw_config.dispatch_mode = MY_EM_DISPATCH_MODE;
-
- /* The location of the PDSP communication memory (physical address) */
- hw_config.pdsp_comm_mem_config.paddr = MY_EM_PDSP_COMM_MEM_BASE;
- hw_config.pdsp_comm_mem_config.vaddr = MY_EM_PDSP_COMM_MEM_VBASE;
- hw_config.pdsp_comm_mem_config.size = MY_EM_PDSP_COMM_MEM_SIZE;
- hw_config.pdsp_comm_mem_config.offset = MY_EM_PDSP_COMM_MEM_OFFSET;
-
- TI_EM_OSAL_TRACE(2, "physical address of the PDSP communication memory is 0x%x\n",
- hw_config.pdsp_comm_mem_config.paddr);
-
- /* Define descriptor regions */
- reg_config = ®ion_configs[TI_EM_RH_PUBLIC];
- reg_config->region_idx = TI_ODP_PUBLIC_REGION_IDX;
- reg_config->desc_size =
- ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(odp_packet_hdr_t));
- reg_config->desc_num = TI_ODP_PUBLIC_DESC_NUM;
- reg_config->desc_base = TI_ODP_PUBLIC_DESC_BASE;
- reg_config->desc_vbase = TI_ODP_PUBLIC_DESC_VBASE;
- reg_config->desc_offset = TI_ODP_PUBLIC_DESC_OFFSET;
- reg_config->desc_flag = TI_EM_RH_UNMANAGED_DESCRIPTOR;
- reg_config->start_idx = TI_ODP_PUBLIC_START_DESC_IDX;
-
- reg_config = ®ion_configs[TI_EM_RH_PRIVATE];
- reg_config->region_idx = TI_ODP_PRIVATE_REGION_IDX;
- reg_config->desc_size = TI_EM_PRIVATE_EVENT_DSC_SIZE;
- reg_config->desc_num = TI_EM_RH_PRIVATE_EVENT_NUM;
- reg_config->desc_base = TI_ODP_PRIVATE_DESC_BASE;
- reg_config->desc_vbase = TI_ODP_PRIVATE_DESC_VBASE;
- reg_config->desc_offset = TI_ODP_PRIVATE_DESC_OFFSET;
- reg_config->desc_flag = TI_EM_RH_UNMANAGED_DESCRIPTOR;
- reg_config->start_idx = TI_ODP_PRIVATE_START_DESC_IDX;
-
- hw_config.region_num = TI_ODP_REGION_NUM;
- hw_config.region_configs = ®ion_configs[0];
-
- /* Define PDSP configuration */
- hw_config.pdsp_num = 0;
- /* do not use router (no chaining) */
- hw_config.pdsp_router.pdsp_id = -1;
-
- TI_EM_OSAL_TRACE(1, "calling EM global initialization\n");
-
- /* call OpenEM global initialization */
- if (ti_em_rh_init_global(0,
- NULL,
- MY_EM_CORE_NUM,
- &hw_config) != EM_OK) {
- TI_EM_OSAL_ERROR("EM global initialization failed!\n");
- return -1;
- }
-
- return 0;
-}
-
-
-int odp_init_global(void)
-{
- odp_thread_init_global();
-
- odp_system_info_init();
-
- ti_em_osal_core_init_global();
- ti_init_hw_config();
-
- if (odp_shm_init_global()) {
- ODP_ERR("ODP shm init failed.\n");
- return -1;
- }
-
- if (odp_buffer_pool_init_global()) {
- ODP_ERR("ODP buffer pool init failed.\n");
- return -1;
- }
-
- if (odp_queue_init_global()) {
- ODP_ERR("ODP queue init failed.\n");
- return -1;
- }
-
- if (odp_schedule_init_global()) {
- ODP_ERR("ODP schedule init failed.\n");
- return -1;
- }
-
- if (odp_pktio_init_global()) {
- ODP_ERR("ODP packet io init failed.\n");
- return -1;
- }
-
- if (odp_timer_init_global()) {
- ODP_ERR("ODP timer init failed.\n");
- return -1;
- }
-
- return 0;
-}
-
-
-int odp_init_local(int thr_id)
-{
- odp_thread_init_local(thr_id);
-
- ti_em_rh_init_local();
-
- if (odp_pktio_init_local()) {
- ODP_ERR("ODP packet io local init failed.\n");
- return -1;
- }
-
- if (odp_schedule_init_local()) {
- ODP_ERR("ODP schedule local init failed.\n");
- return -1;
- }
-
- return 0;
-}
new file mode 100644
@@ -0,0 +1,97 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp_init.h>
+#include <odp_internal.h>
+#include <odp_debug.h>
+#include <configs/odp_config_platform.h>
+#include <ti_em_osal_core.h>
+#include <ti_em_osal_queue.h>
+#include <ti_em_rh.h>
+#include <odp_config.h>
+#include <odp_packet_internal.h>
+
+/*
+ * * Make region_configs[] global, because hw_config is saved in
+ * * ti_em_rh_init_global() and it references region_configs[].
+ * */
+static ti_em_osal_hw_region_config_t region_configs[TI_ODP_REGION_NUM];
+
+int odp_init_platform(odp_global_platform_init_t *platform_params ODP_UNUSED)
+{
+ ti_em_rh_hw_config_t hw_config;
+ ti_em_osal_hw_region_config_t *reg_config;
+ memset(&hw_config, 0, sizeof(ti_em_rh_hw_config_t));
+
+ ti_em_osal_core_init_global();
+
+ /* Set ODP initialization parameters */
+ hw_config.private_free_queue_idx = MY_EM_PRIVATE_FREE_QUEUE_IDX;
+ hw_config.hw_queue_base_idx = MY_EM_SCHED_QUEUE_IDX;
+ hw_config.dma_idx = -1; /* not used */
+ hw_config.dma_queue_base_idx = 0; /* not used */
+ hw_config.device_id = MY_EM_DEVICE_ID;
+ hw_config.process_id = MY_EM_PROCESS_ID;
+ hw_config.chain_config_ptr = NULL;
+ hw_config.dispatch_mode = MY_EM_DISPATCH_MODE;
+
+ /* The location of the PDSP communication memory (physical address) */
+ hw_config.pdsp_comm_mem_config.paddr = MY_EM_PDSP_COMM_MEM_BASE;
+ hw_config.pdsp_comm_mem_config.vaddr = MY_EM_PDSP_COMM_MEM_VBASE;
+ hw_config.pdsp_comm_mem_config.size = MY_EM_PDSP_COMM_MEM_SIZE;
+ hw_config.pdsp_comm_mem_config.offset = MY_EM_PDSP_COMM_MEM_OFFSET;
+
+ TI_EM_OSAL_TRACE(2, "physical address of the PDSP communication memory is 0x%x\n",
+ hw_config.pdsp_comm_mem_config.paddr);
+
+ /* Define descriptor regions */
+ reg_config = ®ion_configs[TI_EM_RH_PUBLIC];
+ reg_config->region_idx = TI_ODP_PUBLIC_REGION_IDX;
+ reg_config->desc_size =
+ ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(odp_packet_hdr_t));
+ reg_config->desc_num = TI_ODP_PUBLIC_DESC_NUM;
+ reg_config->desc_base = TI_ODP_PUBLIC_DESC_BASE;
+ reg_config->desc_vbase = TI_ODP_PUBLIC_DESC_VBASE;
+ reg_config->desc_offset = TI_ODP_PUBLIC_DESC_OFFSET;
+ reg_config->desc_flag = TI_EM_RH_UNMANAGED_DESCRIPTOR;
+ reg_config->start_idx = TI_ODP_PUBLIC_START_DESC_IDX;
+
+ reg_config = ®ion_configs[TI_EM_RH_PRIVATE];
+ reg_config->region_idx = TI_ODP_PRIVATE_REGION_IDX;
+ reg_config->desc_size = TI_EM_PRIVATE_EVENT_DSC_SIZE;
+ reg_config->desc_num = TI_EM_RH_PRIVATE_EVENT_NUM;
+ reg_config->desc_base = TI_ODP_PRIVATE_DESC_BASE;
+ reg_config->desc_vbase = TI_ODP_PRIVATE_DESC_VBASE;
+ reg_config->desc_offset = TI_ODP_PRIVATE_DESC_OFFSET;
+ reg_config->desc_flag = TI_EM_RH_UNMANAGED_DESCRIPTOR;
+ reg_config->start_idx = TI_ODP_PRIVATE_START_DESC_IDX;
+
+ hw_config.region_num = TI_ODP_REGION_NUM;
+ hw_config.region_configs = ®ion_configs[0];
+
+ /* Define PDSP configuration */
+ hw_config.pdsp_num = 0;
+ /* do not use router (no chaining) */
+ hw_config.pdsp_router.pdsp_id = -1;
+
+ TI_EM_OSAL_TRACE(1, "calling EM global initialization\n");
+
+ /* call OpenEM global initialization */
+ if (ti_em_rh_init_global(0,
+ NULL,
+ MY_EM_CORE_NUM,
+ &hw_config) != EM_OK) {
+ TI_EM_OSAL_ERROR("EM global initialization failed!\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int odp_crypto_init_global(void)
+{
+ return 0;
+}
@@ -56,7 +56,7 @@ int odp_test_global_init(void)
{
memset(thread_tbl, 0, sizeof(thread_tbl));
- if (odp_init_global()) {
+ if (odp_init_global(NULL, NULL)) {
ODP_ERR("ODP global init failed.\n");
return -1;
}
Signed-off-by: Mike Holmes <mike.holmes@linaro.org> --- v2: Factor out odp_platform_init so that odp_global_init is only defined for linux_generic and resued. example/generator/odp_generator.c | 2 +- example/l2fwd/odp_l2fwd.c | 2 +- example/odp_example/odp_example.c | 2 +- example/packet/odp_pktio.c | 2 +- example/timer/odp_timer_test.c | 2 +- platform/linux-dpdk/Makefile.am | 3 +- platform/linux-dpdk/odp_init.c | 113 ------------------- platform/linux-dpdk/odp_platform.c | 56 ++++++++++ platform/linux-generic/Makefile.am | 1 + platform/linux-generic/include/api/odp_init.h | 22 +++- platform/linux-generic/include/odp_internal.h | 3 + platform/linux-generic/odp_init.c | 9 +- platform/linux-generic/odp_platform.c | 14 +++ platform/linux-keystone2/Makefile.am | 3 +- platform/linux-keystone2/odp_init.c | 153 -------------------------- platform/linux-keystone2/odp_platform.c | 97 ++++++++++++++++ test/api_test/odp_common.c | 2 +- 17 files changed, 207 insertions(+), 279 deletions(-) delete mode 100644 platform/linux-dpdk/odp_init.c create mode 100644 platform/linux-dpdk/odp_platform.c create mode 100644 platform/linux-generic/odp_platform.c delete mode 100644 platform/linux-keystone2/odp_init.c create mode 100644 platform/linux-keystone2/odp_platform.c