drivers/net/ethernet/fungible/funeth/funeth_rx.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/fungible/funeth/funeth_rx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/fungible/funeth/funeth_rx.c- Extension
.c- Size
- 23021 bytes
- Lines
- 829
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- 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/bpf_trace.hlinux/dma-mapping.hlinux/etherdevice.hlinux/filter.hlinux/irq.hlinux/pci.hlinux/skbuff.hfuneth_txrx.hfuneth.hfun_queue.hfuneth_trace.h
Detected Declarations
function refresh_refsfunction cache_offerfunction cache_getfunction funeth_alloc_pagefunction funeth_free_pagefunction cqe_to_pkt_hash_typefunction get_buffunction fun_gather_pktfunction rx_hwtstamp_enabledfunction advance_cqfunction fun_handle_cqe_pktfunction cqe_phase_mismatchfunction fun_process_cqesfunction fun_rxq_napi_pollfunction fun_rxq_free_bufsfunction fun_rxq_alloc_bufsfunction fun_rxq_init_cachefunction fun_rxq_free_cachefunction fun_rxq_set_bpffunction fun_rxq_free_swfunction fun_rxq_create_devfunction fun_rxq_free_devfunction funeth_rxq_create
Annotated Snippet
if (funeth_alloc_page(q, b, node, GFP_KERNEL)) {
fun_rxq_free_bufs(q);
return -ENOMEM;
}
q->rqes[i] = FUN_EPRQ_RQBUF_INIT(b->dma_addr);
}
q->cur_buf = q->bufs;
return 0;
}
/* Initialize a used-buffer cache of the given depth. */
static int fun_rxq_init_cache(struct funeth_rx_cache *c, unsigned int depth,
int node)
{
c->mask = depth - 1;
c->bufs = kvzalloc_node(depth * sizeof(*c->bufs), GFP_KERNEL, node);
return c->bufs ? 0 : -ENOMEM;
}
/* Deallocate an Rx queue's used-buffer cache and its contents. */
static void fun_rxq_free_cache(struct funeth_rxq *q)
{
struct funeth_rxbuf *b = q->cache.bufs;
unsigned int i;
for (i = 0; i <= q->cache.mask; i++, b++)
funeth_free_page(q, b);
kvfree(q->cache.bufs);
q->cache.bufs = NULL;
}
int fun_rxq_set_bpf(struct funeth_rxq *q, struct bpf_prog *prog)
{
struct funeth_priv *fp = netdev_priv(q->netdev);
struct fun_admin_epcq_req cmd;
u16 headroom;
int err;
headroom = prog ? FUN_XDP_HEADROOM : FUN_RX_HEADROOM;
if (headroom != q->headroom) {
cmd.common = FUN_ADMIN_REQ_COMMON_INIT2(FUN_ADMIN_OP_EPCQ,
sizeof(cmd));
cmd.u.modify =
FUN_ADMIN_EPCQ_MODIFY_REQ_INIT(FUN_ADMIN_SUBOP_MODIFY,
0, q->hw_cqid, headroom);
err = fun_submit_admin_sync_cmd(fp->fdev, &cmd.common, NULL, 0,
0);
if (err)
return err;
q->headroom = headroom;
}
WRITE_ONCE(q->xdp_prog, prog);
return 0;
}
/* Create an Rx queue, allocating the host memory it needs. */
static struct funeth_rxq *fun_rxq_create_sw(struct net_device *dev,
unsigned int qidx,
unsigned int ncqe,
unsigned int nrqe,
struct fun_irq *irq)
{
struct funeth_priv *fp = netdev_priv(dev);
struct funeth_rxq *q;
int err = -ENOMEM;
int numa_node;
numa_node = fun_irq_node(irq);
q = kzalloc_node(sizeof(*q), GFP_KERNEL, numa_node);
if (!q)
goto err;
q->qidx = qidx;
q->netdev = dev;
q->cq_mask = ncqe - 1;
q->rq_mask = nrqe - 1;
q->numa_node = numa_node;
q->rq_db_thres = nrqe / 4;
u64_stats_init(&q->syncp);
q->dma_dev = &fp->pdev->dev;
q->rqes = fun_alloc_ring_mem(q->dma_dev, nrqe, sizeof(*q->rqes),
sizeof(*q->bufs), false, numa_node,
&q->rq_dma_addr, (void **)&q->bufs, NULL);
if (!q->rqes)
goto free_q;
q->cqes = fun_alloc_ring_mem(q->dma_dev, ncqe, FUNETH_CQE_SIZE, 0,
Annotation
- Immediate include surface: `linux/bpf_trace.h`, `linux/dma-mapping.h`, `linux/etherdevice.h`, `linux/filter.h`, `linux/irq.h`, `linux/pci.h`, `linux/skbuff.h`, `funeth_txrx.h`.
- Detected declarations: `function refresh_refs`, `function cache_offer`, `function cache_get`, `function funeth_alloc_page`, `function funeth_free_page`, `function cqe_to_pkt_hash_type`, `function get_buf`, `function fun_gather_pkt`, `function rx_hwtstamp_enabled`, `function advance_cq`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- 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.