Lines Matching refs:cq
35 static int destroy_cq(struct c4iw_rdev *rdev, struct t4_cq *cq, in destroy_cq() argument
60 res->u.cq.restype = FW_RI_RES_TYPE_CQ; in destroy_cq()
61 res->u.cq.op = FW_RI_RES_OP_RESET; in destroy_cq()
62 res->u.cq.iqid = cpu_to_be32(cq->cqid); in destroy_cq()
70 kfree(cq->sw_queue); in destroy_cq()
72 cq->memsize, cq->queue, in destroy_cq()
73 dma_unmap_addr(cq, mapping)); in destroy_cq()
74 c4iw_put_cqid(rdev, cq->cqid, uctx); in destroy_cq()
78 static int create_cq(struct c4iw_rdev *rdev, struct t4_cq *cq, in create_cq() argument
89 cq->cqid = c4iw_get_cqid(rdev, uctx); in create_cq()
90 if (!cq->cqid) { in create_cq()
96 cq->sw_queue = kzalloc(cq->memsize, GFP_KERNEL); in create_cq()
97 if (!cq->sw_queue) { in create_cq()
102 cq->queue = dma_alloc_coherent(&rdev->lldi.pdev->dev, cq->memsize, in create_cq()
103 &cq->dma_addr, GFP_KERNEL); in create_cq()
104 if (!cq->queue) { in create_cq()
108 dma_unmap_addr_set(cq, mapping, cq->dma_addr); in create_cq()
109 memset(cq->queue, 0, cq->memsize); in create_cq()
130 res->u.cq.restype = FW_RI_RES_TYPE_CQ; in create_cq()
131 res->u.cq.op = FW_RI_RES_OP_WRITE; in create_cq()
132 res->u.cq.iqid = cpu_to_be32(cq->cqid); in create_cq()
133 res->u.cq.iqandst_to_iqandstindex = cpu_to_be32( in create_cq()
138 rdev->lldi.ciq_ids[cq->vector])); in create_cq()
139 res->u.cq.iqdroprss_to_iqesize = cpu_to_be16( in create_cq()
145 res->u.cq.iqsize = cpu_to_be16(cq->size); in create_cq()
146 res->u.cq.iqaddr = cpu_to_be64(cq->dma_addr); in create_cq()
158 cq->gen = 1; in create_cq()
159 cq->rdev = rdev; in create_cq()
161 u32 off = (cq->cqid << rdev->cqshift) & PAGE_MASK; in create_cq()
163 cq->ugts = (u64)rdev->bar2_pa + off; in create_cq()
165 cq->gts = rdev->lldi.gts_reg; in create_cq()
166 cq->qid_mask = -1U; in create_cq()
168 u32 off = ((cq->cqid << rdev->cqshift) & PAGE_MASK) + 12; in create_cq()
170 cq->gts = rdev->bar2_kva + off; in create_cq()
171 cq->qid_mask = rdev->qpmask; in create_cq()
175 dma_free_coherent(&rdev->lldi.pdev->dev, cq->memsize, cq->queue, in create_cq()
176 dma_unmap_addr(cq, mapping)); in create_cq()
178 kfree(cq->sw_queue); in create_cq()
180 c4iw_put_cqid(rdev, cq->cqid, uctx); in create_cq()
185 static void insert_recv_cqe(struct t4_wq *wq, struct t4_cq *cq) in insert_recv_cqe() argument
190 wq, cq, cq->sw_cidx, cq->sw_pidx); in insert_recv_cqe()
197 cqe.bits_type_ts = cpu_to_be64(CQE_GENBIT_V((u64)cq->gen)); in insert_recv_cqe()
198 cq->sw_queue[cq->sw_pidx] = cqe; in insert_recv_cqe()
199 t4_swcq_produce(cq); in insert_recv_cqe()
202 int c4iw_flush_rq(struct t4_wq *wq, struct t4_cq *cq, int count) in c4iw_flush_rq() argument
209 wq, cq, wq->rq.in_use, count); in c4iw_flush_rq()
211 insert_recv_cqe(wq, cq); in c4iw_flush_rq()
217 static void insert_sq_cqe(struct t4_wq *wq, struct t4_cq *cq, in insert_sq_cqe() argument
223 wq, cq, cq->sw_cidx, cq->sw_pidx); in insert_sq_cqe()
231 cqe.bits_type_ts = cpu_to_be64(CQE_GENBIT_V((u64)cq->gen)); in insert_sq_cqe()
232 cq->sw_queue[cq->sw_pidx] = cqe; in insert_sq_cqe()
233 t4_swcq_produce(cq); in insert_sq_cqe()
243 struct t4_cq *cq = &chp->cq; in c4iw_flush_sq() local
255 insert_sq_cqe(wq, cq, swsqe); in c4iw_flush_sq()
270 static void flush_completed_wrs(struct t4_wq *wq, struct t4_cq *cq) in flush_completed_wrs() argument
293 __func__, cidx, cq->sw_pidx); in flush_completed_wrs()
295 cq->sw_queue[cq->sw_pidx] = swsqe->cqe; in flush_completed_wrs()
296 t4_swcq_produce(cq); in flush_completed_wrs()
348 PDBG("%s cqid 0x%x\n", __func__, chp->cq.cqid); in c4iw_flush_hw_cq()
349 ret = t4_next_hw_cqe(&chp->cq, &hw_cqe); in c4iw_flush_hw_cq()
406 flush_completed_wrs(&qhp->wq, &chp->cq); in c4iw_flush_hw_cq()
408 swcqe = &chp->cq.sw_queue[chp->cq.sw_pidx]; in c4iw_flush_hw_cq()
411 t4_swcq_produce(&chp->cq); in c4iw_flush_hw_cq()
414 t4_hwcq_consume(&chp->cq); in c4iw_flush_hw_cq()
415 ret = t4_next_hw_cqe(&chp->cq, &hw_cqe); in c4iw_flush_hw_cq()
435 void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count) in c4iw_count_rcqes() argument
442 ptr = cq->sw_cidx; in c4iw_count_rcqes()
443 while (ptr != cq->sw_pidx) { in c4iw_count_rcqes()
444 cqe = &cq->sw_queue[ptr]; in c4iw_count_rcqes()
448 if (++ptr == cq->size) in c4iw_count_rcqes()
451 PDBG("%s cq %p count %d\n", __func__, cq, *count); in c4iw_count_rcqes()
470 static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, struct t4_cqe *cqe, in poll_cq() argument
478 ret = t4_next_cqe(cq, &hw_cqe); in poll_cq()
660 flush_completed_wrs(wq, cq); in poll_cq()
665 __func__, cq, cq->cqid, cq->sw_cidx); in poll_cq()
666 t4_swcq_consume(cq); in poll_cq()
669 __func__, cq, cq->cqid, cq->cidx); in poll_cq()
670 t4_hwcq_consume(cq); in poll_cq()
694 ret = t4_next_cqe(&chp->cq, &rd_cqe); in c4iw_poll_cq_one()
706 ret = poll_cq(wq, &(chp->cq), &cqe, &cqe_flushed, &cookie, &credit); in c4iw_poll_cq_one()
857 remove_handle(chp->rhp, &chp->rhp->cqidr, chp->cq.cqid); in c4iw_destroy_cq()
863 destroy_cq(&chp->rhp->rdev, &chp->cq, in c4iw_destroy_cq()
864 ucontext ? &ucontext->uctx : &chp->cq.rdev->uctx); in c4iw_destroy_cq()
918 memsize = hwentries * sizeof *chp->cq.queue; in c4iw_create_cq()
925 chp->cq.size = hwentries; in c4iw_create_cq()
926 chp->cq.memsize = memsize; in c4iw_create_cq()
927 chp->cq.vector = vector; in c4iw_create_cq()
929 ret = create_cq(&rhp->rdev, &chp->cq, in c4iw_create_cq()
935 chp->cq.size--; /* status page */ in c4iw_create_cq()
941 ret = insert_handle(rhp, &rhp->cqidr, chp, chp->cq.cqid); in c4iw_create_cq()
954 uresp.cqid = chp->cq.cqid; in c4iw_create_cq()
955 uresp.size = chp->cq.size; in c4iw_create_cq()
956 uresp.memsize = chp->cq.memsize; in c4iw_create_cq()
969 mm->addr = virt_to_phys(chp->cq.queue); in c4iw_create_cq()
970 mm->len = chp->cq.memsize; in c4iw_create_cq()
974 mm2->addr = chp->cq.ugts; in c4iw_create_cq()
979 __func__, chp->cq.cqid, chp, chp->cq.size, in c4iw_create_cq()
980 chp->cq.memsize, (unsigned long long) chp->cq.dma_addr); in c4iw_create_cq()
987 remove_handle(rhp, &rhp->cqidr, chp->cq.cqid); in c4iw_create_cq()
989 destroy_cq(&chp->rhp->rdev, &chp->cq, in c4iw_create_cq()
996 int c4iw_resize_cq(struct ib_cq *cq, int cqe, struct ib_udata *udata) in c4iw_resize_cq() argument
1009 ret = t4_arm_cq(&chp->cq, in c4iw_arm_cq()