Skip to content

Commit 0d29371

Browse files
PatrisiousHaddadrleon
authored andcommitted
RDMA/mlx5: Send events from IB driver about device affiliation state
Send blocking events from IB driver whenever the device is done being affiliated or if it is removed from an affiliation. This is useful since now the EN driver can register to those event and know when a device is affiliated or not. Signed-off-by: Patrisious Haddad <phaddad@nvidia.com> Reviewed-by: Mark Bloch <mbloch@nvidia.com> Link: https://lore.kernel.org/r/a7491c3e483cfd8d962f5f75b9a25f253043384a.1695296682.git.leon@kernel.org Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent 6581da7 commit 0d29371

4 files changed

Lines changed: 27 additions & 0 deletions

File tree

drivers/infiniband/hw/mlx5/main.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/mlx5/vport.h>
2525
#include <linux/mlx5/fs.h>
2626
#include <linux/mlx5/eswitch.h>
27+
#include <linux/mlx5/driver.h>
2728
#include <linux/list.h>
2829
#include <rdma/ib_smi.h>
2930
#include <rdma/ib_umem_odp.h>
@@ -3175,6 +3176,13 @@ static void mlx5_ib_unbind_slave_port(struct mlx5_ib_dev *ibdev,
31753176

31763177
lockdep_assert_held(&mlx5_ib_multiport_mutex);
31773178

3179+
mlx5_core_mp_event_replay(ibdev->mdev,
3180+
MLX5_DRIVER_EVENT_AFFILIATION_REMOVED,
3181+
NULL);
3182+
mlx5_core_mp_event_replay(mpi->mdev,
3183+
MLX5_DRIVER_EVENT_AFFILIATION_REMOVED,
3184+
NULL);
3185+
31783186
mlx5_ib_cleanup_cong_debugfs(ibdev, port_num);
31793187

31803188
spin_lock(&port->mp.mpi_lock);
@@ -3226,6 +3234,7 @@ static bool mlx5_ib_bind_slave_port(struct mlx5_ib_dev *ibdev,
32263234
struct mlx5_ib_multiport_info *mpi)
32273235
{
32283236
u32 port_num = mlx5_core_native_port_num(mpi->mdev) - 1;
3237+
u64 key;
32293238
int err;
32303239

32313240
lockdep_assert_held(&mlx5_ib_multiport_mutex);
@@ -3254,6 +3263,14 @@ static bool mlx5_ib_bind_slave_port(struct mlx5_ib_dev *ibdev,
32543263

32553264
mlx5_ib_init_cong_debugfs(ibdev, port_num);
32563265

3266+
key = ibdev->ib_dev.index;
3267+
mlx5_core_mp_event_replay(mpi->mdev,
3268+
MLX5_DRIVER_EVENT_AFFILIATION_DONE,
3269+
&key);
3270+
mlx5_core_mp_event_replay(ibdev->mdev,
3271+
MLX5_DRIVER_EVENT_AFFILIATION_DONE,
3272+
&key);
3273+
32573274
return true;
32583275

32593276
unbind:

drivers/net/ethernet/mellanox/mlx5/core/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,12 @@ void mlx5_core_uplink_netdev_event_replay(struct mlx5_core_dev *dev)
361361
}
362362
EXPORT_SYMBOL(mlx5_core_uplink_netdev_event_replay);
363363

364+
void mlx5_core_mp_event_replay(struct mlx5_core_dev *dev, u32 event, void *data)
365+
{
366+
mlx5_blocking_notifier_call_chain(dev, event, data);
367+
}
368+
EXPORT_SYMBOL(mlx5_core_mp_event_replay);
369+
364370
int mlx5_core_get_caps_mode(struct mlx5_core_dev *dev, enum mlx5_cap_type cap_type,
365371
enum mlx5_cap_mode cap_mode)
366372
{

include/linux/mlx5/device.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ enum mlx5_driver_event {
366366
MLX5_DRIVER_EVENT_UPLINK_NETDEV,
367367
MLX5_DRIVER_EVENT_MACSEC_SA_ADDED,
368368
MLX5_DRIVER_EVENT_MACSEC_SA_DELETED,
369+
MLX5_DRIVER_EVENT_AFFILIATION_DONE,
370+
MLX5_DRIVER_EVENT_AFFILIATION_REMOVED,
369371
};
370372

371373
enum {

include/linux/mlx5/driver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,8 @@ bool mlx5_cmd_is_down(struct mlx5_core_dev *dev);
10271027
void mlx5_core_uplink_netdev_set(struct mlx5_core_dev *mdev, struct net_device *netdev);
10281028
void mlx5_core_uplink_netdev_event_replay(struct mlx5_core_dev *mdev);
10291029

1030+
void mlx5_core_mp_event_replay(struct mlx5_core_dev *dev, u32 event, void *data);
1031+
10301032
void mlx5_health_cleanup(struct mlx5_core_dev *dev);
10311033
int mlx5_health_init(struct mlx5_core_dev *dev);
10321034
void mlx5_start_health_poll(struct mlx5_core_dev *dev);

0 commit comments

Comments
 (0)