drivers/infiniband/ulp/rtrs/rtrs.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/ulp/rtrs/rtrs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/ulp/rtrs/rtrs.c- Extension
.c- Size
- 15576 bytes
- Lines
- 649
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/inet.hrtrs-pri.hrtrs-log.h
Detected Declarations
function voidfunction rtrs_iu_freefunction rtrs_iu_post_recvfunction rtrs_post_recv_emptyfunction rtrs_post_sendfunction rtrs_iu_post_sendfunction rtrs_iu_post_rdma_write_immfunction rtrs_post_rdma_write_imm_emptyfunction qp_event_handlerfunction is_pollqueuefunction create_cqfunction create_qpfunction destroy_cqfunction rtrs_cq_qp_createfunction rtrs_cq_qp_destroyfunction schedule_hbfunction rtrs_send_hb_ackfunction hb_workfunction rtrs_init_hbfunction rtrs_start_hbfunction rtrs_stop_hbfunction rtrs_str_gid_to_sockaddrfunction rtrs_str_to_sockaddrfunction sockaddr_to_strfunction rtrs_addr_to_strfunction rtrs_addr_to_sockaddrfunction rtrs_rdma_dev_pd_initfunction rtrs_rdma_dev_pd_deinitfunction dev_freefunction rtrs_ib_dev_putfunction rtrs_ib_dev_getfunction rtrs_ib_dev_find_or_addexport rtrs_iu_allocexport rtrs_iu_freeexport rtrs_iu_post_recvexport rtrs_post_recv_emptyexport rtrs_iu_post_sendexport rtrs_iu_post_rdma_write_immexport rtrs_cq_qp_createexport rtrs_cq_qp_destroyexport rtrs_send_hb_ackexport rtrs_init_hbexport rtrs_start_hbexport rtrs_stop_hbexport sockaddr_to_strexport rtrs_addr_to_strexport rtrs_addr_to_sockaddrexport rtrs_rdma_dev_pd_init
Annotated Snippet
if (ib_dma_mapping_error(dma_dev, iu->dma_addr)) {
kfree(iu->buf);
goto err;
}
iu->cqe.done = done;
iu->size = size;
}
return ius;
err:
rtrs_iu_free(ius, dma_dev, i);
return NULL;
}
EXPORT_SYMBOL_GPL(rtrs_iu_alloc);
void rtrs_iu_free(struct rtrs_iu *ius, struct ib_device *ibdev, u32 queue_num)
{
struct rtrs_iu *iu;
int i;
if (!ius)
return;
for (i = 0; i < queue_num; i++) {
iu = &ius[i];
ib_dma_unmap_single(ibdev, iu->dma_addr, iu->size, iu->direction);
kfree(iu->buf);
}
kfree(ius);
}
EXPORT_SYMBOL_GPL(rtrs_iu_free);
int rtrs_iu_post_recv(struct rtrs_con *con, struct rtrs_iu *iu)
{
struct rtrs_path *path = con->path;
struct ib_recv_wr wr;
struct ib_sge list;
list.addr = iu->dma_addr;
list.length = iu->size;
list.lkey = path->dev->ib_pd->local_dma_lkey;
if (list.length == 0) {
rtrs_wrn(con->path,
"Posting receive work request failed, sg list is empty\n");
return -EINVAL;
}
wr = (struct ib_recv_wr) {
.wr_cqe = &iu->cqe,
.sg_list = &list,
.num_sge = 1,
};
return ib_post_recv(con->qp, &wr, NULL);
}
EXPORT_SYMBOL_GPL(rtrs_iu_post_recv);
int rtrs_post_recv_empty(struct rtrs_con *con, struct ib_cqe *cqe)
{
struct ib_recv_wr wr;
wr = (struct ib_recv_wr) {
.wr_cqe = cqe,
};
return ib_post_recv(con->qp, &wr, NULL);
}
EXPORT_SYMBOL_GPL(rtrs_post_recv_empty);
static int rtrs_post_send(struct ib_qp *qp, struct ib_send_wr *head,
struct ib_send_wr *wr, struct ib_send_wr *tail)
{
if (head) {
struct ib_send_wr *next = head;
while (next->next)
next = next->next;
next->next = wr;
} else {
head = wr;
}
if (tail)
wr->next = tail;
return ib_post_send(qp, head, NULL);
}
int rtrs_iu_post_send(struct rtrs_con *con, struct rtrs_iu *iu, size_t size,
struct ib_send_wr *head)
Annotation
- Immediate include surface: `linux/module.h`, `linux/inet.h`, `rtrs-pri.h`, `rtrs-log.h`.
- Detected declarations: `function void`, `function rtrs_iu_free`, `function rtrs_iu_post_recv`, `function rtrs_post_recv_empty`, `function rtrs_post_send`, `function rtrs_iu_post_send`, `function rtrs_iu_post_rdma_write_imm`, `function rtrs_post_rdma_write_imm_empty`, `function qp_event_handler`, `function is_pollqueue`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.