static int destroy_cq(PVRDMADev *dev, union pvrdma_cmd_req *req, union pvrdma_cmd_resp *rsp) { struct pvrdma_cmd_destroy_cq *cmd = &req->destroy_cq; RdmaRmCQ *cq; PvrdmaRing *ring; pr_dbg("cq_handle=%d\n", cmd->cq_handle); cq = rdma_rm_get_cq(&dev->rdma_dev_res, cmd->cq_handle); if (!cq) { pr_dbg("Invalid CQ handle\n"); return -EINVAL; } ring = (PvrdmaRing *)cq->opaque; pvrdma_ring_free(ring); /* ring_state was in slot 1, not 0 so need to jump back */ rdma_pci_dma_unmap(PCI_DEVICE(dev), --ring->ring_state, TARGET_PAGE_SIZE); g_free(ring); rdma_rm_dealloc_cq(&dev->rdma_dev_res, cmd->cq_handle); return 0; }
void rdma_rm_dealloc_cq(RdmaDeviceResources *dev_res, uint32_t cq_handle) { RdmaRmCQ *cq; cq = rdma_rm_get_cq(dev_res, cq_handle); if (!cq) { return; } rdma_backend_destroy_cq(&cq->backend_cq); res_tbl_dealloc(&dev_res->cq_tbl, cq_handle); }
void rdma_rm_req_notify_cq(RdmaDeviceResources *dev_res, uint32_t cq_handle, bool notify) { RdmaRmCQ *cq; pr_dbg("cq_handle=%d, notify=0x%x\n", cq_handle, notify); cq = rdma_rm_get_cq(dev_res, cq_handle); if (!cq) { return; } cq->notify = notify; pr_dbg("notify=%d\n", cq->notify); }
int rdma_rm_alloc_qp(RdmaDeviceResources *dev_res, uint32_t pd_handle, uint8_t qp_type, uint32_t max_send_wr, uint32_t max_send_sge, uint32_t send_cq_handle, uint32_t max_recv_wr, uint32_t max_recv_sge, uint32_t recv_cq_handle, void *opaque, uint32_t *qpn) { int rc; RdmaRmQP *qp; RdmaRmCQ *scq, *rcq; RdmaRmPD *pd; uint32_t rm_qpn; pr_dbg("qp_type=%d\n", qp_type); pd = rdma_rm_get_pd(dev_res, pd_handle); if (!pd) { pr_err("Invalid pd handle (%d)\n", pd_handle); return -EINVAL; } scq = rdma_rm_get_cq(dev_res, send_cq_handle); rcq = rdma_rm_get_cq(dev_res, recv_cq_handle); if (!scq || !rcq) { pr_err("Invalid send_cqn or recv_cqn (%d, %d)\n", send_cq_handle, recv_cq_handle); return -EINVAL; } qp = res_tbl_alloc(&dev_res->qp_tbl, &rm_qpn); if (!qp) { return -ENOMEM; } pr_dbg("rm_qpn=%d\n", rm_qpn); qp->qpn = rm_qpn; qp->qp_state = IBV_QPS_RESET; qp->qp_type = qp_type; qp->send_cq_handle = send_cq_handle; qp->recv_cq_handle = recv_cq_handle; qp->opaque = opaque; rc = rdma_backend_create_qp(&qp->backend_qp, qp_type, &pd->backend_pd, &scq->backend_cq, &rcq->backend_cq, max_send_wr, max_recv_wr, max_send_sge, max_recv_sge); if (rc) { rc = -EIO; goto out_dealloc_qp; } *qpn = rdma_backend_qpn(&qp->backend_qp); pr_dbg("rm_qpn=%d, backend_qpn=0x%x\n", rm_qpn, *qpn); g_hash_table_insert(dev_res->qp_hash, g_bytes_new(qpn, sizeof(*qpn)), qp); return 0; out_dealloc_qp: res_tbl_dealloc(&dev_res->qp_tbl, qp->qpn); return rc; }