18#include <odp/helper/odph_api.h>
20#include <bench_common.h>
21#include <export_results.h>
33#define MAX_NAME_LEN 128
36#define TEST_MAX_BENCH_NUM 10
38#define BENCH_INFO(run_fn, init_fn, term_fn, cond_fn, rounds) \
39 {.name = #run_fn, .run = run_fn, .init = init_fn, .term = term_fn, .cond = cond_fn,\
52 char name[MAX_NAME_LEN];
61 uint32_t num_input_queues;
64 uint32_t num_output_queues;
102 bench_tm_suite_t suite;
108 bench_tm_result_t result[TEST_MAX_BENCH_NUM];
112static appl_args_t *gbl_args;
116 if (gbl_args == NULL)
121static int setup_sig_handler(
void)
123 struct sigaction action;
125 memset(&action, 0,
sizeof(action));
126 action.sa_handler = sig_handler;
130 if (sigemptyset(&action.sa_mask))
133 if (sigaction(SIGINT, &action, NULL))
139static void clean_pending_events(
void)
159 ODPH_ABORT(
"Reading pool capabilities failed\n");
174 ODPH_ABORT(
"Creating packet pool failed\n");
181 appl_args_t *appl_args = gbl_args;
189 pool = create_packet_pool();
197 ODPH_ABORT(
"Opening pktio failed\n");
200 pktin_param.
num_queues = appl_args->opt.num_input_queues;
212 pktout_param.
num_queues = appl_args->opt.num_output_queues;
216 ODPH_ABORT(
"Configuring packet input queues failed: %d\n", ret);
220 ODPH_ABORT(
"Configuring packet output queues failed: %d\n", ret);
224 ODPH_ABORT(
"Starting pktio failed: %d\n", ret);
226 appl_args->pool = pool;
227 appl_args->pktio = pktio;
230static void pktio_setup(
void)
232 pktio_setup_param(gbl_args->opt.in_mode, gbl_args->opt.out_mode,
false);
235static void pktio_setup_direct_rx(
void)
240static void pktio_setup_sched_rx(
void)
245static void pktio_setup_cls(
void)
250static void pktio_setup_direct_tx(
void)
255static void pktio_setup_queue_tx(
void)
262 appl_args_t *appl_args = gbl_args;
267 ODPH_ABORT(
"Stopping pktio failed: %d\n", ret);
271 clean_pending_events();
275 ODPH_ABORT(
"Closing pktio failed: %d\n", ret);
279 ODPH_ABORT(
"Destroying pktio pool failed: %d\n", ret);
282static void pktio_clean(
void)
284 pktio_clean_param(gbl_args->opt.in_mode);
287static void pktio_clean_direct_rx(
void)
292static void pktio_clean_sched_rx(
void)
297static int pktio_capability(bench_tm_result_t *res,
int repeat_count)
299 appl_args_t *appl_args = gbl_args;
302 bench_tm_stamp_t s1, s2;
304 uint8_t id1 = bench_tm_func_register(res,
"odp_pktio_capability()");
306 for (
int i = 0; i < repeat_count; i++) {
307 bench_tm_now(res, &s1);
309 bench_tm_now(res, &s2);
312 ODPH_ERR(
"Reading pktio capa failed: %d\n", ret);
316 bench_tm_func_record(&s2, &s1, res, id1);
321static int pktio_lookup(bench_tm_result_t *res,
int repeat_count)
323 appl_args_t *appl_args = gbl_args;
324 const char *name = appl_args->opt.name;
326 bench_tm_stamp_t s1, s2;
327 uint8_t id1 = bench_tm_func_register(res,
"odp_pktio_lookup()");
329 for (
int i = 0; i < repeat_count; i++) {
330 bench_tm_now(res, &s1);
332 bench_tm_now(res, &s2);
335 ODPH_ERR(
"Pktio lookup failed\n");
339 bench_tm_func_record(&s2, &s1, res, id1);
344static int pktio_open_start_stop_close(bench_tm_result_t *res,
int repeat_count)
346 appl_args_t *appl_args = gbl_args;
352 bench_tm_stamp_t s1, s2, s3, s4, s5, s6, s7, s8;
354 uint8_t id1 = bench_tm_func_register(res,
"odp_pktio_open()");
355 uint8_t id2 = bench_tm_func_register(res,
"odp_pktin_queue_config()");
356 uint8_t id3 = bench_tm_func_register(res,
"odp_pktout_queue_config()");
357 uint8_t id4 = bench_tm_func_register(res,
"odp_pktio_start()");
358 uint8_t id5 = bench_tm_func_register(res,
"odp_pktio_stop()");
359 uint8_t id6 = bench_tm_func_register(res,
"odp_pktio_close()");
361 pool = create_packet_pool();
364 param.
in_mode = appl_args->opt.in_mode;
365 param.
out_mode = appl_args->opt.out_mode;
368 pktin_param.
num_queues = appl_args->opt.num_input_queues;
375 pktout_param.
num_queues = appl_args->opt.num_output_queues;
377 for (
int i = 0; i < repeat_count; i++) {
378 bench_tm_now(res, &s1);
380 bench_tm_now(res, &s2);
383 ODPH_ERR(
"Opening pktio failed\n");
388 bench_tm_now(res, &s3);
391 ODPH_ERR(
"Configuring packet input queues failed: %d\n", ret);
396 bench_tm_now(res, &s4);
399 ODPH_ERR(
"Configuring packet output queues failed: %d\n", ret);
404 bench_tm_now(res, &s5);
407 ODPH_ERR(
"Starting pktio failed: %d\n", ret);
412 bench_tm_now(res, &s6);
415 ODPH_ERR(
"Stopping pktio failed: %d\n", ret);
421 clean_pending_events();
423 bench_tm_now(res, &s7);
425 bench_tm_now(res, &s8);
427 ODPH_ERR(
"Closing pktio failed: %d\n", ret);
431 bench_tm_func_record(&s2, &s1, res, id1);
432 bench_tm_func_record(&s3, &s2, res, id2);
433 bench_tm_func_record(&s4, &s3, res, id3);
434 bench_tm_func_record(&s5, &s4, res, id4);
435 bench_tm_func_record(&s6, &s5, res, id5);
436 bench_tm_func_record(&s8, &s7, res, id6);
441 ODPH_ERR(
"Destroying pktio pool failed: %d\n", ret);
447static int pktio_stats(bench_tm_result_t *res,
int repeat_count)
449 appl_args_t *appl_args = gbl_args;
452 bench_tm_stamp_t s1, s2;
454 uint8_t id1 = bench_tm_func_register(res,
"odp_pktio_stats()");
456 for (
int i = 0; i < repeat_count; i++) {
457 bench_tm_now(res, &s1);
459 bench_tm_now(res, &s2);
462 ODPH_ERR(
"Reading pktio stats failed\n");
466 bench_tm_func_record(&s2, &s1, res, id1);
471static int pktio_stats_reset(bench_tm_result_t *res,
int repeat_count)
473 appl_args_t *appl_args = gbl_args;
475 bench_tm_stamp_t s1, s2;
477 int id1 = bench_tm_func_register(res,
"odp_pktio_stats_reset()");
479 for (
int i = 0; i < repeat_count; i++) {
480 bench_tm_now(res, &s1);
482 bench_tm_now(res, &s2);
485 ODPH_ERR(
"Resetting pktio stats failed\n");
489 bench_tm_func_record(&s2, &s1, res, id1);
494static int pktin_queue_stats(bench_tm_result_t *res,
int repeat_count)
496 appl_args_t *appl_args = gbl_args;
500 bench_tm_stamp_t s1, s2;
502 uint8_t id1 = bench_tm_func_register(res,
"odp_pktin_queue_stats()");
506 ODPH_ERR(
"Reading pktio input queue failed\n");
510 for (
int i = 0; i < repeat_count; i++) {
511 bench_tm_now(res, &s1);
513 bench_tm_now(res, &s2);
516 ODPH_ERR(
"Reading pktio stats failed\n");
520 bench_tm_func_record(&s2, &s1, res, id1);
525static int pktin_event_queue_stats(bench_tm_result_t *res,
int repeat_count)
527 appl_args_t *appl_args = gbl_args;
531 bench_tm_stamp_t s1, s2;
533 uint8_t id1 = bench_tm_func_register(res,
"odp_pktin_event_queue_stats()");
537 ODPH_ERR(
"Reading pktio input queue failed\n");
541 for (
int i = 0; i < repeat_count; i++) {
542 bench_tm_now(res, &s1);
544 bench_tm_now(res, &s2);
547 ODPH_ERR(
"Reading pktio stats failed\n");
551 bench_tm_func_record(&s2, &s1, res, id1);
556static int pktout_queue_stats(bench_tm_result_t *res,
int repeat_count)
558 appl_args_t *appl_args = gbl_args;
562 bench_tm_stamp_t s1, s2;
564 uint8_t id1 = bench_tm_func_register(res,
"odp_pktout_queue_stats()");
568 ODPH_ERR(
"Reading pktio input queue failed\n");
572 for (
int i = 0; i < repeat_count; i++) {
573 bench_tm_now(res, &s1);
575 bench_tm_now(res, &s2);
578 ODPH_ERR(
"Reading pktio stats failed\n");
582 bench_tm_func_record(&s2, &s1, res, id1);
587static int pktout_event_queue_stats(bench_tm_result_t *res,
int repeat_count)
589 appl_args_t *appl_args = gbl_args;
593 bench_tm_stamp_t s1, s2;
595 uint8_t id1 = bench_tm_func_register(res,
"odp_pktout_event_queue_stats()");
599 ODPH_ERR(
"Reading pktio input queue failed\n");
603 for (
int i = 0; i < repeat_count; i++) {
604 bench_tm_now(res, &s1);
606 bench_tm_now(res, &s2);
609 ODPH_ERR(
"Reading pktio stats failed\n");
613 bench_tm_func_record(&s2, &s1, res, id1);
637static int check_cls_capa(
void)
639 appl_args_t *appl_args = gbl_args;
646 ODPH_ERR(
"Reading classifier capa failed: %d\n", ret);
652 ODPH_ERR(
"Reading scheduler capa failed: %d\n", ret);
656 if (!find_first_supported_l3_pmr(&cls_capa, &appl_args->cls_pmr_create.term)) {
657 ODPH_ERR(
"Implementations doesn't support any TCP/UDP PMRs\n");
662 if (appl_args->opt.num_pmr + 1 > cls_capa.
max_cos) {
663 ODPH_ERR(
"Not enough CoSes supported for PMR test: %u/%u\n",
664 appl_args->opt.num_pmr + 1, cls_capa.
max_cos);
668 if (appl_args->opt.num_pmr + 1 > sched_capa.
max_queues) {
669 ODPH_ERR(
"Not enough queues supported for PMR test: %u/%u\n",
670 appl_args->opt.num_pmr + 1, sched_capa.
max_queues);
674 appl_args->cls_pmr_create.enabled =
true;
679static int check_cls_cond(
void)
681 return gbl_args->cls_pmr_create.enabled;
684static int cls_pmr_create(bench_tm_result_t *res,
int repeat_count)
686 appl_args_t *appl_args = gbl_args;
692 uint32_t num_cos = appl_args->opt.num_pmr + 1;
693 uint32_t num_pmr = num_cos - 1;
694 uint32_t cos_created = 0;
695 uint32_t queue_created = 0;
697 uint16_t mask = 0xffff;
699 bench_tm_stamp_t s1, s2;
703 uint8_t id1 = bench_tm_func_register(res,
"odp_cls_pmr_create()");
704 uint8_t id2 = bench_tm_func_register(res,
"odp_cls_pmr_destroy()");
711 for (uint32_t i = 0; i < num_cos; i++) {
714 ODPH_ERR(
"odp_queue_create() failed %u / %u\n", i + 1, num_cos);
718 cos_param.
queue = queue[i];
723 ODPH_ERR(
"odp_cls_cos_create() failed %u / %u\n", i + 1, num_cos);
729 if (queue_created != num_cos)
730 ODPH_ERR(
"Unable to create all queues: %u/%u\n", queue_created, num_cos);
732 if (cos_created != num_cos) {
733 ODPH_ERR(
"Unable to create all CoSes: %u/%u\n", cos_created, num_cos);
737 default_cos = cos[0];
741 ODPH_ERR(
"Setting default CoS failed: %d\n", ret);
746 pmr_param.
term = appl_args->cls_pmr_create.term;
749 pmr_param.
val_sz =
sizeof(val);
751 for (uint32_t i = 0; i < (uint32_t)repeat_count; i++) {
752 uint32_t pmr_created = 0;
754 for (uint32_t j = 0; j < num_pmr; j++) {
755 bench_tm_now(res, &s1);
757 bench_tm_now(res, &s2);
761 bench_tm_func_record(&s2, &s1, res, id1);
767 for (uint32_t j = 0; j < pmr_created; j++) {
768 bench_tm_now(res, &s1);
770 bench_tm_now(res, &s2);
773 ODPH_ABORT(
"Destroying PMR failed: %d\n", ret);
775 bench_tm_func_record(&s2, &s1, res, id2);
779 ODPH_DBG(
"Created %u PMRs\n", pmr_created);
785 ODPH_ERR(
"Setting default CoS failed: %d\n", ret);
790 for (uint32_t i = 0; i < cos_created; i++) {
794 ODPH_ERR(
"Destroying CoS failed: %d\n", ret);
799 for (uint32_t i = 0; i < queue_created; i++) {
803 ODPH_ERR(
"Destroying queue failed: %d\n", ret);
811static int bench_pktio_sp_export(
void *data)
813 appl_args_t *gbl_args = data;
814 bench_tm_result_t *res;
817 const char *unit = gbl_args->opt.time ?
"nsec" :
"cycles";
819 if (test_common_write(
"function name,latency (%s) per function call (min),"
820 "latency (%s) per function call (avg),"
821 "latency (%s) per function call (max)\n", unit, unit, unit)) {
826 for (uint32_t i = 0; i < gbl_args->suite.num_bench; i++) {
827 res = &gbl_args->result[i];
829 for (
int j = 0; j < res->num; j++) {
830 num = res->func[j].num ? res->func[j].num : 1;
831 if (test_common_write(
"%s,%" PRIu64
",%" PRIu64
",%" PRIu64
"\n",
833 bench_tm_to_u64(res, &res->func[j].min),
834 bench_tm_to_u64(res, &res->func[j].tot) / num,
835 bench_tm_to_u64(res, &res->func[j].max))) {
843 test_common_write_term();
848bench_tm_info_t test_suite[] = {
849 BENCH_INFO(pktio_capability, pktio_setup, pktio_clean, NULL, 0),
850 BENCH_INFO(pktio_lookup, pktio_setup, pktio_clean, NULL, 0),
851 BENCH_INFO(pktio_open_start_stop_close, NULL, NULL, NULL, 0),
852 BENCH_INFO(pktio_stats, pktio_setup, pktio_clean, NULL, 0),
853 BENCH_INFO(pktin_queue_stats, pktio_setup_direct_rx, pktio_clean_direct_rx, NULL, 0),
854 BENCH_INFO(pktin_event_queue_stats, pktio_setup_sched_rx, pktio_clean_sched_rx, NULL, 0),
855 BENCH_INFO(pktout_queue_stats, pktio_setup_direct_tx, pktio_clean, NULL, 0),
856 BENCH_INFO(pktout_event_queue_stats, pktio_setup_queue_tx, pktio_clean, NULL, 0),
857 BENCH_INFO(pktio_stats_reset, pktio_setup, pktio_clean, NULL, 0),
858 BENCH_INFO(cls_pmr_create, pktio_setup_cls, pktio_clean_sched_rx, check_cls_cond, 0)
862 "Result array is too small to hold all the results");
865static void usage(
void)
868 "ODP pktio API slow path micro benchmarks\n"
871 " -i, --interface <name> Ethernet interface name (default loop).\n"
872 " -m, --in_mode <arg> Packet input mode\n"
873 " 0: Direct mode: PKTIN_MODE_DIRECT (default)\n"
874 " 1: Scheduler mode with parallel queues:\n"
875 " PKTIN_MODE_SCHED + SCHED_SYNC_PARALLEL\n"
876 " -o, --out_mode <arg> Packet output mode\n"
877 " 0: Direct mode: PKTOUT_MODE_DIRECT (default)\n"
878 " 1: Queue mode: PKTOUT_MODE_QUEUE\n"
879 " -p, --pmr <num> Number of PMRs to create/destroy per round (default 1)\n"
880 " -q, --rx_queues <num> Number of packet input queues (default 1)\n"
881 " -t, --tx_queues <num> Number of packet output queues (default 1)\n"
882 " -r, --rounds <num> Run each test case 'num' times (default %u).\n"
883 " -s, --select <idx> Run only selected test case.\n"
884 " -T, --time <opt> Time measurement. 0: measure CPU cycles (default), 1: measure time\n"
885 " -h, --help Display help and exit.\n\n"
889static int parse_interface(appl_args_t *appl_args,
const char *optarg)
891 if (strlen(optarg) + 1 > MAX_NAME_LEN) {
892 ODPH_ERR(
"Unable to store interface name (MAX_NAME_LEN=%d)\n", MAX_NAME_LEN);
895 odph_strcpy(appl_args->opt.name, optarg, MAX_NAME_LEN);
900static int parse_args(
int argc,
char *argv[])
904 static const struct option longopts[] = {
905 {
"interface", required_argument, NULL,
'i'},
906 {
"in_mode", required_argument, NULL,
'm'},
907 {
"out_mode", required_argument, NULL,
'o'},
908 {
"pmr", required_argument, NULL,
'p'},
909 {
"rx_queues", required_argument, NULL,
'q'},
910 {
"tx_queues", required_argument, NULL,
't'},
911 {
"rounds", required_argument, NULL,
'r'},
912 {
"select", required_argument, NULL,
's'},
913 {
"time", required_argument, NULL,
'T'},
914 {
"help", no_argument, NULL,
'h'},
918 static const char *shortopts =
"i:m:o:p:q:r:s:t:T:h";
920 odph_strcpy(gbl_args->opt.name,
"loop", MAX_NAME_LEN);
921 gbl_args->opt.rounds = ROUNDS;
924 gbl_args->opt.num_input_queues = 1;
925 gbl_args->opt.num_output_queues = 1;
926 gbl_args->opt.num_pmr = 1;
929 opt = getopt_long(argc, argv, shortopts, longopts, NULL);
936 if (parse_interface(gbl_args, optarg))
954 gbl_args->opt.num_pmr = atoi(optarg);
957 gbl_args->opt.num_input_queues = atoi(optarg);
960 gbl_args->opt.rounds = atoi(optarg);
963 gbl_args->opt.case_idx = atoi(optarg);
966 gbl_args->opt.num_output_queues = atoi(optarg);
969 gbl_args->opt.time = atoi(optarg);
975 ODPH_ERR(
"Bad option. Use -h for help.\n");
983static int check_args(appl_args_t *appl_args)
991 if (gbl_args->opt.rounds < 1) {
992 ODPH_ERR(
"Invalid test repeat count: %u\n", gbl_args->opt.rounds);
996 if (gbl_args->opt.case_idx > ODPH_ARRAY_SIZE(test_suite)) {
997 ODPH_ERR(
"Invalid test case index: %u\n", gbl_args->opt.case_idx);
1001 pool = create_packet_pool();
1004 param.
in_mode = appl_args->opt.in_mode;
1005 param.
out_mode = appl_args->opt.out_mode;
1009 ODPH_ERR(
"Opening pktio failed\n");
1015 ODPH_ERR(
"Reading pktio capa failed: %d\n", ret);
1020 ODPH_ERR(
"Too many input queues: %u/%u\n", appl_args->opt.num_input_queues,
1026 ODPH_ERR(
"Too many output queues: %u/%u\n", appl_args->opt.num_output_queues,
1033 ODPH_ERR(
"Closing pktio failed: %d\n", ret);
1039 ODPH_ERR(
"Destroying pktio pool failed: %d\n", ret);
1043 if (check_cls_capa() < 0)
1050static void print_info(appl_args_t *appl_args)
1055 "odp_bench_pktio_sp options\n"
1056 "--------------------------\n");
1058 printf(
"CPU mask: %s\n", gbl_args->cpumask_str);
1059 printf(
"Interface: %s\n", gbl_args->opt.name);
1061 printf(
"Input mode: ");
1067 printf(
"Output mode: ");
1073 printf(
"Input queues: %u\n", gbl_args->opt.num_input_queues);
1074 printf(
"Output queues: %u\n", gbl_args->opt.num_output_queues);
1075 printf(
"PMRs: %u\n", gbl_args->opt.num_pmr);
1076 printf(
"Measurement unit: %s\n", gbl_args->opt.time ?
"nsec" :
"CPU cycles");
1077 printf(
"Test rounds: %d\n", gbl_args->opt.rounds);
1081int main(
int argc,
char *argv[])
1083 odph_helper_options_t helper_options;
1084 test_common_options_t common_options;
1085 odph_thread_t worker_thread;
1086 odph_thread_common_param_t thr_common;
1087 odph_thread_param_t thr_param;
1096 argc = odph_parse_options(argc, argv);
1097 if (odph_options(&helper_options)) {
1098 ODPH_ERR(
"Reading ODP helper options failed\n");
1102 argc = test_common_parse_options(argc, argv);
1103 if (test_common_options(&common_options)) {
1104 ODPH_ERR(
"Reading test options failed\n");
1109 init_param.
mem_model = helper_options.mem_model;
1113 ODPH_ERR(
"Global init failed\n");
1119 ODPH_ERR(
"Local init failed\n");
1125 ODPH_ERR(
"Schedule config failed: %d\n", ret);
1129 if (setup_sig_handler()) {
1130 ODPH_ERR(
"Signal handler setup failed\n");
1135 shm =
odp_shm_reserve(
"shm_args",
sizeof(appl_args_t), ODP_CACHE_LINE_SIZE, 0);
1137 ODPH_ERR(
"Shared mem reserve failed\n");
1142 if (gbl_args == NULL) {
1143 ODPH_ERR(
"Shared mem alloc failed\n");
1147 memset(gbl_args, 0,
sizeof(appl_args_t));
1150 ret = parse_args(argc, argv);
1154 if (check_args(gbl_args))
1157 bench_tm_suite_init(&gbl_args->suite);
1158 gbl_args->suite.bench = test_suite;
1159 gbl_args->suite.num_bench = ODPH_ARRAY_SIZE(test_suite);
1160 gbl_args->suite.rounds = gbl_args->opt.rounds;
1161 gbl_args->suite.bench_idx = gbl_args->opt.case_idx;
1162 gbl_args->suite.measure_time = !!gbl_args->opt.time;
1163 if (common_options.is_export)
1164 gbl_args->suite.result = gbl_args->result;
1167 ODPH_ERR(
"Unable to allocate worker thread\n");
1173 sizeof(gbl_args->cpumask_str));
1175 print_info(gbl_args);
1177 memset(&worker_thread, 0,
sizeof(odph_thread_t));
1185 odph_thread_common_param_init(&thr_common);
1186 thr_common.instance = instance;
1187 thr_common.cpumask = &cpumask;
1188 thr_common.share_param = 1;
1190 odph_thread_param_init(&thr_param);
1191 thr_param.start = bench_tm_run;
1192 thr_param.arg = &gbl_args->suite;
1195 odph_thread_create(&worker_thread, &thr_common, &thr_param, 1);
1197 odph_thread_join(&worker_thread, 1);
1199 ret = gbl_args->suite.retval;
1201 if (ret == 0 && common_options.is_export) {
1202 if (bench_pktio_sp_export(gbl_args)) {
1203 ODPH_ERR(
"Error: Export failed\n");
1210 ODPH_ERR(
"Shared mem free failed\n");
1215 ODPH_ERR(
"Local term failed\n");
1220 ODPH_ERR(
"Global term failed\n");
1225 return EXIT_FAILURE;
1227 return EXIT_SUCCESS;
void odp_atomic_store_u32(odp_atomic_u32_t *atom, uint32_t val)
Store value to atomic uint32 variable.
int odp_cos_destroy(odp_cos_t cos)
Discard a class-of-service along with all its associated resources.
odp_pmr_t odp_cls_pmr_create(const odp_pmr_param_t *terms, int num_terms, odp_cos_t src_cos, odp_cos_t dst_cos)
Create Packet Matching Rule (PMR)
int odp_cls_capability(odp_cls_capability_t *capability)
Query classification capabilities.
odp_cls_pmr_term_t
Packet Matching Rule terms.
#define ODP_PMR_INVALID
Invalid packet matching rule handle.
int odp_cls_pmr_destroy(odp_pmr_t pmr)
Function to destroy a packet match rule.
#define ODP_COS_INVALID
Invalid class of service handle.
odp_cos_t odp_cls_cos_create(const char *name, const odp_cls_cos_param_t *param)
Create a class-of-service.
void odp_cls_cos_param_init(odp_cls_cos_param_t *param)
Initialize class of service parameters.
void odp_cls_pmr_param_init(odp_pmr_param_t *param)
Initialize packet matching rule parameters.
@ ODP_PMR_TCP_DPORT
Destination TCP port (val_sz = 2)
@ ODP_PMR_TCP_SPORT
Source TCP port (val_sz = 2)
@ ODP_PMR_UDP_SPORT
Source UDP port (val_sz = 2)
@ ODP_PMR_UDP_DPORT
Destination UDP port (val_sz = 2)
#define ODP_UNUSED
Intentionally unused variables of functions.
void odp_cpumask_set(odp_cpumask_t *mask, int cpu)
Add CPU to mask.
int odp_cpumask_default_worker(odp_cpumask_t *mask, int num)
Default CPU mask for worker threads.
int odp_cpumask_first(const odp_cpumask_t *mask)
Find first set CPU in mask.
void odp_cpumask_zero(odp_cpumask_t *mask)
Clear entire CPU mask.
int32_t odp_cpumask_to_str(const odp_cpumask_t *mask, char *str, int32_t size)
Format a string from CPU mask.
#define ODP_CPUMASK_STR_SIZE
The maximum number of characters needed to record any CPU mask as a string (output of odp_cpumask_to_...
void odp_event_free(odp_event_t event)
Free event.
#define ODP_EVENT_INVALID
Invalid event.
void odp_init_param_init(odp_init_t *param)
Initialize the odp_init_t to default values for all fields.
#define ODP_STATIC_ASSERT(cond, msg)
Compile time assertion macro.
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.
int odp_pktin_queue_stats(odp_pktin_queue_t queue, odp_pktin_queue_stats_t *stats)
Get statistics for direct packet input queue.
void odp_pktin_queue_param_init(odp_pktin_queue_param_t *param)
Initialize packet input queue parameters.
void odp_pktio_param_init(odp_pktio_param_t *param)
Initialize pktio params.
int odp_pktio_close(odp_pktio_t pktio)
Close a packet IO interface.
odp_pktio_t odp_pktio_lookup(const char *name)
Return a packet IO handle for an already open device.
int odp_pktout_queue(odp_pktio_t pktio, odp_pktout_queue_t queues[], int num)
Direct packet output queues.
odp_pktout_mode_t
Packet output mode.
int odp_pktin_event_queue(odp_pktio_t pktio, odp_queue_t queues[], int num)
Event queues for packet input.
odp_pktio_t odp_pktio_open(const char *name, odp_pool_t pool, const odp_pktio_param_t *param)
Open a packet IO interface.
int odp_pktin_event_queue_stats(odp_pktio_t pktio, odp_queue_t queue, odp_pktin_queue_stats_t *stats)
Get statistics for packet input event queue.
int odp_pktio_start(odp_pktio_t pktio)
Start packet receive and transmit.
#define ODP_PKTIO_INVALID
Invalid packet IO handle.
int odp_pktin_queue(odp_pktio_t pktio, odp_pktin_queue_t queues[], int num)
Direct packet input queues.
void odp_pktout_queue_param_init(odp_pktout_queue_param_t *param)
Initialize packet output queue parameters.
int odp_pktout_event_queue(odp_pktio_t pktio, odp_queue_t queues[], int num)
Event queues for packet output.
int odp_pktio_stop(odp_pktio_t pktio)
Stop packet receive and transmit.
int odp_pktio_capability(odp_pktio_t pktio, odp_pktio_capability_t *capa)
Query packet IO interface capabilities.
int odp_pktout_event_queue_stats(odp_pktio_t pktio, odp_queue_t queue, odp_pktout_queue_stats_t *stats)
Get statistics for packet output event queue.
int odp_pktout_queue_stats(odp_pktout_queue_t queue, odp_pktout_queue_stats_t *stats)
Get statistics for direct packet output queue.
int odp_pktio_stats(odp_pktio_t pktio, odp_pktio_stats_t *stats)
Get statistics for pktio handle.
int odp_pktio_default_cos_set(odp_pktio_t pktio, odp_cos_t default_cos)
Set interface default class-of-service.
int odp_pktio_stats_reset(odp_pktio_t pktio)
Reset statistics for pktio handle.
odp_pktin_mode_t
Packet input mode.
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_PKTOUT_MODE_DIRECT
Direct packet output on the interface.
@ ODP_PKTOUT_MODE_QUEUE
Packet output through event queues.
@ ODP_PKTIN_MODE_DIRECT
Direct packet input from the interface.
@ ODP_PKTIN_MODE_SCHED
Packet input through scheduler and scheduled event queues.
odp_pool_t odp_pool_create(const char *name, const odp_pool_param_t *param)
Create a pool.
int odp_pool_capability(odp_pool_capability_t *capa)
Query pool capabilities.
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()
#define ODP_POOL_INVALID
Invalid 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.
odp_queue_t odp_queue_create(const char *name, const odp_queue_param_t *param)
Queue create.
int odp_queue_destroy(odp_queue_t queue)
Destroy ODP queue.
@ ODP_QUEUE_TYPE_SCHED
Scheduled queue.
int odp_schedule_config(const odp_schedule_config_t *config)
Global schedule configuration.
uint64_t odp_schedule_wait_time(uint64_t ns)
Schedule wait time.
int odp_schedule_capability(odp_schedule_capability_t *capa)
Query scheduler capabilities.
odp_event_t odp_schedule(odp_queue_t *from, uint64_t wait)
Schedule an event.
int odp_shm_free(odp_shm_t shm)
Free a contiguous block of shared memory.
void * odp_shm_addr(odp_shm_t shm)
Shared memory block address.
#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.
bool odp_bool_t
Boolean type.
void odp_sys_info_print(void)
Print system info.
@ ODP_THREAD_WORKER
Worker thread.
@ ODP_THREAD_CONTROL
Control thread.
#define ODP_TIME_MSEC_IN_NS
A millisecond in nanoseconds.
Dummy type for strong typing.
Classification capabilities This capability structure defines system level classification capability.
odp_cls_pmr_terms_t supported_terms
PMR terms supported by the classifier.
uint32_t max_cos
Maximum number of CoS supported.
Class of service parameters Used to communicate class of service creation options.
odp_queue_t queue
Mapping used when num_queue = 1, hashing is disabled in this case and application has to configure th...
Global initialization parameters.
odp_mem_model_t mem_model
Application memory model.
Packet input queue parameters.
uint32_t num_queues
Number of input queues to be created.
odp_pktin_hash_proto_t hash_proto
Protocol field selection for hashing.
odp_bool_t hash_enable
Enable flow hashing.
odp_bool_t classifier_enable
Enable classifier.
Packet IO input queue specific statistics counters.
uint32_t max_input_queues
Maximum number of input queues.
uint32_t max_output_queues
Maximum number of output queues.
odp_pktin_mode_t in_mode
Packet input mode.
odp_pktout_mode_t out_mode
Packet output mode.
Packet IO statistics counters.
Packet output queue parameters.
uint32_t num_queues
Number of output queues to be created.
Packet IO output queue specific statistics counters.
Packet Matching Rule parameter structure.
uint32_t val_sz
Size of the value to be matched.
struct odp_pmr_param_t::@4::@6 match
Parameters for single-valued matches.
const void * value
Points to the value to be matched.
const void * mask
Mask of the bits to be matched.
odp_cls_pmr_term_t term
Packet Matching Rule term.
uint32_t max_num
Maximum number of buffers of any size.
struct odp_pool_capability_t::@134 pkt
Packet pool capabilities
uint32_t max_len
Maximum packet data length in bytes.
uint32_t num
Number of buffers in the pool.
struct odp_pool_param_t::@139 pkt
Parameters for packet pools.
odp_pool_type_t type
Pool type.
uint32_t len
Minimum length of 'num' packets.
odp_queue_type_t type
Queue type.
uint32_t max_queues
Maximum number of scheduled (ODP_BLOCKING) queues of the default size.
uint64_t udp_dport
Destination UDP port, implies IPPROTO=17.
uint64_t tcp_dport
Destination TCP port implies IPPROTO=6.
struct odp_cls_pmr_terms_t::@3 bit
Packet Matching Rule term fields.
uint64_t udp_sport
Source UDP Port.
uint64_t tcp_sport
Source TCP port.
struct odp_pktin_hash_proto_t::@107 proto
Protocol header fields for hashing.
uint32_t ipv4_udp
IPv4 addresses and UDP port numbers.