Commit 88621dfe authored by Aviv Heller's avatar Aviv Heller Committed by Doug Ledford

IB/mlx5: Port status track LAG master, when LAG is active

When LAG is active, port up/down events should be triggered
by tracking the LAG master, and not one of the two slave
netdevs.

In the same manner, ib_query_port() should return the details
of the LAG master.
Signed-off-by: default avatarAviv Heller <avivh@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 9ef9c640
...@@ -118,8 +118,17 @@ static int mlx5_netdev_event(struct notifier_block *this, ...@@ -118,8 +118,17 @@ static int mlx5_netdev_event(struct notifier_block *this,
break; break;
case NETDEV_UP: case NETDEV_UP:
case NETDEV_DOWN: case NETDEV_DOWN: {
if (ndev == ibdev->roce.netdev && ibdev->ib_active) { struct net_device *lag_ndev = mlx5_lag_get_roce_netdev(ibdev->mdev);
struct net_device *upper = NULL;
if (lag_ndev) {
upper = netdev_master_upper_dev_get(lag_ndev);
dev_put(lag_ndev);
}
if ((upper == ndev || (!upper && ndev == ibdev->roce.netdev))
&& ibdev->ib_active) {
struct ib_event ibev = {0}; struct ib_event ibev = {0};
ibev.device = &ibdev->ib_dev; ibev.device = &ibdev->ib_dev;
...@@ -129,6 +138,7 @@ static int mlx5_netdev_event(struct notifier_block *this, ...@@ -129,6 +138,7 @@ static int mlx5_netdev_event(struct notifier_block *this,
ib_dispatch_event(&ibev); ib_dispatch_event(&ibev);
} }
break; break;
}
default: default:
break; break;
...@@ -143,6 +153,10 @@ static struct net_device *mlx5_ib_get_netdev(struct ib_device *device, ...@@ -143,6 +153,10 @@ static struct net_device *mlx5_ib_get_netdev(struct ib_device *device,
struct mlx5_ib_dev *ibdev = to_mdev(device); struct mlx5_ib_dev *ibdev = to_mdev(device);
struct net_device *ndev; struct net_device *ndev;
ndev = mlx5_lag_get_roce_netdev(ibdev->mdev);
if (ndev)
return ndev;
/* Ensure ndev does not disappear before we invoke dev_hold() /* Ensure ndev does not disappear before we invoke dev_hold()
*/ */
read_lock(&ibdev->roce.netdev_lock); read_lock(&ibdev->roce.netdev_lock);
...@@ -158,7 +172,7 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num, ...@@ -158,7 +172,7 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,
struct ib_port_attr *props) struct ib_port_attr *props)
{ {
struct mlx5_ib_dev *dev = to_mdev(device); struct mlx5_ib_dev *dev = to_mdev(device);
struct net_device *ndev; struct net_device *ndev, *upper;
enum ib_mtu ndev_ib_mtu; enum ib_mtu ndev_ib_mtu;
u16 qkey_viol_cntr; u16 qkey_viol_cntr;
...@@ -182,6 +196,17 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num, ...@@ -182,6 +196,17 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,
if (!ndev) if (!ndev)
return 0; return 0;
if (mlx5_lag_is_active(dev->mdev)) {
rcu_read_lock();
upper = netdev_master_upper_dev_get_rcu(ndev);
if (upper) {
dev_put(ndev);
ndev = upper;
dev_hold(ndev);
}
rcu_read_unlock();
}
if (netif_running(ndev) && netif_carrier_ok(ndev)) { if (netif_running(ndev) && netif_carrier_ok(ndev)) {
props->state = IB_PORT_ACTIVE; props->state = IB_PORT_ACTIVE;
props->phys_state = 5; props->phys_state = 5;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment