Add fill_dev_info and fill_port_info functions to rdma_restrack_root. This allows providers to have provider-specific fill functions for device and port restrack operations. Signed-off-by: Steve Wise <swise@xxxxxxxxxxxxxxxxxxxxx> --- drivers/infiniband/core/nldev.c | 24 ++++++++++++++++++++++-- drivers/infiniband/core/restrack.c | 2 ++ include/rdma/restrack.h | 14 ++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c index 1a680a3..0610313 100644 --- a/drivers/infiniband/core/nldev.c +++ b/drivers/infiniband/core/nldev.c @@ -114,6 +114,20 @@ static int provider_fill_res_entry(struct rdma_restrack_root *resroot, resroot->fill_res_entry(msg, res) : 0; } +static int provider_fill_dev_info(struct sk_buff *msg, + struct ib_device *device) +{ + return device->res.fill_dev_info ? + device->res.fill_dev_info(msg, device) : 0; +} + +static int provider_fill_port_info(struct sk_buff *msg, + struct ib_device *device, u32 port) +{ + return device->res.fill_port_info ? + device->res.fill_port_info(msg, device, port) : 0; +} + static int fill_nldev_handle(struct sk_buff *msg, struct ib_device *device) { if (nla_put_u32(msg, RDMA_NLDEV_ATTR_DEV_INDEX, device->index)) @@ -155,11 +169,15 @@ static int fill_dev_info(struct sk_buff *msg, struct ib_device *device) return -EMSGSIZE; if (nla_put_u8(msg, RDMA_NLDEV_ATTR_DEV_NODE_TYPE, device->node_type)) return -EMSGSIZE; + + if (provider_fill_dev_info(msg, device)) + return -EMSGSIZE; + return 0; } -static int fill_port_info(struct sk_buff *msg, - struct ib_device *device, u32 port) +static int fill_port_info(struct sk_buff *msg, struct ib_device *device, + u32 port) { struct ib_port_attr attr; int ret; @@ -194,6 +212,8 @@ static int fill_port_info(struct sk_buff *msg, return -EMSGSIZE; if (nla_put_u8(msg, RDMA_NLDEV_ATTR_PORT_PHYS_STATE, attr.phys_state)) return -EMSGSIZE; + if (provider_fill_port_info(msg, device, port)) + return -EMSGSIZE; return 0; } diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c index 78fc6d9..76a8d75 100644 --- a/drivers/infiniband/core/restrack.c +++ b/drivers/infiniband/core/restrack.c @@ -16,6 +16,8 @@ void rdma_restrack_init(struct rdma_restrack_root *res) { init_rwsem(&res->rwsem); res->fill_res_entry = NULL; + res->fill_dev_info = NULL; + res->fill_port_info = NULL; } static const char *type2str(enum rdma_restrack_type type) diff --git a/include/rdma/restrack.h b/include/rdma/restrack.h index 51f400e..525f885 100644 --- a/include/rdma/restrack.h +++ b/include/rdma/restrack.h @@ -45,6 +45,7 @@ enum rdma_restrack_type { #define RDMA_RESTRACK_HASH_BITS 8 struct rdma_restrack_entry; +struct ib_device; /** * struct rdma_restrack_root - main resource tracking management @@ -66,6 +67,19 @@ struct rdma_restrack_root { */ int (*fill_res_entry)(struct sk_buff *msg, struct rdma_restrack_entry *entry); + /** + * @fill_dev_info: provider-specific fill function + * + * Allows rdma providers to add their own device attributes. + */ + int (*fill_dev_info)(struct sk_buff *msg, struct ib_device *device); + /** + * @fill_port_info: provider-specific fill function + * + * Allows rdma providers to add their own port attributes. + */ + int (*fill_port_info)(struct sk_buff *msg, struct ib_device *device, + u32 port); }; /** -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html