drivers/net/ethernet/microchip/sparx5/lan969x/lan969x_fdma.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/sparx5/lan969x/lan969x_fdma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/sparx5/lan969x/lan969x_fdma.c- Extension
.c- Size
- 9359 bytes
- Lines
- 405
- 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
net/page_pool/helpers.h../sparx5_main.h../sparx5_main_regs.h../sparx5_port.hfdma_api.hlan969x.h
Detected Declarations
function Copyrightfunction lan969x_fdma_rx_dataptr_cbfunction lan969x_fdma_get_next_dcbfunction lan969x_fdma_tx_clear_buffunction lan969x_fdma_free_pagesfunction lan969x_fdma_rx_allocfunction lan969x_fdma_tx_allocfunction lan969x_fdma_rx_initfunction lan969x_fdma_tx_initfunction lan969x_fdma_napi_pollfunction lan969x_fdma_xmitfunction lan969x_fdma_initfunction lan969x_fdma_deinit
Annotated Snippet
if (port && port->ndev) {
sparx5->rx.ndev = port->ndev;
break;
}
}
}
static void lan969x_fdma_tx_init(struct sparx5 *sparx5)
{
struct fdma *fdma = &sparx5->tx.fdma;
fdma->channel_id = FDMA_INJ_CHANNEL;
fdma->n_dcbs = FDMA_DCB_MAX;
fdma->n_dbs = 1;
fdma->priv = sparx5;
fdma->size = fdma_get_size(fdma);
fdma->db_size = PAGE_SIZE;
fdma->ops.dataptr_cb = &lan969x_fdma_tx_dataptr_cb;
fdma->ops.nextptr_cb = &fdma_nextptr_cb;
}
int lan969x_fdma_napi_poll(struct napi_struct *napi, int weight)
{
struct sparx5_rx *rx = container_of(napi, struct sparx5_rx, napi);
struct sparx5 *sparx5 = container_of(rx, struct sparx5, rx);
int old_dcb, dcb_reload, counter = 0;
struct fdma *fdma = &rx->fdma;
struct sk_buff *skb;
dcb_reload = fdma->dcb_index;
lan969x_fdma_tx_clear_buf(sparx5, weight);
/* Process RX data */
while (counter < weight) {
if (!fdma_has_frames(fdma))
break;
skb = lan969x_fdma_rx_get_frame(sparx5, rx);
if (!skb)
break;
napi_gro_receive(&rx->napi, skb);
fdma_db_advance(fdma);
counter++;
/* Check if the DCB can be reused */
if (fdma_dcb_is_reusable(fdma))
continue;
fdma_db_reset(fdma);
fdma_dcb_advance(fdma);
}
/* Allocate new pages and map them */
while (dcb_reload != fdma->dcb_index) {
old_dcb = dcb_reload;
dcb_reload++;
/* n_dcbs must be a power of 2 */
dcb_reload &= fdma->n_dcbs - 1;
fdma_dcb_add(fdma,
old_dcb,
FDMA_DCB_INFO_DATAL(fdma->db_size),
FDMA_DCB_STATUS_INTR);
sparx5_fdma_reload(sparx5, fdma);
}
if (counter < weight && napi_complete_done(napi, counter))
spx5_wr(0xff, sparx5, FDMA_INTR_DB_ENA);
return counter;
}
int lan969x_fdma_xmit(struct sparx5 *sparx5, u32 *ifh, struct sk_buff *skb,
struct net_device *dev)
{
int next_dcb, needed_headroom, needed_tailroom, err;
struct sparx5_tx *tx = &sparx5->tx;
struct fdma *fdma = &tx->fdma;
struct sparx5_tx_buf *db_buf;
u64 status;
next_dcb = lan969x_fdma_get_next_dcb(tx);
if (next_dcb < 0)
return -EBUSY;
needed_headroom = max_t(int, IFH_LEN * 4 - skb_headroom(skb), 0);
needed_tailroom = max_t(int, ETH_FCS_LEN - skb_tailroom(skb), 0);
Annotation
- Immediate include surface: `net/page_pool/helpers.h`, `../sparx5_main.h`, `../sparx5_main_regs.h`, `../sparx5_port.h`, `fdma_api.h`, `lan969x.h`.
- Detected declarations: `function Copyright`, `function lan969x_fdma_rx_dataptr_cb`, `function lan969x_fdma_get_next_dcb`, `function lan969x_fdma_tx_clear_buf`, `function lan969x_fdma_free_pages`, `function lan969x_fdma_rx_alloc`, `function lan969x_fdma_tx_alloc`, `function lan969x_fdma_rx_init`, `function lan969x_fdma_tx_init`, `function lan969x_fdma_napi_poll`.
- 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.