drivers/net/ethernet/netronome/nfp/nfp_net_dp.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/nfp_net_dp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/nfp_net_dp.c- Extension
.c- Size
- 11958 bytes
- Lines
- 465
- 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
nfp_app.hnfp_net_dp.hnfp_net_xsk.h
Detected Declarations
function nfp_net_rx_alloc_onefunction nfp_net_tx_ring_initfunction nfp_net_rx_ring_initfunction nfp_net_rx_ring_resetfunction nfp_net_rx_ring_bufs_freefunction nfp_net_rx_ring_bufs_allocfunction nfp_net_tx_rings_preparefunction nfp_net_tx_rings_freefunction nfp_net_rx_ring_freefunction nfp_net_rx_ring_allocfunction nfp_net_rx_rings_preparefunction nfp_net_rx_rings_freefunction nfp_net_rx_ring_hw_cfg_writefunction nfp_net_tx_ring_hw_cfg_writefunction nfp_net_vec_clear_ring_datafunction nfp_net_txfunction __nfp_ctrl_txfunction nfp_ctrl_txfunction nfp_net_vlan_strip
Annotated Snippet
if (!rxbufs[i].frag) {
nfp_net_rx_ring_bufs_free(dp, rx_ring);
return -ENOMEM;
}
}
return 0;
}
int nfp_net_tx_rings_prepare(struct nfp_net *nn, struct nfp_net_dp *dp)
{
unsigned int r;
dp->tx_rings = kzalloc_objs(*dp->tx_rings, dp->num_tx_rings);
if (!dp->tx_rings)
return -ENOMEM;
if (dp->ctrl & NFP_NET_CFG_CTRL_TXRWB) {
dp->txrwb = dma_alloc_coherent(dp->dev,
dp->num_tx_rings * sizeof(u64),
&dp->txrwb_dma, GFP_KERNEL);
if (!dp->txrwb)
goto err_free_rings;
}
for (r = 0; r < dp->num_tx_rings; r++) {
int bias = 0;
if (r >= dp->num_stack_tx_rings)
bias = dp->num_stack_tx_rings;
nfp_net_tx_ring_init(&dp->tx_rings[r], dp,
&nn->r_vecs[r - bias], r, bias);
if (nfp_net_tx_ring_alloc(dp, &dp->tx_rings[r]))
goto err_free_prev;
if (nfp_net_tx_ring_bufs_alloc(dp, &dp->tx_rings[r]))
goto err_free_ring;
}
return 0;
err_free_prev:
while (r--) {
nfp_net_tx_ring_bufs_free(dp, &dp->tx_rings[r]);
err_free_ring:
nfp_net_tx_ring_free(dp, &dp->tx_rings[r]);
}
if (dp->txrwb)
dma_free_coherent(dp->dev, dp->num_tx_rings * sizeof(u64),
dp->txrwb, dp->txrwb_dma);
err_free_rings:
kfree(dp->tx_rings);
return -ENOMEM;
}
void nfp_net_tx_rings_free(struct nfp_net_dp *dp)
{
unsigned int r;
for (r = 0; r < dp->num_tx_rings; r++) {
nfp_net_tx_ring_bufs_free(dp, &dp->tx_rings[r]);
nfp_net_tx_ring_free(dp, &dp->tx_rings[r]);
}
if (dp->txrwb)
dma_free_coherent(dp->dev, dp->num_tx_rings * sizeof(u64),
dp->txrwb, dp->txrwb_dma);
kfree(dp->tx_rings);
}
/**
* nfp_net_rx_ring_free() - Free resources allocated to a RX ring
* @rx_ring: RX ring to free
*/
static void nfp_net_rx_ring_free(struct nfp_net_rx_ring *rx_ring)
{
struct nfp_net_r_vector *r_vec = rx_ring->r_vec;
struct nfp_net_dp *dp = &r_vec->nfp_net->dp;
if (dp->netdev)
xdp_rxq_info_unreg(&rx_ring->xdp_rxq);
if (nfp_net_has_xsk_pool_slow(dp, rx_ring->idx))
kvfree(rx_ring->xsk_rxbufs);
else
kvfree(rx_ring->rxbufs);
if (rx_ring->rxds)
Annotation
- Immediate include surface: `nfp_app.h`, `nfp_net_dp.h`, `nfp_net_xsk.h`.
- Detected declarations: `function nfp_net_rx_alloc_one`, `function nfp_net_tx_ring_init`, `function nfp_net_rx_ring_init`, `function nfp_net_rx_ring_reset`, `function nfp_net_rx_ring_bufs_free`, `function nfp_net_rx_ring_bufs_alloc`, `function nfp_net_tx_rings_prepare`, `function nfp_net_tx_rings_free`, `function nfp_net_rx_ring_free`, `function nfp_net_rx_ring_alloc`.
- 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.