[v2,5/7] ethdev: use hairpin helper functions
diff mbox series

Message ID 20200903211000.244931-5-ferruh.yigit@intel.com
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • [v2,1/7] ethdev: remove legacy descriptor status check API
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ferruh Yigit Sept. 3, 2020, 9:09 p.m. UTC
Hairpin helper functions were not used by drivers, but it was used only
local to ethdev. They are:
'rte_eth_dev_is_rx_hairpin_queue()'
'rte_eth_dev_is_tx_hairpin_queue()'

Exposing them as internal APIs and update mlx5 driver (only user of
hairpin) to use them.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/mlx5/mlx5_rxq.c              | 4 ++--
 drivers/net/mlx5/mlx5_txq.c              | 4 ++--
 lib/librte_ethdev/rte_ethdev_driver.h    | 2 ++
 lib/librte_ethdev/rte_ethdev_version.map | 2 ++
 4 files changed, 8 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 946f7454f6..1b729f7ab2 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -542,7 +542,7 @@  mlx5_rx_queue_stop(struct rte_eth_dev *dev, uint16_t idx)
 	eth_rx_burst_t pkt_burst = dev->rx_pkt_burst;
 	int ret;
 
-	if (dev->data->rx_queue_state[idx] == RTE_ETH_QUEUE_STATE_HAIRPIN) {
+	if (rte_eth_dev_is_rx_hairpin_queue(dev, idx)) {
 		DRV_LOG(ERR, "Hairpin queue can't be stopped");
 		rte_errno = EINVAL;
 		return -EINVAL;
@@ -653,7 +653,7 @@  mlx5_rx_queue_start(struct rte_eth_dev *dev, uint16_t idx)
 {
 	int ret;
 
-	if (dev->data->rx_queue_state[idx] == RTE_ETH_QUEUE_STATE_HAIRPIN) {
+	if (rte_eth_dev_is_rx_hairpin_queue(dev, idx)) {
 		DRV_LOG(ERR, "Hairpin queue can't be started");
 		rte_errno = EINVAL;
 		return -EINVAL;
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 66ad368e64..450d9641de 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -244,7 +244,7 @@  mlx5_tx_queue_stop(struct rte_eth_dev *dev, uint16_t idx)
 {
 	int ret;
 
-	if (dev->data->tx_queue_state[idx] == RTE_ETH_QUEUE_STATE_HAIRPIN) {
+	if (rte_eth_dev_is_tx_hairpin_queue(dev, idx)) {
 		DRV_LOG(ERR, "Hairpin queue can't be stopped");
 		rte_errno = EINVAL;
 		return -EINVAL;
@@ -371,7 +371,7 @@  mlx5_tx_queue_start(struct rte_eth_dev *dev, uint16_t idx)
 {
 	int ret;
 
-	if (dev->data->tx_queue_state[idx] == RTE_ETH_QUEUE_STATE_HAIRPIN) {
+	if (rte_eth_dev_is_tx_hairpin_queue(dev, idx)) {
 		DRV_LOG(ERR, "Hairpin queue can't be started");
 		rte_errno = EINVAL;
 		return -EINVAL;
diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h
index 3d1bc33272..5dfe9fdf1a 100644
--- a/lib/librte_ethdev/rte_ethdev_driver.h
+++ b/lib/librte_ethdev/rte_ethdev_driver.h
@@ -734,6 +734,7 @@  struct eth_dev_ops {
  * @return
  *   - (1) if the queue is hairpin queue, 0 otherwise.
  */
+__rte_internal
 int rte_eth_dev_is_rx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
 
 /**
@@ -748,6 +749,7 @@  int rte_eth_dev_is_rx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
  * @return
  *   - (1) if the queue is hairpin queue, 0 otherwise.
  */
+__rte_internal
 int rte_eth_dev_is_tx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
 
 /**
diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map
index 6a84f3d76d..5db3fb156a 100644
--- a/lib/librte_ethdev/rte_ethdev_version.map
+++ b/lib/librte_ethdev/rte_ethdev_version.map
@@ -237,6 +237,8 @@  INTERNAL {
 	rte_eth_dev_attach_secondary;
 	rte_eth_dev_create;
 	rte_eth_dev_destroy;
+	rte_eth_dev_is_rx_hairpin_queue;
+	rte_eth_dev_is_tx_hairpin_queue;
 	rte_eth_dev_probing_finish;
 	rte_eth_dev_release_port;
 	rte_eth_devargs_parse;