| 1285 | } |
| 1286 | |
| 1287 | int |
| 1288 | rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, |
| 1289 | const struct rte_eth_conf *dev_conf) |
| 1290 | { |
| 1291 | enum rte_eth_hash_function algorithm; |
| 1292 | struct rte_eth_dev *dev; |
| 1293 | struct rte_eth_dev_info dev_info; |
| 1294 | struct rte_eth_conf orig_conf; |
| 1295 | int diag; |
| 1296 | int ret; |
| 1297 | uint16_t old_mtu; |
| 1298 | |
| 1299 | RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); |
| 1300 | dev = &rte_eth_devices[port_id]; |
| 1301 | |
| 1302 | if (dev_conf == NULL) { |
| 1303 | RTE_ETHDEV_LOG(ERR, |
| 1304 | "Cannot configure ethdev port %u from NULL config\n", |
| 1305 | port_id); |
| 1306 | return -EINVAL; |
| 1307 | } |
| 1308 | |
| 1309 | if (*dev->dev_ops->dev_configure == NULL) |
| 1310 | return -ENOTSUP; |
| 1311 | |
| 1312 | if (dev->data->dev_started) { |
| 1313 | RTE_ETHDEV_LOG(ERR, |
| 1314 | "Port %u must be stopped to allow configuration\n", |
| 1315 | port_id); |
| 1316 | return -EBUSY; |
| 1317 | } |
| 1318 | |
| 1319 | /* |
| 1320 | * Ensure that "dev_configured" is always 0 each time prepare to do |
| 1321 | * dev_configure() to avoid any non-anticipated behaviour. |
| 1322 | * And set to 1 when dev_configure() is executed successfully. |
| 1323 | */ |
| 1324 | dev->data->dev_configured = 0; |
| 1325 | |
| 1326 | /* Store original config, as rollback required on failure */ |
| 1327 | memcpy(&orig_conf, &dev->data->dev_conf, sizeof(dev->data->dev_conf)); |
| 1328 | |
| 1329 | /* |
| 1330 | * Copy the dev_conf parameter into the dev structure. |
| 1331 | * rte_eth_dev_info_get() requires dev_conf, copy it before dev_info get |
| 1332 | */ |
| 1333 | if (dev_conf != &dev->data->dev_conf) |
| 1334 | memcpy(&dev->data->dev_conf, dev_conf, |
| 1335 | sizeof(dev->data->dev_conf)); |
| 1336 | |
| 1337 | /* Backup mtu for rollback */ |
| 1338 | old_mtu = dev->data->mtu; |
| 1339 | |
| 1340 | /* fields must be zero to reserve them for future ABI changes */ |
| 1341 | if (dev_conf->rxmode.reserved_64s[0] != 0 || |
| 1342 | dev_conf->rxmode.reserved_64s[1] != 0 || |
| 1343 | dev_conf->rxmode.reserved_ptrs[0] != NULL || |
| 1344 | dev_conf->rxmode.reserved_ptrs[1] != NULL) { |