drivers/infiniband/hw/hfi1/netdev_rx.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/hfi1/netdev_rx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/hfi1/netdev_rx.c- Extension
.c- Size
- 11507 bytes
- Lines
- 487
- 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.
- 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
sdma.hverbs.hnetdev.hhfi.hlinux/netdevice.hlinux/etherdevice.hrdma/ib_verbs.h
Detected Declarations
function Copyrightfunction hfi1_netdev_allocate_ctxtfunction hfi1_netdev_deallocate_ctxtfunction hfi1_netdev_allot_ctxtfunction hfi1_num_netdev_contextsfunction hfi1_netdev_rxq_initfunction hfi1_netdev_rxq_deinitfunction enable_queuesfunction disable_queuesfunction hfi1_netdev_rx_initfunction hfi1_netdev_rx_destroyfunction hfi1_alloc_rxfunction hfi1_free_rxfunction hfi1_netdev_enable_queuesfunction hfi1_netdev_disable_queuesfunction hfi1_netdev_add_data
Annotated Snippet
if (rxq->rcd) {
hfi1_netdev_deallocate_ctxt(dd, rxq->rcd);
hfi1_rcd_put(rxq->rcd);
rxq->rcd = NULL;
}
}
kfree(rx->rxq);
rx->rxq = NULL;
return rc;
}
static void hfi1_netdev_rxq_deinit(struct hfi1_netdev_rx *rx)
{
int i;
struct hfi1_devdata *dd = rx->dd;
for (i = 0; i < rx->num_rx_q; i++) {
struct hfi1_netdev_rxq *rxq = &rx->rxq[i];
netif_napi_del(&rxq->napi);
hfi1_netdev_deallocate_ctxt(dd, rxq->rcd);
hfi1_rcd_put(rxq->rcd);
rxq->rcd = NULL;
}
kfree(rx->rxq);
rx->rxq = NULL;
rx->num_rx_q = 0;
}
static void enable_queues(struct hfi1_netdev_rx *rx)
{
int i;
for (i = 0; i < rx->num_rx_q; i++) {
struct hfi1_netdev_rxq *rxq = &rx->rxq[i];
dd_dev_info(rx->dd, "enabling queue %d on context %d\n", i,
rxq->rcd->ctxt);
napi_enable(&rxq->napi);
hfi1_rcvctrl(rx->dd,
HFI1_RCVCTRL_CTXT_ENB | HFI1_RCVCTRL_INTRAVAIL_ENB,
rxq->rcd);
}
}
static void disable_queues(struct hfi1_netdev_rx *rx)
{
int i;
msix_netdev_synchronize_irq(rx->dd);
for (i = 0; i < rx->num_rx_q; i++) {
struct hfi1_netdev_rxq *rxq = &rx->rxq[i];
dd_dev_info(rx->dd, "disabling queue %d on context %d\n", i,
rxq->rcd->ctxt);
/* wait for napi if it was scheduled */
hfi1_rcvctrl(rx->dd,
HFI1_RCVCTRL_CTXT_DIS | HFI1_RCVCTRL_INTRAVAIL_DIS,
rxq->rcd);
napi_synchronize(&rxq->napi);
napi_disable(&rxq->napi);
}
}
/**
* hfi1_netdev_rx_init - Incrememnts netdevs counter. When called first time,
* it allocates receive queue data and calls netif_napi_add
* for each queue.
*
* @dd: hfi1 dev data
*/
int hfi1_netdev_rx_init(struct hfi1_devdata *dd)
{
struct hfi1_netdev_rx *rx = dd->netdev_rx;
int res;
if (atomic_fetch_inc(&rx->netdevs))
return 0;
mutex_lock(&hfi1_mutex);
res = hfi1_netdev_rxq_init(rx);
mutex_unlock(&hfi1_mutex);
return res;
}
/**
Annotation
- Immediate include surface: `sdma.h`, `verbs.h`, `netdev.h`, `hfi.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `rdma/ib_verbs.h`.
- Detected declarations: `function Copyright`, `function hfi1_netdev_allocate_ctxt`, `function hfi1_netdev_deallocate_ctxt`, `function hfi1_netdev_allot_ctxt`, `function hfi1_num_netdev_contexts`, `function hfi1_netdev_rxq_init`, `function hfi1_netdev_rxq_deinit`, `function enable_queues`, `function disable_queues`, `function hfi1_netdev_rx_init`.
- 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.
- 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.