IBV_POST_RECV(3)

πŸ’– IBV_POST_RECV πŸ’–

okay bestie, pull up a chair, we're doing a libibverbs manpage from the Libibverbs Programmer's Manual and honestly? it's a bop.


✨ NAME ✨

ibv_post_recv β€” post a list of work requests (WRs) to a receive queue 🫢


🌸 SYNOPSIS 🌸

#include <infiniband/verbs.h>

int ibv_post_recv(struct ibv_qp *qp, struct ibv_recv_wr *wr,
                  struct ibv_recv_wr **bad_wr);

πŸŽ€ DESCRIPTION πŸŽ€

so ibv_post_recv() takes a linked list of work requests (WRs) β€” starting with wr, obviously β€” and posts them to the receive queue of the queue pair qp. it's giving "here's my to-do list, please handle it" πŸ’…

and like, the second something fails β€” meaning the failure is detectable immediately, right there while the requests are being posted β€” it stops processing WRs from the list. no cap. then it hands you back the failing WR through bad_wr so you know exactly which one was the problem child πŸ™ˆ

the argument wr is an ibv_recv_wr struct, as defined in <infiniband/verbs.h>. and here's what that bad boy looks like:

struct ibv_recv_wr {
        uint64_t                wr_id;     /* User defined WR ID */
        struct ibv_recv_wr     *next;      /* Pointer to next WR in list, NULL if last WR */
        struct ibv_sge         *sg_list;   /* Pointer to the s/g array */
        int                     num_sge;   /* Size of the s/g array */
};

and the scatter/gather entries inside it, the little icons of the operation:

struct ibv_sge {
        uint64_t                addr;      /* Start address of the local memory buffer */
        uint32_t                length;    /* Length of the buffer */
        uint32_t                lkey;      /* Key of the local Memory Region */
};

⭐ RETURN VALUE ⭐

ibv_post_recv() returns 0 on success πŸŽ‰ or the value of errno on failure (which tells you why it flopped, bestie).


πŸ’€ NOTES πŸ’€

  • the buffers used by a WR can only be safely reused after the WR request is fully executed and a work completion has been retrieved from the corresponding completion queue (CQ). do not skip this. do not get cute with it. wait for the completion. 😭
  • if the QP qp is associated with a shared receive queue, you must use ibv_post_srq_recv() and not ibv_post_recv(), because the QP's own receive queue will not be used. periodt. πŸ’…
  • if a WR is being posted to a UD QP, the Global Routing Header (GRH) of the incoming message gets placed in the first 40 bytes of the buffer(s) in the scatter list. if there's no GRH in the incoming message, then those first bytes are undefined β€” like, genuinely undefined, don't trust them πŸ™ˆ. which means in all cases, the actual data of the incoming message starts at an offset of 40 bytes into the buffer(s) in the scatter list. forty. every time. iykyk. πŸ”₯

🌈 SEE ALSO 🌈


πŸ‘‘ AUTHORS πŸ‘‘

Dotan Barak <dotanba@gmail.com> β€” icon, legend, the moment ✨


and that's the whole thing bestie!! this page is from libibverbs, dated 2006-10-31</>, and it's literally IBV_POST_RECV(3) all the way down. go post some receives, you absolute main character πŸ¦‹πŸ’–

πŸ“¦ where this page comes from