ibv_create_comp_cntr(3)
π ibv_create_comp_cntr(3)
okay bestie, welcome to ibv_create_comp_cntr(3) from the Libibverbs Programmerβs Manual. Weβre doing completion counters today, and honestly? Theyβre kinda iconic. Creating, destroying, setting, incrementing, reading β the whole group chat is here. β¨
β¨ NAME β¨
ibv_create_comp_cntr,ibv_destroy_comp_cntrβ create or destroy a completion counteribv_set_comp_cntr,ibv_set_err_comp_cntrβ set the value of a completion or error counteribv_inc_comp_cntr,ibv_inc_err_comp_cntrβ increment a completion or error counteribv_read_comp_cntr,ibv_read_err_comp_cntrβ read the value of a completion or error counter
πΈ SYNOPSIS πΈ
#include <infiniband/verbs.h>
struct ibv_comp_cntr *ibv_create_comp_cntr(struct ibv_context *context,
struct ibv_comp_cntr_init_attr *cc_attr);
int ibv_destroy_comp_cntr(struct ibv_comp_cntr *comp_cntr);
int ibv_set_comp_cntr(struct ibv_comp_cntr *comp_cntr, uint64_t value);
int ibv_set_err_comp_cntr(struct ibv_comp_cntr *comp_cntr, uint64_t value);
int ibv_inc_comp_cntr(struct ibv_comp_cntr *comp_cntr, uint64_t amount);
int ibv_inc_err_comp_cntr(struct ibv_comp_cntr *comp_cntr, uint64_t amount);
int ibv_read_comp_cntr(struct ibv_comp_cntr *comp_cntr, uint64_t *value);
int ibv_read_err_comp_cntr(struct ibv_comp_cntr *comp_cntr, uint64_t *value);
π¦ DESCRIPTION π¦
Completion counters are giving lightweight completion mechanism energy β they work as an alternative or an extension to completion queues (CQs). Instead of generating individual completion queue entries, a completion counter tracks the aggregate number of completed operations. That makes them super well suited for apps that just need to know how many requests have completed without needing per-request details β think credit based flow control or tracking responses from remote peers. iykyk. π
Each completion counter maintains two distinct 64-bit values: a completion count that gets incremented on successful completions, and an error count that gets incremented when operations complete in error. Two counters, two vibes, zero confusion. π
ibv_create_comp_cntr()allocates a new completion counter for the RDMA device context context. The properties of the counter are defined by cc_attr. The maximum number of completion counters a device supports is reported byibv_query_comp_cntr_caps(3).ibv_destroy_comp_cntr()releases all resources associated with the completion counter comp_cntr. The counter must not be attached to any QP when destroyed. No sneaky attachments, bestie. π«Άibv_set_comp_cntr()sets the completion count of comp_cntr to value.ibv_set_err_comp_cntr()sets the error count of comp_cntr to value.ibv_inc_comp_cntr()increments the completion count of comp_cntr by amount.ibv_inc_err_comp_cntr()increments the error count of comp_cntr by amount.ibv_read_comp_cntr()reads the current completion count of comp_cntr into value.ibv_read_err_comp_cntr()reads the current error count of comp_cntr into value.
π ARGUMENTS π
π¦ ibv_comp_cntr
struct ibv_comp_cntr {
struct ibv_context *context;
uint32_t handle;
};
- context β Device context associated with the completion counter.
- handle β Kernel object handle for the completion counter.
πΈ ibv_comp_cntr_init_attr
enum ibv_comp_cntr_type {
IBV_COMP_CNTR_TYPE_WRS,
IBV_COMP_CNTR_TYPE_BYTES,
};
struct ibv_comp_cntr_init_attr {
uint32_t comp_mask;
enum ibv_comp_cntr_type type;
uint32_t flags;
};
- comp_mask β Bitmask specifying what fields in the structure are valid.
- type β The counting mode for the completion counter. Not all devices support all modes.
IBV_COMP_CNTR_TYPE_WRScounts completed work requests (default).IBV_COMP_CNTR_TYPE_BYTEScounts completed bytes. - flags β Reserved for future use, for now must be
0.
π₯ RETURN VALUE π₯
ibv_create_comp_cntr()returns a pointer to the allocatedibv_comp_cntrobject, orNULLif the request fails (and setserrnoto indicate the failure reason).ibv_destroy_comp_cntr(),ibv_set_comp_cntr(),ibv_set_err_comp_cntr(),ibv_inc_comp_cntr(),ibv_inc_err_comp_cntr(),ibv_read_comp_cntr(), andibv_read_err_comp_cntr()return0on success, or the value oferrnoon failure (which indicates the failure reason).
π ERRORS π
ENOTSUPβ Completion counters are not supported on this device, or the requested operation is not supported for the given counter configuration.ENOMEMβ Not enough resources to create the completion counter.EINVALβ Invalid argument(s) passed.EBUSYβ The completion counter is still attached to a QP (ibv_destroy_comp_cntr()only).
π«Ά NOTES π«Ά
- Counter values must only be updated using
ibv_set_comp_cntr(),ibv_set_err_comp_cntr(),ibv_inc_comp_cntr(), oribv_inc_err_comp_cntr(). Periodt. - Updates made to counter values (e.g. via
ibv_set_comp_cntr()oribv_inc_comp_cntr()) may not be immediately visible when reading the counter viaibv_read_comp_cntr()oribv_read_err_comp_cntr(). A small delay may occur between the update and the observed value. However, the final updated value will eventually be reflected. So likeβ¦ give it a sec, bestie. π - Applications should ensure that the counter value is stable before calling
ibv_set_comp_cntr()oribv_set_err_comp_cntr(). Otherwise, concurrent updates may be lost. Protect your peace and your counter values. π«Ά
π SEE ALSO π
ibv_query_comp_cntr_caps(3)ibv_qp_attach_comp_cntr(3)efadv_create_comp_cntr(3)ibv_create_cq(3)ibv_create_cq_ex(3)ibv_create_qp(3)
π AUTHORS π
Michael Margolin mrgolin@amazon.com
mwah π β this page came from libibverbs, dated 2026-02-09. slay and stay hydrated. πβ¨
π¦ where this page comes from
- arch rolling: rdma-core 65.0-1 Β· GPL-2.0-or-later OR LicenseRef-OpenIB.org-BSD-MIT AND GPL-2.0-or-later OR LicenseRef-OpenIB.org-BSD-FreeBSD AND GPL-2.0-or-later OR LicenseRef-Intel-BSD-3-Clause AND GPL-2.0-or-later OR LicenseRef-PathScale-BSD-Patent-License AND CC0-1.0 AND MIT AND BSD-2-Clause AND CPL-1.0 OR BSD-2-Clause OR GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms