Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IB/core: Introduce counters object and its create/destroy

A verbs application may need to get statistics and info on various aspects
of a verb object (e.g. Flow, QP, ...), in general case the application
will state which object's counters its interested in (we refer to this
action as attach), bind this new counters object to the appropriate verb
object and on later stage read their values using the counters object.

This series introduces a general API for counters object that may
accumulate any ib object counters type, bound and read on demand.

Counters instance is allocated on an IB context and belongs to that
context. Upon successful creation the counters can be bound to a verbs
object so that hardware counter instances can be created and read.

Downstream patches in this series will introduce the attach, bind and the
read functionality.

Counters instance can be de-allocated, upon successful destruction the
related hardware resources are released.

Prior to destroy call the user must first make sure that the counters is
not being used by any IB object, e.g. not attached to any of its counted
type otherwise an EBUSY error is invoked.

Reviewed-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Raed Salem <raeds@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

authored by

Raed Salem and committed by
Leon Romanovsky
fa9b1802 3efa3812

+11
+11
include/rdma/ib_verbs.h
··· 2180 2180 struct list_head pkey_list; 2181 2181 }; 2182 2182 2183 + struct ib_counters { 2184 + struct ib_device *device; 2185 + struct ib_uobject *uobject; 2186 + /* num of objects attached */ 2187 + atomic_t usecnt; 2188 + }; 2189 + 2183 2190 struct uverbs_attr_bundle; 2184 2191 2185 2192 struct ib_device { ··· 2458 2451 struct ib_mr * (*reg_dm_mr)(struct ib_pd *pd, struct ib_dm *dm, 2459 2452 struct ib_dm_mr_attr *attr, 2460 2453 struct uverbs_attr_bundle *attrs); 2454 + struct ib_counters * (*create_counters)(struct ib_device *device, 2455 + struct uverbs_attr_bundle *attrs); 2456 + int (*destroy_counters)(struct ib_counters *counters); 2457 + 2461 2458 /** 2462 2459 * rdma netdev operation 2463 2460 *