| 1 | --- |
| 2 | date: 2018-04-02 |
| 3 | footer: libibverbs |
| 4 | header: "Libibverbs Programmer's Manual" |
| 5 | layout: page |
| 6 | license: 'Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md' |
| 7 | section: 3 |
| 8 | title: ibv_create_counters |
| 9 | tagline: Verbs |
| 10 | --- |
| 11 | |
| 12 | # NAME |
| 13 | |
| 14 | **ibv_create_counters**, **ibv_destroy_counters** - Create or destroy a counters handle |
| 15 | |
| 16 | # SYNOPSIS |
| 17 | |
| 18 | ```c |
| 19 | #include <infiniband/verbs.h> |
| 20 | |
| 21 | struct ibv_counters * |
| 22 | ibv_create_counters(struct ibv_context *context, |
| 23 | struct ibv_counters_init_attr *init_attr); |
| 24 | |
| 25 | int ibv_destroy_counters(struct ibv_counters *counters); |
| 26 | ``` |
| 27 | |
| 28 | # DESCRIPTION |
| 29 | |
| 30 | **ibv_create_counters**() creates a new counters handle for the RDMA device |
| 31 | context. |
| 32 | |
| 33 | An ibv_counters handle can be attached to a verbs resource (e.g.: QP, WQ, Flow) |
| 34 | statically when these are created. |
| 35 | |
| 36 | For example attach an ibv_counters statically to a Flow (struct ibv_flow) during |
| 37 | creation of a new Flow by calling **ibv_create_flow()**. |
| 38 | |
| 39 | Counters are cleared upon creation and values will be monotonically increasing. |
| 40 | |
| 41 | **ibv_destroy_counters**() releases the counters handle, user should |
| 42 | detach the counters object before destroying it. |
| 43 | |
| 44 | # ARGUMENTS |
| 45 | |
| 46 | *context* |
| 47 | : RDMA device context to create the counters on. |
| 48 | |
| 49 | *init_attr* |
| 50 | : Is an ibv_counters_init_attr struct, as defined in verbs.h. |
| 51 | |
| 52 | ## *init_attr* Argument |
| 53 | |
| 54 | ```c |
| 55 | struct ibv_counters_init_attr { |
| 56 | int comp_mask; |
| 57 | }; |
| 58 | ``` |
| 59 | |
| 60 | *comp_mask* |
| 61 | : Bitmask specifying what fields in the structure are valid. |
| 62 | |
| 63 | # RETURN VALUE |
| 64 | |
| 65 | **ibv_create_counters**() returns a pointer to the allocated ibv_counters |
| 66 | object, or NULL if the request fails (and sets errno to indicate the failure |
| 67 | reason) |
| 68 | |
| 69 | **ibv_destroy_counters**() returns 0 on success, or the value of errno on |
| 70 | failure (which indicates the failure reason) |
| 71 | |
| 72 | # ERRORS |
| 73 | |
| 74 | EOPNOTSUPP |
| 75 | : **ibv_create_counters**() is not currently supported on this device |
| 76 | (ENOSYS may sometimes be returned by old versions of libibverbs). |
| 77 | |
| 78 | ENOMEM |
| 79 | : **ibv_create_counters**() could not create ibv_counters object, not enough memory |
| 80 | |
| 81 | EINVAL |
| 82 | : invalid parameter supplied **ibv_destroy_counters**() |
| 83 | |
| 84 | # EXAMPLE |
| 85 | |
| 86 | An example of use of ibv_counters is shown in **ibv_read_counters** |
| 87 | |
| 88 | # SEE ALSO |
| 89 | |
| 90 | **ibv_attach_counters_point_flow**, **ibv_read_counters**, |
| 91 | **ibv_create_flow** |
| 92 | |
| 93 | # AUTHORS |
| 94 | |
| 95 | Raed Salem <[email protected]> |
| 96 | |
| 97 | Alex Rosenbaum <[email protected]> |
| 98 |