From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Gunthorpe Subject: Re: [PATCH rdma-next v2 11/17] RDMA/netlink: Implement counter dumpit calback Date: Wed, 22 May 2019 14:22:16 -0300 Message-ID: <20190522172216.GE15023@ziepe.ca> References: <20190429083453.16654-1-leon@kernel.org> <20190429083453.16654-12-leon@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190429083453.16654-12-leon@kernel.org> Sender: netdev-owner@vger.kernel.org To: Leon Romanovsky Cc: Doug Ledford , Leon Romanovsky , RDMA mailing list , Majd Dibbiny , Mark Zhang , Saeed Mahameed , linux-netdev List-Id: linux-rdma@vger.kernel.org On Mon, Apr 29, 2019 at 11:34:47AM +0300, Leon Romanovsky wrote: > From: Mark Zhang > > This patch adds the ability to return all available counters > together with their properties and hwstats. > > Signed-off-by: Mark Zhang > Reviewed-by: Majd Dibbiny > Signed-off-by: Leon Romanovsky > drivers/infiniband/core/counters.c | 28 +++++ > drivers/infiniband/core/device.c | 2 + > drivers/infiniband/core/nldev.c | 173 +++++++++++++++++++++++++++++ > include/rdma/ib_verbs.h | 10 ++ > include/rdma/rdma_counter.h | 3 + > include/uapi/rdma/rdma_netlink.h | 10 +- > 6 files changed, 225 insertions(+), 1 deletion(-) > > diff --git a/drivers/infiniband/core/counters.c b/drivers/infiniband/core/counters.c > index 665e0d43c21b..36cd9eca1e46 100644 > +++ b/drivers/infiniband/core/counters.c > @@ -62,6 +62,9 @@ static struct rdma_counter *rdma_counter_alloc(struct ib_device *dev, u8 port, > { > struct rdma_counter *counter; > > + if (!dev->ops.counter_alloc_stats) > + return NULL; > + > counter = kzalloc(sizeof(*counter), GFP_KERNEL); > if (!counter) > return NULL; > @@ -69,16 +72,25 @@ static struct rdma_counter *rdma_counter_alloc(struct ib_device *dev, u8 port, > counter->device = dev; > counter->port = port; > counter->res.type = RDMA_RESTRACK_COUNTER; > + counter->stats = dev->ops.counter_alloc_stats(counter); > + if (!counter->stats) > + goto err_stats; > + > counter->mode.mode = mode; > atomic_set(&counter->usecnt, 0); > mutex_init(&counter->lock); > > return counter; > + > +err_stats: > + kfree(counter); > + return NULL; > } > > static void rdma_counter_dealloc(struct rdma_counter *counter) > { > rdma_restrack_del(&counter->res); > + kfree(counter->stats); > kfree(counter); > } > > @@ -279,6 +291,22 @@ int rdma_counter_unbind_qp(struct ib_qp *qp, bool force) > return 0; > } > > +int rdma_counter_query_stats(struct rdma_counter *counter) > +{ > + int ret; > + > + struct ib_device *dev = counter->device; > + Extra blank line Something about festive trees Jason