11 #define OPTPARSE_IMPLEMENTATION
12 #include "misc/optparse.h"
16 #define MAX_CMD_LEN 20
19 static em_cli_shm_t *cli_shm;
30 int r = odph_cli_log_va(fmt, args);
37 static int cli_vlog(
em_log_level_t level,
const char *fmt, va_list args)
41 return odph_cli_log_va(fmt, args);
44 static void print_em_info_help(
void)
46 const char *usage =
"Usage: em_info_print [OPTION]\n"
47 "Print EM related information.\n"
50 " -a, --all\tPrint all EM info\n"
51 " -p, --cpu-arch\tPrint cpu architecture\n"
52 " -c, --conf\tPrint default and runtime configurations\n"
53 " -h, --help\tDisplay this help\n";
57 static void print_em_info_all(
void)
66 static void print_em_info_cpu_arch(
void)
70 print_cpu_arch_info();
75 static void print_em_info_conf(
void)
84 static void cmd_em_info_print(
int argc,
char *argv[])
87 const int max_args = 1;
93 }
else if (argc > max_args) {
94 odph_cli_log(
"Error: extra parameter given to command!\n");
106 char *argv_new[argc];
107 char cmd[MAX_CMD_LEN] =
"em_info_print";
110 for (
int i = 1; i < argc - 1; i++)
111 argv_new[i] = argv[i - 1];
112 argv_new[argc - 1] = NULL;
116 {
"all",
'a', OPTPARSE_NONE},
117 {
"cpu-arch",
'p', OPTPARSE_NONE},
118 {
"conf",
'c', OPTPARSE_NONE},
119 {
"help",
'h', OPTPARSE_NONE},
124 optparse_init(&options, argv_new);
137 print_em_info_cpu_arch();
140 print_em_info_conf();
143 print_em_info_help();
146 odph_cli_log(
"Error: %s\n", options.errmsg);
149 odph_cli_log(
"Unknown Error\n");
155 static void print_em_pool_all(
void)
164 static void print_em_pool(em_pool_t pool,
const char *pool_name)
168 odph_cli_log(
"Error: can't find EM pool %s.\n", pool_name);
170 odph_cli_log(
"Error: can't find EM pool %" PRI_POOL "\n", pool);
176 pool_info_print_hdr(1);
177 pool_info_print(pool);
182 static void print_em_pool_help(
void)
184 const char *usage =
"Usage: em_pool_print [OPTION]\n"
185 "Print EM pool related information\n"
188 " -a, --all\tPrint info of all pools\n"
189 " -i, --id <pool id>\tPrint info of <pool id>\n"
190 " -n, --name <pool name>\tPrint info of <pool name>\n"
191 " -h, --help\tDisplay this help\n";
196 static void cmd_em_pool_print(
int argc,
char *argv[])
199 const int max_args = 2;
205 }
else if (argc > max_args) {
206 odph_cli_log(
"Error: extra parameter given to command!\n");
218 char *argv_new[argc];
219 char cmd[MAX_CMD_LEN] =
"em_pool_print";
222 for (
int i = 1; i < argc - 1; i++)
223 argv_new[i] = argv[i - 1];
224 argv_new[argc - 1] = NULL;
229 {
"all",
'a', OPTPARSE_NONE},
230 {
"id",
'i', OPTPARSE_REQUIRED},
231 {
"name",
'n', OPTPARSE_REQUIRED},
232 {
"help",
'h', OPTPARSE_NONE},
237 optparse_init(&options, argv_new);
249 pool = (em_pool_t)(uintptr_t)(int)strtol(options.optarg, NULL, 0);
250 print_em_pool(pool, NULL);
253 pool = pool_find(options.optarg);
254 print_em_pool(pool, options.optarg);
257 print_em_pool_help();
260 odph_cli_log(
"Error: %s\n", options.errmsg);
263 odph_cli_log(
"Unknown Error\n");
274 odph_cli_log(
"Error: can't find EM pool %s.\n", pool_name);
276 odph_cli_log(
"Error: can't find EM pool %" PRI_POOL "\n", pool);
284 pool_stats_selected_print(pool, opt);
286 pool_stats_print(pool);
292 static int str_to_long(
const char *str,
long *num,
int base)
297 *num = strtol(str, &endptr, base);
299 odph_cli_log(
"strtol failed\n");
304 odph_cli_log(
"No digit is found in given str: %s\n", str);
309 odph_cli_log(
"Extra characters not used in str: %s\n", endptr);
320 if (str_to_long(str_opt, &stats_opt, 16))
323 if (stats_opt & 0x80) {
324 odph_cli_log(
"available is selected\n");
328 if (stats_opt & 0x40) {
329 odph_cli_log(
"alloc_ops is selected\n");
333 if (stats_opt & 0x20) {
334 odph_cli_log(
"alloc_fails is selected\n");
338 if (stats_opt & 0x10) {
339 odph_cli_log(
"free_ops is selected\n");
343 if (stats_opt & 0x08) {
344 odph_cli_log(
"total_ops is selected\n");
348 if (stats_opt & 0x04) {
349 odph_cli_log(
"cache_available is selected\n");
353 if (stats_opt & 0x02) {
354 odph_cli_log(
"cache_alloc_ops is selected\n");
358 if (stats_opt & 0x01) {
359 odph_cli_log(
"cache_free_ops is selected\n");
365 static int subpools_str_to_id(
char *str,
int *num_subpools,
int *subpools)
371 const char *delim =
"[,]";
374 if (!strstr(str,
"[")) {
377 if (str_to_long(str, &
id, 10))
379 subpools[0] = (int)
id;
383 token = strtok_r(str, delim, &saveptr);
385 odph_cli_log(
"Invalid option argument: %s\n", str);
388 if (str_to_long(token, &
id, 10))
390 subpools[0] = (int)
id;
393 token = strtok_r(NULL, delim, &saveptr);
397 if (str_to_long(token, &
id, 10))
399 subpools[i] = (int)
id;
402 if (token && strtok_r(NULL, delim, &saveptr)) {
403 odph_cli_log(
"Too many subpools, maximum number is: %d\n",
EM_MAX_SUBPOOLS);
412 print_em_subpools_stats(em_pool_t pool,
const int subpools[],
int num_subpools,
419 subpools_stats_selected_print(pool, subpools, num_subpools, opt);
421 subpools_stats_print(pool, subpools, num_subpools);
427 static void print_subpools_stats(
char *arg_subpools)
434 const char *str_stats_opt;
435 const char *pool_str;
437 const char *delim =
":";
440 pool_str = strtok_r(arg_subpools, delim, &saveptr);
441 if (pool_str == NULL) {
442 odph_cli_log(
"Invalid optarg: %s\n", arg_subpools);
446 if (str_to_long(pool_str, &pool_id, 16))
451 odph_cli_log(
"Invalid pool id: %d\n", pool_id);
454 pool = (em_pool_t)(uintptr_t)pool_id;
456 str_subpools = strtok_r(NULL, delim, &saveptr);
457 if (str_subpools == NULL) {
458 odph_cli_log(
"Invalid optarg: %s (subpool IDs are missing)\n", arg_subpools);
462 if (subpools_str_to_id(str_subpools, &num_subpools, subpools))
465 str_stats_opt = strtok_r(NULL, delim, &saveptr);
467 if (str_stats_opt == NULL) {
468 print_em_subpools_stats(pool, subpools, num_subpools, NULL);
470 str_to_opt(str_stats_opt, &opt);
471 print_em_subpools_stats(pool, subpools, num_subpools, &opt);
475 static void print_em_pool_stats_help(
void)
477 const char *usage =
"Usage: em_pool_stats [OPTION]\n"
478 "Print EM pool statistics\n"
481 " -i, --id <pool id [:stats opt]>\tPrint statistics of <pool id>\n"
482 " -n, --name <pool name [:stats opt]>\tPrint statistics of <pool name>\n"
483 " -s, --subpools <pool:[subpool ids] [:stats opt]>\tPrint statistics of subpools\n"
484 " -h, --help\tDisplay this help\n\n"
485 "Note stats opt is optional, when not given, it prints statistics from\n"
486 "em_pool_stats(), namely all statistic counters. When it is given,\n"
487 "this command prints selected counters from em_pool_stats_selected().\n"
488 "stats opt here uses one byte to select the counters to be read. One\n"
489 "bit in stats opt selects one counter. MSB represents 'available' and\n"
490 "LSB represents 'cache_free_ops'. For example, stats_opt=0x88 selects\n"
491 "the 'available' and 'total_ops' statistic counters.\n\n"
493 " em_pool_stats -i 0x1\n"
494 " em_pool_stats -i 0x1:0x88\n";
499 static void print_pool_stats(
char *optarg_str,
bool is_id)
505 const char *pool_str;
506 const char *delim =
":";
510 pool_str = strtok_r(optarg_str, delim, &saveptr);
511 if (pool_str == NULL) {
512 odph_cli_log(
"Invalid optarg_str: %s\n", optarg_str);
517 if (str_to_long(pool_str, &pool_id, 16))
522 odph_cli_log(
"Invalid pool id: %d\n", pool_id);
525 pool = (em_pool_t)(uintptr_t)pool_id;
527 pool = pool_find(pool_str);
531 str_opt = strtok_r(NULL, delim, &saveptr);
532 if (str_opt == NULL) {
534 print_em_pool_stats(pool, is_id ? NULL : pool_str, NULL);
536 str_to_opt(str_opt, &opt);
537 print_em_pool_stats(pool, is_id ? NULL : pool_str, &opt);
541 static void cmd_em_pool_stats(
int argc,
char *argv[])
544 const int max_args = 2;
547 odph_cli_log(
"Please specify pool or subpool ids!\n");
548 print_em_pool_stats_help();
550 }
else if (argc > max_args) {
551 odph_cli_log(
"Error: extra parameter given to command!\n");
563 char *argv_new[argc];
564 char cmd[MAX_CMD_LEN] =
"em_pool_stats";
567 for (
int i = 1; i < argc - 1; i++)
568 argv_new[i] = argv[i - 1];
569 argv_new[argc - 1] = NULL;
573 {
"id",
'i', OPTPARSE_REQUIRED},
574 {
"name",
'n', OPTPARSE_REQUIRED},
575 {
"subpools",
's', OPTPARSE_REQUIRED},
576 {
"help",
'h', OPTPARSE_NONE},
581 optparse_init(&options, argv_new);
590 print_pool_stats(options.optarg,
true);
593 print_pool_stats(options.optarg,
false);
596 print_subpools_stats(options.optarg);
599 print_em_pool_stats_help();
602 odph_cli_log(
"Error: %s\n", options.errmsg);
605 odph_cli_log(
"Unknown Error\n");
611 static void print_em_queue_help(
void)
613 const char *usage =
"Usage: em_queue_print [OPTION]\n"
614 "Print EM queue information\n"
617 " -c, --capa\tPrint queue capabilities\n"
618 " -a, --all\tPrint info about all queues\n"
619 " -h, --help\tDisplay this help\n";
623 static void print_em_queue_capa(
void)
632 static void print_em_queue_all(
void)
641 static void cmd_em_queue_print(
int argc,
char *argv[])
644 const int max_args = 1;
648 print_em_queue_all();
650 }
else if (argc > max_args) {
651 odph_cli_log(
"Error: extra parameter given to command!\n");
663 char *argv_new[argc];
664 char cmd[MAX_CMD_LEN] =
"em_queue_print";
667 for (
int i = 1; i < argc - 1; i++)
668 argv_new[i] = argv[i - 1];
669 argv_new[argc - 1] = NULL;
673 {
"capa",
'c', OPTPARSE_NONE},
674 {
"all",
'a', OPTPARSE_NONE},
675 {
"help",
'h', OPTPARSE_NONE},
680 optparse_init(&options, argv_new);
689 print_em_queue_capa();
692 print_em_queue_all();
695 print_em_queue_help();
698 odph_cli_log(
"Error: %s\n", options.errmsg);
701 odph_cli_log(
"Unknown Error\n");
707 static void print_em_qgrp_help(
void)
709 const char *usage =
"Usage: em_qgrp_print [OPTION]\n"
710 "Print EM queue group information\n"
713 " -a, --all(default)\tPrint info about all EM queue groups\n"
714 " -i, --id <qgrp id>\tPrint the queue info of <qgrp id>\n"
715 " -n, --name <qgrp name> \tPrint the queue info of <qgrp name>\n"
716 " -h, --help\tDisplay this help\n";
720 static void print_em_qgrp_all(
void)
729 static void print_em_qgrp_queues(
const em_queue_group_t qgrp,
const char *name)
733 odph_cli_log(
"Error: can't find queue group %s!\n", name);
735 odph_cli_log(
"Error: can't find queue group %" PRI_QGRP "!\n", qgrp);
746 static void cmd_em_qgrp_print(
int argc,
char *argv[])
749 const int max_args = 2;
755 }
else if (argc > max_args) {
756 odph_cli_log(
"Error: extra parameter given to command!\n");
768 char *argv_new[argc];
769 char cmd[MAX_CMD_LEN] =
"em_qgrp_print";
772 for (
int i = 1; i < argc - 1; i++)
773 argv_new[i] = argv[i - 1];
774 argv_new[argc - 1] = NULL;
776 em_queue_group_t qgrp;
779 {
"all",
'a', OPTPARSE_NONE},
780 {
"id",
'i', OPTPARSE_REQUIRED},
781 {
"name",
'n', OPTPARSE_REQUIRED},
782 {
"help",
'h', OPTPARSE_NONE},
787 optparse_init(&options, argv_new);
800 qgrp = (em_queue_group_t)(uintptr_t)(int)strtol(options.optarg, NULL, 0);
801 print_em_qgrp_queues(qgrp, NULL);
805 print_em_qgrp_queues(qgrp, options.optarg);
808 print_em_qgrp_help();
811 odph_cli_log(
"Error: %s\n", options.errmsg);
814 odph_cli_log(
"Unknown Error\n");
820 static void cmd_em_core_print(
int argc,
char *argv[])
827 print_core_map_info();
831 odph_cli_log(
"Error: extra parameter given to command!\n");
835 static void print_em_eo_help(
void)
837 const char *usage =
"Usage: em_eo_print [OPTION]\n"
838 "Print EO information\n"
841 " -a, --all\tPrint all EO info\n"
842 " -i, --id <eo id>\tPrint info about all queues of <eo id>\n"
843 " -n, --name <eo name>\tPrint info about all queues of <eo name>\n"
844 " -h, --help\tDisplay this help\n";
849 static void print_em_eo_all(
void)
858 static void print_em_eo(
const em_eo_t eo,
const char *name)
862 odph_cli_log(
"Error: can't find EO %s\n", name);
864 odph_cli_log(
"Error: can't find EO %" PRI_EO "\n", eo);
875 static void cmd_em_eo_print(
int argc,
char *argv[])
878 const int max_args = 2;
884 }
else if (argc > max_args) {
885 odph_cli_log(
"Error: extra parameter given to command!\n");
897 char *argv_new[argc];
898 char cmd[MAX_CMD_LEN] =
"em_eo_print";
901 for (
int i = 1; i < argc - 1; i++)
902 argv_new[i] = argv[i - 1];
903 argv_new[argc - 1] = NULL;
908 {
"all",
'a', OPTPARSE_NONE},
909 {
"id",
'i', OPTPARSE_REQUIRED},
910 {
"name",
'n', OPTPARSE_REQUIRED},
911 {
"help",
'h', OPTPARSE_NONE},
916 optparse_init(&options, argv_new);
928 eo = (em_eo_t)(uintptr_t)(int)strtol(options.optarg, NULL, 0);
929 print_em_eo(eo, NULL);
933 print_em_eo(eo, options.optarg);
939 odph_cli_log(
"Error: %s\n", options.errmsg);
942 odph_cli_log(
"Unknown Error\n");
948 static void print_em_agrp_help(
void)
950 const char *usage =
"Usage: em_agrp_print [OPTION]\n"
951 "Print info about atomic groups\n"
954 " -a, --all\tPrint info about all atomic groups\n"
955 " -i, --id <ag id>\tPrint info about all queues of <ag id>\n"
956 " -n, --name <ag name>\tPrint info about all queues of <ag name>\n"
957 " -h, --help\tDisplay this help\n";
962 static void print_em_agrp_all(
void)
971 static void print_em_agrp(em_atomic_group_t ag,
const char *ag_name)
975 odph_cli_log(
"Error: can't find atomic group %s\n", ag_name);
977 odph_cli_log(
"Error: can't find atomic group %" PRI_AGRP "\n", ag);
988 static void cmd_em_agrp_print(
int argc,
char *argv[])
991 const int max_args = 2;
997 }
else if (argc > max_args) {
998 odph_cli_log(
"Error: extra parameter given to command!\n");
1010 char *argv_new[argc];
1011 char cmd[MAX_CMD_LEN] =
"em_agrp_print";
1014 for (
int i = 1; i < argc - 1; i++)
1015 argv_new[i] = argv[i - 1];
1016 argv_new[argc - 1] = NULL;
1018 em_atomic_group_t ag;
1021 {
"all",
'a', OPTPARSE_NONE},
1022 {
"id",
'i', OPTPARSE_REQUIRED},
1023 {
"name",
'n', OPTPARSE_REQUIRED},
1024 {
"help",
'h', OPTPARSE_NONE},
1029 optparse_init(&options, argv_new);
1030 options.permute = 0;
1040 print_em_agrp_all();
1043 ag = (em_atomic_group_t)(uintptr_t)(int)strtol(options.optarg, NULL, 0);
1044 print_em_agrp(ag, NULL);
1048 print_em_agrp(ag, options.optarg);
1051 print_em_agrp_help();
1054 odph_cli_log(
"Error: %s\n", options.errmsg);
1057 odph_cli_log(
"Unknown Error\n");
1063 static void cmd_em_egrp_print(
int argc,
char *argv[])
1074 odph_cli_log(
"Error: extra parameter given to command!\n");
1078 static int cli_register_em_commands(
void)
1081 if (odph_cli_register_command(
"em_agrp_print", cmd_em_agrp_print,
1082 "[a|i <ag id>|n <ag name>|h]")) {
1083 EM_LOG(EM_LOG_ERR,
"Registering EM command em_agrp_print failed.\n");
1087 if (odph_cli_register_command(
"em_eo_print", cmd_em_eo_print,
1088 "[a|i <eo id>|n <eo name>|h]")) {
1089 EM_LOG(EM_LOG_ERR,
"Registering EM command em_eo_print failed.\n");
1093 if (odph_cli_register_command(
"em_egrp_print", cmd_em_egrp_print,
"")) {
1094 EM_LOG(EM_LOG_ERR,
"Registering EM cmd em_egrp_print failed.\n");
1098 if (odph_cli_register_command(
"em_info_print", cmd_em_info_print,
1100 EM_LOG(EM_LOG_ERR,
"Registering EM command em_info_print failed.\n");
1104 if (odph_cli_register_command(
"em_pool_print", cmd_em_pool_print,
1105 "[a|i <pool id>|n <pool name>|h]")) {
1106 EM_LOG(EM_LOG_ERR,
"Registering EM command em_pool_print failed.\n");
1110 if (odph_cli_register_command(
"em_pool_stats", cmd_em_pool_stats,
1111 "[i<pool id>|n<pool name>|s<pool id:[subpool ids]>[:o]|h]")) {
1112 EM_LOG(EM_LOG_ERR,
"Registering EM command em_pool_stats failed.\n");
1116 if (odph_cli_register_command(
"em_queue_print", cmd_em_queue_print,
1118 EM_LOG(EM_LOG_ERR,
"Registering EM command em_queue_print failed.\n");
1122 if (odph_cli_register_command(
"em_qgrp_print", cmd_em_qgrp_print,
1123 "[a|i <qgrp id>|n <qgrp name>|h]")) {
1124 EM_LOG(EM_LOG_ERR,
"Registering EM command em_qgrp_print failed.\n");
1128 if (odph_cli_register_command(
"em_core_print", cmd_em_core_print,
"")) {
1129 EM_LOG(EM_LOG_ERR,
"Registering EM command em_core_print failed.\n");
1136 static int read_config_file(
void)
1139 const char *cli_conf =
"cli.enable";
1140 bool cli_enable =
false;
1144 if (unlikely(!ret)) {
1145 EM_LOG(EM_LOG_ERR,
"Config option '%s' not found\n", cli_conf);
1149 EM_PRINT(
"EM CLI config:\n");
1151 em_shm->opt.cli.enable = (int)cli_enable;
1152 EM_PRINT(
" %s: %s(%d)\n", cli_conf, cli_enable ?
"true" :
"false",
1155 cli_conf =
"cli.ip_addr";
1157 &
em_shm->opt.cli.ip_addr);
1158 if (unlikely(!ret)) {
1159 EM_LOG(EM_LOG_ERR,
"Config option '%s' not found\n", cli_conf);
1162 EM_PRINT(
" %s: %s\n", cli_conf,
em_shm->opt.cli.ip_addr);
1164 cli_conf =
"cli.port";
1167 if (unlikely(!ret)) {
1168 EM_LOG(EM_LOG_ERR,
"Config option '%s' not found\n", cli_conf);
1171 EM_PRINT(
" %s: %d\n", cli_conf,
em_shm->opt.cli.port);
1176 static int cli_shm_setup(
void)
1178 if (cli_shm != NULL) {
1179 EM_LOG(EM_LOG_ERR,
"EM CLI shared memory ptr already set!\n");
1187 odp_shm_capability_t shm_capa;
1188 int ret = odp_shm_capability(&shm_capa);
1191 EM_LOG(EM_LOG_ERR,
"shm capability error:%d\n", ret);
1196 if (shm_capa.flags & ODP_SHM_NO_HP)
1197 flags |= ODP_SHM_NO_HP;
1199 odp_shm_t shm = odp_shm_reserve(
"em_cli",
sizeof(em_cli_shm_t),
1200 ODP_CACHE_LINE_SIZE, flags);
1202 if (shm == ODP_SHM_INVALID) {
1203 EM_LOG(EM_LOG_ERR,
"EM CLI shared memory reservation failed!\n");
1207 cli_shm = odp_shm_addr(shm);
1209 if (cli_shm == NULL) {
1210 EM_LOG(EM_LOG_ERR,
"EM CLI shared memory ptr NULL!\n");
1214 memset(cli_shm, 0,
sizeof(em_cli_shm_t));
1217 cli_shm->this_shm = shm;
1222 static int cli_shm_lookup(
void)
1225 em_cli_shm_t *shm_addr;
1228 shm = odp_shm_lookup(
"em_cli");
1229 if (shm == ODP_SHM_INVALID) {
1230 EM_LOG(EM_LOG_ERR,
"Shared memory lookup failed!\n");
1234 shm_addr = odp_shm_addr(shm);
1236 EM_LOG(EM_LOG_ERR,
"Shared memory ptr NULL\n");
1240 if (
em_shm->conf.process_per_core && cli_shm == NULL)
1243 if (shm_addr != cli_shm) {
1244 EM_LOG(EM_LOG_ERR,
"CLI shared memory init fails: cli_shm:%p != shm_addr:%p\n",
1252 static int cli_shm_free(
void)
1254 if (odp_shm_free(cli_shm->this_shm)) {
1255 EM_LOG(EM_LOG_ERR,
"Error: odp_shm_free() failed\n");
1265 static int cli_thr_fn(
__attribute__((__unused__))
void *arg)
1270 if (odph_cli_run()) {
1271 EM_LOG(EM_LOG_ERR,
"Failed to start CLI server.\n");
1290 odph_cli_param_t cli_param = {0};
1292 odph_cli_param_init(&cli_param);
1293 cli_param.hostname =
"EM-ODP";
1294 cli_param.address =
em_shm->opt.cli.ip_addr;
1295 cli_param.port = (uint16_t)
em_shm->opt.cli.port;
1298 if (odph_cli_init(&cli_param)) {
1299 EM_LOG(EM_LOG_ERR,
"Error: odph_cli_init() failed.\n");
1304 if (cli_register_em_commands()) {
1305 EM_LOG(EM_LOG_ERR,
"Error: cli_register_em_commands() failed.\n");
1310 odp_cpumask_t cpumask;
1311 odph_thread_common_param_t thr_common;
1312 odph_thread_param_t thr_param;
1313 odp_instance_t instance;
1315 if (odp_cpumask_default_control(&cpumask, 1) != 1) {
1316 EM_LOG(EM_LOG_ERR,
"Failed to get default CPU mask.\n");
1320 if (odp_instance(&instance)) {
1321 EM_LOG(EM_LOG_ERR,
"Failed to get odp instance.\n");
1325 odph_thread_common_param_init(&thr_common);
1326 thr_common.instance = instance;
1327 thr_common.cpumask = &cpumask;
1328 thr_common.thread_model = 0;
1330 odph_thread_param_init(&thr_param);
1331 thr_param.thr_type = ODP_THREAD_CONTROL;
1332 thr_param.start = cli_thr_fn;
1333 thr_param.arg = NULL;
1336 if (cli_shm_setup()) {
1337 EM_LOG(EM_LOG_ERR,
"Error: cli_shm_setup() failed.\n");
1341 EM_PRINT(
"Starting CLI server on %s:%d\n", cli_param.address, cli_param.port);
1346 if (odph_thread_create(&cli_shm->em_cli_thread, &thr_common,
1347 &thr_param, 1) != 1) {
1348 EM_LOG(EM_LOG_ERR,
"Failed to create CLI server thread.\n");
1365 if (odph_cli_stop()) {
1366 EM_LOG(EM_LOG_ERR,
"Failed to stop CLI.\n");
1370 if (odph_thread_join(&cli_shm->em_cli_thread, 1) != 1) {
1371 EM_LOG(EM_LOG_ERR,
"Failed to join server thread.\n");
1375 if (odph_cli_term()) {
1376 EM_LOG(EM_LOG_ERR,
"Failed to terminate CLI.\n");
1381 EM_PRINT(
"\nCLI server terminated!\n");
1395 if (read_config_file())
1398 if (
em_shm->opt.cli.enable) {
1399 stat = run_em_cli();
1401 if (stat !=
EM_OK) {
1402 EM_LOG(EM_LOG_ERR,
"%s(): run_em_cli() failed:%" PRI_STAT
"\n",
1412 if (!
em_shm->opt.cli.enable)
1415 int ret = cli_shm_lookup();
1427 if (
em_shm->opt.cli.enable) {
1428 stat = stop_em_cli();
1430 if (stat !=
EM_OK) {
1431 EM_LOG(EM_LOG_ERR,
"%s(): stop_em_cli() failed:%" PRI_STAT
"\n",