]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
RDMA/nldev: provide detailed PD information
authorSteve Wise <swise@opengridcomputing.com>
Thu, 1 Mar 2018 21:58:28 +0000 (13:58 -0800)
committerDoug Ledford <dledford@redhat.com>
Thu, 8 Mar 2018 20:03:03 +0000 (15:03 -0500)
Implement the RDMA nldev netlink interface for dumping detailed PD
information.

Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/nldev.c
include/uapi/rdma/rdma_netlink.h

index 4c6626ecdb996ab2f48bc8529f6f4f6e44c30367..192084c783526c064616c7284e4c6f13657c6174 100644 (file)
@@ -91,6 +91,10 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
        [RDMA_NLDEV_ATTR_RES_LKEY]              = { .type = NLA_U32 },
        [RDMA_NLDEV_ATTR_RES_IOVA]              = { .type = NLA_U64 },
        [RDMA_NLDEV_ATTR_RES_MRLEN]             = { .type = NLA_U64 },
+       [RDMA_NLDEV_ATTR_RES_PD]                = { .type = NLA_NESTED },
+       [RDMA_NLDEV_ATTR_RES_PD_ENTRY]          = { .type = NLA_NESTED },
+       [RDMA_NLDEV_ATTR_RES_LOCAL_DMA_LKEY]    = { .type = NLA_U32 },
+       [RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY] = { .type = NLA_U32 },
 };
 
 static int fill_nldev_handle(struct sk_buff *msg, struct ib_device *device)
@@ -439,6 +443,45 @@ static int fill_res_mr_entry(struct sk_buff *msg, struct netlink_callback *cb,
        return -EMSGSIZE;
 }
 
+static int fill_res_pd_entry(struct sk_buff *msg, struct netlink_callback *cb,
+                            struct rdma_restrack_entry *res, uint32_t port)
+{
+       struct ib_pd *pd = container_of(res, struct ib_pd, res);
+       struct nlattr *entry_attr;
+
+       entry_attr = nla_nest_start(msg, RDMA_NLDEV_ATTR_RES_PD_ENTRY);
+       if (!entry_attr)
+               goto out;
+
+       if (netlink_capable(cb->skb, CAP_NET_ADMIN)) {
+               if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_LOCAL_DMA_LKEY,
+                               pd->local_dma_lkey))
+                       goto err;
+               if ((pd->flags & IB_PD_UNSAFE_GLOBAL_RKEY) &&
+                   nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY,
+                               pd->unsafe_global_rkey))
+                       goto err;
+       }
+       if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_RES_USECNT,
+                             atomic_read(&pd->usecnt), 0))
+               goto err;
+       if ((pd->flags & IB_PD_UNSAFE_GLOBAL_RKEY) &&
+           nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY,
+                       pd->unsafe_global_rkey))
+               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)
 {
@@ -741,6 +784,11 @@ static const struct nldev_fill_res_entry fill_entries[RDMA_RESTRACK_MAX] = {
                .nldev_cmd = RDMA_NLDEV_CMD_RES_MR_GET,
                .nldev_attr = RDMA_NLDEV_ATTR_RES_MR,
        },
+       [RDMA_RESTRACK_PD] = {
+               .fill_res_func = fill_res_pd_entry,
+               .nldev_cmd = RDMA_NLDEV_CMD_RES_PD_GET,
+               .nldev_attr = RDMA_NLDEV_ATTR_RES_PD,
+       },
 };
 
 static int res_get_common_dumpit(struct sk_buff *skb,
@@ -901,6 +949,12 @@ static int nldev_res_get_mr_dumpit(struct sk_buff *skb,
        return res_get_common_dumpit(skb, cb, RDMA_RESTRACK_MR);
 }
 
+static int nldev_res_get_pd_dumpit(struct sk_buff *skb,
+                                  struct netlink_callback *cb)
+{
+       return res_get_common_dumpit(skb, cb, RDMA_RESTRACK_PD);
+}
+
 static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = {
        [RDMA_NLDEV_CMD_GET] = {
                .doit = nldev_get_doit,
@@ -936,6 +990,9 @@ static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = {
        [RDMA_NLDEV_CMD_RES_MR_GET] = {
                .dump = nldev_res_get_mr_dumpit,
        },
+       [RDMA_NLDEV_CMD_RES_PD_GET] = {
+               .dump = nldev_res_get_pd_dumpit,
+       },
 };
 
 void __init nldev_init(void)
index 6d9ec38e3af05b3b6e60086ccdd5ef9725c8c344..351139c7e2e7d6de2432acfbb04b9097c357a628 100644 (file)
@@ -244,6 +244,8 @@ enum rdma_nldev_command {
 
        RDMA_NLDEV_CMD_RES_MR_GET, /* can dump */
 
+       RDMA_NLDEV_CMD_RES_PD_GET, /* can dump */
+
        RDMA_NLDEV_NUM_OPS
 };
 
@@ -381,6 +383,11 @@ enum rdma_nldev_attr {
        RDMA_NLDEV_ATTR_RES_IOVA,               /* u64 */
        RDMA_NLDEV_ATTR_RES_MRLEN,              /* u64 */
 
+       RDMA_NLDEV_ATTR_RES_PD,                 /* nested table */
+       RDMA_NLDEV_ATTR_RES_PD_ENTRY,           /* nested table */
+       RDMA_NLDEV_ATTR_RES_LOCAL_DMA_LKEY,     /* u32 */
+       RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY, /* u32 */
+
        RDMA_NLDEV_ATTR_MAX
 };
 #endif /* _UAPI_RDMA_NETLINK_H */