IBV_POST_SRQ_RECV(3)

πŸ’– ibv_post_srq_recv β€” the Libibverbs Programmer's Manual, bestie edition πŸ’–

okay so picture this: you've got a shared receive queue (SRQ for short, we're all friends here) and you need to feed it a whole lil linked list of work requests. that's literally this function. ibv_post_srq_recv(3) is the moment. let's get into it 🫢


✨ NAME ✨

ibv_post_srq_recv β€” post a list of work requests (WRs) to a shared receive queue (SRQ)


🌸 SYNOPSIS 🌸

#include <infiniband/verbs.h>

int ibv_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr,
                      struct ibv_recv_wr **bad_wr);

πŸ¦‹ DESCRIPTION πŸ¦‹

so ibv_post_srq_recv() takes that linked list of work requests (WRs) β€” starting with wr β€” and posts the whole thing to the shared receive queue (SRQ) called srq. it's giving assembly line, it's giving "i have a to-do list and i'm doing it".

but β€” and this is important β€” it stops processing WRs from the list at the first failure (the kind that can be detected immediately while the requests are being posted), and it hands you back that failing WR through bad_wr. so like, it doesn't ghost you, it tells you exactly where things went sideways 😭

the wr argument is an ibv_recv_wr struct, as defined in <infiniband/verbs.h>. here's the fit:

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 because every WR needs somewhere to actually put the data, here's the scatter/gather element situation too:

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 */
};

iconic structs. no notes. πŸ’…


πŸ”₯ RETURN VALUE πŸ”₯

ibv_post_srq_recv() returns 0 on success β€” slay β€” or the value of errno on failure (which is the universe telling you the failure reason, very helpful of it).


πŸ‘‘ NOTES πŸ‘‘

bestie listen. 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 touch those buffers early. i'm serious. don't. πŸ™ˆ

and one more thing, this one's a lil spicy: if a WR is being posted to a UD QP, the Global Routing Header (GRH) of the incoming message will be placed in the first 40 bytes of the buffer(s) in the scatter list. if no GRH is present in the incoming message, then the first bytes will be undefined. which means β€” in all cases β€” the actual data of the incoming message will start at an offset of 40 bytes into the buffer(s) in the scatter list. so yes, 40. always 40. write it down. ⭐


🌈 SEE ALSO 🌈

the whole friend group fr fr 🧚


πŸŽ€ AUTHORS πŸŽ€

Dotan Barak <dotanba@gmail.com> β€” king behavior honestly πŸ‘‘


and that's the page, bestie!! this was libibverbs, dated 2006-10-31, and it ate. periodt. πŸ’œβœ¨

πŸ“¦ where this page comes from