Showing 200 of 608 files from the diff.
Other files ignored by Codecov
m4/odp_dpdk.m4 has changed.
.travis.yml has changed.
helper/chksum.c has changed.
include/odp_api.h has changed.
bootstrap has changed.
.codecov.yml has changed.
.checkpatch.conf has changed.
DEPENDENCIES has changed.
m4/odp_pthread.m4 has changed.
CHANGELOG has changed.
configure.ac has changed.
Makefile.am has changed.
test/README has changed.
.gitignore has changed.
.shippable.yml has changed.
m4/odp_openssl.m4 has changed.
m4/odp_atomic.m4 has changed.
test/Makefile.inc has changed.
Makefile.inc has changed.
README has changed.
test/Makefile.am was deleted.

@@ -17,20 +17,24 @@
Loading
17 17
#define MAX_PKT_BURST 32
18 18
#define MAX_WORKERS 1
19 19
20 -
static int exit_thr;
21 -
static int wait_sec;
22 -
23 -
struct {
20 +
typedef struct {
24 21
	odp_pktio_t if0, if1;
25 22
	odp_pktin_queue_t if0in, if1in;
26 23
	odp_pktout_queue_t if0out, if1out;
27 24
	odph_ethaddr_t src, dst;
28 -
} global;
25 +
	odp_shm_t shm;
26 +
	odp_atomic_u32_t exit_thr;
27 +
	int wait_sec;
28 +
} global_data_t;
29 +
30 +
static global_data_t *global;
29 31
30 32
static void sig_handler(int signo ODP_UNUSED)
31 33
{
32 34
	printf("sig_handler!\n");
33 -
	exit_thr = 1;
35 +
	if (global == NULL)
36 +
		return;
37 +
	odp_atomic_store_u32(&global->exit_thr, 1);
34 38
}
35 39
36 40
static odp_pktio_t create_pktio(const char *name, odp_pool_t pool,
@@ -89,25 +93,25 @@
Loading
89 93
	int pkts, sent, tx_drops, i;
90 94
	uint64_t wait_time = odp_pktin_wait_time(ODP_TIME_SEC_IN_NS);
91 95
92 -
	if (odp_pktio_start(global.if0)) {
96 +
	if (odp_pktio_start(global->if0)) {
93 97
		printf("unable to start input interface\n");
94 98
		exit(1);
95 99
	}
96 100
	printf("started input interface\n");
97 -
	if (odp_pktio_start(global.if1)) {
101 +
	if (odp_pktio_start(global->if1)) {
98 102
		printf("unable to start output interface\n");
99 103
		exit(1);
100 104
	}
101 105
	printf("started output interface\n");
102 106
	printf("started all\n");
103 107
104 -
	while (!exit_thr) {
105 -
		pkts = odp_pktin_recv_tmo(global.if0in, pkt_tbl, MAX_PKT_BURST,
108 +
	while (!odp_atomic_load_u32(&global->exit_thr)) {
109 +
		pkts = odp_pktin_recv_tmo(global->if0in, pkt_tbl, MAX_PKT_BURST,
106 110
					  wait_time);
107 111
108 112
		if (odp_unlikely(pkts <= 0)) {
109 -
			if (wait_sec > 0)
110 -
				if (!(--wait_sec))
113 +
			if (global->wait_sec > 0)
114 +
				if (!(--global->wait_sec))
111 115
					break;
112 116
			continue;
113 117
		}
@@ -121,10 +125,10 @@
Loading
121 125
				return 0;
122 126
			}
123 127
			eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL);
124 -
			eth->src = global.src;
125 -
			eth->dst = global.dst;
128 +
			eth->src = global->src;
129 +
			eth->dst = global->dst;
126 130
		}
127 -
		sent = odp_pktout_send(global.if1out, pkt_tbl, pkts);
131 +
		sent = odp_pktout_send(global->if1out, pkt_tbl, pkts);
128 132
		if (sent < 0)
129 133
			sent = 0;
130 134
		tx_drops = pkts - sent;
@@ -137,21 +141,60 @@
Loading
137 141
138 142
int main(int argc, char **argv)
139 143
{
144 +
	odph_helper_options_t helper_options;
140 145
	odp_pool_t pool;
141 146
	odp_pool_param_t params;
142 147
	odp_cpumask_t cpumask;
143 -
	odph_odpthread_t thd[MAX_WORKERS];
148 +
	odph_thread_t thd[MAX_WORKERS];
144 149
	odp_instance_t instance;
145 -
	odph_odpthread_params_t thr_params;
150 +
	odp_init_t init_param;
151 +
	odph_thread_common_param_t thr_common;
152 +
	odph_thread_param_t thr_param;
146 153
	odph_ethaddr_t correct_src;
147 154
	uint32_t mtu1, mtu2;
155 +
	odp_shm_t shm;
148 156
149 -
	/* let helper collect its own arguments (e.g. --odph_proc) */
157 +
	/* Let helper collect its own arguments (e.g. --odph_proc) */
150 158
	argc = odph_parse_options(argc, argv);
159 +
	if (odph_options(&helper_options)) {
160 +
		printf("Error: reading ODP helper options failed.\n");
161 +
		exit(EXIT_FAILURE);
162 +
	}
163 +
164 +
	odp_init_param_init(&init_param);
165 +
	init_param.mem_model = helper_options.mem_model;
166 +
167 +
	if (odp_init_global(&instance, &init_param, NULL)) {
168 +
		printf("Error: ODP global init failed.\n");
169 +
		exit(1);
170 +
	}
171 +
172 +
	if (odp_init_local(instance, ODP_THREAD_CONTROL)) {
173 +
		printf("Error: ODP local init failed.\n");
174 +
		exit(1);
175 +
	}
176 +
177 +
	/* Reserve memory for args from shared mem */
178 +
	shm = odp_shm_reserve("_appl_global_data", sizeof(global_data_t),
179 +
			      ODP_CACHE_LINE_SIZE, 0);
180 +
	if (shm == ODP_SHM_INVALID) {
181 +
		printf("Error: shared mem reserve failed.\n");
182 +
		exit(EXIT_FAILURE);
183 +
	}
184 +
185 +
	global = odp_shm_addr(shm);
186 +
	if (global == NULL) {
187 +
		printf("Error: shared mem alloc failed.\n");
188 +
		exit(EXIT_FAILURE);
189 +
	}
190 +
191 +
	memset(global, 0, sizeof(global_data_t));
192 +
	odp_atomic_init_u32(&global->exit_thr, 0);
193 +
	global->shm = shm;
151 194
152 195
	if (argc > 7 ||
153 -
	    odph_eth_addr_parse(&global.dst, argv[3]) != 0 ||
154 -
	    odph_eth_addr_parse(&global.src, argv[4]) != 0) {
196 +
	    odph_eth_addr_parse(&global->dst, argv[3]) != 0 ||
197 +
	    odph_eth_addr_parse(&global->src, argv[4]) != 0) {
155 198
		printf("Usage: odp_l2fwd_simple eth0 eth1 01:02:03:04:05:06"
156 199
		       " 07:08:09:0a:0b:0c [-t sec]\n");
157 200
		printf("Where eth0 and eth1 are the used interfaces"
@@ -161,20 +204,10 @@
Loading
161 204
		exit(1);
162 205
	}
163 206
	if (argc == 7 && !strncmp(argv[5], "-t", 2))
164 -
		wait_sec = atoi(argv[6]);
207 +
		global->wait_sec = atoi(argv[6]);
165 208
166 -
	if (wait_sec)
167 -
		printf("running test for %d sec\n", wait_sec);
168 -
169 -
	if (odp_init_global(&instance, NULL, NULL)) {
170 -
		printf("Error: ODP global init failed.\n");
171 -
		exit(1);
172 -
	}
173 -
174 -
	if (odp_init_local(instance, ODP_THREAD_CONTROL)) {
175 -
		printf("Error: ODP local init failed.\n");
176 -
		exit(1);
177 -
	}
209 +
	if (global->wait_sec)
210 +
		printf("running test for %d sec\n", global->wait_sec);
178 211
179 212
	/* Create packet pool */
180 213
	odp_pool_param_init(&params);
@@ -190,44 +223,74 @@
Loading
190 223
		exit(1);
191 224
	}
192 225
193 -
	global.if0 = create_pktio(argv[1], pool, &global.if0in, &global.if0out);
194 -
	global.if1 = create_pktio(argv[2], pool, &global.if1in, &global.if1out);
226 +
	global->if0 = create_pktio(argv[1], pool, &global->if0in,
227 +
				   &global->if0out);
228 +
	global->if1 = create_pktio(argv[2], pool, &global->if1in,
229 +
				   &global->if1out);
195 230
196 231
	/* Do some operations to increase code coverage in tests */
197 -
	if (odp_pktio_mac_addr(global.if0, &correct_src, sizeof(correct_src))
232 +
	if (odp_pktio_mac_addr(global->if0, &correct_src, sizeof(correct_src))
198 233
	    != sizeof(correct_src))
199 234
		printf("Warning: can't get MAC address\n");
200 -
	else if (memcmp(&correct_src, &global.src, sizeof(correct_src)) != 0)
235 +
	else if (memcmp(&correct_src, &global->src, sizeof(correct_src)) != 0)
201 236
		printf("Warning: src MAC invalid\n");
202 237
203 -
	odp_pktio_promisc_mode_set(global.if0, true);
204 -
	odp_pktio_promisc_mode_set(global.if1, true);
205 -
	(void)odp_pktio_promisc_mode(global.if0);
206 -
	(void)odp_pktio_promisc_mode(global.if1);
238 +
	odp_pktio_promisc_mode_set(global->if0, true);
239 +
	odp_pktio_promisc_mode_set(global->if1, true);
240 +
	(void)odp_pktio_promisc_mode(global->if0);
241 +
	(void)odp_pktio_promisc_mode(global->if1);
207 242
208 -
	mtu1 = odp_pktin_maxlen(global.if0);
209 -
	mtu2 = odp_pktout_maxlen(global.if1);
243 +
	mtu1 = odp_pktin_maxlen(global->if0);
244 +
	mtu2 = odp_pktout_maxlen(global->if1);
210 245
	if (mtu1 && mtu2 && mtu1 > mtu2)
211 246
		printf("Warning: input MTU bigger than output MTU\n");
212 247
213 248
	odp_cpumask_default_worker(&cpumask, MAX_WORKERS);
214 249
215 -
	memset(&thr_params, 0, sizeof(thr_params));
216 -
	thr_params.start    = run_worker;
217 -
	thr_params.arg      = NULL;
218 -
	thr_params.thr_type = ODP_THREAD_WORKER;
219 -
	thr_params.instance = instance;
250 +
	memset(&thr_common, 0, sizeof(thr_common));
251 +
	memset(&thr_param, 0, sizeof(thr_param));
252 +
253 +
	thr_param.start    = run_worker;
254 +
	thr_param.thr_type = ODP_THREAD_WORKER;
255 +
256 +
	thr_common.instance    = instance;
257 +
	thr_common.cpumask     = &cpumask;
258 +
	thr_common.share_param = 1;
220 259
221 260
	signal(SIGINT, sig_handler);
222 261
223 -
	odph_odpthreads_create(thd, &cpumask, &thr_params);
224 -
	odph_odpthreads_join(thd);
262 +
	if (odph_thread_create(thd, &thr_common, &thr_param, MAX_WORKERS) !=
263 +
	    MAX_WORKERS) {
264 +
		printf("Error: failed to create threads\n");
265 +
		exit(EXIT_FAILURE);
266 +
	}
267 +
268 +
	if (odph_thread_join(thd, MAX_WORKERS) != MAX_WORKERS) {
269 +
		printf("Error: failed to join threads\n");
270 +
		exit(EXIT_FAILURE);
271 +
	}
272 +
273 +
	if (odp_pktio_stop(global->if0) || odp_pktio_close(global->if0)) {
274 +
		printf("Error: failed to close interface %s\n", argv[1]);
275 +
		exit(EXIT_FAILURE);
276 +
	}
277 +
	if (odp_pktio_stop(global->if1) || odp_pktio_close(global->if1)) {
278 +
		printf("Error: failed to close interface %s\n", argv[2]);
279 +
		exit(EXIT_FAILURE);
280 +
	}
225 281
226 282
	if (odp_pool_destroy(pool)) {
227 283
		printf("Error: pool destroy\n");
228 284
		exit(EXIT_FAILURE);
229 285
	}
230 286
287 +
	global = NULL;
288 +
	odp_mb_full();
289 +
	if (odp_shm_free(shm)) {
290 +
		printf("Error: shm free global data\n");
291 +
		exit(EXIT_FAILURE);
292 +
	}
293 +
231 294
	if (odp_term_local()) {
232 295
		printf("Error: term local\n");
233 296
		exit(EXIT_FAILURE);

@@ -4,8 +4,6 @@
Loading
4 4
 * SPDX-License-Identifier:     BSD-3-Clause
5 5
 */
6 6
7 -
#include "config.h"
8 -
9 7
#include <odp/helper/ip.h>
10 8
11 9
#include <stdio.h>

@@ -1,4 +1,6 @@
Loading
1 1
/* Copyright (c) 2018, Linaro Limited
2 +
 * Copyright (c) 2019, Nokia
3 +
 *
2 4
 * All rights reserved.
3 5
 *
4 6
 * SPDX-License-Identifier:     BSD-3-Clause
@@ -19,6 +21,9 @@
Loading
19 21
	uint32_t num_event;
20 22
	uint32_t num_round;
21 23
	uint32_t max_burst;
24 +
	uint32_t num_burst;
25 +
	uint32_t data_size;
26 +
	int      pool_type;
22 27
23 28
} test_options_t;
24 29
@@ -55,6 +60,10 @@
Loading
55 60
	       "  -e, --num_event        Number of events\n"
56 61
	       "  -r, --num_round        Number of rounds\n"
57 62
	       "  -b, --burst            Maximum number of events per operation\n"
63 +
	       "  -n, --num_burst        Number of bursts allocated/freed back-to-back\n"
64 +
	       "  -s, --data_size        Data size in bytes\n"
65 +
	       "  -t, --pool_type        0: Buffer pool (default)\n"
66 +
	       "                         1: Packet pool\n"
58 67
	       "  -h, --help             This help\n"
59 68
	       "\n");
60 69
}
@@ -70,16 +79,22 @@
Loading
70 79
		{"num_event", required_argument, NULL, 'e'},
71 80
		{"num_round", required_argument, NULL, 'r'},
72 81
		{"burst",     required_argument, NULL, 'b'},
82 +
		{"num_burst", required_argument, NULL, 'n'},
83 +
		{"data_size", required_argument, NULL, 's'},
84 +
		{"pool_type", required_argument, NULL, 't'},
73 85
		{"help",      no_argument,       NULL, 'h'},
74 86
		{NULL, 0, NULL, 0}
75 87
	};
76 88
77 -
	static const char *shortopts = "+c:e:r:b:h";
89 +
	static const char *shortopts = "+c:e:r:b:n:s:t:h";
78 90
79 91
	test_options->num_cpu   = 1;
80 92
	test_options->num_event = 1000;
81 93
	test_options->num_round = 100000;
82 94
	test_options->max_burst = 100;
95 +
	test_options->num_burst = 1;
96 +
	test_options->data_size = 64;
97 +
	test_options->pool_type = 0;
83 98
84 99
	while (1) {
85 100
		opt = getopt_long(argc, argv, shortopts, longopts, &long_index);
@@ -100,6 +115,15 @@
Loading
100 115
		case 'b':
101 116
			test_options->max_burst = atoi(optarg);
102 117
			break;
118 +
		case 'n':
119 +
			test_options->num_burst = atoi(optarg);
120 +
			break;
121 +
		case 's':
122 +
			test_options->data_size = atoi(optarg);
123 +
			break;
124 +
		case 't':
125 +
			test_options->pool_type = atoi(optarg);
126 +
			break;
103 127
		case 'h':
104 128
			/* fall through */
105 129
		default:
@@ -109,6 +133,15 @@
Loading
109 133
		}
110 134
	}
111 135
136 +
	if (test_options->num_burst * test_options->max_burst >
137 +
	    test_options->num_event) {
138 +
		printf("Not enough events (%u) for the burst configuration.\n"
139 +
		       "Use smaller burst size (%u) or less bursts (%u)\n",
140 +
		       test_options->num_event, test_options->max_burst,
141 +
		       test_options->num_burst);
142 +
		ret = -1;
143 +
	}
144 +
112 145
	return ret;
113 146
}
114 147
@@ -148,31 +181,62 @@
Loading
148 181
	odp_pool_capability_t pool_capa;
149 182
	odp_pool_param_t pool_param;
150 183
	odp_pool_t pool;
184 +
	uint32_t max_num, max_size;
151 185
	test_options_t *test_options = &global->test_options;
152 186
	uint32_t num_event = test_options->num_event;
153 187
	uint32_t num_round = test_options->num_round;
154 188
	uint32_t max_burst = test_options->max_burst;
189 +
	uint32_t num_burst = test_options->num_burst;
155 190
	uint32_t num_cpu   = test_options->num_cpu;
191 +
	uint32_t data_size = test_options->data_size;
192 +
	int packet_pool = test_options->pool_type;
156 193
157 194
	printf("\nPool performance test\n");
158 195
	printf("  num cpu    %u\n", num_cpu);
159 196
	printf("  num rounds %u\n", num_round);
160 197
	printf("  num events %u\n", num_event);
161 -
	printf("  max burst  %u\n\n", max_burst);
198 +
	printf("  max burst  %u\n", max_burst);
199 +
	printf("  num bursts %u\n", num_burst);
200 +
	printf("  data size  %u\n", data_size);
201 +
	printf("  pool type  %s\n\n", packet_pool ? "packet" : "buffer");
162 202
163 203
	if (odp_pool_capability(&pool_capa)) {
164 204
		printf("Error: Pool capa failed.\n");
165 205
		return -1;
166 206
	}
167 207
168 -
	if (num_event > pool_capa.buf.max_num) {
169 -
		printf("Max events supported %u\n", pool_capa.buf.max_num);
208 +
	if (packet_pool) {
209 +
		max_num  = pool_capa.pkt.max_num;
210 +
		max_size = pool_capa.pkt.max_len;
211 +
	} else {
212 +
		max_num  = pool_capa.buf.max_num;
213 +
		max_size = pool_capa.buf.max_size;
214 +
	}
215 +
216 +
	if (max_num && num_event > max_num) {
217 +
		printf("Error: max events supported %u\n", max_num);
218 +
		return -1;
219 +
	}
220 +
221 +
	if (max_size && data_size > max_size) {
222 +
		printf("Error: max data size supported %u\n", max_size);
170 223
		return -1;
171 224
	}
172 225
173 226
	odp_pool_param_init(&pool_param);
174 -
	pool_param.type = ODP_POOL_BUFFER;
175 -
	pool_param.buf.num = num_event;
227 +
228 +
	if (packet_pool) {
229 +
		pool_param.type        = ODP_POOL_PACKET;
230 +
		pool_param.pkt.num     = num_event;
231 +
		pool_param.pkt.len     = data_size;
232 +
		pool_param.pkt.max_num = num_event;
233 +
		pool_param.pkt.max_len = data_size;
234 +
235 +
	} else {
236 +
		pool_param.type     = ODP_POOL_BUFFER;
237 +
		pool_param.buf.num  = num_event;
238 +
		pool_param.buf.size = data_size;
239 +
	}
176 240
177 241
	pool = odp_pool_create("pool perf", &pool_param);
178 242
@@ -186,10 +250,10 @@
Loading
186 250
	return 0;
187 251
}
188 252
189 -
static int test_pool(void *arg)
253 +
static int test_buffer_pool(void *arg)
190 254
{
191 -
	int num, ret, thr;
192 -
	uint32_t i, rounds;
255 +
	int ret, thr;
256 +
	uint32_t num, num_free, num_freed, i, rounds;
193 257
	uint64_t c1, c2, cycles, nsec;
194 258
	uint64_t events, frees;
195 259
	odp_time_t t1, t2;
@@ -197,12 +261,14 @@
Loading
197 261
	test_options_t *test_options = &global->test_options;
198 262
	uint32_t num_round = test_options->num_round;
199 263
	uint32_t max_burst = test_options->max_burst;
264 +
	uint32_t num_burst = test_options->num_burst;
265 +
	uint32_t max_num = num_burst * max_burst;
200 266
	odp_pool_t pool = global->pool;
201 -
	odp_buffer_t buf[max_burst];
267 +
	odp_buffer_t buf[max_num];
202 268
203 269
	thr = odp_thread_id();
204 270
205 -
	for (i = 0; i < max_burst; i++)
271 +
	for (i = 0; i < max_num; i++)
206 272
		buf[i] = ODP_BUFFER_INVALID;
207 273
208 274
	events = 0;
@@ -216,19 +282,121 @@
Loading
216 282
	c1 = odp_cpu_cycles();
217 283
218 284
	for (rounds = 0; rounds < num_round; rounds++) {
219 -
		num = odp_buffer_alloc_multi(pool, buf, max_burst);
285 +
		num = 0;
220 286
221 -
		if (odp_likely(num > 0)) {
222 -
			events += num;
223 -
			odp_buffer_free_multi(buf, num);
224 -
			frees++;
287 +
		for (i = 0; i < num_burst; i++) {
288 +
			ret = odp_buffer_alloc_multi(pool, &buf[num],
289 +
						     max_burst);
290 +
			if (odp_unlikely(ret < 0)) {
291 +
				printf("Error: Alloc failed. Round %u\n",
292 +
				       rounds);
293 +
				if (num)
294 +
					odp_buffer_free_multi(buf, num);
295 +
296 +
				return -1;
297 +
			}
298 +
299 +
			num += ret;
300 +
		}
301 +
302 +
		if (odp_unlikely(num == 0))
225 303
			continue;
304 +
305 +
		events += num;
306 +
		num_freed = 0;
307 +
308 +
		while (num_freed < num) {
309 +
			num_free = num - num_freed;
310 +
			if (num_free > max_burst)
311 +
				num_free = max_burst;
312 +
313 +
			odp_buffer_free_multi(&buf[num_freed], num_free);
314 +
			frees++;
315 +
			num_freed += num_free;
226 316
		}
317 +
	}
227 318
228 -
		if (num < 0) {
229 -
			printf("Error: Alloc failed. Round %u\n", rounds);
230 -
			ret = -1;
231 -
			break;
319 +
	c2 = odp_cpu_cycles();
320 +
	t2 = odp_time_local();
321 +
322 +
	nsec   = odp_time_diff_ns(t2, t1);
323 +
	cycles = odp_cpu_cycles_diff(c2, c1);
324 +
325 +
	/* Update stats*/
326 +
	global->stat[thr].rounds = rounds;
327 +
	global->stat[thr].frees  = frees;
328 +
	global->stat[thr].events = events;
329 +
	global->stat[thr].nsec   = nsec;
330 +
	global->stat[thr].cycles = cycles;
331 +
332 +
	return 0;
333 +
}
334 +
335 +
static int test_packet_pool(void *arg)
336 +
{
337 +
	int ret, thr;
338 +
	uint32_t num, num_free, num_freed, i, rounds;
339 +
	uint64_t c1, c2, cycles, nsec;
340 +
	uint64_t events, frees;
341 +
	odp_time_t t1, t2;
342 +
	test_global_t *global = arg;
343 +
	test_options_t *test_options = &global->test_options;
344 +
	uint32_t num_round = test_options->num_round;
345 +
	uint32_t max_burst = test_options->max_burst;
346 +
	uint32_t num_burst = test_options->num_burst;
347 +
	uint32_t max_num = num_burst * max_burst;
348 +
	uint32_t data_size = test_options->data_size;
349 +
	odp_pool_t pool = global->pool;
350 +
	odp_packet_t pkt[max_num];
351 +
352 +
	thr = odp_thread_id();
353 +
354 +
	for (i = 0; i < max_num; i++)
355 +
		pkt[i] = ODP_PACKET_INVALID;
356 +
357 +
	events = 0;
358 +
	frees = 0;
359 +
	ret = 0;
360 +
361 +
	/* Start all workers at the same time */
362 +
	odp_barrier_wait(&global->barrier);
363 +
364 +
	t1 = odp_time_local();
365 +
	c1 = odp_cpu_cycles();
366 +
367 +
	for (rounds = 0; rounds < num_round; rounds++) {
368 +
		num = 0;
369 +
370 +
		for (i = 0; i < num_burst; i++) {
371 +
			ret = odp_packet_alloc_multi(pool, data_size, &pkt[num],
372 +
						     max_burst);
373 +
			if (odp_unlikely(ret < 0)) {
374 +
				printf("Error: Alloc failed. Round %u\n",
375 +
				       rounds);
376 +
377 +
				if (num)
378 +
					odp_packet_free_multi(pkt, num);
379 +
380 +
				return -1;
381 +
			}
382 +
383 +
			num += ret;
384 +
		}
385 +
386 +
		if (odp_unlikely(num == 0))
387 +
			continue;
388 +
389 +
		events += num;
390 +
		num_freed = 0;
391 +
392 +
		while (num_freed < num) {
393 +
			num_free = num - num_freed;
394 +
			if (num_free > max_burst)
395 +
				num_free = max_burst;
396 +
397 +
			odp_packet_free_multi(&pkt[num_freed], num_free);
398 +
			frees++;
399 +
			num_freed += num_free;
232 400
		}
233 401
	}
234 402
@@ -245,7 +413,7 @@
Loading
245 413
	global->stat[thr].nsec   = nsec;
246 414
	global->stat[thr].cycles = cycles;
247 415
248 -
	return ret;
416 +
	return 0;
249 417
}
250 418
251 419
static int start_workers(test_global_t *global, odp_instance_t instance)
@@ -253,13 +421,18 @@
Loading
253 421
	odph_odpthread_params_t thr_params;
254 422
	test_options_t *test_options = &global->test_options;
255 423
	int num_cpu = test_options->num_cpu;
424 +
	int packet_pool = test_options->pool_type;
256 425
257 426
	memset(&thr_params, 0, sizeof(thr_params));
258 427
	thr_params.thr_type = ODP_THREAD_WORKER;
259 428
	thr_params.instance = instance;
260 -
	thr_params.start    = test_pool;
261 429
	thr_params.arg      = global;
262 430
431 +
	if (packet_pool)
432 +
		thr_params.start = test_packet_pool;
433 +
	else
434 +
		thr_params.start = test_buffer_pool;
435 +
263 436
	if (odph_odpthreads_create(global->thread_tbl, &global->cpumask,
264 437
				   &thr_params) != num_cpu)
265 438
		return -1;
@@ -270,9 +443,11 @@
Loading
270 443
static void print_stat(test_global_t *global)
271 444
{
272 445
	int i, num;
273 -
	double rounds_ave, frees_ave, events_ave, nsec_ave, cycles_ave;
446 +
	double rounds_ave, allocs_ave, frees_ave;
447 +
	double events_ave, nsec_ave, cycles_ave;
274 448
	test_options_t *test_options = &global->test_options;
275 449
	int num_cpu = test_options->num_cpu;
450 +
	uint32_t num_burst = test_options->num_burst;
276 451
	uint64_t rounds_sum = 0;
277 452
	uint64_t frees_sum = 0;
278 453
	uint64_t events_sum = 0;
@@ -294,6 +469,7 @@
Loading
294 469
	}
295 470
296 471
	rounds_ave = rounds_sum / num_cpu;
472 +
	allocs_ave = (num_burst * rounds_sum) / num_cpu;
297 473
	frees_ave  = frees_sum / num_cpu;
298 474
	events_ave = events_sum / num_cpu;
299 475
	nsec_ave   = nsec_sum / num_cpu;
@@ -318,7 +494,7 @@
Loading
318 494
319 495
	printf("RESULTS - average over %i threads:\n", num_cpu);
320 496
	printf("----------------------------------\n");
321 -
	printf("  alloc calls:          %.3f\n", rounds_ave);
497 +
	printf("  alloc calls:          %.3f\n", allocs_ave);
322 498
	printf("  free calls:           %.3f\n", frees_ave);
323 499
	printf("  duration:             %.3f msec\n", nsec_ave / 1000000);
324 500
	printf("  num cycles:           %.3f M\n", cycles_ave / 1000000);
@@ -327,9 +503,11 @@
Loading
327 503
	printf("  cycles per event:     %.3f\n",
328 504
	       cycles_ave / events_ave);
329 505
	printf("  ave events allocated: %.3f\n",
330 -
	       events_ave / rounds_ave);
331 -
	printf("  operations per sec:   %.3f M\n",
332 -
	       (1000.0 * rounds_ave) / nsec_ave);
506 +
	       events_ave / allocs_ave);
507 +
	printf("  allocs per sec:       %.3f M\n",
508 +
	       (1000.0 * allocs_ave) / nsec_ave);
509 +
	printf("  frees per sec:        %.3f M\n",
510 +
	       (1000.0 * frees_ave) / nsec_ave);
333 511
	printf("  events per sec:       %.3f M\n\n",
334 512
	       (1000.0 * events_ave) / nsec_ave);
335 513
}
@@ -350,6 +528,7 @@
Loading
350 528
	/* List features not to be used */
351 529
	odp_init_param_init(&init);
352 530
	init.not_used.feat.cls      = 1;
531 +
	init.not_used.feat.compress = 1;
353 532
	init.not_used.feat.crypto   = 1;
354 533
	init.not_used.feat.ipsec    = 1;
355 534
	init.not_used.feat.schedule = 1;
@@ -368,6 +547,8 @@
Loading
368 547
		return -1;
369 548
	}
370 549
550 +
	odp_sys_info_print();
551 +
371 552
	if (set_num_cpu(global))
372 553
		return -1;
373 554

@@ -1,4 +1,5 @@
Loading
1 1
/* Copyright (c) 2013-2018, Linaro Limited
2 +
 * Copyright (c) 2019, Nokia
2 3
 * All rights reserved.
3 4
 *
4 5
 * SPDX-License-Identifier:     BSD-3-Clause
@@ -25,10 +26,13 @@
Loading
25 26
#include <odp/api/plat/packet_inline_types.h>
26 27
#include <odp/api/packet_io.h>
27 28
#include <odp/api/crypto.h>
29 +
#include <odp/api/comp.h>
28 30
#include <odp_ipsec_internal.h>
29 31
#include <odp/api/abi/packet.h>
30 32
#include <odp_queue_if.h>
31 33
34 +
#include <stdint.h>
35 +
32 36
/** Minimum segment length expected by packet_parse_common() */
33 37
#define PACKET_PARSE_SEG_LEN 96
34 38
@@ -64,6 +68,11 @@
Loading
64 68
/* Packet extra data types */
65 69
#define PKT_EXTRA_TYPE_DPDK 1
66 70
71 +
/* Maximum number of segments per packet */
72 +
#define PKT_MAX_SEGS 255
73 +
74 +
ODP_STATIC_ASSERT(PKT_MAX_SEGS < UINT16_MAX, "PACKET_MAX_SEGS_ERROR");
75 +
67 76
/**
68 77
 * Internal Packet header
69 78
 *
@@ -71,35 +80,39 @@
Loading
71 80
 * packet_init(). Because of this any new fields added must be reviewed for
72 81
 * initialization requirements.
73 82
 */
74 -
typedef struct {
75 -
	/* common buffer header */
83 +
typedef struct odp_packet_hdr_t {
84 +
	/* Common buffer header */
76 85
	odp_buffer_hdr_t buf_hdr;
77 86
78 -
	/*
79 -
	 * Following members are initialized by packet_init()
80 -
	 */
87 +
	/* --- 64 bytes --- */
88 +
89 +
	/* Segment data start */
90 +
	uint8_t *seg_data;
81 91
82 92
	packet_parser_t p;
83 93
84 94
	odp_pktio_t input;
85 95
96 +
	/* Next header which continues the segment list */
97 +
	struct odp_packet_hdr_t *seg_next;
98 +
99 +
	/* Total packet length */
86 100
	uint32_t frame_len;
87 101
102 +
	/* Segment data length */
103 +
	uint32_t seg_len;
104 +
105 +
	/* Total segment count */
106 +
	uint16_t seg_count;
107 +
88 108
	uint16_t headroom;
109 +
89 110
	uint16_t tailroom;
90 111
91 112
	/* Event subtype */
92 -
	int8_t subtype;
113 +
	int8_t   subtype;
93 114
94 -
	/*
95 -
	 * Members below are not initialized by packet_init()
96 -
	 */
97 -
98 -
	/* Type of extra data */
99 -
	uint8_t extra_type;
100 -
101 -
	/* Flow hash value */
102 -
	uint32_t flow_hash;
115 +
	/* --- 128 bytes --- */
103 116
104 117
	/* Timestamp value */
105 118
	odp_time_t timestamp;
@@ -107,17 +120,25 @@
Loading
107 120
	/* Classifier destination queue */
108 121
	odp_queue_t dst_queue;
109 122
110 -
	/* Result for crypto packet op */
111 -
	odp_crypto_packet_result_t crypto_op_result;
123 +
	/* Flow hash value */
124 +
	uint32_t flow_hash;
112 125
113 -
	/* Context for IPsec */
114 -
	odp_ipsec_packet_result_t ipsec_ctx;
126 +
	/* Classifier mark */
127 +
	uint16_t cls_mark;
128 +
129 +
	union {
130 +
		struct {
131 +
			/* Result for crypto packet op */
132 +
			odp_crypto_packet_result_t crypto_op_result;
133 +
134 +
			/* Context for IPsec */
135 +
			odp_ipsec_packet_result_t ipsec_ctx;
136 +
		};
137 +
138 +
		/* Result for comp packet op */
139 +
		odp_comp_packet_result_t comp_op_result;
140 +
	};
115 141
116 -
#ifdef ODP_PKTIO_DPDK
117 -
	/* Extra space for packet descriptors. E.g. DPDK mbuf. Keep as the last
118 -
	 * member before data. */
119 -
	uint8_t ODP_ALIGNED_CACHE extra[PKT_EXTRA_LEN];
120 -
#endif
121 142
	/* Packet data storage */
122 143
	uint8_t data[0];
123 144
} odp_packet_hdr_t;
@@ -145,19 +166,12 @@
Loading
145 166
	return (odp_packet_t)(odp_packet_hdr_t *)buf_hdr;
146 167
}
147 168
148 -
static inline seg_entry_t *seg_entry_last(odp_packet_hdr_t *hdr)
169 +
static inline odp_packet_hdr_t *packet_last_seg(odp_packet_hdr_t *hdr)
149 170
{
150 -
	odp_packet_hdr_t *last;
151 -
	uint8_t last_seg;
171 +
	while (hdr->seg_next != NULL)
172 +
		hdr = hdr->seg_next;
152 173
153 -
	last     = hdr->buf_hdr.last_seg;
154 -
	last_seg = last->buf_hdr.num_seg - 1;
155 -
	return &last->buf_hdr.seg[last_seg];
156 -
}
157 -
158 -
static inline odp_event_subtype_t packet_subtype(odp_packet_t pkt)
159 -
{
160 -
	return packet_hdr(pkt)->subtype;
174 +
	return hdr;
161 175
}
162 176
163 177
static inline void packet_subtype_set(odp_packet_t pkt, int ev)
@@ -172,23 +186,24 @@
Loading
172 186
{
173 187
	pool_t *pool = pkt_hdr->buf_hdr.pool_ptr;
174 188
	uint32_t seg_len;
175 -
	int num = pkt_hdr->buf_hdr.segcount;
189 +
	int num = pkt_hdr->seg_count;
176 190
177 -
	if (odp_likely(CONFIG_PACKET_SEG_DISABLED || num == 1)) {
191 +
	if (odp_likely(num == 1)) {
178 192
		seg_len = len;
179 -
		pkt_hdr->buf_hdr.seg[0].len = len;
193 +
		pkt_hdr->seg_len = len;
180 194
	} else {
181 -
		seg_entry_t *last;
195 +
		odp_packet_hdr_t *last;
182 196
183 197
		seg_len = len - ((num - 1) * pool->seg_len);
184 198
185 199
		/* Last segment data length */
186 -
		last      = seg_entry_last(pkt_hdr);
187 -
		last->len = seg_len;
200 +
		last = packet_last_seg(pkt_hdr);
201 +
		last->seg_len = seg_len;
188 202
	}
189 203
190 -
	pkt_hdr->p.input_flags.all  = 0;
191 -
	pkt_hdr->p.flags.all_flags  = 0;
204 +
	/* Clear all flags. Resets also return value of cls_mark, user_ptr, etc. */
205 +
	pkt_hdr->p.input_flags.all = 0;
206 +
	pkt_hdr->p.flags.all_flags = 0;
192 207
193 208
	pkt_hdr->p.l2_offset = 0;
194 209
	pkt_hdr->p.l3_offset = ODP_PACKET_OFFSET_INVALID;
@@ -222,15 +237,37 @@
Loading
222 237
	dst_hdr->dst_queue = src_hdr->dst_queue;
223 238
	dst_hdr->flow_hash = src_hdr->flow_hash;
224 239
	dst_hdr->timestamp = src_hdr->timestamp;
240 +
	dst_hdr->cls_mark  = src_hdr->cls_mark;
241 +
}
242 +
243 +
static inline void *packet_data(odp_packet_hdr_t *pkt_hdr)
244 +
{
245 +
	return pkt_hdr->seg_data;
246 +
}
247 +
248 +
static inline void push_head(odp_packet_hdr_t *pkt_hdr, uint32_t len)
249 +
{
250 +
	pkt_hdr->headroom  -= len;
251 +
	pkt_hdr->frame_len += len;
252 +
	pkt_hdr->seg_data -= len;
253 +
	pkt_hdr->seg_len  += len;
254 +
}
255 +
256 +
static inline void pull_head(odp_packet_hdr_t *pkt_hdr, uint32_t len)
257 +
{
258 +
	pkt_hdr->headroom  += len;
259 +
	pkt_hdr->frame_len -= len;
260 +
	pkt_hdr->seg_data  += len;
261 +
	pkt_hdr->seg_len   -= len;
225 262
}
226 263
227 264
static inline void pull_tail(odp_packet_hdr_t *pkt_hdr, uint32_t len)
228 265
{
229 -
	seg_entry_t *last = seg_entry_last(pkt_hdr);
266 +
	odp_packet_hdr_t *last = packet_last_seg(pkt_hdr);
230 267
231 268
	pkt_hdr->tailroom  += len;
232 269
	pkt_hdr->frame_len -= len;
233 -
	last->len          -= len;
270 +
	last->seg_len      -= len;
234 271
}
235 272
236 273
static inline uint32_t packet_len(odp_packet_hdr_t *pkt_hdr)
@@ -256,7 +293,18 @@
Loading
256 293
		       odp_proto_chksums_t chksums);
257 294
258 295
/* Reset parser metadata for a new parse */
259 -
void packet_parse_reset(odp_packet_hdr_t *pkt_hdr);
296 +
static inline void packet_parse_reset(odp_packet_hdr_t *pkt_hdr, int all)
297 +
{
298 +
	pkt_hdr->p.input_flags.all  = 0;
299 +
	pkt_hdr->p.l2_offset        = ODP_PACKET_OFFSET_INVALID;
300 +
	pkt_hdr->p.l3_offset        = ODP_PACKET_OFFSET_INVALID;
301 +
	pkt_hdr->p.l4_offset        = ODP_PACKET_OFFSET_INVALID;
302 +
303 +
	if (all)
304 +
		pkt_hdr->p.flags.all_flags = 0;
305 +
	else /* Keep user ptr and pktout flags */
306 +
		pkt_hdr->p.flags.all.error = 0;
307 +
}
260 308
261 309
static inline int packet_hdr_has_l2(odp_packet_hdr_t *pkt_hdr)
262 310
{
@@ -310,7 +358,6 @@
Loading
310 358
int _odp_packet_udp_chksum_insert(odp_packet_t pkt);
311 359
int _odp_packet_sctp_chksum_insert(odp_packet_t pkt);
312 360
313 -
314 361
#ifdef __cplusplus
315 362
}
316 363
#endif

@@ -1,17 +1,16 @@
Loading
1 -
/* Copyright (c) 2013-2018, Linaro Limited
1 +
/* Copyright (c) 2019, Nokia
2 +
 * Copyright (c) 2013-2018, Linaro Limited
2 3
 * All rights reserved.
3 4
 *
4 5
 * SPDX-License-Identifier:     BSD-3-Clause
5 6
 */
6 7
7 -
#include "config.h"
8 -
9 8
#include <odp_config_internal.h>
10 9
#include <odp/api/debug.h>
11 10
#include <odp/api/std_types.h>
12 11
#include <odp/api/shared_memory.h>
13 12
#include <odp/api/plat/strong_types.h>
14 -
#include <odp_ishm_internal.h>
13 +
#include <odp_shm_internal.h>
15 14
#include <odp_init_internal.h>
16 15
#include <odp_global_data.h>
17 16
#include <string.h>
@@ -49,7 +48,7 @@
Loading
49 48
	memset(capa, 0, sizeof(odp_shm_capability_t));
50 49
51 50
	capa->max_blocks = ODP_CONFIG_SHM_BLOCKS;
52 -
	capa->max_size = odp_global_data.shm_max_size;
51 +
	capa->max_size = odp_global_ro.shm_max_size;
53 52
	capa->max_align = 0;
54 53
55 54
	return 0;
@@ -59,11 +58,11 @@
Loading
59 58
			  uint32_t flags)
60 59
{
61 60
	int block_index;
62 -
	int flgs = 0; /* internal ishm flags */
61 +
	uint32_t flgs = 0; /* internal ishm flags */
63 62
64 63
	flgs = get_ishm_flags(flags);
65 64
66 -
	block_index = _odp_ishm_reserve(name, size, -1, align, flgs, flags);
65 +
	block_index = _odp_ishm_reserve(name, size, -1, align, 0, flgs, flags);
67 66
	if (block_index >= 0)
68 67
		return to_handle(block_index);
69 68
	else
@@ -115,7 +114,7 @@
Loading
115 114
116 115
void odp_shm_print_all(void)
117 116
{
118 -
	_odp_ishm_status("Memory allocation status:");
117 +
	_odp_ishm_status("ODP shared memory allocation status:");
119 118
}
120 119
121 120
void odp_shm_print(odp_shm_t shm)

@@ -4,8 +4,6 @@
Loading
4 4
 * SPDX-License-Identifier:     BSD-3-Clause
5 5
 */
6 6
7 -
#include "config.h"
8 -
9 7
/**
10 8
 * @file
11 9
 *
@@ -31,7 +29,8 @@
Loading
31 29
 *           doesn't exist it will be created, if it does exist it will
32 30
 *           be overwritten.
33 31
 *   loops   the number of times to iterate through the input file, set
34 -
 *           to 0 to loop indefinitely. The default value is 1.
32 +
 *           to 0 to loop indefinitely. The default value is 1. Looping is
33 +
 *           only supported in thread mode (ODP_MEM_MODEL_THREAD).
35 34
 *
36 35
 * The total length of the string is limited by PKTIO_NAME_LEN.
37 36
 */
@@ -40,6 +39,7 @@
Loading
40 39
41 40
#include <odp_api.h>
42 41
#include <odp/api/plat/packet_inlines.h>
42 +
#include <odp_global_data.h>
43 43
#include <odp_packet_internal.h>
44 44
#include <odp_packet_io_internal.h>
45 45
@@ -56,7 +56,6 @@
Loading
56 56
	void *tx;		/**< tx pcap handle */
57 57
	void *tx_dump;		/**< tx pcap dumper handle */
58 58
	odp_pool_t pool;	/**< rx pool */
59 -
	unsigned char *buf;	/**< per-pktio temp buffer */
60 59
	int loops;		/**< number of times to loop rx pcap */
61 60
	int loop_cnt;		/**< number of loops completed */
62 61
	odp_bool_t promisc;	/**< promiscuous mode state */
@@ -141,12 +140,6 @@
Loading
141 140
		pcap->tx = tx;
142 141
	}
143 142
144 -
	pcap->buf = malloc(PKTIO_PCAP_MTU);
145 -
	if (!pcap->buf) {
146 -
		ODP_ERR("failed to malloc temp buffer\n");
147 -
		return -1;
148 -
	}
149 -
150 143
	pcap->tx_dump = pcap_dump_open(tx, pcap->fname_tx);
151 144
	if (!pcap->tx_dump) {
152 145
		ODP_ERR("failed to open dump file %s (%s)\n",
@@ -198,7 +191,6 @@
Loading
198 191
	if (pcap->rx)
199 192
		pcap_close(pcap->rx);
200 193
201 -
	free(pcap->buf);
202 194
	free(pcap->fname_rx);
203 195
	free(pcap->fname_tx);
204 196
@@ -209,6 +201,10 @@
Loading
209 201
{
210 202
	char errbuf[PCAP_ERRBUF_SIZE];
211 203
204 +
	/* Reopen causes pcap internal failure in process mode */
205 +
	if (odp_global_ro.init_param.mem_model == ODP_MEM_MODEL_PROCESS)
206 +
		return 1;
207 +
212 208
	if (pcap->loops != 0 && ++pcap->loop_cnt >= pcap->loops)
213 209
		return 1;
214 210
@@ -237,10 +233,11 @@
Loading
237 233
	pkt_pcap_t *pcap = pkt_priv(pktio_entry);
238 234
	odp_time_t ts_val;
239 235
	odp_time_t *ts = NULL;
236 +
	uint16_t frame_offset = pktio_entry->s.pktin_frame_offset;
240 237
241 238
	odp_ticketlock_lock(&pktio_entry->s.rxl);
242 239
243 -
	if (pktio_entry->s.state != PKTIO_STATE_STARTED || !pcap->rx) {
240 +
	if (odp_unlikely(!pcap->rx)) {
244 241
		odp_ticketlock_unlock(&pktio_entry->s.rxl);
245 242
		return 0;
246 243
	}
@@ -262,7 +259,8 @@
Loading
262 259
263 260
		pkt_len = hdr->caplen;
264 261
265 -
		ret = packet_alloc_multi(pcap->pool, pkt_len, &pkt, 1);
262 +
		ret = packet_alloc_multi(pcap->pool, pkt_len + frame_offset,
263 +
					 &pkt, 1);
266 264
		if (odp_unlikely(ret != 1))
267 265
			break;
268 266
@@ -270,8 +268,10 @@
Loading
270 268
			ts_val = odp_time_global();
271 269
272 270
		pkt_hdr = packet_hdr(pkt);
271 +
		if (frame_offset)
272 +
			pull_head(pkt_hdr, frame_offset);
273 273
274 -
		if (odp_packet_copy_from_mem(pkt, 0, hdr->caplen, data) != 0) {
274 +
		if (odp_packet_copy_from_mem(pkt, 0, pkt_len, data) != 0) {
275 275
			ODP_ERR("failed to copy packet data\n");
276 276
			break;
277 277
		}
@@ -298,6 +298,7 @@
Loading
298 298
static int _pcapif_dump_pkt(pkt_pcap_t *pcap, odp_packet_t pkt)
299 299
{
300 300
	struct pcap_pkthdr hdr;
301 +
	uint8_t tx_buf[PKTIO_PCAP_MTU];
301 302
302 303
	if (!pcap->tx_dump)
303 304
		return 0;
@@ -306,10 +307,10 @@
Loading
306 307
	hdr.len = hdr.caplen;
307 308
	(void)gettimeofday(&hdr.ts, NULL);
308 309
309 -
	if (odp_packet_copy_to_mem(pkt, 0, hdr.len, pcap->buf) != 0)
310 +
	if (odp_packet_copy_to_mem(pkt, 0, hdr.len, tx_buf) != 0)
310 311
		return -1;
311 312
312 -
	pcap_dump(pcap->tx_dump, &hdr, pcap->buf);
313 +
	pcap_dump(pcap->tx_dump, &hdr, tx_buf);
313 314
	(void)pcap_dump_flush(pcap->tx_dump);
314 315
315 316
	return 0;
@@ -323,11 +324,6 @@
Loading
323 324
324 325
	odp_ticketlock_lock(&pktio_entry->s.txl);
325 326
326 -
	if (pktio_entry->s.state != PKTIO_STATE_STARTED) {
327 -
		odp_ticketlock_unlock(&pktio_entry->s.txl);
328 -
		return 0;
329 -
	}
330 -
331 327
	for (i = 0; i < num; ++i) {
332 328
		int pkt_len = odp_packet_len(pkts[i]);
333 329
@@ -448,6 +444,26 @@
Loading
448 444
	return 0;
449 445
}
450 446
447 +
static int pcapif_link_status(pktio_entry_t *pktio_entry ODP_UNUSED)
448 +
{
449 +
	return ODP_PKTIO_LINK_STATUS_UP;
450 +
}
451 +
452 +
static int pcapif_link_info(pktio_entry_t *pktio_entry ODP_UNUSED, odp_pktio_link_info_t *info)
453 +
{
454 +
	memset(info, 0, sizeof(odp_pktio_link_info_t));
455 +
456 +
	info->autoneg = ODP_PKTIO_LINK_AUTONEG_OFF;
457 +
	info->duplex = ODP_PKTIO_LINK_DUPLEX_FULL;
458 +
	info->media = "virtual";
459 +
	info->pause_rx = ODP_PKTIO_LINK_PAUSE_OFF;
460 +
	info->pause_tx = ODP_PKTIO_LINK_PAUSE_OFF;
461 +
	info->speed = ODP_PKTIO_LINK_SPEED_UNKNOWN;
462 +
	info->status = ODP_PKTIO_LINK_STATUS_UP;
463 +
464 +
	return 0;
465 +
}
466 +
451 467
const pktio_if_ops_t pcap_pktio_ops = {
452 468
	.name = "pcap",
453 469
	.print = NULL,
@@ -470,4 +486,6 @@
Loading
470 486
	.config = NULL,
471 487
	.input_queues_config = NULL,
472 488
	.output_queues_config = NULL,
489 +
	.link_status = pcapif_link_status,
490 +
	.link_info = pcapif_link_info
473 491
};

@@ -10,43 +10,29 @@
Loading
10 10
 * anything else than the ODP API header file.
11 11
 */
12 12
13 -
/* Linux CPU affinity */
14 -
#define _GNU_SOURCE
15 -
#include <sched.h>
16 -
17 -
/* Linux PID */
18 -
#include <sys/types.h>
19 -
#include <unistd.h>
20 -
21 13
#include <stdio.h>
22 14
#include <string.h>
23 15
24 16
#include <odp_api.h>
25 17
26 18
typedef struct {
27 -
	int cpu;
28 19
	int num;
29 20
} options_t;
30 21
31 22
static int parse_args(int argc, char *argv[], options_t *opt)
32 23
{
33 -
	static const char * const args[] = {"-c", "-n"};
24 +
	static const char * const args[] = {"-n"};
34 25
	int i, tmp;
35 26
36 27
	for (i = 1; i < argc; i++) {
37 -
		if ((strcmp(argv[i], args[0]) == 0) &&
28 +
		if ((strcmp(argv[i], args[0]) == 0) && argv[i + 1] &&
38 29
		    (sscanf(argv[i + 1], "%i", &tmp) == 1)) {
39 -
			opt->cpu = tmp;
40 -
			i++;
41 -
		} else if ((strcmp(argv[i], args[1]) == 0) &&
42 -
			   (sscanf(argv[i + 1], "%i", &tmp) == 1)) {
43 30
			opt->num = tmp;
44 31
			i++;
45 32
		} else {
46 33
			printf("\nUsage:\n"
47 -
			       "  %s  CPU number\n"
48 -
			       "  %s  Number of iterations\n\n",
49 -
			       args[0], args[1]);
34 +
			       "  [%s  Number of iterations]\n\n",
35 +
			       args[0]);
50 36
			return -1;
51 37
		}
52 38
	}
@@ -58,36 +44,19 @@
Loading
58 44
{
59 45
	odp_instance_t inst;
60 46
	options_t opt;
61 -
	pid_t pid;
62 -
	cpu_set_t cpu_set;
63 47
	int i;
64 -
	odp_cpumask_t mask;
65 48
66 49
	memset(&opt, 0, sizeof(opt));
67 -
	opt.cpu = 0;
68 50
	opt.num = 1;
69 51
70 52
	if (parse_args(argc, argv, &opt))
71 53
		return -1;
72 54
73 -
	pid = getpid();
74 -
75 55
	if (odp_init_global(&inst, NULL, NULL)) {
76 56
		printf("Global init failed.\n");
77 57
		return -1;
78 58
	}
79 59
80 -
	odp_cpumask_default_control(&mask, 0);
81 -
	opt.cpu = odp_cpumask_first(&mask);
82 -
83 -
	CPU_ZERO(&cpu_set);
84 -
	CPU_SET(opt.cpu, &cpu_set);
85 -
86 -
	if (sched_setaffinity(pid, sizeof(cpu_set_t), &cpu_set)) {
87 -
		printf("Set CPU affinity failed.\n");
88 -
		return -1;
89 -
	}
90 -
91 60
	if (odp_init_local(inst, ODP_THREAD_CONTROL)) {
92 61
		printf("Local init failed.\n");
93 62
		return -1;

@@ -18,30 +18,22 @@
Loading
18 18
extern "C" {
19 19
#endif
20 20
21 -
/** List object */
21 +
/** @cond _ODP_HIDE_FROM_DOXYGEN_ */
22 +
22 23
typedef struct odph_list_object {
23 -
	/** Next element in list */
24 24
	struct odph_list_object *next;
25 25
26 -
	/** Previous element in list */
27 26
	struct odph_list_object *prev;
28 27
} odph_list_object;
29 28
30 -
/** Head of list */
31 29
typedef odph_list_object odph_list_head;
32 30
33 -
/**
34 -
 * @internal Intiailize list head element
35 -
 *
36 -
 * @param list List object to be initialized
37 -
 */
38 31
static inline void ODPH_INIT_LIST_HEAD(odph_list_object *list)
39 32
{
40 33
	list->next = list;
41 34
	list->prev = list;
42 35
}
43 36
44 -
/** @internal Inline function @param new @param prev @param next */
45 37
static inline void __odph_list_add(odph_list_object *new,
46 38
				   odph_list_object *prev,
47 39
				   odph_list_object *next)
@@ -52,20 +44,17 @@
Loading
52 44
	prev->next = new;
53 45
}
54 46
55 -
/** @internal Inline function @param new @param head */
56 47
static inline void odph_list_add(odph_list_object *new, odph_list_object *head)
57 48
{
58 49
	__odph_list_add(new, head, head->next);
59 50
}
60 51
61 -
/** @internal Inline function @param new @param head */
62 52
static inline void odph_list_add_tail(struct odph_list_object *new,
63 53
				      odph_list_object *head)
64 54
{
65 55
	__odph_list_add(new, head->prev, head);
66 56
}
67 57
68 -
/** @internal Inline function @param prev @param next */
69 58
static inline void __odph_list_del(struct odph_list_object *prev,
70 59
				   odph_list_object *next)
71 60
{
@@ -73,29 +62,27 @@
Loading
73 62
	prev->next = next;
74 63
}
75 64
76 -
/** @internal Inline function @param entry */
77 65
static inline void odph_list_del(struct odph_list_object *entry)
78 66
{
79 67
	__odph_list_del(entry->prev, entry->next);
80 68
	ODPH_INIT_LIST_HEAD(entry);
81 69
}
82 70
83 -
/** @internal Inline function @param head @return */
84 71
static inline int odph_list_empty(const struct odph_list_object *head)
85 72
{
86 73
	return head->next == head;
87 74
}
88 75
89 -
/** @internal */
90 76
#define container_of(ptr, type, list_node) \
91 77
		((type *)(void *)((char *)ptr - offsetof(type, list_node)))
92 78
93 -
/** @internal */
94 79
#define ODPH_LIST_FOR_EACH(pos, list_head, type, list_node) \
95 80
	for (pos = container_of((list_head)->next, type, list_node); \
96 81
		&pos->list_node != (list_head); \
97 82
		pos = container_of(pos->list_node.next, type, list_node))
98 83
84 +
/** @endcond */
85 +
99 86
#ifdef __cplusplus
100 87
}
101 88
#endif

@@ -4,8 +4,6 @@
Loading
4 4
 * SPDX-License-Identifier:	BSD-3-Clause
5 5
 */
6 6
7 -
#include "config.h"
8 -
9 7
#include <odp/api/errno.h>
10 8
#include <string.h>
11 9
#include <stdio.h>
@@ -26,9 +24,9 @@
Loading
26 24
void odp_errno_print(const char *str)
27 25
{
28 26
	if (str != NULL)
29 -
		printf("%s ", str);
30 -
31 -
	ODP_PRINT("%s\n", strerror(__odp_errno));
27 +
		ODP_PRINT("%s %s\n", str, strerror(__odp_errno));
28 +
	else
29 +
		ODP_PRINT("%s\n", strerror(__odp_errno));
32 30
}
33 31
34 32
const char *odp_errno_str(int errnum)

@@ -15,8 +15,7 @@
Loading
15 15
#include <unistd.h>
16 16
#include <inttypes.h>
17 17
#include <sys/time.h>
18 -
19 -
#include <example_debug.h>
18 +
#include <signal.h>
20 19
21 20
#include <odp_api.h>
22 21
@@ -31,6 +30,7 @@
Loading
31 30
#define MAX_UDP_TX_BURST	512
32 31
#define DEFAULT_RX_BURST	32
33 32
#define MAX_RX_BURST		512
33 +
#define STATS_INTERVAL		10   /* Interval between stats prints (sec) */
34 34
35 35
#define APPL_MODE_UDP    0			/**< UDP mode */
36 36
#define APPL_MODE_PING   1			/**< ping mode */
@@ -132,10 +132,6 @@
Loading
132 132
		} rx;
133 133
	};
134 134
	odp_pool_t pool;	/**< Pool for packet IO */
135 -
	odp_timer_pool_t tp;	/**< Timer pool handle */
136 -
	odp_queue_t tq;		/**< Queue for timeouts */
137 -
	odp_timer_t tim;	/**< Timer handle */
138 -
	odp_timeout_t tmo_ev;	/**< Timeout event */
139 135
	int mode;		/**< Thread mode */
140 136
} thread_args_t;
141 137
@@ -151,14 +147,13 @@
Loading
151 147
	int thread_cnt;
152 148
	int tx_burst_size;
153 149
	int rx_burst_size;
150 +
	/** Barrier to sync threads execution */
151 +
	odp_barrier_t barrier;
154 152
} args_t;
155 153
156 154
/** Global pointer to args */
157 155
static args_t *args;
158 156
159 -
/** Barrier to sync threads execution */
160 -
static odp_barrier_t barrier;
161 -
162 157
/** Packet processing function types */
163 158
typedef odp_packet_t (*setup_pkt_ref_fn_t)(odp_pool_t,
164 159
					   odp_pktout_config_opt_t *);
@@ -172,25 +167,13 @@
Loading
172 167
static int scan_ip(char *buf, unsigned int *paddr);
173 168
static void print_global_stats(int num_workers);
174 169
175 -
/**
176 -
 * Sleep for the specified amount of milliseconds
177 -
 * Use ODP timer, busy wait until timer expired and timeout event received
178 -
 */
179 -
static void millisleep(uint32_t ms,
180 -
		       odp_timer_pool_t tp,
181 -
		       odp_timer_t tim,
182 -
		       odp_queue_t q,
183 -
		       odp_timeout_t tmo)
170 +
static void sig_handler(int signo ODP_UNUSED)
184 171
{
185 -
	uint64_t ticks = odp_timer_ns_to_tick(tp, 1000000ULL * ms);
186 -
	odp_event_t ev = odp_timeout_to_event(tmo);
187 -
	int rc = odp_timer_set_rel(tim, ticks, &ev);
188 -
189 -
	if (rc != ODP_TIMER_SUCCESS)
190 -
		EXAMPLE_ABORT("odp_timer_set_rel() failed\n");
191 -
	/* Spin waiting for timeout event */
192 -
	while ((ev = odp_queue_deq(q)) == ODP_EVENT_INVALID)
193 -
		(void)0;
172 +
	int i;
173 +
	if (args == NULL)
174 +
		return;
175 +
	for (i = 0; i < args->thread_cnt; i++)
176 +
		args->thread[i].stop = 1;
194 177
}
195 178
196 179
/**
@@ -575,13 +558,13 @@
Loading
575 558
	itf->pktio = odp_pktio_open(dev, pool, &pktio_param);
576 559
577 560
	if (itf->pktio == ODP_PKTIO_INVALID) {
578 -
		EXAMPLE_ERR("Error: pktio create failed for %s\n", dev);
561 +
		ODPH_ERR("Error: pktio create failed for %s\n", dev);
579 562
		return -1;
580 563
	}
581 564
582 565
	if (odp_pktio_capability(itf->pktio, &capa)) {
583 -
		EXAMPLE_ERR("Error: Failed to get interface capabilities %s\n",
584 -
			    dev);
566 +
		ODPH_ERR("Error: Failed to get interface capabilities %s\n",
567 +
			 dev);
585 568
		return -1;
586 569
	}
587 570
	odp_pktio_config_init(&itf->config);
@@ -619,8 +602,8 @@
Loading
619 602
		itf->config.parser.layer = ODP_PROTO_LAYER_L3;
620 603
621 604
	if (odp_pktio_config(itf->pktio, &itf->config)) {
622 -
		EXAMPLE_ERR("Error: Failed to set interface configuration %s\n",
623 -
			    dev);
605 +
		ODPH_ERR("Error: Failed to set interface configuration %s\n",
606 +
			 dev);
624 607
		return -1;
625 608
	}
626 609
@@ -629,8 +612,8 @@
Loading
629 612
		if (num_rx_queues > capa.max_input_queues) {
630 613
			num_rx_queues = capa.max_input_queues;
631 614
			pktin_mode = ODP_PKTIO_OP_MT;
632 -
			EXAMPLE_DBG("Warning: Force RX multithread safe mode "
633 -
				    "(slower)on %s\n",	dev);
615 +
			ODPH_DBG("Warning: Force RX multithread safe mode "
616 +
				 "(slower)on %s\n",	dev);
634 617
		}
635 618
636 619
		odp_pktin_queue_param_init(&pktin_param);
@@ -641,8 +624,8 @@
Loading
641 624
				ODP_SCHED_SYNC_ATOMIC;
642 625
643 626
		if (odp_pktin_queue_config(itf->pktio, &pktin_param)) {
644 -
			EXAMPLE_ERR("Error: pktin queue config failed "
645 -
				    "for %s\n", dev);
627 +
			ODPH_ERR("Error: pktin queue config failed for %s\n",
628 +
				 dev);
646 629
			return -1;
647 630
		}
648 631
	}
@@ -652,8 +635,8 @@
Loading
652 635
		if (num_tx_queues > capa.max_output_queues) {
653 636
			num_tx_queues = capa.max_output_queues;
654 637
			pktout_mode = ODP_PKTIO_OP_MT;
655 -
			EXAMPLE_DBG("Warning: Force TX multithread safe mode "
656 -
				    "(slower) on %s\n", dev);
638 +
			ODPH_DBG("Warning: Force TX multithread safe mode "
639 +
				 "(slower) on %s\n", dev);
657 640
		}
658 641
659 642
		odp_pktout_queue_param_init(&pktout_param);
@@ -661,21 +644,21 @@
Loading
661 644
		pktout_param.op_mode = pktout_mode;
662 645
663 646
		if (odp_pktout_queue_config(itf->pktio, &pktout_param)) {
664 -
			EXAMPLE_ERR("Error: pktout queue config failed for %s\n",
665 -
				    dev);
647 +
			ODPH_ERR("Error: pktout queue config failed for %s\n",
648 +
				 dev);
666 649
			return -1;
667 650
		}
668 651
	}
669 652
670 653
	ret = odp_pktio_start(itf->pktio);
671 654
	if (ret)
672 -
		EXAMPLE_ABORT("Error: unable to start %s\n", dev);
655 +
		ODPH_ABORT("Error: unable to start %s\n", dev);
673 656
674 657
	itf->pktout_count = num_tx_queues;
675 658
	if (itf->pktout_count &&
676 659
	    odp_pktout_queue(itf->pktio, itf->pktout, itf->pktout_count) !=
677 660
	    (int)itf->pktout_count) {
678 -
		EXAMPLE_ERR("Error: failed to get output queues for %s\n", dev);
661 +
		ODPH_ERR("Error: failed to get output queues for %s\n", dev);
679 662
		return -1;
680 663
	}
681 664
@@ -683,7 +666,7 @@
Loading
683 666
	if (!sched && itf->pktin_count &&
684 667
	    odp_pktin_queue(itf->pktio, itf->pktin, itf->pktin_count) !=
685 668
	    (int)itf->pktin_count) {
686 -
		EXAMPLE_ERR("Error: failed to get input queues for %s\n", dev);
669 +
		ODPH_ERR("Error: failed to get input queues for %s\n", dev);
687 670
		return -1;
688 671
	}
689 672
@@ -742,8 +725,8 @@
Loading
742 725
		if (args->appl.number != -1)
743 726
			pkt_count_max = args->appl.number;
744 727
	} else {
745 -
		EXAMPLE_ERR("  [%02i] Error: invalid processing mode %d\n",
746 -
			    thr, args->appl.mode);
728 +
		ODPH_ERR("  [%02i] Error: invalid processing mode %d\n", thr,
729 +
			 args->appl.mode);
747 730
		return -1;
748 731
	}
749 732
	pkt_array_size = args->tx_burst_size;
@@ -751,14 +734,14 @@
Loading
751 734
	if (setup_pkt_ref_array(thr_args->pool, pktout_cfg,
752 735
				pkt_ref_array, pkt_array_size,
753 736
				setup_pkt_ref)) {
754 -
		EXAMPLE_ERR("[%02i] Error: failed to create"
755 -
			    " reference packets\n", thr);
737 +
		ODPH_ERR("[%02i] Error: failed to create reference packets\n",
738 +
			 thr);
756 739
		return -1;
757 740
	}
758 741
759 742
	printf("  [%02i] created mode: SEND\n", thr);
760 743
761 -
	odp_barrier_wait(&barrier);
744 +
	odp_barrier_wait(&args->barrier);
762 745
763 746
	for (;;) {
764 747
		if (thr_args->stop)
@@ -773,8 +756,8 @@
Loading
773 756
		if (setup_pkt_array(pktout_cfg, counters,
774 757
				    pkt_ref_array, pkt_array,
775 758
				    pkt_array_size, setup_pkt, setup_pkt_arg)) {
776 -
			EXAMPLE_ERR("[%02i] Error: failed to setup packets\n",
777 -
				    thr);
759 +
			ODPH_ERR("[%02i] Error: failed to setup packets\n",
760 +
				 thr);
778 761
			break;
779 762
		}
780 763
@@ -793,7 +776,7 @@
Loading
793 776
				burst_size -= ret;
794 777
				continue;
795 778
			}
796 -
			EXAMPLE_ERR("  [%02i] packet send failed\n", thr);
779 +
			ODPH_ERR("  [%02i] packet send failed\n", thr);
797 780
			odp_packet_free_multi(&pkt_array[burst_start],
798 781
					      burst_size);
799 782
			break;
@@ -801,17 +784,9 @@
Loading
801 784
802 785
		counters->ctr_pkt_snd += pkt_array_size - burst_size;
803 786
804 -
		if (args->appl.interval != 0) {
805 -
			printf("  [%02i] send pkt no:%ju seq %ju\n",
806 -
			       thr,
807 -
			       counters->ctr_seq,
808 -
			       counters->ctr_seq % 0xffff);
809 -
			millisleep(args->appl.interval,
810 -
				   thr_args->tp,
811 -
				   thr_args->tim,
812 -
				   thr_args->tq,
813 -
				   thr_args->tmo_ev);
814 -
		}
787 +
		if (args->appl.interval != 0)
788 +
			odp_time_wait_ns((uint64_t)args->appl.interval *
789 +
					 ODP_TIME_MSEC_IN_NS);
815 790
		counters->ctr_seq += seq_step;
816 791
	}
817 792
@@ -929,7 +904,7 @@
Loading
929 904
	burst_size = args->rx_burst_size;
930 905
931 906
	printf("  [%02i] created mode: RECEIVE SCHEDULER\n", thr);
932 -
	odp_barrier_wait(&barrier);
907 +
	odp_barrier_wait(&args->barrier);
933 908
934 909
	for (;;) {
935 910
		if (thr_args->stop)
@@ -980,7 +955,7 @@
Loading
980 955
	burst_size = args->rx_burst_size;
981 956
982 957
	printf("  [%02i] created mode: RECEIVE\n", thr);
983 -
	odp_barrier_wait(&barrier);
958 +
	odp_barrier_wait(&args->barrier);
984 959
985 960
	for (;;) {
986 961
		if (thr_args->stop)
@@ -1043,10 +1018,10 @@
Loading
1043 1018
	uint64_t pkts_rcv = 0, pkts_rcv_prev = 0;
1044 1019
	uint64_t pps_rcv = 0, maximum_pps_rcv = 0;
1045 1020
	uint64_t stall, pkts_snd_drop;
1046 -
	int verbose_interval = 20, i;
1021 +
	int verbose_interval = STATS_INTERVAL, i;
1047 1022
	odp_thrmask_t thrd_mask;
1048 1023
1049 -
	odp_barrier_wait(&barrier);
1024 +
	odp_barrier_wait(&args->barrier);
1050 1025
1051 1026
	wait = odp_time_local_from_ns(verbose_interval * ODP_TIME_SEC_IN_NS);
1052 1027
	next = odp_time_sum(odp_time_local(), wait);
@@ -1123,7 +1098,8 @@
Loading
1123 1098
 */
1124 1099
int main(int argc, char *argv[])
1125 1100
{
1126 -
	odph_odpthread_t thread_tbl[MAX_WORKERS];
1101 +
	odph_helper_options_t helper_options;
1102 +
	odph_thread_t thread_tbl[MAX_WORKERS];
1127 1103
	odp_pool_t pool;
1128 1104
	int num_workers;
1129 1105
	unsigned num_rx_queues, num_tx_queues;
@@ -1132,34 +1108,50 @@
Loading
1132 1108
	odp_cpumask_t cpumask;
1133 1109
	char cpumaskstr[ODP_CPUMASK_STR_SIZE];
1134 1110
	odp_pool_param_t params;
1135 -
	odp_timer_pool_param_t tparams;
1136 -
	odp_timer_pool_t tp;
1137 -
	odp_pool_t tmop;
1138 -
	odp_queue_t tq;
1139 -
	odp_event_t ev;
1140 1111
	interface_t *ifs;
1141 1112
	odp_instance_t instance;
1142 -
	odph_odpthread_params_t thr_params;
1143 -
	odp_timer_capability_t timer_capa;
1113 +
	odp_init_t init_param;
1114 +
	odph_thread_common_param_t thr_common;
1115 +
	odph_thread_param_t thr_param;
1116 +
1117 +
	/* Signal handler has to be registered before global init in case ODP
1118 +
	 * implementation creates internal threads/processes. */
1119 +
	signal(SIGINT, sig_handler);
1120 +
1121 +
	/* Let helper collect its own arguments (e.g. --odph_proc) */
1122 +
	argc = odph_parse_options(argc, argv);
1123 +
	if (odph_options(&helper_options)) {
1124 +
		ODPH_ERR("Error: reading ODP helper options failed.\n");
1125 +
		exit(EXIT_FAILURE);
1126 +
	}
1127 +
1128 +
	odp_init_param_init(&init_param);
1129 +
	init_param.mem_model = helper_options.mem_model;
1144 1130
1145 1131
	/* Init ODP before calling anything else */
1146 -
	if (odp_init_global(&instance, NULL, NULL)) {
1147 -
		EXAMPLE_ERR("Error: ODP global init failed.\n");
1132 +
	if (odp_init_global(&instance, &init_param, NULL)) {
1133 +
		ODPH_ERR("Error: ODP global init failed.\n");
1148 1134
		exit(EXIT_FAILURE);
1149 1135
	}
1150 1136
1151 1137
	if (odp_init_local(instance, ODP_THREAD_CONTROL)) {
1152 -
		EXAMPLE_ERR("Error: ODP local init failed.\n");
1138 +
		ODPH_ERR("Error: ODP local init failed.\n");
1153 1139
		exit(EXIT_FAILURE);
1154 1140
	}
1155 1141
1156 1142
	/* Reserve memory for args from shared mem */
1157 1143
	shm = odp_shm_reserve("shm_args", sizeof(args_t),
1158 1144
			      ODP_CACHE_LINE_SIZE, 0);
1145 +
1146 +
	if (shm == ODP_SHM_INVALID) {
1147 +
		ODPH_ERR("Error: shared mem reserve failed.\n");
1148 +
		exit(EXIT_FAILURE);
1149 +
	}
1150 +
1159 1151
	args = odp_shm_addr(shm);
1160 1152
1161 1153
	if (args == NULL) {
1162 -
		EXAMPLE_ERR("Error: shared mem alloc failed.\n");
1154 +
		ODPH_ERR("Error: shared mem alloc failed.\n");
1163 1155
		exit(EXIT_FAILURE);
1164 1156
	}
1165 1157
	memset(args, 0, sizeof(*args));
@@ -1193,7 +1185,7 @@
Loading
1193 1185
	/* ping mode need two workers */
1194 1186
	if (args->appl.mode == APPL_MODE_PING) {
1195 1187
		if (num_workers < 2) {
1196 -
			EXAMPLE_ERR("Need at least two worker threads\n");
1188 +
			ODPH_ERR("Need at least two worker threads\n");
1197 1189
			exit(EXIT_FAILURE);
1198 1190
		} else {
1199 1191
			num_workers = 2;
@@ -1213,6 +1205,9 @@
Loading
1213 1205
		args->rx_burst_size = args->appl.rx_burst;
1214 1206
	}
1215 1207
1208 +
	/* Configure scheduler */
1209 +
	odp_schedule_config(NULL);
1210 +
1216 1211
	/* Create packet pool */
1217 1212
	odp_pool_param_init(&params);
1218 1213
	params.pkt.seg_len = POOL_PKT_LEN;
@@ -1223,41 +1218,11 @@
Loading
1223 1218
	pool = odp_pool_create("packet_pool", &params);
1224 1219
1225 1220
	if (pool == ODP_POOL_INVALID) {
1226 -
		EXAMPLE_ERR("Error: packet pool create failed.\n");
1221 +
		ODPH_ERR("Error: packet pool create failed.\n");
1227 1222
		exit(EXIT_FAILURE);
1228 1223
	}
1229 1224
	odp_pool_print(pool);
1230 1225
1231 -
	/* Create timer pool */
1232 -
	if (odp_timer_capability(ODP_CLOCK_CPU, &timer_capa)) {
1233 -
		EXAMPLE_ERR("Error: get timer capacity failed.\n");
1234 -
		exit(EXIT_FAILURE);
1235 -
	}
1236 -
	tparams.res_ns = MAX(1 * ODP_TIME_MSEC_IN_NS,
1237 -
			     timer_capa.highest_res_ns);
1238 -
	tparams.min_tmo = 0;
1239 -
	tparams.max_tmo = 10000 * ODP_TIME_SEC_IN_NS;
1240 -
	tparams.num_timers = num_workers; /* One timer per worker */
1241 -
	tparams.priv = 0; /* Shared */
1242 -
	tparams.clk_src = ODP_CLOCK_CPU;
1243 -
	tp = odp_timer_pool_create("timer_pool", &tparams);
1244 -
	if (tp == ODP_TIMER_POOL_INVALID) {
1245 -
		EXAMPLE_ERR("Timer pool create failed.\n");
1246 -
		exit(EXIT_FAILURE);
1247 -
	}
1248 -
	odp_timer_pool_start();
1249 -
1250 -
	/* Create timeout pool */
1251 -
	odp_pool_param_init(&params);
1252 -
	params.tmo.num     = tparams.num_timers; /* One timeout per timer */
1253 -
	params.type	   = ODP_POOL_TIMEOUT;
1254 -
1255 -
	tmop = odp_pool_create("timeout_pool", &params);
1256 -
	if (tmop == ODP_POOL_INVALID) {
1257 -
		EXAMPLE_ERR("Error: timeout pool create failed.\n");
1258 -
		exit(EXIT_FAILURE);
1259 -
	}
1260 -
1261 1226
	ifs = malloc(sizeof(interface_t) * args->appl.if_count);
1262 1227
1263 1228
	for (i = 0; i < args->appl.if_count; ++i) {
@@ -1278,8 +1243,8 @@
Loading
1278 1243
1279 1244
		if (create_pktio(args->appl.if_names[i], pool, num_rx_queues,
1280 1245
				 num_tx_queues, &ifs[i])) {
1281 -
			EXAMPLE_ERR("Error: create interface %s failed.\n",
1282 -
				    args->appl.if_names[i]);
1246 +
			ODPH_ERR("Error: create interface %s failed.\n",
1247 +
				 args->appl.if_names[i]);
1283 1248
			exit(EXIT_FAILURE);
1284 1249
		}
1285 1250
	}
@@ -1288,12 +1253,14 @@
Loading
1288 1253
	memset(thread_tbl, 0, sizeof(thread_tbl));
1289 1254
1290 1255
	/* Init threads params */
1291 -
	memset(&thr_params, 0, sizeof(thr_params));
1292 -
	thr_params.thr_type = ODP_THREAD_WORKER;
1293 -
	thr_params.instance = instance;
1256 +
	memset(&thr_param, 0, sizeof(thr_param));
1257 +
	thr_param.thr_type = ODP_THREAD_WORKER;
1258 +
1259 +
	memset(&thr_common, 0, sizeof(thr_common));
1260 +
	thr_common.instance = instance;
1294 1261
1295 1262
	/* num workers + print thread */
1296 -
	odp_barrier_init(&barrier, num_workers + 1);
1263 +
	odp_barrier_init(&args->barrier, num_workers + 1);
1297 1264
1298 1265
	if (args->appl.mode == APPL_MODE_PING) {
1299 1266
		odp_cpumask_t cpu_mask;
@@ -1304,72 +1271,38 @@
Loading
1304 1271
		cpu_first = odp_cpumask_first(&cpumask);
1305 1272
		odp_cpumask_set(&cpu_mask, cpu_first);
1306 1273
1307 -
		tq = odp_queue_create("", NULL);
1308 -
		if (tq == ODP_QUEUE_INVALID) {
1309 -
			EXAMPLE_ERR("queue_create failed\n");
1310 -
			abort();
1311 -
		}
1312 1274
		thr_args = &args->thread[PING_THR_RX];
1313 1275
		if (!args->appl.sched)
1314 1276
			thr_args->rx.pktin = ifs[0].pktin[0];
1315 1277
		thr_args->pool = pool;
1316 -
		thr_args->tp = tp;
1317 -
		thr_args->tq = tq;
1318 -
		thr_args->tim = odp_timer_alloc(tp, tq, NULL);
1319 -
		if (thr_args->tim == ODP_TIMER_INVALID) {
1320 -
			EXAMPLE_ERR("timer_alloc failed\n");
1321 -
			abort();
1322 -
		}
1323 -
		thr_args->tmo_ev = odp_timeout_alloc(tmop);
1324 -
		if (thr_args->tmo_ev == ODP_TIMEOUT_INVALID) {
1325 -
			EXAMPLE_ERR("timeout_alloc failed\n");
1326 -
			abort();
1327 -
		}
1328 1278
		thr_args->mode = args->appl.mode;
1329 1279
1330 -
		memset(&thr_params, 0, sizeof(thr_params));
1331 1280
		if (args->appl.sched)
1332 -
			thr_params.start = gen_recv_thread;
1281 +
			thr_param.start = gen_recv_thread;
1333 1282
		else
1334 -
			thr_params.start = gen_recv_direct_thread;
1335 -
		thr_params.arg      = thr_args;
1336 -
		thr_params.thr_type = ODP_THREAD_WORKER;
1337 -
		thr_params.instance = instance;
1338 -
1339 -
		odph_odpthreads_create(&thread_tbl[PING_THR_RX],
1340 -
				       &cpu_mask, &thr_params);
1341 -
1342 -
		tq = odp_queue_create("", NULL);
1343 -
		if (tq == ODP_QUEUE_INVALID) {
1344 -
			EXAMPLE_ERR("queue_create failed\n");
1345 -
			abort();
1346 -
		}
1283 +
			thr_param.start = gen_recv_direct_thread;
1284 +
1285 +
		thr_param.arg = thr_args;
1286 +
1287 +
		thr_common.cpumask = &cpu_mask;
1288 +
1289 +
		odph_thread_create(&thread_tbl[PING_THR_RX], &thr_common,
1290 +
				   &thr_param, 1);
1291 +
1347 1292
		thr_args = &args->thread[PING_THR_TX];
1348 1293
		thr_args->tx.pktout = ifs[0].pktout[0];
1349 1294
		thr_args->tx.pktout_cfg = &ifs[0].config.pktout;
1350 1295
		thr_args->pool = pool;
1351 -
		thr_args->tp = tp;
1352 -
		thr_args->tq = tq;
1353 -
		thr_args->tim = odp_timer_alloc(tp, tq, NULL);
1354 -
		if (thr_args->tim == ODP_TIMER_INVALID) {
1355 -
			EXAMPLE_ERR("timer_alloc failed\n");
1356 -
			abort();
1357 -
		}
1358 -
		thr_args->tmo_ev = odp_timeout_alloc(tmop);
1359 -
		if (thr_args->tmo_ev == ODP_TIMEOUT_INVALID) {
1360 -
			EXAMPLE_ERR("timeout_alloc failed\n");
1361 -
			abort();
1362 -
		}
1363 1296
		thr_args->mode = args->appl.mode;
1364 1297
		cpu_next = odp_cpumask_next(&cpumask, cpu_first);
1365 1298
		odp_cpumask_zero(&cpu_mask);
1366 1299
		odp_cpumask_set(&cpu_mask, cpu_next);
1367 1300
1368 -
		thr_params.start = gen_send_thread;
1369 -
		thr_params.arg   = thr_args;
1301 +
		thr_param.start = gen_send_thread;
1302 +
		thr_param.arg   = thr_args;
1370 1303
1371 -
		odph_odpthreads_create(&thread_tbl[PING_THR_TX],
1372 -
				       &cpu_mask, &thr_params);
1304 +
		odph_thread_create(&thread_tbl[PING_THR_TX], &thr_common,
1305 +
				   &thr_param, 1);
1373 1306
1374 1307
	} else {
1375 1308
		int cpu = odp_cpumask_first(&cpumask);
@@ -1428,24 +1361,7 @@
Loading
1428 1361
1429 1362
				args->thread[i].counters.ctr_seq = start_seq;
1430 1363
			}
1431 -
			tq = odp_queue_create("", NULL);
1432 -
			if (tq == ODP_QUEUE_INVALID) {
1433 -
				EXAMPLE_ERR("queue_create failed\n");
1434 -
				abort();
1435 -
			}
1436 1364
			args->thread[i].pool = pool;
1437 -
			args->thread[i].tp = tp;
1438 -
			args->thread[i].tq = tq;
1439 -
			args->thread[i].tim = odp_timer_alloc(tp, tq, NULL);
1440 -
			if (args->thread[i].tim == ODP_TIMER_INVALID) {
1441 -
				EXAMPLE_ERR("timer_alloc failed\n");
1442 -
				abort();
1443 -
			}
1444 -
			args->thread[i].tmo_ev = odp_timeout_alloc(tmop);
1445 -
			if (args->thread[i].tmo_ev == ODP_TIMEOUT_INVALID) {
1446 -
				EXAMPLE_ERR("timeout_alloc failed\n");
1447 -
				abort();
1448 -
			}
1449 1365
			args->thread[i].mode = args->appl.mode;
1450 1366
1451 1367
			if (args->appl.mode == APPL_MODE_UDP) {
@@ -1456,7 +1372,7 @@
Loading
1456 1372
				else
1457 1373
					thr_run_func = gen_recv_direct_thread;
1458 1374
			} else {
1459 -
				EXAMPLE_ERR("ERR MODE\n");
1375 +
				ODPH_ERR("ERR MODE\n");
1460 1376
				exit(EXIT_FAILURE);
1461 1377
			}
1462 1378
			/*
@@ -1467,11 +1383,13 @@
Loading
1467 1383
			odp_cpumask_zero(&thd_mask);
1468 1384
			odp_cpumask_set(&thd_mask, cpu);
1469 1385
1470 -
			thr_params.start = thr_run_func;
1471 -
			thr_params.arg   = &args->thread[i];
1386 +
			thr_param.start = thr_run_func;
1387 +
			thr_param.arg   = &args->thread[i];
1472 1388
1473 -
			odph_odpthreads_create(&thread_tbl[i],
1474 -
					       &thd_mask, &thr_params);
1389 +
			thr_common.cpumask = &thd_mask;
1390 +
1391 +
			odph_thread_create(&thread_tbl[i], &thr_common,
1392 +
					   &thr_param, 1);
1475 1393
			cpu = odp_cpumask_next(&cpumask, cpu);
1476 1394
		}
1477 1395
	}
@@ -1479,38 +1397,20 @@
Loading
1479 1397
	print_global_stats(num_workers);
1480 1398
1481 1399
	/* Master thread waits for other threads to exit */
1482 -
	for (i = 0; i < num_workers; ++i)
1483 -
		odph_odpthreads_join(&thread_tbl[i]);
1400 +
	odph_thread_join(thread_tbl, num_workers);
1484 1401
1485 1402
	for (i = 0; i < args->appl.if_count; ++i)
1486 1403
		odp_pktio_stop(ifs[i].pktio);
1487 1404
1488 -
	for (i = 0; i < num_workers; ++i) {
1489 -
		odp_timer_cancel(args->thread[i].tim, &ev);
1490 -
		odp_timer_free(args->thread[i].tim);
1491 -
		odp_timeout_free(args->thread[i].tmo_ev);
1492 -
	}
1493 -
1494 -
	for (i = 0; i < num_workers; ++i) {
1495 -
		while (1) {
1496 -
			ev = odp_queue_deq(args->thread[i].tq);
1497 -
			if (ev == ODP_EVENT_INVALID)
1498 -
				break;
1499 -
			odp_event_free(ev);
1500 -
		}
1501 -
		odp_queue_destroy(args->thread[i].tq);
1502 -
	}
1503 -
1504 1405
	for (i = 0; i < args->appl.if_count; ++i)
1505 1406
		odp_pktio_close(ifs[i].pktio);
1506 1407
	free(ifs);
1507 1408
	free(args->appl.if_names);
1508 1409
	free(args->appl.if_str);
1410 +
	args = NULL;
1411 +
	odp_mb_full();
1509 1412
	if (0 != odp_pool_destroy(pool))
1510 1413
		fprintf(stderr, "unable to destroy pool \"pool\"\n");
1511 -
	odp_timer_pool_destroy(tp);
1512 -
	if (0 != odp_pool_destroy(tmop))
1513 -
		fprintf(stderr, "unable to destroy pool \"tmop\"\n");
1514 1414
	if (0 != odp_shm_free(shm))
1515 1415
		fprintf(stderr, "unable to free \"shm\"\n");
1516 1416
	odp_term_local();
@@ -1563,9 +1463,6 @@
Loading
1563 1463
	static const char *shortopts = "+I:a:b:s:d:p:i:m:n:t:w:c:x:he:j:f:k"
1564 1464
					":yr:z";
1565 1465
1566 -
	/* let helper collect its own arguments (e.g. --odph_proc) */
1567 -
	argc = odph_parse_options(argc, argv);
1568 -
1569 1466
	appl_args->mode = -1; /* Invalid, must be changed by parsing */
1570 1467
	appl_args->number = -1;
1571 1468
	appl_args->payload = 56;
@@ -1598,9 +1495,9 @@
Loading
1598 1495
			if (odp_cpumask_count(&cpumask_and) <
1599 1496
			    odp_cpumask_count(&cpumask_args) ||
1600 1497
			    odp_cpumask_count(&cpumask_args) > MAX_WORKERS) {
1601 -
				EXAMPLE_ERR("Wrong cpu mask, max cpu's:%d\n",
1602 -
					    num_workers < MAX_WORKERS ?
1603 -
					    num_workers : MAX_WORKERS);
1498 +
				ODPH_ERR("Wrong cpu mask, max cpu's:%d\n",
1499 +
					 num_workers < MAX_WORKERS ?
1500 +
					 num_workers : MAX_WORKERS);
1604 1501
				exit(EXIT_FAILURE);
1605 1502
			}
1606 1503
			break;
@@ -1653,35 +1550,35 @@
Loading
1653 1550
			} else if (optarg[0] == 'r') {
1654 1551
				appl_args->mode = APPL_MODE_RCV;
1655 1552
			} else {
1656 -
				EXAMPLE_ERR("wrong mode!\n");
1553 +
				ODPH_ERR("wrong mode!\n");
1657 1554
				exit(EXIT_FAILURE);
1658 1555
			}
1659 1556
			break;
1660 1557
1661 1558
		case 'a':
1662 1559
			if (odph_eth_addr_parse(&appl_args->srcmac, optarg)) {
1663 -
				EXAMPLE_ERR("wrong src mac:%s\n", optarg);
1560 +
				ODPH_ERR("wrong src mac:%s\n", optarg);
1664 1561
				exit(EXIT_FAILURE);
1665 1562
			}
1666 1563
			break;
1667 1564
1668 1565
		case 'b':
1669 1566
			if (odph_eth_addr_parse(&appl_args->dstmac, optarg)) {
1670 -
				EXAMPLE_ERR("wrong dst mac:%s\n", optarg);
1567 +
				ODPH_ERR("wrong dst mac:%s\n", optarg);
1671 1568
				exit(EXIT_FAILURE);
1672 1569
			}
1673 1570
			break;
1674 1571
1675 1572
		case 's':
1676 1573
			if (scan_ip(optarg, &appl_args->srcip) != 1) {
1677 -
				EXAMPLE_ERR("wrong src ip:%s\n", optarg);
1574 +
				ODPH_ERR("wrong src ip:%s\n", optarg);
1678 1575
				exit(EXIT_FAILURE);
1679 1576
			}
1680 1577
			break;
1681 1578
1682 1579
		case 'd':
1683 1580
			if (scan_ip(optarg, &appl_args->dstip) != 1) {
1684 -
				EXAMPLE_ERR("wrong dst ip:%s\n", optarg);
1581 +
				ODPH_ERR("wrong dst ip:%s\n", optarg);
1685 1582
				exit(EXIT_FAILURE);
1686 1583
			}
1687 1584
			break;
@@ -1713,23 +1610,23 @@
Loading
1713 1610
		case 'i':
1714 1611
			appl_args->interval = atoi(optarg);
1715 1612
			if (appl_args->interval <= 200 && geteuid() != 0) {
1716 -
				EXAMPLE_ERR("should be root user\n");
1613 +
				ODPH_ERR("should be root user\n");
1717 1614
				exit(EXIT_FAILURE);
1718 1615
			}
1719 1616
			break;
1720 1617
		case 'x':
1721 1618
			appl_args->udp_tx_burst = atoi(optarg);
1722 1619
			if (appl_args->udp_tx_burst >  MAX_UDP_TX_BURST) {
1723 -
				EXAMPLE_ERR("wrong UDP Tx burst size (max %d)\n",
1724 -
					    MAX_UDP_TX_BURST);
1620 +
				ODPH_ERR("wrong UDP Tx burst size (max %d)\n",
1621 +
					 MAX_UDP_TX_BURST);
1725 1622
				exit(EXIT_FAILURE);
1726 1623
			}
1727 1624
			break;
1728 1625
		case 'r':
1729 1626
			appl_args->rx_burst = atoi(optarg);
1730 1627
			if (appl_args->rx_burst >  MAX_RX_BURST) {
1731 -
				EXAMPLE_ERR("wrong Rx burst size (max %d)\n",
1732 -
					    MAX_RX_BURST);
1628 +
				ODPH_ERR("wrong Rx burst size (max %d)\n",
1629 +
					 MAX_RX_BURST);
1733 1630
				exit(EXIT_FAILURE);
1734 1631
			}
1735 1632
			break;

@@ -4,8 +4,6 @@
Loading
4 4
 * SPDX-License-Identifier:     BSD-3-Clause
5 5
 */
6 6
7 -
#include "config.h"
8 -
9 7
/*
10 8
 * This file handles the lower end of the ishm memory allocator:
11 9
 * It performs the physical mappings.
@@ -17,7 +15,7 @@
Loading
17 15
#include <odp/api/debug.h>
18 16
#include <odp_debug_internal.h>
19 17
#include <odp_align_internal.h>
20 -
#include <odp_ishm_internal.h>
18 +
#include <odp_shm_internal.h>
21 19
#include <odp_ishmphy_internal.h>
22 20
23 21
#include <stdlib.h>
@@ -30,6 +28,7 @@
Loading
30 28
#include <fcntl.h>
31 29
#include <sys/types.h>
32 30
#include <sys/wait.h>
31 +
#include <inttypes.h>
33 32
#include <odp_ishmphy_internal.h>
34 33
35 34
static void *common_va_address;
@@ -39,125 +38,83 @@
Loading
39 38
#define MAP_ANONYMOUS MAP_ANON
40 39
#endif
41 40
42 -
/* Book some virtual address space
43 -
 * This function is called at odp_init_global() time to pre-book some
44 -
 * virtual address space inherited by all odpthreads (i.e. descendant
45 -
 * processes and threads) and later used to guarantee the unicity the
46 -
 * the mapping VA address when memory is reserver with the _ODP_ISHM_SINGLE_VA
47 -
 * flag.
41 +
/* Reserve single VA memory
42 +
 * This function is called at odp_init_global() time to pre-reserve some memory
43 +
 * which is inherited by all odpthreads (i.e. descendant processes and threads).
44 +
 * This memory block is later used when memory is reserved with
45 +
 * _ODP_ISHM_SINGLE_VA flag.
48 46
 * returns the address of the mapping or NULL on error.
49 47
 */
50 -
void *_odp_ishmphy_book_va(uintptr_t len, intptr_t align)
48 +
void *_odp_ishmphy_reserve_single_va(uint64_t len, int fd)
51 49
{
52 50
	void *addr;
53 51
54 -
	addr = mmap(NULL, len + align, PROT_NONE,
55 -
		    MAP_SHARED | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
52 +
	addr = mmap(NULL, len, PROT_READ | PROT_WRITE,
53 +
		    MAP_SHARED | MAP_POPULATE, fd, 0);
56 54
	if (addr == MAP_FAILED) {
57 -
		ODP_ERR("_ishmphy_book_va failure\n");
55 +
		ODP_ERR("mmap failed: %s\n", strerror(errno));
58 56
		return NULL;
59 57
	}
60 58
61 -
	if (mprotect(addr, len, PROT_NONE))
62 -
			ODP_ERR("failure for protect\n");
59 +
	if (mprotect(addr, len, PROT_READ | PROT_WRITE))
60 +
		ODP_ERR("mprotect failed: %s\n", strerror(errno));
63 61
64 -
	ODP_DBG("VA Reserved: %p, len=%p\n", addr, len + align);
62 +
	ODP_DBG("VA Reserved: %p, len=%" PRIu64 "\n", addr, len);
65 63
66 64
	common_va_address = addr;
67 65
	common_va_len	  = len;
68 66
69 -
	/* return the nearest aligned address: */
70 -
	return (void *)(((uintptr_t)addr + align - 1) & (-align));
67 +
	return addr;
71 68
}
72 69
73 -
/* Un-book some virtual address space
74 -
 * This function is called at odp_term_global() time to unbook
75 -
 * the virtual address space booked by _ishmphy_book_va()
70 +
/* Free single VA memory
71 +
 * This function is called at odp_term_global() time to free the memory reserved
72 +
 * by _odp_ishmphy_reserve_single_va()
76 73
 */
77 -
int _odp_ishmphy_unbook_va(void)
74 +
int _odp_ishmphy_free_single_va(void)
78 75
{
79 76
	int ret;
80 77
78 +
	if (!common_va_address)
79 +
		return 0;
80 +
81 81
	ret = munmap(common_va_address, common_va_len);
82 82
	if (ret)
83 -
		ODP_ERR("_unishmphy_book_va failure\n");
83 +
		ODP_ERR("munmap failed: %s\n", strerror(errno));
84 84
	return ret;
85 85
}
86 86
87 87
/*
88 88
 * do a mapping:
89 89
 * Performs a mapping of the provided file descriptor to the process VA
90 -
 * space. If the _ODP_ISHM_SINGLE_VA flag is set, 'start' is assumed to be
91 -
 * the VA address where the mapping is to be done.
92 -
 * If the flag is not set, a new VA address is taken.
90 +
 * space. Not to be used with _ODP_ISHM_SINGLE_VA blocks.
93 91
 * returns the address of the mapping or NULL on error.
94 92
 */
95 -
void *_odp_ishmphy_map(int fd, void *start, uint64_t size,
96 -
		       int flags)
93 +
void *_odp_ishmphy_map(int fd, uint64_t size, uint64_t offset, int flags)
97 94
{
98 -
	void *mapped_addr_tmp, *mapped_addr;
95 +
	void *mapped_addr;
99 96
	int mmap_flags = MAP_POPULATE;
100 97
101 -
	if (flags & _ODP_ISHM_SINGLE_VA) {
102 -
		if (!start) {
103 -
			ODP_ERR("failure: missing address\n");
104 -
			return NULL;
105 -
		}
106 -
		/* maps over fragment of reserved VA: */
107 -
		/* first, try a normal map. If that works, remap it where it
108 -
		 * should (on the prereverved space), and remove the initial
109 -
		 * normal mapping:
110 -
		 * This is because it turned out that if a mapping fails
111 -
		 * on a the prereserved virtual address space, then
112 -
		 * the prereserved address space which was tried to be mapped
113 -
		 * on becomes available to the kernel again! This was not
114 -
		 * according to expectations: the assumption was that if a
115 -
		 * mapping fails, the system should remain unchanged, but this
116 -
		 * is obvioulsy not true (at least for huge pages when
117 -
		 * exhausted).
118 -
		 * So the strategy is to first map at a non reserved place
119 -
		 * (which can then be freed and returned to the kernel on
120 -
		 * failure) and peform a new map to the prereserved space on
121 -
		 * success (which is then guaranteed to work).
122 -
		 * The initial free maping can then be removed.
123 -
		 */
124 -
		mapped_addr = MAP_FAILED;
125 -
		mapped_addr_tmp = mmap(NULL, size, PROT_READ | PROT_WRITE,
126 -
				       MAP_SHARED | mmap_flags, fd, 0);
127 -
		if (mapped_addr_tmp != MAP_FAILED) {
128 -
			/* If OK, do new map at right fixed location... */
129 -
			mapped_addr = mmap(start,
130 -
					   size, PROT_READ | PROT_WRITE,
131 -
					   MAP_SHARED | MAP_FIXED | mmap_flags,
132 -
					   fd, 0);
133 -
			if (mapped_addr != start)
134 -
				ODP_ERR("new map failed:%s\n", strerror(errno));
135 -
			/* ... and remove initial mapping: */
136 -
			if (munmap(mapped_addr_tmp, size))
137 -
				ODP_ERR("munmap failed:%s\n", strerror(errno));
138 -
		}
139 -
	} else {
140 -
		/* just do a new mapping in the VA space: */
141 -
		mapped_addr = mmap(NULL, size, PROT_READ | PROT_WRITE,
142 -
				   MAP_SHARED | mmap_flags, fd, 0);
143 -
		if ((mapped_addr >= common_va_address) &&
144 -
		    ((char *)mapped_addr <
145 -
			(char *)common_va_address + common_va_len)) {
146 -
			ODP_ERR("VA SPACE OVERLAP!\n");
147 -
		}
98 +
	ODP_ASSERT(!(flags & _ODP_ISHM_SINGLE_VA));
99 +
100 +
	/* do a new mapping in the VA space: */
101 +
	mapped_addr = mmap(NULL, size, PROT_READ | PROT_WRITE,
102 +
			   MAP_SHARED | mmap_flags, fd, offset);
103 +
	if ((mapped_addr >= common_va_address) &&
104 +
	    ((char *)mapped_addr <
105 +
		(char *)common_va_address + common_va_len)) {
106 +
		ODP_ERR("VA SPACE OVERLAP!\n");
148 107
	}
149 108
150 -
	if (mapped_addr == MAP_FAILED) {
151 -
		ODP_ERR("mmap failed:%s\n", strerror(errno));
109 +
	if (mapped_addr == MAP_FAILED)
152 110
		return NULL;
153 -
	}
154 111
155 112
	/* if locking is requested, lock it...*/
156 113
	if (flags & _ODP_ISHM_LOCK) {
157 114
		if (mlock(mapped_addr, size)) {
115 +
			ODP_ERR("mlock failed: %s\n", strerror(errno));
158 116
			if (munmap(mapped_addr, size))
159 -
				ODP_ERR("munmap failed:%s\n", strerror(errno));
160 -
			ODP_ERR("mlock failed:%s\n", strerror(errno));
117 +
				ODP_ERR("munmap failed: %s\n", strerror(errno));
161 118
			return NULL;
162 119
		}
163 120
	}
@@ -165,44 +122,25 @@
Loading
165 122
}
166 123
167 124
/* free a mapping:
168 -
 * If the _ODP_ISHM_SINGLE_VA flag was given at creation time the virtual
169 -
 * address range must be returned to the preoallocated "pool". this is
170 -
 * done by mapping non accessibly memory there (hence blocking the VA but
171 -
 * releasing the physical memory).
172 -
 * If the _ODP_ISHM_SINGLE_VA flag was not given, both physical memory and
173 -
 * virtual address space are realeased by calling the normal munmap.
125 +
 * _ODP_ISHM_SINGLE_VA memory is not returned back to linux until global
126 +
 * terminate. If the _ODP_ISHM_SINGLE_VA flag was not given, both physical
127 +
 * memory and virtual address space are released by calling the normal munmap.
174 128
 * return 0 on success or -1 on error.
175 129
 */
176 130
int _odp_ishmphy_unmap(void *start, uint64_t len, int flags)
177 131
{
178 -
	void *addr;
179 132
	int ret;
180 -
	int mmap_flgs;
181 -
182 -
	mmap_flgs = MAP_SHARED | MAP_FIXED | MAP_ANONYMOUS | MAP_NORESERVE;
183 133
184 134
	/* if locking was requested, unlock...*/
185 135
	if (flags & _ODP_ISHM_LOCK)
186 136
		munlock(start, len);
187 137
188 -
	if (flags & _ODP_ISHM_SINGLE_VA) {
189 -
		/* map unnaccessible memory overwrites previous mapping
190 -
		 * and free the physical memory, but guarantees to block
191 -
		 * the VA range from other mappings
192 -
		 */
193 -
		addr = mmap(start, len, PROT_NONE, mmap_flgs, -1, 0);
194 -
		if (addr == MAP_FAILED) {
195 -
			ODP_ERR("_ishmphy_free failure for ISHM_SINGLE_VA\n");
196 -
			return -1;
197 -
		}
198 -
		if (mprotect(start, len, PROT_NONE))
199 -
			ODP_ERR("_ishmphy_free failure for protect\n");
138 +
	if (flags & _ODP_ISHM_SINGLE_VA)
200 139
		return 0;
201 -
	}
202 140
203 141
	/* just release the mapping */
204 142
	ret = munmap(start, len);
205 143
	if (ret)
206 -
		ODP_ERR("_ishmphy_free failure: %s\n", strerror(errno));
144 +
		ODP_ERR("munmap failed: %s\n", strerror(errno));
207 145
	return ret;
208 146
}

@@ -4,8 +4,6 @@
Loading
4 4
 * SPDX-License-Identifier:     BSD-3-Clause
5 5
 */
6 6
7 -
#include "config.h"
8 -
9 7
#include <odp/api/atomic.h>
10 8
11 9
int odp_atomic_lock_free_u64(odp_atomic_op_t *atomic_op)

@@ -4,8 +4,6 @@
Loading
4 4
 * SPDX-License-Identifier:     BSD-3-Clause
5 5
 */
6 6
7 -
#include "config.h"
8 -
9 7
#include <odp_posix_extensions.h>
10 8
11 9
#include <sched.h>
@@ -236,8 +234,8 @@
Loading
236 234
	int ret;
237 235
238 236
	/* Clear the global cpumasks for control and worker CPUs */
239 -
	odp_cpumask_zero(&odp_global_data.control_cpus);
240 -
	odp_cpumask_zero(&odp_global_data.worker_cpus);
237 +
	odp_cpumask_zero(&odp_global_ro.control_cpus);
238 +
	odp_cpumask_zero(&odp_global_ro.worker_cpus);
241 239
242 240
	CPU_ZERO(&cpuset);
243 241
	ret = sched_getaffinity(0, sizeof(cpuset), &cpuset);
@@ -249,12 +247,12 @@
Loading
249 247
250 248
	for (cpu_idnum = 0; cpu_idnum < CPU_SETSIZE - 1; cpu_idnum++) {
251 249
		if (CPU_ISSET(cpu_idnum, &cpuset)) {
252 -
			odp_global_data.num_cpus_installed++;
250 +
			odp_global_ro.num_cpus_installed++;
253 251
			/* Add the CPU to our default cpumasks */
254 -
			odp_cpumask_set(&odp_global_data.control_cpus,
255 -
						(int)cpu_idnum);
256 -
			odp_cpumask_set(&odp_global_data.worker_cpus,
257 -
						(int)cpu_idnum);
252 +
			odp_cpumask_set(&odp_global_ro.control_cpus,
253 +
					(int)cpu_idnum);
254 +
			odp_cpumask_set(&odp_global_ro.worker_cpus,
255 +
					(int)cpu_idnum);
258 256
		}
259 257
	}
260 258
@@ -269,8 +267,8 @@
Loading
269 267
 */
270 268
static void init_default_control_cpumask(int worker_cpus_default)
271 269
{
272 -
	odp_cpumask_t *control_mask = &odp_global_data.control_cpus;
273 -
	odp_cpumask_t *worker_mask = &odp_global_data.worker_cpus;
270 +
	odp_cpumask_t *control_mask = &odp_global_ro.control_cpus;
271 +
	odp_cpumask_t *worker_mask = &odp_global_ro.worker_cpus;
274 272
	int i;
275 273
276 274
	/* (Bits for all available CPUs are SET in control cpumask) */
@@ -281,7 +279,7 @@
Loading
281 279
		 * If only one or two CPUs installed, use CPU 0 for control.
282 280
		 * Otherwise leave it for the kernel and start with CPU 1.
283 281
		 */
284 -
		if (odp_global_data.num_cpus_installed < 3) {
282 +
		if (odp_global_ro.num_cpus_installed < 3) {
285 283
			/*
286 284
			 * If only two CPUS, use CPU 0 for control and
287 285
			 * use CPU 1 for workers.
@@ -294,7 +292,7 @@
Loading
294 292
			 * reserve remaining CPUs for workers
295 293
			 */
296 294
			odp_cpumask_clr(control_mask, 0);
297 -
			for (i = 2; i < odp_global_data.num_cpus_installed; i++)
295 +
			for (i = 2; i < odp_global_ro.num_cpus_installed; i++)
298 296
				if (odp_cpumask_isset(worker_mask, i))
299 297
					odp_cpumask_clr(control_mask, i);
300 298
		}
@@ -303,7 +301,7 @@
Loading
303 301
		 * The worker cpumask was specified so first ensure
304 302
		 * the control cpumask does not overlap any worker CPUs
305 303
		 */
306 -
		for (i = 0; i < odp_global_data.num_cpus_installed; i++)
304 +
		for (i = 0; i < odp_global_ro.num_cpus_installed; i++)
307 305
			if (odp_cpumask_isset(worker_mask, i))
308 306
				odp_cpumask_clr(control_mask, i);
309 307
@@ -311,7 +309,7 @@
Loading
311 309
		 * If only one or two CPUs installed,
312 310
		 * ensure availability of CPU 0 for control threads
313 311
		 */
314 -
		if (odp_global_data.num_cpus_installed < 3) {
312 +
		if (odp_global_ro.num_cpus_installed < 3) {
315 313
			odp_cpumask_set(control_mask, 0);
316 314
			odp_cpumask_clr(control_mask, 1);
317 315
		} else {
@@ -337,8 +335,8 @@
Loading
337 335
 */
338 336
static void init_default_worker_cpumask(int control_cpus_default)
339 337
{
340 -
	odp_cpumask_t *control_mask = &odp_global_data.control_cpus;
341 -
	odp_cpumask_t *worker_mask = &odp_global_data.worker_cpus;
338 +
	odp_cpumask_t *control_mask = &odp_global_ro.control_cpus;
339 +
	odp_cpumask_t *worker_mask = &odp_global_ro.worker_cpus;
342 340
	int i;
343 341
344 342
	/* (Bits for all available CPUs are SET in worker cpumask) */
@@ -348,10 +346,10 @@
Loading
348 346
		 * The control cpumask was also unspecified...
349 347
		 * CPU 0 is only used for workers on uniprocessor systems
350 348
		 */
351 -
		if (odp_global_data.num_cpus_installed > 1)
349 +
		if (odp_global_ro.num_cpus_installed > 1)
352 350
			odp_cpumask_clr(worker_mask, 0);
353 351
354 -
		if (odp_global_data.num_cpus_installed > 2)
352 +
		if (odp_global_ro.num_cpus_installed > 2)
355 353
			/*
356 354
			 * If three or more CPUs, reserve CPU 0 for kernel,
357 355
			 * reserve CPU 1 for control, and
@@ -363,7 +361,7 @@
Loading
363 361
		 * The control cpumask was specified so first ensure
364 362
		 * the worker cpumask does not overlap any control CPUs
365 363
		 */
366 -
		for (i = 0; i < odp_global_data.num_cpus_installed; i++)
364 +
		for (i = 0; i < odp_global_ro.num_cpus_installed; i++)
367 365
			if (odp_cpumask_isset(control_mask, i))
368 366
				odp_cpumask_clr(worker_mask, i);
369 367
@@ -371,7 +369,7 @@
Loading
371 369
		 * If only one CPU installed, use CPU 0 for workers
372 370
		 * even though it is used for control as well.
373 371
		 */
374 -
		if (odp_global_data.num_cpus_installed < 2)
372 +
		if (odp_global_ro.num_cpus_installed < 2)
375 373
			odp_cpumask_set(worker_mask, 0);
376 374
		else
377 375
			odp_cpumask_clr(worker_mask, 0);
@@ -384,10 +382,10 @@
Loading
384 382
 * It also allows the default cpumasks to be overridden by
385 383
 * externally specified cpumasks passed in as initialization parameters.
386 384
 */
387 -
int odp_cpumask_init_global(const odp_init_t *params)
385 +
int _odp_cpumask_init_global(const odp_init_t *params)
388 386
{
389 -
	odp_cpumask_t *control_mask = &odp_global_data.control_cpus;
390 -
	odp_cpumask_t *worker_mask = &odp_global_data.worker_cpus;
387 +
	odp_cpumask_t *control_mask = &odp_global_ro.control_cpus;
388 +
	odp_cpumask_t *worker_mask = &odp_global_ro.worker_cpus;
391 389
	odp_cpumask_t check_mask;
392 390
	int control_cpus_default = 1;
393 391
	int worker_cpus_default = 1;
@@ -453,7 +451,7 @@
Loading
453 451
	}
454 452
}
455 453
456 -
int odp_cpumask_term_global(void)
454 +
int _odp_cpumask_term_global(void)
457 455
{
458 456
	return 0;
459 457
}

@@ -1,12 +1,10 @@
Loading
1 1
/* Copyright (c) 2013-2018, Linaro Limited
2 -
 * Copyright (c) 2013, Nokia Solutions and Networks
2 +
 * Copyright (c) 2013-2020, Nokia Solutions and Networks
3 3
 * All rights reserved.
4 4
 *
5 5
 * SPDX-License-Identifier:     BSD-3-Clause
6 6
 */
7 7
8 -
#include "config.h"
9 -
10 8
#include <odp_api.h>
11 9
#include <odp_packet_internal.h>
12 10
#include <odp_packet_io_internal.h>
@@ -19,6 +17,7 @@
Loading
19 17
#include <odp/api/plat/byteorder_inlines.h>
20 18
#include <odp_queue_if.h>
21 19
#include <odp/api/plat/queue_inlines.h>
20 +
#include <odp_global_data.h>
22 21
23 22
#include <protocols/eth.h>
24 23
#include <protocols/ip.h>
@@ -123,7 +122,7 @@
Loading
123 122
		pkt_len = odp_packet_len(pkt);
124 123
		pkt_hdr = packet_hdr(pkt);
125 124
126 -
		packet_parse_reset(pkt_hdr);
125 +
		packet_parse_reset(pkt_hdr, 1);
127 126
		if (pktio_cls_enabled(pktio_entry)) {
128 127
			odp_packet_t new_pkt;
129 128
			odp_pool_t new_pool;
@@ -163,7 +162,9 @@
Loading
163 162
					failed++;
164 163
					continue;
165 164
				}
165 +
166 166
				pkt = new_pkt;
167 +
				pkt_hdr = packet_hdr(new_pkt);
167 168
			}
168 169
		} else {
169 170