API Reference Manual  1.46.0
odp_debug.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2020-2022 Nokia
3  */
4 
13 #include <stdlib.h>
14 #include <stdio.h>
15 #include <stdint.h>
16 #include <inttypes.h>
17 #include <string.h>
18 #include <getopt.h>
19 
20 #include <odp_api.h>
21 #include <odp/helper/odph_api.h>
22 
23 #define MAX_NAME_LEN 128
24 
25 typedef struct test_global_t {
26  int system;
27  int shm;
28  int pool;
29  int queue;
30  int pktio;
31  int ipsec;
32  int timer;
33  int stash;
34  char pktio_name[MAX_NAME_LEN];
35 
36 } test_global_t;
37 
38 static test_global_t test_global;
39 
40 static void print_usage(void)
41 {
42  printf("This example prints out debug information on various ODP objects.\n"
43  "Select debug functions to be called with options. All listed functions\n"
44  "are called when no options are given.\n"
45  "\n"
46  "OPTIONS:\n"
47  " -S, --system Call odp_sys_info_print() and odp_sys_config_print()\n"
48  " -s, --shm Create a SHM and call odp_shm_print()\n"
49  " -p, --pool Create various types of pools and call odp_pool_print()\n"
50  " -q, --queue Create various types of queues and call odp_queue_print()\n"
51  " -i, --interface <name> Start a packet IO interface, and call odp_pktio_print(),\n"
52  " odp_pktio_extra_stats_print(), etc. Uses loop interface by default.\n"
53  " -I, --ipsec Call odp_ipsec_print()\n"
54  " -t, --timer Call timer pool, timer and timeout print functions\n"
55  " -a, --stash Create stash and call odp_stash_print()\n"
56  " -h, --help Display help and exit.\n\n");
57 }
58 
59 static int parse_options(int argc, char *argv[], test_global_t *global)
60 {
61  int opt;
62  char *str;
63  uint32_t str_len = 0;
64 
65  const struct option longopts[] = {
66  {"system", no_argument, NULL, 'S'},
67  {"shm", no_argument, NULL, 's'},
68  {"pool", no_argument, NULL, 'p'},
69  {"queue", no_argument, NULL, 'q'},
70  {"interface", required_argument, NULL, 'i'},
71  {"ipsec", no_argument, NULL, 'I'},
72  {"timer", no_argument, NULL, 't'},
73  {"stash", no_argument, NULL, 'a'},
74  {"help", no_argument, NULL, 'h'},
75  {NULL, 0, NULL, 0}
76  };
77  const char *shortopts = "+Sspqi:Itah";
78  int ret = 0;
79 
80  while (1) {
81  opt = getopt_long(argc, argv, shortopts, longopts, NULL);
82 
83  if (opt == -1)
84  break; /* No more options */
85 
86  switch (opt) {
87  case 'S':
88  global->system = 1;
89  break;
90  case 's':
91  global->shm = 1;
92  break;
93  case 'p':
94  global->pool = 1;
95  break;
96  case 'q':
97  global->queue = 1;
98  break;
99  case 'i':
100  global->pktio = 1;
101  str = optarg;
102  str_len = strlen(str);
103 
104  if (str_len && str_len < MAX_NAME_LEN)
105  strcpy(global->pktio_name, str);
106  break;
107  case 'I':
108  global->ipsec = 1;
109  break;
110  case 't':
111  global->timer = 1;
112  break;
113  case 'a':
114  global->stash = 1;
115  break;
116  case 'h':
117  default:
118  print_usage();
119  return -1;
120  }
121  }
122 
123  if (global->pktio && (str_len == 0 || str_len >= MAX_NAME_LEN)) {
124  ODPH_ERR("Bad interface name length: %u\n", str_len);
125  ret = -1;
126  }
127 
128  return ret;
129 }
130 
131 static int shm_debug(void)
132 {
133  const char *name = "debug_shm";
135 
136  shm = odp_shm_reserve(name, 8 * 1024, 64, 0);
137  if (shm == ODP_SHM_INVALID) {
138  ODPH_ERR("SHM reserve failed: %s\n", name);
139  return -1;
140  }
141 
142  printf("\n");
144 
145  printf("\n");
146  odp_shm_print(shm);
147 
148  if (odp_shm_free(shm)) {
149  ODPH_ERR("SHM free failed: %s\n", name);
150  return -1;
151  }
152 
153  return 0;
154 }
155 
156 static int buffer_debug(odp_pool_t pool)
157 {
158  odp_buffer_t buf = odp_buffer_alloc(pool);
159 
160  if (buf == ODP_BUFFER_INVALID) {
161  ODPH_ERR("Buffer alloc failed\n");
162  return -1;
163  }
164 
165  printf("\n");
166  odp_buffer_print(buf);
167 
168  odp_buffer_free(buf);
169 
170  return 0;
171 }
172 
173 static int packet_debug(odp_pool_t pool, int len)
174 {
175  odp_packet_t pkt = odp_packet_alloc(pool, len);
176 
177  if (pkt == ODP_PACKET_INVALID) {
178  ODPH_ERR("Packet alloc failed\n");
179  return -1;
180  }
181 
182  printf("\n");
183  odp_packet_print(pkt);
184 
185  printf("\n");
186  odp_packet_print_data(pkt, 0, len);
187 
188  odp_packet_free(pkt);
189 
190  return 0;
191 }
192 
193 static int pool_debug(void)
194 {
195  odp_pool_t pool;
196  odp_pool_param_t param;
197  const char *name;
198  int pkt_len = 100;
199 
200  name = "debug_buffer_pool";
201  odp_pool_param_init(&param);
202  param.type = ODP_POOL_BUFFER;
203  param.buf.num = 10;
204  param.buf.size = 1000;
205 
206  pool = odp_pool_create(name, &param);
207 
208  if (pool == ODP_POOL_INVALID) {
209  ODPH_ERR("Pool create failed: %s\n", name);
210  return -1;
211  }
212 
213  printf("\n");
214  odp_pool_print(pool);
215 
216  if (buffer_debug(pool))
217  return -1;
218 
219  if (odp_pool_destroy(pool)) {
220  ODPH_ERR("Pool destroy failed: %s\n", name);
221  return -1;
222  }
223 
224  name = "debug_packet_pool";
225  odp_pool_param_init(&param);
226  param.type = ODP_POOL_PACKET;
227  param.pkt.num = 10;
228  param.pkt.len = pkt_len;
229  param.pkt.max_len = 1000;
230 
231  pool = odp_pool_create(name, &param);
232 
233  if (pool == ODP_POOL_INVALID) {
234  ODPH_ERR("Pool create failed: %s\n", name);
235  return -1;
236  }
237 
238  printf("\n");
239  odp_pool_print(pool);
240 
241  if (packet_debug(pool, pkt_len))
242  return -1;
243 
244  if (odp_pool_destroy(pool)) {
245  ODPH_ERR("Pool destroy failed: %s\n", name);
246  return -1;
247  }
248 
249  name = "debug_tmo_pool";
250  odp_pool_param_init(&param);
251  param.type = ODP_POOL_TIMEOUT;
252  param.tmo.num = 10;
253 
254  pool = odp_pool_create(name, &param);
255 
256  if (pool == ODP_POOL_INVALID) {
257  ODPH_ERR("Pool create failed: %s\n", name);
258  return -1;
259  }
260 
261  printf("\n");
262  odp_pool_print(pool);
263 
264  if (odp_pool_destroy(pool)) {
265  ODPH_ERR("Pool destroy failed: %s\n", name);
266  return -1;
267  }
268 
269  return 0;
270 }
271 
272 static int queue_debug(void)
273 {
274  odp_queue_param_t param;
275  const char *name;
276  int i;
277  int num = 3;
278  odp_queue_t queue[num];
279 
280  name = "plain_queue";
281  odp_queue_param_init(&param);
282  param.type = ODP_QUEUE_TYPE_PLAIN;
283 
284  queue[0] = odp_queue_create(name, &param);
285 
286  if (queue[0] == ODP_QUEUE_INVALID) {
287  ODPH_ERR("Queue create failed: %s\n", name);
288  return -1;
289  }
290 
291  printf("\n");
292  odp_queue_print(queue[0]);
293 
294  name = "parallel_sched_queue";
295  odp_queue_param_init(&param);
296  param.type = ODP_QUEUE_TYPE_SCHED;
297 
298  queue[1] = odp_queue_create(name, &param);
299 
300  if (queue[1] == ODP_QUEUE_INVALID) {
301  ODPH_ERR("Queue create failed: %s\n", name);
302  return -1;
303  }
304 
305  printf("\n");
306  odp_queue_print(queue[1]);
307 
308  name = "atomic_sched_queue";
310  param.sched.prio = odp_schedule_max_prio();
311 
312  queue[2] = odp_queue_create(name, &param);
313 
314  if (queue[2] == ODP_QUEUE_INVALID) {
315  ODPH_ERR("Queue create failed: %s\n", name);
316  return -1;
317  }
318 
319  printf("\n");
320  odp_queue_print(queue[2]);
321 
322  printf("\n");
324 
325  printf("\n");
327 
328  for (i = 0; i < num; i++) {
329  if (odp_queue_destroy(queue[i])) {
330  ODPH_ERR("Queue destroy failed: %i\n", i);
331  return -1;
332  }
333  }
334 
335  return 0;
336 }
337 
338 static int pktio_debug(test_global_t *global)
339 {
340  odp_pool_t pool;
341  odp_pool_param_t pool_param;
342  odp_pktio_t pktio;
344  uint8_t mac[ODPH_ETHADDR_LEN];
345  int pkt_len = 100;
346 
347  odp_pool_param_init(&pool_param);
348  pool_param.type = ODP_POOL_PACKET;
349  pool_param.pkt.num = 10;
350  pool_param.pkt.len = pkt_len;
351 
352  pool = odp_pool_create("debug_pktio_pool", &pool_param);
353 
354  if (pool == ODP_POOL_INVALID) {
355  ODPH_ERR("Pool create failed\n");
356  return -1;
357  }
358 
359  pktio = odp_pktio_open(global->pktio_name, pool, NULL);
360 
361  if (pktio == ODP_PKTIO_INVALID) {
362  ODPH_ERR("Pktio open failed\n");
363  return -1;
364  }
365 
366  /* Start interface with default config */
367  if (odp_pktin_queue_config(pktio, NULL)) {
368  ODPH_ERR("Packet input queue config failed\n");
369  return -1;
370  }
371 
372  if (odp_pktout_queue_config(pktio, NULL)) {
373  ODPH_ERR("Packet output queue config failed\n");
374  return -1;
375  }
376 
377  if (odp_pktio_start(pktio)) {
378  ODPH_ERR("Pktio start failed\n");
379  return -1;
380  }
381 
382  printf("\nWaiting link up");
383 
384  /* Wait max 5 seconds for link up */
385  for (int i = 0; i < 25; i++) {
387  break;
388 
390  printf(".");
391  fflush(NULL);
392  }
393 
394  printf("\n\n");
395 
396  printf("Packet IO\n---------\n");
397  printf(" index: %i\n", odp_pktio_index(pktio));
398  printf(" handle: 0x%" PRIx64 "\n", odp_pktio_to_u64(pktio));
399 
400  if (odp_pktio_mac_addr(pktio, mac, ODPH_ETHADDR_LEN) == ODPH_ETHADDR_LEN) {
401  printf(" mac address: %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2],
402  mac[3], mac[4], mac[5]);
403  }
404 
405  printf(" input maxlen: %u\n", odp_pktin_maxlen(pktio));
406  printf(" output maxlen: %u\n", odp_pktout_maxlen(pktio));
407  printf(" promisc mode: %i\n", odp_pktio_promisc_mode(pktio));
408  printf(" timestamp res: %" PRIu64 " Hz\n\n", odp_pktio_ts_res(pktio));
409 
410  if (odp_pktio_link_info(pktio, &info) == 0) {
411  printf("Link info\n---------\n");
412  printf(" auto neg: %i\n", info.autoneg);
413  printf(" duplex: %i\n", info.duplex);
414  printf(" media: %s\n", info.media);
415  printf(" pause_rx: %i\n", info.pause_rx);
416  printf(" pause_tx: %i\n", info.pause_tx);
417  printf(" speed: %u Mbit/s\n", info.speed);
418  printf(" status: %i\n", info.status);
419  }
420 
421  printf("\n");
422  odp_pktio_print(pktio);
423 
424  printf("\n");
426 
427  if (odp_pktio_stop(pktio)) {
428  ODPH_ERR("Pktio stop failed\n");
429  return -1;
430  }
431 
432  if (odp_pktio_close(pktio)) {
433  ODPH_ERR("Pktio close failed\n");
434  return -1;
435  }
436 
437  if (odp_pool_destroy(pool)) {
438  ODPH_ERR("Pool destroy failed\n");
439  return -1;
440  }
441 
442  return 0;
443 }
444 
445 static int ipsec_debug(void)
446 {
447  printf("\n");
448  odp_ipsec_print();
449 
450  return 0;
451 }
452 
453 static int timer_debug(void)
454 {
455  odp_pool_t pool;
456  odp_pool_param_t pool_param;
457  odp_timeout_t timeout;
458  odp_timer_res_capability_t timer_res_capa;
459  odp_timer_capability_t timer_capa;
460  odp_timer_pool_t timer_pool;
461  odp_timer_pool_param_t timer_param;
462  odp_timer_start_t start_param;
463  odp_timer_t timer;
464  odp_queue_t queue;
465  odp_queue_param_t queue_param;
466  odp_event_t event;
467  uint64_t tick;
468  uint64_t max_tmo = ODP_TIME_SEC_IN_NS;
469  uint64_t res = 100 * ODP_TIME_MSEC_IN_NS;
470  int started = 0;
471 
472  odp_pool_param_init(&pool_param);
473  pool_param.type = ODP_POOL_TIMEOUT;
474  pool_param.tmo.num = 10;
475 
476  pool = odp_pool_create("debug_timer", &pool_param);
477 
478  if (pool == ODP_POOL_INVALID) {
479  ODPH_ERR("Pool create failed\n");
480  return -1;
481  }
482 
483  timeout = odp_timeout_alloc(pool);
484  if (timeout == ODP_TIMEOUT_INVALID) {
485  ODPH_ERR("Timeout alloc failed\n");
486  return -1;
487  }
488 
489  if (odp_timer_capability(ODP_CLOCK_DEFAULT, &timer_capa)) {
490  ODPH_ERR("Timer capa failed\n");
491  return -1;
492  }
493 
494  if (timer_capa.max_tmo.max_tmo < max_tmo)
495  max_tmo = timer_capa.max_tmo.max_tmo;
496 
497  memset(&timer_res_capa, 0, sizeof(odp_timer_res_capability_t));
498  timer_res_capa.max_tmo = max_tmo;
499  if (odp_timer_res_capability(ODP_CLOCK_DEFAULT, &timer_res_capa)) {
500  ODPH_ERR("Timer resolution capability failed\n");
501  return -1;
502  }
503 
504  if (timer_res_capa.res_ns > res)
505  res = timer_res_capa.res_ns;
506 
507  odp_timer_pool_param_init(&timer_param);
508  timer_param.res_ns = res;
509  timer_param.min_tmo = max_tmo / 10;
510  timer_param.max_tmo = max_tmo;
511  timer_param.num_timers = 10;
512  timer_param.clk_src = ODP_CLOCK_DEFAULT;
513 
514  timer_pool = odp_timer_pool_create("debug_timer", &timer_param);
515 
516  if (timer_pool == ODP_TIMER_POOL_INVALID) {
517  ODPH_ERR("Timer pool create failed\n");
518  return -1;
519  }
520 
521  if (odp_timer_pool_start_multi(&timer_pool, 1) != 1) {
522  ODPH_ERR("Timer pool start failed\n");
523  return -1;
524  }
525 
526  odp_queue_param_init(&queue_param);
527  if (timer_capa.queue_type_sched)
528  queue_param.type = ODP_QUEUE_TYPE_SCHED;
529 
530  queue = odp_queue_create("debug_timer", &queue_param);
531  if (queue == ODP_QUEUE_INVALID) {
532  ODPH_ERR("Queue create failed.\n");
533  return -1;
534  }
535 
536  printf("\n");
537  odp_timer_pool_print(timer_pool);
538 
539  tick = odp_timer_ns_to_tick(timer_pool, max_tmo / 2);
540 
541  timer = odp_timer_alloc(timer_pool, queue, (void *)(uintptr_t)0xdeadbeef);
542 
543  printf("\n");
544  odp_timeout_print(timeout);
545 
546  event = odp_timeout_to_event(timeout);
547 
548  start_param.tick_type = ODP_TIMER_TICK_REL;
549  start_param.tick = tick;
550  start_param.tmo_ev = event;
551 
552  if (odp_timer_start(timer, &start_param) == ODP_TIMER_SUCCESS)
553  started = 1;
554  else
555  ODPH_ERR("Timer start failed.\n");
556 
557  printf("\n");
558  odp_timer_print(timer);
559 
560  if (started && odp_timer_cancel(timer, &event) != ODP_TIMER_SUCCESS) {
561  ODPH_ERR("Timer cancel failed\n");
562  return -1;
563  } else {
564  timeout = odp_timeout_from_event(event);
565 
566  printf("\n");
567  odp_timeout_print(timeout);
568 
569  odp_timeout_free(timeout);
570  }
571 
572  if (odp_timer_free(timer)) {
573  ODPH_ERR("Timer free failed\n");
574  return -1;
575  }
576 
577  odp_timer_pool_destroy(timer_pool);
578 
579  if (odp_queue_destroy(queue)) {
580  ODPH_ERR("Queue destroy failed\n");
581  return -1;
582  }
583 
584  if (odp_pool_destroy(pool)) {
585  ODPH_ERR("Pool destroy failed\n");
586  return -1;
587  }
588 
589  return 0;
590 }
591 
592 static int stash_debug(void)
593 {
594  odp_stash_param_t param;
595  odp_stash_t stash;
596  uint32_t val = 0xdeadbeef;
597 
598  odp_stash_param_init(&param);
599  param.num_obj = 10;
600  param.obj_size = 4;
601 
602  stash = odp_stash_create("debug_stash", &param);
603 
604  if (stash == ODP_STASH_INVALID) {
605  ODPH_ERR("Stash create failed\n");
606  return -1;
607  }
608 
609  if (odp_stash_put_u32(stash, &val, 1) != 1) {
610  ODPH_ERR("Stash put failed\n");
611  return -1;
612  }
613 
614  printf("\n");
615  odp_stash_print(stash);
616 
617  if (odp_stash_get_u32(stash, &val, 1) != 1) {
618  ODPH_ERR("Stash get failed\n");
619  return -1;
620  }
621 
622  if (odp_stash_destroy(stash)) {
623  ODPH_ERR("Stash destroy failed\n");
624  return -1;
625  }
626 
627  return 0;
628 }
629 
630 int main(int argc, char *argv[])
631 {
632  odp_instance_t inst;
633  test_global_t *global = &test_global;
634 
635  printf("ODP debug example\n\n");
636  memset(global, 0, sizeof(test_global_t));
637 
638  if (argc < 2) {
639  /* If not arguments, run all test cases */
640  global->system = 1;
641  global->shm = 1;
642  global->pool = 1;
643  global->queue = 1;
644  global->pktio = 1;
645  global->ipsec = 1;
646  global->timer = 1;
647  global->stash = 1;
648  strcpy(global->pktio_name, "loop");
649  } else {
650  if (parse_options(argc, argv, global))
651  exit(EXIT_FAILURE);
652  }
653 
654  if (odp_init_global(&inst, NULL, NULL)) {
655  ODPH_ERR("Global init failed.\n");
656  exit(EXIT_FAILURE);
657  }
658 
659  if (odp_init_local(inst, ODP_THREAD_CONTROL)) {
660  ODPH_ERR("Local init failed.\n");
661  exit(EXIT_FAILURE);
662  }
663 
664  /* Configure scheduler before creating any scheduled queues */
665  if (odp_schedule_config(NULL)) {
666  ODPH_ERR("Schedule config failed\n");
667  exit(EXIT_FAILURE);
668  }
669 
670  if (global->system) {
671  printf("\n");
673 
674  printf("\n");
676  }
677 
678  if (global->shm && shm_debug()) {
679  ODPH_ERR("SHM debug failed.\n");
680  exit(EXIT_FAILURE);
681  }
682 
683  if (global->pool && pool_debug()) {
684  ODPH_ERR("Pool debug failed.\n");
685  exit(EXIT_FAILURE);
686  }
687 
688  if (global->queue && queue_debug()) {
689  ODPH_ERR("Queue debug failed.\n");
690  exit(EXIT_FAILURE);
691  }
692 
693  if (global->pktio && pktio_debug(global)) {
694  ODPH_ERR("Packet debug failed.\n");
695  exit(EXIT_FAILURE);
696  }
697 
698  if (global->ipsec && ipsec_debug()) {
699  ODPH_ERR("IPSEC debug failed.\n");
700  exit(EXIT_FAILURE);
701  }
702 
703  if (global->timer && timer_debug()) {
704  ODPH_ERR("Timer debug failed.\n");
705  exit(EXIT_FAILURE);
706  }
707 
708  if (global->stash && stash_debug()) {
709  ODPH_ERR("Stash debug failed.\n");
710  exit(EXIT_FAILURE);
711  }
712 
713  if (odp_term_local()) {
714  ODPH_ERR("Local term failed.\n");
715  exit(EXIT_FAILURE);
716  }
717 
718  if (odp_term_global(inst)) {
719  ODPH_ERR("Global term failed.\n");
720  exit(EXIT_FAILURE);
721  }
722 
723  return 0;
724 }
odp_buffer_t odp_buffer_alloc(odp_pool_t pool)
Buffer alloc.
void odp_buffer_free(odp_buffer_t buf)
Buffer free.
#define ODP_BUFFER_INVALID
Invalid buffer.
void odp_buffer_print(odp_buffer_t buf)
Print buffer metadata to STDOUT.
int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type)
Thread local ODP initialization.
int odp_init_global(odp_instance_t *instance, const odp_init_t *params, const odp_platform_init_t *platform_params)
Global ODP initialization.
int odp_term_local(void)
Thread local ODP termination.
int odp_term_global(odp_instance_t instance)
Global ODP termination.
uint64_t odp_instance_t
ODP instance ID.
void odp_ipsec_print(void)
Print global IPSEC configuration info.
int odp_pktio_mac_addr(odp_pktio_t pktio, void *mac_addr, int size)
Get the default MAC address of a packet IO interface.
uint64_t odp_pktio_ts_res(odp_pktio_t pktio)
Packet IO timestamp resolution in hertz.
int odp_pktio_promisc_mode(odp_pktio_t pktio)
Determine if promiscuous mode is enabled for a packet IO interface.
int odp_pktio_close(odp_pktio_t pktio)
Close a packet IO interface.
uint32_t odp_pktin_maxlen(odp_pktio_t pktio)
Maximum frame length at packet input.
int odp_pktio_link_info(odp_pktio_t pktio, odp_pktio_link_info_t *info)
Retrieve information about packet IO link status.
uint32_t odp_pktout_maxlen(odp_pktio_t pktio)
Maximum frame length at packet output.
void odp_pktio_extra_stats_print(odp_pktio_t pktio)
Print extra statistics for a packet IO interface.
odp_pktio_t odp_pktio_open(const char *name, odp_pool_t pool, const odp_pktio_param_t *param)
Open a packet IO interface.
void odp_pktio_print(odp_pktio_t pktio)
Print pktio info to the console.
int odp_pktio_start(odp_pktio_t pktio)
Start packet receive and transmit.
#define ODP_PKTIO_INVALID
Invalid packet IO handle.
int odp_pktio_stop(odp_pktio_t pktio)
Stop packet receive and transmit.
int odp_pktio_index(odp_pktio_t pktio)
Get pktio interface index.
odp_pktio_link_status_t odp_pktio_link_status(odp_pktio_t pktio)
Determine pktio link is up or down for a packet IO interface.
uint64_t odp_pktio_to_u64(odp_pktio_t pktio)
Get printable value for an odp_pktio_t.
int odp_pktin_queue_config(odp_pktio_t pktio, const odp_pktin_queue_param_t *param)
Configure packet input queues.
int odp_pktout_queue_config(odp_pktio_t pktio, const odp_pktout_queue_param_t *param)
Configure packet output queues.
@ ODP_PKTIO_LINK_STATUS_UP
Link status is up.
void odp_packet_print_data(odp_packet_t pkt, uint32_t offset, uint32_t len)
Print packet data.
odp_packet_t odp_packet_alloc(odp_pool_t pool, uint32_t len)
Allocate a packet from a packet pool.
void odp_packet_free(odp_packet_t pkt)
Free packet.
#define ODP_PACKET_INVALID
Invalid packet.
void odp_packet_print(odp_packet_t pkt)
Print packet debug information.
odp_pool_t odp_pool_create(const char *name, const odp_pool_param_t *param)
Create a pool.
void odp_pool_param_init(odp_pool_param_t *param)
Initialize pool params.
int odp_pool_destroy(odp_pool_t pool)
Destroy a pool previously created by odp_pool_create()
void odp_pool_print(odp_pool_t pool)
Print pool info.
#define ODP_POOL_INVALID
Invalid pool.
@ ODP_POOL_TIMEOUT
Timeout pool.
@ ODP_POOL_BUFFER
Buffer pool.
@ ODP_POOL_PACKET
Packet pool.
void odp_queue_param_init(odp_queue_param_t *param)
Initialize queue params.
#define ODP_QUEUE_INVALID
Invalid queue.
void odp_queue_print_all(void)
Print debug info about all queues.
odp_queue_t odp_queue_create(const char *name, const odp_queue_param_t *param)
Queue create.
void odp_queue_print(odp_queue_t queue)
Print queue info.
int odp_queue_destroy(odp_queue_t queue)
Destroy ODP queue.
@ ODP_QUEUE_TYPE_SCHED
Scheduled queue.
@ ODP_QUEUE_TYPE_PLAIN
Plain queue.
#define ODP_SCHED_SYNC_ATOMIC
Atomic queue synchronization.
int odp_schedule_max_prio(void)
Maximum scheduling priority level.
int odp_schedule_config(const odp_schedule_config_t *config)
Global schedule configuration.
void odp_schedule_print(void)
Print debug info about scheduler.
void odp_shm_print_all(void)
Print all shared memory blocks.
int odp_shm_free(odp_shm_t shm)
Free a contiguous block of shared memory.
void odp_shm_print(odp_shm_t shm)
Print shared memory block info.
#define ODP_SHM_INVALID
Invalid shared memory block.
odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align, uint32_t flags)
Reserve a contiguous block of shared memory.
#define ODP_STASH_INVALID
Invalid stash handle.
void odp_stash_param_init(odp_stash_param_t *param)
Initialize stash params.
int odp_stash_destroy(odp_stash_t stash)
Destroy a stash.
int32_t odp_stash_put_u32(odp_stash_t stash, const uint32_t val[], int32_t num)
Put 32-bit integers into a stash.
int32_t odp_stash_get_u32(odp_stash_t stash, uint32_t val[], int32_t num)
Get 32-bit integers from a stash.
void odp_stash_print(odp_stash_t stash)
Print debug information about the stash.
odp_stash_t odp_stash_create(const char *name, const odp_stash_param_t *param)
Create a stash.
void odp_sys_info_print(void)
Print system info.
void odp_sys_config_print(void)
Print configuration.
@ ODP_THREAD_CONTROL
Control thread.
#define ODP_TIME_SEC_IN_NS
A second in nanoseconds.
void odp_time_wait_ns(uint64_t ns)
Wait the specified number of nanoseconds.
#define ODP_TIME_MSEC_IN_NS
A millisecond in nanoseconds.
void odp_timeout_free(odp_timeout_t tmo)
Timeout free.
int odp_timer_pool_start_multi(odp_timer_pool_t timer_pool[], int num)
Start timer pools.
void odp_timer_pool_print(odp_timer_pool_t timer_pool)
Print timer pool debug information.
void odp_timer_print(odp_timer_t timer)
Print timer debug information.
odp_timeout_t odp_timeout_alloc(odp_pool_t pool)
Timeout alloc.
int odp_timer_free(odp_timer_t timer)
Free a timer.
odp_timeout_t odp_timeout_from_event(odp_event_t ev)
Get timeout handle from a ODP_EVENT_TIMEOUT type event.
#define ODP_TIMER_POOL_INVALID
Invalid timer pool handle.
odp_timer_pool_t odp_timer_pool_create(const char *name, const odp_timer_pool_param_t *params)
Create a timer pool.
int odp_timer_cancel(odp_timer_t timer, odp_event_t *tmo_ev)
Cancel a timer.
int odp_timer_capability(odp_timer_clk_src_t clk_src, odp_timer_capability_t *capa)
Query timer capabilities per clock source.
uint64_t odp_timer_ns_to_tick(odp_timer_pool_t timer_pool, uint64_t ns)
Convert nanoseconds to timer ticks.
int odp_timer_start(odp_timer_t timer, const odp_timer_start_t *start_param)
Start a timer.
int odp_timer_res_capability(odp_timer_clk_src_t clk_src, odp_timer_res_capability_t *res_capa)
Timer resolution capability.
void odp_timeout_print(odp_timeout_t tmo)
Print timeout debug information.
odp_event_t odp_timeout_to_event(odp_timeout_t tmo)
Convert timeout handle to event handle.
#define ODP_TIMEOUT_INVALID
Invalid timeout handle.
odp_timer_t odp_timer_alloc(odp_timer_pool_t timer_pool, odp_queue_t queue, const void *user_ptr)
Allocate a timer.
#define ODP_CLOCK_DEFAULT
The default clock source.
void odp_timer_pool_param_init(odp_timer_pool_param_t *param)
Initialize timer pool parameters.
void odp_timer_pool_destroy(odp_timer_pool_t timer_pool)
Destroy a timer pool.
@ ODP_TIMER_SUCCESS
Timer operation succeeded.
@ ODP_TIMER_TICK_REL
Relative ticks.
The OpenDataPlane API.
Pool parameters.
uint32_t num
Number of buffers in the pool.
uint32_t max_len
Maximum packet length that will be allocated from the pool.
struct odp_pool_param_t::@127 tmo
Parameters for timeout pools.
uint32_t size
Minimum buffer size in bytes.
odp_pool_type_t type
Pool type.
uint32_t len
Minimum length of 'num' packets.
struct odp_pool_param_t::@126 pkt
Parameters for packet pools.
struct odp_pool_param_t::@125 buf
Parameters for buffer pools.
ODP Queue parameters.
odp_schedule_param_t sched
Scheduler parameters.
odp_queue_type_t type
Queue type.
odp_schedule_prio_t prio
Priority level.
odp_schedule_sync_t sync
Synchronization method.
Stash parameters.
uint32_t obj_size
Object handle size in bytes.
uint64_t num_obj
Number of object handles.
odp_timer_res_capability_t max_tmo
Maximum timeout length.
odp_bool_t queue_type_sched
Scheduled queue destination support.
Timer pool parameters.
uint64_t res_ns
Timeout resolution in nanoseconds.
uint64_t min_tmo
Minimum relative timeout in nanoseconds.
uint32_t num_timers
Number of timers in the pool.
odp_timer_clk_src_t clk_src
Clock source for timers.
uint64_t max_tmo
Maximum relative timeout in nanoseconds.
Timer resolution capability.
uint64_t max_tmo
Maximum relative timeout in nanoseconds.
uint64_t res_ns
Timeout resolution in nanoseconds.
Timer start parameters.
uint64_t tick
Expiration time in ticks.
odp_event_t tmo_ev
Timeout event.
odp_timer_tick_type_t tick_type
Tick type.