Lines Matching refs:cq
35 static int destroy_cq(struct c4iw_rdev *rdev, struct t4_cq *cq, in destroy_cq() argument
56 res->u.cq.restype = FW_RI_RES_TYPE_CQ; in destroy_cq()
57 res->u.cq.op = FW_RI_RES_OP_RESET; in destroy_cq()
58 res->u.cq.iqid = cpu_to_be32(cq->cqid); in destroy_cq()
66 kfree(cq->sw_queue); in destroy_cq()
68 cq->memsize, cq->queue, in destroy_cq()
69 dma_unmap_addr(cq, mapping)); in destroy_cq()
70 c4iw_put_cqid(rdev, cq->cqid, uctx); in destroy_cq()
74 static int create_cq(struct c4iw_rdev *rdev, struct t4_cq *cq, in create_cq() argument
85 cq->cqid = c4iw_get_cqid(rdev, uctx); in create_cq()
86 if (!cq->cqid) { in create_cq()
92 cq->sw_queue = kzalloc(cq->memsize, GFP_KERNEL); in create_cq()
93 if (!cq->sw_queue) { in create_cq()
98 cq->queue = dma_alloc_coherent(&rdev->lldi.pdev->dev, cq->memsize, in create_cq()
99 &cq->dma_addr, GFP_KERNEL); in create_cq()
100 if (!cq->queue) { in create_cq()
104 dma_unmap_addr_set(cq, mapping, cq->dma_addr); in create_cq()
105 memset(cq->queue, 0, cq->memsize); in create_cq()
126 res->u.cq.restype = FW_RI_RES_TYPE_CQ; in create_cq()
127 res->u.cq.op = FW_RI_RES_OP_WRITE; in create_cq()
128 res->u.cq.iqid = cpu_to_be32(cq->cqid); in create_cq()
129 res->u.cq.iqandst_to_iqandstindex = cpu_to_be32( in create_cq()
134 rdev->lldi.ciq_ids[cq->vector])); in create_cq()
135 res->u.cq.iqdroprss_to_iqesize = cpu_to_be16( in create_cq()
141 res->u.cq.iqsize = cpu_to_be16(cq->size); in create_cq()
142 res->u.cq.iqaddr = cpu_to_be64(cq->dma_addr); in create_cq()
154 cq->gen = 1; in create_cq()
155 cq->gts = rdev->lldi.gts_reg; in create_cq()
156 cq->rdev = rdev; in create_cq()
158 cq->bar2_va = c4iw_bar2_addrs(rdev, cq->cqid, T4_BAR2_QTYPE_INGRESS, in create_cq()
159 &cq->bar2_qid, in create_cq()
160 user ? &cq->bar2_pa : NULL); in create_cq()
161 if (user && !cq->bar2_pa) { in create_cq()
163 pci_name(rdev->lldi.pdev), cq->cqid); in create_cq()
169 dma_free_coherent(&rdev->lldi.pdev->dev, cq->memsize, cq->queue, in create_cq()
170 dma_unmap_addr(cq, mapping)); in create_cq()
172 kfree(cq->sw_queue); in create_cq()
174 c4iw_put_cqid(rdev, cq->cqid, uctx); in create_cq()
179 static void insert_recv_cqe(struct t4_wq *wq, struct t4_cq *cq) in insert_recv_cqe() argument
184 wq, cq, cq->sw_cidx, cq->sw_pidx); in insert_recv_cqe()
191 cqe.bits_type_ts = cpu_to_be64(CQE_GENBIT_V((u64)cq->gen)); in insert_recv_cqe()
192 cq->sw_queue[cq->sw_pidx] = cqe; in insert_recv_cqe()
193 t4_swcq_produce(cq); in insert_recv_cqe()
196 int c4iw_flush_rq(struct t4_wq *wq, struct t4_cq *cq, int count) in c4iw_flush_rq() argument
203 wq, cq, wq->rq.in_use, count); in c4iw_flush_rq()
205 insert_recv_cqe(wq, cq); in c4iw_flush_rq()
211 static void insert_sq_cqe(struct t4_wq *wq, struct t4_cq *cq, in insert_sq_cqe() argument
217 wq, cq, cq->sw_cidx, cq->sw_pidx); in insert_sq_cqe()
225 cqe.bits_type_ts = cpu_to_be64(CQE_GENBIT_V((u64)cq->gen)); in insert_sq_cqe()
226 cq->sw_queue[cq->sw_pidx] = cqe; in insert_sq_cqe()
227 t4_swcq_produce(cq); in insert_sq_cqe()
237 struct t4_cq *cq = &chp->cq; in c4iw_flush_sq() local
249 insert_sq_cqe(wq, cq, swsqe); in c4iw_flush_sq()
264 static void flush_completed_wrs(struct t4_wq *wq, struct t4_cq *cq) in flush_completed_wrs() argument
287 __func__, cidx, cq->sw_pidx); in flush_completed_wrs()
289 cq->sw_queue[cq->sw_pidx] = swsqe->cqe; in flush_completed_wrs()
290 t4_swcq_produce(cq); in flush_completed_wrs()
342 PDBG("%s cqid 0x%x\n", __func__, chp->cq.cqid); in c4iw_flush_hw_cq()
343 ret = t4_next_hw_cqe(&chp->cq, &hw_cqe); in c4iw_flush_hw_cq()
400 flush_completed_wrs(&qhp->wq, &chp->cq); in c4iw_flush_hw_cq()
402 swcqe = &chp->cq.sw_queue[chp->cq.sw_pidx]; in c4iw_flush_hw_cq()
405 t4_swcq_produce(&chp->cq); in c4iw_flush_hw_cq()
408 t4_hwcq_consume(&chp->cq); in c4iw_flush_hw_cq()
409 ret = t4_next_hw_cqe(&chp->cq, &hw_cqe); in c4iw_flush_hw_cq()
429 void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count) in c4iw_count_rcqes() argument
436 ptr = cq->sw_cidx; in c4iw_count_rcqes()
437 while (ptr != cq->sw_pidx) { in c4iw_count_rcqes()
438 cqe = &cq->sw_queue[ptr]; in c4iw_count_rcqes()
442 if (++ptr == cq->size) in c4iw_count_rcqes()
445 PDBG("%s cq %p count %d\n", __func__, cq, *count); in c4iw_count_rcqes()
464 static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, struct t4_cqe *cqe, in poll_cq() argument
472 ret = t4_next_cqe(cq, &hw_cqe); in poll_cq()
654 flush_completed_wrs(wq, cq); in poll_cq()
659 __func__, cq, cq->cqid, cq->sw_cidx); in poll_cq()
660 t4_swcq_consume(cq); in poll_cq()
663 __func__, cq, cq->cqid, cq->cidx); in poll_cq()
664 t4_hwcq_consume(cq); in poll_cq()
688 ret = t4_next_cqe(&chp->cq, &rd_cqe); in c4iw_poll_cq_one()
700 ret = poll_cq(wq, &(chp->cq), &cqe, &cqe_flushed, &cookie, &credit); in c4iw_poll_cq_one()
861 remove_handle(chp->rhp, &chp->rhp->cqidr, chp->cq.cqid); in c4iw_destroy_cq()
867 destroy_cq(&chp->rhp->rdev, &chp->cq, in c4iw_destroy_cq()
868 ucontext ? &ucontext->uctx : &chp->cq.rdev->uctx, in c4iw_destroy_cq()
936 memsize = hwentries * sizeof *chp->cq.queue; in c4iw_create_cq()
943 chp->cq.size = hwentries; in c4iw_create_cq()
944 chp->cq.memsize = memsize; in c4iw_create_cq()
945 chp->cq.vector = vector; in c4iw_create_cq()
947 ret = create_cq(&rhp->rdev, &chp->cq, in c4iw_create_cq()
953 chp->cq.size--; /* status page */ in c4iw_create_cq()
959 ret = insert_handle(rhp, &rhp->cqidr, chp, chp->cq.cqid); in c4iw_create_cq()
972 uresp.cqid = chp->cq.cqid; in c4iw_create_cq()
973 uresp.size = chp->cq.size; in c4iw_create_cq()
974 uresp.memsize = chp->cq.memsize; in c4iw_create_cq()
987 mm->addr = virt_to_phys(chp->cq.queue); in c4iw_create_cq()
988 mm->len = chp->cq.memsize; in c4iw_create_cq()
992 mm2->addr = chp->cq.bar2_pa; in c4iw_create_cq()
997 __func__, chp->cq.cqid, chp, chp->cq.size, in c4iw_create_cq()
998 chp->cq.memsize, (unsigned long long) chp->cq.dma_addr); in c4iw_create_cq()
1005 remove_handle(rhp, &rhp->cqidr, chp->cq.cqid); in c4iw_create_cq()
1007 destroy_cq(&chp->rhp->rdev, &chp->cq, in c4iw_create_cq()
1017 int c4iw_resize_cq(struct ib_cq *cq, int cqe, struct ib_udata *udata) in c4iw_resize_cq() argument
1030 t4_arm_cq(&chp->cq, in c4iw_arm_cq()
1033 ret = t4_cq_notempty(&chp->cq); in c4iw_arm_cq()