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>
这个提交包含在:
@@ -82,15 +82,14 @@ void rxe_av_to_attr(struct rxe_av *av, struct rdma_ah_attr *attr)
|
||||
rdma_ah_set_port_num(attr, av->port_num);
|
||||
}
|
||||
|
||||
void rxe_av_fill_ip_info(struct rxe_av *av,
|
||||
struct rdma_ah_attr *attr,
|
||||
struct ib_gid_attr *sgid_attr,
|
||||
union ib_gid *sgid)
|
||||
void rxe_av_fill_ip_info(struct rxe_av *av, struct rdma_ah_attr *attr)
|
||||
{
|
||||
rdma_gid2ip((struct sockaddr *)&av->sgid_addr, sgid);
|
||||
const struct ib_gid_attr *sgid_attr = attr->grh.sgid_attr;
|
||||
|
||||
rdma_gid2ip((struct sockaddr *)&av->sgid_addr, &sgid_attr->gid);
|
||||
rdma_gid2ip((struct sockaddr *)&av->dgid_addr,
|
||||
&rdma_ah_read_grh(attr)->dgid);
|
||||
av->network_type = ib_gid_to_network_type(sgid_attr->gid_type, sgid);
|
||||
av->network_type = rdma_gid_attr_network_type(sgid_attr);
|
||||
}
|
||||
|
||||
struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt)
|
||||
|
@@ -43,10 +43,7 @@ void rxe_av_from_attr(u8 port_num, struct rxe_av *av,
|
||||
|
||||
void rxe_av_to_attr(struct rxe_av *av, struct rdma_ah_attr *attr);
|
||||
|
||||
void rxe_av_fill_ip_info(struct rxe_av *av,
|
||||
struct rdma_ah_attr *attr,
|
||||
struct ib_gid_attr *sgid_attr,
|
||||
union ib_gid *sgid);
|
||||
void rxe_av_fill_ip_info(struct rxe_av *av, struct rdma_ah_attr *attr);
|
||||
|
||||
struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt);
|
||||
|
||||
|
@@ -580,9 +580,6 @@ int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
int err;
|
||||
struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
|
||||
union ib_gid sgid;
|
||||
struct ib_gid_attr sgid_attr;
|
||||
|
||||
if (mask & IB_QP_MAX_QP_RD_ATOMIC) {
|
||||
int max_rd_atomic = __roundup_pow_of_two(attr->max_rd_atomic);
|
||||
@@ -623,30 +620,14 @@ int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask,
|
||||
qp->attr.qkey = attr->qkey;
|
||||
|
||||
if (mask & IB_QP_AV) {
|
||||
ib_get_cached_gid(&rxe->ib_dev, 1,
|
||||
rdma_ah_read_grh(&attr->ah_attr)->sgid_index,
|
||||
&sgid, &sgid_attr);
|
||||
rxe_av_from_attr(attr->port_num, &qp->pri_av, &attr->ah_attr);
|
||||
rxe_av_fill_ip_info(&qp->pri_av, &attr->ah_attr,
|
||||
&sgid_attr, &sgid);
|
||||
if (sgid_attr.ndev)
|
||||
dev_put(sgid_attr.ndev);
|
||||
rxe_av_fill_ip_info(&qp->pri_av, &attr->ah_attr);
|
||||
}
|
||||
|
||||
if (mask & IB_QP_ALT_PATH) {
|
||||
u8 sgid_index =
|
||||
rdma_ah_read_grh(&attr->alt_ah_attr)->sgid_index;
|
||||
|
||||
ib_get_cached_gid(&rxe->ib_dev, 1, sgid_index,
|
||||
&sgid, &sgid_attr);
|
||||
|
||||
rxe_av_from_attr(attr->alt_port_num, &qp->alt_av,
|
||||
&attr->alt_ah_attr);
|
||||
rxe_av_fill_ip_info(&qp->alt_av, &attr->alt_ah_attr,
|
||||
&sgid_attr, &sgid);
|
||||
if (sgid_attr.ndev)
|
||||
dev_put(sgid_attr.ndev);
|
||||
|
||||
rxe_av_fill_ip_info(&qp->alt_av, &attr->alt_ah_attr);
|
||||
qp->attr.alt_port_num = attr->alt_port_num;
|
||||
qp->attr.alt_pkey_index = attr->alt_pkey_index;
|
||||
qp->attr.alt_timeout = attr->alt_timeout;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
在新工单中引用
屏蔽一个用户