4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 #include <rte_errno.h>
47 #include <rte_cfgfile.h>
48 #include <rte_string_fns.h>
54 * Default config values
57 static struct app_params app_params_default = {
58 .config_file = "./config/ip_pipeline.cfg",
59 .log_level = APP_LOG_LEVEL_HIGH,
67 static const struct app_mempool_params mempool_params_default = {
69 .buffer_size = 2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM,
70 .pool_size = 32 * 1024,
75 static const struct app_link_params link_params_default = {
93 .mq_mode = ETH_MQ_RX_NONE,
95 .header_split = 0, /* Header split */
96 .hw_ip_checksum = 0, /* IP checksum offload */
97 .hw_vlan_filter = 0, /* VLAN filtering */
98 .hw_vlan_strip = 0, /* VLAN strip */
99 .hw_vlan_extend = 0, /* Extended VLAN */
100 .jumbo_frame = 0, /* Jumbo frame support */
101 .hw_strip_crc = 0, /* CRC strip by HW */
102 .enable_scatter = 0, /* Scattered packets RX handler */
104 .max_rx_pkt_len = 9000, /* Jumbo frame max packet len */
105 .split_hdr_size = 0, /* Header split buffer size */
108 .mq_mode = ETH_MQ_TX_NONE,
116 static const struct app_pktq_hwq_in_params default_hwq_in_params = {
128 .rx_free_thresh = 64,
130 .rx_deferred_start = 0,
134 static const struct app_pktq_hwq_out_params default_hwq_out_params = {
149 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
150 ETH_TXQ_FLAGS_NOOFFLOADS,
151 .tx_deferred_start = 0,
155 static const struct app_pktq_swq_params default_swq_params = {
169 .mempool_direct_id = 0,
170 .mempool_indirect_id = 0,
173 struct app_pktq_tm_params default_tm_params = {
175 .file_name = "./config/tm_profile.cfg",
180 struct app_pktq_source_params default_source_params = {
185 .n_bytes_per_pkt = 0,
188 struct app_pktq_sink_params default_sink_params = {
194 struct app_msgq_params default_msgq_params = {
200 struct app_pipeline_params default_pipeline_params = {
213 static const char app_usage[] =
214 "Usage: %s [-f CONFIG_FILE] [-s SCRIPT_FILE] [-p PORT_MASK] "
215 "[-l LOG_LEVEL] [--preproc PREPROCESSOR] [--preproc-args ARGS]\n"
218 "\t-f CONFIG_FILE: Default config file is %s\n"
219 "\t-p PORT_MASK: Mask of NIC port IDs in hex format (generated from "
220 "config file when not provided)\n"
221 "\t-s SCRIPT_FILE: No CLI script file is run when not specified\n"
222 "\t-l LOG_LEVEL: 0 = NONE, 1 = HIGH PRIO (default), 2 = LOW PRIO\n"
223 "\t--preproc PREPROCESSOR: Configuration file pre-processor\n"
224 "\t--preproc-args ARGS: Arguments to be passed to pre-processor\n"
228 app_print_usage(char *prgname)
230 rte_exit(0, app_usage, prgname, app_params_default.config_file);
233 #define PARSER_PARAM_ADD_CHECK(result, params_array, section_name) \
235 APP_CHECK((result != -EINVAL), \
236 "Parse error: no free memory"); \
237 APP_CHECK((result != -ENOMEM), \
238 "Parse error: too many \"%s\" sections", section_name); \
239 APP_CHECK(((result >= 0) && (params_array)[result].parsed == 0),\
240 "Parse error: duplicate \"%s\" section", section_name); \
241 APP_CHECK((result >= 0), \
242 "Parse error in section \"%s\"", section_name); \
245 #define PARSE_ERROR(exp, section, entry) \
246 APP_CHECK(exp, "Parse error in section \"%s\": entry \"%s\"\n", section, entry)
248 #define PARSE_ERROR_MESSAGE(exp, section, entry, message) \
249 APP_CHECK(exp, "Parse error in section \"%s\", entry \"%s\": %s\n", \
250 section, entry, message)
253 #define PARSE_ERROR_MALLOC(exp) \
254 APP_CHECK(exp, "Parse error: no free memory\n")
256 #define PARSE_ERROR_SECTION(exp, section) \
257 APP_CHECK(exp, "Parse error in section \"%s\"", section)
259 #define PARSE_ERROR_SECTION_NO_ENTRIES(exp, section) \
260 APP_CHECK(exp, "Parse error in section \"%s\": no entries\n", section)
262 #define PARSE_WARNING_IGNORED(exp, section, entry) \
265 fprintf(stderr, "Parse warning in section \"%s\": " \
266 "entry \"%s\" is ignored\n", section, entry); \
269 #define PARSE_ERROR_INVALID(exp, section, entry) \
270 APP_CHECK(exp, "Parse error in section \"%s\": unrecognized entry \"%s\"\n",\
273 #define PARSE_ERROR_DUPLICATE(exp, section, entry) \
274 APP_CHECK(exp, "Parse error in section \"%s\": duplicate entry \"%s\"\n",\
278 validate_name(const char *name, const char *prefix, int num)
282 for (i = 0; (name[i] != '\0') && (prefix[i] != '\0'); i++) {
283 if (name[i] != prefix[i])
287 if (prefix[i] != '\0')
298 j = skip_digits(&name[i]);
300 if ((j == 0) || (name[i] != '.'))
306 j = skip_digits(&name[i]);
308 if ((j == 0) || (name[i] != '\0'))
316 parse_eal(struct app_params *app,
317 const char *section_name,
318 struct rte_cfgfile *cfg)
320 struct app_eal_params *p = &app->eal_params;
321 struct rte_cfgfile_entry *entries;
324 n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
325 PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
327 entries = malloc(n_entries * sizeof(struct rte_cfgfile_entry));
328 PARSE_ERROR_MALLOC(entries != NULL);
330 rte_cfgfile_section_entries(cfg, section_name, entries, n_entries);
332 for (i = 0; i < n_entries; i++) {
333 struct rte_cfgfile_entry *entry = &entries[i];
336 if (strcmp(entry->name, "c") == 0) {
337 PARSE_WARNING_IGNORED(0, section_name, entry->name);
342 if (strcmp(entry->name, "l") == 0) {
343 PARSE_WARNING_IGNORED(0, section_name, entry->name);
348 if (strcmp(entry->name, "lcores") == 0) {
349 PARSE_ERROR_DUPLICATE((p->coremap == NULL),
352 p->coremap = strdup(entry->value);
357 if (strcmp(entry->name, "master_lcore") == 0) {
360 PARSE_ERROR_DUPLICATE((p->master_lcore_present == 0),
363 p->master_lcore_present = 1;
365 status = parser_read_uint32(&p->master_lcore,
367 PARSE_ERROR((status == 0), section_name, entry->name);
372 if (strcmp(entry->name, "n") == 0) {
375 PARSE_ERROR_DUPLICATE((p->channels_present == 0),
378 p->channels_present = 1;
380 status = parser_read_uint32(&p->channels, entry->value);
381 PARSE_ERROR((status == 0), section_name, entry->name);
386 if (strcmp(entry->name, "m") == 0) {
389 PARSE_ERROR_DUPLICATE((p->memory_present == 0),
392 p->memory_present = 1;
394 status = parser_read_uint32(&p->memory, entry->value);
395 PARSE_ERROR((status == 0), section_name, entry->name);
400 if (strcmp(entry->name, "r") == 0) {
403 PARSE_ERROR_DUPLICATE((p->ranks_present == 0),
406 p->ranks_present = 1;
408 status = parser_read_uint32(&p->ranks, entry->value);
409 PARSE_ERROR((status == 0), section_name, entry->name);
414 if ((strcmp(entry->name, "pci_blacklist") == 0) ||
415 (strcmp(entry->name, "b") == 0)) {
418 for (i = 0; i < APP_MAX_LINKS; i++) {
419 if (p->pci_blacklist[i])
422 p->pci_blacklist[i] =
423 strdup(entry->value);
424 PARSE_ERROR_MALLOC(p->pci_blacklist[i]);
429 PARSE_ERROR_MESSAGE((i < APP_MAX_LINKS),
430 section_name, entry->name,
431 "too many elements");
436 if ((strcmp(entry->name, "pci_whitelist") == 0) ||
437 (strcmp(entry->name, "w") == 0)) {
440 PARSE_ERROR_MESSAGE((app->port_mask != 0),
441 section_name, entry->name, "entry to be "
442 "generated by the application (port_mask "
445 for (i = 0; i < APP_MAX_LINKS; i++) {
446 if (p->pci_whitelist[i])
449 p->pci_whitelist[i] = strdup(entry->value);
450 PARSE_ERROR_MALLOC(p->pci_whitelist[i]);
455 PARSE_ERROR_MESSAGE((i < APP_MAX_LINKS),
456 section_name, entry->name,
457 "too many elements");
462 if (strcmp(entry->name, "vdev") == 0) {
465 for (i = 0; i < APP_MAX_LINKS; i++) {
469 p->vdev[i] = strdup(entry->value);
470 PARSE_ERROR_MALLOC(p->vdev[i]);
475 PARSE_ERROR_MESSAGE((i < APP_MAX_LINKS),
476 section_name, entry->name,
477 "too many elements");
482 if (strcmp(entry->name, "vmware_tsc_map") == 0) {
485 PARSE_ERROR_DUPLICATE((p->vmware_tsc_map_present == 0),
488 p->vmware_tsc_map_present = 1;
490 val = parser_read_arg_bool(entry->value);
491 PARSE_ERROR((val >= 0), section_name, entry->name);
492 p->vmware_tsc_map = val;
497 if (strcmp(entry->name, "proc_type") == 0) {
498 PARSE_ERROR_DUPLICATE((p->proc_type == NULL),
501 p->proc_type = strdup(entry->value);
506 if (strcmp(entry->name, "syslog") == 0) {
507 PARSE_ERROR_DUPLICATE((p->syslog == NULL),
510 p->syslog = strdup(entry->value);
515 if (strcmp(entry->name, "log_level") == 0) {
518 PARSE_ERROR_DUPLICATE((p->log_level_present == 0),
521 p->log_level_present = 1;
523 status = parser_read_uint32(&p->log_level,
525 PARSE_ERROR((status == 0), section_name, entry->name);
530 if (strcmp(entry->name, "v") == 0) {
533 PARSE_ERROR_DUPLICATE((p->version_present == 0),
536 p->version_present = 1;
538 val = parser_read_arg_bool(entry->value);
539 PARSE_ERROR((val >= 0), section_name, entry->name);
545 if ((strcmp(entry->name, "help") == 0) ||
546 (strcmp(entry->name, "h") == 0)) {
549 PARSE_ERROR_DUPLICATE((p->help_present == 0),
554 val = parser_read_arg_bool(entry->value);
555 PARSE_ERROR((val >= 0), section_name, entry->name);
561 if (strcmp(entry->name, "no_huge") == 0) {
564 PARSE_ERROR_DUPLICATE((p->no_huge_present == 0),
567 p->no_huge_present = 1;
569 val = parser_read_arg_bool(entry->value);
570 PARSE_ERROR((val >= 0), section_name, entry->name);
576 if (strcmp(entry->name, "no_pci") == 0) {
579 PARSE_ERROR_DUPLICATE((p->no_pci_present == 0),
582 p->no_pci_present = 1;
584 val = parser_read_arg_bool(entry->value);
585 PARSE_ERROR((val >= 0), section_name, entry->name);
591 if (strcmp(entry->name, "no_hpet") == 0) {
594 PARSE_ERROR_DUPLICATE((p->no_hpet_present == 0),
597 p->no_hpet_present = 1;
599 val = parser_read_arg_bool(entry->value);
600 PARSE_ERROR((val >= 0), section_name, entry->name);
606 if (strcmp(entry->name, "no_shconf") == 0) {
609 PARSE_ERROR_DUPLICATE((p->no_shconf_present == 0),
612 p->no_shconf_present = 1;
614 val = parser_read_arg_bool(entry->value);
615 PARSE_ERROR((val >= 0), section_name, entry->name);
621 if (strcmp(entry->name, "d") == 0) {
622 PARSE_ERROR_DUPLICATE((p->add_driver == NULL),
625 p->add_driver = strdup(entry->value);
630 if (strcmp(entry->name, "socket_mem") == 0) {
631 PARSE_ERROR_DUPLICATE((p->socket_mem == NULL),
634 p->socket_mem = strdup(entry->value);
639 if (strcmp(entry->name, "huge_dir") == 0) {
640 PARSE_ERROR_DUPLICATE((p->huge_dir == NULL),
643 p->huge_dir = strdup(entry->value);
648 if (strcmp(entry->name, "file_prefix") == 0) {
649 PARSE_ERROR_DUPLICATE((p->file_prefix == NULL),
652 p->file_prefix = strdup(entry->value);
657 if (strcmp(entry->name, "base_virtaddr") == 0) {
658 PARSE_ERROR_DUPLICATE((p->base_virtaddr == NULL),
661 p->base_virtaddr = strdup(entry->value);
666 if (strcmp(entry->name, "create_uio_dev") == 0) {
669 PARSE_ERROR_DUPLICATE((p->create_uio_dev_present == 0),
672 p->create_uio_dev_present = 1;
674 val = parser_read_arg_bool(entry->value);
675 PARSE_ERROR((val >= 0), section_name, entry->name);
676 p->create_uio_dev = val;
681 if (strcmp(entry->name, "vfio_intr") == 0) {
682 PARSE_ERROR_DUPLICATE((p->vfio_intr == NULL),
685 p->vfio_intr = strdup(entry->value);
690 if (strcmp(entry->name, "xen_dom0") == 0) {
693 PARSE_ERROR_DUPLICATE((p->xen_dom0_present == 0),
696 p->xen_dom0_present = 1;
698 val = parser_read_arg_bool(entry->value);
699 PARSE_ERROR((val >= 0), section_name, entry->name);
705 PARSE_ERROR_INVALID(0, section_name, entry->name);
712 parse_pipeline_pktq_in(struct app_params *app,
713 struct app_pipeline_params *p,
716 const char *next = value;
718 char name[APP_PARAM_NAME_SIZE];
721 while (*next != '\0') {
722 enum app_pktq_in_type type;
727 next = skip_white_spaces(next);
731 end_space = strchr(next, ' ');
732 end_tab = strchr(next, ' ');
734 if (end_space && (!end_tab))
736 else if ((!end_space) && end_tab)
738 else if (end_space && end_tab)
739 end = RTE_MIN(end_space, end_tab);
744 name_len = strlen(next);
746 name_len = end - next;
748 if (name_len == 0 || name_len == sizeof(name))
751 strncpy(name, next, name_len);
752 name[name_len] = '\0';
757 if (validate_name(name, "RXQ", 2) == 0) {
758 type = APP_PKTQ_IN_HWQ;
759 id = APP_PARAM_ADD(app->hwq_in_params, name);
760 } else if (validate_name(name, "SWQ", 1) == 0) {
761 type = APP_PKTQ_IN_SWQ;
762 id = APP_PARAM_ADD(app->swq_params, name);
763 } else if (validate_name(name, "TM", 1) == 0) {
764 type = APP_PKTQ_IN_TM;
765 id = APP_PARAM_ADD(app->tm_params, name);
766 } else if (validate_name(name, "SOURCE", 1) == 0) {
767 type = APP_PKTQ_IN_SOURCE;
768 id = APP_PARAM_ADD(app->source_params, name);
775 p->pktq_in[p->n_pktq_in].type = type;
776 p->pktq_in[p->n_pktq_in].id = (uint32_t) id;
784 parse_pipeline_pktq_out(struct app_params *app,
785 struct app_pipeline_params *p,
788 const char *next = value;
790 char name[APP_PARAM_NAME_SIZE];
793 while (*next != '\0') {
794 enum app_pktq_out_type type;
799 next = skip_white_spaces(next);
803 end_space = strchr(next, ' ');
804 end_tab = strchr(next, ' ');
806 if (end_space && (!end_tab))
808 else if ((!end_space) && end_tab)
810 else if (end_space && end_tab)
811 end = RTE_MIN(end_space, end_tab);
816 name_len = strlen(next);
818 name_len = end - next;
820 if (name_len == 0 || name_len == sizeof(name))
823 strncpy(name, next, name_len);
824 name[name_len] = '\0';
828 if (validate_name(name, "TXQ", 2) == 0) {
829 type = APP_PKTQ_OUT_HWQ;
830 id = APP_PARAM_ADD(app->hwq_out_params, name);
831 } else if (validate_name(name, "SWQ", 1) == 0) {
832 type = APP_PKTQ_OUT_SWQ;
833 id = APP_PARAM_ADD(app->swq_params, name);
834 } else if (validate_name(name, "TM", 1) == 0) {
835 type = APP_PKTQ_OUT_TM;
836 id = APP_PARAM_ADD(app->tm_params, name);
837 } else if (validate_name(name, "SINK", 1) == 0) {
838 type = APP_PKTQ_OUT_SINK;
839 id = APP_PARAM_ADD(app->sink_params, name);
846 p->pktq_out[p->n_pktq_out].type = type;
847 p->pktq_out[p->n_pktq_out].id = id;
855 parse_pipeline_msgq_in(struct app_params *app,
856 struct app_pipeline_params *p,
859 const char *next = value;
861 char name[APP_PARAM_NAME_SIZE];
865 while (*next != '\0') {
869 next = skip_white_spaces(next);
873 end_space = strchr(next, ' ');
874 end_tab = strchr(next, ' ');
876 if (end_space && (!end_tab))
878 else if ((!end_space) && end_tab)
880 else if (end_space && end_tab)
881 end = RTE_MIN(end_space, end_tab);
886 name_len = strlen(next);
888 name_len = end - next;
890 if (name_len == 0 || name_len == sizeof(name))
893 strncpy(name, next, name_len);
894 name[name_len] = '\0';
899 if (validate_name(name, "MSGQ", 1) != 0)
902 idx = APP_PARAM_ADD(app->msgq_params, name);
906 p->msgq_in[p->n_msgq_in] = idx;
914 parse_pipeline_msgq_out(struct app_params *app,
915 struct app_pipeline_params *p,
918 const char *next = value;
920 char name[APP_PARAM_NAME_SIZE];
924 while (*next != '\0') {
928 next = skip_white_spaces(next);
932 end_space = strchr(next, ' ');
933 end_tab = strchr(next, ' ');
935 if (end_space && (!end_tab))
937 else if ((!end_space) && end_tab)
939 else if (end_space && end_tab)
940 end = RTE_MIN(end_space, end_tab);
945 name_len = strlen(next);
947 name_len = end - next;
949 if (name_len == 0 || name_len == sizeof(name))
952 strncpy(name, next, name_len);
953 name[name_len] = '\0';
958 if (validate_name(name, "MSGQ", 1) != 0)
961 idx = APP_PARAM_ADD(app->msgq_params, name);
965 p->msgq_out[p->n_msgq_out] = idx;
973 parse_pipeline(struct app_params *app,
974 const char *section_name,
975 struct rte_cfgfile *cfg)
977 char name[CFG_NAME_LEN];
978 struct app_pipeline_params *param;
979 struct rte_cfgfile_entry *entries;
983 n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
984 PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
986 entries = malloc(n_entries * sizeof(struct rte_cfgfile_entry));
987 PARSE_ERROR_MALLOC(entries != NULL);
989 rte_cfgfile_section_entries(cfg, section_name, entries, n_entries);
991 param_idx = APP_PARAM_ADD(app->pipeline_params, section_name);
992 PARSER_PARAM_ADD_CHECK(param_idx, app->pipeline_params, section_name);
994 param = &app->pipeline_params[param_idx];
996 for (i = 0; i < n_entries; i++) {
997 struct rte_cfgfile_entry *ent = &entries[i];
999 if (strcmp(ent->name, "type") == 0) {
1000 int w_size = snprintf(param->type, RTE_DIM(param->type),
1003 PARSE_ERROR(((w_size > 0) &&
1004 (w_size < (int)RTE_DIM(param->type))),
1010 if (strcmp(ent->name, "core") == 0) {
1011 int status = parse_pipeline_core(
1012 ¶m->socket_id, ¶m->core_id,
1013 ¶m->hyper_th_id, ent->value);
1015 PARSE_ERROR((status == 0), section_name,
1020 if (strcmp(ent->name, "pktq_in") == 0) {
1021 int status = parse_pipeline_pktq_in(app, param,
1024 PARSE_ERROR((status == 0), section_name,
1029 if (strcmp(ent->name, "pktq_out") == 0) {
1030 int status = parse_pipeline_pktq_out(app, param,
1033 PARSE_ERROR((status == 0), section_name,
1038 if (strcmp(ent->name, "msgq_in") == 0) {
1039 int status = parse_pipeline_msgq_in(app, param,
1042 PARSE_ERROR((status == 0), section_name,
1047 if (strcmp(ent->name, "msgq_out") == 0) {
1048 int status = parse_pipeline_msgq_out(app, param,
1051 PARSE_ERROR((status == 0), section_name,
1056 if (strcmp(ent->name, "timer_period") == 0) {
1057 int status = parser_read_uint32(
1058 ¶m->timer_period,
1061 PARSE_ERROR((status == 0), section_name,
1066 /* pipeline type specific items */
1067 APP_CHECK((param->n_args < APP_MAX_PIPELINE_ARGS),
1068 "Parse error in section \"%s\": too many "
1069 "pipeline specified parameters", section_name);
1071 param->args_name[param->n_args] = strdup(ent->name);
1072 param->args_value[param->n_args] = strdup(ent->value);
1074 APP_CHECK((param->args_name[param->n_args] != NULL) &&
1075 (param->args_value[param->n_args] != NULL),
1076 "Parse error: no free memory");
1083 snprintf(name, sizeof(name), "MSGQ-REQ-%s", section_name);
1084 param_idx = APP_PARAM_ADD(app->msgq_params, name);
1085 PARSER_PARAM_ADD_CHECK(param_idx, app->msgq_params, name);
1086 app->msgq_params[param_idx].cpu_socket_id = param->socket_id;
1087 param->msgq_in[param->n_msgq_in++] = param_idx;
1089 snprintf(name, sizeof(name), "MSGQ-RSP-%s", section_name);
1090 param_idx = APP_PARAM_ADD(app->msgq_params, name);
1091 PARSER_PARAM_ADD_CHECK(param_idx, app->msgq_params, name);
1092 app->msgq_params[param_idx].cpu_socket_id = param->socket_id;
1093 param->msgq_out[param->n_msgq_out++] = param_idx;
1095 snprintf(name, sizeof(name), "MSGQ-REQ-CORE-s%" PRIu32 "c%" PRIu32 "%s",
1098 (param->hyper_th_id) ? "h" : "");
1099 param_idx = APP_PARAM_ADD(app->msgq_params, name);
1100 PARSER_PARAM_ADD_CHECK(param_idx, app->msgq_params, name);
1101 app->msgq_params[param_idx].cpu_socket_id = param->socket_id;
1103 snprintf(name, sizeof(name), "MSGQ-RSP-CORE-s%" PRIu32 "c%" PRIu32 "%s",
1106 (param->hyper_th_id) ? "h" : "");
1107 param_idx = APP_PARAM_ADD(app->msgq_params, name);
1108 PARSER_PARAM_ADD_CHECK(param_idx, app->msgq_params, name);
1109 app->msgq_params[param_idx].cpu_socket_id = param->socket_id;
1115 parse_mempool(struct app_params *app,
1116 const char *section_name,
1117 struct rte_cfgfile *cfg)
1119 struct app_mempool_params *param;
1120 struct rte_cfgfile_entry *entries;
1124 n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
1125 PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
1127 entries = malloc(n_entries * sizeof(struct rte_cfgfile_entry));
1128 PARSE_ERROR_MALLOC(entries != NULL);
1130 rte_cfgfile_section_entries(cfg, section_name, entries, n_entries);
1132 param_idx = APP_PARAM_ADD(app->mempool_params, section_name);
1133 PARSER_PARAM_ADD_CHECK(param_idx, app->mempool_params, section_name);
1135 param = &app->mempool_params[param_idx];
1137 for (i = 0; i < n_entries; i++) {
1138 struct rte_cfgfile_entry *ent = &entries[i];
1140 if (strcmp(ent->name, "buffer_size") == 0) {
1141 int status = parser_read_uint32(
1142 ¶m->buffer_size, ent->value);
1144 PARSE_ERROR((status == 0), section_name,
1149 if (strcmp(ent->name, "pool_size") == 0) {
1150 int status = parser_read_uint32(
1151 ¶m->pool_size, ent->value);
1153 PARSE_ERROR((status == 0), section_name,
1158 if (strcmp(ent->name, "cache_size") == 0) {
1159 int status = parser_read_uint32(
1160 ¶m->cache_size, ent->value);
1162 PARSE_ERROR((status == 0), section_name,
1167 if (strcmp(ent->name, "cpu") == 0) {
1168 int status = parser_read_uint32(
1169 ¶m->cpu_socket_id, ent->value);
1171 PARSE_ERROR((status == 0), section_name,
1177 PARSE_ERROR_INVALID(0, section_name, ent->name);
1186 parse_link(struct app_params *app,
1187 const char *section_name,
1188 struct rte_cfgfile *cfg)
1190 struct app_link_params *param;
1191 struct rte_cfgfile_entry *entries;
1193 int pci_bdf_present = 0;
1196 n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
1197 PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
1199 entries = malloc(n_entries * sizeof(struct rte_cfgfile_entry));
1200 PARSE_ERROR_MALLOC(entries != NULL);
1202 rte_cfgfile_section_entries(cfg, section_name, entries, n_entries);
1204 param_idx = APP_PARAM_ADD(app->link_params, section_name);
1205 PARSER_PARAM_ADD_CHECK(param_idx, app->link_params, section_name);
1207 param = &app->link_params[param_idx];
1209 for (i = 0; i < n_entries; i++) {
1210 struct rte_cfgfile_entry *ent = &entries[i];
1212 if (strcmp(ent->name, "promisc") == 0) {
1213 int status = parser_read_arg_bool(ent->value);
1215 PARSE_ERROR((status != -EINVAL), section_name,
1217 param->promisc = status;
1221 if (strcmp(ent->name, "arp_q") == 0) {
1222 int status = parser_read_uint32(¶m->arp_q,
1225 PARSE_ERROR((status == 0), section_name,
1230 if (strcmp(ent->name, "tcp_syn_q") == 0) {
1231 int status = parser_read_uint32(
1232 ¶m->tcp_syn_q, ent->value);
1234 PARSE_ERROR((status == 0), section_name, ent->name);
1238 if (strcmp(ent->name, "ip_local_q") == 0) {
1239 int status = parser_read_uint32(
1240 ¶m->ip_local_q, ent->value);
1242 PARSE_ERROR((status == 0), section_name,
1248 if (strcmp(ent->name, "tcp_local_q") == 0) {
1249 int status = parser_read_uint32(
1250 ¶m->tcp_local_q, ent->value);
1252 PARSE_ERROR((status == 0), section_name,
1257 if (strcmp(ent->name, "udp_local_q") == 0) {
1258 int status = parser_read_uint32(
1259 ¶m->udp_local_q, ent->value);
1261 PARSE_ERROR((status == 0), section_name,
1266 if (strcmp(ent->name, "sctp_local_q") == 0) {
1267 int status = parser_read_uint32(
1268 ¶m->sctp_local_q, ent->value);
1270 PARSE_ERROR((status == 0), section_name,
1275 if (strcmp(ent->name, "pci_bdf") == 0) {
1276 PARSE_ERROR_DUPLICATE((pci_bdf_present == 0),
1277 section_name, ent->name);
1279 snprintf(param->pci_bdf, APP_LINK_PCI_BDF_SIZE,
1281 pci_bdf_present = 1;
1286 PARSE_ERROR_INVALID(0, section_name, ent->name);
1289 /* Check for mandatory fields */
1291 PARSE_ERROR_MESSAGE((pci_bdf_present == 0),
1292 section_name, "pci_bdf",
1293 "entry not allowed (port_mask is provided)");
1295 PARSE_ERROR_MESSAGE((pci_bdf_present),
1296 section_name, "pci_bdf",
1297 "this entry is mandatory (port_mask is not "
1306 parse_rxq(struct app_params *app,
1307 const char *section_name,
1308 struct rte_cfgfile *cfg)
1310 struct app_pktq_hwq_in_params *param;
1311 struct rte_cfgfile_entry *entries;
1315 n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
1316 PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
1318 entries = malloc(n_entries * sizeof(struct rte_cfgfile_entry));
1319 PARSE_ERROR_MALLOC(entries != NULL);
1321 rte_cfgfile_section_entries(cfg, section_name, entries, n_entries);
1323 param_idx = APP_PARAM_ADD(app->hwq_in_params, section_name);
1324 PARSER_PARAM_ADD_CHECK(param_idx, app->hwq_in_params, section_name);
1326 param = &app->hwq_in_params[param_idx];
1328 for (i = 0; i < n_entries; i++) {
1329 struct rte_cfgfile_entry *ent = &entries[i];
1331 if (strcmp(ent->name, "mempool") == 0) {
1332 int status = validate_name(ent->value,
1336 PARSE_ERROR((status == 0), section_name,
1338 idx = APP_PARAM_ADD(app->mempool_params,
1340 PARSER_PARAM_ADD_CHECK(idx, app->mempool_params,
1342 param->mempool_id = idx;
1346 if (strcmp(ent->name, "size") == 0) {
1347 int status = parser_read_uint32(¶m->size,
1350 PARSE_ERROR((status == 0), section_name,
1355 if (strcmp(ent->name, "burst") == 0) {
1356 int status = parser_read_uint32(¶m->burst,
1359 PARSE_ERROR((status == 0), section_name,
1365 PARSE_ERROR_INVALID(0, section_name, ent->name);
1374 parse_txq(struct app_params *app,
1375 const char *section_name,
1376 struct rte_cfgfile *cfg)
1378 struct app_pktq_hwq_out_params *param;
1379 struct rte_cfgfile_entry *entries;
1383 n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
1384 PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
1386 entries = malloc(n_entries * sizeof(struct rte_cfgfile_entry));
1387 PARSE_ERROR_MALLOC(entries != NULL);
1389 rte_cfgfile_section_entries(cfg, section_name, entries, n_entries);
1391 param_idx = APP_PARAM_ADD(app->hwq_out_params, section_name);
1392 PARSER_PARAM_ADD_CHECK(param_idx, app->hwq_out_params, section_name);
1394 param = &app->hwq_out_params[param_idx];
1396 for (i = 0; i < n_entries; i++) {
1397 struct rte_cfgfile_entry *ent = &entries[i];
1399 if (strcmp(ent->name, "size") == 0) {
1400 int status = parser_read_uint32(¶m->size,
1403 PARSE_ERROR((status == 0), section_name,
1408 if (strcmp(ent->name, "burst") == 0) {
1409 int status = parser_read_uint32(¶m->burst,
1412 PARSE_ERROR((status == 0), section_name,
1417 if (strcmp(ent->name, "dropless") == 0) {
1418 int status = parser_read_arg_bool(ent->value);
1421 PARSE_ERROR((status != -EINVAL), section_name,
1423 param->dropless = status;
1428 PARSE_ERROR_INVALID(0, section_name, ent->name);
1437 parse_swq(struct app_params *app,
1438 const char *section_name,
1439 struct rte_cfgfile *cfg)
1441 struct app_pktq_swq_params *param;
1442 struct rte_cfgfile_entry *entries;
1444 uint32_t mtu_present = 0;
1445 uint32_t metadata_size_present = 0;
1446 uint32_t mempool_direct_present = 0;
1447 uint32_t mempool_indirect_present = 0;
1451 n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
1452 PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
1454 entries = malloc(n_entries * sizeof(struct rte_cfgfile_entry));
1455 PARSE_ERROR_MALLOC(entries != NULL);
1457 rte_cfgfile_section_entries(cfg, section_name, entries, n_entries);
1459 param_idx = APP_PARAM_ADD(app->swq_params, section_name);
1460 PARSER_PARAM_ADD_CHECK(param_idx, app->swq_params, section_name);
1462 param = &app->swq_params[param_idx];
1464 for (i = 0; i < n_entries; i++) {
1465 struct rte_cfgfile_entry *ent = &entries[i];
1467 if (strcmp(ent->name, "size") == 0) {
1468 int status = parser_read_uint32(¶m->size,
1471 PARSE_ERROR((status == 0), section_name,
1476 if (strcmp(ent->name, "burst_read") == 0) {
1477 int status = parser_read_uint32(&
1478 param->burst_read, ent->value);
1480 PARSE_ERROR((status == 0), section_name,
1485 if (strcmp(ent->name, "burst_write") == 0) {
1486 int status = parser_read_uint32(
1487 ¶m->burst_write, ent->value);
1489 PARSE_ERROR((status == 0), section_name,
1494 if (strcmp(ent->name, "dropless") == 0) {
1495 int status = parser_read_arg_bool(ent->value);
1497 PARSE_ERROR((status != -EINVAL), section_name,
1499 param->dropless = status;
1503 if (strcmp(ent->name, "n_retries") == 0) {
1504 int status = parser_read_uint64(¶m->n_retries,
1507 PARSE_ERROR((status == 0), section_name,
1512 if (strcmp(ent->name, "cpu") == 0) {
1513 int status = parser_read_uint32(
1514 ¶m->cpu_socket_id, ent->value);
1516 PARSE_ERROR((status == 0), section_name, ent->name);
1520 if (strcmp(ent->name, "ipv4_frag") == 0) {
1521 int status = parser_read_arg_bool(ent->value);
1523 PARSE_ERROR((status != -EINVAL), section_name,
1526 param->ipv4_frag = status;
1527 if (param->mtu == 0)
1533 if (strcmp(ent->name, "ipv6_frag") == 0) {
1534 int status = parser_read_arg_bool(ent->value);
1536 PARSE_ERROR((status != -EINVAL), section_name,
1538 param->ipv6_frag = status;
1539 if (param->mtu == 0)
1544 if (strcmp(ent->name, "ipv4_ras") == 0) {
1545 int status = parser_read_arg_bool(ent->value);
1547 PARSE_ERROR((status != -EINVAL), section_name,
1549 param->ipv4_ras = status;
1553 if (strcmp(ent->name, "ipv6_ras") == 0) {
1554 int status = parser_read_arg_bool(ent->value);
1556 PARSE_ERROR((status != -EINVAL), section_name,
1558 param->ipv6_ras = status;
1562 if (strcmp(ent->name, "mtu") == 0) {
1563 int status = parser_read_uint32(¶m->mtu,
1566 PARSE_ERROR((status == 0), section_name,
1572 if (strcmp(ent->name, "metadata_size") == 0) {
1573 int status = parser_read_uint32(
1574 ¶m->metadata_size, ent->value);
1576 PARSE_ERROR((status == 0), section_name,
1578 metadata_size_present = 1;
1582 if (strcmp(ent->name, "mempool_direct") == 0) {
1583 int status = validate_name(ent->value,
1587 PARSE_ERROR((status == 0), section_name,
1590 idx = APP_PARAM_ADD(app->mempool_params,
1592 PARSER_PARAM_ADD_CHECK(idx, app->mempool_params,
1594 param->mempool_direct_id = idx;
1595 mempool_direct_present = 1;
1599 if (strcmp(ent->name, "mempool_indirect") == 0) {
1600 int status = validate_name(ent->value,
1604 PARSE_ERROR((status == 0), section_name,
1606 idx = APP_PARAM_ADD(app->mempool_params,
1608 PARSER_PARAM_ADD_CHECK(idx, app->mempool_params,
1610 param->mempool_indirect_id = idx;
1611 mempool_indirect_present = 1;
1616 PARSE_ERROR_INVALID(0, section_name, ent->name);
1619 APP_CHECK(((mtu_present) &&
1620 ((param->ipv4_frag == 1) || (param->ipv6_frag == 1))),
1621 "Parse error in section \"%s\": IPv4/IPv6 fragmentation "
1622 "is off, therefore entry \"mtu\" is not allowed",
1625 APP_CHECK(((metadata_size_present) &&
1626 ((param->ipv4_frag == 1) || (param->ipv6_frag == 1))),
1627 "Parse error in section \"%s\": IPv4/IPv6 fragmentation "
1628 "is off, therefore entry \"metadata_size\" is "
1629 "not allowed", section_name);
1631 APP_CHECK(((mempool_direct_present) &&
1632 ((param->ipv4_frag == 1) || (param->ipv6_frag == 1))),
1633 "Parse error in section \"%s\": IPv4/IPv6 fragmentation "
1634 "is off, therefore entry \"mempool_direct\" is "
1635 "not allowed", section_name);
1637 APP_CHECK(((mempool_indirect_present) &&
1638 ((param->ipv4_frag == 1) || (param->ipv6_frag == 1))),
1639 "Parse error in section \"%s\": IPv4/IPv6 fragmentation "
1640 "is off, therefore entry \"mempool_indirect\" is "
1641 "not allowed", section_name);
1649 parse_tm(struct app_params *app,
1650 const char *section_name,
1651 struct rte_cfgfile *cfg)
1653 struct app_pktq_tm_params *param;
1654 struct rte_cfgfile_entry *entries;
1658 n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
1659 PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
1661 entries = malloc(n_entries * sizeof(struct rte_cfgfile_entry));
1662 PARSE_ERROR_MALLOC(entries != NULL);
1664 rte_cfgfile_section_entries(cfg, section_name, entries, n_entries);
1666 param_idx = APP_PARAM_ADD(app->tm_params, section_name);
1667 PARSER_PARAM_ADD_CHECK(param_idx, app->tm_params, section_name);
1669 param = &app->tm_params[param_idx];
1671 for (i = 0; i < n_entries; i++) {
1672 struct rte_cfgfile_entry *ent = &entries[i];
1674 if (strcmp(ent->name, "cfg") == 0) {
1675 param->file_name = strdup(ent->value);
1676 PARSE_ERROR_MALLOC(param->file_name != NULL);
1680 if (strcmp(ent->name, "burst_read") == 0) {
1681 int status = parser_read_uint32(
1682 ¶m->burst_read, ent->value);
1684 PARSE_ERROR((status == 0), section_name,
1689 if (strcmp(ent->name, "burst_write") == 0) {
1690 int status = parser_read_uint32(
1691 ¶m->burst_write, ent->value);
1693 PARSE_ERROR((status == 0), section_name,
1699 PARSE_ERROR_INVALID(0, section_name, ent->name);
1708 parse_source(struct app_params *app,
1709 const char *section_name,
1710 struct rte_cfgfile *cfg)
1712 struct app_pktq_source_params *param;
1713 struct rte_cfgfile_entry *entries;
1716 uint32_t pcap_file_present = 0;
1717 uint32_t pcap_size_present = 0;
1719 n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
1720 PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
1722 entries = malloc(n_entries * sizeof(struct rte_cfgfile_entry));
1723 PARSE_ERROR_MALLOC(entries != NULL);
1725 rte_cfgfile_section_entries(cfg, section_name, entries, n_entries);
1727 param_idx = APP_PARAM_ADD(app->source_params, section_name);
1728 PARSER_PARAM_ADD_CHECK(param_idx, app->source_params, section_name);
1730 param = &app->source_params[param_idx];
1732 for (i = 0; i < n_entries; i++) {
1733 struct rte_cfgfile_entry *ent = &entries[i];
1735 if (strcmp(ent->name, "mempool") == 0) {
1736 int status = validate_name(ent->value,
1740 PARSE_ERROR((status == 0), section_name,
1742 idx = APP_PARAM_ADD(app->mempool_params,
1744 PARSER_PARAM_ADD_CHECK(idx, app->mempool_params,
1746 param->mempool_id = idx;
1750 if (strcmp(ent->name, "burst") == 0) {
1751 int status = parser_read_uint32(¶m->burst,
1754 PARSE_ERROR((status == 0), section_name,
1759 if (strcmp(ent->name, "pcap_file_rd") == 0) {
1760 PARSE_ERROR_DUPLICATE((pcap_file_present == 0),
1761 section_name, ent->name);
1763 param->file_name = strdup(ent->value);
1765 PARSE_ERROR_MALLOC(param->file_name != NULL);
1766 pcap_file_present = 1;
1771 if (strcmp(ent->name, "pcap_bytes_rd_per_pkt") == 0) {
1774 PARSE_ERROR_DUPLICATE((pcap_size_present == 0),
1775 section_name, ent->name);
1777 status = parser_read_uint32(
1778 ¶m->n_bytes_per_pkt, ent->value);
1780 PARSE_ERROR((status == 0), section_name,
1782 pcap_size_present = 1;
1788 PARSE_ERROR_INVALID(0, section_name, ent->name);
1797 parse_sink(struct app_params *app,
1798 const char *section_name,
1799 struct rte_cfgfile *cfg)
1801 struct app_pktq_sink_params *param;
1802 struct rte_cfgfile_entry *entries;
1805 uint32_t pcap_file_present = 0;
1806 uint32_t pcap_n_pkt_present = 0;
1808 n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
1809 PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
1811 entries = malloc(n_entries * sizeof(struct rte_cfgfile_entry));
1812 PARSE_ERROR_MALLOC(entries != NULL);
1814 rte_cfgfile_section_entries(cfg, section_name, entries, n_entries);
1816 param_idx = APP_PARAM_ADD(app->sink_params, section_name);
1817 PARSER_PARAM_ADD_CHECK(param_idx, app->sink_params, section_name);
1819 param = &app->sink_params[param_idx];
1821 for (i = 0; i < n_entries; i++) {
1822 struct rte_cfgfile_entry *ent = &entries[i];
1824 if (strcmp(ent->name, "pcap_file_wr") == 0) {
1825 PARSE_ERROR_DUPLICATE((pcap_file_present == 0),
1826 section_name, ent->name);
1828 param->file_name = strdup(ent->value);
1830 PARSE_ERROR_MALLOC((param->file_name != NULL));
1835 if (strcmp(ent->name, "pcap_n_pkt_wr") == 0) {
1838 PARSE_ERROR_DUPLICATE((pcap_n_pkt_present == 0),
1839 section_name, ent->name);
1841 status = parser_read_uint32(
1842 ¶m->n_pkts_to_dump, ent->value);
1844 PARSE_ERROR((status == 0), section_name,
1851 PARSE_ERROR_INVALID(0, section_name, ent->name);
1860 parse_msgq_req_pipeline(struct app_params *app,
1861 const char *section_name,
1862 struct rte_cfgfile *cfg)
1864 struct app_msgq_params *param;
1865 struct rte_cfgfile_entry *entries;
1869 n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
1870 PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
1872 entries = malloc(n_entries * sizeof(struct rte_cfgfile_entry));
1873 PARSE_ERROR_MALLOC(entries != NULL);
1875 rte_cfgfile_section_entries(cfg, section_name, entries, n_entries);
1877 param_idx = APP_PARAM_ADD(app->msgq_params, section_name);
1878 PARSER_PARAM_ADD_CHECK(param_idx, app->msgq_params, section_name);
1880 param = &app->msgq_params[param_idx];
1882 for (i = 0; i < n_entries; i++) {
1883 struct rte_cfgfile_entry *ent = &entries[i];
1885 if (strcmp(ent->name, "size") == 0) {
1886 int status = parser_read_uint32(¶m->size,
1889 PARSE_ERROR((status == 0), section_name,
1895 PARSE_ERROR_INVALID(0, section_name, ent->name);
1903 parse_msgq_rsp_pipeline(struct app_params *app,
1904 const char *section_name,
1905 struct rte_cfgfile *cfg)
1907 struct app_msgq_params *param;
1908 struct rte_cfgfile_entry *entries;
1912 n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
1913 PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
1915 entries = malloc(n_entries * sizeof(struct rte_cfgfile_entry));
1916 PARSE_ERROR_MALLOC(entries != NULL);
1918 rte_cfgfile_section_entries(cfg, section_name, entries, n_entries);
1920 param_idx = APP_PARAM_ADD(app->msgq_params, section_name);
1921 PARSER_PARAM_ADD_CHECK(param_idx, app->msgq_params, section_name);
1923 param = &app->msgq_params[param_idx];
1925 for (i = 0; i < n_entries; i++) {
1926 struct rte_cfgfile_entry *ent = &entries[i];
1928 if (strcmp(ent->name, "size") == 0) {
1929 int status = parser_read_uint32(¶m->size,
1932 PARSE_ERROR((status == 0), section_name,
1938 PARSE_ERROR_INVALID(0, section_name, ent->name);
1947 parse_msgq(struct app_params *app,
1948 const char *section_name,
1949 struct rte_cfgfile *cfg)
1951 struct app_msgq_params *param;
1952 struct rte_cfgfile_entry *entries;
1956 n_entries = rte_cfgfile_section_num_entries(cfg, section_name);
1957 PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name);
1959 entries = malloc(n_entries * sizeof(struct rte_cfgfile_entry));
1960 PARSE_ERROR_MALLOC(entries != NULL);
1962 rte_cfgfile_section_entries(cfg, section_name, entries, n_entries);
1964 param_idx = APP_PARAM_ADD(app->msgq_params, section_name);
1965 PARSER_PARAM_ADD_CHECK(param_idx, app->msgq_params, section_name);
1967 param = &app->msgq_params[param_idx];
1969 for (i = 0; i < n_entries; i++) {
1970 struct rte_cfgfile_entry *ent = &entries[i];
1972 if (strcmp(ent->name, "size") == 0) {
1973 int status = parser_read_uint32(¶m->size,
1976 PARSE_ERROR((status == 0), section_name,
1981 if (strcmp(ent->name, "cpu") == 0) {
1982 int status = parser_read_uint32(
1983 ¶m->cpu_socket_id, ent->value);
1985 PARSE_ERROR((status == 0), section_name,
1991 PARSE_ERROR_INVALID(0, section_name, ent->name);
1999 typedef void (*config_section_load)(struct app_params *p,
2000 const char *section_name,
2001 struct rte_cfgfile *cfg);
2003 struct config_section {
2004 const char prefix[CFG_NAME_LEN];
2006 config_section_load load;
2009 static const struct config_section cfg_file_scheme[] = {
2010 {"EAL", 0, parse_eal},
2011 {"PIPELINE", 1, parse_pipeline},
2012 {"MEMPOOL", 1, parse_mempool},
2013 {"LINK", 1, parse_link},
2014 {"RXQ", 2, parse_rxq},
2015 {"TXQ", 2, parse_txq},
2016 {"SWQ", 1, parse_swq},
2017 {"TM", 1, parse_tm},
2018 {"SOURCE", 1, parse_source},
2019 {"SINK", 1, parse_sink},
2020 {"MSGQ-REQ-PIPELINE", 1, parse_msgq_req_pipeline},
2021 {"MSGQ-RSP-PIPELINE", 1, parse_msgq_rsp_pipeline},
2022 {"MSGQ", 1, parse_msgq},
2026 create_implicit_mempools(struct app_params *app)
2030 idx = APP_PARAM_ADD(app->mempool_params, "MEMPOOL0");
2031 PARSER_PARAM_ADD_CHECK(idx, app->mempool_params, "start-up");
2035 create_implicit_links_from_port_mask(struct app_params *app,
2038 uint32_t pmd_id, link_id;
2041 for (pmd_id = 0; pmd_id < RTE_MAX_ETHPORTS; pmd_id++) {
2042 char name[APP_PARAM_NAME_SIZE];
2045 if ((port_mask & (1LLU << pmd_id)) == 0)
2048 snprintf(name, sizeof(name), "LINK%" PRIu32, link_id);
2049 idx = APP_PARAM_ADD(app->link_params, name);
2050 PARSER_PARAM_ADD_CHECK(idx, app->link_params, name);
2052 app->link_params[idx].pmd_id = pmd_id;
2058 assign_link_pmd_id_from_pci_bdf(struct app_params *app)
2062 for (i = 0; i < app->n_links; i++) {
2063 struct app_link_params *link = &app->link_params[i];
2070 app_config_parse(struct app_params *app, const char *file_name)
2072 struct rte_cfgfile *cfg;
2073 char **section_names;
2074 int i, j, sect_count;
2076 /* Implicit mempools */
2077 create_implicit_mempools(app);
2081 create_implicit_links_from_port_mask(app, app->port_mask);
2083 /* Load application configuration file */
2084 cfg = rte_cfgfile_load(file_name, 0);
2085 APP_CHECK((cfg != NULL), "Parse error: Unable to load config "
2086 "file %s", file_name);
2088 sect_count = rte_cfgfile_num_sections(cfg, NULL, 0);
2089 APP_CHECK((sect_count > 0), "Parse error: number of sections "
2090 "in file \"%s\" return %d", file_name,
2093 section_names = malloc(sect_count * sizeof(char *));
2094 PARSE_ERROR_MALLOC(section_names != NULL);
2096 for (i = 0; i < sect_count; i++)
2097 section_names[i] = malloc(CFG_NAME_LEN);
2099 rte_cfgfile_sections(cfg, section_names, sect_count);
2101 for (i = 0; i < sect_count; i++) {
2102 const struct config_section *sch_s;
2103 int len, cfg_name_len;
2105 cfg_name_len = strlen(section_names[i]);
2107 /* Find section type */
2108 for (j = 0; j < (int)RTE_DIM(cfg_file_scheme); j++) {
2109 sch_s = &cfg_file_scheme[j];
2110 len = strlen(sch_s->prefix);
2112 if (cfg_name_len < len)
2115 /* After section name we expect only '\0' or digit or
2116 * digit dot digit, so protect against false matching,
2117 * for example: "ABC" should match section name
2118 * "ABC0.0", but it should not match section_name
2121 if ((section_names[i][len] != '\0') &&
2122 !isdigit(section_names[i][len]))
2125 if (strncmp(sch_s->prefix, section_names[i], len) == 0)
2129 APP_CHECK(j < (int)RTE_DIM(cfg_file_scheme),
2130 "Parse error: unknown section %s",
2133 APP_CHECK(validate_name(section_names[i],
2135 sch_s->numbers) == 0,
2136 "Parse error: invalid section name \"%s\"",
2139 sch_s->load(app, section_names[i], cfg);
2142 for (i = 0; i < sect_count; i++)
2143 free(section_names[i]);
2145 free(section_names);
2147 rte_cfgfile_close(cfg);
2149 APP_PARAM_COUNT(app->mempool_params, app->n_mempools);
2150 APP_PARAM_COUNT(app->link_params, app->n_links);
2151 APP_PARAM_COUNT(app->hwq_in_params, app->n_pktq_hwq_in);
2152 APP_PARAM_COUNT(app->hwq_out_params, app->n_pktq_hwq_out);
2153 APP_PARAM_COUNT(app->swq_params, app->n_pktq_swq);
2154 APP_PARAM_COUNT(app->tm_params, app->n_pktq_tm);
2155 APP_PARAM_COUNT(app->source_params, app->n_pktq_source);
2156 APP_PARAM_COUNT(app->sink_params, app->n_pktq_sink);
2157 APP_PARAM_COUNT(app->msgq_params, app->n_msgq);
2158 APP_PARAM_COUNT(app->pipeline_params, app->n_pipelines);
2160 if (app->port_mask == 0)
2161 assign_link_pmd_id_from_pci_bdf(app);
2163 /* Save configuration to output file */
2164 app_config_save(app, app->output_file);
2166 /* Load TM configuration files */
2167 app_config_parse_tm(app);
2173 save_eal_params(struct app_params *app, FILE *f)
2175 struct app_eal_params *p = &app->eal_params;
2178 fprintf(f, "[EAL]\n");
2181 fprintf(f, "%s = %s\n", "lcores", p->coremap);
2183 if (p->master_lcore_present)
2184 fprintf(f, "%s = %" PRIu32 "\n",
2185 "master_lcore", p->master_lcore);
2187 fprintf(f, "%s = %" PRIu32 "\n", "n", p->channels);
2189 if (p->memory_present)
2190 fprintf(f, "%s = %" PRIu32 "\n", "m", p->memory);
2192 if (p->ranks_present)
2193 fprintf(f, "%s = %" PRIu32 "\n", "r", p->ranks);
2195 for (i = 0; i < APP_MAX_LINKS; i++) {
2196 if (p->pci_blacklist[i] == NULL)
2199 fprintf(f, "%s = %s\n", "pci_blacklist",
2200 p->pci_blacklist[i]);
2203 for (i = 0; i < APP_MAX_LINKS; i++) {
2204 if (p->pci_whitelist[i] == NULL)
2207 fprintf(f, "%s = %s\n", "pci_whitelist",
2208 p->pci_whitelist[i]);
2211 for (i = 0; i < APP_MAX_LINKS; i++) {
2212 if (p->vdev[i] == NULL)
2215 fprintf(f, "%s = %s\n", "vdev",
2219 if (p->vmware_tsc_map_present)
2220 fprintf(f, "%s = %s\n", "vmware_tsc_map",
2221 (p->vmware_tsc_map) ? "yes" : "no");
2224 fprintf(f, "%s = %s\n", "proc_type", p->proc_type);
2227 fprintf(f, "%s = %s\n", "syslog", p->syslog);
2229 if (p->log_level_present)
2230 fprintf(f, "%s = %" PRIu32 "\n", "log_level", p->log_level);
2232 if (p->version_present)
2233 fprintf(f, "%s = %s\n", "v", (p->version) ? "yes" : "no");
2235 if (p->help_present)
2236 fprintf(f, "%s = %s\n", "help", (p->help) ? "yes" : "no");
2238 if (p->no_huge_present)
2239 fprintf(f, "%s = %s\n", "no_huge", (p->no_huge) ? "yes" : "no");
2241 if (p->no_pci_present)
2242 fprintf(f, "%s = %s\n", "no_pci", (p->no_pci) ? "yes" : "no");
2244 if (p->no_hpet_present)
2245 fprintf(f, "%s = %s\n", "no_hpet", (p->no_hpet) ? "yes" : "no");
2247 if (p->no_shconf_present)
2248 fprintf(f, "%s = %s\n", "no_shconf",
2249 (p->no_shconf) ? "yes" : "no");
2252 fprintf(f, "%s = %s\n", "d", p->add_driver);
2255 fprintf(f, "%s = %s\n", "socket_mem", p->socket_mem);
2258 fprintf(f, "%s = %s\n", "huge_dir", p->huge_dir);
2261 fprintf(f, "%s = %s\n", "file_prefix", p->file_prefix);
2263 if (p->base_virtaddr)
2264 fprintf(f, "%s = %s\n", "base_virtaddr", p->base_virtaddr);
2266 if (p->create_uio_dev_present)
2267 fprintf(f, "%s = %s\n", "create_uio_dev",
2268 (p->create_uio_dev) ? "yes" : "no");
2271 fprintf(f, "%s = %s\n", "vfio_intr", p->vfio_intr);
2273 if (p->xen_dom0_present)
2274 fprintf(f, "%s = %s\n", "xen_dom0",
2275 (p->xen_dom0) ? "yes" : "no");
2281 save_mempool_params(struct app_params *app, FILE *f)
2283 struct app_mempool_params *p;
2286 count = RTE_DIM(app->mempool_params);
2287 for (i = 0; i < count; i++) {
2288 p = &app->mempool_params[i];
2289 if (!APP_PARAM_VALID(p))
2292 fprintf(f, "[%s]\n", p->name);
2293 fprintf(f, "%s = %" PRIu32 "\n", "buffer_size", p->buffer_size);
2294 fprintf(f, "%s = %" PRIu32 "\n", "pool_size", p->pool_size);
2295 fprintf(f, "%s = %" PRIu32 "\n", "cache_size", p->cache_size);
2296 fprintf(f, "%s = %" PRIu32 "\n", "cpu", p->cpu_socket_id);
2303 save_links_params(struct app_params *app, FILE *f)
2305 struct app_link_params *p;
2308 count = RTE_DIM(app->link_params);
2309 for (i = 0; i < count; i++) {
2310 p = &app->link_params[i];
2311 if (!APP_PARAM_VALID(p))
2314 fprintf(f, "[%s]\n", p->name);
2315 fprintf(f, "; %s = %" PRIu32 "\n", "pmd_id", p->pmd_id);
2316 fprintf(f, "%s = %s\n", "promisc", p->promisc ? "yes" : "no");
2317 fprintf(f, "%s = %" PRIu32 "\n", "arp_q", p->arp_q);
2318 fprintf(f, "%s = %" PRIu32 "\n", "tcp_syn_q",
2320 fprintf(f, "%s = %" PRIu32 "\n", "ip_local_q", p->ip_local_q);
2321 fprintf(f, "%s = %" PRIu32 "\n", "tcp_local_q", p->tcp_local_q);
2322 fprintf(f, "%s = %" PRIu32 "\n", "udp_local_q", p->udp_local_q);
2323 fprintf(f, "%s = %" PRIu32 "\n", "sctp_local_q",
2326 if (strlen(p->pci_bdf))
2327 fprintf(f, "%s = %s\n", "pci_bdf", p->pci_bdf);
2334 save_rxq_params(struct app_params *app, FILE *f)
2336 struct app_pktq_hwq_in_params *p;
2339 count = RTE_DIM(app->hwq_in_params);
2340 for (i = 0; i < count; i++) {
2341 p = &app->hwq_in_params[i];
2342 if (!APP_PARAM_VALID(p))
2345 fprintf(f, "[%s]\n", p->name);
2346 fprintf(f, "%s = %s\n",
2348 app->mempool_params[p->mempool_id].name);
2349 fprintf(f, "%s = %" PRIu32 "\n", "size", p->size);
2350 fprintf(f, "%s = %" PRIu32 "\n", "burst", p->burst);
2357 save_txq_params(struct app_params *app, FILE *f)
2359 struct app_pktq_hwq_out_params *p;
2362 count = RTE_DIM(app->hwq_out_params);
2363 for (i = 0; i < count; i++) {
2364 p = &app->hwq_out_params[i];
2365 if (!APP_PARAM_VALID(p))
2368 fprintf(f, "[%s]\n", p->name);
2369 fprintf(f, "%s = %" PRIu32 "\n", "size", p->size);
2370 fprintf(f, "%s = %" PRIu32 "\n", "burst", p->burst);
2371 fprintf(f, "%s = %s\n",
2373 p->dropless ? "yes" : "no");
2380 save_swq_params(struct app_params *app, FILE *f)
2382 struct app_pktq_swq_params *p;
2385 count = RTE_DIM(app->swq_params);
2386 for (i = 0; i < count; i++) {
2387 p = &app->swq_params[i];
2388 if (!APP_PARAM_VALID(p))
2391 fprintf(f, "[%s]\n", p->name);
2392 fprintf(f, "%s = %" PRIu32 "\n", "size", p->size);
2393 fprintf(f, "%s = %" PRIu32 "\n", "burst_read", p->burst_read);
2394 fprintf(f, "%s = %" PRIu32 "\n", "burst_write", p->burst_write);
2395 fprintf(f, "%s = %s\n", "dropless", p->dropless ? "yes" : "no");
2396 fprintf(f, "%s = %" PRIu64 "\n", "n_retries", p->n_retries);
2397 fprintf(f, "%s = %" PRIu32 "\n", "cpu", p->cpu_socket_id);
2398 fprintf(f, "%s = %s\n", "ipv4_frag", p->ipv4_frag ? "yes" : "no");
2399 fprintf(f, "%s = %s\n", "ipv6_frag", p->ipv6_frag ? "yes" : "no");
2400 fprintf(f, "%s = %s\n", "ipv4_ras", p->ipv4_ras ? "yes" : "no");
2401 fprintf(f, "%s = %s\n", "ipv6_ras", p->ipv6_ras ? "yes" : "no");
2402 if ((p->ipv4_frag == 1) || (p->ipv6_frag == 1)) {
2403 fprintf(f, "%s = %" PRIu32 "\n", "mtu", p->mtu);
2404 fprintf(f, "%s = %" PRIu32 "\n", "metadata_size", p->metadata_size);
2405 fprintf(f, "%s = %s\n",
2407 app->mempool_params[p->mempool_direct_id].name);
2408 fprintf(f, "%s = %s\n",
2410 app->mempool_params[p->mempool_indirect_id].name);
2418 save_tm_params(struct app_params *app, FILE *f)
2420 struct app_pktq_tm_params *p;
2423 count = RTE_DIM(app->tm_params);
2424 for (i = 0; i < count; i++) {
2425 p = &app->tm_params[i];
2426 if (!APP_PARAM_VALID(p))
2429 fprintf(f, "[%s]\n", p->name);
2430 fprintf(f, "%s = %s\n", "cfg", p->file_name);
2431 fprintf(f, "%s = %" PRIu32 "\n", "burst_read", p->burst_read);
2432 fprintf(f, "%s = %" PRIu32 "\n", "burst_write", p->burst_write);
2439 save_source_params(struct app_params *app, FILE *f)
2441 struct app_pktq_source_params *p;
2444 count = RTE_DIM(app->source_params);
2445 for (i = 0; i < count; i++) {
2446 p = &app->source_params[i];
2447 if (!APP_PARAM_VALID(p))
2450 fprintf(f, "[%s]\n", p->name);
2451 fprintf(f, "%s = %s\n",
2453 app->mempool_params[p->mempool_id].name);
2454 fprintf(f, "%s = %" PRIu32 "\n", "burst", p->burst);
2455 fprintf(f, "%s = %s\n", "pcap_file_rd", p->file_name);
2456 fprintf(f, "%s = %" PRIu32 "\n", "pcap_bytes_rd_per_pkt",
2457 p->n_bytes_per_pkt);
2463 save_sink_params(struct app_params *app, FILE *f)
2465 struct app_pktq_sink_params *p;
2468 count = RTE_DIM(app->sink_params);
2469 for (i = 0; i < count; i++) {
2470 p = &app->sink_params[i];
2471 if (!APP_PARAM_VALID(p))
2474 fprintf(f, "[%s]\n", p->name);
2475 fprintf(f, "%s = %s\n", "pcap_file_wr", p->file_name);
2476 fprintf(f, "%s = %" PRIu32 "\n",
2477 "pcap_n_pkt_wr", p->n_pkts_to_dump);
2483 save_msgq_params(struct app_params *app, FILE *f)
2485 struct app_msgq_params *p;
2488 count = RTE_DIM(app->msgq_params);
2489 for (i = 0; i < count; i++) {
2490 p = &app->msgq_params[i];
2491 if (!APP_PARAM_VALID(p))
2494 fprintf(f, "[%s]\n", p->name);
2495 fprintf(f, "%s = %" PRIu32 "\n", "size", p->size);
2496 fprintf(f, "%s = %" PRIu32 "\n", "cpu", p->cpu_socket_id);
2503 save_pipeline_params(struct app_params *app, FILE *f)
2507 count = RTE_DIM(app->pipeline_params);
2508 for (i = 0; i < count; i++) {
2509 struct app_pipeline_params *p = &app->pipeline_params[i];
2511 if (!APP_PARAM_VALID(p))
2515 fprintf(f, "[%s]\n", p->name);
2518 fprintf(f, "type = %s\n", p->type);
2521 fprintf(f, "core = s%" PRIu32 "c%" PRIu32 "%s\n",
2524 (p->hyper_th_id) ? "h" : "");
2530 fprintf(f, "pktq_in =");
2531 for (j = 0; j < p->n_pktq_in; j++) {
2532 struct app_pktq_in_params *pp = &p->pktq_in[j];
2536 case APP_PKTQ_IN_HWQ:
2537 name = app->hwq_in_params[pp->id].name;
2539 case APP_PKTQ_IN_SWQ:
2540 name = app->swq_params[pp->id].name;
2542 case APP_PKTQ_IN_TM:
2543 name = app->tm_params[pp->id].name;
2545 case APP_PKTQ_IN_SOURCE:
2546 name = app->source_params[pp->id].name;
2549 APP_CHECK(0, "System error "
2550 "occurred while saving "
2551 "parameter to file");
2554 fprintf(f, " %s", name);
2560 if (p->n_pktq_out) {
2563 fprintf(f, "pktq_out =");
2564 for (j = 0; j < p->n_pktq_out; j++) {
2565 struct app_pktq_out_params *pp =
2570 case APP_PKTQ_OUT_HWQ:
2571 name = app->hwq_out_params[pp->id].name;
2573 case APP_PKTQ_OUT_SWQ:
2574 name = app->swq_params[pp->id].name;
2576 case APP_PKTQ_OUT_TM:
2577 name = app->tm_params[pp->id].name;
2579 case APP_PKTQ_OUT_SINK:
2580 name = app->sink_params[pp->id].name;
2583 APP_CHECK(0, "System error "
2584 "occurred while saving "
2585 "parameter to file");
2588 fprintf(f, " %s", name);
2597 fprintf(f, "msgq_in =");
2598 for (j = 0; j < p->n_msgq_in; j++) {
2599 uint32_t id = p->msgq_in[j];
2600 char *name = app->msgq_params[id].name;
2602 fprintf(f, " %s", name);
2608 if (p->n_msgq_out) {
2611 fprintf(f, "msgq_out =");
2612 for (j = 0; j < p->n_msgq_out; j++) {
2613 uint32_t id = p->msgq_out[j];
2614 char *name = app->msgq_params[id].name;
2616 fprintf(f, " %s", name);
2622 fprintf(f, "timer_period = %" PRIu32 "\n", p->timer_period);
2628 for (j = 0; j < p->n_args; j++)
2629 fprintf(f, "%s = %s\n", p->args_name[j],
2638 app_config_save(struct app_params *app, const char *file_name)
2641 char *name, *dir_name;
2644 name = strdup(file_name);
2645 dir_name = dirname(name);
2646 status = access(dir_name, W_OK);
2647 APP_CHECK((status == 0),
2648 "Error: need write access privilege to directory "
2649 "\"%s\" to save configuration\n", dir_name);
2651 file = fopen(file_name, "w");
2652 APP_CHECK((file != NULL),
2653 "Error: failed to save configuration to file \"%s\"",
2656 save_eal_params(app, file);
2657 save_pipeline_params(app, file);
2658 save_mempool_params(app, file);
2659 save_links_params(app, file);
2660 save_rxq_params(app, file);
2661 save_txq_params(app, file);
2662 save_swq_params(app, file);
2663 save_tm_params(app, file);
2664 save_source_params(app, file);
2665 save_sink_params(app, file);
2666 save_msgq_params(app, file);
2673 app_config_init(struct app_params *app)
2677 memcpy(app, &app_params_default, sizeof(struct app_params));
2679 /* configure default_source_params */
2680 default_source_params.file_name = strdup("./config/packets.pcap");
2681 PARSE_ERROR_MALLOC(default_source_params.file_name != NULL);
2683 for (i = 0; i < RTE_DIM(app->mempool_params); i++)
2684 memcpy(&app->mempool_params[i],
2685 &mempool_params_default,
2686 sizeof(struct app_mempool_params));
2688 for (i = 0; i < RTE_DIM(app->link_params); i++)
2689 memcpy(&app->link_params[i],
2690 &link_params_default,
2691 sizeof(struct app_link_params));
2693 for (i = 0; i < RTE_DIM(app->hwq_in_params); i++)
2694 memcpy(&app->hwq_in_params[i],
2695 &default_hwq_in_params,
2696 sizeof(default_hwq_in_params));
2698 for (i = 0; i < RTE_DIM(app->hwq_out_params); i++)
2699 memcpy(&app->hwq_out_params[i],
2700 &default_hwq_out_params,
2701 sizeof(default_hwq_out_params));
2703 for (i = 0; i < RTE_DIM(app->swq_params); i++)
2704 memcpy(&app->swq_params[i],
2705 &default_swq_params,
2706 sizeof(default_swq_params));
2708 for (i = 0; i < RTE_DIM(app->tm_params); i++)
2709 memcpy(&app->tm_params[i],
2711 sizeof(default_tm_params));
2713 for (i = 0; i < RTE_DIM(app->source_params); i++)
2714 memcpy(&app->source_params[i],
2715 &default_source_params,
2716 sizeof(default_source_params));
2718 for (i = 0; i < RTE_DIM(app->sink_params); i++)
2719 memcpy(&app->sink_params[i],
2720 &default_sink_params,
2721 sizeof(default_sink_params));
2723 for (i = 0; i < RTE_DIM(app->msgq_params); i++)
2724 memcpy(&app->msgq_params[i],
2725 &default_msgq_params,
2726 sizeof(default_msgq_params));
2728 for (i = 0; i < RTE_DIM(app->pipeline_params); i++)
2729 memcpy(&app->pipeline_params[i],
2730 &default_pipeline_params,
2731 sizeof(default_pipeline_params));
2737 filenamedup(const char *filename, const char *suffix)
2739 char *s = malloc(strlen(filename) + strlen(suffix) + 1);
2744 sprintf(s, "%s%s", filename, suffix);
2749 app_config_args(struct app_params *app, int argc, char **argv)
2751 const char *optname;
2752 int opt, option_index;
2753 int f_present, s_present, p_present, l_present;
2754 int preproc_present, preproc_params_present;
2757 static struct option lgopts[] = {
2758 { "preproc", 1, 0, 0 },
2759 { "preproc-args", 1, 0, 0 },
2763 /* Copy application name */
2764 strncpy(app->app_name, argv[0], APP_APPNAME_SIZE - 1);
2770 preproc_present = 0;
2771 preproc_params_present = 0;
2773 while ((opt = getopt_long(argc, argv, "f:s:p:l:", lgopts,
2774 &option_index)) != EOF)
2778 rte_panic("Error: Config file is provided "
2779 "more than once\n");
2782 if (!strlen(optarg))
2783 rte_panic("Error: Config file name is null\n");
2785 app->config_file = strdup(optarg);
2786 if (app->config_file == NULL)
2787 rte_panic("Error: Memory allocation failure\n");
2793 rte_panic("Error: Script file is provided "
2794 "more than once\n");
2797 if (!strlen(optarg))
2798 rte_panic("Error: Script file name is null\n");
2800 app->script_file = strdup(optarg);
2801 if (app->script_file == NULL)
2802 rte_panic("Error: Memory allocation failure\n");
2808 rte_panic("Error: PORT_MASK is provided "
2809 "more than once\n");
2812 if ((sscanf(optarg, "%" SCNx64 "%n", &app->port_mask,
2814 ((size_t) scaned != strlen(optarg)))
2815 rte_panic("Error: PORT_MASK is not "
2816 "a hexadecimal integer\n");
2818 if (app->port_mask == 0)
2819 rte_panic("Error: PORT_MASK is null\n");
2825 rte_panic("Error: LOG_LEVEL is provided "
2826 "more than once\n");
2829 if ((sscanf(optarg, "%" SCNu32 "%n", &app->log_level,
2831 ((size_t) scaned != strlen(optarg)) ||
2832 (app->log_level >= APP_LOG_LEVELS))
2833 rte_panic("Error: LOG_LEVEL invalid value\n");
2838 optname = lgopts[option_index].name;
2840 if (strcmp(optname, "preproc") == 0) {
2841 if (preproc_present)
2842 rte_panic("Error: Preprocessor argument "
2843 "is provided more than once\n");
2844 preproc_present = 1;
2846 app->preproc = strdup(optarg);
2850 if (strcmp(optname, "preproc-args") == 0) {
2851 if (preproc_params_present)
2852 rte_panic("Error: Preprocessor args "
2853 "are provided more than once\n");
2854 preproc_params_present = 1;
2856 app->preproc_args = strdup(optarg);
2860 app_print_usage(argv[0]);
2864 app_print_usage(argv[0]);
2867 optind = 0; /* reset getopt lib */
2869 /* Check dependencies between args */
2870 if (preproc_params_present && (preproc_present == 0))
2871 rte_panic("Error: Preprocessor args specified while "
2872 "preprocessor is not defined\n");
2874 app->parser_file = preproc_present ?
2875 filenamedup(app->config_file, ".preproc") :
2876 strdup(app->config_file);
2877 app->output_file = filenamedup(app->config_file, ".out");
2883 app_config_preproc(struct app_params *app)
2888 if (app->preproc == NULL)
2891 status = access(app->config_file, F_OK | R_OK);
2892 APP_CHECK((status == 0), "Error: Unable to open file %s",
2895 snprintf(buffer, sizeof(buffer), "%s %s %s > %s",
2897 app->preproc_args ? app->preproc_args : "",
2901 status = system(buffer);
2902 APP_CHECK((WIFEXITED(status) && (WEXITSTATUS(status) == 0)),
2903 "Error occurred while pre-processing file \"%s\"\n",