| .. | .. |
|---|
| 155 | 155 | return status; |
|---|
| 156 | 156 | } |
|---|
| 157 | 157 | |
|---|
| 158 | | -struct ib_ah *ocrdma_create_ah(struct ib_pd *ibpd, struct rdma_ah_attr *attr, |
|---|
| 159 | | - struct ib_udata *udata) |
|---|
| 158 | +int ocrdma_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, |
|---|
| 159 | + struct ib_udata *udata) |
|---|
| 160 | 160 | { |
|---|
| 161 | 161 | u32 *ahid_addr; |
|---|
| 162 | 162 | int status; |
|---|
| 163 | | - struct ocrdma_ah *ah; |
|---|
| 163 | + struct ocrdma_ah *ah = get_ocrdma_ah(ibah); |
|---|
| 164 | 164 | bool isvlan = false; |
|---|
| 165 | 165 | u16 vlan_tag = 0xffff; |
|---|
| 166 | 166 | const struct ib_gid_attr *sgid_attr; |
|---|
| 167 | | - struct ocrdma_pd *pd = get_ocrdma_pd(ibpd); |
|---|
| 168 | | - struct ocrdma_dev *dev = get_ocrdma_dev(ibpd->device); |
|---|
| 167 | + struct ocrdma_pd *pd = get_ocrdma_pd(ibah->pd); |
|---|
| 168 | + struct rdma_ah_attr *attr = init_attr->ah_attr; |
|---|
| 169 | + struct ocrdma_dev *dev = get_ocrdma_dev(ibah->device); |
|---|
| 169 | 170 | |
|---|
| 170 | 171 | if ((attr->type != RDMA_AH_ATTR_TYPE_ROCE) || |
|---|
| 171 | 172 | !(rdma_ah_get_ah_flags(attr) & IB_AH_GRH)) |
|---|
| 172 | | - return ERR_PTR(-EINVAL); |
|---|
| 173 | + return -EINVAL; |
|---|
| 173 | 174 | |
|---|
| 174 | 175 | if (atomic_cmpxchg(&dev->update_sl, 1, 0)) |
|---|
| 175 | 176 | ocrdma_init_service_level(dev); |
|---|
| 176 | 177 | |
|---|
| 177 | | - ah = kzalloc(sizeof(*ah), GFP_ATOMIC); |
|---|
| 178 | | - if (!ah) |
|---|
| 179 | | - return ERR_PTR(-ENOMEM); |
|---|
| 178 | + sgid_attr = attr->grh.sgid_attr; |
|---|
| 179 | + status = rdma_read_gid_l2_fields(sgid_attr, &vlan_tag, NULL); |
|---|
| 180 | + if (status) |
|---|
| 181 | + return status; |
|---|
| 180 | 182 | |
|---|
| 181 | 183 | status = ocrdma_alloc_av(dev, ah); |
|---|
| 182 | 184 | if (status) |
|---|
| 183 | 185 | goto av_err; |
|---|
| 184 | | - |
|---|
| 185 | | - sgid_attr = attr->grh.sgid_attr; |
|---|
| 186 | | - if (is_vlan_dev(sgid_attr->ndev)) |
|---|
| 187 | | - vlan_tag = vlan_dev_vlan_id(sgid_attr->ndev); |
|---|
| 188 | 186 | |
|---|
| 189 | 187 | /* Get network header type for this GID */ |
|---|
| 190 | 188 | ah->hdr_type = rdma_gid_attr_network_type(sgid_attr); |
|---|
| .. | .. |
|---|
| 209 | 207 | OCRDMA_AH_VLAN_VALID_SHIFT); |
|---|
| 210 | 208 | } |
|---|
| 211 | 209 | |
|---|
| 212 | | - return &ah->ibah; |
|---|
| 210 | + return 0; |
|---|
| 213 | 211 | |
|---|
| 214 | 212 | av_conf_err: |
|---|
| 215 | 213 | ocrdma_free_av(dev, ah); |
|---|
| 216 | 214 | av_err: |
|---|
| 217 | | - kfree(ah); |
|---|
| 218 | | - return ERR_PTR(status); |
|---|
| 215 | + return status; |
|---|
| 219 | 216 | } |
|---|
| 220 | 217 | |
|---|
| 221 | | -int ocrdma_destroy_ah(struct ib_ah *ibah) |
|---|
| 218 | +int ocrdma_destroy_ah(struct ib_ah *ibah, u32 flags) |
|---|
| 222 | 219 | { |
|---|
| 223 | 220 | struct ocrdma_ah *ah = get_ocrdma_ah(ibah); |
|---|
| 224 | 221 | struct ocrdma_dev *dev = get_ocrdma_dev(ibah->device); |
|---|
| 225 | 222 | |
|---|
| 226 | 223 | ocrdma_free_av(dev, ah); |
|---|
| 227 | | - kfree(ah); |
|---|
| 228 | 224 | return 0; |
|---|
| 229 | 225 | } |
|---|
| 230 | 226 | |
|---|
| .. | .. |
|---|
| 253 | 249 | return 0; |
|---|
| 254 | 250 | } |
|---|
| 255 | 251 | |
|---|
| 256 | | -int ocrdma_process_mad(struct ib_device *ibdev, |
|---|
| 257 | | - int process_mad_flags, |
|---|
| 258 | | - u8 port_num, |
|---|
| 259 | | - const struct ib_wc *in_wc, |
|---|
| 260 | | - const struct ib_grh *in_grh, |
|---|
| 261 | | - const struct ib_mad_hdr *in, size_t in_mad_size, |
|---|
| 262 | | - struct ib_mad_hdr *out, size_t *out_mad_size, |
|---|
| 252 | +int ocrdma_process_mad(struct ib_device *ibdev, int process_mad_flags, |
|---|
| 253 | + u8 port_num, const struct ib_wc *in_wc, |
|---|
| 254 | + const struct ib_grh *in_grh, const struct ib_mad *in, |
|---|
| 255 | + struct ib_mad *out, size_t *out_mad_size, |
|---|
| 263 | 256 | u16 *out_mad_pkey_index) |
|---|
| 264 | 257 | { |
|---|
| 265 | | - int status; |
|---|
| 258 | + int status = IB_MAD_RESULT_SUCCESS; |
|---|
| 266 | 259 | struct ocrdma_dev *dev; |
|---|
| 267 | | - const struct ib_mad *in_mad = (const struct ib_mad *)in; |
|---|
| 268 | | - struct ib_mad *out_mad = (struct ib_mad *)out; |
|---|
| 269 | 260 | |
|---|
| 270 | | - if (WARN_ON_ONCE(in_mad_size != sizeof(*in_mad) || |
|---|
| 271 | | - *out_mad_size != sizeof(*out_mad))) |
|---|
| 272 | | - return IB_MAD_RESULT_FAILURE; |
|---|
| 273 | | - |
|---|
| 274 | | - switch (in_mad->mad_hdr.mgmt_class) { |
|---|
| 275 | | - case IB_MGMT_CLASS_PERF_MGMT: |
|---|
| 261 | + if (in->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT) { |
|---|
| 276 | 262 | dev = get_ocrdma_dev(ibdev); |
|---|
| 277 | | - if (!ocrdma_pma_counters(dev, out_mad)) |
|---|
| 278 | | - status = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY; |
|---|
| 279 | | - else |
|---|
| 280 | | - status = IB_MAD_RESULT_SUCCESS; |
|---|
| 281 | | - break; |
|---|
| 282 | | - default: |
|---|
| 283 | | - status = IB_MAD_RESULT_SUCCESS; |
|---|
| 284 | | - break; |
|---|
| 263 | + ocrdma_pma_counters(dev, out); |
|---|
| 264 | + status |= IB_MAD_RESULT_REPLY; |
|---|
| 285 | 265 | } |
|---|
| 266 | + |
|---|
| 286 | 267 | return status; |
|---|
| 287 | 268 | } |
|---|