drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c- Extension
.c- Size
- 25030 bytes
- Lines
- 1023
- 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.
- 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
linux/bpf.hlinux/filter.hnet/page_pool/helpers.hlan966x_main.h
Detected Declarations
function lan966x_fdma_rx_dataptr_cbfunction lan966x_fdma_tx_dataptr_cbfunction lan966x_fdma_xdp_tx_dataptr_cbfunction lan966x_fdma_channel_activefunction lan966x_fdma_rx_free_pagesfunction lan966x_fdma_rx_free_pagefunction lan966x_fdma_rx_alloc_page_poolfunction lan966x_fdma_rx_allocfunction lan966x_fdma_rx_startfunction lan966x_fdma_rx_disablefunction lan966x_fdma_rx_reloadfunction lan966x_fdma_tx_allocfunction lan966x_fdma_tx_freefunction lan966x_fdma_tx_activatefunction lan966x_fdma_tx_disablefunction lan966x_fdma_tx_reloadfunction lan966x_fdma_wakeup_netdevfunction lan966x_fdma_stop_netdevfunction lan966x_fdma_tx_clear_buffunction lan966x_fdma_rx_check_framefunction lan966x_fdma_napi_pollfunction lan966x_fdma_irq_handlerfunction lan966x_fdma_get_next_dcbfunction lan966x_fdma_tx_startfunction lan966x_fdma_xmit_xdpffunction lan966x_fdma_xmitfunction lan966x_fdma_get_max_mtufunction lan966x_qsys_sw_statusfunction lan966x_fdma_reloadfunction lan966x_fdma_get_max_framefunction __lan966x_fdma_reloadfunction lan966x_fdma_change_mtufunction lan966x_fdma_reload_page_poolfunction lan966x_fdma_netdev_initfunction lan966x_fdma_netdev_deinitfunction lan966x_fdma_initfunction lan966x_fdma_deinit
Annotated Snippet
if (dcb_buf->use_skb) {
dma_unmap_single(lan966x->dev,
dcb_buf->dma_addr,
dcb_buf->len,
DMA_TO_DEVICE);
if (!dcb_buf->ptp)
napi_consume_skb(dcb_buf->data.skb, weight);
} else {
if (dcb_buf->xdp_ndo)
dma_unmap_single(lan966x->dev,
dcb_buf->dma_addr,
dcb_buf->len,
DMA_TO_DEVICE);
if (dcb_buf->xdp_ndo)
xdp_return_frame_bulk(dcb_buf->data.xdpf, &bq);
else
page_pool_recycle_direct(rx->page_pool,
dcb_buf->data.page);
}
clear = true;
}
xdp_flush_frame_bulk(&bq);
if (clear)
lan966x_fdma_wakeup_netdev(lan966x);
spin_unlock_irqrestore(&lan966x->tx_lock, flags);
}
static int lan966x_fdma_rx_check_frame(struct lan966x_rx *rx, u64 *src_port)
{
struct lan966x *lan966x = rx->lan966x;
struct fdma *fdma = &rx->fdma;
struct lan966x_port *port;
struct fdma_db *db;
struct page *page;
db = fdma_db_next_get(fdma);
page = rx->page[fdma->dcb_index][fdma->db_index];
if (unlikely(!page))
return FDMA_ERROR;
dma_sync_single_for_cpu(lan966x->dev,
(dma_addr_t)db->dataptr + XDP_PACKET_HEADROOM,
FDMA_DCB_STATUS_BLOCKL(db->status),
DMA_FROM_DEVICE);
lan966x_ifh_get_src_port(page_address(page) + XDP_PACKET_HEADROOM,
src_port);
if (WARN_ON(*src_port >= lan966x->num_phys_ports))
return FDMA_ERROR;
port = lan966x->ports[*src_port];
if (!lan966x_xdp_port_present(port))
return FDMA_PASS;
return lan966x_xdp_run(port, page, FDMA_DCB_STATUS_BLOCKL(db->status));
}
static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx,
u64 src_port)
{
struct lan966x *lan966x = rx->lan966x;
struct fdma *fdma = &rx->fdma;
struct sk_buff *skb;
struct fdma_db *db;
struct page *page;
u64 timestamp;
/* Get the received frame and unmap it */
db = fdma_db_next_get(fdma);
page = rx->page[fdma->dcb_index][fdma->db_index];
skb = build_skb(page_address(page), fdma->db_size);
if (unlikely(!skb))
goto free_page;
skb_mark_for_recycle(skb);
skb_reserve(skb, XDP_PACKET_HEADROOM);
skb_put(skb, FDMA_DCB_STATUS_BLOCKL(db->status));
lan966x_ifh_get_timestamp(skb->data, ×tamp);
skb->dev = lan966x->ports[src_port]->dev;
skb_pull(skb, IFH_LEN_BYTES);
Annotation
- Immediate include surface: `linux/bpf.h`, `linux/filter.h`, `net/page_pool/helpers.h`, `lan966x_main.h`.
- Detected declarations: `function lan966x_fdma_rx_dataptr_cb`, `function lan966x_fdma_tx_dataptr_cb`, `function lan966x_fdma_xdp_tx_dataptr_cb`, `function lan966x_fdma_channel_active`, `function lan966x_fdma_rx_free_pages`, `function lan966x_fdma_rx_free_page`, `function lan966x_fdma_rx_alloc_page_pool`, `function lan966x_fdma_rx_alloc`, `function lan966x_fdma_rx_start`, `function lan966x_fdma_rx_disable`.
- Atlas domain: Driver Families / drivers/net.
- 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.