diff options
author | Vincent Hsu <vincent.hsu@linaro.org> | 2014-07-21 11:52:01 +0530 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2014-07-23 15:15:25 +0400 |
commit | 7cc718acd1fefaf3375fd7bbfad3dade0ca9e2dc (patch) | |
tree | 083dae11a6828a494325c0c0cce0b697ad63825b /platform/linux-dpdk/odp_init.c | |
parent | f9c3c07126c2d91e671464450cceb9c389a13cc9 (diff) |
Initial ODP-DPDK port
- Pulled necessary files from platform/linux-generic into
platform/linux-dpdk
- Made necessary changes in files to get it compiled with dpdk library
for eg.,
* odp_buffer_hdr_t is mapped to struct rte_mbuf
* All odp_buffer_* maps to rte_* in dpdk
* necessary initialisations like odp_init_dpdk
* All packet related changes in odp_packet.c and odp_packet_io.c
* dpdk support in odp_packet_dpdk.c
Signed-off-by: Vincent Hsu <vincent.hsu@linaro.org>
- Add/modify files to support linux-dpdk compilation in new automake
environment.
* Modified configure.ac
* Added platform/linux-dpdk/Makefile.am
* Moved all files from platform/linux-dpdk/source to
platform/linux-dpdk/.
- Added platform/linux-dpdk/README on how to clone, compile DPDK and
commands to execute on ODP.
- Made ODP_BUFFER_<TYPES> consistent with linux-generic.
- Removed odp_buffer_is_scatter API to be inline with linux-generic.
- Added platform/linux-dpdk/odp_linux.c to supply the function
and argument to the pthread created by dpdk.
Signed-off-by: Venkatesh Vivekanandan <venkatesh.vivekanandan@linaro.org>
Diffstat (limited to 'platform/linux-dpdk/odp_init.c')
-rw-r--r-- | platform/linux-dpdk/odp_init.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c new file mode 100644 index 000000000..ecc206669 --- /dev/null +++ b/platform/linux-dpdk/odp_init.c @@ -0,0 +1,113 @@ +/* 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; +} |