diff options
author | Mark Bloch <markb@mellanox.com> | 2019-03-28 16:27:35 +0300 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2019-04-10 21:05:39 +0300 |
commit | da796ccb3e0eba24b15beedb168178c9b74ce6f2 (patch) | |
tree | 318a90b9ab3e06d417dbc9620afdfa238d560bab /drivers/infiniband/hw/mlx5/ib_rep.c | |
parent | 4a6dc8552ab2f670fdff317a5ac1bc42f85a8772 (diff) | |
download | linux-da796ccb3e0eba24b15beedb168178c9b74ce6f2.tar.xz |
RDMA/mlx5: Move ports allocation to outside of INIT stage
In downstream patches we will need access to the ports before doing any
stages, in order to set net device per representor.
Signed-off-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/hw/mlx5/ib_rep.c')
-rw-r--r-- | drivers/infiniband/hw/mlx5/ib_rep.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/infiniband/hw/mlx5/ib_rep.c b/drivers/infiniband/hw/mlx5/ib_rep.c index 87d553396fb4..14ac728b460c 100644 --- a/drivers/infiniband/hw/mlx5/ib_rep.c +++ b/drivers/infiniband/hw/mlx5/ib_rep.c @@ -51,6 +51,7 @@ mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) { const struct mlx5_ib_profile *profile; struct mlx5_ib_dev *ibdev; + int num_ports = 1; if (rep->vport == MLX5_VPORT_UPLINK) profile = &uplink_rep_profile; @@ -61,10 +62,17 @@ mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) if (!ibdev) return -ENOMEM; + ibdev->port = kcalloc(num_ports, sizeof(*ibdev->port), + GFP_KERNEL); + if (!ibdev->port) { + ib_dealloc_device(&ibdev->ib_dev); + return -ENOMEM; + } + ibdev->rep = rep; ibdev->mdev = dev; - ibdev->num_ports = max(MLX5_CAP_GEN(dev, num_ports), - MLX5_CAP_GEN(dev, num_vhca_ports)); + ibdev->num_ports = num_ports; + if (!__mlx5_ib_add(ibdev, profile)) return -EINVAL; |