IBV_POLL_CQ(3)
π IBV_POLL_CQ(3) π
okay bestie, welcome to the Libibverbs Programmer's Manual β¨ this one's the manual page for ibv_poll_cq, and honestly? it's giving "the main character of your verbs code" because literally nothing happens until you poll. let's get into it π«Ά
πΈ NAME πΈ
ibv_poll_cq β poll a completion queue (CQ)
β¨ SYNOPSIS β¨
#include <infiniband/verbs.h>
int ibv_poll_cq(struct ibv_cq *cq, int num_entries,
struct ibv_wc *wc);
π¦ DESCRIPTION π¦
so ibv_poll_cq() polls the CQ cq for work completions and hands you back the first num_entries of them (or, if the CQ has fewer than that many sitting there, it just gives you all of the available completions β no drama, no waiting around for more) in the array wc. the argument wc is a pointer to an array of ibv_wc structs, as defined in <infiniband/verbs.h>. iykyk π
and here's the iconic struct itself, verbatim, every field, no edits:
struct ibv_wc {
uint64_t wr_id; /* ID of the completed Work Request (WR) */
enum ibv_wc_status status; /* Status of the operation */
enum ibv_wc_opcode opcode; /* Operation type specified in the completed WR */
uint32_t vendor_err; /* Vendor error syndrome */
uint32_t byte_len; /* Number of bytes transferred */
union {
__be32 imm_data; /* Immediate data (in network byte order) */
uint32_t invalidated_rkey; /* Local RKey that was invalidated */
};
uint32_t qp_num; /* Local QP number of completed WR */
uint32_t src_qp; /* Source QP number (remote QP number) of completed WR (valid only for UD QPs) */
unsigned int wc_flags; /* Flags of the completed WR */
uint16_t pkey_index; /* P_Key index (valid only for GSI QPs) */
uint16_t slid; /* Source LID */
uint8_t sl; /* Service Level */
uint8_t dlid_path_bits; /* DLID path bits (not applicable for multicast messages) */
};
π the wc_flags situation π
the attribute wc_flags describes the properties of the work completion. it's either 0 or the bitwise OR of one or more of these flags, periodt:
IBV_WC_GRHβ GRH is present (valid only for UD QPs)IBV_WC_WITH_IMMβ Immediate data value is validIBV_WC_WITH_INVβ Invalidated RKey data value is valid (cannot be combined withIBV_WC_WITH_IMM)IBV_WC_IP_CSUM_OKβ TCP/UDP checksum over IPv4 and IPv4 header checksum are verified. Valid only whendevice_cap_flagsindevice_attrindicates current QP is supported by checksum offload.
π the important caveat π
not all wc attributes are always valid, bestie, and this part matters. if the completion status is anything other than IBV_WC_SUCCESS, then only these attributes are valid: wr_id, status, qp_num, and vendor_err. that's it. don't go reading the other fields, they're not giving what you think they're giving π
π RETURN VALUE π
on success, ibv_poll_cq() returns a non-negative value equal to the number of completions found. on failure, a negative value is returned. slay.
π NOTES π
each polled completion is removed from the CQ and cannot be returned to it. it's gone. it left the chat. π«‘
the user should consume work completions at a rate that prevents CQ overrun from occurrence. in case of a CQ overrun, the async event IBV_EVENT_CQ_ERR will be triggered, and the CQ cannot be used. yeah. that's a whole thing. keep up with your polls, fr fr.
IBV_WC_DRIVER1 will be reported as a response to IBV_WR_DRIVER1 opcode; IBV_WC_DRIVER2/IBV_WC_DRIVER3 will be reported on specific driver operations. β¨
π SEE ALSO π
π AUTHORS π
Dotan Barak <dotanba@gmail.com>
okay that's the whole page, you ate that π this was the libibverbs manual page, dated 2006-10-31, and yes she's been iconic since then. go poll your CQ and hydrate. bye bestie π
β¨
π¦ where this page comes from
- alpine 3.24: rdma-core-doc 61.0-r0 Β· GPL-2.0-only OR BSD-2-Clause
- 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
- centos-stream 10: rdma-core-devel 62.0-3.el10 Β· GPLv2 or BSD
- centos-stream 9: rdma-core-devel 61.0-3.el9 Β· GPLv2 or BSD
- centos-stream 9: rdma-core-devel 61.0-3.el9 Β· GPLv2 or BSD
- debian bookworm: libibverbs-dev 44.0-2 Β· BSD-MIT OR GPL-2.0-only
- debian trixie: libibverbs-dev 56.1-1 Β· BSD-MIT OR GPL-2.0-only
- fedora 43: rdma-core-devel 58.0-4.fc43 Β· GPL-2.0-only OR BSD-2-Clause AND BSD-3-Clause
- fedora 43: rdma-core-devel 58.0-4.fc43 Β· GPL-2.0-only OR BSD-2-Clause AND BSD-3-Clause
- fedora 44: rdma-core-devel 61.0-2.fc44 Β· GPL-2.0-only OR BSD-2-Clause AND BSD-3-Clause
- fedora 44: rdma-core-devel 61.0-2.fc44 Β· GPL-2.0-only OR BSD-2-Clause AND BSD-3-Clause
- fedora 44: rdma-core-devel 61.1^20260812git975bdaf-1.fc44 Β· GPL-2.0-only OR BSD-2-Clause AND BSD-3-Clause
- fedora 44: rdma-core-devel 61.1^20260812git975bdaf-1.fc44 Β· GPL-2.0-only OR BSD-2-Clause AND BSD-3-Clause
- nixos 26.05: rdma-core 62.0
- nixpkgs unstable: rdma-core 65.0
- opensuse-leap 16.0: rdma-core-devel 56.1-160000.2.2 Β· BSD-2-Clause OR GPL-2.0-only
- opensuse-leap 16.0: rdma-core-devel 56.1-160000.2.2 Β· BSD-2-Clause OR GPL-2.0-only
- opensuse-leap 16.0: rdma-core-devel 56.1-160000.2.2 Β· BSD-2-Clause OR GPL-2.0-only
- opensuse-leap 16.0: rdma-core-devel 56.1-160000.2.2 Β· BSD-2-Clause OR GPL-2.0-only
- ubuntu jammy: libibverbs-dev 39.0-1 Β· BSD-MIT OR GPL-2.0-only
- ubuntu noble: libibverbs-dev 50.0-2build2 Β· BSD-MIT OR GPL-2.0-only
- ubuntu noble: libibverbs-dev 50.0-2ubuntu0.2 Β· BSD-MIT OR GPL-2.0-only
- ubuntu questing: libibverbs-dev 56.1-1ubuntu1
- ubuntu resolute: libibverbs-dev 61.0-2ubuntu3 Β· BSD-MIT OR GPL-2.0-only
- ubuntu stonking: libibverbs-dev 64.0-1ubuntu1 Β· BSD-MIT OR GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms