23#include <odp/helper/odph_api.h>
38#include "em_libconfig.h"
51#define OPTPARSE_IMPLEMENTATION
52#include "misc/optparse.h"
54static atomic_bool stop_top;
55static atomic_bool in_top_thr;
56static odph_thread_t cli_top_thread;
62static em_cli_shm_t *cli_shm;
64static void sleep_ms(uint64_t ms);
66__attribute__((format(printf, 2, 3)))
75 int r = odph_cli_log_va(fmt, args);
82static int cli_vlog(
em_log_level_t level,
const char *fmt, va_list args)
86 return odph_cli_log_va(fmt, args);
89static void print_em_info_help(
void)
91 const char *usage =
"Usage: em_info_print [OPTION]\n"
92 "Print EM related information.\n"
95 " -a, --all\tPrint all EM info\n"
96 " -p, --cpu-arch\tPrint cpu architecture\n"
97 " -c, --conf\tPrint default and runtime configurations\n"
98 " -h, --help\tDisplay this help\n";
102static void print_em_info_all(
void)
104 core_log_fn_set(cli_log);
105 core_vlog_fn_set(cli_vlog);
107 core_log_fn_set(NULL);
108 core_vlog_fn_set(NULL);
111static void print_em_info_cpu_arch(
void)
113 core_log_fn_set(cli_log);
114 core_vlog_fn_set(cli_vlog);
115 print_cpu_arch_info();
116 core_log_fn_set(NULL);
117 core_vlog_fn_set(NULL);
120static void print_em_info_conf(
void)
122 core_log_fn_set(cli_log);
123 core_vlog_fn_set(cli_vlog);
124 em_libconfig_print(&
em_shm->libconfig);
125 core_log_fn_set(NULL);
126 core_vlog_fn_set(NULL);
129static void cmd_em_info_print(
int argc,
char *argv[])
132 const int max_args = 1;
138 }
else if (argc > max_args) {
139 odph_cli_log(
"Error: extra parameter given to command!\n");
151 char *argv_new[argc];
152 char cmd[MAX_CMD_LEN] =
"em_info_print";
155 for (
int i = 1; i < argc - 1; i++)
156 argv_new[i] = argv[i - 1];
157 argv_new[argc - 1] = NULL;
161 {
"all",
'a', OPTPARSE_NONE},
162 {
"cpu-arch",
'p', OPTPARSE_NONE},
163 {
"conf",
'c', OPTPARSE_NONE},
164 {
"help",
'h', OPTPARSE_NONE},
169 optparse_init(&options, argv_new);
182 print_em_info_cpu_arch();
185 print_em_info_conf();
188 print_em_info_help();
191 odph_cli_log(
"Error: %s\n", options.errmsg);
194 odph_cli_log(
"Unknown Error\n");
200 char *arg = optparse_arg(&options);
203 odph_cli_log(
"\033[1;31mError\033[0m: unexpected argument '%s'\n", arg);
204 print_em_info_help();
208static void print_em_pool_all(
void)
210 core_log_fn_set(cli_log);
211 core_vlog_fn_set(cli_vlog);
213 core_log_fn_set(NULL);
214 core_vlog_fn_set(NULL);
217static void print_em_pool(em_pool_t pool,
const char *pool_name)
221 odph_cli_log(
"Error: can't find EM pool %s.\n", pool_name);
223 odph_cli_log(
"Error: can't find EM pool %" PRI_POOL "\n", pool);
227 core_log_fn_set(cli_log);
228 core_vlog_fn_set(cli_vlog);
229 pool_info_print_hdr(1);
230 pool_info_print(pool);
231 core_log_fn_set(NULL);
232 core_vlog_fn_set(NULL);
235static void print_em_pool_help(
void)
237 const char *usage =
"Usage: em_pool_print [OPTION]\n"
238 "Print EM pool related information\n"
241 " -a, --all\tPrint info of all pools\n"
242 " -i, --id <pool id>\tPrint info of <pool id>\n"
243 " -n, --name <pool name>\tPrint info of <pool name>\n"
244 " -h, --help\tDisplay this help\n";
249static void cmd_em_pool_print(
int argc,
char *argv[])
252 const int max_args = 2;
258 }
else if (argc > max_args) {
259 odph_cli_log(
"Error: extra parameter given to command!\n");
271 char *argv_new[argc];
272 char cmd[MAX_CMD_LEN] =
"em_pool_print";
275 for (
int i = 1; i < argc - 1; i++)
276 argv_new[i] = argv[i - 1];
277 argv_new[argc - 1] = NULL;
282 {
"all",
'a', OPTPARSE_NONE},
283 {
"id",
'i', OPTPARSE_REQUIRED},
284 {
"name",
'n', OPTPARSE_REQUIRED},
285 {
"help",
'h', OPTPARSE_NONE},
290 optparse_init(&options, argv_new);
302 if (!options.optarg) {
303 odph_cli_log(
"Error: pool ID is required!\n");
306 pool = (em_pool_t)(uintptr_t)(int)strtol(options.optarg, NULL, 0);
307 print_em_pool(pool, NULL);
310 if (!options.optarg) {
311 odph_cli_log(
"Error: pool name is required!\n");
314 pool = pool_find(options.optarg);
315 print_em_pool(pool, options.optarg);
318 print_em_pool_help();
321 odph_cli_log(
"Error: %s\n", options.errmsg);
324 odph_cli_log(
"Unknown Error\n");
330 char *arg = optparse_arg(&options);
333 odph_cli_log(
"\033[1;31mError\033[0m: unexpected argument '%s'\n", arg);
334 print_em_pool_help();
338static void print_em_pool_stats_opt_help(
void)
340 const char *usage =
"Usage: em_pool_stats_opt [OPTION]\n"
341 "Print EM pool statistic counter options\n"
344 " -a, --all\tPrint statistic options of all pools\n"
345 " -i, --id <pool id>\tPrint statistic options of <pool id>\n"
346 " -n, --name <pool name>\tPrint statistic options of <pool name>\n"
347 " -h, --help\tDisplay this help\n";
352static void print_em_pool_stats_opt_all(
void)
354 core_log_fn_set(cli_log);
355 core_vlog_fn_set(cli_vlog);
357 core_log_fn_set(NULL);
358 core_vlog_fn_set(NULL);
361static void print_em_pool_stats_opt(em_pool_t pool,
const char *pool_name)
365 odph_cli_log(
"Error: can't find EM pool %s.\n", pool_name);
367 odph_cli_log(
"Error: can't find EM pool %" PRI_POOL "\n", pool);
371 core_log_fn_set(cli_log);
372 core_vlog_fn_set(cli_vlog);
374 core_log_fn_set(NULL);
375 core_vlog_fn_set(NULL);
378static void cmd_em_pool_stats_opt(
int argc,
char *argv[])
381 const int max_args = 2;
385 print_em_pool_stats_opt_all();
387 }
else if (argc > max_args) {
388 odph_cli_log(
"Error: extra parameter given to command!\n");
400 char *argv_new[argc];
401 char cmd[MAX_CMD_LEN] =
"em_pool_stats_opt";
404 for (
int i = 1; i < argc - 1; i++)
405 argv_new[i] = argv[i - 1];
406 argv_new[argc - 1] = NULL;
411 {
"all",
'a', OPTPARSE_NONE},
412 {
"id",
'i', OPTPARSE_REQUIRED},
413 {
"name",
'n', OPTPARSE_REQUIRED},
414 {
"help",
'h', OPTPARSE_NONE},
419 optparse_init(&options, argv_new);
428 print_em_pool_stats_opt_all();
431 if (!options.optarg) {
432 odph_cli_log(
"Error: pool ID is required!\n");
435 pool = (em_pool_t)(uintptr_t)(int)strtol(options.optarg, NULL, 0);
436 print_em_pool_stats_opt(pool, NULL);
439 if (!options.optarg) {
440 odph_cli_log(
"Error: pool name is required!\n");
443 pool = pool_find(options.optarg);
444 print_em_pool_stats_opt(pool, options.optarg);
447 print_em_pool_stats_opt_help();
450 odph_cli_log(
"Error: %s\n", options.errmsg);
453 odph_cli_log(
"Unknown Error\n");
459 char *arg = optparse_arg(&options);
462 odph_cli_log(
"\033[1;31mError\033[0m: unexpected argument '%s'\n", arg);
463 print_em_pool_stats_opt_help();
472 odph_cli_log(
"Error: can't find EM pool %s.\n", pool_name);
474 odph_cli_log(
"Error: can't find EM pool %" PRI_POOL "\n", pool);
478 core_log_fn_set(cli_log);
479 core_vlog_fn_set(cli_vlog);
482 pool_stats_selected_print(pool, opt);
484 pool_stats_print(pool);
486 core_log_fn_set(NULL);
487 core_vlog_fn_set(NULL);
490static int str_to_long(
const char *str,
long *num,
int base)
495 *num = strtol(str, &endptr, base);
497 odph_cli_log(
"strtol failed\n");
502 odph_cli_log(
"No digit is found in given str: %s\n", str);
507 odph_cli_log(
"Extra characters not used in str: %s\n", endptr);
518 if (str_to_long(str_opt, &stats_opt, 16))
521 if (stats_opt & 0x80) {
522 odph_cli_log(
"available is selected\n");
526 if (stats_opt & 0x40) {
527 odph_cli_log(
"alloc_ops is selected\n");
531 if (stats_opt & 0x20) {
532 odph_cli_log(
"alloc_fails is selected\n");
536 if (stats_opt & 0x10) {
537 odph_cli_log(
"free_ops is selected\n");
541 if (stats_opt & 0x08) {
542 odph_cli_log(
"total_ops is selected\n");
546 if (stats_opt & 0x04) {
547 odph_cli_log(
"cache_available is selected\n");
551 if (stats_opt & 0x02) {
552 odph_cli_log(
"cache_alloc_ops is selected\n");
556 if (stats_opt & 0x01) {
557 odph_cli_log(
"cache_free_ops is selected\n");
566static int str_to_subpool_id(
const char *str,
int *subpool_id)
570 if (str_to_long(str, &
id, 10))
574 odph_cli_log(
"Invalid subpool id: %ld (valid range: 0...%d)\n",
579 *subpool_id = (int)
id;
584static int subpools_str_to_id(
char *str,
int *num_subpools,
int *subpools)
589 const char *delim =
"[,]";
592 if (!strstr(str,
"[")) {
595 if (str_to_subpool_id(str, &subpools[0]))
600 token = strtok_r(str, delim, &saveptr);
602 odph_cli_log(
"Invalid option argument: %s\n", str);
605 if (str_to_subpool_id(token, &subpools[0]))
609 token = strtok_r(NULL, delim, &saveptr);
613 if (str_to_subpool_id(token, &subpools[i]))
617 if (token && strtok_r(NULL, delim, &saveptr)) {
618 odph_cli_log(
"Too many subpools, maximum number is: %d\n",
EM_MAX_SUBPOOLS);
627print_em_subpools_stats(em_pool_t pool,
const int subpools[],
int num_subpools,
630 core_log_fn_set(cli_log);
631 core_vlog_fn_set(cli_vlog);
634 subpools_stats_selected_print(pool, subpools, num_subpools, opt);
636 subpools_stats_print(pool, subpools, num_subpools);
638 core_log_fn_set(NULL);
639 core_vlog_fn_set(NULL);
642static void print_subpools_stats(
char *arg_subpools)
649 const char *str_stats_opt;
650 const char *pool_str;
652 const char *delim =
":";
655 pool_str = strtok_r(arg_subpools, delim, &saveptr);
656 if (pool_str == NULL) {
657 odph_cli_log(
"Invalid optarg: %s\n", arg_subpools);
661 if (str_to_long(pool_str, &pool_id, 16))
666 odph_cli_log(
"Invalid pool id: %ld\n", pool_id);
669 pool = (em_pool_t)(uintptr_t)pool_id;
671 str_subpools = strtok_r(NULL, delim, &saveptr);
672 if (str_subpools == NULL) {
673 odph_cli_log(
"Invalid optarg: %s (subpool IDs are missing)\n", arg_subpools);
677 if (subpools_str_to_id(str_subpools, &num_subpools, subpools))
680 str_stats_opt = strtok_r(NULL, delim, &saveptr);
682 if (str_stats_opt == NULL) {
683 print_em_subpools_stats(pool, subpools, num_subpools, NULL);
685 str_to_opt(str_stats_opt, &opt);
686 print_em_subpools_stats(pool, subpools, num_subpools, &opt);
690static void print_em_pool_stats_help(
void)
692 const char *usage =
"Usage: em_pool_stats [OPTION]\n"
695 " Print EM pool statistics\n"
698 " -i, --id <pool id [:stats opt]>\tPrint statistics of <pool id>\n"
699 " -n, --name <pool name [:stats opt]>\tPrint statistics of <pool name>\n"
700 " -s, --subpools <pool:[subpool ids] [:stats opt]>\tPrint statistics of subpools\n"
701 " -h, --help\tDisplay this help\n"
703 "subpool ids are separated with ',', no space should be used\n"
705 "'stats opt' is optional, when not given, it prints statistics from\n"
706 "em_pool_stats(), namely all statistic counters. When it is given,\n"
707 "this command prints selected counters from em_pool_stats_selected().\n"
708 "stats opt here uses one byte to select the counters to be read. One\n"
709 "bit in stats opt selects one counter. MSB represents 'available' and\n"
710 "LSB represents 'cache_free_ops'. For example, stats_opt=0x88 selects\n"
711 "the 'available' and 'total_ops' statistic counters.\n"
714 " em_pool_stats -i 0x1\n"
715 " em_pool_stats -i 0x1:0x88\n"
716 " em_pool_stats -n default:0x88\n"
717 " em_pool_stats -s 0x1:[0,1,3]\n";
722static void print_pool_stats(
char *optarg_str,
bool is_id)
728 const char *pool_str;
729 const char *delim =
":";
733 pool_str = strtok_r(optarg_str, delim, &saveptr);
734 if (pool_str == NULL) {
735 odph_cli_log(
"Invalid optarg_str: %s\n", optarg_str);
740 if (str_to_long(pool_str, &pool_id, 16))
745 odph_cli_log(
"Invalid pool id: %ld\n", pool_id);
748 pool = (em_pool_t)(uintptr_t)pool_id;
750 pool = pool_find(pool_str);
754 str_opt = strtok_r(NULL, delim, &saveptr);
755 if (str_opt == NULL) {
757 print_em_pool_stats(pool, is_id ? NULL : pool_str, NULL);
759 str_to_opt(str_opt, &opt);
760 print_em_pool_stats(pool, is_id ? NULL : pool_str, &opt);
764static void cmd_em_pool_stats(
int argc,
char *argv[])
767 const int max_args = 2;
770 odph_cli_log(
"Please specify pool or subpool ids!\n");
771 print_em_pool_stats_help();
773 }
else if (argc > max_args) {
774 odph_cli_log(
"Error: extra parameter given to command!\n");
775 print_em_pool_stats_help();
787 char *argv_new[argc];
788 char cmd[MAX_CMD_LEN] =
"em_pool_stats";
791 for (
int i = 1; i < argc - 1; i++)
792 argv_new[i] = argv[i - 1];
793 argv_new[argc - 1] = NULL;
797 {
"id",
'i', OPTPARSE_REQUIRED},
798 {
"name",
'n', OPTPARSE_REQUIRED},
799 {
"subpools",
's', OPTPARSE_REQUIRED},
800 {
"help",
'h', OPTPARSE_NONE},
805 optparse_init(&options, argv_new);
814 if (!options.optarg) {
815 odph_cli_log(
"Error: pool ID is required!\n");
818 print_pool_stats(options.optarg,
true);
821 if (!options.optarg) {
822 odph_cli_log(
"Error: pool name is required!\n");
825 print_pool_stats(options.optarg,
false);
828 if (!options.optarg) {
829 odph_cli_log(
"Error: subpool IDs are required!\n");
832 print_subpools_stats(options.optarg);
835 print_em_pool_stats_help();
838 odph_cli_log(
"Error: %s\n", options.errmsg);
841 odph_cli_log(
"Unknown Error\n");
847 char *arg = optparse_arg(&options);
850 odph_cli_log(
"\033[1;31mError\033[0m: unexpected argument '%s'\n", arg);
851 print_em_pool_stats_help();
855static void print_em_queue_help(
void)
857 const char *usage =
"Usage: em_queue_print [OPTION]\n"
860 " Print EM queue information\n"
863 " -c, --capa\tPrint queue capabilities\n"
864 " -a, --all\tPrint info about all queues\n"
865 " -h, --help\tDisplay this help\n"
868 " em_queue_print -c\n";
872static void print_em_queue_capa(
void)
874 core_log_fn_set(cli_log);
875 core_vlog_fn_set(cli_vlog);
877 core_log_fn_set(NULL);
878 core_vlog_fn_set(NULL);
881static void print_em_queue_all(
void)
883 core_log_fn_set(cli_log);
884 core_vlog_fn_set(cli_vlog);
886 core_log_fn_set(NULL);
887 core_vlog_fn_set(NULL);
890static void cmd_em_queue_print(
int argc,
char *argv[])
893 const int max_args = 1;
897 print_em_queue_all();
899 }
else if (argc > max_args) {
900 odph_cli_log(
"Error: extra parameter given to command!\n");
901 print_em_queue_help();
913 char *argv_new[argc];
914 char cmd[MAX_CMD_LEN] =
"em_queue_print";
917 for (
int i = 1; i < argc - 1; i++)
918 argv_new[i] = argv[i - 1];
919 argv_new[argc - 1] = NULL;
923 {
"capa",
'c', OPTPARSE_NONE},
924 {
"all",
'a', OPTPARSE_NONE},
925 {
"help",
'h', OPTPARSE_NONE},
930 optparse_init(&options, argv_new);
939 print_em_queue_capa();
942 print_em_queue_all();
945 print_em_queue_help();
948 odph_cli_log(
"Error: %s\n", options.errmsg);
951 odph_cli_log(
"Unknown Error\n");
957 char *arg = optparse_arg(&options);
960 odph_cli_log(
"\033[1;31mError\033[0m: unexpected argument '%s'\n", arg);
961 print_em_queue_help();
965static void print_em_qgrp_help(
void)
967 const char *usage =
"Usage: em_qgrp_print [OPTION]\n"
970 " Print EM queue group information\n"
973 " -a, --all(default)\tPrint info about all EM queue groups\n"
974 " -i, --id <qgrp id>\tPrint the queue info of <qgrp id>\n"
975 " -n, --name <qgrp name> \tPrint the queue info of <qgrp name>\n"
976 " -h, --help\tDisplay this help\n"
979 " em_qgrp_print -i 0x80\n"
980 " em_qgrp_print --name default\n";
984static void print_em_qgrp_all(
void)
986 core_log_fn_set(cli_log);
987 core_vlog_fn_set(cli_vlog);
988 queue_group_info_print_all();
989 core_log_fn_set(NULL);
990 core_vlog_fn_set(NULL);
993static void print_em_qgrp_queues(
const em_queue_group_t qgrp,
const char *name)
997 odph_cli_log(
"Error: can't find queue group %s!\n", name);
999 odph_cli_log(
"Error: can't find queue group %" PRI_QGRP "!\n", qgrp);
1003 core_log_fn_set(cli_log);
1004 core_vlog_fn_set(cli_vlog);
1005 queue_group_queues_print(qgrp);
1006 core_log_fn_set(NULL);
1007 core_vlog_fn_set(NULL);
1010static void cmd_em_qgrp_print(
int argc,
char *argv[])
1013 const int max_args = 2;
1017 print_em_qgrp_all();
1019 }
else if (argc > max_args) {
1020 odph_cli_log(
"Error: extra parameter given to command!\n");
1021 print_em_qgrp_help();
1033 char *argv_new[argc];
1034 char cmd[MAX_CMD_LEN] =
"em_qgrp_print";
1037 for (
int i = 1; i < argc - 1; i++)
1038 argv_new[i] = argv[i - 1];
1039 argv_new[argc - 1] = NULL;
1041 em_queue_group_t qgrp;
1044 {
"all",
'a', OPTPARSE_NONE},
1045 {
"id",
'i', OPTPARSE_REQUIRED},
1046 {
"name",
'n', OPTPARSE_REQUIRED},
1047 {
"help",
'h', OPTPARSE_NONE},
1052 optparse_init(&options, argv_new);
1053 options.permute = 0;
1062 print_em_qgrp_all();
1065 if (!options.optarg) {
1066 odph_cli_log(
"Error: queue group ID is required!\n");
1069 qgrp = (em_queue_group_t)(uintptr_t)(int)strtol(options.optarg, NULL, 0);
1070 print_em_qgrp_queues(qgrp, NULL);
1073 if (!options.optarg) {
1074 odph_cli_log(
"Error: queue group name is required!\n");
1078 print_em_qgrp_queues(qgrp, options.optarg);
1081 print_em_qgrp_help();
1084 odph_cli_log(
"Error: %s\n", options.errmsg);
1087 odph_cli_log(
"Unknown Error\n");
1092 char *arg = optparse_arg(&options);
1095 odph_cli_log(
"\033[1;31mError\033[0m: unexpected argument '%s'\n", arg);
1096 print_em_qgrp_help();
1100static void print_em_core_help(
void)
1102 const char *usage =
"Usage: em_core_print\n"
1105 " Print EM core info\n";
1107 odph_cli_log(usage);
1110static void cmd_em_core_print(
int argc,
char *argv[])
1115 core_log_fn_set(cli_log);
1116 core_vlog_fn_set(cli_vlog);
1117 print_core_map_info();
1118 core_log_fn_set(NULL);
1119 core_vlog_fn_set(NULL);
1121 odph_cli_log(
"Error: extra parameter given to command!\n");
1122 print_em_core_help();
1126static void print_em_cfgfile_opts_help(
void)
1128 const char *usage =
"Usage: em_cfgfile_opts\n"
1131 " Print EM config file options\n";
1133 odph_cli_log(usage);
1136static void cmd_em_cfgfile_opts(
int argc,
char *argv[])
1141 core_log_fn_set(cli_log);
1142 core_vlog_fn_set(cli_vlog);
1143 cfgfile_opts_print();
1144 core_log_fn_set(NULL);
1145 core_vlog_fn_set(NULL);
1147 odph_cli_log(
"Error: extra parameter given to command!\n");
1148 print_em_cfgfile_opts_help();
1152static void print_em_conf_opts_help(
void)
1154 const char *usage =
"Usage: em_conf_opts\n"
1157 " Print EM runtime configuration options given to em_init()\n";
1159 odph_cli_log(usage);
1162static void cmd_em_conf_opts(
int argc,
char *argv[])
1167 core_log_fn_set(cli_log);
1168 core_vlog_fn_set(cli_vlog);
1170 core_log_fn_set(NULL);
1171 core_vlog_fn_set(NULL);
1173 odph_cli_log(
"Error: extra parameter given to command!\n");
1174 print_em_conf_opts_help();
1178static void print_em_eo_help(
void)
1180 const char *usage =
"Usage: em_eo_print [OPTION]\n"
1183 " Print EO information\n"
1186 " -a, --all\tPrint all EO info\n"
1187 " -i, --id <eo id>\tPrint info about all queues of <eo id>\n"
1188 " -n, --name <eo name>\tPrint info about all queues of <eo name>\n"
1189 " -h, --help\tDisplay this help\n"
1192 " em_eo_print --id 0x1\n"
1193 " em_eo_print -n 'Control EO'\n";
1195 odph_cli_log(usage);
1198static void print_em_eo_all(
void)
1200 core_log_fn_set(cli_log);
1201 core_vlog_fn_set(cli_vlog);
1202 eo_info_print_all();
1203 core_log_fn_set(NULL);
1204 core_vlog_fn_set(NULL);
1207static void print_em_eo(
const em_eo_t eo,
const char *name)
1211 odph_cli_log(
"Error: can't find EO %s\n", name);
1213 odph_cli_log(
"Error: can't find EO %" PRI_EO "\n", eo);
1217 core_log_fn_set(cli_log);
1218 core_vlog_fn_set(cli_vlog);
1219 eo_queue_info_print(eo);
1220 core_log_fn_set(NULL);
1221 core_vlog_fn_set(NULL);
1224static void cmd_em_eo_print(
int argc,
char *argv[])
1227 const int max_args = 2;
1233 }
else if (argc > max_args) {
1234 odph_cli_log(
"Error: extra parameter given to command!\n");
1247 char *argv_new[argc];
1248 char cmd[MAX_CMD_LEN] =
"em_eo_print";
1251 for (
int i = 1; i < argc - 1; i++)
1252 argv_new[i] = argv[i - 1];
1253 argv_new[argc - 1] = NULL;
1258 {
"all",
'a', OPTPARSE_NONE},
1259 {
"id",
'i', OPTPARSE_REQUIRED},
1260 {
"name",
'n', OPTPARSE_REQUIRED},
1261 {
"help",
'h', OPTPARSE_NONE},
1266 optparse_init(&options, argv_new);
1267 options.permute = 0;
1279 if (!options.optarg) {
1280 odph_cli_log(
"Error: EO ID is required!\n");
1283 eo = (em_eo_t)(uintptr_t)(int)strtol(options.optarg, NULL, 0);
1284 print_em_eo(eo, NULL);
1287 if (!options.optarg) {
1288 odph_cli_log(
"Error: EO name is required!\n");
1292 print_em_eo(eo, options.optarg);
1298 odph_cli_log(
"Error: %s\n", options.errmsg);
1301 odph_cli_log(
"Unknown Error\n");
1307 char *arg = optparse_arg(&options);
1310 odph_cli_log(
"\033[1;31mError\033[0m: unexpected argument '%s'\n", arg);
1315static void print_em_agrp_help(
void)
1317 const char *usage =
"Usage: em_agrp_print [OPTION]\n"
1320 " Print info about atomic groups\n"
1323 " -a, --all\tPrint info about all atomic groups\n"
1324 " -i, --id <ag id>\tPrint info about all queues of <ag id>\n"
1325 " -n, --name <ag name>\tPrint info about all queues of <ag name>\n"
1326 " -h, --help\tDisplay this help\n"
1330 " em_agrp_print -n AG-A1\n";
1332 odph_cli_log(usage);
1335static void print_em_agrp_all(
void)
1337 core_log_fn_set(cli_log);
1338 core_vlog_fn_set(cli_vlog);
1339 print_atomic_group_info();
1340 core_log_fn_set(NULL);
1341 core_vlog_fn_set(NULL);
1344static void print_em_agrp(em_atomic_group_t ag,
const char *ag_name)
1348 odph_cli_log(
"Error: can't find atomic group %s\n", ag_name);
1350 odph_cli_log(
"Error: can't find atomic group %" PRI_AGRP "\n", ag);
1354 core_log_fn_set(cli_log);
1355 core_vlog_fn_set(cli_vlog);
1356 print_atomic_group_queues(ag);
1357 core_log_fn_set(NULL);
1358 core_vlog_fn_set(NULL);
1361static void cmd_em_agrp_print(
int argc,
char *argv[])
1364 const int max_args = 2;
1368 print_em_agrp_all();
1370 }
else if (argc > max_args) {
1371 odph_cli_log(
"Error: extra parameter given to command!\n");
1372 print_em_agrp_help();
1384 char *argv_new[argc];
1385 char cmd[MAX_CMD_LEN] =
"em_agrp_print";
1388 for (
int i = 1; i < argc - 1; i++)
1389 argv_new[i] = argv[i - 1];
1390 argv_new[argc - 1] = NULL;
1392 em_atomic_group_t ag;
1395 {
"all",
'a', OPTPARSE_NONE},
1396 {
"id",
'i', OPTPARSE_REQUIRED},
1397 {
"name",
'n', OPTPARSE_REQUIRED},
1398 {
"help",
'h', OPTPARSE_NONE},
1403 optparse_init(&options, argv_new);
1404 options.permute = 0;
1414 print_em_agrp_all();
1417 if (!options.optarg) {
1418 odph_cli_log(
"Error: atomic group ID is required!\n");
1421 ag = (em_atomic_group_t)(uintptr_t)(int)strtol(options.optarg, NULL, 0);
1422 print_em_agrp(ag, NULL);
1425 if (!options.optarg) {
1426 odph_cli_log(
"Error: atomic group name is required!\n");
1430 print_em_agrp(ag, options.optarg);
1433 print_em_agrp_help();
1436 odph_cli_log(
"Error: %s\n", options.errmsg);
1439 odph_cli_log(
"Unknown Error\n");
1445 char *arg = optparse_arg(&options);
1448 odph_cli_log(
"\033[1;31mError\033[0m: unexpected argument '%s'\n", arg);
1449 print_em_agrp_help();
1453static void print_em_egrp_help(
void)
1455 const char *usage =
"Usage: em_egrp_print\n"
1458 " Print info about event groups\n";
1460 odph_cli_log(usage);
1463static void cmd_em_egrp_print(
int argc,
char *argv[])
1468 core_log_fn_set(cli_log);
1469 core_vlog_fn_set(cli_vlog);
1470 event_group_info_print();
1471 core_log_fn_set(NULL);
1472 core_vlog_fn_set(NULL);
1474 odph_cli_log(
"Error: extra parameter given to command!\n");
1475 print_em_egrp_help();
1479static inline void erase_line(uint32_t line)
1481 odph_cli_log(
"\033[%u;1H", line);
1482 odph_cli_log(
"\033[2K");
1486read_core_data(
const int core, odp_time_t *to_idle , odp_time_t *to_active ,
1487 uint64_t *active_sum ,
bool *while_idle )
1491 em_cli_top_t *top = &cli_shm->top;
1494 seq1 = odp_atomic_load_acq_u32(&top->core_times[core].seq);
1499 *to_idle = top->core_times[core].to_idle;
1500 *to_active = top->core_times[core].to_active;
1501 *active_sum = top->core_times[core].active_sum;
1502 *while_idle = top->core_times[core].while_idle;
1505 seq2 = odp_atomic_load_acq_u32(&top->core_times[core].seq);
1506 }
while (seq1 != seq2);
1510calculate_top_percentage(uint64_t active_sum, odp_time_t to_active, odp_time_t t_print,
1511 uint32_t round,
int core)
1514 uint64_t interval_ns;
1515 uint64_t active_interval;
1516 em_cli_top_t *top = &cli_shm->top;
1517 uint64_t active_current = active_sum;
1518 uint64_t store_active_sum = active_sum;
1519 uint64_t prev_active_sum = top->core_times[core].prev_active_sum;
1521 if (odp_time_cmp(to_active, ODP_TIME_NULL) > 0) {
1522 store_active_sum += odp_time_diff_ns(t_print, to_active);
1524 if (odp_time_cmp(to_active, top->t_prev) > 0)
1525 active_current += odp_time_diff_ns(t_print, to_active);
1530 top->core_times[core].prev_active_sum = store_active_sum;
1538 active_interval = active_current;
1539 interval_ns = odp_time_diff_ns(t_print, top->t0);
1542 interval_ns = odp_time_diff_ns(t_print, top->t_prev);
1544 if (active_current > prev_active_sum)
1545 active_interval = active_current - prev_active_sum;
1566 active_interval = active_current - active_sum;
1570 per = (double)active_interval / (
double)interval_ns;
1575static int top_thread_func(
void *arg)
1578 bool while_idle =
false;
1579 odp_time_t to_idle = ODP_TIME_NULL;
1580 odp_time_t to_active = ODP_TIME_NULL;
1581 uint64_t active_sum = 0;
1583 int num_line_prev = 0;
1584 em_cli_top_t *top = &cli_shm->top;
1585 uint32_t sleep_time = (uint32_t)(uintptr_t)arg;
1590 odph_cli_log(
"\033[2J\033[1;1H");
1593 odph_cli_log(
"Top started. Type 'stop' or 's' and Enter key to end it\n");
1594 odph_cli_log(
"Update every %.3fs (%u ms)\n\n", (
float)sleep_time / 1000, sleep_time);
1603 odph_cli_log(
"Number of EM cores: %u Round: %u\n",
em_core_count(), round++);
1606 odph_cli_log(
"EM-core %%CPU\n");
1610 uint32_t core_cnt = 0;
1611 odp_time_t t_print = ODP_TIME_NULL;
1616 read_core_data(core, &to_idle , &to_active ,
1617 &active_sum , &while_idle );
1618 t_print = odp_time_global();
1620 if (!while_idle && !odp_time_cmp(to_idle, ODP_TIME_NULL) &&
1621 !odp_time_cmp(to_active, ODP_TIME_NULL)) {
1623 top->core_times[core].prev_active_sum =
1624 odp_time_diff_ns(t_print, top->t0);
1626 per = calculate_top_percentage(active_sum,
1631 while (core - num_line > 0) {
1632 erase_line(num_line + 6);
1633 odph_cli_log(
"- -\n");
1638 erase_line(core + 6);
1641 odph_cli_log(
"%-11d%-.2f\n", core, per * 100);
1650 if (num_line_prev > num_line) {
1651 for (
int i = 0; i < num_line_prev - num_line; i++)
1652 erase_line(num_line + 6 + i);
1658 erase_line(num_line_prev + 6 + 1);
1659 erase_line(num_line_prev + 6 + 2);
1663 odph_cli_log(
"\033[%u;1H", num_line + 6 + 1);
1664 odph_cli_log(
"Total: %-.2f(max %u)\n", per_sum * 100, core_cnt * 100);
1666 odph_cli_log(
"\033[%u;1H", num_line + 6 + 2);
1668 odph_cli_log(
"Average: %-.2f\n", per_sum * 100 / core_cnt);
1670 odph_cli_log(
"Average: n/a\n");
1673 num_line_prev = num_line;
1675 top->t_prev = t_print;
1677 sleep_ms(sleep_time);
1683static void to_idle_func(uint64_t delay_ns)
1688 em_cli_top_t *top = &cli_shm->top;
1691 odp_atomic_inc_u32(&top->core_times[core].seq);
1694 odp_time_t t_to_idle = odp_time_global();
1695 odp_time_t to_active = top->core_times[core].to_active;
1697 if (odp_time_cmp(to_active, ODP_TIME_NULL) > 0)
1698 diff = odp_time_diff_ns(t_to_idle, to_active);
1700 diff = odp_time_diff_ns(t_to_idle, top->t0);
1702 top->core_times[core].to_active = ODP_TIME_NULL;
1703 top->core_times[core].to_idle = t_to_idle;
1704 top->core_times[core].active_sum += diff;
1710 odp_atomic_add_rel_u32(&top->core_times[core].seq, 1);
1713static void while_idle_func(
void)
1716 em_cli_top_t *top = &cli_shm->top;
1719 odp_atomic_inc_u32(&top->core_times[core].seq);
1722 top->core_times[core].while_idle =
true;
1725 odp_atomic_add_rel_u32(&top->core_times[core].seq, 1);
1728static void to_active_func(
void)
1731 em_cli_top_t *top = &cli_shm->top;
1734 odp_atomic_inc_u32(&top->core_times[core].seq);
1737 odp_time_t time_to_active = odp_time_global();
1739 top->core_times[core].to_active = time_to_active;
1740 top->core_times[core].while_idle =
false;
1743 odp_atomic_add_rel_u32(&top->core_times[core].seq, 1);
1747static int unregister_hooks(
void)
1753 if (status !=
EM_OK) {
1754 odph_cli_log(
"Unregistering to_idle hook failed!\n");
1759 if (status !=
EM_OK) {
1760 odph_cli_log(
"Unregistering while_idle hook failed!\n");
1765 if (status !=
EM_OK) {
1766 odph_cli_log(
"Unregistering to_active hook failed!\n");
1773static void create_top_thread(uint32_t sleep_time)
1776 odp_cpumask_t cpumask;
1777 odp_instance_t instance;
1778 odph_thread_param_t thr_param;
1779 odph_thread_common_param_t thr_common;
1781 if (odp_cpumask_default_control(&cpumask, 1) != 1) {
1782 EM_LOG(EM_LOG_ERR,
"Failed to get default CPU mask.\n");
1786 if (odp_instance(&instance)) {
1787 EM_LOG(EM_LOG_ERR,
"Failed to get odp instance.\n");
1792 memset(&cli_shm->top.core_times, 0,
sizeof(cli_shm->top.core_times));
1794 odp_atomic_init_u32(&cli_shm->top.core_times[i].seq, 0);
1796 cli_shm->top.t0 = odp_time_global();
1800 if (status !=
EM_OK) {
1801 odph_cli_log(
"Registering to_active hook failed!\n");
1806 if (status !=
EM_OK) {
1808 odph_cli_log(
"Registering to_idle hook failed!\n");
1813 if (status !=
EM_OK) {
1816 odph_cli_log(
"Registering while_idle hook failed!\n");
1821 odph_thread_common_param_init(&thr_common);
1822 thr_common.instance = instance;
1823 thr_common.cpumask = &cpumask;
1824 thr_common.thread_model = 0;
1826 odph_thread_param_init(&thr_param);
1827 thr_param.thr_type = ODP_THREAD_CONTROL;
1828 thr_param.start = top_thread_func;
1829 thr_param.arg = (
void *)(uintptr_t)sleep_time;
1832 if (odph_thread_create(&cli_top_thread, &thr_common, &thr_param, 1) != 1) {
1833 odph_cli_log(
"Failed to create CLI top server thread.\n");
1834 if (unregister_hooks()) {
1835 odph_cli_log(
"Unregistering idle hooks failed\n");
1840 odph_cli_log(
"Top started. Type 'stop' to end it.\n");
1844static void print_em_top_help(
void)
1846 const char *usage =
"Usage: top [OPTIONS]\n"
1849 " Show EM core usage\n"
1852 " -t, --time <time>\tSets the update rate in seconds(default 1s)\n"
1853 " -h, --help\t\tDisplay this help\n"
1858 odph_cli_log(usage);
1861static void cmd_em_top(
int argc,
char *argv[])
1864 uint32_t sleep_time = 1000;
1867 const int max_args = 2;
1871 create_top_thread(sleep_time);
1873 }
else if (argc > max_args) {
1874 odph_cli_log(
"Error: extra parameter given to command top!\n");
1875 print_em_top_help();
1887 char *argv_new[argc];
1888 char cmd[MAX_CMD_LEN] =
"top";
1891 for (
int i = 1; i < argc - 1; i++)
1892 argv_new[i] = argv[i - 1];
1893 argv_new[argc - 1] = NULL;
1897 {
"time",
't', OPTPARSE_REQUIRED},
1898 {
"help",
'h', OPTPARSE_NONE},
1903 optparse_init(&options, argv_new);
1904 options.permute = 0;
1914 char *endptr = NULL;
1919 if (!options.optarg) {
1920 odph_cli_log(
"Error: update rate is required!\n");
1925 float seconds = strtof(options.optarg, &endptr);
1932 if (endptr == options.optarg || *endptr !=
'\0' ||
1933 errno != 0 || !isfinite(seconds) ||
1934 seconds < 0.1f || seconds > 3600.0f) {
1935 odph_cli_log(
"Error: update rate must be a number within [0.1, 3600]s!\n");
1938 sleep_time = (uint32_t)(seconds * 1000);
1939 create_top_thread(sleep_time);
1943 print_em_top_help();
1946 odph_cli_log(
"Error: %s\n", options.errmsg);
1949 odph_cli_log(
"Unknown Error\n");
1955 char *arg = optparse_arg(&options);
1958 odph_cli_log(
"Error: unexpected argument '%s'\n", arg);
1959 print_em_top_help();
1963static void cmd_em_stop(
int argc,
char *argv[])
1970 odph_cli_log(
"stop must be used after top command\n");
1976 odph_thread_join_result_t join_res = {0};
1977 int ret = odph_thread_join_result(&cli_top_thread, &join_res, 1);
1980 odph_cli_log(
"Failed to join CLI top thread:%d, join_res={is_sig=%d, ret=%d}\n",
1981 ret, join_res.is_sig, join_res.ret);
1990 if (unregister_hooks()) {
1991 odph_cli_log(
"Unregistering idle hooks failed\n");
1996static int cli_register_em_commands(
void)
1999 if (odph_cli_register_command(
"em_agrp_print", cmd_em_agrp_print,
2000 "[-a|-i <ag id>|-n <ag name>|-h]")) {
2001 EM_LOG(EM_LOG_ERR,
"Registering EM command em_agrp_print failed.\n");
2005 if (odph_cli_register_command(
"em_eo_print", cmd_em_eo_print,
2006 "[-a|-i <eo id>|-n <eo name>|-h]")) {
2007 EM_LOG(EM_LOG_ERR,
"Registering EM command em_eo_print failed.\n");
2011 if (odph_cli_register_command(
"em_egrp_print", cmd_em_egrp_print,
"")) {
2012 EM_LOG(EM_LOG_ERR,
"Registering EM cmd em_egrp_print failed.\n");
2016 if (odph_cli_register_command(
"em_info_print", cmd_em_info_print,
2018 EM_LOG(EM_LOG_ERR,
"Registering EM command em_info_print failed.\n");
2022 if (odph_cli_register_command(
"em_pool_print", cmd_em_pool_print,
2023 "[-a|-i <pool id>|-n <pool name>|-h]")) {
2024 EM_LOG(EM_LOG_ERR,
"Registering EM command em_pool_print failed.\n");
2028 if (odph_cli_register_command(
"em_pool_stats_opt", cmd_em_pool_stats_opt,
2029 "[-a|-i <pool id>|-n <pool name>|-h]")) {
2030 EM_LOG(EM_LOG_ERR,
"Registering EM command em_pool_stats_opt failed.\n");
2034#define EM_POOL_STATS_HELP \
2035"[-i<pool id>[:o]|-n<pool name>[:o]|-s<pool id:[subpool ids]>[:o]|-h]"
2037 if (odph_cli_register_command(
"em_pool_stats", cmd_em_pool_stats,
2038 EM_POOL_STATS_HELP)) {
2039 EM_LOG(EM_LOG_ERR,
"Registering EM command em_pool_stats failed.\n");
2043 if (odph_cli_register_command(
"em_queue_print", cmd_em_queue_print,
2045 EM_LOG(EM_LOG_ERR,
"Registering EM command em_queue_print failed.\n");
2049 if (odph_cli_register_command(
"em_qgrp_print", cmd_em_qgrp_print,
2050 "[-a|-i <qgrp id>|-n <qgrp name>|-h]")) {
2051 EM_LOG(EM_LOG_ERR,
"Registering EM command em_qgrp_print failed.\n");
2055 if (odph_cli_register_command(
"em_core_print", cmd_em_core_print,
"")) {
2056 EM_LOG(EM_LOG_ERR,
"Registering EM command em_core_print failed.\n");
2060 if (odph_cli_register_command(
"em_cfgfile_opts", cmd_em_cfgfile_opts,
"")) {
2061 EM_LOG(EM_LOG_ERR,
"Registering EM command em_cfgfile_opts failed.\n");
2065 if (odph_cli_register_command(
"em_conf_opts", cmd_em_conf_opts,
"")) {
2066 EM_LOG(EM_LOG_ERR,
"Registering EM command em_conf_opts failed.\n");
2070 if (odph_cli_register_command(
"top", cmd_em_top,
"[-t <time(s)>|-h]")) {
2071 EM_LOG(EM_LOG_ERR,
"Registering EM command top failed.\n");
2075 if (odph_cli_register_command(
"stop", cmd_em_stop,
2076 "Stop the top printing, used after top")) {
2077 EM_LOG(EM_LOG_ERR,
"Registering EM command stop failed.\n");
2084static int read_config_file(
void)
2087 const char *cli_conf =
"cli.enable";
2088 bool cli_enable =
false;
2089 int ret = em_libconfig_lookup_bool(&
em_shm->libconfig, cli_conf,
2092 if (unlikely(!ret)) {
2093 EM_LOG(EM_LOG_ERR,
"Config option '%s' not found\n", cli_conf);
2097 EM_PRINT(
"EM CLI config:\n");
2099 em_shm->
opt.cli.enable = (int)cli_enable;
2100 EM_PRINT(
" %s: %s(%d)\n", cli_conf, cli_enable ?
"true" :
"false",
2103 cli_conf =
"cli.ip_addr";
2104 ret = em_libconfig_lookup_string(&
em_shm->libconfig, cli_conf,
2106 if (unlikely(!ret)) {
2107 EM_LOG(EM_LOG_ERR,
"Config option '%s' not found\n", cli_conf);
2110 EM_PRINT(
" %s: %s\n", cli_conf,
em_shm->
opt.cli.ip_addr);
2112 cli_conf =
"cli.port";
2113 ret = em_libconfig_lookup_int(&
em_shm->libconfig, cli_conf,
2115 if (unlikely(!ret)) {
2116 EM_LOG(EM_LOG_ERR,
"Config option '%s' not found\n", cli_conf);
2119 EM_PRINT(
" %s: %d\n", cli_conf,
em_shm->
opt.cli.port);
2124static int cli_shm_setup(
void)
2126 if (cli_shm != NULL) {
2127 EM_LOG(EM_LOG_ERR,
"EM CLI shared memory ptr already set!\n");
2135 odp_shm_capability_t shm_capa;
2136 int ret = odp_shm_capability(&shm_capa);
2139 EM_LOG(EM_LOG_ERR,
"shm capability error:%d\n", ret);
2144 if (shm_capa.flags & ODP_SHM_NO_HP)
2145 flags |= ODP_SHM_NO_HP;
2147 odp_shm_t shm = odp_shm_reserve(
"em_cli",
sizeof(em_cli_shm_t),
2148 ODP_CACHE_LINE_SIZE, flags);
2150 if (shm == ODP_SHM_INVALID) {
2151 EM_LOG(EM_LOG_ERR,
"EM CLI shared memory reservation failed!\n");
2155 cli_shm = odp_shm_addr(shm);
2157 if (cli_shm == NULL) {
2158 EM_LOG(EM_LOG_ERR,
"EM CLI shared memory ptr NULL!\n");
2162 memset(cli_shm, 0,
sizeof(em_cli_shm_t));
2165 cli_shm->this_shm = shm;
2170static int cli_shm_lookup(
void)
2173 em_cli_shm_t *shm_addr;
2176 shm = odp_shm_lookup(
"em_cli");
2177 if (shm == ODP_SHM_INVALID) {
2178 EM_LOG(EM_LOG_ERR,
"Shared memory lookup failed!\n");
2182 shm_addr = odp_shm_addr(shm);
2184 EM_LOG(EM_LOG_ERR,
"Shared memory ptr NULL\n");
2191 if (shm_addr != cli_shm) {
2192 EM_LOG(EM_LOG_ERR,
"CLI shared memory init fails: cli_shm:%p != shm_addr:%p\n",
2200static int cli_shm_free(
void)
2202 if (odp_shm_free(cli_shm->this_shm)) {
2203 EM_LOG(EM_LOG_ERR,
"Error: odp_shm_free() failed\n");
2213static int cli_thr_fn(__attribute__((__unused__))
void *arg)
2217 if (unlikely(status !=
EM_OK)) {
2219 "Failed to init CLI server: init_cli_thread()=%" PRIxSTAT
"\n",
2225 int ret = odph_cli_run();
2229 "Failed to run CLI server:%d Maybe another instance is already running?\n\n",
2231 cli_shm->run_failed =
true;
2249 odph_cli_param_t cli_param = {0};
2251 odph_cli_param_init(&cli_param);
2252 cli_param.hostname =
"EM-ODP";
2253 cli_param.address =
em_shm->
opt.cli.ip_addr;
2254 cli_param.port = (uint16_t)
em_shm->
opt.cli.port;
2257 if (odph_cli_init(&cli_param)) {
2258 EM_LOG(EM_LOG_ERR,
"Error: odph_cli_init() failed.\n");
2263 if (cli_register_em_commands()) {
2264 EM_LOG(EM_LOG_ERR,
"Error: cli_register_em_commands() failed.\n");
2269 odp_cpumask_t cpumask;
2270 odph_thread_common_param_t thr_common;
2271 odph_thread_param_t thr_param;
2272 odp_instance_t instance;
2274 if (odp_cpumask_default_control(&cpumask, 1) != 1) {
2275 EM_LOG(EM_LOG_ERR,
"Failed to get default CPU mask.\n");
2279 if (odp_instance(&instance)) {
2280 EM_LOG(EM_LOG_ERR,
"Failed to get odp instance.\n");
2284 odph_thread_common_param_init(&thr_common);
2285 thr_common.instance = instance;
2286 thr_common.cpumask = &cpumask;
2287 thr_common.thread_model = 0;
2289 odph_thread_param_init(&thr_param);
2290 thr_param.thr_type = ODP_THREAD_CONTROL;
2291 thr_param.start = cli_thr_fn;
2292 thr_param.arg = NULL;
2295 if (cli_shm_setup()) {
2296 EM_LOG(EM_LOG_ERR,
"Error: cli_shm_setup() failed.\n");
2300 EM_PRINT(
"Starting CLI server on %s:%d\n", cli_param.address, cli_param.port);
2305 if (odph_thread_create(&cli_shm->em_cli_thread, &thr_common,
2306 &thr_param, 1) != 1) {
2307 EM_LOG(EM_LOG_ERR,
"Failed to create CLI server thread.\n");
2312 cli_shm->server_thr_created =
true;
2317static void sleep_ms(uint64_t ms)
2319 struct timespec req;
2320 struct timespec rem;
2322 req.tv_sec = ms / 1000;
2323 req.tv_nsec = (ms % 1000) * 1000000;
2325 while (nanosleep(&req, &rem) == -1 && errno == EINTR)
2340 if (!cli_shm->run_failed) {
2341 const int max_try_cnt = 4;
2351 EM_LOG(EM_LOG_ERR,
"Failed to stop CLI:%d - Retrying (%d)\n",
2353 sleep_ms(10 * try_cnt);
2355 err = odph_cli_stop();
2357 }
while (err && try_cnt < max_try_cnt);
2360 EM_LOG(EM_LOG_ERR,
"Failed to stop CLI:%d Give up with ERROR!\n",
2366 if (!err && cli_shm->server_thr_created) {
2367 odph_thread_join_result_t join_res = {0};
2368 int ret = odph_thread_join_result(&cli_shm->em_cli_thread, &join_res, 1);
2372 "Failed to join CLI server thread:%d, join_res={is_sig=%d, ret=%d}\n",
2373 ret, join_res.is_sig, join_res.ret);
2378 err = odph_cli_term();
2380 EM_LOG(EM_LOG_ERR,
"Failed to terminate CLI:%d\n", err);
2385 EM_PRINT(
"\nCLI server terminated!\n");
2399 if (read_config_file())
2403 stat = run_em_cli();
2405 if (stat !=
EM_OK) {
2406 EM_LOG(EM_LOG_ERR,
"%s(): run_em_cli() failed:%" PRI_STAT
"\n",
2419 int ret = cli_shm_lookup();
2432 stat = stop_em_cli();
2434 if (stat !=
EM_OK) {
2435 EM_LOG(EM_LOG_ERR,
"%s(): stop_em_cli() failed:%" PRI_STAT
"\n",
#define EM_MAX_SUBPOOLS
The maximum number of subpools in each EM pool. The subpool is a pool with buffers of only one size.
#define EM_QUEUE_GROUP_UNDEF
#define EM_ATOMIC_GROUP_UNDEF
em_status_t emcli_init_local(void)
Initialize the EM CLI locally on an EM core (if enabled)
em_status_t emcli_term(void)
Terminate the EM CLI (if enabled)
em_status_t emcli_term_local(void)
Terminate the EM CLI locally on an EM core (if enabled)
em_status_t emcli_init(void)
Initialize the EM CLI (if enabled)
em_atomic_group_t em_atomic_group_find(const char *name)
int em_core_id_next(void)
int em_core_id_first(em_core_type_t core_type, uint32_t *num)
uint32_t em_core_count(void)
em_eo_t em_eo_find(const char *name)
em_status_t em_hooks_register_to_active(em_idle_hook_to_active_t func)
em_status_t em_hooks_unregister_to_active(em_idle_hook_to_active_t func)
em_status_t em_hooks_unregister_to_idle(em_idle_hook_to_idle_t func)
em_status_t em_hooks_register_to_idle(em_idle_hook_to_idle_t func)
em_status_t em_hooks_register_while_idle(em_idle_hook_while_idle_t func)
em_status_t em_hooks_unregister_while_idle(em_idle_hook_while_idle_t func)
void em_pool_stats_opt_print(em_pool_t pool)
void em_pool_stats_opt_print_all(void)
void em_pool_info_print_all(void)
em_queue_group_t em_queue_group_find(const char *name)