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

Function main

dpdk/examples/bond/main.c:682–751  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

680
681/* Main function, does initialisation and calls the per-lcore functions */
682int
683main(int argc, char *argv[])
684{
685 int ret, worker_core_id;
686 uint16_t nb_ports, i;
687
688 /* init EAL */
689 ret = rte_eal_init(argc, argv);
690 rte_devargs_dump(stdout);
691 if (ret < 0)
692 rte_exit(EXIT_FAILURE, "Error with EAL initialization\n");
693 argc -= ret;
694 argv += ret;
695
696 nb_ports = rte_eth_dev_count_avail();
697 if (nb_ports == 0)
698 rte_exit(EXIT_FAILURE, "Give at least one port\n");
699 else if (nb_ports > MAX_PORTS)
700 rte_exit(EXIT_FAILURE, "You can have max 4 ports\n");
701
702 mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", NB_MBUF, 32,
703 0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());
704 if (mbuf_pool == NULL)
705 rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");
706
707 /* initialize all ports */
708 members_count = nb_ports;
709 RTE_ETH_FOREACH_DEV(i) {
710 member_port_init(i, mbuf_pool);
711 members[i] = i;
712 }
713
714 bond_port_init(mbuf_pool);
715
716 rte_spinlock_init(&global_flag_stru_p->lock);
717
718 /* check state of lcores */
719 RTE_LCORE_FOREACH_WORKER(worker_core_id) {
720 if (rte_eal_get_lcore_state(worker_core_id) != WAIT)
721 return -EBUSY;
722 }
723
724 /* start lcore main on core != main_core - ARP response thread */
725 worker_core_id = rte_get_next_lcore(rte_lcore_id(), 1, 0);
726 if ((worker_core_id >= RTE_MAX_LCORE) || (worker_core_id == 0))
727 return -EPERM;
728
729 global_flag_stru_p->LcoreMainIsRunning = 1;
730 global_flag_stru_p->LcoreMainCore = worker_core_id;
731 printf("Starting lcore_main on core %d:%d Our IP:%d.%d.%d.%d\n",
732 worker_core_id,
733 rte_eal_remote_launch((lcore_function_t *)lcore_main,
734 NULL,
735 worker_core_id),
736 BOND_IP_1,
737 BOND_IP_2,
738 BOND_IP_3,
739 BOND_IP_4

Callers

nothing calls this directly

Calls 15

rte_devargs_dumpFunction · 0.85
rte_exitFunction · 0.85
rte_eth_dev_count_availFunction · 0.85
rte_pktmbuf_pool_createFunction · 0.85
rte_socket_idFunction · 0.85
member_port_initFunction · 0.85
bond_port_initFunction · 0.85
rte_spinlock_initFunction · 0.85
rte_eal_get_lcore_stateFunction · 0.85
rte_get_next_lcoreFunction · 0.85
rte_lcore_idFunction · 0.85
rte_eal_remote_launchFunction · 0.85

Tested by

no test coverage detected