- };
- const uint16_t rx_rings = 1, tx_rings = 1;
- const uint16_t rx_ring_size = 512, tx_ring_size = 512;
- struct rte_eth_conf port_conf = port_conf_default;
- int retval;
- uint16_t q;
- struct rte_eth_dev_info dev_info;
- struct rte_eth_txconf txconf;
-
- if (!rte_eth_dev_is_valid_port(port))
- return -1;
-
- retval = rte_eth_dev_info_get(port, &dev_info);
- if (retval != 0) {
- printf("Error during getting device (port %u) info: %s\n",
- port, strerror(-retval));
- return retval;
- }
-
- if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
- port_conf.txmode.offloads |=
- DEV_TX_OFFLOAD_MBUF_FAST_FREE;
- rx_conf = dev_info.default_rxconf;
- rx_conf.offloads = port_conf.rxmode.offloads;
-
- port_conf.rx_adv_conf.rss_conf.rss_hf &=
- dev_info.flow_type_rss_offloads;
- if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
- port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
- printf("Port %u modified RSS hash function based on hardware support,"
- "requested:%#"PRIx64" configured:%#"PRIx64"\n",
- port,
- port_conf_default.rx_adv_conf.rss_conf.rss_hf,
- port_conf.rx_adv_conf.rss_conf.rss_hf);
- }
-
- /* 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), &rx_conf,
- mbuf_pool);
- if (retval < 0)
- return retval;
- }
-
- txconf = dev_info.default_txconf;
- txconf.offloads = port_conf_default.txmode.offloads;
- /* 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), &txconf);
- if (retval < 0)
- return retval;