Port initialization. 8< */
| 117 | |
| 118 | /* Port initialization. 8< */ |
| 119 | static inline int |
| 120 | port_init(uint16_t port, struct rte_mempool *mbuf_pool) |
| 121 | { |
| 122 | struct rte_eth_conf port_conf; |
| 123 | const uint16_t rx_rings = 1, tx_rings = 1; |
| 124 | uint16_t nb_rxd = RX_RING_SIZE; |
| 125 | uint16_t nb_txd = TX_RING_SIZE; |
| 126 | int retval; |
| 127 | uint16_t q; |
| 128 | struct rte_eth_dev_info dev_info; |
| 129 | struct rte_eth_rxconf rxconf; |
| 130 | struct rte_eth_txconf txconf; |
| 131 | |
| 132 | if (!rte_eth_dev_is_valid_port(port)) |
| 133 | return -1; |
| 134 | |
| 135 | memset(&port_conf, 0, sizeof(struct rte_eth_conf)); |
| 136 | |
| 137 | retval = rte_eth_dev_info_get(port, &dev_info); |
| 138 | if (retval != 0) { |
| 139 | printf("Error during getting device (port %u) info: %s\n", |
| 140 | port, strerror(-retval)); |
| 141 | |
| 142 | return retval; |
| 143 | } |
| 144 | |
| 145 | if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) |
| 146 | port_conf.txmode.offloads |= |
| 147 | RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE; |
| 148 | |
| 149 | if (hw_timestamping) { |
| 150 | if (!(dev_info.rx_offload_capa & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) { |
| 151 | printf("\nERROR: Port %u does not support hardware timestamping\n" |
| 152 | , port); |
| 153 | return -1; |
| 154 | } |
| 155 | port_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_TIMESTAMP; |
| 156 | rte_mbuf_dyn_rx_timestamp_register(&hwts_dynfield_offset, NULL); |
| 157 | if (hwts_dynfield_offset < 0) { |
| 158 | printf("ERROR: Failed to register timestamp field\n"); |
| 159 | return -rte_errno; |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf); |
| 164 | if (retval != 0) |
| 165 | return retval; |
| 166 | |
| 167 | retval = rte_eth_dev_adjust_nb_rx_tx_desc(port, &nb_rxd, &nb_txd); |
| 168 | if (retval != 0) |
| 169 | return retval; |
| 170 | |
| 171 | rxconf = dev_info.default_rxconf; |
| 172 | |
| 173 | for (q = 0; q < rx_rings; q++) { |
| 174 | retval = rte_eth_rx_queue_setup(port, q, nb_rxd, |
| 175 | rte_eth_dev_socket_id(port), &rxconf, mbuf_pool); |
| 176 | if (retval < 0) |
nothing calls this directly
no test coverage detected