35 #include <linux/slab.h>
56 for (;
wr; wr = wr->
next) {
61 if ((
unsigned) wr->
num_sge > srq->
rq.max_sge) {
70 if (next >= srq->
rq.size)
72 if (next == wq->
tail) {
73 spin_unlock_irqrestore(&srq->
rq.lock, flags);
79 wqe = get_rwqe_ptr(&srq->
rq, wq->
head);
82 for (i = 0; i < wr->
num_sge; i++)
87 spin_unlock_irqrestore(&srq->
rq.lock, flags);
115 if (srq_init_attr->
attr.max_wr == 0) {
135 srq->
rq.size = srq_init_attr->
attr.max_wr + 1;
136 srq->
rq.max_sge = srq_init_attr->
attr.max_sge;
137 sz =
sizeof(
struct ib_sge) * srq->
rq.max_sge +
162 err = ib_copy_to_udata(udata, &srq->ip->offset,
163 sizeof(srq->ip->offset));
175 srq->
rq.wq->head = 0;
176 srq->
rq.wq->tail = 0;
177 srq->
limit = srq_init_attr->
attr.srq_limit;
237 srq->rq.max_sge *
sizeof(
struct ib_sge);
250 ret = ib_copy_from_udata(&offset_addr, udata,
251 sizeof(offset_addr));
255 (
void __user *) (
unsigned long) offset_addr;
256 ret = ib_copy_to_udata(udata, &offset,
262 spin_lock_irq(&srq->rq.lock);
269 if (head >= srq->rq.size)
272 if (tail >= srq->rq.size)
276 n += srq->rq.size -
tail;
285 while (tail != head) {
289 wqe = get_rwqe_ptr(&srq->rq, tail);
292 for (i = 0; i < wqe->
num_sge; i++)
296 if (++tail >= srq->rq.size)
303 if (attr_mask & IB_SRQ_LIMIT)
305 spin_unlock_irq(&srq->rq.lock);
321 ret = ib_copy_to_udata(udata, &ip->
offset,
334 spin_lock_irq(&srq->
rq.lock);
339 spin_unlock_irq(&srq->
rq.lock);
344 spin_unlock_irq(&srq->
rq.lock);