本文整理汇总了C++中rte_eth_dev_count函数的典型用法代码示例。如果您正苦于以下问题:C++ rte_eth_dev_count函数的具体用法?C++ rte_eth_dev_count怎么用?C++ rte_eth_dev_count使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rte_eth_dev_count函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rte_event_eth_rx_adapter_stats_reset
int
rte_event_eth_rx_adapter_stats_reset(uint8_t id)
{
struct rte_event_eth_rx_adapter *rx_adapter;
struct rte_eventdev *dev;
struct eth_device_info *dev_info;
uint32_t i;
RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
rx_adapter = id_to_rx_adapter(id);
if (rx_adapter == NULL)
return -EINVAL;
dev = &rte_eventdevs[rx_adapter->eventdev_id];
for (i = 0; i < rte_eth_dev_count(); i++) {
dev_info = &rx_adapter->eth_devices[i];
if (dev_info->internal_event_port == 0 ||
dev->dev_ops->eth_rx_adapter_stats_reset == NULL)
continue;
(*dev->dev_ops->eth_rx_adapter_stats_reset)(dev,
&rte_eth_devices[i]);
}
memset(&rx_adapter->stats, 0, sizeof(rx_adapter->stats));
return 0;
}
开发者ID:qoriq-open-source,项目名称:dpdk,代码行数:27,代码来源:rte_event_eth_rx_adapter.c
示例2: pcap_lookupdev
char* pcap_lookupdev(char* errbuf)
{
int port = 0;
struct rte_eth_dev_info info;
if (globalInit(errbuf) != DPDKPCAP_OK)
{
return NULL;
}
int portsNumber = rte_eth_dev_count();
if (portsNumber < 1)
{
snprintf (errbuf, PCAP_ERRBUF_SIZE, "No devices found");
return NULL;
}
if (deviceInit(port, errbuf) == DPDKPCAP_FAILURE)
{
return NULL;
}
rte_eth_dev_info_get(port, &info);
snprintf(ifName, DPDKPCAP_IF_NAMESIZE, "enp%us%u",
info.pci_dev->addr.bus,
info.pci_dev->addr.devid);
deviceNames[port] = ifName;
return ifName;
}
开发者ID:garyachy,项目名称:SwitchEmu,代码行数:32,代码来源:dpdkpcap.c
示例3: 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
示例4: kni_config_network_interface
/* Callback for request of configuring network interface up/down */
static int
kni_config_network_interface(uint8_t port_id, uint8_t if_up)
{
int ret = 0;
RTE_LOG(INFO, KNI, "---- kni_config_network_interface\n");
if (port_id >= rte_eth_dev_count() || port_id >= RTE_MAX_ETHPORTS) {
RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
return -EINVAL;
}
RTE_LOG(INFO, KNI, "Configure network interface of %d %s\n", port_id,
if_up ? "up" : "down");
if (if_up != 0) { /* Configure network interface up */
rte_eth_dev_stop(port_id);
ret = rte_eth_dev_start(port_id);
kni_port_rdy[port_id]++;
} else /* Configure network interface down */
rte_eth_dev_stop(port_id);
if (ret < 0)
RTE_LOG(ERR, KNI, "Failed to start port %d\n", port_id);
RTE_LOG(INFO, KNI, "finished kni_config_network_interface\n");
return ret;
}
开发者ID:Gandi,项目名称:packet-journey,代码行数:28,代码来源:kni.c
示例5: 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
示例6: dpdk_helper_link_status_get
static int dpdk_helper_link_status_get(dpdk_helper_ctx_t *phc) {
dpdk_events_ctx_t *ec = DPDK_EVENTS_CTX_GET(phc);
/* get Link Status values from DPDK */
uint8_t nb_ports = rte_eth_dev_count();
if (nb_ports == 0) {
DPDK_CHILD_LOG("dpdkevent-helper: No DPDK ports available. "
"Check bound devices to DPDK driver.\n");
return -ENODEV;
}
ec->nb_ports = nb_ports > RTE_MAX_ETHPORTS ? RTE_MAX_ETHPORTS : nb_ports;
for (int i = 0; i < ec->nb_ports; i++) {
if (ec->config.link_status.enabled_port_mask & (1 << i)) {
struct rte_eth_link link;
ec->link_info[i].read_time = cdtime();
rte_eth_link_get_nowait(i, &link);
if ((link.link_status == ETH_LINK_NA) ||
(link.link_status != ec->link_info[i].link_status)) {
ec->link_info[i].link_status = link.link_status;
ec->link_info[i].status_updated = 1;
DPDK_CHILD_LOG(" === PORT %d Link Status: %s\n", i,
link.link_status ? "UP" : "DOWN");
}
}
}
return 0;
}
开发者ID:Feandil,项目名称:collectd,代码行数:29,代码来源:dpdkevents.c
示例7: kni_config_network_interface
/* Callback for request of configuring network interface up/down */
static int
kni_config_network_interface(uint8_t port_id, uint8_t if_up)
{
#if 0
int ret = 0;
if (port_id >= rte_eth_dev_count() || port_id >= RTE_MAX_ETHPORTS) {
RTE_LOG(ERR, APP, "Invalid port id %d\n", port_id);
return -EINVAL;
}
RTE_LOG(INFO, APP, "Configure network interface of %d %s\n",
port_id, if_up ? "up" : "down");
if (if_up != 0) { /* Configure network interface up */
rte_eth_dev_stop(port_id);
ret = rte_eth_dev_start(port_id);
} else /* Configure network interface down */
rte_eth_dev_stop(port_id);
if (ret < 0)
RTE_LOG(ERR, APP, "Failed to start port %d\n", port_id);
return ret;
#endif
return 0;
}
开发者ID:dodng,项目名称:dpdk-odp,代码行数:28,代码来源:odp_kni.c
示例8: 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
示例9: l2sw_main_process
static void
l2sw_main_process(struct lcore_env *env)
{
struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
uint8_t n_ports = rte_eth_dev_count();
unsigned lcore_id = rte_lcore_id();
uint64_t prev_tsc, diff_tsc, cur_tsc, timer_tsc;
const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S
* BURST_TX_DRAIN_US;
//RTE_LOG(INFO, MARIO, "[%u] Starting main processing.\n", lcore_id);
prev_tsc = 0;
timer_tsc = 0;
while(1) {
cur_tsc = rte_rdtsc();
diff_tsc = cur_tsc - prev_tsc;
if (unlikely(diff_tsc > drain_tsc)) {
uint8_t port_id;
for(port_id = 0; port_id < n_ports; port_id++) {
if (env->tx_mbufs[port_id].len == 0)
continue;
l2sw_send_burst(env, port_id, env->tx_mbufs[port_id].len);
env->tx_mbufs[port_id].len = 0;
}
/* if timer is enabled */
if (timer_period > 0) {
/* advance the timer */
timer_tsc += diff_tsc;
/* if timer has reached its timeout */
if (unlikely(timer_tsc >= (uint64_t) timer_period)) {
/* do this only on master core */
if (lcore_id == rte_get_master_lcore()) {
//print_stats(env);
/* reset the timer */
timer_tsc = 0;
}
}
}
prev_tsc = cur_tsc;
}
/* RX */
uint8_t port_id;
for (port_id = 0; port_id < n_ports; port_id++) {
unsigned n_rx = rte_eth_rx_burst(port_id, lcore_id,
pkt_burst, MAX_PKT_BURST);
if (n_rx != 0)
//RTE_LOG(INFO, MARIO, "[%u-%u] %u packet(s) came.\n",
// lcore_id, port_id, n_rx);
__sync_fetch_and_add(&port_statistics[port_id].rx, n_rx);
ether_in(env, pkt_burst, n_rx, port_id);
}
}
return ;
}
开发者ID:sdnnfv,项目名称:dpdk,代码行数:60,代码来源:router.c
示例10: 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
示例11: qCritical
/**
* @brief Initialize all DPDK devices
*
* @return true on success
*/
bool DPDKAdapter::initializeDevs()
{
if(rte_eal_pci_probe() < 0)
{
qCritical("Cannot probe PCI");
return false;
}
nPortCount = rte_eth_dev_count();
if(nPortCount < 1)
{
qCritical("No ports found");
return false;
}
//Limit devices count
if(nPortCount > RTE_MAX_ETHPORTS)
nPortCount = RTE_MAX_ETHPORTS;
for(u_int8_t portId; portId < nPortCount; ++portId)
{
if(!initDevRxTxMPool(portId))
{
qCritical("TX/RX pools could not been allocated : port %u", portId);
return false;
}
}
return true;
}
开发者ID:sdnnfv,项目名称:dpdkadapter,代码行数:35,代码来源:dpdk_adapter.cpp
示例12: start_loop
static int start_loop(int verbose)
{
struct pg_error *error = NULL;
struct pg_brick *nic_tmp, *switch_east, *print_tmp;
uint16_t port_count = rte_eth_dev_count();
GList *nic_manager = NULL;
GList *manager = NULL;
g_assert(port_count > 1);
/*
* Here is an ascii graph of the links:
*
* [NIC-X] - [PRINT-X] --\
* \
* [NIC-X+1] - [PRINT-X+1] } -- [SWITCH]
* /
* [NIC-X+2] - [PRINT-X+2] /
* ....
*/
switch_east = pg_switch_new("switch", 20, 20, &error);
CHECK_ERROR(error);
PG_BM_ADD(manager, switch_east);
for (int i = 0; i < port_count; ++i) {
nic_tmp = pg_nic_new_by_id("nic", 1, 1, WEST_SIDE, i, &error);
CHECK_ERROR(error);
print_tmp = pg_print_new("print", 1, 1, NULL,
PG_PRINT_FLAG_MAX, NULL,
&error);
CHECK_ERROR(error);
if (!verbose)
pg_brick_chained_links(&error, nic_tmp, switch_east);
else
pg_brick_chained_links(&error, nic_tmp,
print_tmp, switch_east);
CHECK_ERROR(error);
PG_BM_ADD(nic_manager, nic_tmp);
PG_BM_ADD(manager, print_tmp);
}
while (1) {
uint64_t tot_send_pkts = 0;
for (int i = 0; i < 100000; ++i) {
uint16_t nb_send_pkts;
PG_BM_GET_NEXT(nic_manager, nic_tmp);
pg_brick_poll(nic_tmp, &nb_send_pkts, &error);
tot_send_pkts += nb_send_pkts;
CHECK_ERROR(error);
usleep(1);
}
printf("poll pkts: %lu\n", tot_send_pkts);
}
nic_manager = g_list_first(nic_manager);
PG_BM_DESTROY(manager);
PG_BM_DESTROY(nic_manager);
return 0;
}
开发者ID:benoit-canet,项目名称:packetgraph,代码行数:58,代码来源:switch.c
示例13: smp_parse_args
/* Parse the argument given in the command line of the application */
static int
smp_parse_args(int argc, char **argv)
{
int opt, ret;
char **argvopt;
int option_index;
unsigned i, port_mask = 0;
char *prgname = argv[0];
static struct option lgopts[] = {
{PARAM_NUM_PROCS, 1, 0, 0},
{PARAM_PROC_ID, 1, 0, 0},
{NULL, 0, 0, 0}
};
argvopt = argv;
while ((opt = getopt_long(argc, argvopt, "p:", \
lgopts, &option_index)) != EOF) {
switch (opt) {
case 'p':
port_mask = strtoull(optarg, NULL, 16);
break;
/* long options */
case 0:
if (strncmp(lgopts[option_index].name, PARAM_NUM_PROCS, 8) == 0)
num_procs = atoi(optarg);
else if (strncmp(lgopts[option_index].name, PARAM_PROC_ID, 7) == 0)
proc_id = atoi(optarg);
break;
default:
smp_usage(prgname, "Cannot parse all command-line arguments\n");
}
}
if (optind >= 0)
argv[optind-1] = prgname;
if (proc_id < 0)
smp_usage(prgname, "Invalid or missing proc-id parameter\n");
if (rte_eal_process_type() == RTE_PROC_PRIMARY && num_procs == 0)
smp_usage(prgname, "Invalid or missing num-procs parameter\n");
if (port_mask == 0)
smp_usage(prgname, "Invalid or missing port mask\n");
/* get the port numbers from the port mask */
for(i = 0; i < rte_eth_dev_count(); i++)
if(port_mask & (1 << i))
ports[num_ports++] = (uint8_t)i;
ret = optind-1;
optind = 0; /* reset getopt lib */
return (ret);
}
开发者ID:Lanyaaki,项目名称:ipaugenblick,代码行数:57,代码来源:main.c
示例14: 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
示例15: 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
示例16: port_init
static inline int
port_init(uint16_t port, struct rte_mempool *mbuf_pool)
{
struct rte_eth_conf port_conf = port_conf_default;
const uint16_t rx_rings = 1, tx_rings = 1;
int retval;
uint16_t q;
if (port >= rte_eth_dev_count())
return -1;
/* Configure the Ethernet device. */
retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
if (retval != 0)
return retval;
/* Allocate and set up 1 RX queue per Ethernet port. */
for (q = 0; q < rx_rings; q++) {
retval = rte_eth_rx_queue_setup(port, q, RX_RING_SIZE,
rte_eth_dev_socket_id(port), NULL, mbuf_pool);
if (retval < 0)
return retval;
}
/* Allocate and set up 1 TX queue per Ethernet port. */
for (q = 0; q < tx_rings; q++) {
retval = rte_eth_tx_queue_setup(port, q, TX_RING_SIZE,
rte_eth_dev_socket_id(port), NULL);
if (retval < 0)
return retval;
}
/* Start the Ethernet port. */
retval = rte_eth_dev_start(port);
if (retval < 0)
return retval;
/* Display the port MAC address. */
struct ether_addr addr;
rte_eth_macaddr_get(port, &addr);
printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8
" %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n",
(unsigned int)port,
addr.addr_bytes[0], addr.addr_bytes[1],
addr.addr_bytes[2], addr.addr_bytes[3],
addr.addr_bytes[4], addr.addr_bytes[5]);
/* Enable RX in promiscuous mode for the Ethernet device. */
rte_eth_promiscuous_enable(port);
return 0;
}
开发者ID:cleveritcz,项目名称:f-stack,代码行数:53,代码来源:main.c
示例17: tlkp_udp_lcore_init
/*****************************************************************************
* tlkp_udp_lcore_init()
****************************************************************************/
void tlkp_udp_lcore_init(uint32_t lcore_id)
{
unsigned int i;
RTE_PER_LCORE(tlkp_ucb_hash_table) =
rte_zmalloc_socket("udp_hash_table", rte_eth_dev_count() *
TPG_HASH_BUCKET_SIZE *
sizeof(tlkp_hash_bucket_t),
RTE_CACHE_LINE_SIZE,
rte_lcore_to_socket_id(lcore_id));
if (RTE_PER_LCORE(tlkp_ucb_hash_table) == NULL) {
TPG_ERROR_ABORT("[%d]: Failed to allocate per lcore udp htable!\n",
rte_lcore_index(lcore_id));
}
for (i = 0; i < (rte_eth_dev_count() * TPG_HASH_BUCKET_SIZE); i++) {
/*
* Initialize all list headers.
*/
LIST_INIT((&RTE_PER_LCORE(tlkp_ucb_hash_table)[i]));
}
}
开发者ID:Juniper,项目名称:warp17,代码行数:25,代码来源:tpg_udp_lookup.c
示例18: valid_port_id
int
valid_port_id(uint8_t port_id)
{
/* Verify that port id is valid */
int ethdev_count = rte_eth_dev_count();
if (port_id >= ethdev_count) {
RTE_BOND_LOG(ERR, "Port Id %d is greater than rte_eth_dev_count %d",
port_id, ethdev_count);
return -1;
}
return 0;
}
开发者ID:Lanyaaki,项目名称:ipaugenblick,代码行数:13,代码来源:rte_eth_bond_api.c
示例19: kni_config_network_interface
static int
kni_config_network_interface(uint8_t port_id, uint8_t if_up) {
int ret = 0;
if (port_id >= rte_eth_dev_count())
return -EINVAL;
ret = (if_up) ?
rte_eth_dev_set_link_up(port_id) :
rte_eth_dev_set_link_down(port_id);
return ret;
}
开发者ID:emmericp,项目名称:dpdk,代码行数:13,代码来源:init.c
示例20: port_init
/*
* Initialises a given port using global settings and with the rx buffers
* coming from the mbuf_pool passed as parameter
*/
static inline int
port_init(uint8_t port, struct rte_mempool *mbuf_pool)
{
struct rte_eth_conf port_conf;
const uint16_t rxRings = ETH_VMDQ_DCB_NUM_QUEUES,
txRings = (uint16_t)rte_lcore_count();
const uint16_t rxRingSize = 128, txRingSize = 512;
int retval;
uint16_t q;
retval = get_eth_conf(&port_conf, num_pools);
if (retval < 0)
return retval;
if (port >= rte_eth_dev_count()) return -1;
retval = rte_eth_dev_configure(port, rxRings, txRings, &port_conf);
if (retval != 0)
return retval;
for (q = 0; q < rxRings; q ++) {
retval = rte_eth_rx_queue_setup(port, q, rxRingSize,
rte_eth_dev_socket_id(port),
NULL,
mbuf_pool);
if (retval < 0)
return retval;
}
for (q = 0; q < txRings; q ++) {
retval = rte_eth_tx_queue_setup(port, q, txRingSize,
rte_eth_dev_socket_id(port),
NULL);
if (retval < 0)
return retval;
}
retval = rte_eth_dev_start(port);
if (retval < 0)
return retval;
struct ether_addr addr;
rte_eth_macaddr_get(port, &addr);
printf("Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
" %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
(unsigned)port,
addr.addr_bytes[0], addr.addr_bytes[1], addr.addr_bytes[2],
addr.addr_bytes[3], addr.addr_bytes[4], addr.addr_bytes[5]);
return 0;
}
开发者ID:Grindland,项目名称:dpdk-valgrind,代码行数:55,代码来源:main.c
注:本文中的rte_eth_dev_count函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论