Re: [PATCH rdma-next v2 06/13] RDMA/counter: Add optional counter support
From: Jason Gunthorpe <jgg@nvidia.com>
Date: 2021-10-04 18:01:41
Also in:
linux-rdma, lkml
From: Jason Gunthorpe <jgg@nvidia.com>
Date: 2021-10-04 18:01:41
Also in:
linux-rdma, lkml
On Thu, Sep 30, 2021 at 11:02:22AM +0300, Leon Romanovsky wrote:
diff --git a/drivers/infiniband/core/counters.c b/drivers/infiniband/core/counters.c index 331cd29f0d61..dac8f370ae3c 100644 +++ b/drivers/infiniband/core/counters.c@@ -106,6 +106,36 @@ static int __rdma_counter_bind_qp(struct rdma_counter *counter, return ret; } +int rdma_counter_modify(struct ib_device *dev, u32 port, + unsigned int index, bool enable) +{ + struct rdma_hw_stats *stats; + int ret = 0; + + if (!dev->ops.modify_hw_stat) + return -EOPNOTSUPP; + + stats = ib_get_hw_stats_port(dev, port); + if (!stats || (index >= stats->num_counters) || + !(stats->descs[index].flags & IB_STAT_FLAG_OPTIONAL)) + return -EINVAL; + + mutex_lock(&stats->lock); + + if (enable != test_bit(index, stats->is_disabled)) + goto out; + + ret = dev->ops.modify_hw_stat(dev, port, index, enable); + if (ret) + goto out; + + enable ? clear_bit(index, stats->is_disabled) : + set_bit(index, stats->is_disabled);
This still needs to follow the kernel standard.. Jason