Skip to content

Commit a9017e2

Browse files
yishaihdledford
authored andcommitted
IB/core: Extend create QP to get indirection table
Extend create QP to get Receive Work Queue (WQ) indirection table. QP can be created with external Receive Work Queue indirection table, in that case it is ready to receive immediately. Signed-off-by: Yishai Hadas <[email protected]> Signed-off-by: Matan Barak <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent c5f9092 commit a9017e2

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

drivers/infiniband/core/verbs.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,12 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
754754
struct ib_qp *qp;
755755
int ret;
756756

757+
if (qp_init_attr->rwq_ind_tbl &&
758+
(qp_init_attr->recv_cq ||
759+
qp_init_attr->srq || qp_init_attr->cap.max_recv_wr ||
760+
qp_init_attr->cap.max_recv_sge))
761+
return ERR_PTR(-EINVAL);
762+
757763
/*
758764
* If the callers is using the RDMA API calculate the resources
759765
* needed for the RDMA READ/WRITE operations.
@@ -771,6 +777,7 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
771777
qp->real_qp = qp;
772778
qp->uobject = NULL;
773779
qp->qp_type = qp_init_attr->qp_type;
780+
qp->rwq_ind_tbl = qp_init_attr->rwq_ind_tbl;
774781

775782
atomic_set(&qp->usecnt, 0);
776783
qp->mrs_used = 0;
@@ -788,7 +795,8 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
788795
qp->srq = NULL;
789796
} else {
790797
qp->recv_cq = qp_init_attr->recv_cq;
791-
atomic_inc(&qp_init_attr->recv_cq->usecnt);
798+
if (qp_init_attr->recv_cq)
799+
atomic_inc(&qp_init_attr->recv_cq->usecnt);
792800
qp->srq = qp_init_attr->srq;
793801
if (qp->srq)
794802
atomic_inc(&qp_init_attr->srq->usecnt);
@@ -799,7 +807,10 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
799807
qp->xrcd = NULL;
800808

801809
atomic_inc(&pd->usecnt);
802-
atomic_inc(&qp_init_attr->send_cq->usecnt);
810+
if (qp_init_attr->send_cq)
811+
atomic_inc(&qp_init_attr->send_cq->usecnt);
812+
if (qp_init_attr->rwq_ind_tbl)
813+
atomic_inc(&qp->rwq_ind_tbl->usecnt);
803814

804815
if (qp_init_attr->cap.max_rdma_ctxs) {
805816
ret = rdma_rw_init_mrs(qp, qp_init_attr);
@@ -1279,6 +1290,7 @@ int ib_destroy_qp(struct ib_qp *qp)
12791290
struct ib_pd *pd;
12801291
struct ib_cq *scq, *rcq;
12811292
struct ib_srq *srq;
1293+
struct ib_rwq_ind_table *ind_tbl;
12821294
int ret;
12831295

12841296
WARN_ON_ONCE(qp->mrs_used > 0);
@@ -1293,6 +1305,7 @@ int ib_destroy_qp(struct ib_qp *qp)
12931305
scq = qp->send_cq;
12941306
rcq = qp->recv_cq;
12951307
srq = qp->srq;
1308+
ind_tbl = qp->rwq_ind_tbl;
12961309

12971310
if (!qp->uobject)
12981311
rdma_rw_cleanup_mrs(qp);
@@ -1307,6 +1320,8 @@ int ib_destroy_qp(struct ib_qp *qp)
13071320
atomic_dec(&rcq->usecnt);
13081321
if (srq)
13091322
atomic_dec(&srq->usecnt);
1323+
if (ind_tbl)
1324+
atomic_dec(&ind_tbl->usecnt);
13101325
}
13111326

13121327
return ret;

include/rdma/ib_verbs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,7 @@ struct ib_qp_init_attr {
10171017
* Only needed for special QP types, or when using the RW API.
10181018
*/
10191019
u8 port_num;
1020+
struct ib_rwq_ind_table *rwq_ind_tbl;
10201021
};
10211022

10221023
struct ib_qp_open_attr {
@@ -1511,6 +1512,7 @@ struct ib_qp {
15111512
void *qp_context;
15121513
u32 qp_num;
15131514
enum ib_qp_type qp_type;
1515+
struct ib_rwq_ind_table *rwq_ind_tbl;
15141516
};
15151517

15161518
struct ib_mr {

0 commit comments

Comments
 (0)