aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw
diff options
context:
space:
mode:
authorMoni Shoua <monis@mellanox.com>2013-12-12 11:03:15 -0500
committerRoland Dreier <roland@purestorage.com>2014-01-19 18:13:58 -0500
commit40aca6ffcac57dd9c65877a59a8bbb210c4691ca (patch)
tree38d04201204be282164c9c8005787c45063625b3 /drivers/infiniband/hw
parent297e0dad720664dad44baa2cdd13f871979fb58c (diff)
RDMA/ocrdma: Handle Ethernet L2 parameters for IP based GID addressing
This patch is similar in spirit to the "IB/mlx4: Handle Ethernet L2 parameters for IP based GID addressing". It handles the fact that IP based RoCE gids don't store Ethernet L2 parameters, MAC and VLAN. When building an address handle, instead of parsing the dgid to get the MAC and VLAN, take them from the address handle attributes. Cc: Naresh Gottumukkala <bgottumukkala@emulex.com> Signed-off-by: Moni Shoua <monis@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma.h12
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_ah.c5
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_hw.c21
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_hw.h1
4 files changed, 17 insertions, 22 deletions
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma.h b/drivers/infiniband/hw/ocrdma/ocrdma.h
index 294dd27b601e..7c001b97b23f 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma.h
@@ -423,5 +423,17 @@ static inline int is_cqe_wr_imm(struct ocrdma_cqe *cqe)
423 OCRDMA_CQE_WRITE_IMM) ? 1 : 0; 423 OCRDMA_CQE_WRITE_IMM) ? 1 : 0;
424} 424}
425 425
426static inline int ocrdma_resolve_dmac(struct ocrdma_dev *dev,
427 struct ib_ah_attr *ah_attr, u8 *mac_addr)
428{
429 struct in6_addr in6;
430
431 memcpy(&in6, ah_attr->grh.dgid.raw, sizeof(in6));
432 if (rdma_is_multicast_addr(&in6))
433 rdma_get_mcast_mac(&in6, mac_addr);
434 else
435 memcpy(mac_addr, ah_attr->dmac, ETH_ALEN);
436 return 0;
437}
426 438
427#endif 439#endif
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
index ee499d942257..bbb7962cd9df 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
@@ -49,7 +49,7 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
49 49
50 ah->sgid_index = attr->grh.sgid_index; 50 ah->sgid_index = attr->grh.sgid_index;
51 51
52 vlan_tag = rdma_get_vlan_id(&attr->grh.dgid); 52 vlan_tag = attr->vlan_id;
53 if (!vlan_tag || (vlan_tag > 0xFFF)) 53 if (!vlan_tag || (vlan_tag > 0xFFF))
54 vlan_tag = dev->pvid; 54 vlan_tag = dev->pvid;
55 if (vlan_tag && (vlan_tag < 0x1000)) { 55 if (vlan_tag && (vlan_tag < 0x1000)) {
@@ -64,7 +64,8 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
64 eth_sz = sizeof(struct ocrdma_eth_basic); 64 eth_sz = sizeof(struct ocrdma_eth_basic);
65 } 65 }
66 memcpy(&eth.smac[0], &dev->nic_info.mac_addr[0], ETH_ALEN); 66 memcpy(&eth.smac[0], &dev->nic_info.mac_addr[0], ETH_ALEN);
67 status = ocrdma_resolve_dgid(dev, &attr->grh.dgid, &eth.dmac[0]); 67 memcpy(&eth.dmac[0], attr->dmac, ETH_ALEN);
68 status = ocrdma_resolve_dmac(dev, attr, &eth.dmac[0]);
68 if (status) 69 if (status)
69 return status; 70 return status;
70 status = ocrdma_query_gid(&dev->ibdev, 1, attr->grh.sgid_index, 71 status = ocrdma_query_gid(&dev->ibdev, 1, attr->grh.sgid_index,
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
index 56bf32fcb62c..1664d648cbfc 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
@@ -2076,23 +2076,6 @@ mbx_err:
2076 return status; 2076 return status;
2077} 2077}
2078 2078
2079int ocrdma_resolve_dgid(struct ocrdma_dev *dev, union ib_gid *dgid,
2080 u8 *mac_addr)
2081{
2082 struct in6_addr in6;
2083
2084 memcpy(&in6, dgid, sizeof in6);
2085 if (rdma_is_multicast_addr(&in6)) {
2086 rdma_get_mcast_mac(&in6, mac_addr);
2087 } else if (rdma_link_local_addr(&in6)) {
2088 rdma_get_ll_mac(&in6, mac_addr);
2089 } else {
2090 pr_err("%s() fail to resolve mac_addr.\n", __func__);
2091 return -EINVAL;
2092 }
2093 return 0;
2094}
2095
2096static int ocrdma_set_av_params(struct ocrdma_qp *qp, 2079static int ocrdma_set_av_params(struct ocrdma_qp *qp,
2097 struct ocrdma_modify_qp *cmd, 2080 struct ocrdma_modify_qp *cmd,
2098 struct ib_qp_attr *attrs) 2081 struct ib_qp_attr *attrs)
@@ -2126,14 +2109,14 @@ static int ocrdma_set_av_params(struct ocrdma_qp *qp,
2126 2109
2127 qp->sgid_idx = ah_attr->grh.sgid_index; 2110 qp->sgid_idx = ah_attr->grh.sgid_index;
2128 memcpy(&cmd->params.sgid[0], &sgid.raw[0], sizeof(cmd->params.sgid)); 2111 memcpy(&cmd->params.sgid[0], &sgid.raw[0], sizeof(cmd->params.sgid));
2129 ocrdma_resolve_dgid(qp->dev, &ah_attr->grh.dgid, &mac_addr[0]); 2112 ocrdma_resolve_dmac(qp->dev, ah_attr, &mac_addr[0]);
2130 cmd->params.dmac_b0_to_b3 = mac_addr[0] | (mac_addr[1] << 8) | 2113 cmd->params.dmac_b0_to_b3 = mac_addr[0] | (mac_addr[1] << 8) |
2131 (mac_addr[2] << 16) | (mac_addr[3] << 24); 2114 (mac_addr[2] << 16) | (mac_addr[3] << 24);
2132 /* convert them to LE format. */ 2115 /* convert them to LE format. */
2133 ocrdma_cpu_to_le32(&cmd->params.dgid[0], sizeof(cmd->params.dgid)); 2116 ocrdma_cpu_to_le32(&cmd->params.dgid[0], sizeof(cmd->params.dgid));
2134 ocrdma_cpu_to_le32(&cmd->params.sgid[0], sizeof(cmd->params.sgid)); 2117 ocrdma_cpu_to_le32(&cmd->params.sgid[0], sizeof(cmd->params.sgid));
2135 cmd->params.vlan_dmac_b4_to_b5 = mac_addr[4] | (mac_addr[5] << 8); 2118 cmd->params.vlan_dmac_b4_to_b5 = mac_addr[4] | (mac_addr[5] << 8);
2136 vlan_id = rdma_get_vlan_id(&sgid); 2119 vlan_id = ah_attr->vlan_id;
2137 if (vlan_id && (vlan_id < 0x1000)) { 2120 if (vlan_id && (vlan_id < 0x1000)) {
2138 cmd->params.vlan_dmac_b4_to_b5 |= 2121 cmd->params.vlan_dmac_b4_to_b5 |=
2139 vlan_id << OCRDMA_QP_PARAMS_VLAN_SHIFT; 2122 vlan_id << OCRDMA_QP_PARAMS_VLAN_SHIFT;
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.h b/drivers/infiniband/hw/ocrdma/ocrdma_hw.h
index f2a89d4cc7c4..82fe332ae6c6 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.h
@@ -94,7 +94,6 @@ void ocrdma_ring_cq_db(struct ocrdma_dev *, u16 cq_id, bool armed,
94int ocrdma_mbx_get_link_speed(struct ocrdma_dev *dev, u8 *lnk_speed); 94int ocrdma_mbx_get_link_speed(struct ocrdma_dev *dev, u8 *lnk_speed);
95int ocrdma_query_config(struct ocrdma_dev *, 95int ocrdma_query_config(struct ocrdma_dev *,
96 struct ocrdma_mbx_query_config *config); 96 struct ocrdma_mbx_query_config *config);
97int ocrdma_resolve_dgid(struct ocrdma_dev *, union ib_gid *dgid, u8 *mac_addr);
98 97
99int ocrdma_mbx_alloc_pd(struct ocrdma_dev *, struct ocrdma_pd *); 98int ocrdma_mbx_alloc_pd(struct ocrdma_dev *, struct ocrdma_pd *);
100int ocrdma_mbx_dealloc_pd(struct ocrdma_dev *, struct ocrdma_pd *); 99int ocrdma_mbx_dealloc_pd(struct ocrdma_dev *, struct ocrdma_pd *);