Skip to content

Commit

Permalink
ethdev: add API to check if queue is available
Browse files Browse the repository at this point in the history
The API rte_eth_dev_rxq/txq_avail which
is used to check if Rx/Tx queue is available.

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
Dengdui Huang authored and ovsrobot committed May 25, 2023
1 parent 2d9e109 commit eb91c77
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/guides/rel_notes/release_23_07.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ New Features
=======================================================
* **Added ethdev Rx/Tx queue ID check API.**

Added ethdev Rx/Tx queue ID check API which provides functions
for check if Rx/Tx queue is available.


Removed Items
-------------

Expand Down
22 changes: 22 additions & 0 deletions lib/ethdev/rte_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,28 @@ eth_dev_validate_tx_queue(const struct rte_eth_dev *dev, uint16_t tx_queue_id)
return 0;
}

int
rte_eth_dev_rxq_avail(uint16_t port_id, uint16_t queue_id)
{
struct rte_eth_dev *dev;

RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
dev = &rte_eth_devices[port_id];

return eth_dev_validate_rx_queue(dev, queue_id);
}

int
rte_eth_dev_txq_avail(uint16_t port_id, uint16_t queue_id)
{
struct rte_eth_dev *dev;

RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
dev = &rte_eth_devices[port_id];

return eth_dev_validate_tx_queue(dev, queue_id);
}

int
rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id)
{
Expand Down
36 changes: 36 additions & 0 deletions lib/ethdev/rte_ethdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -2665,6 +2665,42 @@ int rte_eth_dev_socket_id(uint16_t port_id);
*/
int rte_eth_dev_is_valid_port(uint16_t port_id);

/**
* @warning
* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
*
* Check if Rx queue is available.
*
* @param port_id
* The port identifier of the Ethernet device.
* @param queue_id
* The index of the receive queue.
* @return
* - -ENODEV: if *port_id* is invalid.
* - -EINVAL: if queue is out of range or not been setup.
* - 0 if Rx queue is available.
*/
__rte_experimental
int rte_eth_dev_rxq_avail(uint16_t port_id, uint16_t queue_id);

/**
* @warning
* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
*
* Check if Tx queue is available.
*
* @param port_id
* The port identifier of the Ethernet device.
* @param queue_id
* The index of the transmit queue.
* @return
* - -ENODEV: if *port_id* is invalid.
* - -EINVAL: if queue is out of range or not been setup.
* - 0 if Tx queue is available.
*/
__rte_experimental
int rte_eth_dev_txq_avail(uint16_t port_id, uint16_t queue_id);

/**
* Start specified Rx queue of a port. It is used when rx_deferred_start
* flag of the specified queue is true.
Expand Down
4 changes: 4 additions & 0 deletions lib/ethdev/version.map
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ EXPERIMENTAL {
rte_flow_action_handle_query_update;
rte_flow_async_action_handle_query_update;
rte_flow_async_create_by_index;

# added in 23.07
rte_eth_dev_rxq_avail;
rte_eth_dev_txq_avail;
};

INTERNAL {
Expand Down

0 comments on commit eb91c77

Please sign in to comment.