diff mbox series

[v3,rdma-next,1/7] RDMA/mlx5: Check RoCE LAG status before getting netdev

Message ID 20240909173025.30422-2-michaelgur@nvidia.com (mailing list archive)
State Accepted
Headers show
Series Support RDMA events monitoring through | expand

Commit Message

Michael Guralnik Sept. 9, 2024, 5:30 p.m. UTC
From: Mark Bloch <mbloch@nvidia.com>

Check if RoCE LAG is active before calling the LAG layer for netdev.
This clarifies if LAG is active. No behavior changes with this patch.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Michael Guralnik <michaelgur@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/mlx5/main.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

Comments

Kalesh Anakkur Purayil Sept. 10, 2024, 3:58 a.m. UTC | #1
On Mon, Sep 9, 2024 at 11:10 PM Michael Guralnik <michaelgur@nvidia.com> wrote:
>
> From: Mark Bloch <mbloch@nvidia.com>
>
> Check if RoCE LAG is active before calling the LAG layer for netdev.
> This clarifies if LAG is active. No behavior changes with this patch.
>
> Signed-off-by: Mark Bloch <mbloch@nvidia.com>
> Signed-off-by: Michael Guralnik <michaelgur@nvidia.com>
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Looks good to me
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> ---
>  drivers/infiniband/hw/mlx5/main.c | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
> index b85ad3c0bfa1..cdf1ce0f6b34 100644
> --- a/drivers/infiniband/hw/mlx5/main.c
> +++ b/drivers/infiniband/hw/mlx5/main.c
> @@ -198,12 +198,18 @@ static int mlx5_netdev_event(struct notifier_block *this,
>         case NETDEV_CHANGE:
>         case NETDEV_UP:
>         case NETDEV_DOWN: {
> -               struct net_device *lag_ndev = mlx5_lag_get_roce_netdev(mdev);
>                 struct net_device *upper = NULL;
>
> -               if (lag_ndev) {
> -                       upper = netdev_master_upper_dev_get(lag_ndev);
> -                       dev_put(lag_ndev);
> +               if (mlx5_lag_is_roce(mdev)) {
> +                       struct net_device *lag_ndev;
> +
> +                       lag_ndev = mlx5_lag_get_roce_netdev(mdev);
> +                       if (lag_ndev) {
> +                               upper = netdev_master_upper_dev_get(lag_ndev);
> +                               dev_put(lag_ndev);
> +                       } else {
> +                               goto done;
> +                       }
>                 }
>
>                 if (ibdev->is_rep)
> @@ -257,9 +263,10 @@ static struct net_device *mlx5_ib_get_netdev(struct ib_device *device,
>         if (!mdev)
>                 return NULL;
>
> -       ndev = mlx5_lag_get_roce_netdev(mdev);
> -       if (ndev)
> +       if (mlx5_lag_is_roce(mdev)) {
> +               ndev = mlx5_lag_get_roce_netdev(mdev);
>                 goto out;
> +       }
>
>         /* Ensure ndev does not disappear before we invoke dev_hold()
>          */
> --
> 2.17.2
>
>
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index b85ad3c0bfa1..cdf1ce0f6b34 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -198,12 +198,18 @@  static int mlx5_netdev_event(struct notifier_block *this,
 	case NETDEV_CHANGE:
 	case NETDEV_UP:
 	case NETDEV_DOWN: {
-		struct net_device *lag_ndev = mlx5_lag_get_roce_netdev(mdev);
 		struct net_device *upper = NULL;
 
-		if (lag_ndev) {
-			upper = netdev_master_upper_dev_get(lag_ndev);
-			dev_put(lag_ndev);
+		if (mlx5_lag_is_roce(mdev)) {
+			struct net_device *lag_ndev;
+
+			lag_ndev = mlx5_lag_get_roce_netdev(mdev);
+			if (lag_ndev) {
+				upper = netdev_master_upper_dev_get(lag_ndev);
+				dev_put(lag_ndev);
+			} else {
+				goto done;
+			}
 		}
 
 		if (ibdev->is_rep)
@@ -257,9 +263,10 @@  static struct net_device *mlx5_ib_get_netdev(struct ib_device *device,
 	if (!mdev)
 		return NULL;
 
-	ndev = mlx5_lag_get_roce_netdev(mdev);
-	if (ndev)
+	if (mlx5_lag_is_roce(mdev)) {
+		ndev = mlx5_lag_get_roce_netdev(mdev);
 		goto out;
+	}
 
 	/* Ensure ndev does not disappear before we invoke dev_hold()
 	 */