Lines Matching refs:srq
42 static void *get_wqe(struct mlx4_ib_srq *srq, int n) in get_wqe() argument
44 return mlx4_buf_offset(&srq->buf, n << srq->msrq.wqe_shift); in get_wqe()
47 static void mlx4_ib_srq_event(struct mlx4_srq *srq, enum mlx4_event type) in mlx4_ib_srq_event() argument
50 struct ib_srq *ibsrq = &to_mibsrq(srq)->ibsrq; in mlx4_ib_srq_event()
54 event.element.srq = ibsrq; in mlx4_ib_srq_event()
64 "on SRQ %06x\n", type, srq->srqn); in mlx4_ib_srq_event()
79 struct mlx4_ib_srq *srq = to_msrq(ib_srq); in mlx4_ib_create_srq() local
98 mutex_init(&srq->mutex); in mlx4_ib_create_srq()
99 spin_lock_init(&srq->lock); in mlx4_ib_create_srq()
100 srq->msrq.max = roundup_pow_of_two(init_attr->attr.max_wr + 1); in mlx4_ib_create_srq()
101 srq->msrq.max_gs = init_attr->attr.max_sge; in mlx4_ib_create_srq()
105 srq->msrq.max_gs * in mlx4_ib_create_srq()
107 srq->msrq.wqe_shift = ilog2(desc_size); in mlx4_ib_create_srq()
109 buf_size = srq->msrq.max * desc_size; in mlx4_ib_create_srq()
117 srq->umem = in mlx4_ib_create_srq()
119 if (IS_ERR(srq->umem)) in mlx4_ib_create_srq()
120 return PTR_ERR(srq->umem); in mlx4_ib_create_srq()
123 dev->dev, ib_umem_num_dma_blocks(srq->umem, PAGE_SIZE), in mlx4_ib_create_srq()
124 PAGE_SHIFT, &srq->mtt); in mlx4_ib_create_srq()
128 err = mlx4_ib_umem_write_mtt(dev, &srq->mtt, srq->umem); in mlx4_ib_create_srq()
132 err = mlx4_ib_db_map_user(udata, ucmd.db_addr, &srq->db); in mlx4_ib_create_srq()
136 err = mlx4_db_alloc(dev->dev, &srq->db, 0); in mlx4_ib_create_srq()
140 *srq->db.db = 0; in mlx4_ib_create_srq()
143 &srq->buf)) { in mlx4_ib_create_srq()
148 srq->head = 0; in mlx4_ib_create_srq()
149 srq->tail = srq->msrq.max - 1; in mlx4_ib_create_srq()
150 srq->wqe_ctr = 0; in mlx4_ib_create_srq()
152 for (i = 0; i < srq->msrq.max; ++i) { in mlx4_ib_create_srq()
153 next = get_wqe(srq, i); in mlx4_ib_create_srq()
155 cpu_to_be16((i + 1) & (srq->msrq.max - 1)); in mlx4_ib_create_srq()
163 err = mlx4_mtt_init(dev->dev, srq->buf.npages, srq->buf.page_shift, in mlx4_ib_create_srq()
164 &srq->mtt); in mlx4_ib_create_srq()
168 err = mlx4_buf_write_mtt(dev->dev, &srq->mtt, &srq->buf); in mlx4_ib_create_srq()
172 srq->wrid = kvmalloc_array(srq->msrq.max, in mlx4_ib_create_srq()
174 if (!srq->wrid) { in mlx4_ib_create_srq()
186 &srq->mtt, srq->db.dma, &srq->msrq); in mlx4_ib_create_srq()
190 srq->msrq.event = mlx4_ib_srq_event; in mlx4_ib_create_srq()
191 srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn; in mlx4_ib_create_srq()
194 if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof (__u32))) { in mlx4_ib_create_srq()
199 init_attr->attr.max_wr = srq->msrq.max - 1; in mlx4_ib_create_srq()
205 mlx4_ib_db_unmap_user(ucontext, &srq->db); in mlx4_ib_create_srq()
207 kvfree(srq->wrid); in mlx4_ib_create_srq()
210 mlx4_mtt_cleanup(dev->dev, &srq->mtt); in mlx4_ib_create_srq()
213 if (!srq->umem) in mlx4_ib_create_srq()
214 mlx4_buf_free(dev->dev, buf_size, &srq->buf); in mlx4_ib_create_srq()
215 ib_umem_release(srq->umem); in mlx4_ib_create_srq()
219 mlx4_db_free(dev->dev, &srq->db); in mlx4_ib_create_srq()
228 struct mlx4_ib_srq *srq = to_msrq(ibsrq); in mlx4_ib_modify_srq() local
236 if (attr->srq_limit >= srq->msrq.max) in mlx4_ib_modify_srq()
239 mutex_lock(&srq->mutex); in mlx4_ib_modify_srq()
240 ret = mlx4_srq_arm(dev->dev, &srq->msrq, attr->srq_limit); in mlx4_ib_modify_srq()
241 mutex_unlock(&srq->mutex); in mlx4_ib_modify_srq()
253 struct mlx4_ib_srq *srq = to_msrq(ibsrq); in mlx4_ib_query_srq() local
257 ret = mlx4_srq_query(dev->dev, &srq->msrq, &limit_watermark); in mlx4_ib_query_srq()
262 srq_attr->max_wr = srq->msrq.max - 1; in mlx4_ib_query_srq()
263 srq_attr->max_sge = srq->msrq.max_gs; in mlx4_ib_query_srq()
268 int mlx4_ib_destroy_srq(struct ib_srq *srq, struct ib_udata *udata) in mlx4_ib_destroy_srq() argument
270 struct mlx4_ib_dev *dev = to_mdev(srq->device); in mlx4_ib_destroy_srq()
271 struct mlx4_ib_srq *msrq = to_msrq(srq); in mlx4_ib_destroy_srq()
293 void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index) in mlx4_ib_free_srq_wqe() argument
298 spin_lock(&srq->lock); in mlx4_ib_free_srq_wqe()
300 next = get_wqe(srq, srq->tail); in mlx4_ib_free_srq_wqe()
302 srq->tail = wqe_index; in mlx4_ib_free_srq_wqe()
304 spin_unlock(&srq->lock); in mlx4_ib_free_srq_wqe()
310 struct mlx4_ib_srq *srq = to_msrq(ibsrq); in mlx4_ib_post_srq_recv() local
319 spin_lock_irqsave(&srq->lock, flags); in mlx4_ib_post_srq_recv()
327 if (unlikely(wr->num_sge > srq->msrq.max_gs)) { in mlx4_ib_post_srq_recv()
333 if (unlikely(srq->head == srq->tail)) { in mlx4_ib_post_srq_recv()
339 srq->wrid[srq->head] = wr->wr_id; in mlx4_ib_post_srq_recv()
341 next = get_wqe(srq, srq->head); in mlx4_ib_post_srq_recv()
342 srq->head = be16_to_cpu(next->next_wqe_index); in mlx4_ib_post_srq_recv()
351 if (i < srq->msrq.max_gs) { in mlx4_ib_post_srq_recv()
359 srq->wqe_ctr += nreq; in mlx4_ib_post_srq_recv()
367 *srq->db.db = cpu_to_be32(srq->wqe_ctr); in mlx4_ib_post_srq_recv()
371 spin_unlock_irqrestore(&srq->lock, flags); in mlx4_ib_post_srq_recv()