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

Function main

dpdk/examples/distributor/main.c:769–1027  ·  view source on GitHub ↗

Main function, does initialization and calls the per-lcore functions */

Source from the content-addressed store, hash-verified

767
768/* Main function, does initialization and calls the per-lcore functions */
769int
770main(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");

Callers

nothing calls this directly

Calls 15

rte_exitFunction · 0.85
rte_lcore_countFunction · 0.85
rte_eth_dev_count_availFunction · 0.85
rte_pktmbuf_pool_createFunction · 0.85
rte_socket_idFunction · 0.85
rte_distributor_createFunction · 0.85
rte_ring_createFunction · 0.85
rte_mallocFunction · 0.85
rte_eal_remote_launchFunction · 0.85
rte_eal_wait_lcoreFunction · 0.85
rte_freeFunction · 0.85
parse_argsFunction · 0.70

Tested by

no test coverage detected