2 * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
3 * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 #include <linux/skbuff.h>
35 #include <linux/delay.h>
36 #include <linux/sched.h>
40 #include "rxe_queue.h"
43 char *rxe_qp_state_name
[] = {
44 [QP_STATE_RESET
] = "RESET",
45 [QP_STATE_INIT
] = "INIT",
46 [QP_STATE_READY
] = "READY",
47 [QP_STATE_DRAIN
] = "DRAIN",
48 [QP_STATE_DRAINED
] = "DRAINED",
49 [QP_STATE_ERROR
] = "ERROR",
52 static int rxe_qp_chk_cap(struct rxe_dev
*rxe
, struct ib_qp_cap
*cap
,
55 if (cap
->max_send_wr
> rxe
->attr
.max_qp_wr
) {
56 pr_warn("invalid send wr = %d > %d\n",
57 cap
->max_send_wr
, rxe
->attr
.max_qp_wr
);
61 if (cap
->max_send_sge
> rxe
->attr
.max_sge
) {
62 pr_warn("invalid send sge = %d > %d\n",
63 cap
->max_send_sge
, rxe
->attr
.max_sge
);
68 if (cap
->max_recv_wr
> rxe
->attr
.max_qp_wr
) {
69 pr_warn("invalid recv wr = %d > %d\n",
70 cap
->max_recv_wr
, rxe
->attr
.max_qp_wr
);
74 if (cap
->max_recv_sge
> rxe
->attr
.max_sge
) {
75 pr_warn("invalid recv sge = %d > %d\n",
76 cap
->max_recv_sge
, rxe
->attr
.max_sge
);
81 if (cap
->max_inline_data
> rxe
->max_inline_data
) {
82 pr_warn("invalid max inline data = %d > %d\n",
83 cap
->max_inline_data
, rxe
->max_inline_data
);
93 int rxe_qp_chk_init(struct rxe_dev
*rxe
, struct ib_qp_init_attr
*init
)
95 struct ib_qp_cap
*cap
= &init
->cap
;
96 struct rxe_port
*port
;
97 int port_num
= init
->port_num
;
99 if (!init
->recv_cq
|| !init
->send_cq
) {
100 pr_warn("missing cq\n");
104 if (rxe_qp_chk_cap(rxe
, cap
, !!init
->srq
))
107 if (init
->qp_type
== IB_QPT_SMI
|| init
->qp_type
== IB_QPT_GSI
) {
109 pr_warn("invalid port = %d\n", port_num
);
115 if (init
->qp_type
== IB_QPT_SMI
&& port
->qp_smi_index
) {
116 pr_warn("SMI QP exists for port %d\n", port_num
);
120 if (init
->qp_type
== IB_QPT_GSI
&& port
->qp_gsi_index
) {
121 pr_warn("GSI QP exists for port %d\n", port_num
);
132 static int alloc_rd_atomic_resources(struct rxe_qp
*qp
, unsigned int n
)
134 qp
->resp
.res_head
= 0;
135 qp
->resp
.res_tail
= 0;
136 qp
->resp
.resources
= kcalloc(n
, sizeof(struct resp_res
), GFP_KERNEL
);
138 if (!qp
->resp
.resources
)
144 static void free_rd_atomic_resources(struct rxe_qp
*qp
)
146 if (qp
->resp
.resources
) {
149 for (i
= 0; i
< qp
->attr
.max_dest_rd_atomic
; i
++) {
150 struct resp_res
*res
= &qp
->resp
.resources
[i
];
152 free_rd_atomic_resource(qp
, res
);
154 kfree(qp
->resp
.resources
);
155 qp
->resp
.resources
= NULL
;
159 void free_rd_atomic_resource(struct rxe_qp
*qp
, struct resp_res
*res
)
161 if (res
->type
== RXE_ATOMIC_MASK
) {
163 kfree_skb(res
->atomic
.skb
);
164 } else if (res
->type
== RXE_READ_MASK
) {
166 rxe_drop_ref(res
->read
.mr
);
171 static void cleanup_rd_atomic_resources(struct rxe_qp
*qp
)
174 struct resp_res
*res
;
176 if (qp
->resp
.resources
) {
177 for (i
= 0; i
< qp
->attr
.max_dest_rd_atomic
; i
++) {
178 res
= &qp
->resp
.resources
[i
];
179 free_rd_atomic_resource(qp
, res
);
184 static void rxe_qp_init_misc(struct rxe_dev
*rxe
, struct rxe_qp
*qp
,
185 struct ib_qp_init_attr
*init
)
187 struct rxe_port
*port
;
190 qp
->sq_sig_type
= init
->sq_sig_type
;
191 qp
->attr
.path_mtu
= 1;
192 qp
->mtu
= ib_mtu_enum_to_int(qp
->attr
.path_mtu
);
194 qpn
= qp
->pelem
.index
;
197 switch (init
->qp_type
) {
200 port
->qp_smi_index
= qpn
;
201 qp
->attr
.port_num
= init
->port_num
;
206 port
->qp_gsi_index
= qpn
;
207 qp
->attr
.port_num
= init
->port_num
;
211 qp
->ibqp
.qp_num
= qpn
;
215 INIT_LIST_HEAD(&qp
->grp_list
);
217 skb_queue_head_init(&qp
->send_pkts
);
219 spin_lock_init(&qp
->grp_lock
);
220 spin_lock_init(&qp
->state_lock
);
222 atomic_set(&qp
->ssn
, 0);
223 atomic_set(&qp
->skb_out
, 0);
226 static int rxe_qp_init_req(struct rxe_dev
*rxe
, struct rxe_qp
*qp
,
227 struct ib_qp_init_attr
*init
,
228 struct ib_ucontext
*context
, struct ib_udata
*udata
)
233 err
= sock_create_kern(&init_net
, AF_INET
, SOCK_DGRAM
, 0, &qp
->sk
);
236 qp
->sk
->sk
->sk_user_data
= qp
;
238 qp
->sq
.max_wr
= init
->cap
.max_send_wr
;
239 qp
->sq
.max_sge
= init
->cap
.max_send_sge
;
240 qp
->sq
.max_inline
= init
->cap
.max_inline_data
;
242 wqe_size
= max_t(int, sizeof(struct rxe_send_wqe
) +
243 qp
->sq
.max_sge
* sizeof(struct ib_sge
),
244 sizeof(struct rxe_send_wqe
) +
247 qp
->sq
.queue
= rxe_queue_init(rxe
,
253 err
= do_mmap_info(rxe
, udata
, true,
254 context
, qp
->sq
.queue
->buf
,
255 qp
->sq
.queue
->buf_size
, &qp
->sq
.queue
->ip
);
258 kvfree(qp
->sq
.queue
->buf
);
263 qp
->req
.wqe_index
= producer_index(qp
->sq
.queue
);
264 qp
->req
.state
= QP_STATE_RESET
;
266 qp
->comp
.opcode
= -1;
268 spin_lock_init(&qp
->sq
.sq_lock
);
269 skb_queue_head_init(&qp
->req_pkts
);
271 rxe_init_task(rxe
, &qp
->req
.task
, qp
,
272 rxe_requester
, "req");
273 rxe_init_task(rxe
, &qp
->comp
.task
, qp
,
274 rxe_completer
, "comp");
276 setup_timer(&qp
->rnr_nak_timer
, rnr_nak_timer
, (unsigned long)qp
);
277 setup_timer(&qp
->retrans_timer
, retransmit_timer
, (unsigned long)qp
);
278 qp
->qp_timeout_jiffies
= 0; /* Can't be set for UD/UC in modify_qp */
283 static int rxe_qp_init_resp(struct rxe_dev
*rxe
, struct rxe_qp
*qp
,
284 struct ib_qp_init_attr
*init
,
285 struct ib_ucontext
*context
, struct ib_udata
*udata
)
291 qp
->rq
.max_wr
= init
->cap
.max_recv_wr
;
292 qp
->rq
.max_sge
= init
->cap
.max_recv_sge
;
294 wqe_size
= rcv_wqe_size(qp
->rq
.max_sge
);
296 pr_debug("qp#%d max_wr = %d, max_sge = %d, wqe_size = %d\n",
297 qp_num(qp
), qp
->rq
.max_wr
, qp
->rq
.max_sge
, wqe_size
);
299 qp
->rq
.queue
= rxe_queue_init(rxe
,
305 err
= do_mmap_info(rxe
, udata
, false, context
,
307 qp
->rq
.queue
->buf_size
,
310 kvfree(qp
->rq
.queue
->buf
);
316 spin_lock_init(&qp
->rq
.producer_lock
);
317 spin_lock_init(&qp
->rq
.consumer_lock
);
319 skb_queue_head_init(&qp
->resp_pkts
);
321 rxe_init_task(rxe
, &qp
->resp
.task
, qp
,
322 rxe_responder
, "resp");
324 qp
->resp
.opcode
= OPCODE_NONE
;
326 qp
->resp
.state
= QP_STATE_RESET
;
331 /* called by the create qp verb */
332 int rxe_qp_from_init(struct rxe_dev
*rxe
, struct rxe_qp
*qp
, struct rxe_pd
*pd
,
333 struct ib_qp_init_attr
*init
, struct ib_udata
*udata
,
337 struct rxe_cq
*rcq
= to_rcq(init
->recv_cq
);
338 struct rxe_cq
*scq
= to_rcq(init
->send_cq
);
339 struct rxe_srq
*srq
= init
->srq
? to_rsrq(init
->srq
) : NULL
;
340 struct ib_ucontext
*context
= udata
? ibpd
->uobject
->context
: NULL
;
353 rxe_qp_init_misc(rxe
, qp
, init
);
355 err
= rxe_qp_init_req(rxe
, qp
, init
, context
, udata
);
359 err
= rxe_qp_init_resp(rxe
, qp
, init
, context
, udata
);
363 qp
->attr
.qp_state
= IB_QPS_RESET
;
369 rxe_queue_cleanup(qp
->sq
.queue
);
380 /* called by the query qp verb */
381 int rxe_qp_to_init(struct rxe_qp
*qp
, struct ib_qp_init_attr
*init
)
383 init
->event_handler
= qp
->ibqp
.event_handler
;
384 init
->qp_context
= qp
->ibqp
.qp_context
;
385 init
->send_cq
= qp
->ibqp
.send_cq
;
386 init
->recv_cq
= qp
->ibqp
.recv_cq
;
387 init
->srq
= qp
->ibqp
.srq
;
389 init
->cap
.max_send_wr
= qp
->sq
.max_wr
;
390 init
->cap
.max_send_sge
= qp
->sq
.max_sge
;
391 init
->cap
.max_inline_data
= qp
->sq
.max_inline
;
394 init
->cap
.max_recv_wr
= qp
->rq
.max_wr
;
395 init
->cap
.max_recv_sge
= qp
->rq
.max_sge
;
398 init
->sq_sig_type
= qp
->sq_sig_type
;
400 init
->qp_type
= qp
->ibqp
.qp_type
;
406 /* called by the modify qp verb, this routine checks all the parameters before
409 int rxe_qp_chk_attr(struct rxe_dev
*rxe
, struct rxe_qp
*qp
,
410 struct ib_qp_attr
*attr
, int mask
)
412 enum ib_qp_state cur_state
= (mask
& IB_QP_CUR_STATE
) ?
413 attr
->cur_qp_state
: qp
->attr
.qp_state
;
414 enum ib_qp_state new_state
= (mask
& IB_QP_STATE
) ?
415 attr
->qp_state
: cur_state
;
417 if (!ib_modify_qp_is_ok(cur_state
, new_state
, qp_type(qp
), mask
,
418 IB_LINK_LAYER_ETHERNET
)) {
419 pr_warn("invalid mask or state for qp\n");
423 if (mask
& IB_QP_STATE
) {
424 if (cur_state
== IB_QPS_SQD
) {
425 if (qp
->req
.state
== QP_STATE_DRAIN
&&
426 new_state
!= IB_QPS_ERR
)
431 if (mask
& IB_QP_PORT
) {
432 if (attr
->port_num
!= 1) {
433 pr_warn("invalid port %d\n", attr
->port_num
);
438 if (mask
& IB_QP_CAP
&& rxe_qp_chk_cap(rxe
, &attr
->cap
, !!qp
->srq
))
441 if (mask
& IB_QP_AV
&& rxe_av_chk_attr(rxe
, &attr
->ah_attr
))
444 if (mask
& IB_QP_ALT_PATH
) {
445 if (rxe_av_chk_attr(rxe
, &attr
->alt_ah_attr
))
447 if (attr
->alt_port_num
!= 1) {
448 pr_warn("invalid alt port %d\n", attr
->alt_port_num
);
451 if (attr
->alt_timeout
> 31) {
452 pr_warn("invalid QP alt timeout %d > 31\n",
458 if (mask
& IB_QP_PATH_MTU
) {
459 struct rxe_port
*port
= &rxe
->port
;
461 enum ib_mtu max_mtu
= port
->attr
.max_mtu
;
462 enum ib_mtu mtu
= attr
->path_mtu
;
465 pr_debug("invalid mtu (%d) > (%d)\n",
466 ib_mtu_enum_to_int(mtu
),
467 ib_mtu_enum_to_int(max_mtu
));
472 if (mask
& IB_QP_MAX_QP_RD_ATOMIC
) {
473 if (attr
->max_rd_atomic
> rxe
->attr
.max_qp_rd_atom
) {
474 pr_warn("invalid max_rd_atomic %d > %d\n",
476 rxe
->attr
.max_qp_rd_atom
);
481 if (mask
& IB_QP_TIMEOUT
) {
482 if (attr
->timeout
> 31) {
483 pr_warn("invalid QP timeout %d > 31\n",
495 /* move the qp to the reset state */
496 static void rxe_qp_reset(struct rxe_qp
*qp
)
498 /* stop tasks from running */
499 rxe_disable_task(&qp
->resp
.task
);
501 /* stop request/comp */
503 if (qp_type(qp
) == IB_QPT_RC
)
504 rxe_disable_task(&qp
->comp
.task
);
505 rxe_disable_task(&qp
->req
.task
);
508 /* move qp to the reset state */
509 qp
->req
.state
= QP_STATE_RESET
;
510 qp
->resp
.state
= QP_STATE_RESET
;
512 /* let state machines reset themselves drain work and packet queues
515 __rxe_do_task(&qp
->resp
.task
);
518 __rxe_do_task(&qp
->comp
.task
);
519 __rxe_do_task(&qp
->req
.task
);
520 rxe_queue_reset(qp
->sq
.queue
);
523 /* cleanup attributes */
524 atomic_set(&qp
->ssn
, 0);
526 qp
->req
.need_retry
= 0;
527 qp
->req
.noack_pkts
= 0;
529 qp
->resp
.opcode
= -1;
530 qp
->resp
.drop_msg
= 0;
531 qp
->resp
.goto_error
= 0;
532 qp
->resp
.sent_psn_nak
= 0;
535 rxe_drop_ref(qp
->resp
.mr
);
539 cleanup_rd_atomic_resources(qp
);
542 rxe_enable_task(&qp
->resp
.task
);
545 if (qp_type(qp
) == IB_QPT_RC
)
546 rxe_enable_task(&qp
->comp
.task
);
548 rxe_enable_task(&qp
->req
.task
);
552 /* drain the send queue */
553 static void rxe_qp_drain(struct rxe_qp
*qp
)
556 if (qp
->req
.state
!= QP_STATE_DRAINED
) {
557 qp
->req
.state
= QP_STATE_DRAIN
;
558 if (qp_type(qp
) == IB_QPT_RC
)
559 rxe_run_task(&qp
->comp
.task
, 1);
561 __rxe_do_task(&qp
->comp
.task
);
562 rxe_run_task(&qp
->req
.task
, 1);
567 /* move the qp to the error state */
568 void rxe_qp_error(struct rxe_qp
*qp
)
570 qp
->req
.state
= QP_STATE_ERROR
;
571 qp
->resp
.state
= QP_STATE_ERROR
;
572 qp
->attr
.qp_state
= IB_QPS_ERR
;
574 /* drain work and packet queues */
575 rxe_run_task(&qp
->resp
.task
, 1);
577 if (qp_type(qp
) == IB_QPT_RC
)
578 rxe_run_task(&qp
->comp
.task
, 1);
580 __rxe_do_task(&qp
->comp
.task
);
581 rxe_run_task(&qp
->req
.task
, 1);
584 /* called by the modify qp verb */
585 int rxe_qp_from_attr(struct rxe_qp
*qp
, struct ib_qp_attr
*attr
, int mask
,
586 struct ib_udata
*udata
)
589 struct rxe_dev
*rxe
= to_rdev(qp
->ibqp
.device
);
591 struct ib_gid_attr sgid_attr
;
593 if (mask
& IB_QP_MAX_QP_RD_ATOMIC
) {
594 int max_rd_atomic
= __roundup_pow_of_two(attr
->max_rd_atomic
);
596 qp
->attr
.max_rd_atomic
= max_rd_atomic
;
597 atomic_set(&qp
->req
.rd_atomic
, max_rd_atomic
);
600 if (mask
& IB_QP_MAX_DEST_RD_ATOMIC
) {
601 int max_dest_rd_atomic
=
602 __roundup_pow_of_two(attr
->max_dest_rd_atomic
);
604 qp
->attr
.max_dest_rd_atomic
= max_dest_rd_atomic
;
606 free_rd_atomic_resources(qp
);
608 err
= alloc_rd_atomic_resources(qp
, max_dest_rd_atomic
);
613 if (mask
& IB_QP_CUR_STATE
)
614 qp
->attr
.cur_qp_state
= attr
->qp_state
;
616 if (mask
& IB_QP_EN_SQD_ASYNC_NOTIFY
)
617 qp
->attr
.en_sqd_async_notify
= attr
->en_sqd_async_notify
;
619 if (mask
& IB_QP_ACCESS_FLAGS
)
620 qp
->attr
.qp_access_flags
= attr
->qp_access_flags
;
622 if (mask
& IB_QP_PKEY_INDEX
)
623 qp
->attr
.pkey_index
= attr
->pkey_index
;
625 if (mask
& IB_QP_PORT
)
626 qp
->attr
.port_num
= attr
->port_num
;
628 if (mask
& IB_QP_QKEY
)
629 qp
->attr
.qkey
= attr
->qkey
;
631 if (mask
& IB_QP_AV
) {
632 ib_get_cached_gid(&rxe
->ib_dev
, 1,
633 attr
->ah_attr
.grh
.sgid_index
, &sgid
,
635 rxe_av_from_attr(rxe
, attr
->port_num
, &qp
->pri_av
,
637 rxe_av_fill_ip_info(rxe
, &qp
->pri_av
, &attr
->ah_attr
,
640 dev_put(sgid_attr
.ndev
);
643 if (mask
& IB_QP_ALT_PATH
) {
644 ib_get_cached_gid(&rxe
->ib_dev
, 1,
645 attr
->alt_ah_attr
.grh
.sgid_index
, &sgid
,
648 rxe_av_from_attr(rxe
, attr
->alt_port_num
, &qp
->alt_av
,
650 rxe_av_fill_ip_info(rxe
, &qp
->alt_av
, &attr
->alt_ah_attr
,
653 dev_put(sgid_attr
.ndev
);
655 qp
->attr
.alt_port_num
= attr
->alt_port_num
;
656 qp
->attr
.alt_pkey_index
= attr
->alt_pkey_index
;
657 qp
->attr
.alt_timeout
= attr
->alt_timeout
;
660 if (mask
& IB_QP_PATH_MTU
) {
661 qp
->attr
.path_mtu
= attr
->path_mtu
;
662 qp
->mtu
= ib_mtu_enum_to_int(attr
->path_mtu
);
665 if (mask
& IB_QP_TIMEOUT
) {
666 qp
->attr
.timeout
= attr
->timeout
;
667 if (attr
->timeout
== 0) {
668 qp
->qp_timeout_jiffies
= 0;
670 /* According to the spec, timeout = 4.096 * 2 ^ attr->timeout [us] */
671 int j
= nsecs_to_jiffies(4096ULL << attr
->timeout
);
673 qp
->qp_timeout_jiffies
= j
? j
: 1;
677 if (mask
& IB_QP_RETRY_CNT
) {
678 qp
->attr
.retry_cnt
= attr
->retry_cnt
;
679 qp
->comp
.retry_cnt
= attr
->retry_cnt
;
680 pr_debug("qp#%d set retry count = %d\n", qp_num(qp
),
684 if (mask
& IB_QP_RNR_RETRY
) {
685 qp
->attr
.rnr_retry
= attr
->rnr_retry
;
686 qp
->comp
.rnr_retry
= attr
->rnr_retry
;
687 pr_debug("qp#%d set rnr retry count = %d\n", qp_num(qp
),
691 if (mask
& IB_QP_RQ_PSN
) {
692 qp
->attr
.rq_psn
= (attr
->rq_psn
& BTH_PSN_MASK
);
693 qp
->resp
.psn
= qp
->attr
.rq_psn
;
694 pr_debug("qp#%d set resp psn = 0x%x\n", qp_num(qp
),
698 if (mask
& IB_QP_MIN_RNR_TIMER
) {
699 qp
->attr
.min_rnr_timer
= attr
->min_rnr_timer
;
700 pr_debug("qp#%d set min rnr timer = 0x%x\n", qp_num(qp
),
701 attr
->min_rnr_timer
);
704 if (mask
& IB_QP_SQ_PSN
) {
705 qp
->attr
.sq_psn
= (attr
->sq_psn
& BTH_PSN_MASK
);
706 qp
->req
.psn
= qp
->attr
.sq_psn
;
707 qp
->comp
.psn
= qp
->attr
.sq_psn
;
708 pr_debug("qp#%d set req psn = 0x%x\n", qp_num(qp
), qp
->req
.psn
);
711 if (mask
& IB_QP_PATH_MIG_STATE
)
712 qp
->attr
.path_mig_state
= attr
->path_mig_state
;
714 if (mask
& IB_QP_DEST_QPN
)
715 qp
->attr
.dest_qp_num
= attr
->dest_qp_num
;
717 if (mask
& IB_QP_STATE
) {
718 qp
->attr
.qp_state
= attr
->qp_state
;
720 switch (attr
->qp_state
) {
722 pr_debug("qp#%d state -> RESET\n", qp_num(qp
));
727 pr_debug("qp#%d state -> INIT\n", qp_num(qp
));
728 qp
->req
.state
= QP_STATE_INIT
;
729 qp
->resp
.state
= QP_STATE_INIT
;
733 pr_debug("qp#%d state -> RTR\n", qp_num(qp
));
734 qp
->resp
.state
= QP_STATE_READY
;
738 pr_debug("qp#%d state -> RTS\n", qp_num(qp
));
739 qp
->req
.state
= QP_STATE_READY
;
743 pr_debug("qp#%d state -> SQD\n", qp_num(qp
));
748 pr_warn("qp#%d state -> SQE !!?\n", qp_num(qp
));
749 /* Not possible from modify_qp. */
753 pr_debug("qp#%d state -> ERR\n", qp_num(qp
));
762 /* called by the query qp verb */
763 int rxe_qp_to_attr(struct rxe_qp
*qp
, struct ib_qp_attr
*attr
, int mask
)
765 struct rxe_dev
*rxe
= to_rdev(qp
->ibqp
.device
);
769 attr
->rq_psn
= qp
->resp
.psn
;
770 attr
->sq_psn
= qp
->req
.psn
;
772 attr
->cap
.max_send_wr
= qp
->sq
.max_wr
;
773 attr
->cap
.max_send_sge
= qp
->sq
.max_sge
;
774 attr
->cap
.max_inline_data
= qp
->sq
.max_inline
;
777 attr
->cap
.max_recv_wr
= qp
->rq
.max_wr
;
778 attr
->cap
.max_recv_sge
= qp
->rq
.max_sge
;
781 rxe_av_to_attr(rxe
, &qp
->pri_av
, &attr
->ah_attr
);
782 rxe_av_to_attr(rxe
, &qp
->alt_av
, &attr
->alt_ah_attr
);
784 if (qp
->req
.state
== QP_STATE_DRAIN
) {
785 attr
->sq_draining
= 1;
786 /* applications that get this state
787 * typically spin on it. yield the
792 attr
->sq_draining
= 0;
795 pr_debug("attr->sq_draining = %d\n", attr
->sq_draining
);
800 /* called by the destroy qp verb */
801 void rxe_qp_destroy(struct rxe_qp
*qp
)
804 qp
->qp_timeout_jiffies
= 0;
805 rxe_cleanup_task(&qp
->resp
.task
);
807 del_timer_sync(&qp
->retrans_timer
);
808 del_timer_sync(&qp
->rnr_nak_timer
);
810 rxe_cleanup_task(&qp
->req
.task
);
811 rxe_cleanup_task(&qp
->comp
.task
);
813 /* flush out any receive wr's or pending requests */
814 __rxe_do_task(&qp
->req
.task
);
816 __rxe_do_task(&qp
->comp
.task
);
817 __rxe_do_task(&qp
->req
.task
);
821 /* called when the last reference to the qp is dropped */
822 void rxe_qp_cleanup(struct rxe_pool_entry
*arg
)
824 struct rxe_qp
*qp
= container_of(arg
, typeof(*qp
), pelem
);
826 rxe_drop_all_mcast_groups(qp
);
829 rxe_queue_cleanup(qp
->sq
.queue
);
832 rxe_drop_ref(qp
->srq
);
835 rxe_queue_cleanup(qp
->rq
.queue
);
838 rxe_drop_ref(qp
->scq
);
840 rxe_drop_ref(qp
->rcq
);
842 rxe_drop_ref(qp
->pd
);
845 rxe_drop_ref(qp
->resp
.mr
);
849 free_rd_atomic_resources(qp
);
851 kernel_sock_shutdown(qp
->sk
, SHUT_RDWR
);
852 sock_release(qp
->sk
);