On Fri, Mar 23, 2018 at 09:49:39AM -0700, Steve Wise wrote: > Each provider can register a "fill entry" function with the restrack core. > This function will be called when filling out a resource, allowing the > provider to add provider-specific details. The details consist of a > table of nested attributes, that are in the form of "key, value" tuple. > The key nlattr must be strings, and the value nlattr can be one of > provider attributes that are generic, but typed, allowing the nlmessage > to ve validated. Currently the types include string, s32, u32, x32, s64, > u64, and x64. The inclusion of x, s, and u variants for numeric attributes > allows the user tool to print the number in the desired format. > > More attrs can be defined as they become needed by providers. > > Signed-off-by: Steve Wise <swise@xxxxxxxxxxxxxxxxxxxxx> > --- > drivers/infiniband/core/nldev.c | 39 +++++++++++++++++++++++++++++++++++++++ > include/rdma/restrack.h | 10 ++++++++++ > include/uapi/rdma/rdma_netlink.h | 16 ++++++++++++++++ > 3 files changed, 65 insertions(+) > > diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c > index 884843e..8346ede 100644 > --- a/drivers/infiniband/core/nldev.c > +++ b/drivers/infiniband/core/nldev.c > @@ -95,8 +95,27 @@ > [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 }, > + [RDMA_NLDEV_ATTR_PROVIDER] = { .type = NLA_NESTED }, > + [RDMA_NLDEV_ATTR_PROVIDER_ENTRY] = { .type = NLA_NESTED }, > + [RDMA_NLDEV_ATTR_PROVIDER_STRING] = { .type = NLA_NUL_STRING, > + .len = RDMA_NLDEV_ATTR_PROVIDER_STRLEN }, > + [RDMA_NLDEV_ATTR_PROVIDER_D32] = { .type = NLA_S32 }, > + [RDMA_NLDEV_ATTR_PROVIDER_U32] = { .type = NLA_U32 }, > + [RDMA_NLDEV_ATTR_PROVIDER_X32] = { .type = NLA_U32 }, > + [RDMA_NLDEV_ATTR_PROVIDER_D64] = { .type = NLA_S64 }, > + [RDMA_NLDEV_ATTR_PROVIDER_U64] = { .type = NLA_U64 }, > + [RDMA_NLDEV_ATTR_PROVIDER_X64] = { .type = NLA_U64 }, > }; > > +static int provider_fill_res_entry(struct rdma_restrack_root *resroot, > + struct sk_buff *msg, > + struct netlink_callback *cb, > + struct rdma_restrack_entry *res) > +{ > + return resroot->fill_res_entry ? > + resroot->fill_res_entry(msg, cb, res) : 0; > +} Please add "fill_res_entry = NULL" line into rdma_restrack_init() despite kzalloc usage in ib_alloc_device(). And I afraid that we didn't settle the PROVIDER_*64 thing. Thanks
Attachment:
signature.asc
Description: PGP signature