IBV_ATTACH_COUNTERS_POINT_FLOW(3)

✨ NAME ✨

ibv_attach_counters_point_flow β€” the way you attach one individual counter definition to a flow object, bestie πŸ’… (this is from the ibv_attac...oint_flow(3) page, Libibverbs Programmer's Manual, if you were wondering 🫢)


🌸 SYNOPSIS 🌸

#include <infiniband/verbs.h>

int ibv_attach_counters_point_flow(struct ibv_counters *counters,
                                   struct ibv_counter_attach_attr *counter_attach_attr,
                                   struct ibv_flow *flow);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so listen πŸ‘‘ β€” counters point is a whole family of APIs, and what they do is attach an individual counter description definition to a verb object at a specific index location. That's it, that's the vibe.

Here's the tea on when your counters object actually starts collecting values: only after it is bound to the verb object resource. Not before. No cap. ⭐

A static attach can be created when you pass NULL instead of the reference to the verbs object (like, for a flow, you'd provide NULL instead of the flow). In that case this counters object will only start collecting values after it is bound to the verbs resource β€” and for flow, that moment is when you reference the counters handle while creating a flow with ibv_create_flow(). iykyk 🌈

Once an ibv_counters is bound statically to a verbs resource, no additional attach is allowed till the counter object is not bound to any verb object. Lowkey important, don't skip this one πŸ™ˆ

The counter_desc argument specifies which counter value should be collected β€” it's defined in verbs.h as one of the enum ibv_counter_description options.

Wanna know if a specific counter_desc value is supported on a specific verbs object? Just check the return value for success, or for the ENOTSUP errno. Vibe check complete βœ…

Also β€” attaching a counters handle to multiple objects of the same type will accumulate the values into a single index. For example: creating several ibv_flow(s) with the same ibv_counters handle will collect the values from all relevant flows into the relevant index location when reading the values from ibv_read_counters(). And setting the index more than once with different or same counter_desc will aggregate the values from all relevant counters into the relevant index location. Basically it all pools together, iconic πŸŽ€

The runtime values of counters can be read from the hardware by calling ibv_read_counters(). 🧚


πŸ’– ARGUMENTS πŸ’–

  • counters β€” Existing counters to attach new counter point on.
  • counter_attach_attr β€” An ibv_counter_attach_attr struct, as defined in verbs.h.
  • flow β€” Existing flow to attach a new counters point on (in static mode it must be NULL).

πŸ“ counter_attach_attr Argument

struct ibv_counter_attach_attr {
    enum ibv_counter_description counter_desc;
    uint32_t index;
    uint32_t comp_mask;
};

πŸ“ counter_desc Argument

enum ibv_counter_description {
    IBV_COUNTER_PACKETS,
    IBV_COUNTER_BYTES,
};
  • index β€” Desired location of the specific counter at the counters object. πŸ“
  • comp_mask β€” Bitmask specifying what fields in the structure are valid.

πŸ”₯ RETURN VALUE πŸ”₯

ibv_attach_counters_point_flow() returns 0 on success, or the value of errno on failure (which indicates the failure reason). Periodt.


πŸ’€ ERRORS πŸ’€

  • EINVAL β€” invalid argument(s) passed 😭
  • ENOTSUP β€” counter_desc is not supported on the requested object
  • EBUSY β€” the counter object is already bound to a flow, additional attach calls is not allowed (valid for static attach only)
  • ENOMEM β€” not enough memory

πŸŽ€ NOTES πŸŽ€

Counter values in each index location are cleared upon creation when calling ibv_create_counters(). Attaching counters points will only increase these values accordingly. So like, don't be surprised when they start at zero, bestie πŸ’œ


⭐ EXAMPLE ⭐

An example of use of ibv_attach_counters_point_flow() is shown in ibv_read_counters.


🌈 SEE ALSO 🌈

ibv_create_counters, ibv_destroy_counters, ibv_read_counters, ibv_create_flow


πŸ‘‘ AUTHORS πŸ‘‘

  • Raed Salem <raeds@mellanox.com>
  • Alex Rosenbaum <alexr@mellanox.com>

k bye bestie, go forth and attach those counter points πŸ’…βœ¨ β€” this page is from libibverbs, dated 2018-04-02, and the original is ibv_attac...oint_flow(3). Mwah 🫢

πŸ“¦ where this page comes from