Parse the argument given in the command line of the application */
| 630 | |
| 631 | /* Parse the argument given in the command line of the application */ |
| 632 | static int |
| 633 | dma_parse_args(int argc, char **argv, unsigned int nb_ports) |
| 634 | { |
| 635 | static const char short_options[] = |
| 636 | "b:" /* dma batch size */ |
| 637 | "c:" /* copy type (sw|hw) */ |
| 638 | "f:" /* max frame size */ |
| 639 | "m:" /* force min copy size */ |
| 640 | "p:" /* portmask */ |
| 641 | "q:" /* number of RX queues per port */ |
| 642 | "s:" /* ring size */ |
| 643 | "i:" /* interval, in seconds, between stats prints */ |
| 644 | ; |
| 645 | |
| 646 | static const struct option lgopts[] = { |
| 647 | {CMD_LINE_OPT_MAC_UPDATING, no_argument, &mac_updating, 1}, |
| 648 | {CMD_LINE_OPT_NO_MAC_UPDATING, no_argument, &mac_updating, 0}, |
| 649 | {CMD_LINE_OPT_PORTMASK, required_argument, NULL, 'p'}, |
| 650 | {CMD_LINE_OPT_NB_QUEUE, required_argument, NULL, 'q'}, |
| 651 | {CMD_LINE_OPT_COPY_TYPE, required_argument, NULL, 'c'}, |
| 652 | {CMD_LINE_OPT_RING_SIZE, required_argument, NULL, 's'}, |
| 653 | {CMD_LINE_OPT_BATCH_SIZE, required_argument, NULL, 'b'}, |
| 654 | {CMD_LINE_OPT_FRAME_SIZE, required_argument, NULL, 'f'}, |
| 655 | {CMD_LINE_OPT_FORCE_COPY_SIZE, required_argument, NULL, 'm'}, |
| 656 | {CMD_LINE_OPT_STATS_INTERVAL, required_argument, NULL, 'i'}, |
| 657 | {NULL, 0, 0, 0} |
| 658 | }; |
| 659 | |
| 660 | const unsigned int default_port_mask = (1 << nb_ports) - 1; |
| 661 | int opt, ret; |
| 662 | char **argvopt; |
| 663 | int option_index; |
| 664 | char *prgname = argv[0]; |
| 665 | |
| 666 | dma_enabled_port_mask = default_port_mask; |
| 667 | argvopt = argv; |
| 668 | |
| 669 | while ((opt = getopt_long(argc, argvopt, short_options, |
| 670 | lgopts, &option_index)) != EOF) { |
| 671 | |
| 672 | switch (opt) { |
| 673 | case 'b': |
| 674 | dma_batch_sz = atoi(optarg); |
| 675 | if (dma_batch_sz > MAX_PKT_BURST) { |
| 676 | printf("Invalid dma batch size, %s.\n", optarg); |
| 677 | dma_usage(prgname); |
| 678 | return -1; |
| 679 | } |
| 680 | break; |
| 681 | case 'f': |
| 682 | max_frame_size = atoi(optarg); |
| 683 | if (max_frame_size > RTE_ETHER_MAX_JUMBO_FRAME_LEN) { |
| 684 | printf("Invalid max frame size, %s.\n", optarg); |
| 685 | dma_usage(prgname); |
| 686 | return -1; |
| 687 | } |
| 688 | break; |
| 689 |
no test coverage detected