Lines Matching refs:cq

37 static void 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()
63 kfree(cq->sw_queue); in destroy_cq()
65 cq->memsize, cq->queue, in destroy_cq()
66 dma_unmap_addr(cq, mapping)); in destroy_cq()
67 c4iw_put_cqid(rdev, cq->cqid, uctx); in destroy_cq()
70 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()
107 cq->qp_errp = &((struct t4_status_page *) in create_cq()
108 ((u8 *)cq->queue + (cq->size - 1) * in create_cq()
109 (sizeof(*cq->queue) / 2)))->qp_err; in create_cq()
111 cq->qp_errp = &((struct t4_status_page *) in create_cq()
112 ((u8 *)cq->queue + (cq->size - 1) * in create_cq()
113 sizeof(*cq->queue)))->qp_err; in create_cq()
134 res->u.cq.restype = FW_RI_RES_TYPE_CQ; in create_cq()
135 res->u.cq.op = FW_RI_RES_OP_WRITE; in create_cq()
136 res->u.cq.iqid = cpu_to_be32(cq->cqid); in create_cq()
137 res->u.cq.iqandst_to_iqandstindex = cpu_to_be32( in create_cq()
142 rdev->lldi.ciq_ids[cq->vector])); in create_cq()
143 res->u.cq.iqdroprss_to_iqesize = cpu_to_be16( in create_cq()
151 res->u.cq.iqsize = cpu_to_be16(cq->size); in create_cq()
152 res->u.cq.iqaddr = cpu_to_be64(cq->dma_addr); in create_cq()
159 cq->gen = 1; in create_cq()
160 cq->gts = rdev->lldi.gts_reg; in create_cq()
161 cq->rdev = rdev; in create_cq()
163 cq->bar2_va = c4iw_bar2_addrs(rdev, cq->cqid, CXGB4_BAR2_QTYPE_INGRESS, in create_cq()
164 &cq->bar2_qid, in create_cq()
165 user ? &cq->bar2_pa : NULL); in create_cq()
166 if (user && !cq->bar2_pa) { in create_cq()
168 pci_name(rdev->lldi.pdev), cq->cqid); in create_cq()
174 dma_free_coherent(&rdev->lldi.pdev->dev, cq->memsize, cq->queue, in create_cq()
175 dma_unmap_addr(cq, mapping)); in create_cq()
177 kfree(cq->sw_queue); in create_cq()
179 c4iw_put_cqid(rdev, cq->cqid, uctx); in create_cq()
184 static void insert_recv_cqe(struct t4_wq *wq, struct t4_cq *cq, u32 srqidx) in insert_recv_cqe() argument
189 wq, cq, cq->sw_cidx, cq->sw_pidx); in insert_recv_cqe()
196 cqe.bits_type_ts = cpu_to_be64(CQE_GENBIT_V((u64)cq->gen)); in insert_recv_cqe()
199 cq->sw_queue[cq->sw_pidx] = cqe; in insert_recv_cqe()
200 t4_swcq_produce(cq); in insert_recv_cqe()
203 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, 0); 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
253 insert_sq_cqe(wq, cq, swsqe); in c4iw_flush_sq()
267 static void flush_completed_wrs(struct t4_wq *wq, struct t4_cq *cq) in flush_completed_wrs() argument
287 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 pr_debug("cqid 0x%x\n", chp->cq.cqid); in c4iw_flush_hw_cq()
343 ret = t4_next_hw_cqe(&chp->cq, &hw_cqe); in c4iw_flush_hw_cq()
407 flush_completed_wrs(&qhp->wq, &chp->cq); in c4iw_flush_hw_cq()
409 swcqe = &chp->cq.sw_queue[chp->cq.sw_pidx]; in c4iw_flush_hw_cq()
412 t4_swcq_produce(&chp->cq); in c4iw_flush_hw_cq()
415 t4_hwcq_consume(&chp->cq); in c4iw_flush_hw_cq()
416 ret = t4_next_hw_cqe(&chp->cq, &hw_cqe); in c4iw_flush_hw_cq()
443 void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count) in c4iw_count_rcqes() argument
450 ptr = cq->sw_cidx; in c4iw_count_rcqes()
451 while (ptr != cq->sw_pidx) { in c4iw_count_rcqes()
452 cqe = &cq->sw_queue[ptr]; in c4iw_count_rcqes()
456 if (++ptr == cq->size) in c4iw_count_rcqes()
459 pr_debug("cq %p count %d\n", cq, *count); in c4iw_count_rcqes()
544 static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, struct t4_cqe *cqe, in poll_cq() argument
553 ret = t4_next_cqe(cq, &hw_cqe); in poll_cq()
739 flush_completed_wrs(wq, cq); in poll_cq()
744 cq, cq->cqid, cq->sw_cidx); in poll_cq()
745 t4_swcq_consume(cq); in poll_cq()
748 cq, cq->cqid, cq->cidx); in poll_cq()
749 t4_hwcq_consume(cq); in poll_cq()
764 ret = poll_cq(wq, &(chp->cq), &cqe, &cqe_flushed, &cookie, &credit, in __c4iw_poll_cq_one()
928 ret = t4_next_cqe(&chp->cq, &rd_cqe); in c4iw_poll_cq_one()
984 xa_erase_irq(&chp->rhp->cqs, chp->cq.cqid); in c4iw_destroy_cq()
990 destroy_cq(&chp->rhp->rdev, &chp->cq, in c4iw_destroy_cq()
991 ucontext ? &ucontext->uctx : &chp->cq.rdev->uctx, in c4iw_destroy_cq()
1066 (sizeof(*chp->cq.queue) / 2) : sizeof(*chp->cq.queue)); in c4iw_create_cq()
1074 chp->cq.size = hwentries; in c4iw_create_cq()
1075 chp->cq.memsize = memsize; in c4iw_create_cq()
1076 chp->cq.vector = vector; in c4iw_create_cq()
1078 ret = create_cq(&rhp->rdev, &chp->cq, in c4iw_create_cq()
1085 chp->cq.size--; /* status page */ in c4iw_create_cq()
1091 ret = xa_insert_irq(&rhp->cqs, chp->cq.cqid, chp, GFP_KERNEL); in c4iw_create_cq()
1106 uresp.cqid = chp->cq.cqid; in c4iw_create_cq()
1107 uresp.size = chp->cq.size; in c4iw_create_cq()
1108 uresp.memsize = chp->cq.memsize; in c4iw_create_cq()
1128 mm->addr = virt_to_phys(chp->cq.queue); in c4iw_create_cq()
1129 mm->len = chp->cq.memsize; in c4iw_create_cq()
1133 mm2->addr = chp->cq.bar2_pa; in c4iw_create_cq()
1139 chp->cq.cqid, chp, chp->cq.size, chp->cq.memsize, in c4iw_create_cq()
1140 &chp->cq.dma_addr); in c4iw_create_cq()
1147 xa_erase_irq(&rhp->cqs, chp->cq.cqid); in c4iw_create_cq()
1149 destroy_cq(&chp->rhp->rdev, &chp->cq, in c4iw_create_cq()
1168 t4_arm_cq(&chp->cq, in c4iw_arm_cq()
1171 ret = t4_cq_notempty(&chp->cq); in c4iw_arm_cq()
1186 insert_recv_cqe(&qhp->wq, &rchp->cq, srqidx); in c4iw_flush_srqidx()