drivers/infiniband/hw/hfi1/rc.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/hfi1/rc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/hfi1/rc.c- Extension
.c- Size
- 91600 bytes
- Lines
- 3245
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/io.hrdma/rdma_vt.hrdma/rdmavt_qp.hhfi.hqp.hrc.hverbs_txreq.htrace.h
Detected Declarations
function Copyrightfunction make_rc_ackfunction OPfunction hfi1_make_rc_reqfunction statesfunction hfi1_make_bth_aethfunction hfi1_queue_rc_ackfunction hfi1_make_rc_ack_9Bfunction hfi1_make_rc_ack_16Bfunction hfi1_rc_rcvfunction reset_psnfunction hfi1_rc_rcvfunction hfi1_make_rc_reqfunction hfi1_restart_rcfunction reset_sending_psnfunction hfi1_rc_verbs_abortedfunction hfi1_rc_send_completefunction cmp_psnfunction update_last_psnfunction cmp_psnfunction set_restart_qpfunction update_qp_retry_statefunction rc_rcv_respfunction rdma_seq_errfunction hfi1_rc_rcvfunction rc_cancel_ackfunction rc_rcv_errorfunction log_cca_eventfunction process_becnfunction qp_rcvfunction responsesfunction hfi1_rc_hdrerr
Annotated Snippet
if (p == qp->r_head_ack_queue) {
e = NULL;
break;
}
e = &qp->s_ack_queue[p];
if (!e->opcode) {
e = NULL;
break;
}
if (cmp_psn(psn, e->psn) >= 0) {
if (p == qp->s_tail_ack_queue &&
cmp_psn(psn, e->lpsn) <= 0)
s = false;
break;
}
}
if (prev)
*prev = p;
if (prev_ack)
*prev_ack = i;
if (scheduled)
*scheduled = s;
return e;
}
/**
* make_rc_ack - construct a response packet (ACK, NAK, or RDMA read)
* @dev: the device for this QP
* @qp: a pointer to the QP
* @ohdr: a pointer to the IB header being constructed
* @ps: the xmit packet state
*
* Return 1 if constructed; otherwise, return 0.
* Note that we are in the responder's side of the QP context.
* Note the QP s_lock must be held.
*/
static int make_rc_ack(struct hfi1_ibdev *dev, struct rvt_qp *qp,
struct ib_other_headers *ohdr,
struct hfi1_pkt_state *ps)
{
struct rvt_ack_entry *e;
u32 hwords, hdrlen;
u32 len = 0;
u32 bth0 = 0, bth2 = 0;
u32 bth1 = qp->remote_qpn | (HFI1_CAP_IS_KSET(OPFN) << IB_BTHE_E_SHIFT);
int middle = 0;
u32 pmtu = qp->pmtu;
struct hfi1_qp_priv *qpriv = qp->priv;
bool last_pkt;
u32 delta;
u8 next = qp->s_tail_ack_queue;
struct tid_rdma_request *req;
trace_hfi1_rsp_make_rc_ack(qp, 0);
lockdep_assert_held(&qp->s_lock);
/* Don't send an ACK if we aren't supposed to. */
if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_RECV_OK))
goto bail;
if (qpriv->hdr_type == HFI1_PKT_TYPE_9B)
/* header size in 32-bit words LRH+BTH = (8+12)/4. */
hwords = 5;
else
/* header size in 32-bit words 16B LRH+BTH = (16+12)/4. */
hwords = 7;
switch (qp->s_ack_state) {
case OP(RDMA_READ_RESPONSE_LAST):
case OP(RDMA_READ_RESPONSE_ONLY):
e = &qp->s_ack_queue[qp->s_tail_ack_queue];
release_rdma_sge_mr(e);
fallthrough;
case OP(ATOMIC_ACKNOWLEDGE):
/*
* We can increment the tail pointer now that the last
* response has been sent instead of only being
* constructed.
*/
if (++next > rvt_size_atomic(&dev->rdi))
next = 0;
/*
* Only advance the s_acked_ack_queue pointer if there
* have been no TID RDMA requests.
*/
e = &qp->s_ack_queue[qp->s_tail_ack_queue];
if (e->opcode != TID_OP(WRITE_REQ) &&
qp->s_acked_ack_queue == qp->s_tail_ack_queue)
qp->s_acked_ack_queue = next;
qp->s_tail_ack_queue = next;
trace_hfi1_rsp_make_rc_ack(qp, e->psn);
Annotation
- Immediate include surface: `linux/io.h`, `rdma/rdma_vt.h`, `rdma/rdmavt_qp.h`, `hfi.h`, `qp.h`, `rc.h`, `verbs_txreq.h`, `trace.h`.
- Detected declarations: `function Copyright`, `function make_rc_ack`, `function OP`, `function hfi1_make_rc_req`, `function states`, `function hfi1_make_bth_aeth`, `function hfi1_queue_rc_ack`, `function hfi1_make_rc_ack_9B`, `function hfi1_make_rc_ack_16B`, `function hfi1_rc_rcv`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.