ibv_qp_a...comp_cntr(3)

πŸ“¦
version 65.0 Β· 2 versions
, in arch rolling

πŸ’… ibv_qp_attach_comp_cntr β€” NAME ✨

okay so bestie, welcome to the ibv_qp_attach_comp_cntr page from the Libibverbs Programmer's Manual (yes, that's the manual name, we're fancy here πŸŽ€). The whole vibe of this function? Attach a completion counter to a QP. That's it, that's the tweet. πŸ¦‹


🌸 SYNOPSIS 🌸

#include <infiniband/verbs.h>

int ibv_qp_attach_comp_cntr(struct ibv_qp *qp,
                            struct ibv_comp_cntr *comp_cntr,
                            struct ibv_qp_attach_comp_cntr_attr *attr);

✨ DESCRIPTION ✨

So ibv_qp_attach_comp_cntr() does exactly what it says on the tin: it attaches the completion counter comp_cntr to the queue pair qp. And the attr argument? That's the little icon that tells it which operation types should update the counter. iykyk πŸ’–

🚨 vibe check on the QP state, bestie: the QP must be in IBV_QPS_RESET or IBV_QPS_INIT state when you attach a completion counter. Try to attach to a QP in literally any other state and it will fail with EINVAL. no cap, it's not gonna work 😭

The completion counter starts collecting values for the specified QP once attached. And here's the cute part β€” attaching the same completion counter to multiple QPs will accumulate values from all attached QPs into the same counter. it's giving "sharing is caring" 🫢

The op_mask field is the main character here β€” it controls which operation completions get counted:

  • Local operations β€” IBV_QP_ATTACH_COMP_CNTR_OP_SEND, IBV_QP_ATTACH_COMP_CNTR_OP_RECV, IBV_QP_ATTACH_COMP_CNTR_OP_RDMA_READ, IBV_QP_ATTACH_COMP_CNTR_OP_RDMA_WRITE β€” count completions initiated by the local QP.
  • Remote operations β€” IBV_QP_ATTACH_COMP_CNTR_OP_REMOTE_RDMA_READ, IBV_QP_ATTACH_COMP_CNTR_OP_REMOTE_RDMA_WRITE β€” count completions of incoming RDMA operations initiated by the remote side. 🌈

Supported op_mask values may vary by device and can be queried using ibv_query_comp_cntr_caps(3); unsupported values will result in an ENOTSUP error. so like, check before you commit, bestie πŸ™ˆ

Multiple completion counters can be attached to the same QP β€” provided their op_mask values do not overlap. Each QP and operation type pair can be associated with at most one completion counter. Attempting to attach a counter with an op_mask that conflicts with an already attached counter will fail. πŸ’€

And the tea on detaching: there is no explicit detach operation. A completion counter is implicitly detached when the QP it is attached to is destroyed. Also β€” a completion counter cannot be destroyed while it is still attached to any QP. The QP must be destroyed first. periodt. πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

  • qp β€” The queue pair to attach the completion counter to. your fave QP πŸ’œ
  • comp_cntr β€” The completion counter to attach, previously created with ibv_create_comp_cntr(). gotta make it first, babe ✨
  • attr β€” Attach attributes specifying which operation types update the counter.

🧚 ibv_qp_attach_comp_cntr_attr 🧚

enum ibv_qp_attach_comp_cntr_op {
    IBV_QP_ATTACH_COMP_CNTR_OP_SEND                    = 1 << 0,
    IBV_QP_ATTACH_COMP_CNTR_OP_RECV                    = 1 << 1,
    IBV_QP_ATTACH_COMP_CNTR_OP_RDMA_READ               = 1 << 2,
    IBV_QP_ATTACH_COMP_CNTR_OP_REMOTE_RDMA_READ        = 1 << 3,
    IBV_QP_ATTACH_COMP_CNTR_OP_RDMA_WRITE              = 1 << 4,
    IBV_QP_ATTACH_COMP_CNTR_OP_REMOTE_RDMA_WRITE       = 1 << 5,
};

struct ibv_qp_attach_comp_cntr_attr {
    uint32_t comp_mask;
    uint32_t op_mask;
};
  • comp_mask β€” Bitmask specifying what fields in the structure are valid. It's used for extensibility, so it should be set to 0. keep it zero, bestie, it's not that deep πŸ“
  • op_mask β€” Bitmask of ibv_qp_attach_comp_cntr_op values specifying which operation types should update the counter. the important one πŸ’…

⭐ RETURN VALUE ⭐

ibv_qp_attach_comp_cntr() returns 0 on success, or the value of errno on failure (which indicates the failure reason). slay when it's 0 πŸ’–


πŸ”₯ ERRORS πŸ”₯

  • EINVAL β€” Invalid argument(s) passed. πŸ’€
  • ENOTSUP β€” Requested operation is not supported on this device. your device said "not today" 😭
  • EBUSY β€” The op_mask overlaps with a completion counter already attached to this QP. someone else got there first πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘

ibv_create_comp_cntr(3), ibv_query_comp_cntr_caps(3), ibv_create_qp(3)


πŸ¦‹ AUTHORS πŸ¦‹

Michael Margolin mrgolin@amazon.com


okay that's the whole page, bestie, you ate that 🫢✨ shoutout to libibverbs, dated 2026-02-09 β€” and yes, the footer says ibv_qp_a...comp_cntr(3) too, we love a consistent icon πŸ’…πŸŽ€

πŸ“¦ 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