Thread (21 messages) 21 messages, 2 authors, 2021-10-05

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

On Thu, Sep 30, 2021 at 11:02:22AM +0300, Leon Romanovsky wrote:
quoted hunk ↗ jump to hunk
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help