35 #include <linux/slab.h>
51 struct qib_srq *srq = to_isrq(ibsrq);
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_sge == 0 ||
117 srq_init_attr->
attr.max_wr == 0 ||
132 srq->
rq.size = srq_init_attr->
attr.max_wr + 1;
133 srq->
rq.max_sge = srq_init_attr->
attr.max_sge;
134 sz =
sizeof(
struct ib_sge) * srq->
rq.max_sge +
148 u32 s =
sizeof(
struct qib_rwq) + srq->rq.size * sz;
158 err = ib_copy_to_udata(udata, &srq->ip->offset,
159 sizeof(srq->ip->offset));
171 srq->
rq.wq->head = 0;
172 srq->
rq.wq->tail = 0;
173 srq->
limit = srq_init_attr->
attr.srq_limit;
215 struct qib_srq *srq = to_isrq(ibsrq);
233 srq->rq.max_sge *
sizeof(
struct ib_sge);
246 ret = ib_copy_from_udata(&offset_addr, udata,
247 sizeof(offset_addr));
251 (
void __user *) (
unsigned long) offset_addr;
252 ret = ib_copy_to_udata(udata, &offset,
258 spin_lock_irq(&srq->rq.lock);
266 if (head >= srq->rq.size || tail >= srq->rq.size) {
272 n += srq->rq.size -
tail;
281 while (tail != head) {
285 wqe = get_rwqe_ptr(&srq->rq, tail);
288 for (i = 0; i < wqe->
num_sge; i++)
291 p = (
struct qib_rwqe *)((
char *) p + sz);
292 if (++tail >= srq->rq.size)
299 if (attr_mask & IB_SRQ_LIMIT)
301 spin_unlock_irq(&srq->rq.lock);
317 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);
353 struct qib_srq *srq = to_isrq(ibsrq);
367 struct qib_srq *srq = to_isrq(ibsrq);