| 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_attach_counters_point_flow |
| 9 | --- |
| 10 | # NAME |
| 11 | |
| 12 | **ibv_attach_counters_point_flow** - attach individual counter definition to |
| 13 | a flow object |
| 14 | |
| 15 | # SYNOPSIS |
| 16 | |
| 17 | ```c |
| 18 | #include <infiniband/verbs.h> |
| 19 | |
| 20 | int ibv_attach_counters_point_flow(struct ibv_counters *counters, |
| 21 | struct ibv_counter_attach_attr *counter_attach_attr, |
| 22 | struct ibv_flow *flow); |
| 23 | ``` |
| 24 | |
| 25 | # DESCRIPTION |
| 26 | |
| 27 | Attach counters point are a family of APIs to attach individual counter |
| 28 | description definition to a verb object at a specific index location. |
| 29 | |
| 30 | Counters object will start collecting values after it is bound to the verb object |
| 31 | resource. |
| 32 | |
| 33 | A static attach can be created when NULL is provided instead of the reference |
| 34 | to the verbs object (e.g.: in case of flow providing NULL instead of *flow*). |
| 35 | In this case, this counters object will only start collecting values after it is |
| 36 | bound to the verbs resource, for flow this is when referencing the counters handle |
| 37 | when creating a flow with **ibv_create_flow**(). |
| 38 | |
| 39 | Once an ibv_counters is bound statically to a verbs resource, no additional attach |
| 40 | is allowed till the counter object is not bound to any verb object. |
| 41 | |
| 42 | The argument counter_desc specifies which counter value should be collected. It |
| 43 | is defined in verbs.h as one of the enum ibv_counter_description options. |
| 44 | |
| 45 | Supported capabilities of specific counter_desc values per verbs object can be |
| 46 | tested by checking the return value for success or ENOTSUP errno. |
| 47 | |
| 48 | Attaching a counters handle to multiple objects of the same type will accumulate |
| 49 | the values into a single index. e.g.: creating several ibv_flow(s) with the same |
| 50 | ibv_counters handle will collect the values from all relevant flows into the |
| 51 | relevant index location when reading the values from **ibv_read_counters**(), |
| 52 | setting the index more than once with different or same counter_desc will |
| 53 | aggregate the values from all relevant counters into the relevant index |
| 54 | location. |
| 55 | |
| 56 | The runtime values of counters can be read from the hardware by calling |
| 57 | **ibv_read_counters**(). |
| 58 | |
| 59 | # ARGUMENTS |
| 60 | |
| 61 | *counters* |
| 62 | : Existing counters to attach new counter point on. |
| 63 | |
| 64 | *counter_attach_attr* |
| 65 | : An ibv_counter_attach_attr struct, as defined in verbs.h. |
| 66 | |
| 67 | *flow* |
| 68 | : Existing flow to attach a new counters point on (in static mode |
| 69 | it must be NULL). |
| 70 | |
| 71 | ## *counter_attach_attr* Argument |
| 72 | |
| 73 | ```c |
| 74 | struct ibv_counter_attach_attr { |
| 75 | enum ibv_counter_description counter_desc; |
| 76 | uint32_t index; |
| 77 | uint32_t comp_mask; |
| 78 | }; |
| 79 | ``` |
| 80 | |
| 81 | ## *counter_desc* Argument |
| 82 | |
| 83 | ```c |
| 84 | enum ibv_counter_description { |
| 85 | IBV_COUNTER_PACKETS, |
| 86 | IBV_COUNTER_BYTES, |
| 87 | }; |
| 88 | ``` |
| 89 | |
| 90 | *index* |
| 91 | : Desired location of the specific counter at the counters object. |
| 92 | |
| 93 | *comp_mask* |
| 94 | : Bitmask specifying what fields in the structure are valid. |
| 95 | |
| 96 | # RETURN VALUE |
| 97 | |
| 98 | **ibv_attach_counters_point_flow**() returns 0 on success, or the value of errno |
| 99 | on failure (which indicates the failure reason) |
| 100 | |
| 101 | # ERRORS |
| 102 | |
| 103 | EINVAL |
| 104 | : invalid argument(s) passed |
| 105 | |
| 106 | ENOTSUP |
| 107 | : *counter_desc* is not supported on the requested object |
| 108 | |
| 109 | EBUSY |
| 110 | : the counter object is already bound to a flow, additional attach calls is not allowed (valid for static attach only) |
| 111 | |
| 112 | ENOMEM |
| 113 | : not enough memory |
| 114 | |
| 115 | # NOTES |
| 116 | Counter values in each index location are cleared upon creation when calling |
| 117 | **ibv_create_counters**(). |
| 118 | Attaching counters points will only increase these values accordingly. |
| 119 | |
| 120 | # EXAMPLE |
| 121 | |
| 122 | An example of use of **ibv_attach_counters_point_flow**() is shown in |
| 123 | **ibv_read_counters** |
| 124 | |
| 125 | # SEE ALSO |
| 126 | |
| 127 | **ibv_create_counters**, **ibv_destroy_counters**, |
| 128 | **ibv_read_counters**, **ibv_create_flow** |
| 129 | |
| 130 | # AUTHORS |
| 131 | |
| 132 | Raed Salem <[email protected]> |
| 133 | |
| 134 | Alex Rosenbaum <[email protected]> |