Lines Matching refs:cq

67 	struct pvrdma_cq *cq = to_vcq(ibcq);  in pvrdma_req_notify_cq()  local
68 u32 val = cq->cq_handle; in pvrdma_req_notify_cq()
75 spin_lock_irqsave(&cq->cq_lock, flags); in pvrdma_req_notify_cq()
82 has_data = pvrdma_idx_ring_has_data(&cq->ring_state->rx, in pvrdma_req_notify_cq()
83 cq->ibcq.cqe, &head); in pvrdma_req_notify_cq()
88 spin_unlock_irqrestore(&cq->cq_lock, flags); in pvrdma_req_notify_cq()
107 struct pvrdma_cq *cq = to_vcq(ibcq); in pvrdma_create_cq() local
132 cq->ibcq.cqe = entries; in pvrdma_create_cq()
133 cq->is_kernel = !udata; in pvrdma_create_cq()
135 if (!cq->is_kernel) { in pvrdma_create_cq()
141 cq->umem = ib_umem_get(ibdev, ucmd.buf_addr, ucmd.buf_size, in pvrdma_create_cq()
143 if (IS_ERR(cq->umem)) { in pvrdma_create_cq()
144 ret = PTR_ERR(cq->umem); in pvrdma_create_cq()
148 npages = ib_umem_num_dma_blocks(cq->umem, PAGE_SIZE); in pvrdma_create_cq()
155 cq->offset = PAGE_SIZE; in pvrdma_create_cq()
165 ret = pvrdma_page_dir_init(dev, &cq->pdir, npages, cq->is_kernel); in pvrdma_create_cq()
173 if (cq->is_kernel) in pvrdma_create_cq()
174 cq->ring_state = cq->pdir.pages[0]; in pvrdma_create_cq()
176 pvrdma_page_dir_insert_umem(&cq->pdir, cq->umem, 0); in pvrdma_create_cq()
178 refcount_set(&cq->refcnt, 1); in pvrdma_create_cq()
179 init_completion(&cq->free); in pvrdma_create_cq()
180 spin_lock_init(&cq->cq_lock); in pvrdma_create_cq()
187 cmd->pdir_dma = cq->pdir.dir_dma; in pvrdma_create_cq()
195 cq->ibcq.cqe = resp->cqe; in pvrdma_create_cq()
196 cq->cq_handle = resp->cq_handle; in pvrdma_create_cq()
199 dev->cq_tbl[cq->cq_handle % dev->dsr->caps.max_cq] = cq; in pvrdma_create_cq()
202 if (!cq->is_kernel) { in pvrdma_create_cq()
203 cq->uar = &context->uar; in pvrdma_create_cq()
209 pvrdma_destroy_cq(&cq->ibcq, udata); in pvrdma_create_cq()
217 pvrdma_page_dir_cleanup(dev, &cq->pdir); in pvrdma_create_cq()
219 ib_umem_release(cq->umem); in pvrdma_create_cq()
225 static void pvrdma_free_cq(struct pvrdma_dev *dev, struct pvrdma_cq *cq) in pvrdma_free_cq() argument
227 if (refcount_dec_and_test(&cq->refcnt)) in pvrdma_free_cq()
228 complete(&cq->free); in pvrdma_free_cq()
229 wait_for_completion(&cq->free); in pvrdma_free_cq()
231 ib_umem_release(cq->umem); in pvrdma_free_cq()
233 pvrdma_page_dir_cleanup(dev, &cq->pdir); in pvrdma_free_cq()
241 int pvrdma_destroy_cq(struct ib_cq *cq, struct ib_udata *udata) in pvrdma_destroy_cq() argument
243 struct pvrdma_cq *vcq = to_vcq(cq); in pvrdma_destroy_cq()
246 struct pvrdma_dev *dev = to_vdev(cq->device); in pvrdma_destroy_cq()
270 static inline struct pvrdma_cqe *get_cqe(struct pvrdma_cq *cq, int i) in get_cqe() argument
273 &cq->pdir, in get_cqe()
274 cq->offset + in get_cqe()
278 void _pvrdma_flush_cqe(struct pvrdma_qp *qp, struct pvrdma_cq *cq) in _pvrdma_flush_cqe() argument
283 if (!cq->is_kernel) in _pvrdma_flush_cqe()
287 has_data = pvrdma_idx_ring_has_data(&cq->ring_state->rx, in _pvrdma_flush_cqe()
288 cq->ibcq.cqe, &head); in _pvrdma_flush_cqe()
292 int tail = pvrdma_idx(&cq->ring_state->rx.prod_tail, in _pvrdma_flush_cqe()
293 cq->ibcq.cqe); in _pvrdma_flush_cqe()
298 (cq->ibcq.cqe - head + tail); in _pvrdma_flush_cqe()
302 curr = cq->ibcq.cqe - 1; in _pvrdma_flush_cqe()
304 tail = cq->ibcq.cqe - 1; in _pvrdma_flush_cqe()
305 curr_cqe = get_cqe(cq, curr); in _pvrdma_flush_cqe()
308 cqe = get_cqe(cq, tail); in _pvrdma_flush_cqe()
314 &cq->ring_state->rx.cons_head, in _pvrdma_flush_cqe()
315 cq->ibcq.cqe); in _pvrdma_flush_cqe()
322 static int pvrdma_poll_one(struct pvrdma_cq *cq, struct pvrdma_qp **cur_qp, in pvrdma_poll_one() argument
325 struct pvrdma_dev *dev = to_vdev(cq->ibcq.device); in pvrdma_poll_one()
332 has_data = pvrdma_idx_ring_has_data(&cq->ring_state->rx, in pvrdma_poll_one()
333 cq->ibcq.cqe, &head); in pvrdma_poll_one()
338 pvrdma_write_uar_cq(dev, cq->cq_handle | PVRDMA_UAR_CQ_POLL); in pvrdma_poll_one()
347 cqe = get_cqe(cq, head); in pvrdma_poll_one()
373 pvrdma_idx_ring_inc(&cq->ring_state->rx.cons_head, cq->ibcq.cqe); in pvrdma_poll_one()
388 struct pvrdma_cq *cq = to_vcq(ibcq); in pvrdma_poll_cq() local
396 spin_lock_irqsave(&cq->cq_lock, flags); in pvrdma_poll_cq()
398 if (pvrdma_poll_one(cq, &cur_qp, wc + npolled)) in pvrdma_poll_cq()
402 spin_unlock_irqrestore(&cq->cq_lock, flags); in pvrdma_poll_cq()