[2/7] net/mlx5: use direct API to find port by device

Message ID 1592998387-28181-2-git-send-email-michaelba@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers
Series [1/7] common/mlx5: fix code arrangement in tag allocation |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Michael Baum June 24, 2020, 11:33 a.m. UTC
  Using RTE_ETH_FOREACH_DEV_OF loop is not necessary when the driver wants
to find only the first match.

Use rte_eth_find_next_of to find it.

Signed-off-by: Michael Baum <michaelba@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/mlx5_mr.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
  

Comments

Raslan Darawsheh June 28, 2020, 1:55 p.m. UTC | #1
Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Michael Baum
> Sent: Wednesday, June 24, 2020 2:33 PM
> To: dev@dpdk.org
> Cc: Matan Azrad <matan@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>
> Subject: [dpdk-dev] [PATCH 2/7] net/mlx5: use direct API to find port by
> device
> 
> Using RTE_ETH_FOREACH_DEV_OF loop is not necessary when the driver
> wants
> to find only the first match.
> 
> Use rte_eth_find_next_of to find it.
> 
> Signed-off-by: Michael Baum <michaelba@mellanox.com>
> Acked-by: Matan Azrad <matan@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_mr.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
> index adbe07c..3b781b6 100644
> --- a/drivers/net/mlx5/mlx5_mr.c
> +++ b/drivers/net/mlx5/mlx5_mr.c
> @@ -313,9 +313,10 @@ struct mr_update_mp_data {
>  {
>  	uint16_t port_id;
> 
> -	RTE_ETH_FOREACH_DEV_OF(port_id, &pdev->device)
> -		return &rte_eth_devices[port_id];
> -	return NULL;
> +	port_id = rte_eth_find_next_of(0, &pdev->device);
> +	if (port_id == RTE_MAX_ETHPORTS)
> +		return NULL;
> +	return &rte_eth_devices[port_id];
>  }
> 
>  /**
> --
> 1.8.3.1


Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index adbe07c..3b781b6 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -313,9 +313,10 @@  struct mr_update_mp_data {
 {
 	uint16_t port_id;
 
-	RTE_ETH_FOREACH_DEV_OF(port_id, &pdev->device)
-		return &rte_eth_devices[port_id];
-	return NULL;
+	port_id = rte_eth_find_next_of(0, &pdev->device);
+	if (port_id == RTE_MAX_ETHPORTS)
+		return NULL;
+	return &rte_eth_devices[port_id];
 }
 
 /**