Commit 611d0820 authored by Mark Bloch's avatar Mark Bloch Committed by Leon Romanovsky
Browse files

RDMA/mlx5: Allocate IB device with net namespace supplied from core dev



Use the new ib_alloc_device_with_net() API to allocate the IB device
so that it is properly bound to the network namespace obtained via
mlx5_core_net(). This change ensures correct namespace association
(e.g., for containerized setups).

Additionally, expose mlx5_core_net so that RDMA driver can use it.

Signed-off-by: default avatarShay Drory <shayd@nvidia.com>
Signed-off-by: default avatarMark Bloch <mbloch@nvidia.com>
Reviewed-by: default avatarParav Pandit <parav@nvidia.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
parent 8cffca86
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -88,7 +88,8 @@ mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
	else
		return mlx5_ib_set_vport_rep(lag_master, rep, vport_index);

	ibdev = ib_alloc_device(mlx5_ib_dev, ib_dev);
	ibdev = ib_alloc_device_with_net(mlx5_ib_dev, ib_dev,
					 mlx5_core_net(lag_master));
	if (!ibdev)
		return -ENOMEM;

+4 −2
Original line number Diff line number Diff line
@@ -4793,7 +4793,8 @@ static struct ib_device *mlx5_ib_add_sub_dev(struct ib_device *parent,
	    !MLX5_CAP_GEN_2(mparent->mdev, multiplane_qp_ud))
		return ERR_PTR(-EOPNOTSUPP);

	mplane = ib_alloc_device(mlx5_ib_dev, ib_dev);
	mplane = ib_alloc_device_with_net(mlx5_ib_dev, ib_dev,
					  mlx5_core_net(mparent->mdev));
	if (!mplane)
		return ERR_PTR(-ENOMEM);

@@ -4907,7 +4908,8 @@ static int mlx5r_probe(struct auxiliary_device *adev,

	num_ports = max(MLX5_CAP_GEN(mdev, num_ports),
			MLX5_CAP_GEN(mdev, num_vhca_ports));
	dev = ib_alloc_device(mlx5_ib_dev, ib_dev);
	dev = ib_alloc_device_with_net(mlx5_ib_dev, ib_dev,
				       mlx5_core_net(mdev));
	if (!dev)
		return -ENOMEM;

+0 −5
Original line number Diff line number Diff line
@@ -45,11 +45,6 @@ int mlx5_crdump_enable(struct mlx5_core_dev *dev);
void mlx5_crdump_disable(struct mlx5_core_dev *dev);
int mlx5_crdump_collect(struct mlx5_core_dev *dev, u32 *cr_data);

static inline struct net *mlx5_core_net(struct mlx5_core_dev *dev)
{
	return devlink_net(priv_to_devlink(dev));
}

static inline struct net_device *mlx5_uplink_netdev_get(struct mlx5_core_dev *mdev)
{
	return mdev->mlx5e_res.uplink_netdev;
+5 −0
Original line number Diff line number Diff line
@@ -1349,4 +1349,9 @@ enum {
};

bool mlx5_wc_support_get(struct mlx5_core_dev *mdev);

static inline struct net *mlx5_core_net(struct mlx5_core_dev *dev)
{
	return devlink_net(priv_to_devlink(dev));
}
#endif /* MLX5_DRIVER_H */