mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-01-10 11:30:49 +00:00
RDMA: Convert drivers to use the AH's sgid_attr in post_wr paths
For UD the drivers were doing a sgid_index lookup into the cache to get the attrs, however we can now directly access the same attrs stores in the ib_ah instead and remove the lookup. 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:
parent
1a1f460ff1
commit
89af969a66
@ -1879,15 +1879,13 @@ static int bnxt_re_build_qp1_send_v2(struct bnxt_re_qp *qp,
|
|||||||
struct bnxt_qplib_swqe *wqe,
|
struct bnxt_qplib_swqe *wqe,
|
||||||
int payload_size)
|
int payload_size)
|
||||||
{
|
{
|
||||||
struct ib_device *ibdev = &qp->rdev->ibdev;
|
|
||||||
struct bnxt_re_ah *ah = container_of(ud_wr(wr)->ah, struct bnxt_re_ah,
|
struct bnxt_re_ah *ah = container_of(ud_wr(wr)->ah, struct bnxt_re_ah,
|
||||||
ib_ah);
|
ib_ah);
|
||||||
struct bnxt_qplib_ah *qplib_ah = &ah->qplib_ah;
|
struct bnxt_qplib_ah *qplib_ah = &ah->qplib_ah;
|
||||||
|
const struct ib_gid_attr *sgid_attr = ah->ib_ah.sgid_attr;
|
||||||
struct bnxt_qplib_sge sge;
|
struct bnxt_qplib_sge sge;
|
||||||
union ib_gid sgid;
|
|
||||||
u8 nw_type;
|
u8 nw_type;
|
||||||
u16 ether_type;
|
u16 ether_type;
|
||||||
struct ib_gid_attr sgid_attr;
|
|
||||||
union ib_gid dgid;
|
union ib_gid dgid;
|
||||||
bool is_eth = false;
|
bool is_eth = false;
|
||||||
bool is_vlan = false;
|
bool is_vlan = false;
|
||||||
@ -1900,22 +1898,10 @@ static int bnxt_re_build_qp1_send_v2(struct bnxt_re_qp *qp,
|
|||||||
|
|
||||||
memset(&qp->qp1_hdr, 0, sizeof(qp->qp1_hdr));
|
memset(&qp->qp1_hdr, 0, sizeof(qp->qp1_hdr));
|
||||||
|
|
||||||
rc = ib_get_cached_gid(ibdev, 1,
|
if (is_vlan_dev(sgid_attr->ndev))
|
||||||
qplib_ah->host_sgid_index, &sgid,
|
vlan_id = vlan_dev_vlan_id(sgid_attr->ndev);
|
||||||
&sgid_attr);
|
|
||||||
if (rc) {
|
|
||||||
dev_err(rdev_to_dev(qp->rdev),
|
|
||||||
"Failed to query gid at index %d",
|
|
||||||
qplib_ah->host_sgid_index);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
if (sgid_attr.ndev) {
|
|
||||||
if (is_vlan_dev(sgid_attr.ndev))
|
|
||||||
vlan_id = vlan_dev_vlan_id(sgid_attr.ndev);
|
|
||||||
dev_put(sgid_attr.ndev);
|
|
||||||
}
|
|
||||||
/* Get network header type for this GID */
|
/* Get network header type for this GID */
|
||||||
nw_type = rdma_gid_attr_network_type(&sgid_attr);
|
nw_type = rdma_gid_attr_network_type(sgid_attr);
|
||||||
switch (nw_type) {
|
switch (nw_type) {
|
||||||
case RDMA_NETWORK_IPV4:
|
case RDMA_NETWORK_IPV4:
|
||||||
nw_type = BNXT_RE_ROCEV2_IPV4_PACKET;
|
nw_type = BNXT_RE_ROCEV2_IPV4_PACKET;
|
||||||
@ -1928,9 +1914,9 @@ static int bnxt_re_build_qp1_send_v2(struct bnxt_re_qp *qp,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memcpy(&dgid.raw, &qplib_ah->dgid, 16);
|
memcpy(&dgid.raw, &qplib_ah->dgid, 16);
|
||||||
is_udp = sgid_attr.gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP;
|
is_udp = sgid_attr->gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP;
|
||||||
if (is_udp) {
|
if (is_udp) {
|
||||||
if (ipv6_addr_v4mapped((struct in6_addr *)&sgid)) {
|
if (ipv6_addr_v4mapped((struct in6_addr *)&sgid_attr->gid)) {
|
||||||
ip_version = 4;
|
ip_version = 4;
|
||||||
ether_type = ETH_P_IP;
|
ether_type = ETH_P_IP;
|
||||||
} else {
|
} else {
|
||||||
@ -1963,9 +1949,10 @@ static int bnxt_re_build_qp1_send_v2(struct bnxt_re_qp *qp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_grh || (ip_version == 6)) {
|
if (is_grh || (ip_version == 6)) {
|
||||||
memcpy(qp->qp1_hdr.grh.source_gid.raw, sgid.raw, sizeof(sgid));
|
memcpy(qp->qp1_hdr.grh.source_gid.raw, sgid_attr->gid.raw,
|
||||||
|
sizeof(sgid_attr->gid));
|
||||||
memcpy(qp->qp1_hdr.grh.destination_gid.raw, qplib_ah->dgid.data,
|
memcpy(qp->qp1_hdr.grh.destination_gid.raw, qplib_ah->dgid.data,
|
||||||
sizeof(sgid));
|
sizeof(sgid_attr->gid));
|
||||||
qp->qp1_hdr.grh.hop_limit = qplib_ah->hop_limit;
|
qp->qp1_hdr.grh.hop_limit = qplib_ah->hop_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1975,7 +1962,7 @@ static int bnxt_re_build_qp1_send_v2(struct bnxt_re_qp *qp,
|
|||||||
qp->qp1_hdr.ip4.frag_off = htons(IP_DF);
|
qp->qp1_hdr.ip4.frag_off = htons(IP_DF);
|
||||||
qp->qp1_hdr.ip4.ttl = qplib_ah->hop_limit;
|
qp->qp1_hdr.ip4.ttl = qplib_ah->hop_limit;
|
||||||
|
|
||||||
memcpy(&qp->qp1_hdr.ip4.saddr, sgid.raw + 12, 4);
|
memcpy(&qp->qp1_hdr.ip4.saddr, sgid_attr->gid.raw + 12, 4);
|
||||||
memcpy(&qp->qp1_hdr.ip4.daddr, qplib_ah->dgid.data + 12, 4);
|
memcpy(&qp->qp1_hdr.ip4.daddr, qplib_ah->dgid.data + 12, 4);
|
||||||
qp->qp1_hdr.ip4.check = ib_ud_ip4_csum(&qp->qp1_hdr);
|
qp->qp1_hdr.ip4.check = ib_ud_ip4_csum(&qp->qp1_hdr);
|
||||||
}
|
}
|
||||||
|
@ -3169,12 +3169,8 @@ 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].
|
to_mdev(ib_dev)->sriov.demux[sqp->qp.port - 1].
|
||||||
guid_cache[ah->av.ib.gid_index];
|
guid_cache[ah->av.ib.gid_index];
|
||||||
} else {
|
} else {
|
||||||
err = rdma_query_gid(ib_dev,
|
sqp->ud_header.grh.source_gid =
|
||||||
be32_to_cpu(ah->av.ib.port_pd) >> 24,
|
ah->ibah.sgid_attr->gid;
|
||||||
ah->av.ib.gid_index,
|
|
||||||
&sqp->ud_header.grh.source_gid);
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memcpy(sqp->ud_header.grh.destination_gid.raw,
|
memcpy(sqp->ud_header.grh.destination_gid.raw,
|
||||||
|
@ -281,10 +281,7 @@ int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah,
|
|||||||
header->grh.flow_label =
|
header->grh.flow_label =
|
||||||
ah->av->sl_tclass_flowlabel & cpu_to_be32(0xfffff);
|
ah->av->sl_tclass_flowlabel & cpu_to_be32(0xfffff);
|
||||||
header->grh.hop_limit = ah->av->hop_limit;
|
header->grh.hop_limit = ah->av->hop_limit;
|
||||||
ib_get_cached_gid(&dev->ib_dev,
|
header->grh.source_gid = ah->ibah.sgid_attr->gid;
|
||||||
be32_to_cpu(ah->av->port_pd) >> 24,
|
|
||||||
ah->av->gid_index % dev->limits.gid_table_len,
|
|
||||||
&header->grh.source_gid, NULL);
|
|
||||||
memcpy(header->grh.destination_gid.raw,
|
memcpy(header->grh.destination_gid.raw,
|
||||||
ah->av->dgid, 16);
|
ah->av->dgid, 16);
|
||||||
}
|
}
|
||||||
|
@ -387,11 +387,10 @@ static inline int qedr_gsi_build_header(struct qedr_dev *dev,
|
|||||||
bool has_vlan = false, has_grh_ipv6 = true;
|
bool has_vlan = false, has_grh_ipv6 = true;
|
||||||
struct rdma_ah_attr *ah_attr = &get_qedr_ah(ud_wr(swr)->ah)->attr;
|
struct rdma_ah_attr *ah_attr = &get_qedr_ah(ud_wr(swr)->ah)->attr;
|
||||||
const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr);
|
const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr);
|
||||||
union ib_gid sgid;
|
const struct ib_gid_attr *sgid_attr = grh->sgid_attr;
|
||||||
int send_size = 0;
|
int send_size = 0;
|
||||||
u16 vlan_id = 0;
|
u16 vlan_id = 0;
|
||||||
u16 ether_type;
|
u16 ether_type;
|
||||||
struct ib_gid_attr sgid_attr;
|
|
||||||
int rc;
|
int rc;
|
||||||
int ip_ver = 0;
|
int ip_ver = 0;
|
||||||
|
|
||||||
@ -402,28 +401,16 @@ static inline int qedr_gsi_build_header(struct qedr_dev *dev,
|
|||||||
for (i = 0; i < swr->num_sge; ++i)
|
for (i = 0; i < swr->num_sge; ++i)
|
||||||
send_size += swr->sg_list[i].length;
|
send_size += swr->sg_list[i].length;
|
||||||
|
|
||||||
rc = ib_get_cached_gid(qp->ibqp.device, rdma_ah_get_port_num(ah_attr),
|
vlan_id = rdma_vlan_dev_vlan_id(sgid_attr->ndev);
|
||||||
grh->sgid_index, &sgid, &sgid_attr);
|
|
||||||
if (rc) {
|
|
||||||
DP_ERR(dev,
|
|
||||||
"gsi post send: failed to get cached GID (port=%d, ix=%d)\n",
|
|
||||||
rdma_ah_get_port_num(ah_attr),
|
|
||||||
grh->sgid_index);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
vlan_id = rdma_vlan_dev_vlan_id(sgid_attr.ndev);
|
|
||||||
if (vlan_id < VLAN_CFI_MASK)
|
if (vlan_id < VLAN_CFI_MASK)
|
||||||
has_vlan = true;
|
has_vlan = true;
|
||||||
|
|
||||||
dev_put(sgid_attr.ndev);
|
has_udp = (sgid_attr->gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP);
|
||||||
|
|
||||||
has_udp = (sgid_attr.gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP);
|
|
||||||
if (!has_udp) {
|
if (!has_udp) {
|
||||||
/* RoCE v1 */
|
/* RoCE v1 */
|
||||||
ether_type = ETH_P_IBOE;
|
ether_type = ETH_P_IBOE;
|
||||||
*roce_mode = ROCE_V1;
|
*roce_mode = ROCE_V1;
|
||||||
} else if (ipv6_addr_v4mapped((struct in6_addr *)&sgid)) {
|
} else if (ipv6_addr_v4mapped((struct in6_addr *)&sgid_attr->gid)) {
|
||||||
/* RoCE v2 IPv4 */
|
/* RoCE v2 IPv4 */
|
||||||
ip_ver = 4;
|
ip_ver = 4;
|
||||||
ether_type = ETH_P_IP;
|
ether_type = ETH_P_IP;
|
||||||
@ -471,7 +458,7 @@ static inline int qedr_gsi_build_header(struct qedr_dev *dev,
|
|||||||
udh->grh.flow_label = grh->flow_label;
|
udh->grh.flow_label = grh->flow_label;
|
||||||
udh->grh.hop_limit = grh->hop_limit;
|
udh->grh.hop_limit = grh->hop_limit;
|
||||||
udh->grh.destination_gid = grh->dgid;
|
udh->grh.destination_gid = grh->dgid;
|
||||||
memcpy(&udh->grh.source_gid.raw, &sgid.raw,
|
memcpy(&udh->grh.source_gid.raw, sgid_attr->gid.raw,
|
||||||
sizeof(udh->grh.source_gid.raw));
|
sizeof(udh->grh.source_gid.raw));
|
||||||
} else {
|
} else {
|
||||||
/* IPv4 header */
|
/* IPv4 header */
|
||||||
@ -482,7 +469,7 @@ static inline int qedr_gsi_build_header(struct qedr_dev *dev,
|
|||||||
udh->ip4.frag_off = htons(IP_DF);
|
udh->ip4.frag_off = htons(IP_DF);
|
||||||
udh->ip4.ttl = grh->hop_limit;
|
udh->ip4.ttl = grh->hop_limit;
|
||||||
|
|
||||||
ipv4_addr = qedr_get_ipv4_from_gid(sgid.raw);
|
ipv4_addr = qedr_get_ipv4_from_gid(sgid_attr->gid.raw);
|
||||||
udh->ip4.saddr = ipv4_addr;
|
udh->ip4.saddr = ipv4_addr;
|
||||||
ipv4_addr = qedr_get_ipv4_from_gid(grh->dgid.raw);
|
ipv4_addr = qedr_get_ipv4_from_gid(grh->dgid.raw);
|
||||||
udh->ip4.daddr = ipv4_addr;
|
udh->ip4.daddr = ipv4_addr;
|
||||||
|
Loading…
Reference in New Issue
Block a user