MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ntb_parse_args

Function ntb_parse_args

dpdk/examples/ntb/ntb_fwd.c:1009–1083  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1007}
1008
1009static void
1010ntb_parse_args(int argc, char **argv)
1011{
1012 char *prgname = argv[0], **argvopt = argv;
1013 int opt, opt_idx, n, i;
1014
1015 while ((opt = getopt_long(argc, argvopt, short_options,
1016 lgopts, &opt_idx)) != EOF) {
1017 switch (opt) {
1018 case 'i':
1019 printf("Interactive-mode selected.\n");
1020 interactive = 1;
1021 break;
1022 case OPT_QP_NUM:
1023 n = atoi(optarg);
1024 if (n > 0)
1025 num_queues = n;
1026 else
1027 rte_exit(EXIT_FAILURE, "q must be > 0.\n");
1028 break;
1029 case OPT_BUF_SIZE_NUM:
1030 n = atoi(optarg);
1031 if (n > RTE_PKTMBUF_HEADROOM && n <= 0xFFFF)
1032 ntb_buf_size = n;
1033 else
1034 rte_exit(EXIT_FAILURE, "buf-size must be > "
1035 "%u and < 65536.\n",
1036 RTE_PKTMBUF_HEADROOM);
1037 break;
1038 case OPT_FWD_MODE_NUM:
1039 for (i = 0; i < MAX_FWD_MODE; i++) {
1040 if (!strcmp(optarg, fwd_mode_s[i])) {
1041 fwd_mode = i;
1042 break;
1043 }
1044 }
1045 if (i == MAX_FWD_MODE)
1046 rte_exit(EXIT_FAILURE, "Unsupported mode. "
1047 "(Should be: file-trans | rxonly | txonly "
1048 "| iofwd)\n");
1049 break;
1050 case OPT_NB_DESC_NUM:
1051 n = atoi(optarg);
1052 if (n >= NTB_MIN_DESC_SIZE && n <= NTB_MAX_DESC_SIZE)
1053 nb_desc = n;
1054 else
1055 rte_exit(EXIT_FAILURE, "nb-desc must be within"
1056 " [%u, %u].\n", NTB_MIN_DESC_SIZE,
1057 NTB_MAX_DESC_SIZE);
1058 break;
1059 case OPT_TXFREET_NUM:
1060 n = atoi(optarg);
1061 if (n >= 0)
1062 tx_free_thresh = n;
1063 else
1064 rte_exit(EXIT_FAILURE, "txfreet must be"
1065 " >= 0\n");
1066 break;

Callers 1

mainFunction · 0.85

Calls 5

getopt_longFunction · 0.85
rte_exitFunction · 0.85
strcmpFunction · 0.85
ntb_usageFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected