Skip to content

Commit 7492052

Browse files
paravmellanoxjgunthorpe
authored andcommitted
IB/mlx4: Use GID attribute from ah attribute
While converting GID index from attribute to that of the HCA, GID attribute is available from the ah_attr. Make use of GID attribute to simplify the code and also avoid avoid GID query. Signed-off-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
1 parent 47ec386 commit 7492052

File tree

4 files changed

+9
-20
lines changed

4 files changed

+9
-20
lines changed

drivers/infiniband/hw/mlx4/ah.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ static struct ib_ah *create_iboe_ah(struct ib_pd *pd,
105105
vlan_tag |= (rdma_ah_get_sl(ah_attr) & 7) << 13;
106106
ah->av.eth.port_pd = cpu_to_be32(to_mpd(pd)->pdn |
107107
(rdma_ah_get_port_num(ah_attr) << 24));
108-
ret = mlx4_ib_gid_index_to_real_index(ibdev,
109-
rdma_ah_get_port_num(ah_attr),
110-
grh->sgid_index);
108+
ret = mlx4_ib_gid_index_to_real_index(ibdev, gid_attr);
111109
if (ret < 0)
112110
return ERR_PTR(ret);
113111
ah->av.eth.gid_index = ret;

drivers/infiniband/hw/mlx4/main.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -380,17 +380,15 @@ static int mlx4_ib_del_gid(const struct ib_gid_attr *attr, void **context)
380380
}
381381

382382
int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev,
383-
u8 port_num, int index)
383+
const struct ib_gid_attr *attr)
384384
{
385385
struct mlx4_ib_iboe *iboe = &ibdev->iboe;
386386
struct gid_cache_context *ctx = NULL;
387-
union ib_gid gid;
388387
struct mlx4_port_gid_table *port_gid_table;
389388
int real_index = -EINVAL;
390389
int i;
391-
int ret;
392390
unsigned long flags;
393-
struct ib_gid_attr attr;
391+
u8 port_num = attr->port_num;
394392

395393
if (port_num > MLX4_MAX_PORTS)
396394
return -EINVAL;
@@ -399,21 +397,15 @@ int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev,
399397
port_num = 1;
400398

401399
if (!rdma_cap_roce_gid_table(&ibdev->ib_dev, port_num))
402-
return index;
403-
404-
ret = ib_get_cached_gid(&ibdev->ib_dev, port_num, index, &gid, &attr);
405-
if (ret)
406-
return ret;
407-
408-
if (attr.ndev)
409-
dev_put(attr.ndev);
400+
return attr->index;
410401

411402
spin_lock_irqsave(&iboe->lock, flags);
412403
port_gid_table = &iboe->gids[port_num - 1];
413404

414405
for (i = 0; i < MLX4_MAX_PORT_GIDS; ++i)
415-
if (!memcmp(&port_gid_table->gids[i].gid, &gid, sizeof(gid)) &&
416-
attr.gid_type == port_gid_table->gids[i].gid_type) {
406+
if (!memcmp(&port_gid_table->gids[i].gid,
407+
&attr->gid, sizeof(attr->gid)) &&
408+
attr->gid_type == port_gid_table->gids[i].gid_type) {
417409
ctx = port_gid_table->gids[i].ctx;
418410
break;
419411
}

drivers/infiniband/hw/mlx4/mlx4_ib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
900900
int mr_access_flags, struct ib_pd *pd,
901901
struct ib_udata *udata);
902902
int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev,
903-
u8 port_num, int index);
903+
const struct ib_gid_attr *attr);
904904

905905
void mlx4_sched_ib_sl2vl_update_work(struct mlx4_ib_dev *ibdev,
906906
int port);

drivers/infiniband/hw/mlx4/qp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,8 +1859,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev,
18591859
if (rdma_ah_get_ah_flags(ah) & IB_AH_GRH) {
18601860
const struct ib_global_route *grh = rdma_ah_read_grh(ah);
18611861
int real_sgid_index =
1862-
mlx4_ib_gid_index_to_real_index(dev, port,
1863-
grh->sgid_index);
1862+
mlx4_ib_gid_index_to_real_index(dev, grh->sgid_attr);
18641863

18651864
if (real_sgid_index < 0)
18661865
return real_sgid_index;

0 commit comments

Comments
 (0)