diff options
author | devesh.sharma@emulex.com <devesh.sharma@emulex.com> | 2014-09-05 05:39:48 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2014-09-22 12:37:42 -0400 |
commit | 1be528bcb88d0b854dda1d60b31f4f8f7310f034 (patch) | |
tree | a62856b1a990d9b47bedee1b82ea9d78efda619c | |
parent | f93439e476d012b2503dbb07fe0fc675bcbff099 (diff) |
RDMA/ocrdma: Resolve L2 address when creating user AH
Because of IP-based GIDs, userspace AHs must have MAC and VLAN ID
resolved separately. Presently, user AHs are broken for ocrdma. This
patch resolves L2 addresses while creating user AH and obtains the
right DMAC and VLAN ID before creating AH.
Signed-off-by: Devesh Sharma <devesh.sharma@emulex.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
-rw-r--r-- | drivers/infiniband/hw/ocrdma/ocrdma_ah.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c index 40f8536c10b0..a9f967d47575 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #define OCRDMA_VID_PCP_SHIFT 0xD | 38 | #define OCRDMA_VID_PCP_SHIFT 0xD |
39 | 39 | ||
40 | static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah, | 40 | static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah, |
41 | struct ib_ah_attr *attr, int pdid) | 41 | struct ib_ah_attr *attr, union ib_gid *sgid, int pdid) |
42 | { | 42 | { |
43 | int status = 0; | 43 | int status = 0; |
44 | u16 vlan_tag; bool vlan_enabled = false; | 44 | u16 vlan_tag; bool vlan_enabled = false; |
@@ -49,8 +49,7 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah, | |||
49 | memset(ð, 0, sizeof(eth)); | 49 | memset(ð, 0, sizeof(eth)); |
50 | memset(&grh, 0, sizeof(grh)); | 50 | memset(&grh, 0, sizeof(grh)); |
51 | 51 | ||
52 | ah->sgid_index = attr->grh.sgid_index; | 52 | /* VLAN */ |
53 | |||
54 | vlan_tag = attr->vlan_id; | 53 | vlan_tag = attr->vlan_id; |
55 | if (!vlan_tag || (vlan_tag > 0xFFF)) | 54 | if (!vlan_tag || (vlan_tag > 0xFFF)) |
56 | vlan_tag = dev->pvid; | 55 | vlan_tag = dev->pvid; |
@@ -65,15 +64,14 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah, | |||
65 | eth.eth_type = cpu_to_be16(OCRDMA_ROCE_ETH_TYPE); | 64 | eth.eth_type = cpu_to_be16(OCRDMA_ROCE_ETH_TYPE); |
66 | eth_sz = sizeof(struct ocrdma_eth_basic); | 65 | eth_sz = sizeof(struct ocrdma_eth_basic); |
67 | } | 66 | } |
67 | /* MAC */ | ||
68 | memcpy(ð.smac[0], &dev->nic_info.mac_addr[0], ETH_ALEN); | 68 | memcpy(ð.smac[0], &dev->nic_info.mac_addr[0], ETH_ALEN); |
69 | memcpy(ð.dmac[0], attr->dmac, ETH_ALEN); | ||
70 | status = ocrdma_resolve_dmac(dev, attr, ð.dmac[0]); | 69 | status = ocrdma_resolve_dmac(dev, attr, ð.dmac[0]); |
71 | if (status) | 70 | if (status) |
72 | return status; | 71 | return status; |
73 | status = ocrdma_query_gid(&dev->ibdev, 1, attr->grh.sgid_index, | 72 | ah->sgid_index = attr->grh.sgid_index; |
74 | (union ib_gid *)&grh.sgid[0]); | 73 | memcpy(&grh.sgid[0], sgid->raw, sizeof(union ib_gid)); |
75 | if (status) | 74 | memcpy(&grh.dgid[0], attr->grh.dgid.raw, sizeof(attr->grh.dgid.raw)); |
76 | return status; | ||
77 | 75 | ||
78 | grh.tclass_flow = cpu_to_be32((6 << 28) | | 76 | grh.tclass_flow = cpu_to_be32((6 << 28) | |
79 | (attr->grh.traffic_class << 24) | | 77 | (attr->grh.traffic_class << 24) | |
@@ -81,8 +79,7 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah, | |||
81 | /* 0x1b is next header value in GRH */ | 79 | /* 0x1b is next header value in GRH */ |
82 | grh.pdid_hoplimit = cpu_to_be32((pdid << 16) | | 80 | grh.pdid_hoplimit = cpu_to_be32((pdid << 16) | |
83 | (0x1b << 8) | attr->grh.hop_limit); | 81 | (0x1b << 8) | attr->grh.hop_limit); |
84 | 82 | /* Eth HDR */ | |
85 | memcpy(&grh.dgid[0], attr->grh.dgid.raw, sizeof(attr->grh.dgid.raw)); | ||
86 | memcpy(&ah->av->eth_hdr, ð, eth_sz); | 83 | memcpy(&ah->av->eth_hdr, ð, eth_sz); |
87 | memcpy((u8 *)ah->av + eth_sz, &grh, sizeof(struct ocrdma_grh)); | 84 | memcpy((u8 *)ah->av + eth_sz, &grh, sizeof(struct ocrdma_grh)); |
88 | if (vlan_enabled) | 85 | if (vlan_enabled) |
@@ -98,6 +95,8 @@ struct ib_ah *ocrdma_create_ah(struct ib_pd *ibpd, struct ib_ah_attr *attr) | |||
98 | struct ocrdma_ah *ah; | 95 | struct ocrdma_ah *ah; |
99 | struct ocrdma_pd *pd = get_ocrdma_pd(ibpd); | 96 | struct ocrdma_pd *pd = get_ocrdma_pd(ibpd); |
100 | struct ocrdma_dev *dev = get_ocrdma_dev(ibpd->device); | 97 | struct ocrdma_dev *dev = get_ocrdma_dev(ibpd->device); |
98 | union ib_gid sgid; | ||
99 | u8 zmac[ETH_ALEN]; | ||
101 | 100 | ||
102 | if (!(attr->ah_flags & IB_AH_GRH)) | 101 | if (!(attr->ah_flags & IB_AH_GRH)) |
103 | return ERR_PTR(-EINVAL); | 102 | return ERR_PTR(-EINVAL); |
@@ -111,7 +110,27 @@ struct ib_ah *ocrdma_create_ah(struct ib_pd *ibpd, struct ib_ah_attr *attr) | |||
111 | status = ocrdma_alloc_av(dev, ah); | 110 | status = ocrdma_alloc_av(dev, ah); |
112 | if (status) | 111 | if (status) |
113 | goto av_err; | 112 | goto av_err; |
114 | status = set_av_attr(dev, ah, attr, pd->id); | 113 | |
114 | status = ocrdma_query_gid(&dev->ibdev, 1, attr->grh.sgid_index, &sgid); | ||
115 | if (status) { | ||
116 | pr_err("%s(): Failed to query sgid, status = %d\n", | ||
117 | __func__, status); | ||
118 | goto av_conf_err; | ||
119 | } | ||
120 | |||
121 | memset(&zmac, 0, ETH_ALEN); | ||
122 | if (pd->uctx && | ||
123 | memcmp(attr->dmac, &zmac, ETH_ALEN)) { | ||
124 | status = rdma_addr_find_dmac_by_grh(&sgid, &attr->grh.dgid, | ||
125 | attr->dmac, &attr->vlan_id); | ||
126 | if (status) { | ||
127 | pr_err("%s(): Failed to resolve dmac from gid." | ||
128 | "status = %d\n", __func__, status); | ||
129 | goto av_conf_err; | ||
130 | } | ||
131 | } | ||
132 | |||
133 | status = set_av_attr(dev, ah, attr, &sgid, pd->id); | ||
115 | if (status) | 134 | if (status) |
116 | goto av_conf_err; | 135 | goto av_conf_err; |
117 | 136 | ||