| 2467 | } |
| 2468 | |
| 2469 | int |
| 2470 | rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id, |
| 2471 | uint16_t nb_tx_desc, unsigned int socket_id, |
| 2472 | const struct rte_eth_txconf *tx_conf) |
| 2473 | { |
| 2474 | struct rte_eth_dev *dev; |
| 2475 | struct rte_eth_dev_info dev_info; |
| 2476 | struct rte_eth_txconf local_conf; |
| 2477 | int ret; |
| 2478 | |
| 2479 | RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); |
| 2480 | dev = &rte_eth_devices[port_id]; |
| 2481 | |
| 2482 | if (tx_queue_id >= dev->data->nb_tx_queues) { |
| 2483 | RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u\n", tx_queue_id); |
| 2484 | return -EINVAL; |
| 2485 | } |
| 2486 | |
| 2487 | if (*dev->dev_ops->tx_queue_setup == NULL) |
| 2488 | return -ENOTSUP; |
| 2489 | |
| 2490 | if (tx_conf != NULL && |
| 2491 | (tx_conf->reserved_64s[0] != 0 || |
| 2492 | tx_conf->reserved_64s[1] != 0 || |
| 2493 | tx_conf->reserved_ptrs[0] != NULL || |
| 2494 | tx_conf->reserved_ptrs[1] != NULL)) { |
| 2495 | RTE_ETHDEV_LOG(ERR, "Tx conf reserved fields not zero\n"); |
| 2496 | return -EINVAL; |
| 2497 | } |
| 2498 | |
| 2499 | ret = rte_eth_dev_info_get(port_id, &dev_info); |
| 2500 | if (ret != 0) |
| 2501 | return ret; |
| 2502 | |
| 2503 | /* Use default specified by driver, if nb_tx_desc is zero */ |
| 2504 | if (nb_tx_desc == 0) { |
| 2505 | nb_tx_desc = dev_info.default_txportconf.ring_size; |
| 2506 | /* If driver default is zero, fall back on EAL default */ |
| 2507 | if (nb_tx_desc == 0) |
| 2508 | nb_tx_desc = RTE_ETH_DEV_FALLBACK_TX_RINGSIZE; |
| 2509 | } |
| 2510 | if (nb_tx_desc > dev_info.tx_desc_lim.nb_max || |
| 2511 | nb_tx_desc < dev_info.tx_desc_lim.nb_min || |
| 2512 | nb_tx_desc % dev_info.tx_desc_lim.nb_align != 0) { |
| 2513 | RTE_ETHDEV_LOG(ERR, |
| 2514 | "Invalid value for nb_tx_desc(=%hu), should be: <= %hu, >= %hu, and a product of %hu\n", |
| 2515 | nb_tx_desc, dev_info.tx_desc_lim.nb_max, |
| 2516 | dev_info.tx_desc_lim.nb_min, |
| 2517 | dev_info.tx_desc_lim.nb_align); |
| 2518 | return -EINVAL; |
| 2519 | } |
| 2520 | |
| 2521 | if (dev->data->dev_started && |
| 2522 | !(dev_info.dev_capa & |
| 2523 | RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP)) |
| 2524 | return -EBUSY; |
| 2525 | |
| 2526 | if (dev->data->dev_started && |