drivers/infiniband/sw/siw/siw_qp.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/sw/siw/siw_qp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/sw/siw/siw_qp.c- Extension
.c- Size
- 32481 bytes
- Lines
- 1319
- 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.
- 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/errno.hlinux/types.hlinux/net.hlinux/scatterlist.hlinux/llist.hasm/barrier.hnet/tcp.htrace/events/sock.hsiw.hsiw_verbs.hsiw_mem.h
Detected Declarations
function siw_qp_llp_data_readyfunction siw_qp_llp_closefunction siw_qp_llp_write_spacefunction siw_qp_readq_initfunction siw_qp_mpa_rtsfunction siw_tagged_errorfunction siw_rdmap_errorfunction siw_init_terminatefunction siw_send_terminatefunction siw_qp_modify_nonstatefunction siw_qp_nextstate_from_idlefunction siw_qp_nextstate_from_rtsfunction siw_qp_nextstate_from_termfunction siw_qp_nextstate_from_closefunction siw_qp_modifyfunction siw_read_to_orqfunction siw_activate_tx_from_sqfunction siw_activate_txfunction siw_cq_notify_nowfunction siw_sqe_completefunction siw_rqe_completefunction siw_sq_flushfunction siw_rq_flushfunction rx_typefunction siw_qp_addfunction siw_free_qp
Annotated Snippet
down_read_trylock(&qp->state_lock))) {
read_descriptor_t rd_desc = { .arg.data = qp, .count = 1 };
if (likely(qp->attrs.state == SIW_QP_STATE_RTS))
/*
* Implements data receive operation during
* socket callback. TCP gracefully catches
* the case where there is nothing to receive
* (not calling siw_tcp_rx_data() then).
*/
tcp_read_sock(sk, &rd_desc, siw_tcp_rx_data);
up_read(&qp->state_lock);
} else {
siw_dbg_qp(qp, "unable to process RX, suspend: %d\n",
qp->rx_stream.rx_suspend);
}
done:
read_unlock(&sk->sk_callback_lock);
}
void siw_qp_llp_close(struct siw_qp *qp)
{
siw_dbg_qp(qp, "enter llp close, state = %s\n",
siw_qp_state_to_string[qp->attrs.state]);
down_write(&qp->state_lock);
qp->rx_stream.rx_suspend = 1;
qp->tx_ctx.tx_suspend = 1;
qp->attrs.sk = NULL;
switch (qp->attrs.state) {
case SIW_QP_STATE_RTS:
case SIW_QP_STATE_RTR:
case SIW_QP_STATE_IDLE:
case SIW_QP_STATE_TERMINATE:
qp->attrs.state = SIW_QP_STATE_ERROR;
break;
/*
* SIW_QP_STATE_CLOSING:
*
* This is a forced close. shall the QP be moved to
* ERROR or IDLE ?
*/
case SIW_QP_STATE_CLOSING:
if (tx_wqe(qp)->wr_status == SIW_WR_IDLE)
qp->attrs.state = SIW_QP_STATE_ERROR;
else
qp->attrs.state = SIW_QP_STATE_IDLE;
break;
default:
siw_dbg_qp(qp, "llp close: no state transition needed: %s\n",
siw_qp_state_to_string[qp->attrs.state]);
break;
}
siw_sq_flush(qp);
siw_rq_flush(qp);
/*
* Dereference closing CEP
*/
if (qp->cep) {
siw_cep_put(qp->cep);
qp->cep = NULL;
}
up_write(&qp->state_lock);
siw_dbg_qp(qp, "llp close exit: state %s\n",
siw_qp_state_to_string[qp->attrs.state]);
}
/*
* socket callback routine informing about newly available send space.
* Function schedules SQ work for processing SQ items.
*/
void siw_qp_llp_write_space(struct sock *sk)
{
struct siw_cep *cep;
read_lock(&sk->sk_callback_lock);
cep = sk_to_cep(sk);
if (cep) {
cep->sk_write_space(sk);
if (!test_bit(SOCK_NOSPACE, &sk->sk_socket->flags))
(void)siw_sq_start(cep->qp);
Annotation
- Immediate include surface: `linux/errno.h`, `linux/types.h`, `linux/net.h`, `linux/scatterlist.h`, `linux/llist.h`, `asm/barrier.h`, `net/tcp.h`, `trace/events/sock.h`.
- Detected declarations: `function siw_qp_llp_data_ready`, `function siw_qp_llp_close`, `function siw_qp_llp_write_space`, `function siw_qp_readq_init`, `function siw_qp_mpa_rts`, `function siw_tagged_error`, `function siw_rdmap_error`, `function siw_init_terminate`, `function siw_send_terminate`, `function siw_qp_modify_nonstate`.
- 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.