diff mbox series

[RFC,for-next,2/6] RDMA/mlx5: remove deliver net device event

Message ID 1579147847-12158-3-git-send-email-liweihang@huawei.com (mailing list archive)
State Changes Requested
Headers show
Series ofed support to send ib port link event | expand

Commit Message

Weihang Li Jan. 16, 2020, 4:10 a.m. UTC
From: Lang Cheng <chenglang@huawei.com>

The code that handles the link event of the net device has been moved
into the core, and the related processing should been removed from the
provider's driver.

Signed-off-by: Lang Cheng <chenglang@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/hw/mlx5/main.c | 95 ++++-----------------------------------
 1 file changed, 9 insertions(+), 86 deletions(-)

Comments

Leon Romanovsky Jan. 16, 2020, 11:41 a.m. UTC | #1
On Thu, Jan 16, 2020 at 12:10:43PM +0800, Weihang Li wrote:
> From: Lang Cheng <chenglang@huawei.com>
>
> The code that handles the link event of the net device has been moved
> into the core, and the related processing should been removed from the
> provider's driver.

I have serious doubts that this patch broke mlx5 LAG functionality.

Thanks
Leon Romanovsky Jan. 20, 2020, 7:45 a.m. UTC | #2
On Mon, Jan 20, 2020 at 03:31:14PM +0800, Lang Cheng wrote:
>
> On 2020/1/16 19:41, Leon Romanovsky wrote:
> > On Thu, Jan 16, 2020 at 12:10:43PM +0800, Weihang Li wrote:
> > > From: Lang Cheng <chenglang@huawei.com>
> > >
> > > The code that handles the link event of the net device has been moved
> > > into the core, and the related processing should been removed from the
> > > provider's driver.
> > I have serious doubts that this patch broke mlx5 LAG functionality.
>
> All vendor drivers need to remove port link event code,
> and query slave info(only if support bonding) in ops.query_port callback.
> Here is about 4 function:
>
> mlx5_netdev_event(): remove all port link event code after ib core supports
> sending them,
>
> mlx5_get_rep_roce(): Only mlx5_netdev_event() ever called it, and now no
> one, so remove it.
>
> get_port_state():just move public operation to ib core.
>
> mlx5_query_port_roce():	query more info, no impact on existing code.
>
>
> Is there any hidden relationship that I didn't notice?

You didn't missed the functions which are relevant to bond, but from
what I saw you implemented wrongly events handling related to mlx5 bond.

I didn't look very deeply yet because the series is far from
completion and maybe I'm mistaken and bond works perfectly.

Thanks

>
> Thanks.
>
> >
> > Thanks
> > _______________________________________________
> > Linuxarm mailing list
> > Linuxarm@huawei.com
> > http://hulk.huawei.com/mailman/listinfo/linuxarm
> >
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 97bcf01..bb0dbfb 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -144,48 +144,6 @@  mlx5_ib_port_link_layer(struct ib_device *device, u8 port_num)
 	return mlx5_port_type_cap_to_rdma_ll(port_type_cap);
 }
 
-static int get_port_state(struct ib_device *ibdev,
-			  u8 port_num,
-			  enum ib_port_state *state)
-{
-	struct ib_port_attr attr;
-	int ret;
-
-	memset(&attr, 0, sizeof(attr));
-	ret = ibdev->ops.query_port(ibdev, port_num, &attr);
-	if (!ret)
-		*state = attr.state;
-	return ret;
-}
-
-static struct mlx5_roce *mlx5_get_rep_roce(struct mlx5_ib_dev *dev,
-					   struct net_device *ndev,
-					   u8 *port_num)
-{
-	struct mlx5_eswitch *esw = dev->mdev->priv.eswitch;
-	struct net_device *rep_ndev;
-	struct mlx5_ib_port *port;
-	int i;
-
-	for (i = 0; i < dev->num_ports; i++) {
-		port  = &dev->port[i];
-		if (!port->rep)
-			continue;
-
-		read_lock(&port->roce.netdev_lock);
-		rep_ndev = mlx5_ib_get_rep_netdev(esw,
-						  port->rep->vport);
-		if (rep_ndev == ndev) {
-			read_unlock(&port->roce.netdev_lock);
-			*port_num = i + 1;
-			return &port->roce;
-		}
-		read_unlock(&port->roce.netdev_lock);
-	}
-
-	return NULL;
-}
-
 static int mlx5_netdev_event(struct notifier_block *this,
 			     unsigned long event, void *ptr)
 {
@@ -219,52 +177,10 @@  static int mlx5_netdev_event(struct notifier_block *this,
 		write_unlock(&roce->netdev_lock);
 		break;
 
-	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 (ibdev->is_rep)
-			roce = mlx5_get_rep_roce(ibdev, ndev, &port_num);
-		if (!roce)
-			return NOTIFY_DONE;
-		if ((upper == ndev || (!upper && ndev == roce->netdev))
-		    && ibdev->ib_active) {
-			struct ib_event ibev = { };
-			enum ib_port_state port_state;
-
-			if (get_port_state(&ibdev->ib_dev, port_num,
-					   &port_state))
-				goto done;
-
-			if (roce->last_port_state == port_state)
-				goto done;
-
-			roce->last_port_state = port_state;
-			ibev.device = &ibdev->ib_dev;
-			if (port_state == IB_PORT_DOWN)
-				ibev.event = IB_EVENT_PORT_ERR;
-			else if (port_state == IB_PORT_ACTIVE)
-				ibev.event = IB_EVENT_PORT_ACTIVE;
-			else
-				goto done;
-
-			ibev.element.port_num = port_num;
-			ib_dispatch_event(&ibev);
-		}
-		break;
-	}
-
 	default:
 		break;
 	}
-done:
+
 	mlx5_ib_put_native_port_mdev(ibdev, port_num);
 	return NOTIFY_DONE;
 }
@@ -569,7 +485,14 @@  static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,
 
 	dev_put(ndev);
 
-	props->active_mtu	= min(props->max_mtu, ndev_ib_mtu);
+	props->active_mtu = min(props->max_mtu, ndev_ib_mtu);
+
+	if ((dev->lag_active && ndev != mlx5_lag_get_roce_netdev(mdev)) ||
+	    (!dev->lag_active && port_num != mdev_port_num))
+		props->port_event_flags = IB_PORT_BONDING_SLAVE;
+	else
+		props->port_event_flags &= ~IB_PORT_BONDING_SLAVE;
+
 out:
 	if (put_mdev)
 		mlx5_ib_put_native_port_mdev(dev, port_num);