From: Erez Alfasi <ereza@xxxxxxxxxxxx> Provide an ODP explicit/implicit type indicator as part of 'rdma resource mr show' dump. For example: ~$: rdma resource mr show dev mlx5_0 mrn 1 rkey 0xa99a lkey 0xa99a mrlen 50000000 pdn 9 pid 7372 odp explicit comm ibv_rc_pingpong For non-ODP MRs, we won't print "odp ..." at all. Signed-off-by: Erez Alfasi <ereza@xxxxxxxxxxxx> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- drivers/infiniband/core/nldev.c | 8 ++++++++ include/uapi/rdma/rdma_netlink.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c index e287b71a1cfd..1562b9446c51 100644 --- a/drivers/infiniband/core/nldev.c +++ b/drivers/infiniband/core/nldev.c @@ -37,6 +37,8 @@ #include <net/netlink.h> #include <rdma/rdma_cm.h> #include <rdma/rdma_netlink.h> +#include <rdma/ib_umem.h> +#include <rdma/ib_umem_odp.h> #include "core_priv.h" #include "cma_priv.h" @@ -101,6 +103,7 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = { [RDMA_NLDEV_ATTR_RES_MRLEN] = { .type = NLA_U64 }, [RDMA_NLDEV_ATTR_RES_MRN] = { .type = NLA_U32 }, [RDMA_NLDEV_ATTR_RES_MR_ENTRY] = { .type = NLA_NESTED }, + [RDMA_NLDEV_ATTR_RES_MR_ODP_TYPE] = { .type = NLA_U8 }, [RDMA_NLDEV_ATTR_RES_PATH_MIG_STATE] = { .type = NLA_U8 }, [RDMA_NLDEV_ATTR_RES_PD] = { .type = NLA_NESTED }, [RDMA_NLDEV_ATTR_RES_PDN] = { .type = NLA_U32 }, @@ -589,6 +592,11 @@ static int fill_res_mr_entry(struct sk_buff *msg, bool has_cap_net_admin, goto err; } + if (mr->umem->is_odp) + if (nla_put_u8(msg, RDMA_NLDEV_ATTR_RES_MR_ODP_TYPE, + to_ib_umem_odp(mr->umem)->type)) + goto err; + if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_RES_MRLEN, mr->length, RDMA_NLDEV_ATTR_PAD)) goto err; diff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h index 8e277783fa96..765771a7caf7 100644 --- a/include/uapi/rdma/rdma_netlink.h +++ b/include/uapi/rdma/rdma_netlink.h @@ -525,6 +525,11 @@ enum rdma_nldev_attr { */ RDMA_NLDEV_ATTR_DEV_DIM, /* u8 */ + /* + * MR ODP type, e.g. implicit/explicit. + */ + RDMA_NLDEV_ATTR_RES_MR_ODP_TYPE, /* u8 */ + /* * Always the end */ -- 2.20.1