RDMA: Convert drivers to use sgid_attr instead of sgid_index
The core code now ensures that all driver callbacks that receive an rdma_ah_attrs will have a sgid_attr's pointer if there is a GRH present. Drivers can use this pointer instead of calling a query function with sgid_index. This simplifies the drivers and also avoids races where a gid_index lookup may return different data if it is changed. Signed-off-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
This commit is contained in:

committed by
Jason Gunthorpe

parent
d97099fe53
commit
47ec386662
@@ -222,25 +222,11 @@ static int rxe_dealloc_pd(struct ib_pd *ibpd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rxe_init_av(struct rxe_dev *rxe, struct rdma_ah_attr *attr,
|
||||
struct rxe_av *av)
|
||||
static void rxe_init_av(struct rxe_dev *rxe, struct rdma_ah_attr *attr,
|
||||
struct rxe_av *av)
|
||||
{
|
||||
int err;
|
||||
union ib_gid sgid;
|
||||
struct ib_gid_attr sgid_attr;
|
||||
|
||||
err = ib_get_cached_gid(&rxe->ib_dev, rdma_ah_get_port_num(attr),
|
||||
rdma_ah_read_grh(attr)->sgid_index, &sgid,
|
||||
&sgid_attr);
|
||||
if (err) {
|
||||
pr_err("Failed to query sgid. err = %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
rxe_av_from_attr(rdma_ah_get_port_num(attr), av, attr);
|
||||
rxe_av_fill_ip_info(av, attr, &sgid_attr, &sgid);
|
||||
dev_put(sgid_attr.ndev);
|
||||
return 0;
|
||||
rxe_av_fill_ip_info(av, attr);
|
||||
}
|
||||
|
||||
static struct ib_ah *rxe_create_ah(struct ib_pd *ibpd,
|
||||
@@ -266,13 +252,9 @@ static struct ib_ah *rxe_create_ah(struct ib_pd *ibpd,
|
||||
rxe_add_ref(pd);
|
||||
ah->pd = pd;
|
||||
|
||||
err = rxe_init_av(rxe, attr, &ah->av);
|
||||
if (err)
|
||||
goto err2;
|
||||
|
||||
rxe_init_av(rxe, attr, &ah->av);
|
||||
return &ah->ibah;
|
||||
|
||||
err2:
|
||||
rxe_drop_ref(pd);
|
||||
rxe_drop_ref(ah);
|
||||
err1:
|
||||
@@ -289,10 +271,7 @@ static int rxe_modify_ah(struct ib_ah *ibah, struct rdma_ah_attr *attr)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = rxe_init_av(rxe, attr, &ah->av);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
rxe_init_av(rxe, attr, &ah->av);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user