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
@ -82,12 +82,11 @@ static struct ib_ah *create_iboe_ah(struct ib_pd *pd,
|
||||
struct mlx4_ib_ah *ah)
|
||||
{
|
||||
struct mlx4_ib_dev *ibdev = to_mdev(pd->device);
|
||||
const struct ib_gid_attr *gid_attr;
|
||||
struct mlx4_dev *dev = ibdev->dev;
|
||||
int is_mcast = 0;
|
||||
struct in6_addr in6;
|
||||
u16 vlan_tag = 0xffff;
|
||||
union ib_gid sgid;
|
||||
struct ib_gid_attr gid_attr;
|
||||
const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr);
|
||||
int ret;
|
||||
|
||||
@ -96,15 +95,12 @@ static struct ib_ah *create_iboe_ah(struct ib_pd *pd,
|
||||
is_mcast = 1;
|
||||
|
||||
memcpy(ah->av.eth.mac, ah_attr->roce.dmac, ETH_ALEN);
|
||||
ret = ib_get_cached_gid(pd->device, rdma_ah_get_port_num(ah_attr),
|
||||
grh->sgid_index, &sgid, &gid_attr);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
eth_zero_addr(ah->av.eth.s_mac);
|
||||
if (is_vlan_dev(gid_attr.ndev))
|
||||
vlan_tag = vlan_dev_vlan_id(gid_attr.ndev);
|
||||
memcpy(ah->av.eth.s_mac, gid_attr.ndev->dev_addr, ETH_ALEN);
|
||||
dev_put(gid_attr.ndev);
|
||||
gid_attr = ah_attr->grh.sgid_attr;
|
||||
if (is_vlan_dev(gid_attr->ndev))
|
||||
vlan_tag = vlan_dev_vlan_id(gid_attr->ndev);
|
||||
memcpy(ah->av.eth.s_mac, gid_attr->ndev->dev_addr, ETH_ALEN);
|
||||
|
||||
if (vlan_tag < 0x1000)
|
||||
vlan_tag |= (rdma_ah_get_sl(ah_attr) & 7) << 13;
|
||||
ah->av.eth.port_pd = cpu_to_be32(to_mpd(pd)->pdn |
|
||||
|
@ -2176,6 +2176,7 @@ static int __mlx4_ib_modify_qp(void *src, enum mlx4_ib_source_type src_type,
|
||||
{
|
||||
struct ib_uobject *ibuobject;
|
||||
struct ib_srq *ibsrq;
|
||||
const struct ib_gid_attr *gid_attr = NULL;
|
||||
struct ib_rwq_ind_table *rwq_ind_tbl;
|
||||
enum ib_qp_type qp_type;
|
||||
struct mlx4_ib_dev *dev;
|
||||
@ -2356,29 +2357,17 @@ static int __mlx4_ib_modify_qp(void *src, enum mlx4_ib_source_type src_type,
|
||||
if (attr_mask & IB_QP_AV) {
|
||||
u8 port_num = mlx4_is_bonded(dev->dev) ? 1 :
|
||||
attr_mask & IB_QP_PORT ? attr->port_num : qp->port;
|
||||
union ib_gid gid;
|
||||
struct ib_gid_attr gid_attr = {.gid_type = IB_GID_TYPE_IB};
|
||||
u16 vlan = 0xffff;
|
||||
u8 smac[ETH_ALEN];
|
||||
int status = 0;
|
||||
int is_eth =
|
||||
rdma_cap_eth_ah(&dev->ib_dev, port_num) &&
|
||||
rdma_ah_get_ah_flags(&attr->ah_attr) & IB_AH_GRH;
|
||||
|
||||
if (is_eth) {
|
||||
int index =
|
||||
rdma_ah_read_grh(&attr->ah_attr)->sgid_index;
|
||||
|
||||
status = ib_get_cached_gid(&dev->ib_dev, port_num,
|
||||
index, &gid, &gid_attr);
|
||||
if (!status) {
|
||||
vlan = rdma_vlan_dev_vlan_id(gid_attr.ndev);
|
||||
memcpy(smac, gid_attr.ndev->dev_addr, ETH_ALEN);
|
||||
dev_put(gid_attr.ndev);
|
||||
}
|
||||
gid_attr = attr->ah_attr.grh.sgid_attr;
|
||||
vlan = rdma_vlan_dev_vlan_id(gid_attr->ndev);
|
||||
memcpy(smac, gid_attr->ndev->dev_addr, ETH_ALEN);
|
||||
}
|
||||
if (status)
|
||||
goto out;
|
||||
|
||||
if (mlx4_set_path(dev, attr, attr_mask, qp, &context->pri_path,
|
||||
port_num, vlan, smac))
|
||||
@ -2389,7 +2378,7 @@ static int __mlx4_ib_modify_qp(void *src, enum mlx4_ib_source_type src_type,
|
||||
|
||||
if (is_eth &&
|
||||
(cur_state == IB_QPS_INIT && new_state == IB_QPS_RTR)) {
|
||||
u8 qpc_roce_mode = gid_type_to_qpc(gid_attr.gid_type);
|
||||
u8 qpc_roce_mode = gid_type_to_qpc(gid_attr->gid_type);
|
||||
|
||||
if (qpc_roce_mode == MLX4_QPC_ROCE_MODE_UNDEFINED) {
|
||||
err = -EINVAL;
|
||||
@ -3181,10 +3170,12 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
|
||||
to_mdev(ib_dev)->sriov.demux[sqp->qp.port - 1].
|
||||
guid_cache[ah->av.ib.gid_index];
|
||||
} else {
|
||||
ib_get_cached_gid(ib_dev,
|
||||
be32_to_cpu(ah->av.ib.port_pd) >> 24,
|
||||
ah->av.ib.gid_index,
|
||||
&sqp->ud_header.grh.source_gid, NULL);
|
||||
err = rdma_query_gid(ib_dev,
|
||||
be32_to_cpu(ah->av.ib.port_pd) >> 24,
|
||||
ah->av.ib.gid_index,
|
||||
&sqp->ud_header.grh.source_gid);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
}
|
||||
memcpy(sqp->ud_header.grh.destination_gid.raw,
|
||||
|
Reference in New Issue
Block a user