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

Function initialize_ports

dpdk/examples/l2fwd-crypto/main.c:2562–2697  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2560}
2561
2562static int
2563initialize_ports(struct l2fwd_crypto_options *options)
2564{
2565 uint16_t last_portid = 0, portid;
2566 unsigned enabled_portcount = 0;
2567 unsigned nb_ports = rte_eth_dev_count_avail();
2568
2569 if (nb_ports == 0) {
2570 printf("No Ethernet ports - bye\n");
2571 return -1;
2572 }
2573
2574 /* Reset l2fwd_dst_ports */
2575 for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
2576 l2fwd_dst_ports[portid] = 0;
2577
2578 RTE_ETH_FOREACH_DEV(portid) {
2579 int retval;
2580 struct rte_eth_dev_info dev_info;
2581 struct rte_eth_rxconf rxq_conf;
2582 struct rte_eth_txconf txq_conf;
2583 struct rte_eth_conf local_port_conf = port_conf;
2584
2585 /* Skip ports that are not enabled */
2586 if ((options->portmask & (1 << portid)) == 0)
2587 continue;
2588
2589 /* init port */
2590 printf("Initializing port %u... ", portid);
2591 fflush(stdout);
2592
2593 retval = rte_eth_dev_info_get(portid, &dev_info);
2594 if (retval != 0) {
2595 printf("Error during getting device (port %u) info: %s\n",
2596 portid, strerror(-retval));
2597 return retval;
2598 }
2599
2600 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)
2601 local_port_conf.txmode.offloads |=
2602 RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
2603 retval = rte_eth_dev_configure(portid, 1, 1, &local_port_conf);
2604 if (retval < 0) {
2605 printf("Cannot configure device: err=%d, port=%u\n",
2606 retval, portid);
2607 return -1;
2608 }
2609
2610 retval = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
2611 &nb_txd);
2612 if (retval < 0) {
2613 printf("Cannot adjust number of descriptors: err=%d, port=%u\n",
2614 retval, portid);
2615 return -1;
2616 }
2617
2618 /* init one RX queue */
2619 fflush(stdout);

Callers 1

mainFunction · 0.70

Calls 14

rte_eth_dev_count_availFunction · 0.85
rte_eth_dev_info_getFunction · 0.85
rte_eth_dev_configureFunction · 0.85
rte_eth_rx_queue_setupFunction · 0.85
rte_eth_dev_socket_idFunction · 0.85
rte_eth_tx_queue_setupFunction · 0.85
rte_eth_dev_startFunction · 0.85
rte_strerrorFunction · 0.85
rte_eth_macaddr_getFunction · 0.85
memsetFunction · 0.85

Tested by

no test coverage detected