blob: fa1002226523dc7fd25ca0a43e51d865d9f32715 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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_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;
}
if (odp_crypto_init_global()) {
ODP_ERR("ODP crypto 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;
}
|