| 274 | } |
| 275 | |
| 276 | static inline int |
| 277 | configure_eth_port(uint16_t port_id) |
| 278 | { |
| 279 | struct rte_ether_addr addr; |
| 280 | const uint16_t rxRings = 1, txRings = 1; |
| 281 | int ret; |
| 282 | uint16_t q; |
| 283 | uint16_t nb_rxd = RX_DESC_PER_QUEUE; |
| 284 | uint16_t nb_txd = TX_DESC_PER_QUEUE; |
| 285 | struct rte_eth_dev_info dev_info; |
| 286 | struct rte_eth_txconf txconf; |
| 287 | struct rte_eth_conf port_conf = port_conf_default; |
| 288 | |
| 289 | if (!rte_eth_dev_is_valid_port(port_id)) |
| 290 | return -1; |
| 291 | |
| 292 | ret = rte_eth_dev_info_get(port_id, &dev_info); |
| 293 | if (ret != 0) { |
| 294 | printf("Error during getting device (port %u) info: %s\n", |
| 295 | port_id, strerror(-ret)); |
| 296 | return ret; |
| 297 | } |
| 298 | |
| 299 | if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) |
| 300 | port_conf.txmode.offloads |= |
| 301 | RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE; |
| 302 | ret = rte_eth_dev_configure(port_id, rxRings, txRings, &port_conf); |
| 303 | if (ret != 0) |
| 304 | return ret; |
| 305 | |
| 306 | ret = rte_eth_dev_adjust_nb_rx_tx_desc(port_id, &nb_rxd, &nb_txd); |
| 307 | if (ret != 0) |
| 308 | return ret; |
| 309 | |
| 310 | for (q = 0; q < rxRings; q++) { |
| 311 | ret = rte_eth_rx_queue_setup(port_id, q, nb_rxd, |
| 312 | rte_eth_dev_socket_id(port_id), NULL, |
| 313 | mbuf_pool); |
| 314 | if (ret < 0) |
| 315 | return ret; |
| 316 | } |
| 317 | |
| 318 | txconf = dev_info.default_txconf; |
| 319 | txconf.offloads = port_conf.txmode.offloads; |
| 320 | for (q = 0; q < txRings; q++) { |
| 321 | ret = rte_eth_tx_queue_setup(port_id, q, nb_txd, |
| 322 | rte_eth_dev_socket_id(port_id), &txconf); |
| 323 | if (ret < 0) |
| 324 | return ret; |
| 325 | } |
| 326 | |
| 327 | ret = rte_eth_dev_start(port_id); |
| 328 | if (ret < 0) |
| 329 | return ret; |
| 330 | |
| 331 | ret = rte_eth_macaddr_get(port_id, &addr); |
| 332 | if (ret != 0) { |
| 333 | printf("Failed to get MAC address (port %u): %s\n", |
no test coverage detected