[PATCH rdma-next v4 9/9] RDMA/nldev: Provide parent IDs for PD, MR and QP objects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Leon Romanovsky <leonro@xxxxxxxxxxxx>

PD, MR and QP objects have parents objects: contexts and PDs.
The exposed parent IDs allow to correlate various objects
and simplify debug investigation.

Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
---
 drivers/infiniband/core/nldev.c  | 41 ++++++++++++++++++++++++++++----
 include/uapi/rdma/rdma_netlink.h |  1 +
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index e460025fbddf..6e0ea878d78f 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -111,6 +111,7 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
 	[RDMA_NLDEV_ATTR_RES_CQN]               = { .type = NLA_U32 },
 	[RDMA_NLDEV_ATTR_RES_MRN]               = { .type = NLA_U32 },
 	[RDMA_NLDEV_ATTR_RES_CM_IDN]            = { .type = NLA_U32 },
+	[RDMA_NLDEV_ATTR_RES_CTXN]              = { .type = NLA_U32 },
 };
 
 static int put_driver_name_print_type(struct sk_buff *msg, const char *name,
@@ -375,25 +376,54 @@ static bool fill_res_entry(struct ib_device *dev, struct sk_buff *msg,
 
 static bool fill_res_ids(struct sk_buff *msg, struct rdma_restrack_entry *res)
 {
-	bool ret;
+	bool ret = false;
 
 	switch (res->type) {
-	case RDMA_RESTRACK_PD:
+	case RDMA_RESTRACK_PD: {
+		struct ib_pd *pd = container_of(res, struct ib_pd, res);
+
 		ret = nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_PDN,
 				  rdma_res_to_id(res));
+		if (!ret && !rdma_is_kernel_res(res))
+			ret = nla_put_u32(
+				msg, RDMA_NLDEV_ATTR_RES_CTXN,
+				rdma_res_to_id(&pd->uobject->context->res));
 		break;
-	case RDMA_RESTRACK_CQ:
+	}
+	case RDMA_RESTRACK_CQ: {
+		struct ib_cq *cq = container_of(res, struct ib_cq, res);
+
 		ret = nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_CQN,
 				  rdma_res_to_id(res));
+		if (!ret && !rdma_is_kernel_res(res))
+			ret = nla_put_u32(
+				msg, RDMA_NLDEV_ATTR_RES_CTXN,
+				rdma_res_to_id(&cq->uobject->context->res));
+
 		break;
-	case RDMA_RESTRACK_MR:
+	}
+	case RDMA_RESTRACK_MR: {
+		struct ib_mr *mr = container_of(res, struct ib_mr, res);
+
 		ret = nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_MRN,
 				  rdma_res_to_id(res));
+		if (!ret && !rdma_is_kernel_res(res))
+			ret = nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_PDN,
+					  rdma_res_to_id(&mr->pd->res));
 		break;
+	}
 	case RDMA_RESTRACK_CM_ID:
 		ret = nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_CM_IDN,
 				  rdma_res_to_id(res));
 		break;
+	case RDMA_RESTRACK_QP: {
+		struct ib_qp *qp = container_of(res, struct ib_qp, res);
+
+		if (!rdma_is_kernel_res(res))
+			ret = nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_PDN,
+					  rdma_res_to_id(&qp->pd->res));
+		break;
+	}
 	default:
 		ret = true;
 	}
@@ -447,6 +477,9 @@ static int fill_res_qp_entry(struct sk_buff *msg, bool has_cap_net_admin,
 	if (nla_put_u8(msg, RDMA_NLDEV_ATTR_RES_STATE, qp_attr.qp_state))
 		goto err;
 
+	if (fill_res_ids(msg, res))
+		goto err;
+
 	if (fill_res_name_pid(msg, res))
 		goto err;
 
diff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h
index dfcb0bbdade5..38394783b950 100644
--- a/include/uapi/rdma/rdma_netlink.h
+++ b/include/uapi/rdma/rdma_netlink.h
@@ -425,6 +425,7 @@ enum rdma_nldev_attr {
 	RDMA_NLDEV_ATTR_RES_CQN,               /* u32 */
 	RDMA_NLDEV_ATTR_RES_MRN,               /* u32 */
 	RDMA_NLDEV_ATTR_RES_CM_IDN,            /* u32 */
+	RDMA_NLDEV_ATTR_RES_CTXN,	       /* u32 */
 
 	/*
 	 * Always the end
-- 
2.19.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux