|
@@ -85,6 +85,12 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
|
|
|
[RDMA_NLDEV_ATTR_RES_CQE] = { .type = NLA_U32 },
|
|
|
[RDMA_NLDEV_ATTR_RES_USECNT] = { .type = NLA_U64 },
|
|
|
[RDMA_NLDEV_ATTR_RES_POLL_CTX] = { .type = NLA_U8 },
|
|
|
+ [RDMA_NLDEV_ATTR_RES_MR] = { .type = NLA_NESTED },
|
|
|
+ [RDMA_NLDEV_ATTR_RES_MR_ENTRY] = { .type = NLA_NESTED },
|
|
|
+ [RDMA_NLDEV_ATTR_RES_RKEY] = { .type = NLA_U32 },
|
|
|
+ [RDMA_NLDEV_ATTR_RES_LKEY] = { .type = NLA_U32 },
|
|
|
+ [RDMA_NLDEV_ATTR_RES_IOVA] = { .type = NLA_U64 },
|
|
|
+ [RDMA_NLDEV_ATTR_RES_MRLEN] = { .type = NLA_U64 },
|
|
|
};
|
|
|
|
|
|
static int fill_nldev_handle(struct sk_buff *msg, struct ib_device *device)
|
|
@@ -197,6 +203,7 @@ static int fill_res_info(struct sk_buff *msg, struct ib_device *device)
|
|
|
[RDMA_RESTRACK_CQ] = "cq",
|
|
|
[RDMA_RESTRACK_QP] = "qp",
|
|
|
[RDMA_RESTRACK_CM_ID] = "cm_id",
|
|
|
+ [RDMA_RESTRACK_MR] = "mr",
|
|
|
};
|
|
|
|
|
|
struct rdma_restrack_root *res = &device->res;
|
|
@@ -397,6 +404,41 @@ out:
|
|
|
return -EMSGSIZE;
|
|
|
}
|
|
|
|
|
|
+static int fill_res_mr_entry(struct sk_buff *msg, struct netlink_callback *cb,
|
|
|
+ struct rdma_restrack_entry *res, uint32_t port)
|
|
|
+{
|
|
|
+ struct ib_mr *mr = container_of(res, struct ib_mr, res);
|
|
|
+ struct nlattr *entry_attr;
|
|
|
+
|
|
|
+ entry_attr = nla_nest_start(msg, RDMA_NLDEV_ATTR_RES_MR_ENTRY);
|
|
|
+ if (!entry_attr)
|
|
|
+ goto out;
|
|
|
+
|
|
|
+ if (netlink_capable(cb->skb, CAP_NET_ADMIN)) {
|
|
|
+ if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_RKEY, mr->rkey))
|
|
|
+ goto err;
|
|
|
+ if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_LKEY, mr->lkey))
|
|
|
+ goto err;
|
|
|
+ if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_RES_IOVA,
|
|
|
+ mr->iova, 0))
|
|
|
+ goto err;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_RES_MRLEN, mr->length, 0))
|
|
|
+ goto err;
|
|
|
+
|
|
|
+ if (fill_res_name_pid(msg, res))
|
|
|
+ goto err;
|
|
|
+
|
|
|
+ nla_nest_end(msg, entry_attr);
|
|
|
+ return 0;
|
|
|
+
|
|
|
+err:
|
|
|
+ nla_nest_cancel(msg, entry_attr);
|
|
|
+out:
|
|
|
+ return -EMSGSIZE;
|
|
|
+}
|
|
|
+
|
|
|
static int nldev_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|
|
struct netlink_ext_ack *extack)
|
|
|
{
|
|
@@ -694,6 +736,11 @@ static const struct nldev_fill_res_entry fill_entries[RDMA_RESTRACK_MAX] = {
|
|
|
.nldev_cmd = RDMA_NLDEV_CMD_RES_CQ_GET,
|
|
|
.nldev_attr = RDMA_NLDEV_ATTR_RES_CQ,
|
|
|
},
|
|
|
+ [RDMA_RESTRACK_MR] = {
|
|
|
+ .fill_res_func = fill_res_mr_entry,
|
|
|
+ .nldev_cmd = RDMA_NLDEV_CMD_RES_MR_GET,
|
|
|
+ .nldev_attr = RDMA_NLDEV_ATTR_RES_MR,
|
|
|
+ },
|
|
|
};
|
|
|
|
|
|
static int res_get_common_dumpit(struct sk_buff *skb,
|
|
@@ -848,6 +895,12 @@ static int nldev_res_get_cq_dumpit(struct sk_buff *skb,
|
|
|
return res_get_common_dumpit(skb, cb, RDMA_RESTRACK_CQ);
|
|
|
}
|
|
|
|
|
|
+static int nldev_res_get_mr_dumpit(struct sk_buff *skb,
|
|
|
+ struct netlink_callback *cb)
|
|
|
+{
|
|
|
+ return res_get_common_dumpit(skb, cb, RDMA_RESTRACK_MR);
|
|
|
+}
|
|
|
+
|
|
|
static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = {
|
|
|
[RDMA_NLDEV_CMD_GET] = {
|
|
|
.doit = nldev_get_doit,
|
|
@@ -880,6 +933,9 @@ static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = {
|
|
|
[RDMA_NLDEV_CMD_RES_CQ_GET] = {
|
|
|
.dump = nldev_res_get_cq_dumpit,
|
|
|
},
|
|
|
+ [RDMA_NLDEV_CMD_RES_MR_GET] = {
|
|
|
+ .dump = nldev_res_get_mr_dumpit,
|
|
|
+ },
|
|
|
};
|
|
|
|
|
|
void __init nldev_init(void)
|