summaryrefslogtreecommitdiff
path: root/drivers/infiniband/core/nldev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/core/nldev.c')
-rw-r--r--drivers/infiniband/core/nldev.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index 02a0a9c0a4a6..b4bae92c5c4e 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -188,6 +188,7 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
[RDMA_NLDEV_ATTR_FRMR_POOLS_AGING_PERIOD] = { .type = NLA_U32 },
[RDMA_NLDEV_ATTR_FRMR_POOL_PINNED_HANDLES] = { .type = NLA_U32 },
[RDMA_NLDEV_ATTR_FRMR_POOL_KEY_KERNEL_VENDOR_KEY] = { .type = NLA_U64 },
+ [RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_MAX] = { .type = NLA_U64 },
};
static int put_driver_name_print_type(struct sk_buff *msg, const char *name,
@@ -413,7 +414,7 @@ out:
}
static int fill_res_info_entry(struct sk_buff *msg,
- const char *name, u64 curr)
+ const char *name, u64 curr, u64 max)
{
struct nlattr *entry_attr;
@@ -427,6 +428,9 @@ static int fill_res_info_entry(struct sk_buff *msg,
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR, curr,
RDMA_NLDEV_ATTR_PAD))
goto err;
+ if (max && nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_MAX,
+ max, RDMA_NLDEV_ATTR_PAD))
+ goto err;
nla_nest_end(msg, entry_attr);
return 0;
@@ -447,10 +451,13 @@ static int fill_res_info(struct sk_buff *msg, struct ib_device *device,
[RDMA_RESTRACK_MR] = "mr",
[RDMA_RESTRACK_CTX] = "ctx",
[RDMA_RESTRACK_SRQ] = "srq",
+ [RDMA_RESTRACK_COMP_CNTR] = "comp_cntr",
};
+ struct ib_comp_cntr_caps comp_cntr_caps = {};
struct nlattr *table_attr;
- int ret, i, curr;
+ u64 curr, max;
+ int ret, i;
if (fill_nldev_handle(msg, device))
return -EMSGSIZE;
@@ -459,11 +466,36 @@ static int fill_res_info(struct sk_buff *msg, struct ib_device *device,
if (!table_attr)
return -EMSGSIZE;
+ if (device->ops.query_comp_cntr_caps)
+ device->ops.query_comp_cntr_caps(device, &comp_cntr_caps, NULL);
+
for (i = 0; i < RDMA_RESTRACK_MAX; i++) {
if (!names[i])
continue;
curr = rdma_restrack_count(device, i, show_details);
- ret = fill_res_info_entry(msg, names[i], curr);
+ switch (i) {
+ case RDMA_RESTRACK_QP:
+ max = device->attrs.max_qp;
+ break;
+ case RDMA_RESTRACK_CQ:
+ max = device->attrs.max_cq;
+ break;
+ case RDMA_RESTRACK_MR:
+ max = device->attrs.max_mr;
+ break;
+ case RDMA_RESTRACK_PD:
+ max = device->attrs.max_pd;
+ break;
+ case RDMA_RESTRACK_SRQ:
+ max = device->attrs.max_srq;
+ break;
+ case RDMA_RESTRACK_COMP_CNTR:
+ max = comp_cntr_caps.max_counters;
+ break;
+ default:
+ max = 0;
+ }
+ ret = fill_res_info_entry(msg, names[i], curr, max);
if (ret)
goto err;
}
@@ -2133,6 +2165,11 @@ static int nldev_stat_set_counter_dynamic_doit(struct nlattr *tb[],
nla_for_each_nested(entry_attr, tb[RDMA_NLDEV_ATTR_STAT_HWCOUNTERS],
rem) {
+ if (nla_len(entry_attr) != sizeof(u32)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
index = nla_get_u32(entry_attr);
if ((index >= stats->num_counters) ||
!(stats->descs[index].flags & IB_STAT_FLAG_OPTIONAL)) {