drivers/infiniband/hw/hfi1/driver.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/hfi1/driver.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/hfi1/driver.c- Extension
.c- Size
- 50139 bytes
- Lines
- 1906
- 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/spinlock.hlinux/pci.hlinux/io.hlinux/delay.hlinux/netdevice.hlinux/vmalloc.hlinux/module.hlinux/prefetch.hrdma/ib_verbs.hlinux/etherdevice.hhfi.htrace.hqp.hsdma.hdebugfs.hfault.hipoib.hnetdev.h
Detected Declarations
struct ps_mdatafunction hfi1_caps_setfunction hfi1_caps_getfunction hfi1_count_active_unitsfunction hfi1_rcvbuf_validatefunction rcv_hdrerrfunction init_packetfunction setfunction init_ps_mdatafunction ps_donefunction ps_skipfunction update_ps_mdatafunction __prescan_rxqfunction process_rcv_qp_workfunction max_packet_exceededfunction check_max_packetfunction skip_rcv_packetfunction process_rcv_packet_napifunction process_rcv_packetfunction process_rcv_updatefunction finish_packetfunction handle_receive_interrupt_napi_fpfunction handle_receive_interrupt_nodma_rtailfunction handle_receive_interrupt_dma_rtailfunction set_all_fastpathfunction set_all_slowpathfunction __set_armed_to_activefunction set_armed_to_activefunction handle_receive_interruptfunction handle_receive_interrupt_napi_spfunction ACTIVEfunction mtu_to_enumfunction enum_to_mtufunction set_mtufunction hfi1_set_lidfunction shutdown_led_overridefunction run_led_overridefunction shutdown_led_overridefunction hfi1_reset_devicefunction hfi1_setup_ib_headerfunction hfi1_bypass_ingress_pkt_checkfunction opa_get_lidfunction hfi1_setup_9B_packetfunction hfi1_setup_bypass_packetfunction show_eflags_errsfunction handle_eflagsfunction hfi1_ipoib_ib_rcvfunction process_receive_ib
Annotated Snippet
struct ps_mdata {
struct hfi1_ctxtdata *rcd;
u32 rsize;
u32 maxcnt;
u32 ps_head;
u32 ps_tail;
u32 ps_seq;
};
static inline void init_ps_mdata(struct ps_mdata *mdata,
struct hfi1_packet *packet)
{
struct hfi1_ctxtdata *rcd = packet->rcd;
mdata->rcd = rcd;
mdata->rsize = packet->rsize;
mdata->maxcnt = packet->maxcnt;
mdata->ps_head = packet->rhqoff;
if (get_dma_rtail_setting(rcd)) {
mdata->ps_tail = get_rcvhdrtail(rcd);
if (rcd->ctxt == HFI1_CTRL_CTXT)
mdata->ps_seq = hfi1_seq_cnt(rcd);
else
mdata->ps_seq = 0; /* not used with DMA_RTAIL */
} else {
mdata->ps_tail = 0; /* used only with DMA_RTAIL*/
mdata->ps_seq = hfi1_seq_cnt(rcd);
}
}
static inline int ps_done(struct ps_mdata *mdata, u64 rhf,
struct hfi1_ctxtdata *rcd)
{
if (get_dma_rtail_setting(rcd))
return mdata->ps_head == mdata->ps_tail;
return mdata->ps_seq != rhf_rcv_seq(rhf);
}
static inline int ps_skip(struct ps_mdata *mdata, u64 rhf,
struct hfi1_ctxtdata *rcd)
{
/*
* Control context can potentially receive an invalid rhf.
* Drop such packets.
*/
if ((rcd->ctxt == HFI1_CTRL_CTXT) && (mdata->ps_head != mdata->ps_tail))
return mdata->ps_seq != rhf_rcv_seq(rhf);
return 0;
}
static inline void update_ps_mdata(struct ps_mdata *mdata,
struct hfi1_ctxtdata *rcd)
{
mdata->ps_head += mdata->rsize;
if (mdata->ps_head >= mdata->maxcnt)
mdata->ps_head = 0;
/* Control context must do seq counting */
if (!get_dma_rtail_setting(rcd) ||
rcd->ctxt == HFI1_CTRL_CTXT)
mdata->ps_seq = hfi1_seq_incr_wrap(mdata->ps_seq);
}
/*
* prescan_rxq - search through the receive queue looking for packets
* containing Excplicit Congestion Notifications (FECNs, or BECNs).
* When an ECN is found, process the Congestion Notification, and toggle
* it off.
* This is declared as a macro to allow quick checking of the port to avoid
* the overhead of a function call if not enabled.
*/
#define prescan_rxq(rcd, packet) \
do { \
if (rcd->ppd->cc_prescan) \
__prescan_rxq(packet); \
} while (0)
static void __prescan_rxq(struct hfi1_packet *packet)
{
struct hfi1_ctxtdata *rcd = packet->rcd;
struct ps_mdata mdata;
init_ps_mdata(&mdata, packet);
while (1) {
struct hfi1_ibport *ibp = rcd_to_iport(rcd);
__le32 *rhf_addr = (__le32 *)rcd->rcvhdrq + mdata.ps_head +
packet->rcd->rhf_offset;
struct rvt_qp *qp;
Annotation
- Immediate include surface: `linux/spinlock.h`, `linux/pci.h`, `linux/io.h`, `linux/delay.h`, `linux/netdevice.h`, `linux/vmalloc.h`, `linux/module.h`, `linux/prefetch.h`.
- Detected declarations: `struct ps_mdata`, `function hfi1_caps_set`, `function hfi1_caps_get`, `function hfi1_count_active_units`, `function hfi1_rcvbuf_validate`, `function rcv_hdrerr`, `function init_packet`, `function set`, `function init_ps_mdata`, `function ps_done`.
- 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.