diff mbox series

[V3,1/1] mlx4: trigger IB events needed by SMC

Message ID 20181112114155.44750-1-ubraun@linux.ibm.com (mailing list archive)
State Accepted
Commit fc6526fba130dcbd496b96a9abf75a9382da95da
Delegated to: Jason Gunthorpe
Headers show
Series [V3,1/1] mlx4: trigger IB events needed by SMC | expand

Commit Message

Ursula Braun Nov. 12, 2018, 11:41 a.m. UTC
The mlx4 driver does not trigger an IB_EVENT_PORT_ACTIVE when the
RoCE network interface is activated. When SMC determines the RoCE
device port to be used, it checks the port states.
This patch triggers IB events for NETDEV_UP and NETDEV_DOWN.

v1->v2:
take into account previous port states (IB_PORT_DOWN vs. IB_PORT_ACTIVE).

v2->v3:
this change log added.

Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
---
 drivers/infiniband/hw/mlx4/main.c    | 27 +++++++++++++++++++++++++++
 drivers/infiniband/hw/mlx4/mlx4_ib.h |  1 +
 2 files changed, 28 insertions(+)

Comments

Leon Romanovsky Nov. 13, 2018, 1:35 p.m. UTC | #1
On Mon, Nov 12, 2018 at 12:41:55PM +0100, Ursula Braun wrote:
> The mlx4 driver does not trigger an IB_EVENT_PORT_ACTIVE when the
> RoCE network interface is activated. When SMC determines the RoCE
> device port to be used, it checks the port states.
> This patch triggers IB events for NETDEV_UP and NETDEV_DOWN.
>
> v1->v2:
> take into account previous port states (IB_PORT_DOWN vs. IB_PORT_ACTIVE).
>
> v2->v3:
> this change log added.

The changelog should be below "---" line and after SOB.
It ensures that such information won't appear in git log.

I took it for regression.
Thanks a lot for your work.

>
> Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
> ---
>  drivers/infiniband/hw/mlx4/main.c    | 27 +++++++++++++++++++++++++++
>  drivers/infiniband/hw/mlx4/mlx4_ib.h |  1 +
>  2 files changed, 28 insertions(+)
>
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 0def2323459c..b73b5fa1822a 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2352,6 +2352,32 @@ static void mlx4_ib_scan_netdevs(struct mlx4_ib_dev *ibdev,
>  		     event == NETDEV_UP || event == NETDEV_CHANGE))
>  			update_qps_port = port;
>
> +		if (dev == iboe->netdevs[port - 1] &&
> +		    (event == NETDEV_UP || event == NETDEV_DOWN)) {
> +			enum ib_port_state port_state;
> +			struct ib_event ibev = { };
> +
> +			if (ib_get_cached_port_state(&ibdev->ib_dev, port,
> +						     &port_state))
> +				continue;
> +
> +			if (event == NETDEV_UP &&
> +			    (port_state != IB_PORT_ACTIVE ||
> +			     iboe->last_port_state[port - 1] != IB_PORT_DOWN))
> +				continue;
> +			if (event == NETDEV_DOWN &&
> +			    (port_state != IB_PORT_DOWN ||
> +			     iboe->last_port_state[port - 1] != IB_PORT_ACTIVE))
> +				continue;
> +			iboe->last_port_state[port - 1] = port_state;
> +
> +			ibev.device = &ibdev->ib_dev;
> +			ibev.element.port_num = port;
> +			ibev.event = event == NETDEV_UP ? IB_EVENT_PORT_ACTIVE :
> +							  IB_EVENT_PORT_ERR;
> +			ib_dispatch_event(&ibev);
> +		}
> +
>  	}
>  	spin_unlock_bh(&iboe->lock);
>
> @@ -2710,6 +2736,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
>  	for (i = 0; i < ibdev->num_ports; ++i) {
>  		mutex_init(&ibdev->counters_table[i].mutex);
>  		INIT_LIST_HEAD(&ibdev->counters_table[i].counters_list);
> +		iboe->last_port_state[i] = IB_PORT_DOWN;
>  	}
>
>  	num_req_counters = mlx4_is_bonded(dev) ? 1 : ibdev->num_ports;
> diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> index 8850dfc3826d..5cb52424912e 100644
> --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
> +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> @@ -519,6 +519,7 @@ struct mlx4_ib_iboe {
>  	atomic64_t		mac[MLX4_MAX_PORTS];
>  	struct notifier_block 	nb;
>  	struct mlx4_port_gid_table gids[MLX4_MAX_PORTS];
> +	enum ib_port_state	last_port_state[MLX4_MAX_PORTS];
>  };
>
>  struct pkey_mgt {
> --
> 2.16.4
>
Jason Gunthorpe Nov. 21, 2018, 10:24 p.m. UTC | #2
On Tue, Nov 13, 2018 at 6:35 AM Leon Romanovsky <leon@kernel.org> wrote:
>
> On Mon, Nov 12, 2018 at 12:41:55PM +0100, Ursula Braun wrote:
> > The mlx4 driver does not trigger an IB_EVENT_PORT_ACTIVE when the
> > RoCE network interface is activated. When SMC determines the RoCE
> > device port to be used, it checks the port states.
> > This patch triggers IB events for NETDEV_UP and NETDEV_DOWN.
> >
> > v1->v2:
> > take into account previous port states (IB_PORT_DOWN vs. IB_PORT_ACTIVE).
> >
> > v2->v3:
> > this change log added.
>
> The changelog should be below "---" line and after SOB.
> It ensures that such information won't appear in git log.
>
> I took it for regression.
> Thanks a lot for your work.

Yes, no?

Thanks,
Jason
Leon Romanovsky Nov. 22, 2018, 12:59 p.m. UTC | #3
On Mon, Nov 12, 2018 at 12:41:55PM +0100, Ursula Braun wrote:
> The mlx4 driver does not trigger an IB_EVENT_PORT_ACTIVE when the
> RoCE network interface is activated. When SMC determines the RoCE
> device port to be used, it checks the port states.
> This patch triggers IB events for NETDEV_UP and NETDEV_DOWN.
>
> v1->v2:
> take into account previous port states (IB_PORT_DOWN vs. IB_PORT_ACTIVE).
>
> v2->v3:
> this change log added.
>
> Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
> ---
>  drivers/infiniband/hw/mlx4/main.c    | 27 +++++++++++++++++++++++++++
>  drivers/infiniband/hw/mlx4/mlx4_ib.h |  1 +
>  2 files changed, 28 insertions(+)
>

Thanks a lot for your work and patience.
Acked-by: Leon Romanovsky <leonro@mellanox.com>
Jason Gunthorpe Nov. 22, 2018, 6:26 p.m. UTC | #4
On Mon, Nov 12, 2018 at 12:41:55PM +0100, Ursula Braun wrote:
> The mlx4 driver does not trigger an IB_EVENT_PORT_ACTIVE when the
> RoCE network interface is activated. When SMC determines the RoCE
> device port to be used, it checks the port states.
> This patch triggers IB events for NETDEV_UP and NETDEV_DOWN.
> 
> v1->v2:
> take into account previous port states (IB_PORT_DOWN vs. IB_PORT_ACTIVE).
> 
> v2->v3:
> this change log added.
> 
> Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
> Acked-by: Leon Romanovsky <leonro@mellanox.com>
> ---
>  drivers/infiniband/hw/mlx4/main.c    | 27 +++++++++++++++++++++++++++
>  drivers/infiniband/hw/mlx4/mlx4_ib.h |  1 +
>  2 files changed, 28 insertions(+)

Applied to for-next

Thanks
Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 0def2323459c..b73b5fa1822a 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2352,6 +2352,32 @@  static void mlx4_ib_scan_netdevs(struct mlx4_ib_dev *ibdev,
 		     event == NETDEV_UP || event == NETDEV_CHANGE))
 			update_qps_port = port;
 
+		if (dev == iboe->netdevs[port - 1] &&
+		    (event == NETDEV_UP || event == NETDEV_DOWN)) {
+			enum ib_port_state port_state;
+			struct ib_event ibev = { };
+
+			if (ib_get_cached_port_state(&ibdev->ib_dev, port,
+						     &port_state))
+				continue;
+
+			if (event == NETDEV_UP &&
+			    (port_state != IB_PORT_ACTIVE ||
+			     iboe->last_port_state[port - 1] != IB_PORT_DOWN))
+				continue;
+			if (event == NETDEV_DOWN &&
+			    (port_state != IB_PORT_DOWN ||
+			     iboe->last_port_state[port - 1] != IB_PORT_ACTIVE))
+				continue;
+			iboe->last_port_state[port - 1] = port_state;
+
+			ibev.device = &ibdev->ib_dev;
+			ibev.element.port_num = port;
+			ibev.event = event == NETDEV_UP ? IB_EVENT_PORT_ACTIVE :
+							  IB_EVENT_PORT_ERR;
+			ib_dispatch_event(&ibev);
+		}
+
 	}
 	spin_unlock_bh(&iboe->lock);
 
@@ -2710,6 +2736,7 @@  static void *mlx4_ib_add(struct mlx4_dev *dev)
 	for (i = 0; i < ibdev->num_ports; ++i) {
 		mutex_init(&ibdev->counters_table[i].mutex);
 		INIT_LIST_HEAD(&ibdev->counters_table[i].counters_list);
+		iboe->last_port_state[i] = IB_PORT_DOWN;
 	}
 
 	num_req_counters = mlx4_is_bonded(dev) ? 1 : ibdev->num_ports;
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 8850dfc3826d..5cb52424912e 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -519,6 +519,7 @@  struct mlx4_ib_iboe {
 	atomic64_t		mac[MLX4_MAX_PORTS];
 	struct notifier_block 	nb;
 	struct mlx4_port_gid_table gids[MLX4_MAX_PORTS];
+	enum ib_port_state	last_port_state[MLX4_MAX_PORTS];
 };
 
 struct pkey_mgt {