Main function, does initialization and calls the per-lcore functions */
| 767 | |
| 768 | /* Main function, does initialization and calls the per-lcore functions */ |
| 769 | int |
| 770 | main(int argc, char *argv[]) |
| 771 | { |
| 772 | struct rte_mempool *mbuf_pool; |
| 773 | struct rte_distributor *d; |
| 774 | struct rte_ring *dist_tx_ring; |
| 775 | struct rte_ring *rx_dist_ring; |
| 776 | struct rte_power_core_capabilities lcore_cap; |
| 777 | unsigned int lcore_id, worker_id = 0; |
| 778 | int distr_core_id = -1, rx_core_id = -1, tx_core_id = -1; |
| 779 | unsigned nb_ports; |
| 780 | unsigned int min_cores; |
| 781 | uint16_t portid; |
| 782 | uint16_t nb_ports_available; |
| 783 | uint64_t t, freq; |
| 784 | |
| 785 | /* catch ctrl-c so we can print on exit */ |
| 786 | signal(SIGINT, int_handler); |
| 787 | |
| 788 | /* init EAL */ |
| 789 | int ret = rte_eal_init(argc, argv); |
| 790 | if (ret < 0) |
| 791 | rte_exit(EXIT_FAILURE, "Error with EAL initialization\n"); |
| 792 | argc -= ret; |
| 793 | argv += ret; |
| 794 | |
| 795 | /* parse application arguments (after the EAL ones) */ |
| 796 | ret = parse_args(argc, argv); |
| 797 | if (ret < 0) |
| 798 | rte_exit(EXIT_FAILURE, "Invalid distributor parameters\n"); |
| 799 | |
| 800 | if (enable_lcore_rx_distributor) { |
| 801 | /* RX and distributor combined, 3 fixed function cores (stat, TX, at least 1 worker) */ |
| 802 | min_cores = 4; |
| 803 | num_workers = rte_lcore_count() - 3; |
| 804 | } else { |
| 805 | /* separate RX and distributor, 3 fixed function cores (stat, TX, at least 1 worker) */ |
| 806 | min_cores = 5; |
| 807 | num_workers = rte_lcore_count() - 4; |
| 808 | } |
| 809 | |
| 810 | if (rte_lcore_count() < min_cores) |
| 811 | rte_exit(EXIT_FAILURE, "Error, This application needs at " |
| 812 | "least 4 logical cores to run:\n" |
| 813 | "1 lcore for stats (can be core 0)\n" |
| 814 | "1 or 2 lcore for packet RX and distribution\n" |
| 815 | "1 lcore for packet TX\n" |
| 816 | "and at least 1 lcore for worker threads\n"); |
| 817 | |
| 818 | if (init_power_library() == 0) |
| 819 | power_lib_initialised = 1; |
| 820 | |
| 821 | nb_ports = rte_eth_dev_count_avail(); |
| 822 | if (nb_ports == 0) |
| 823 | rte_exit(EXIT_FAILURE, "Error: no ethernet ports detected\n"); |
| 824 | if (nb_ports != 1 && (nb_ports & 1)) |
| 825 | rte_exit(EXIT_FAILURE, "Error: number of ports must be even, except " |
| 826 | "when using a single port\n"); |
nothing calls this directly
no test coverage detected