| .. | .. |
|---|
| 60 | 60 | * @solicited: true if @entry is solicited |
|---|
| 61 | 61 | * |
|---|
| 62 | 62 | * This may be called with qp->s_lock held. |
|---|
| 63 | + * |
|---|
| 64 | + * Return: return true on success, else return |
|---|
| 65 | + * false if cq is full. |
|---|
| 63 | 66 | */ |
|---|
| 64 | | -void rvt_cq_enter(struct rvt_cq *cq, struct ib_wc *entry, bool solicited) |
|---|
| 67 | +bool rvt_cq_enter(struct rvt_cq *cq, struct ib_wc *entry, bool solicited) |
|---|
| 65 | 68 | { |
|---|
| 66 | | - struct rvt_cq_wc *wc; |
|---|
| 69 | + struct ib_uverbs_wc *uqueue = NULL; |
|---|
| 70 | + struct ib_wc *kqueue = NULL; |
|---|
| 71 | + struct rvt_cq_wc *u_wc = NULL; |
|---|
| 72 | + struct rvt_k_cq_wc *k_wc = NULL; |
|---|
| 67 | 73 | unsigned long flags; |
|---|
| 68 | 74 | u32 head; |
|---|
| 69 | 75 | u32 next; |
|---|
| 76 | + u32 tail; |
|---|
| 70 | 77 | |
|---|
| 71 | 78 | spin_lock_irqsave(&cq->lock, flags); |
|---|
| 72 | 79 | |
|---|
| 80 | + if (cq->ip) { |
|---|
| 81 | + u_wc = cq->queue; |
|---|
| 82 | + uqueue = &u_wc->uqueue[0]; |
|---|
| 83 | + head = RDMA_READ_UAPI_ATOMIC(u_wc->head); |
|---|
| 84 | + tail = RDMA_READ_UAPI_ATOMIC(u_wc->tail); |
|---|
| 85 | + } else { |
|---|
| 86 | + k_wc = cq->kqueue; |
|---|
| 87 | + kqueue = &k_wc->kqueue[0]; |
|---|
| 88 | + head = k_wc->head; |
|---|
| 89 | + tail = k_wc->tail; |
|---|
| 90 | + } |
|---|
| 91 | + |
|---|
| 73 | 92 | /* |
|---|
| 74 | | - * Note that the head pointer might be writable by user processes. |
|---|
| 75 | | - * Take care to verify it is a sane value. |
|---|
| 93 | + * Note that the head pointer might be writable by |
|---|
| 94 | + * user processes.Take care to verify it is a sane value. |
|---|
| 76 | 95 | */ |
|---|
| 77 | | - wc = cq->queue; |
|---|
| 78 | | - head = wc->head; |
|---|
| 79 | 96 | if (head >= (unsigned)cq->ibcq.cqe) { |
|---|
| 80 | 97 | head = cq->ibcq.cqe; |
|---|
| 81 | 98 | next = 0; |
|---|
| .. | .. |
|---|
| 83 | 100 | next = head + 1; |
|---|
| 84 | 101 | } |
|---|
| 85 | 102 | |
|---|
| 86 | | - if (unlikely(next == wc->tail)) { |
|---|
| 103 | + if (unlikely(next == tail || cq->cq_full)) { |
|---|
| 104 | + struct rvt_dev_info *rdi = cq->rdi; |
|---|
| 105 | + |
|---|
| 106 | + if (!cq->cq_full) |
|---|
| 107 | + rvt_pr_err_ratelimited(rdi, "CQ is full!\n"); |
|---|
| 108 | + cq->cq_full = true; |
|---|
| 87 | 109 | spin_unlock_irqrestore(&cq->lock, flags); |
|---|
| 88 | 110 | if (cq->ibcq.event_handler) { |
|---|
| 89 | 111 | struct ib_event ev; |
|---|
| .. | .. |
|---|
| 93 | 115 | ev.event = IB_EVENT_CQ_ERR; |
|---|
| 94 | 116 | cq->ibcq.event_handler(&ev, cq->ibcq.cq_context); |
|---|
| 95 | 117 | } |
|---|
| 96 | | - return; |
|---|
| 118 | + return false; |
|---|
| 97 | 119 | } |
|---|
| 98 | 120 | trace_rvt_cq_enter(cq, entry, head); |
|---|
| 99 | | - if (cq->ip) { |
|---|
| 100 | | - wc->uqueue[head].wr_id = entry->wr_id; |
|---|
| 101 | | - wc->uqueue[head].status = entry->status; |
|---|
| 102 | | - wc->uqueue[head].opcode = entry->opcode; |
|---|
| 103 | | - wc->uqueue[head].vendor_err = entry->vendor_err; |
|---|
| 104 | | - wc->uqueue[head].byte_len = entry->byte_len; |
|---|
| 105 | | - wc->uqueue[head].ex.imm_data = entry->ex.imm_data; |
|---|
| 106 | | - wc->uqueue[head].qp_num = entry->qp->qp_num; |
|---|
| 107 | | - wc->uqueue[head].src_qp = entry->src_qp; |
|---|
| 108 | | - wc->uqueue[head].wc_flags = entry->wc_flags; |
|---|
| 109 | | - wc->uqueue[head].pkey_index = entry->pkey_index; |
|---|
| 110 | | - wc->uqueue[head].slid = ib_lid_cpu16(entry->slid); |
|---|
| 111 | | - wc->uqueue[head].sl = entry->sl; |
|---|
| 112 | | - wc->uqueue[head].dlid_path_bits = entry->dlid_path_bits; |
|---|
| 113 | | - wc->uqueue[head].port_num = entry->port_num; |
|---|
| 121 | + if (uqueue) { |
|---|
| 122 | + uqueue[head].wr_id = entry->wr_id; |
|---|
| 123 | + uqueue[head].status = entry->status; |
|---|
| 124 | + uqueue[head].opcode = entry->opcode; |
|---|
| 125 | + uqueue[head].vendor_err = entry->vendor_err; |
|---|
| 126 | + uqueue[head].byte_len = entry->byte_len; |
|---|
| 127 | + uqueue[head].ex.imm_data = entry->ex.imm_data; |
|---|
| 128 | + uqueue[head].qp_num = entry->qp->qp_num; |
|---|
| 129 | + uqueue[head].src_qp = entry->src_qp; |
|---|
| 130 | + uqueue[head].wc_flags = entry->wc_flags; |
|---|
| 131 | + uqueue[head].pkey_index = entry->pkey_index; |
|---|
| 132 | + uqueue[head].slid = ib_lid_cpu16(entry->slid); |
|---|
| 133 | + uqueue[head].sl = entry->sl; |
|---|
| 134 | + uqueue[head].dlid_path_bits = entry->dlid_path_bits; |
|---|
| 135 | + uqueue[head].port_num = entry->port_num; |
|---|
| 114 | 136 | /* Make sure entry is written before the head index. */ |
|---|
| 115 | | - smp_wmb(); |
|---|
| 137 | + RDMA_WRITE_UAPI_ATOMIC(u_wc->head, next); |
|---|
| 116 | 138 | } else { |
|---|
| 117 | | - wc->kqueue[head] = *entry; |
|---|
| 139 | + kqueue[head] = *entry; |
|---|
| 140 | + k_wc->head = next; |
|---|
| 118 | 141 | } |
|---|
| 119 | | - wc->head = next; |
|---|
| 120 | 142 | |
|---|
| 121 | 143 | if (cq->notify == IB_CQ_NEXT_COMP || |
|---|
| 122 | 144 | (cq->notify == IB_CQ_SOLICITED && |
|---|
| .. | .. |
|---|
| 132 | 154 | } |
|---|
| 133 | 155 | |
|---|
| 134 | 156 | spin_unlock_irqrestore(&cq->lock, flags); |
|---|
| 157 | + return true; |
|---|
| 135 | 158 | } |
|---|
| 136 | 159 | EXPORT_SYMBOL(rvt_cq_enter); |
|---|
| 137 | 160 | |
|---|
| .. | .. |
|---|
| 166 | 189 | |
|---|
| 167 | 190 | /** |
|---|
| 168 | 191 | * rvt_create_cq - create a completion queue |
|---|
| 169 | | - * @ibdev: the device this completion queue is attached to |
|---|
| 192 | + * @ibcq: Allocated CQ |
|---|
| 170 | 193 | * @attr: creation attributes |
|---|
| 171 | | - * @context: unused by the QLogic_IB driver |
|---|
| 172 | 194 | * @udata: user data for libibverbs.so |
|---|
| 173 | 195 | * |
|---|
| 174 | 196 | * Called by ib_create_cq() in the generic verbs code. |
|---|
| 175 | 197 | * |
|---|
| 176 | | - * Return: pointer to the completion queue or negative errno values |
|---|
| 177 | | - * for failure. |
|---|
| 198 | + * Return: 0 on success |
|---|
| 178 | 199 | */ |
|---|
| 179 | | -struct ib_cq *rvt_create_cq(struct ib_device *ibdev, |
|---|
| 180 | | - const struct ib_cq_init_attr *attr, |
|---|
| 181 | | - struct ib_ucontext *context, |
|---|
| 182 | | - struct ib_udata *udata) |
|---|
| 200 | +int rvt_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, |
|---|
| 201 | + struct ib_udata *udata) |
|---|
| 183 | 202 | { |
|---|
| 203 | + struct ib_device *ibdev = ibcq->device; |
|---|
| 184 | 204 | struct rvt_dev_info *rdi = ib_to_rvt(ibdev); |
|---|
| 185 | | - struct rvt_cq *cq; |
|---|
| 186 | | - struct rvt_cq_wc *wc; |
|---|
| 187 | | - struct ib_cq *ret; |
|---|
| 205 | + struct rvt_cq *cq = ibcq_to_rvtcq(ibcq); |
|---|
| 206 | + struct rvt_cq_wc *u_wc = NULL; |
|---|
| 207 | + struct rvt_k_cq_wc *k_wc = NULL; |
|---|
| 188 | 208 | u32 sz; |
|---|
| 189 | 209 | unsigned int entries = attr->cqe; |
|---|
| 190 | 210 | int comp_vector = attr->comp_vector; |
|---|
| 211 | + int err; |
|---|
| 191 | 212 | |
|---|
| 192 | 213 | if (attr->flags) |
|---|
| 193 | | - return ERR_PTR(-EINVAL); |
|---|
| 214 | + return -EINVAL; |
|---|
| 194 | 215 | |
|---|
| 195 | 216 | if (entries < 1 || entries > rdi->dparms.props.max_cqe) |
|---|
| 196 | | - return ERR_PTR(-EINVAL); |
|---|
| 217 | + return -EINVAL; |
|---|
| 197 | 218 | |
|---|
| 198 | 219 | if (comp_vector < 0) |
|---|
| 199 | 220 | comp_vector = 0; |
|---|
| 200 | 221 | |
|---|
| 201 | 222 | comp_vector = comp_vector % rdi->ibdev.num_comp_vectors; |
|---|
| 202 | | - |
|---|
| 203 | | - /* Allocate the completion queue structure. */ |
|---|
| 204 | | - cq = kzalloc_node(sizeof(*cq), GFP_KERNEL, rdi->dparms.node); |
|---|
| 205 | | - if (!cq) |
|---|
| 206 | | - return ERR_PTR(-ENOMEM); |
|---|
| 207 | 223 | |
|---|
| 208 | 224 | /* |
|---|
| 209 | 225 | * Allocate the completion queue entries and head/tail pointers. |
|---|
| .. | .. |
|---|
| 212 | 228 | * We need to use vmalloc() in order to support mmap and large |
|---|
| 213 | 229 | * numbers of entries. |
|---|
| 214 | 230 | */ |
|---|
| 215 | | - sz = sizeof(*wc); |
|---|
| 216 | | - if (udata && udata->outlen >= sizeof(__u64)) |
|---|
| 217 | | - sz += sizeof(struct ib_uverbs_wc) * (entries + 1); |
|---|
| 218 | | - else |
|---|
| 219 | | - sz += sizeof(struct ib_wc) * (entries + 1); |
|---|
| 220 | | - wc = udata ? |
|---|
| 221 | | - vmalloc_user(sz) : |
|---|
| 222 | | - vzalloc_node(sz, rdi->dparms.node); |
|---|
| 223 | | - if (!wc) { |
|---|
| 224 | | - ret = ERR_PTR(-ENOMEM); |
|---|
| 225 | | - goto bail_cq; |
|---|
| 231 | + if (udata && udata->outlen >= sizeof(__u64)) { |
|---|
| 232 | + sz = sizeof(struct ib_uverbs_wc) * (entries + 1); |
|---|
| 233 | + sz += sizeof(*u_wc); |
|---|
| 234 | + u_wc = vmalloc_user(sz); |
|---|
| 235 | + if (!u_wc) |
|---|
| 236 | + return -ENOMEM; |
|---|
| 237 | + } else { |
|---|
| 238 | + sz = sizeof(struct ib_wc) * (entries + 1); |
|---|
| 239 | + sz += sizeof(*k_wc); |
|---|
| 240 | + k_wc = vzalloc_node(sz, rdi->dparms.node); |
|---|
| 241 | + if (!k_wc) |
|---|
| 242 | + return -ENOMEM; |
|---|
| 226 | 243 | } |
|---|
| 227 | 244 | |
|---|
| 228 | 245 | /* |
|---|
| .. | .. |
|---|
| 230 | 247 | * See rvt_mmap() for details. |
|---|
| 231 | 248 | */ |
|---|
| 232 | 249 | if (udata && udata->outlen >= sizeof(__u64)) { |
|---|
| 233 | | - int err; |
|---|
| 234 | | - |
|---|
| 235 | | - cq->ip = rvt_create_mmap_info(rdi, sz, context, wc); |
|---|
| 236 | | - if (!cq->ip) { |
|---|
| 237 | | - ret = ERR_PTR(-ENOMEM); |
|---|
| 250 | + cq->ip = rvt_create_mmap_info(rdi, sz, udata, u_wc); |
|---|
| 251 | + if (IS_ERR(cq->ip)) { |
|---|
| 252 | + err = PTR_ERR(cq->ip); |
|---|
| 238 | 253 | goto bail_wc; |
|---|
| 239 | 254 | } |
|---|
| 240 | 255 | |
|---|
| 241 | 256 | err = ib_copy_to_udata(udata, &cq->ip->offset, |
|---|
| 242 | 257 | sizeof(cq->ip->offset)); |
|---|
| 243 | | - if (err) { |
|---|
| 244 | | - ret = ERR_PTR(err); |
|---|
| 258 | + if (err) |
|---|
| 245 | 259 | goto bail_ip; |
|---|
| 246 | | - } |
|---|
| 247 | 260 | } |
|---|
| 248 | 261 | |
|---|
| 249 | 262 | spin_lock_irq(&rdi->n_cqs_lock); |
|---|
| 250 | 263 | if (rdi->n_cqs_allocated == rdi->dparms.props.max_cq) { |
|---|
| 251 | 264 | spin_unlock_irq(&rdi->n_cqs_lock); |
|---|
| 252 | | - ret = ERR_PTR(-ENOMEM); |
|---|
| 265 | + err = -ENOMEM; |
|---|
| 253 | 266 | goto bail_ip; |
|---|
| 254 | 267 | } |
|---|
| 255 | 268 | |
|---|
| .. | .. |
|---|
| 279 | 292 | cq->notify = RVT_CQ_NONE; |
|---|
| 280 | 293 | spin_lock_init(&cq->lock); |
|---|
| 281 | 294 | INIT_WORK(&cq->comptask, send_complete); |
|---|
| 282 | | - cq->queue = wc; |
|---|
| 283 | | - |
|---|
| 284 | | - ret = &cq->ibcq; |
|---|
| 295 | + if (u_wc) |
|---|
| 296 | + cq->queue = u_wc; |
|---|
| 297 | + else |
|---|
| 298 | + cq->kqueue = k_wc; |
|---|
| 285 | 299 | |
|---|
| 286 | 300 | trace_rvt_create_cq(cq, attr); |
|---|
| 287 | | - goto done; |
|---|
| 301 | + return 0; |
|---|
| 288 | 302 | |
|---|
| 289 | 303 | bail_ip: |
|---|
| 290 | 304 | kfree(cq->ip); |
|---|
| 291 | 305 | bail_wc: |
|---|
| 292 | | - vfree(wc); |
|---|
| 293 | | -bail_cq: |
|---|
| 294 | | - kfree(cq); |
|---|
| 295 | | -done: |
|---|
| 296 | | - return ret; |
|---|
| 306 | + vfree(u_wc); |
|---|
| 307 | + vfree(k_wc); |
|---|
| 308 | + return err; |
|---|
| 297 | 309 | } |
|---|
| 298 | 310 | |
|---|
| 299 | 311 | /** |
|---|
| 300 | 312 | * rvt_destroy_cq - destroy a completion queue |
|---|
| 301 | 313 | * @ibcq: the completion queue to destroy. |
|---|
| 314 | + * @udata: user data or NULL for kernel object |
|---|
| 302 | 315 | * |
|---|
| 303 | 316 | * Called by ib_destroy_cq() in the generic verbs code. |
|---|
| 304 | | - * |
|---|
| 305 | | - * Return: always 0 |
|---|
| 306 | 317 | */ |
|---|
| 307 | | -int rvt_destroy_cq(struct ib_cq *ibcq) |
|---|
| 318 | +int rvt_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) |
|---|
| 308 | 319 | { |
|---|
| 309 | 320 | struct rvt_cq *cq = ibcq_to_rvtcq(ibcq); |
|---|
| 310 | 321 | struct rvt_dev_info *rdi = cq->rdi; |
|---|
| .. | .. |
|---|
| 316 | 327 | if (cq->ip) |
|---|
| 317 | 328 | kref_put(&cq->ip->ref, rvt_release_mmap_info); |
|---|
| 318 | 329 | else |
|---|
| 319 | | - vfree(cq->queue); |
|---|
| 320 | | - kfree(cq); |
|---|
| 321 | | - |
|---|
| 330 | + vfree(cq->kqueue); |
|---|
| 322 | 331 | return 0; |
|---|
| 323 | 332 | } |
|---|
| 324 | 333 | |
|---|
| .. | .. |
|---|
| 346 | 355 | if (cq->notify != IB_CQ_NEXT_COMP) |
|---|
| 347 | 356 | cq->notify = notify_flags & IB_CQ_SOLICITED_MASK; |
|---|
| 348 | 357 | |
|---|
| 349 | | - if ((notify_flags & IB_CQ_REPORT_MISSED_EVENTS) && |
|---|
| 350 | | - cq->queue->head != cq->queue->tail) |
|---|
| 351 | | - ret = 1; |
|---|
| 358 | + if (notify_flags & IB_CQ_REPORT_MISSED_EVENTS) { |
|---|
| 359 | + if (cq->queue) { |
|---|
| 360 | + if (RDMA_READ_UAPI_ATOMIC(cq->queue->head) != |
|---|
| 361 | + RDMA_READ_UAPI_ATOMIC(cq->queue->tail)) |
|---|
| 362 | + ret = 1; |
|---|
| 363 | + } else { |
|---|
| 364 | + if (cq->kqueue->head != cq->kqueue->tail) |
|---|
| 365 | + ret = 1; |
|---|
| 366 | + } |
|---|
| 367 | + } |
|---|
| 352 | 368 | |
|---|
| 353 | 369 | spin_unlock_irqrestore(&cq->lock, flags); |
|---|
| 354 | 370 | |
|---|
| .. | .. |
|---|
| 364 | 380 | int rvt_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata) |
|---|
| 365 | 381 | { |
|---|
| 366 | 382 | struct rvt_cq *cq = ibcq_to_rvtcq(ibcq); |
|---|
| 367 | | - struct rvt_cq_wc *old_wc; |
|---|
| 368 | | - struct rvt_cq_wc *wc; |
|---|
| 369 | 383 | u32 head, tail, n; |
|---|
| 370 | 384 | int ret; |
|---|
| 371 | 385 | u32 sz; |
|---|
| 372 | 386 | struct rvt_dev_info *rdi = cq->rdi; |
|---|
| 387 | + struct rvt_cq_wc *u_wc = NULL; |
|---|
| 388 | + struct rvt_cq_wc *old_u_wc = NULL; |
|---|
| 389 | + struct rvt_k_cq_wc *k_wc = NULL; |
|---|
| 390 | + struct rvt_k_cq_wc *old_k_wc = NULL; |
|---|
| 373 | 391 | |
|---|
| 374 | 392 | if (cqe < 1 || cqe > rdi->dparms.props.max_cqe) |
|---|
| 375 | 393 | return -EINVAL; |
|---|
| .. | .. |
|---|
| 377 | 395 | /* |
|---|
| 378 | 396 | * Need to use vmalloc() if we want to support large #s of entries. |
|---|
| 379 | 397 | */ |
|---|
| 380 | | - sz = sizeof(*wc); |
|---|
| 381 | | - if (udata && udata->outlen >= sizeof(__u64)) |
|---|
| 382 | | - sz += sizeof(struct ib_uverbs_wc) * (cqe + 1); |
|---|
| 383 | | - else |
|---|
| 384 | | - sz += sizeof(struct ib_wc) * (cqe + 1); |
|---|
| 385 | | - wc = udata ? |
|---|
| 386 | | - vmalloc_user(sz) : |
|---|
| 387 | | - vzalloc_node(sz, rdi->dparms.node); |
|---|
| 388 | | - if (!wc) |
|---|
| 389 | | - return -ENOMEM; |
|---|
| 390 | | - |
|---|
| 398 | + if (udata && udata->outlen >= sizeof(__u64)) { |
|---|
| 399 | + sz = sizeof(struct ib_uverbs_wc) * (cqe + 1); |
|---|
| 400 | + sz += sizeof(*u_wc); |
|---|
| 401 | + u_wc = vmalloc_user(sz); |
|---|
| 402 | + if (!u_wc) |
|---|
| 403 | + return -ENOMEM; |
|---|
| 404 | + } else { |
|---|
| 405 | + sz = sizeof(struct ib_wc) * (cqe + 1); |
|---|
| 406 | + sz += sizeof(*k_wc); |
|---|
| 407 | + k_wc = vzalloc_node(sz, rdi->dparms.node); |
|---|
| 408 | + if (!k_wc) |
|---|
| 409 | + return -ENOMEM; |
|---|
| 410 | + } |
|---|
| 391 | 411 | /* Check that we can write the offset to mmap. */ |
|---|
| 392 | 412 | if (udata && udata->outlen >= sizeof(__u64)) { |
|---|
| 393 | 413 | __u64 offset = 0; |
|---|
| .. | .. |
|---|
| 402 | 422 | * Make sure head and tail are sane since they |
|---|
| 403 | 423 | * might be user writable. |
|---|
| 404 | 424 | */ |
|---|
| 405 | | - old_wc = cq->queue; |
|---|
| 406 | | - head = old_wc->head; |
|---|
| 425 | + if (u_wc) { |
|---|
| 426 | + old_u_wc = cq->queue; |
|---|
| 427 | + head = RDMA_READ_UAPI_ATOMIC(old_u_wc->head); |
|---|
| 428 | + tail = RDMA_READ_UAPI_ATOMIC(old_u_wc->tail); |
|---|
| 429 | + } else { |
|---|
| 430 | + old_k_wc = cq->kqueue; |
|---|
| 431 | + head = old_k_wc->head; |
|---|
| 432 | + tail = old_k_wc->tail; |
|---|
| 433 | + } |
|---|
| 434 | + |
|---|
| 407 | 435 | if (head > (u32)cq->ibcq.cqe) |
|---|
| 408 | 436 | head = (u32)cq->ibcq.cqe; |
|---|
| 409 | | - tail = old_wc->tail; |
|---|
| 410 | 437 | if (tail > (u32)cq->ibcq.cqe) |
|---|
| 411 | 438 | tail = (u32)cq->ibcq.cqe; |
|---|
| 412 | 439 | if (head < tail) |
|---|
| .. | .. |
|---|
| 418 | 445 | goto bail_unlock; |
|---|
| 419 | 446 | } |
|---|
| 420 | 447 | for (n = 0; tail != head; n++) { |
|---|
| 421 | | - if (cq->ip) |
|---|
| 422 | | - wc->uqueue[n] = old_wc->uqueue[tail]; |
|---|
| 448 | + if (u_wc) |
|---|
| 449 | + u_wc->uqueue[n] = old_u_wc->uqueue[tail]; |
|---|
| 423 | 450 | else |
|---|
| 424 | | - wc->kqueue[n] = old_wc->kqueue[tail]; |
|---|
| 451 | + k_wc->kqueue[n] = old_k_wc->kqueue[tail]; |
|---|
| 425 | 452 | if (tail == (u32)cq->ibcq.cqe) |
|---|
| 426 | 453 | tail = 0; |
|---|
| 427 | 454 | else |
|---|
| 428 | 455 | tail++; |
|---|
| 429 | 456 | } |
|---|
| 430 | 457 | cq->ibcq.cqe = cqe; |
|---|
| 431 | | - wc->head = n; |
|---|
| 432 | | - wc->tail = 0; |
|---|
| 433 | | - cq->queue = wc; |
|---|
| 458 | + if (u_wc) { |
|---|
| 459 | + RDMA_WRITE_UAPI_ATOMIC(u_wc->head, n); |
|---|
| 460 | + RDMA_WRITE_UAPI_ATOMIC(u_wc->tail, 0); |
|---|
| 461 | + cq->queue = u_wc; |
|---|
| 462 | + } else { |
|---|
| 463 | + k_wc->head = n; |
|---|
| 464 | + k_wc->tail = 0; |
|---|
| 465 | + cq->kqueue = k_wc; |
|---|
| 466 | + } |
|---|
| 434 | 467 | spin_unlock_irq(&cq->lock); |
|---|
| 435 | 468 | |
|---|
| 436 | | - vfree(old_wc); |
|---|
| 469 | + if (u_wc) |
|---|
| 470 | + vfree(old_u_wc); |
|---|
| 471 | + else |
|---|
| 472 | + vfree(old_k_wc); |
|---|
| 437 | 473 | |
|---|
| 438 | 474 | if (cq->ip) { |
|---|
| 439 | 475 | struct rvt_mmap_info *ip = cq->ip; |
|---|
| 440 | 476 | |
|---|
| 441 | | - rvt_update_mmap_info(rdi, ip, sz, wc); |
|---|
| 477 | + rvt_update_mmap_info(rdi, ip, sz, u_wc); |
|---|
| 442 | 478 | |
|---|
| 443 | 479 | /* |
|---|
| 444 | 480 | * Return the offset to mmap. |
|---|
| .. | .. |
|---|
| 462 | 498 | bail_unlock: |
|---|
| 463 | 499 | spin_unlock_irq(&cq->lock); |
|---|
| 464 | 500 | bail_free: |
|---|
| 465 | | - vfree(wc); |
|---|
| 501 | + vfree(u_wc); |
|---|
| 502 | + vfree(k_wc); |
|---|
| 503 | + |
|---|
| 466 | 504 | return ret; |
|---|
| 467 | 505 | } |
|---|
| 468 | 506 | |
|---|
| .. | .. |
|---|
| 480 | 518 | int rvt_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry) |
|---|
| 481 | 519 | { |
|---|
| 482 | 520 | struct rvt_cq *cq = ibcq_to_rvtcq(ibcq); |
|---|
| 483 | | - struct rvt_cq_wc *wc; |
|---|
| 521 | + struct rvt_k_cq_wc *wc; |
|---|
| 484 | 522 | unsigned long flags; |
|---|
| 485 | 523 | int npolled; |
|---|
| 486 | 524 | u32 tail; |
|---|
| .. | .. |
|---|
| 491 | 529 | |
|---|
| 492 | 530 | spin_lock_irqsave(&cq->lock, flags); |
|---|
| 493 | 531 | |
|---|
| 494 | | - wc = cq->queue; |
|---|
| 532 | + wc = cq->kqueue; |
|---|
| 495 | 533 | tail = wc->tail; |
|---|
| 496 | 534 | if (tail > (u32)cq->ibcq.cqe) |
|---|
| 497 | 535 | tail = (u32)cq->ibcq.cqe; |
|---|
| .. | .. |
|---|
| 515 | 553 | |
|---|
| 516 | 554 | /** |
|---|
| 517 | 555 | * rvt_driver_cq_init - Init cq resources on behalf of driver |
|---|
| 518 | | - * @rdi: rvt dev structure |
|---|
| 519 | 556 | * |
|---|
| 520 | 557 | * Return: 0 on success |
|---|
| 521 | 558 | */ |
|---|
| .. | .. |
|---|
| 531 | 568 | |
|---|
| 532 | 569 | /** |
|---|
| 533 | 570 | * rvt_cq_exit - tear down cq reources |
|---|
| 534 | | - * @rdi: rvt dev structure |
|---|
| 535 | 571 | */ |
|---|
| 536 | 572 | void rvt_cq_exit(void) |
|---|
| 537 | 573 | { |
|---|