diff options
Diffstat (limited to 'drivers/infiniband/core/verbs.c')
-rw-r--r-- | drivers/infiniband/core/verbs.c | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index b78e7dc6933..468999c3880 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c | |||
@@ -125,35 +125,47 @@ struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr) | |||
125 | } | 125 | } |
126 | EXPORT_SYMBOL(ib_create_ah); | 126 | EXPORT_SYMBOL(ib_create_ah); |
127 | 127 | ||
128 | struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc, | 128 | int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc, |
129 | struct ib_grh *grh, u8 port_num) | 129 | struct ib_grh *grh, struct ib_ah_attr *ah_attr) |
130 | { | 130 | { |
131 | struct ib_ah_attr ah_attr; | ||
132 | u32 flow_class; | 131 | u32 flow_class; |
133 | u16 gid_index; | 132 | u16 gid_index; |
134 | int ret; | 133 | int ret; |
135 | 134 | ||
136 | memset(&ah_attr, 0, sizeof ah_attr); | 135 | memset(ah_attr, 0, sizeof *ah_attr); |
137 | ah_attr.dlid = wc->slid; | 136 | ah_attr->dlid = wc->slid; |
138 | ah_attr.sl = wc->sl; | 137 | ah_attr->sl = wc->sl; |
139 | ah_attr.src_path_bits = wc->dlid_path_bits; | 138 | ah_attr->src_path_bits = wc->dlid_path_bits; |
140 | ah_attr.port_num = port_num; | 139 | ah_attr->port_num = port_num; |
141 | 140 | ||
142 | if (wc->wc_flags & IB_WC_GRH) { | 141 | if (wc->wc_flags & IB_WC_GRH) { |
143 | ah_attr.ah_flags = IB_AH_GRH; | 142 | ah_attr->ah_flags = IB_AH_GRH; |
144 | ah_attr.grh.dgid = grh->sgid; | 143 | ah_attr->grh.dgid = grh->sgid; |
145 | 144 | ||
146 | ret = ib_find_cached_gid(pd->device, &grh->dgid, &port_num, | 145 | ret = ib_find_cached_gid(device, &grh->dgid, &port_num, |
147 | &gid_index); | 146 | &gid_index); |
148 | if (ret) | 147 | if (ret) |
149 | return ERR_PTR(ret); | 148 | return ret; |
150 | 149 | ||
151 | ah_attr.grh.sgid_index = (u8) gid_index; | 150 | ah_attr->grh.sgid_index = (u8) gid_index; |
152 | flow_class = be32_to_cpu(grh->version_tclass_flow); | 151 | flow_class = be32_to_cpu(grh->version_tclass_flow); |
153 | ah_attr.grh.flow_label = flow_class & 0xFFFFF; | 152 | ah_attr->grh.flow_label = flow_class & 0xFFFFF; |
154 | ah_attr.grh.traffic_class = (flow_class >> 20) & 0xFF; | 153 | ah_attr->grh.hop_limit = grh->hop_limit; |
155 | ah_attr.grh.hop_limit = grh->hop_limit; | 154 | ah_attr->grh.traffic_class = (flow_class >> 20) & 0xFF; |
156 | } | 155 | } |
156 | return 0; | ||
157 | } | ||
158 | EXPORT_SYMBOL(ib_init_ah_from_wc); | ||
159 | |||
160 | struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc, | ||
161 | struct ib_grh *grh, u8 port_num) | ||
162 | { | ||
163 | struct ib_ah_attr ah_attr; | ||
164 | int ret; | ||
165 | |||
166 | ret = ib_init_ah_from_wc(pd->device, port_num, wc, grh, &ah_attr); | ||
167 | if (ret) | ||
168 | return ERR_PTR(ret); | ||
157 | 169 | ||
158 | return ib_create_ah(pd, &ah_attr); | 170 | return ib_create_ah(pd, &ah_attr); |
159 | } | 171 | } |