コード例 #1
0
ファイル: commands.c プロジェクト: gonzopancho/dppd-BNG
void start_core_all(void)
{
	uint32_t cores[RTE_MAX_LCORE];
	uint32_t lcore_id;
	char tmp[256];
	int cnt = 0;

	dppd_core_to_str(tmp, sizeof(tmp), 0);
	plog_info("Starting cores: %s\n", tmp);

	lcore_id = -1;
	while (dppd_core_next(&lcore_id, 0) == 0) {
		cores[cnt++] = lcore_id;
	}
	start_cores(cores, cnt);
}
コード例 #2
0
ファイル: tpg_main.c プロジェクト: Rao-DS/warp17
/*****************************************************************************
 * main()
 ****************************************************************************/
int main(int argc, char **argv)
{
    global_config_t *cfg;
    int              ret;

    /*
     * Initialize DPDK infrastructure before we do anything else
     */
    ret = rte_eal_init(argc, argv);
    if (ret < 0)
        rte_panic("Cannot init EAL\n");

    /*
     * Initialize RTE timer library
     */
    rte_timer_subsystem_init();
    /*
     * Precalculate the number of cycles per us so we don't do it everytime.
     */
    cycles_per_us = (rte_get_timer_hz() / 1000000);

    /*
     * Return value above to be used to scan app specific options
     */
    argc -= ret;
    argv += ret;

    /*
     * General checks
     */
    if (rte_lcore_count() < 3)
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s\n",
                       "WARP17 needs at least three cores!");
    /* We only support at most 64 cores right now (to make parsing easier). */
    if (rte_lcore_count() > (sizeof(uint64_t) * 8))
        TPG_ERROR_EXIT(EXIT_FAILURE,
                       "ERROR: WARP17 supports at most %"PRIu32" cores!\n",
                       (uint32_t)sizeof(uint64_t) * 8);
    if (rte_eth_dev_count() > TPG_ETH_DEV_MAX)
        TPG_ERROR_EXIT(EXIT_FAILURE,
                       "ERROR: WARP17 works with at most %u ports!\n",
                       TPG_ETH_DEV_MAX);

    /*
     * Initialize various submodules
     */

    if (!cli_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the command line interface");

    if (!rpc_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the RPC server");

    if (!cfg_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s\n",
                       "Failed initializing default configuration!\n");

    if (!cfg_handle_command_line(argc, argv))
        exit(EXIT_FAILURE); /* Error reporting is handled by the function itself */

    if (!trace_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the tracing module");

    if (!trace_filter_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the trace filter module");

    if (!mem_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed allocating required mbufs");

    /* WARNING: Careful when adding code above this point. Up until ports are
     * initialized DPDK can't know that there might be ring interfaces that
     * still need to be created. Therefore any call to rte_eth_dev_count()
     * doesn't include them.
     */
    if (!port_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the Ethernets ports");

    if (!msg_sys_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the message queues");

    if (!test_mgmt_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing test mgmt");

    if (!test_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing tests");

    if (!eth_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the Ethernets pkt handler");

    if (!arp_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the ARP pkt handler");

    if (!route_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the ROUTE module");

    if (!ipv4_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the IPv4 pkt handler");

    if (!tcp_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the TCP pkt handler");

    if (!udp_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the UDP pkt handler");

    if (!tlkp_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the Session lookup engine");

    if (!tlkp_tcp_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the TCP lookup engine");

    if (!tlkp_udp_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the UDP lookup engine");

    if (!tsm_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the TSM module");

    if (!timer_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the TCP timers module");

    if (!pkt_loop_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the pkt loop");

    if (!raw_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the RAW Application module");

    if (!http_init())
        TPG_ERROR_EXIT(EXIT_FAILURE, "ERROR: %s!\n",
                       "Failed initializing the RAW Application module");

    start_cores();

    /*
     * Process startup command file, if any.
     */
    cfg = cfg_get_config();
    if (cfg != NULL && cfg->gcfg_cmd_file) {
        if (!cli_run_input_file(cfg->gcfg_cmd_file))
            TPG_ERROR_EXIT(EXIT_FAILURE, "Failed to run command file: %s!\n",
                           cfg->gcfg_cmd_file);
    }

    /*
     * Process CLI commands, and other house keeping tasks...
     */
    cli_interact();
    tpg_exit = true;

    /*
     * Exit!!!
     */
    rte_eal_mp_wait_lcore();

    /*
     * Destroy the CLI.
     */
    cli_exit();

    /*
     * Destroy the mgmt RPC server.
     */
    rpc_destroy();
    return 0;
}