| 355 | } |
| 356 | |
| 357 | static void krping_cq_event_handler(struct ib_cq *cq, void *ctx) |
| 358 | { |
| 359 | struct krping_cb *cb = ctx; |
| 360 | struct ib_wc wc; |
| 361 | struct ib_recv_wr *bad_wr; |
| 362 | int ret; |
| 363 | |
| 364 | BUG_ON(cb->cq != cq); |
| 365 | if (cb->frtest) { |
| 366 | printk(KERN_ERR PFX "cq completion event in frtest!\n"); |
| 367 | return; |
| 368 | } |
| 369 | if (!cb->wlat && !cb->rlat && !cb->bw) |
| 370 | ib_req_notify_cq(cb->cq, IB_CQ_NEXT_COMP); |
| 371 | while ((ret = ib_poll_cq(cb->cq, 1, &wc)) == 1) { |
| 372 | if (wc.status) { |
| 373 | if (wc.status == IB_WC_WR_FLUSH_ERR) { |
| 374 | DEBUG_LOG("cq flushed\n"); |
| 375 | continue; |
| 376 | } else { |
| 377 | printk(KERN_ERR PFX "cq completion failed with " |
| 378 | "wr_id %jx status %d opcode %d vender_err %x\n", |
| 379 | (uintmax_t)wc.wr_id, wc.status, wc.opcode, wc.vendor_err); |
| 380 | goto error; |
| 381 | } |
| 382 | } |
| 383 | if (cb->state == ERROR) { |
| 384 | printk(KERN_ERR PFX "cq completion in ERROR state\n"); |
| 385 | return; |
| 386 | } |
| 387 | switch (wc.opcode) { |
| 388 | case IB_WC_SEND: |
| 389 | DEBUG_LOG("send completion\n"); |
| 390 | cb->stats.send_bytes += cb->send_sgl.length; |
| 391 | cb->stats.send_msgs++; |
| 392 | break; |
| 393 | |
| 394 | case IB_WC_RDMA_WRITE: |
| 395 | DEBUG_LOG("rdma write completion\n"); |
| 396 | cb->stats.write_bytes += cb->rdma_sq_wr.wr.sg_list->length; |
| 397 | cb->stats.write_msgs++; |
| 398 | cb->state = RDMA_WRITE_COMPLETE; |
| 399 | wake_up_interruptible(&cb->sem); |
| 400 | break; |
| 401 | |
| 402 | case IB_WC_RDMA_READ: |
| 403 | DEBUG_LOG("rdma read completion\n"); |
| 404 | cb->stats.read_bytes += cb->rdma_sq_wr.wr.sg_list->length; |
| 405 | cb->stats.read_msgs++; |
| 406 | cb->state = RDMA_READ_COMPLETE; |
| 407 | wake_up_interruptible(&cb->sem); |
| 408 | break; |
| 409 | |
| 410 | case IB_WC_RECV: |
| 411 | DEBUG_LOG("recv completion\n"); |
| 412 | cb->stats.recv_bytes += sizeof(cb->recv_buf); |
| 413 | cb->stats.recv_msgs++; |
| 414 | if (cb->wlat || cb->rlat || cb->bw) |
no test coverage detected