Commit 6504c772 authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

IB/mlx4: Use port iterator and validation APIs

Use IB core provided routine to check if the port is valid or not and to
iterate over IB ports.

Link: https://lore.kernel.org/r/20210127150010.1876121-10-leon@kernel.orgSigned-off-by: default avatarParav Pandit <parav@nvidia.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 131be267
...@@ -1699,7 +1699,7 @@ static struct ib_flow *mlx4_ib_create_flow(struct ib_qp *qp, ...@@ -1699,7 +1699,7 @@ static struct ib_flow *mlx4_ib_create_flow(struct ib_qp *qp,
struct mlx4_dev *dev = (to_mdev(qp->device))->dev; struct mlx4_dev *dev = (to_mdev(qp->device))->dev;
int is_bonded = mlx4_is_bonded(dev); int is_bonded = mlx4_is_bonded(dev);
if (flow_attr->port < 1 || flow_attr->port > qp->device->phys_port_cnt) if (!rdma_is_port_valid(qp->device, flow_attr->port))
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
if (flow_attr->flags & ~IB_FLOW_ATTR_FLAGS_DONT_TRAP) if (flow_attr->flags & ~IB_FLOW_ATTR_FLAGS_DONT_TRAP)
......
...@@ -798,7 +798,7 @@ static void unregister_pkey_tree(struct mlx4_ib_dev *device) ...@@ -798,7 +798,7 @@ static void unregister_pkey_tree(struct mlx4_ib_dev *device)
int mlx4_ib_device_register_sysfs(struct mlx4_ib_dev *dev) int mlx4_ib_device_register_sysfs(struct mlx4_ib_dev *dev)
{ {
int i; unsigned int i;
int ret = 0; int ret = 0;
if (!mlx4_is_master(dev->dev)) if (!mlx4_is_master(dev->dev))
...@@ -817,7 +817,7 @@ int mlx4_ib_device_register_sysfs(struct mlx4_ib_dev *dev) ...@@ -817,7 +817,7 @@ int mlx4_ib_device_register_sysfs(struct mlx4_ib_dev *dev)
goto err_ports; goto err_ports;
} }
for (i = 1; i <= dev->ib_dev.phys_port_cnt; ++i) { rdma_for_each_port(&dev->ib_dev, i) {
ret = add_port_entries(dev, i); ret = add_port_entries(dev, i);
if (ret) if (ret)
goto err_add_entries; goto err_add_entries;
......
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