当前位置: 首页>>代码示例>>C++>>正文


C++ rte_eal_init函数代码示例

本文整理汇总了C++中rte_eal_init函数的典型用法代码示例。如果您正苦于以下问题:C++ rte_eal_init函数的具体用法?C++ rte_eal_init怎么用?C++ rte_eal_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rte_eal_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: globalinit

static int
globalinit(void)
{
    int rv;

    if (rte_eal_init(sizeof(ealargs)/sizeof(ealargs[0]),
                     /*UNCONST*/(void *)(uintptr_t)ealargs) < 0)
        OUT("eal init\n");

    if ((mbpool = rte_mempool_create("mbuf_pool", NMBUF, MBSIZE, MBALIGN,
                                     sizeof(struct rte_pktmbuf_pool_private),
                                     rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL, 0, 0)) == NULL)
        OUT("mbuf pool\n");

    if (PMD_INIT() < 0)
        OUT("wm driver\n");
    if (rte_eal_pci_probe() < 0)
        OUT("PCI probe\n");
    if (rte_eth_dev_count() == 0)
        OUT("no ports\n");
    rv = 0;

out:
    return rv;
}
开发者ID:purcaro,项目名称:dpdk-rumptcpip,代码行数:25,代码来源:rumpcomp_user.c

示例2: globalinit

static int
globalinit(struct virtif_user *viu)
{
	int rv;

	if ((rv = rte_eal_init(sizeof(ealargs)/sizeof(ealargs[0]),
	    /*UNCONST*/(void *)(uintptr_t)ealargs)) < 0)
		OUT("eal init");

	if ((mbpool_tx = rte_mempool_create("mbuf_pool_tx", NMBUF_TX, MBSIZE, 0/*MBCACHE*/,
	    sizeof(struct rte_pktmbuf_pool_private),
	    rte_pktmbuf_pool_init, NULL,
	    rte_pktmbuf_init, NULL, 0, 0)) == NULL) {
		rv = -EINVAL;
		OUT("mbuf pool tx");
	}
	if ((mbpool_rx = rte_mempool_create("mbuf_pool_rx", NMBUF_RX, MBSIZE, 0/*MBCACHE*/,
	    sizeof(struct rte_pktmbuf_pool_private),
	    rte_pktmbuf_pool_init, NULL,
	    rte_pktmbuf_init, NULL, 0, 0)) == NULL) {
		rv = -EINVAL;
		OUT("mbuf pool tx");
	}

	if (rte_eth_dev_count() == 0) {
		rv = -1;
		OUT("no ports");
	}
	rv = 0;

 out:
 	return rv;
}
开发者ID:ywahl,项目名称:dpdk-rumptcpip,代码行数:33,代码来源:dpdkif_user.c

示例3: main

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;
}
开发者ID:EthanZhuang,项目名称:dpdk-ans,代码行数:35,代码来源:anscli_main.c

示例4: main

int32_t main(int32_t argc, char **argv)
{
	int32_t ret = -1;
	
	ret = rte_eal_init(argc, argv);
	if(0 > ret)
	{
		rte_exit(EXIT_FAILURE, "rte_eal_init failed!\n");
	}

	argc -= ret;
	argv += ret;

	ret = udpi_parse_args(argc, argv);
	if(0 > ret)
	{
		udpi_print_usage(argv[0]);
		rte_exit(EXIT_FAILURE, "invalid user args!\n");
	}

	udpi_init();

	rte_eal_mp_remote_launch(udpi_lcore_main_loop, 
		NULL, CALL_MASTER);
	
	return 0;
}
开发者ID:exuuwen,项目名称:study,代码行数:27,代码来源:main.c

示例5: MAIN

int
MAIN(int argc, char **argv)
{
	uint32_t lcore;
	int ret;

	/* Init EAL */
	ret = rte_eal_init(argc, argv);
	if (ret < 0)
		return -1;
	argc -= ret;
	argv += ret;

	/* Parse application arguments (after the EAL ones) */
	ret = app_parse_args(argc, argv);
	if (ret < 0) {
		app_print_usage();
		return -1;
	}

	/* Init */
	app_init();
	app_print_params();

	/* Launch per-lcore init on every lcore */
	rte_eal_mp_remote_launch(app_lcore_main_loop, NULL, CALL_MASTER);
	RTE_LCORE_FOREACH_SLAVE(lcore) {
		if (rte_eal_wait_lcore(lcore) < 0) {
			return -1;
		}
	}

	return 0;
}
开发者ID:AMildner,项目名称:MoonGen,代码行数:34,代码来源:main.c

示例6: parse_args

/*
 * Parse the command line arguments passed to the application.
 */
int parse_args(int argc, char** argv, app_params* p)
{
  // initialize the environment
  int ret = rte_eal_init(argc, argv);
  if (ret < 0) {
      rte_exit(EXIT_FAILURE, "Failed to initialize EAL: %i\n", ret);
  }

  // advance past the environmental settings
  argc -= ret;
  argv += ret;

  // parse arguments to the application
  ret = parse_app_args(argc, argv, p);
  if (ret < 0) {
      rte_exit(EXIT_FAILURE, "\n");
  }

  p->nb_ports = rte_eth_dev_count();
  p->nb_rx_workers = p->nb_rx_queue;
  p->nb_tx_workers = (rte_lcore_count() - 1) - p->nb_rx_workers;

  // validate the number of workers
  if(p->nb_tx_workers < p->nb_rx_workers) {
      rte_exit(EXIT_FAILURE, "Additional lcore(s) required; found=%u, required=%u \n",
          rte_lcore_count(), (p->nb_rx_queue*2) + 1);
  }

  return 0;
}
开发者ID:JonZeolla,项目名称:incubator-metron,代码行数:33,代码来源:args.c

示例7: globalinit

static int
globalinit(struct virtif_user *viu)
{
	int rv;

	if ((rv = rte_eal_init(sizeof(ealargs)/sizeof(ealargs[0]),
	    /*UNCONST*/(void *)(uintptr_t)ealargs)) < 0)
		OUT("eal init\n");

	/* disable mempool cache due to DPDK bug, not thread safe */
	if ((mbpool = rte_mempool_create("mbuf_pool", NMBUF, MBSIZE, 0/*MBCACHE*/,
	    sizeof(struct rte_pktmbuf_pool_private),
	    rte_pktmbuf_pool_init, NULL,
	    rte_pktmbuf_init, NULL, 0, 0)) == NULL) {
		rv = -EINVAL;
		OUT("mbuf pool\n");
	}

	if ((rv = PMD_INIT()) < 0)
		OUT("pmd init\n");
	if ((rv = rte_eal_pci_probe()) < 0)
		OUT("PCI probe\n");
	if (rte_eth_dev_count() == 0) {
		rv = -1;
		OUT("no ports\n");
	}
	rv = 0;

 out:
 	return rv;
}
开发者ID:eagles125,项目名称:dpdk-rumptcpip,代码行数:31,代码来源:rumpcomp_user.c

示例8: main

int main(int argc, char *argv[])
{
	int ret;

	signal(SIGINT, signal_handler);

	/* init EAL */
	ret = rte_eal_init(argc, argv);
	if (ret < 0)
		rte_exit(EXIT_FAILURE, "Error with EAL initialization\n");

	g_vhost_ctrlr = vhost_scsi_ctrlr_construct("vhost.socket");
	if (g_vhost_ctrlr == NULL) {
		fprintf(stderr, "Construct vhost scsi controller failed\n");
		return 0;
	}

	if (sem_init(&exit_sem, 0, 0) < 0) {
		fprintf(stderr, "Error init exit_sem\n");
		return -1;
	}

	rte_vhost_driver_start(dev_pathname);

	/* loop for exit the application */
	while (1)
		sleep(1);

	return 0;
}
开发者ID:DrenfongWong,项目名称:dpdk,代码行数:30,代码来源:vhost_scsi.c

示例9: main

int
main(int argc, char **argv)
{
	struct cmdline *cl;
	int ret;

	ret = rte_eal_init(argc, argv);
	if (ret < 0)
		return -1;

	rte_timer_subsystem_init();

	argc -= ret;
	argv += ret;

	prgname = argv[0];

#ifndef RTE_EXEC_ENV_BAREMETAL
	if ((recursive_call = getenv(RECURSIVE_ENV_VAR)) != NULL)
		return do_recursive_call();
#endif

	cl = cmdline_stdin_new(main_ctx, "RTE>>");
	if (cl == NULL) {
		return -1;
	}
	cmdline_interact(cl);
	cmdline_stdin_exit(cl);

	return 0;
}
开发者ID:alegacy,项目名称:Pktgen-DPDK,代码行数:31,代码来源:test.c

示例10: main

int main(int argc, char **argv)
{
    int c;
    int ret;
    int sp_sc;
    unsigned socket_io;

    /* initialize EAL first */
    ret = rte_eal_init(argc, argv);

    argc -= ret;
    argv += ret;

    sp_sc = 1;
    bulk_size = 1;
    while ((c = getopt(argc, argv, "sm:b:w:")) != -1) {
        switch (c) {
        case 's':
            sp_sc = 1;
            break;
        case 'm':
            sp_sc = 0;
            nb_producers = atoi(optarg);
            break;
        case 'b':
            bulk_size = atoi(optarg);
            break;
        case 'w':
            work_cycles = atoi(optarg);
            break;
        case '?':
            break;
        }
    }

    setlocale(LC_NUMERIC, "");

    socket_io = rte_lcore_to_socket_id(rte_get_master_lcore());

    ring = rte_ring_create(ring_name,
                           ring_size, socket_io, RING_F_SP_ENQ | RING_F_SC_DEQ);

    if (ring == NULL) {
        rte_panic("Cannot create ring");
    }

    if (sp_sc) {
        printf("[MASTER] Single Producer/Consumer\n");
        printf("[MASTER] Bulk size: %d\n", bulk_size);
        driver_sp_sc();
    } else {
        printf("[MASTER] Number of Producers/Consumers: %d\n", nb_producers);
        printf("[MASTER] Bulk size: %d\n", bulk_size);
        driver_mp_mc();
    }
    rte_eal_mp_wait_lcore();
}
开发者ID:wshen0123,项目名称:test-rte_ring,代码行数:57,代码来源:main.c

示例11: main

int main(int argc, char **argv)
{
	int rc;

	/*
	 * By default, the SPDK NVMe driver uses DPDK for huge page-based
	 *  memory management and NVMe request buffer pools.  Huge pages can
	 *  be either 2MB or 1GB in size (instead of 4KB) and are pinned in
	 *  memory.  Pinned memory is important to ensure DMA operations
	 *  never target swapped out memory.
	 *
	 * So first we must initialize DPDK.  "-c 0x1" indicates to only use
	 *  core 0.
	 */
	rc = rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]), ealargs);
	if (rc < 0) {
		fprintf(stderr, "could not initialize dpdk\n");
		return 1;
	}

	/*
	 * Create the NVMe request buffer pool.  This will be used internally
	 *  by the SPDK NVMe driver to allocate an spdk_nvme_request data
	 *  structure for each I/O request.  This is implicitly passed to
	 *  the SPDK NVMe driver via an extern declaration in nvme_impl.h.
	 */
	request_mempool = rte_mempool_create("nvme_request", 8192,
					     spdk_nvme_request_size(), 128, 0,
					     NULL, NULL, NULL, NULL,
					     SOCKET_ID_ANY, 0);

	if (request_mempool == NULL) {
		fprintf(stderr, "could not initialize request mempool\n");
		return 1;
	}

	printf("Initializing NVMe Controllers\n");

	/*
	 * Start the SPDK NVMe enumeration process.  probe_cb will be called
	 *  for each NVMe controller found, giving our application a choice on
	 *  whether to attach to each controller.  attach_cb will then be
	 *  called for each controller after the SPDK NVMe driver has completed
	 *  initializing the controller we chose to attach.
	 */
	rc = spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL);
	if (rc != 0) {
		fprintf(stderr, "spdk_nvme_probe() failed\n");
		cleanup();
		return 1;
	}

	printf("Initialization complete.\n");
	hello_world();
	cleanup();
	return 0;
}
开发者ID:NealXu,项目名称:spdk,代码行数:57,代码来源:hello_world.c

示例12: init

/**
 * Main init function for the multi-process server app,
 * calls subfunctions to do each stage of the initialisation.
 */
int
init(int argc, char *argv[])
{
	int retval;
	const struct rte_memzone *mz;
	uint8_t i, total_ports;

	/* init EAL, parsing EAL args */
	retval = rte_eal_init(argc, argv);
	if (retval < 0)
		return -1;
	argc -= retval;
	argv += retval;

	/* initialise the nic drivers */
	retval = init_drivers();
	if (retval != 0)
		rte_exit(EXIT_FAILURE, "Cannot initialise drivers\n");

	/* get total number of ports */
	total_ports = rte_eth_dev_count();

	/* set up array for port data */
	mz = rte_memzone_reserve(MZ_PORT_INFO, sizeof(*ports),
				rte_socket_id(), NO_FLAGS);
	if (mz == NULL)
		rte_exit(EXIT_FAILURE, "Cannot reserve memory zone for port information\n");
	memset(mz->addr, 0, sizeof(*ports));
	ports = mz->addr;

	/* parse additional, application arguments */
	retval = parse_app_args(total_ports, argc, argv);
	if (retval != 0)
		return -1;

	/* initialise mbuf pools */
	retval = init_mbuf_pools();
	if (retval != 0)
		rte_exit(EXIT_FAILURE, "Cannot create needed mbuf pools\n");

	/* now initialise the ports we will use */
	for (i = 0; i < ports->num_ports; i++) {
		retval = init_port(ports->id[i]);
		if (retval != 0)
			rte_exit(EXIT_FAILURE, "Cannot initialise port %u\n",
					(unsigned)i);
	}

	check_all_ports_link_status(ports->num_ports, (~0x0));

	/* initialise the client queues/rings for inter-eu comms */
	init_shm_rings();

	return 0;
}
开发者ID:AMildner,项目名称:MoonGen,代码行数:59,代码来源:init.c

示例13: main

int main(int argc, char **argv)
{
	struct dev			*iter;
	int				rc, i;

	printf("NVMe Write/Read with End-to-End data protection test\n");

	rc = rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]),
			  (char **)(void *)(uintptr_t)ealargs);

	if (rc < 0) {
		fprintf(stderr, "could not initialize dpdk\n");
		exit(1);
	}

	request_mempool = rte_mempool_create("nvme_request", 8192,
					     spdk_nvme_request_size(), 128, 0,
					     NULL, NULL, NULL, NULL,
					     SOCKET_ID_ANY, 0);

	if (request_mempool == NULL) {
		fprintf(stderr, "could not initialize request mempool\n");
		exit(1);
	}

	if (spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL) != 0) {
		fprintf(stderr, "nvme_probe() failed\n");
		exit(1);
	}

	rc = 0;
	foreach_dev(iter) {
#define TEST(x) write_read_e2e_dp_tests(iter, x, #x)
		if (TEST(dp_with_pract_test)
		    || TEST(dp_without_pract_extended_lba_test)
		    || TEST(dp_without_flags_extended_lba_test)
		    || TEST(dp_without_pract_separate_meta_test)
		    || TEST(dp_without_pract_separate_meta_apptag_test)
		    || TEST(dp_without_flags_separate_meta_test)) {
#undef TEST
			rc = 1;
			printf("%s: failed End-to-End data protection tests\n", iter->name);
		}
	}

	printf("Cleaning up...\n");

	for (i = 0; i < num_devs; i++) {
		struct dev *dev = &devs[i];

		spdk_nvme_detach(dev->ctrlr);
	}

	return rc;
}
开发者ID:NealXu,项目名称:spdk,代码行数:55,代码来源:nvme_dp.c

示例14: main

/* Main function */
int main(int argc, char **argv)
{
	int ret;
	int i;

	/* Create handler for SIGINT for CTRL + C closing and SIGALRM to print stats*/
	signal(SIGINT, sig_handler);
	signal(SIGALRM, alarm_routine);

	/* Initialize DPDK enviroment with args, then shift argc and argv to get application parameters */
	ret = rte_eal_init(argc, argv);
	if (ret < 0) FATAL_ERROR("Cannot init EAL\n");
	argc -= ret;
	argv += ret;

	/* Check if this application can use 1 core*/
	ret = rte_lcore_count ();
	if (ret != 2) FATAL_ERROR("This application needs exactly 2 cores.");

	/* Parse arguments */
	parse_args(argc, argv);
	if (ret < 0) FATAL_ERROR("Wrong arguments\n");

	/* Probe PCI bus for ethernet devices, mandatory only in DPDK < 1.8.0 */
	#if RTE_VER_MAJOR == 1 && RTE_VER_MINOR < 8
		ret = rte_eal_pci_probe();
		if (ret < 0) FATAL_ERROR("Cannot probe PCI\n");
	#endif

	/* Get number of ethernet devices */
	nb_sys_ports = rte_eth_dev_count();
	if (nb_sys_ports <= 0) FATAL_ERROR("Cannot find ETH devices\n");
	
	/* Create a mempool with per-core cache, initializing every element for be used as mbuf, and allocating on the current NUMA node */
	pktmbuf_pool = rte_mempool_create(MEMPOOL_NAME, buffer_size-1, MEMPOOL_ELEM_SZ, MEMPOOL_CACHE_SZ, sizeof(struct rte_pktmbuf_pool_private), rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL,rte_socket_id(), 0);
	if (pktmbuf_pool == NULL) FATAL_ERROR("Cannot create cluster_mem_pool. Errno: %d [ENOMEM: %d, ENOSPC: %d, E_RTE_NO_TAILQ: %d, E_RTE_NO_CONFIG: %d, E_RTE_SECONDARY: %d, EINVAL: %d, EEXIST: %d]\n", rte_errno, ENOMEM, ENOSPC, E_RTE_NO_TAILQ, E_RTE_NO_CONFIG, E_RTE_SECONDARY, EINVAL, EEXIST  );
	
	/* Create a ring for exchanging packets between cores, and allocating on the current NUMA node */
	intermediate_ring = rte_ring_create 	(RING_NAME, buffer_size, rte_socket_id(), RING_F_SP_ENQ | RING_F_SC_DEQ );
 	if (intermediate_ring == NULL ) FATAL_ERROR("Cannot create ring");


	/* Operations needed for each ethernet device */			
	for(i=0; i < nb_sys_ports; i++)
		init_port(i);

	/* Start consumer and producer routine on 2 different cores: producer launched first... */
	ret =  rte_eal_mp_remote_launch (main_loop_producer, NULL, SKIP_MASTER);
	if (ret != 0) FATAL_ERROR("Cannot start consumer thread\n");	

	/* ... and then loop in consumer */
	main_loop_consumer ( NULL );	

	return 0;
}
开发者ID:thomasbhatia,项目名称:DPDK-Replay,代码行数:56,代码来源:main_replay_copy_2_cores.c

示例15: main

/*
 * Application main function - loops through
 * receiving and processing packets. Never returns
 */
int
main(int argc, char *argv[])
{
	int retval = 0;
	uint8_t port = 0;
	char *port_name;

	if ((retval = rte_eal_init(argc, argv)) < 0) {
		RTE_LOG(INFO, APP, "EAL init failed.\n");
		return -1;
	}

	argc -= retval;
	argv += retval;
	if (parse_app_args(argc, argv) < 0)
		rte_exit(EXIT_FAILURE, "Invalid command-line arguments\n");

	memset(kni_list, 0, sizeof(struct rte_kni) * MAX_KNI_PORTS);

	/* Open KNI or exit */
	kni_fd = open("/dev/" KNI_DEVICE, O_RDWR);
	if (kni_fd < 0) {
		RTE_LOG(ERR, KNI, "Can not open /dev/%s\n", KNI_DEVICE);
		return -1;
	}

	/* Lookup for vports struct */
	if (ovs_vport_lookup_vport_info() == NULL)
		return -1;

	/* Initialise the devices for each port*/
	for (port = 0; port < ports_n; port++) {
		port_name = port_names[port];
		RTE_LOG(INFO, KNI, "Attaching queues for port '%s'\n", port_name);
		if (create_kni_device(&kni_list[port], port_name, port) < 0)
			return -1;
	}

	RTE_LOG(INFO, KNI, "\nKNI client handling packets \n");
	RTE_LOG(INFO, KNI, "[Press Ctrl-C to quit ...]\n");

	for (;;) {
		for (port = 0; port < ports_n; port++) {
			/* Sleep to reduce processor load. As long as we respond
			 * before rtnetlink times out we will still be able to ifup
			 * and change mtu
			 */
			sleep(1);
			rte_kni_handle_request(&kni_list[port]);
		}
	}

	return 0;
}
开发者ID:Grace-Liu,项目名称:dpdk-ovs,代码行数:58,代码来源:kni_client.c


注:本文中的rte_eal_init函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。