Example #1
0
int
test_logs(void)
{
	/* enable these logs type */
	rte_set_log_type(RTE_LOGTYPE_TESTAPP1, 1);
	rte_set_log_type(RTE_LOGTYPE_TESTAPP2, 1);

	/* log in debug level */
	rte_set_log_level(RTE_LOG_DEBUG);
	RTE_LOG(DEBUG, TESTAPP1, "this is a debug level message\n");
	RTE_LOG(INFO, TESTAPP1, "this is a info level message\n");
	RTE_LOG(WARNING, TESTAPP1, "this is a warning level message\n");

	/* log in info level */
	rte_set_log_level(RTE_LOG_INFO);
	RTE_LOG(DEBUG, TESTAPP2, "debug level message (not displayed)\n");
	RTE_LOG(INFO, TESTAPP2, "this is a info level message\n");
	RTE_LOG(WARNING, TESTAPP2, "this is a warning level message\n");

	/* disable one log type */
	rte_set_log_type(RTE_LOGTYPE_TESTAPP2, 0);

	/* log in debug level */
	rte_set_log_level(RTE_LOG_DEBUG);
	RTE_LOG(DEBUG, TESTAPP1, "this is a debug level message\n");
	RTE_LOG(DEBUG, TESTAPP2, "debug level message (not displayed)\n");

	rte_log_dump_history();

	return 0;
}
void DpdkDeviceList::setDpdkLogLevel(LoggerPP::LogLevel logLevel)
{
	if (logLevel == LoggerPP::Normal)
		rte_set_log_level(RTE_LOG_NOTICE);
	else // logLevel == LoggerPP::Debug
		rte_set_log_level(RTE_LOG_DEBUG);
}
Example #3
0
void DpdkDeviceList::setDpdkLogLevel(LoggerPP::LogLevel logLevel)
{
#if (RTE_VER_YEAR > 17) || (RTE_VER_YEAR == 17 && RTE_VER_MONTH >= 11)
	if (logLevel == LoggerPP::Normal)
		rte_log_set_global_level(RTE_LOG_NOTICE);
	else // logLevel == LoggerPP::Debug
		rte_log_set_global_level(RTE_LOG_DEBUG);
#else
	if (logLevel == LoggerPP::Normal)
		rte_set_log_level(RTE_LOG_NOTICE);
	else // logLevel == LoggerPP::Debug
		rte_set_log_level(RTE_LOG_DEBUG);
#endif
}
Example #4
0
static void
cmd_loglevel_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
		    __rte_unused void *data)
{
	struct cmd_loglevel_result *res = parsed_result;
	rte_set_log_level(res->level);
}
Example #5
0
int
vhost_init(void)
{
	int ret;
	static pthread_t tid;

/* The log level is only set if DEBUG is set in vhost.h */
#ifdef LOG_LEVEL
	/* Set log level. */
	rte_set_log_level(LOG_LEVEL); 
#endif

	/* one vHost device per OVS virtual port */
	num_devices = MAX_VHOST_PORTS;

	/* Register CUSE device to handle IOCTLs. */
	ret = register_cuse_device((char*)&dev_basename, dev_index,
			           get_virtio_net_callbacks());
	if (ret != 0)
		rte_exit(EXIT_FAILURE, "CUSE device setup failure.\n");

	init_virtio_net(&virtio_net_device_ops);

	/* Start CUSE session thread. */
	pthread_create(&tid, NULL, (void*)cuse_session_loop, NULL);
	
	RTE_LOG(INFO, APP, "Initialising Vhost\n");
	return 0;
}
Example #6
0
int main(void)
{
    int ret;
    struct cmdline *cl;
    int     param_num = 8;
    char *param[] = {"anscli",
                               "-c",
                               "1",
                               "-n",
                               "1",
                               "--no-pci",
                               "--socket-mem=1",
                               "--proc-type=secondary",
                               NULL};


    rte_set_log_level(RTE_LOG_ERR);
    ret = rte_eal_init(param_num, param);
    if (ret < 0)
        rte_panic("Cannot init EAL\n");

    ret = anscli_ring_init();
    if(ret != 0)
        rte_panic("Cannot init ring\n");


    cl = cmdline_stdin_new(ip_main_ctx, "ans> ");
    if (cl == NULL)
    rte_panic("Cannot create ans cmdline instance\n");

    cmdline_interact(cl);
    cmdline_stdin_exit(cl);

    return 0;
}
Example #7
0
static void
cmd_loglevel_parsed(void						*parsed_result,
					__rte_unused struct cmdline *cl,
					__rte_unused void			*data)
{
	struct cmd_loglevel_result *res = parsed_result;

#if RTE_VERSION >= RTE_VERSION_NUM(17, 5, 0, 0)
	rte_log_set_global_level(res->level);
#else
	rte_set_log_level(res->level);
#endif
}
Example #8
0
int MAIN(int argc, char **argv)
{
    int ret;
    struct cmdline *cl;

    rte_set_log_level(RTE_LOG_INFO);

    ret = rte_eal_init(argc, argv);
    if (ret < 0)
        rte_exit(EXIT_FAILURE, "Cannot initialize EAL\n");

    setup_shared_variables();

    cl = cmdline_stdin_new(qwctl_ctx, "qwctl> ");
    if (cl == NULL)
        rte_exit(EXIT_FAILURE, "Cannot create cmdline instance\n");

    cmdline_interact(cl);
    cmdline_stdin_exit(cl);

    return 0;
}
Example #9
0
int MAIN(int argc, char **argv) {

	int ret;
	int i=0;
	int nb_lcore;
	struct user_params params;

	struct lcore_config lcore[APP_MAX_LCORES];
	uint8_t lcore_id;

	/* Associate signal_hanlder function with appropriate signals */
	signal(SIGUSR1, signal_handler);
	signal(SIGUSR2, signal_handler);

	/* Parse EAL arguments and init DPDK EAL
	 *
	 * After this function call, all lcores are initialized in WAIT state and
	 * ready to receive functions to execute
	 */
	ret = rte_eal_init(argc, argv);
	if (ret < 0)
		rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n");
	argc -= ret;
	argv += ret;

	nb_lcore = rte_lcore_count();
	if (nb_lcore < 2) 
		rte_exit(EXIT_FAILURE, "Too few locres. At least 2 required (one for packet fwd, one for control plane), %d given\n", nb_lcore);
	/*
	 * This call sets log level in the sense that log messages for a lower
	 * layer that this will not be shown but will still take CPU cycles.
	 * To actually remove logging code from the program, set log level in
	 * DPDK config files located in $RTE_SDK/config.
	 */
	rte_set_log_level(RTE_LOG_DEBUG);

	/*
	 * Parse application-specific arguments, which comes after the EAL ones and
	 * are separated from the latter by a double dash (--)
	 */
	ret = parse_args(argc, argv, &params);
	if (ret < 0)
		rte_exit(EXIT_FAILURE, "Invalid content router arguments\n");

	// Configure the app config object
	app_conf.fib_num_buckets = FIB_NUM_BUCKETS;
	app_conf.fib_max_elements = FIB_MAX_ELEMENTS;

	app_conf.pit_num_buckets = PIT_NUM_BUCKETS;
	app_conf.pit_max_elements = PIT_MAX_ELEMENTS;
	app_conf.pit_ttl_us = PIT_TTL_US;

	/* CS settings */
	app_conf.cs_num_buckets = CS_NUM_BUCKETS;
	app_conf.cs_max_elements = CS_MAX_ELEMENTS;

	/* Packet burst settings */
	app_conf.tx_burst_size = MAX_PKT_BURST;
	app_conf.rx_burst_size = MAX_PKT_BURST;

	/* Packet pool settings */
	app_conf.nb_mbuf = NB_MBUF;
	app_conf.mbuf_size = MBUF_SIZE;
	app_conf.mempool_cache_size = MEMPOOL_CACHE_SIZE;

	/* Other config */
	app_conf.promic_mode = params.promisc_mode;
	app_conf.portmask = params.portmask;
	app_conf.numa_on = params.numa_on;
	
	for(i=0; i< APP_MAX_ETH_PORTS;i++)
		memcpy(app_conf.config_remote_addr[i],params.config_remote_addr[i] ,18);

	init_app(&app_conf, lcore_conf);
	reset_stats();

	MAIN_LOG("All configuration done. Launching worker lcores\n");

	/* launch per-lcore init on every lcore but lcore 0 and control plane lcore*/
	for(lcore_id = 1; lcore_id < nb_lcore; lcore_id++){
		if (lcore_id == CONTROL_PLANE_LCORE)
			continue;
		ret = rte_eal_remote_launch(pkt_fwd_loop, NULL,lcore_id);
		if (ret < 0)
			rte_exit(EXIT_FAILURE, "lcore %u busy\n",lcore_id);
	}
	/* launch control plane core if not MASTER (LCORE=0, current)*/
	if (CONTROL_PLANE_LCORE != 0){
		ret = rte_eal_remote_launch(ctrl_loop, NULL, CONTROL_PLANE_LCORE);
		MAIN_LOG("Fwd and Ctrl loops Launched\n");
		if (ret < 0)
			rte_exit(EXIT_FAILURE, "lcore %u busy\n",CONTROL_PLANE_LCORE);
		pkt_fwd_loop(NULL);
	}
	else
		ctrl_loop(NULL); /* launch control plane core if not MASTER (LCORE=0, current)*/
	
	RTE_LCORE_FOREACH_SLAVE(lcore_id)
	{
		if (rte_eal_wait_lcore(lcore_id) < 0)
			return -1;
	}
	return 0;
}