drivers/net/ethernet/netronome/nfp/nfdk/rings.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/nfdk/rings.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/nfdk/rings.c- Extension
.c- Size
- 5303 bytes
- Lines
- 198
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/seq_file.h../nfp_net.h../nfp_net_dp.hnfdk.h
Detected Declarations
function nfp_nfdk_tx_ring_resetfunction nfp_nfdk_tx_ring_freefunction nfp_nfdk_tx_ring_allocfunction nfp_nfdk_tx_ring_bufs_freefunction nfp_nfdk_print_tx_descs
Annotated Snippet
if (!skb) {
n_descs = D_BLOCK_CPL(tx_ring->rd_p);
goto next;
}
nr_frags = skb_shinfo(skb)->nr_frags;
txbuf++;
/* Unmap head */
size = skb_headlen(skb);
dma_unmap_single(dev, txbuf->dma_addr, size, DMA_TO_DEVICE);
n_descs += nfp_nfdk_headlen_to_segs(size);
txbuf++;
frag = skb_shinfo(skb)->frags;
fend = frag + nr_frags;
for (; frag < fend; frag++) {
size = skb_frag_size(frag);
dma_unmap_page(dev, txbuf->dma_addr,
skb_frag_size(frag), DMA_TO_DEVICE);
n_descs += DIV_ROUND_UP(size,
NFDK_TX_MAX_DATA_PER_DESC);
txbuf++;
}
if (skb_is_gso(skb))
n_descs++;
dev_kfree_skb_any(skb);
next:
tx_ring->rd_p += n_descs;
}
memset(tx_ring->txds, 0, tx_ring->size);
tx_ring->data_pending = 0;
tx_ring->wr_p = 0;
tx_ring->rd_p = 0;
tx_ring->qcp_rd_p = 0;
tx_ring->wr_ptr_add = 0;
if (tx_ring->is_xdp || !dp->netdev)
return;
nd_q = netdev_get_tx_queue(dp->netdev, tx_ring->idx);
netdev_tx_reset_queue(nd_q);
}
static void nfp_nfdk_tx_ring_free(struct nfp_net_tx_ring *tx_ring)
{
struct nfp_net_r_vector *r_vec = tx_ring->r_vec;
struct nfp_net_dp *dp = &r_vec->nfp_net->dp;
kvfree(tx_ring->ktxbufs);
if (tx_ring->ktxds)
dma_free_coherent(dp->dev, tx_ring->size,
tx_ring->ktxds, tx_ring->dma);
tx_ring->cnt = 0;
tx_ring->txbufs = NULL;
tx_ring->txds = NULL;
tx_ring->dma = 0;
tx_ring->size = 0;
}
static int
nfp_nfdk_tx_ring_alloc(struct nfp_net_dp *dp, struct nfp_net_tx_ring *tx_ring)
{
struct nfp_net_r_vector *r_vec = tx_ring->r_vec;
tx_ring->cnt = dp->txd_cnt * NFDK_TX_DESC_PER_SIMPLE_PKT;
tx_ring->size = array_size(tx_ring->cnt, sizeof(*tx_ring->ktxds));
tx_ring->ktxds = dma_alloc_coherent(dp->dev, tx_ring->size,
&tx_ring->dma,
GFP_KERNEL | __GFP_NOWARN);
if (!tx_ring->ktxds) {
netdev_warn(dp->netdev, "failed to allocate TX descriptor ring memory, requested descriptor count: %d, consider lowering descriptor count\n",
tx_ring->cnt);
goto err_alloc;
}
tx_ring->ktxbufs = kvzalloc_objs(*tx_ring->ktxbufs, tx_ring->cnt);
if (!tx_ring->ktxbufs)
goto err_alloc;
if (!tx_ring->is_xdp && dp->netdev)
netif_set_xps_queue(dp->netdev, &r_vec->affinity_mask,
tx_ring->idx);
return 0;
Annotation
- Immediate include surface: `linux/seq_file.h`, `../nfp_net.h`, `../nfp_net_dp.h`, `nfdk.h`.
- Detected declarations: `function nfp_nfdk_tx_ring_reset`, `function nfp_nfdk_tx_ring_free`, `function nfp_nfdk_tx_ring_alloc`, `function nfp_nfdk_tx_ring_bufs_free`, `function nfp_nfdk_print_tx_descs`.
- 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.