drivers/net/ethernet/netronome/nfp/nfd3/dp.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/nfd3/dp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/nfd3/dp.c- Extension
.c- Size
- 38122 bytes
- Lines
- 1414
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bpf_trace.hlinux/netdevice.hlinux/bitfield.hnet/xfrm.h../nfp_app.h../nfp_net.h../nfp_net_dp.h../nfp_net_xsk.h../crypto/crypto.h../crypto/fw.hnfd3.h
Detected Declarations
function nfp_nfd3_tx_ring_should_wakefunction nfp_nfd3_tx_ring_should_stopfunction nfp_nfd3_tx_ring_stopfunction nfp_nfd3_tx_tsofunction nfp_nfd3_tx_csumfunction nfp_nfd3_prep_tx_metafunction nfp_nfd3_txfunction nfp_nfd3_tx_completefunction nfp_nfd3_xdp_completefunction nfp_nfd3_napi_alloc_onefunction nfp_nfd3_rx_give_onefunction nfp_nfd3_rx_ring_fill_freelistfunction nfp_nfd3_rx_csum_has_errorsfunction nfp_nfd3_rx_csumfunction nfp_nfd3_set_hashfunction nfp_nfd3_set_hash_descfunction nfp_nfd3_parse_metafunction nfp_nfd3_rx_dropfunction nfp_nfd3_tx_xdp_buffunction nfp_nfd3_rxfunction nfp_nfd3_pollfunction nfp_nfd3_ctrl_tx_onefunction __nfp_ctrl_tx_queuedfunction nfp_ctrl_meta_okfunction nfp_ctrl_rx_onefunction nfp_ctrl_rxfunction nfp_nfd3_ctrl_poll
Annotated Snippet
if (fidx == -1) {
/* unmap head */
dma_unmap_single(dp->dev, tx_buf->dma_addr,
skb_headlen(skb), DMA_TO_DEVICE);
done_pkts += tx_buf->pkt_cnt;
done_bytes += tx_buf->real_len;
} else {
/* unmap fragment */
frag = &skb_shinfo(skb)->frags[fidx];
dma_unmap_page(dp->dev, tx_buf->dma_addr,
skb_frag_size(frag), DMA_TO_DEVICE);
}
/* check for last gather fragment */
if (fidx == nr_frags - 1)
napi_consume_skb(skb, budget);
tx_buf->dma_addr = 0;
tx_buf->skb = NULL;
tx_buf->fidx = -2;
}
tx_ring->qcp_rd_p = qcp_rd_p;
u64_stats_update_begin(&r_vec->tx_sync);
r_vec->tx_bytes += done_bytes;
r_vec->tx_pkts += done_pkts;
u64_stats_update_end(&r_vec->tx_sync);
if (!dp->netdev)
return;
nd_q = netdev_get_tx_queue(dp->netdev, tx_ring->idx);
netdev_tx_completed_queue(nd_q, done_pkts, done_bytes);
if (nfp_nfd3_tx_ring_should_wake(tx_ring)) {
/* Make sure TX thread will see updated tx_ring->rd_p */
smp_mb();
if (unlikely(netif_tx_queue_stopped(nd_q)))
netif_tx_wake_queue(nd_q);
}
WARN_ONCE(tx_ring->wr_p - tx_ring->rd_p > tx_ring->cnt,
"TX ring corruption rd_p=%u wr_p=%u cnt=%u\n",
tx_ring->rd_p, tx_ring->wr_p, tx_ring->cnt);
}
static bool nfp_nfd3_xdp_complete(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;
u32 done_pkts = 0, done_bytes = 0;
bool done_all;
int idx, todo;
u32 qcp_rd_p;
/* Work out how many descriptors have been transmitted */
qcp_rd_p = nfp_net_read_tx_cmpl(tx_ring, dp);
if (qcp_rd_p == tx_ring->qcp_rd_p)
return true;
todo = D_IDX(tx_ring, qcp_rd_p - tx_ring->qcp_rd_p);
done_all = todo <= NFP_NET_XDP_MAX_COMPLETE;
todo = min(todo, NFP_NET_XDP_MAX_COMPLETE);
tx_ring->qcp_rd_p = D_IDX(tx_ring, tx_ring->qcp_rd_p + todo);
done_pkts = todo;
while (todo--) {
idx = D_IDX(tx_ring, tx_ring->rd_p);
tx_ring->rd_p++;
done_bytes += tx_ring->txbufs[idx].real_len;
}
u64_stats_update_begin(&r_vec->tx_sync);
r_vec->tx_bytes += done_bytes;
r_vec->tx_pkts += done_pkts;
u64_stats_update_end(&r_vec->tx_sync);
WARN_ONCE(tx_ring->wr_p - tx_ring->rd_p > tx_ring->cnt,
"XDP TX ring corruption rd_p=%u wr_p=%u cnt=%u\n",
tx_ring->rd_p, tx_ring->wr_p, tx_ring->cnt);
return done_all;
}
Annotation
- Immediate include surface: `linux/bpf_trace.h`, `linux/netdevice.h`, `linux/bitfield.h`, `net/xfrm.h`, `../nfp_app.h`, `../nfp_net.h`, `../nfp_net_dp.h`, `../nfp_net_xsk.h`.
- Detected declarations: `function nfp_nfd3_tx_ring_should_wake`, `function nfp_nfd3_tx_ring_should_stop`, `function nfp_nfd3_tx_ring_stop`, `function nfp_nfd3_tx_tso`, `function nfp_nfd3_tx_csum`, `function nfp_nfd3_prep_tx_meta`, `function nfp_nfd3_tx`, `function nfp_nfd3_tx_complete`, `function nfp_nfd3_xdp_complete`, `function nfp_nfd3_napi_alloc_one`.
- 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.