static int iwch_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags) { struct iwch_dev *rhp; struct iwch_cq *chp; enum t3_cq_opcode cq_op; int err; unsigned long flag; u32 rptr; chp = to_iwch_cq(ibcq); rhp = chp->rhp; if ((flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED) cq_op = CQ_ARM_SE; else cq_op = CQ_ARM_AN; if (chp->user_rptr_addr) { if (get_user(rptr, chp->user_rptr_addr)) return -EFAULT; spin_lock_irqsave(&chp->lock, flag); chp->cq.rptr = rptr; } else spin_lock_irqsave(&chp->lock, flag); PDBG("%s rptr 0x%x\n", __FUNCTION__, chp->cq.rptr); err = cxio_hal_cq_op(&rhp->rdev, &chp->cq, cq_op, 0); spin_unlock_irqrestore(&chp->lock, flag); if (err < 0) printk(KERN_ERR MOD "Error %d rearming CQID 0x%x\n", err, chp->cq.cqid); if (err > 0 && !(flags & IB_CQ_REPORT_MISSED_EVENTS)) err = 0; return err; }
/* * Get one cq entry from cxio and map it to openib. * * Returns: * 0 cqe returned * -ENOBUFS EMPTY; * -EAGAIN caller must try again * any other neg errno fatal error */ static int iwch_poll_cq_one(struct iwch_dev *rhp, struct iwch_cq *chp, struct ib_wc *wc) { struct iwch_qp *qhp = NULL; struct t3_cqe cqe, *rd_cqe; struct t3_wq *wq; u32 credit = 0; u8 cqe_flushed; u64 cookie; int ret = 1; rd_cqe = cxio_next_cqe(&chp->cq); if (!rd_cqe) return 0; qhp = get_qhp(rhp, CQE_QPID(*rd_cqe)); if (!qhp) wq = NULL; else { mtx_lock(&qhp->lock); wq = &(qhp->wq); } ret = cxio_poll_cq(wq, &(chp->cq), &cqe, &cqe_flushed, &cookie, &credit); if (t3a_device(chp->rhp) && credit) { CTR3(KTR_IW_CXGB, "%s updating %d cq credits on id %d", __FUNCTION__, credit, chp->cq.cqid); cxio_hal_cq_op(&rhp->rdev, &chp->cq, CQ_CREDIT_UPDATE, credit); } if (ret) { ret = -EAGAIN; goto out; } ret = 1; wc->wr_id = cookie; wc->qp = &qhp->ibqp; wc->vendor_err = CQE_STATUS(cqe); CTR4(KTR_IW_CXGB, "iwch_poll_cq_one qpid 0x%x type %d opcode %d status 0x%x", CQE_QPID(cqe), CQE_TYPE(cqe), CQE_OPCODE(cqe), CQE_STATUS(cqe)); CTR3(KTR_IW_CXGB, "wrid hi 0x%x lo 0x%x cookie 0x%llx", CQE_WRID_HI(cqe), CQE_WRID_LOW(cqe), (unsigned long long) cookie); if (CQE_TYPE(cqe) == 0) { if (!CQE_STATUS(cqe)) wc->byte_len = CQE_LEN(cqe); else wc->byte_len = 0; wc->opcode = IB_WC_RECV; } else { switch (CQE_OPCODE(cqe)) { case T3_RDMA_WRITE: wc->opcode = IB_WC_RDMA_WRITE; break; case T3_READ_REQ: wc->opcode = IB_WC_RDMA_READ; wc->byte_len = CQE_LEN(cqe); break; case T3_SEND: case T3_SEND_WITH_SE: wc->opcode = IB_WC_SEND; break; case T3_BIND_MW: wc->opcode = IB_WC_BIND_MW; break; /* these aren't supported yet */ case T3_SEND_WITH_INV: case T3_SEND_WITH_SE_INV: case T3_LOCAL_INV: case T3_FAST_REGISTER: default: log(LOG_ERR, "Unexpected opcode %d " "in the CQE received for QPID=0x%0x\n", CQE_OPCODE(cqe), CQE_QPID(cqe)); ret = -EINVAL; goto out; } } if (cqe_flushed) wc->status = IB_WC_WR_FLUSH_ERR; else { switch (CQE_STATUS(cqe)) { case TPT_ERR_SUCCESS: wc->status = IB_WC_SUCCESS; break; case TPT_ERR_STAG: wc->status = IB_WC_LOC_ACCESS_ERR; break; case TPT_ERR_PDID: wc->status = IB_WC_LOC_PROT_ERR; break; case TPT_ERR_QPID: case TPT_ERR_ACCESS: wc->status = IB_WC_LOC_ACCESS_ERR; break; case TPT_ERR_WRAP: wc->status = IB_WC_GENERAL_ERR; break; case TPT_ERR_BOUND: wc->status = IB_WC_LOC_LEN_ERR; break; case TPT_ERR_INVALIDATE_SHARED_MR: case TPT_ERR_INVALIDATE_MR_WITH_MW_BOUND: wc->status = IB_WC_MW_BIND_ERR; break; case TPT_ERR_CRC: case TPT_ERR_MARKER: case TPT_ERR_PDU_LEN_ERR: case TPT_ERR_OUT_OF_RQE: case TPT_ERR_DDP_VERSION: case TPT_ERR_RDMA_VERSION: case TPT_ERR_DDP_QUEUE_NUM: case TPT_ERR_MSN: case TPT_ERR_TBIT: case TPT_ERR_MO: case TPT_ERR_MSN_RANGE: case TPT_ERR_IRD_OVERFLOW: case TPT_ERR_OPCODE: wc->status = IB_WC_FATAL_ERR; break; case TPT_ERR_SWFLUSH: wc->status = IB_WC_WR_FLUSH_ERR; break; default: log(LOG_ERR, "Unexpected cqe_status 0x%x for " "QPID=0x%0x\n", CQE_STATUS(cqe), CQE_QPID(cqe)); ret = -EINVAL; } } out: if (wq) mtx_unlock(&qhp->lock); return ret; }