net/mlx5: replace a port lookup with ethdev API

Message ID 20190418001529.7528-1-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Delegated to: Shahaf Shuler
Headers
Series net/mlx5: replace a port lookup with ethdev API |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Thomas Monjalon April 18, 2019, 12:15 a.m. UTC
  Looking for an ethdev port is better (and more efficient)
with an ethdev API than an EAL one.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/net/mlx5/mlx5_mr.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
  

Comments

Shahaf Shuler April 22, 2019, 5:46 p.m. UTC | #1
Thursday, April 18, 2019 3:15 AM, Thomas Monjalon:
> Subject: [PATCH] net/mlx5: replace a port lookup with ethdev API
> 
> Looking for an ethdev port is better (and more efficient) with an ethdev API
> than an EAL one.
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

Applied to next-net-mlx, thanks.
  

Patch

diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index 44b65916d..8f35cb2d8 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -1310,16 +1310,10 @@  mlx5_mr_update_ext_mp_cb(struct rte_mempool *mp, void *opaque,
 static struct rte_eth_dev *
 pci_dev_to_eth_dev(struct rte_pci_device *pdev)
 {
-	struct rte_dev_iterator it;
-	struct rte_device *dev;
+	uint16_t port_id;
 
-	/**
-	 *  We really need to iterate all devices regardless of
-	 *  their owner.
-	 */
-	RTE_DEV_FOREACH(dev, "class=eth", &it)
-		if (dev == &pdev->device)
-			return it.class_device;
+	RTE_ETH_FOREACH_DEV_OF(port_id, &pdev->device)
+		return &rte_eth_devices[port_id];
 	return NULL;
 }