drivers/net/ethernet/netronome/nfp/nfdk/dp.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/nfdk/dp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/nfdk/dp.c- Extension
.c- Size
- 41648 bytes
- Lines
- 1576
- 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/overflow.hlinux/sizes.hlinux/bitfield.hnet/xfrm.h../nfp_app.h../nfp_net.h../nfp_net_dp.h../crypto/crypto.h../crypto/fw.hnfdk.h
Detected Declarations
function nfp_nfdk_tx_ring_should_wakefunction nfp_nfdk_tx_ring_should_stopfunction nfp_nfdk_tx_ring_stopfunction nfp_nfdk_tx_tsofunction nfp_nfdk_tx_csumfunction nfp_nfdk_tx_maybe_close_blockfunction nfp_nfdk_prep_tx_metafunction nfp_nfdk_txfunction nfp_nfdk_tx_completefunction nfp_nfdk_napi_alloc_onefunction nfp_nfdk_rx_give_onefunction nfp_nfdk_rx_ring_fill_freelistfunction nfp_nfdk_rx_csum_has_errorsfunction nfp_nfdk_rx_csumfunction nfp_nfdk_set_hashfunction nfp_nfdk_parse_metafunction nfp_nfdk_rx_dropfunction nfp_nfdk_xdp_completefunction nfp_nfdk_tx_xdp_buffunction round_downfunction nfp_nfdk_rxfunction nfp_nfdk_pollfunction nfp_nfdk_ctrl_tx_onefunction __nfp_ctrl_tx_queuedfunction nfp_ctrl_meta_okfunction nfp_ctrl_rx_onefunction nfp_ctrl_rxfunction nfp_nfdk_ctrl_poll
Annotated Snippet
if (skb_is_nonlinear(skb)) {
err = skb_linearize(skb);
if (err)
return err;
goto recount_descs;
}
return -EINVAL;
}
/* Under count by 1 (don't count meta) for the round down to work out */
n_descs += !!skb_is_gso(skb);
if (round_down(tx_ring->wr_p, NFDK_TX_DESC_BLOCK_CNT) !=
round_down(tx_ring->wr_p + n_descs, NFDK_TX_DESC_BLOCK_CNT))
goto close_block;
if ((u32)tx_ring->data_pending + skb->len > NFDK_TX_MAX_DATA_PER_BLOCK)
goto close_block;
return 0;
close_block:
wr_p = tx_ring->wr_p;
nop_slots = D_BLOCK_CPL(wr_p);
wr_idx = D_IDX(tx_ring, wr_p);
tx_ring->ktxbufs[wr_idx].skb = NULL;
txd = &tx_ring->ktxds[wr_idx];
memset(txd, 0, array_size(nop_slots, sizeof(struct nfp_nfdk_tx_desc)));
tx_ring->data_pending = 0;
tx_ring->wr_p += nop_slots;
tx_ring->wr_ptr_add += nop_slots;
return 0;
}
static int
nfp_nfdk_prep_tx_meta(struct nfp_net_dp *dp, struct nfp_app *app,
struct sk_buff *skb, bool *ipsec)
{
struct metadata_dst *md_dst = skb_metadata_dst(skb);
struct nfp_ipsec_offload offload_info;
unsigned char *data;
bool vlan_insert;
u32 meta_id = 0;
int md_bytes;
#ifdef CONFIG_NFP_NET_IPSEC
if (xfrm_offload(skb))
*ipsec = nfp_net_ipsec_tx_prep(dp, skb, &offload_info);
#endif
if (unlikely(md_dst && md_dst->type != METADATA_HW_PORT_MUX))
md_dst = NULL;
vlan_insert = skb_vlan_tag_present(skb) && (dp->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2);
if (!(md_dst || vlan_insert || *ipsec))
return 0;
md_bytes = sizeof(meta_id) +
(!!md_dst ? NFP_NET_META_PORTID_SIZE : 0) +
(vlan_insert ? NFP_NET_META_VLAN_SIZE : 0) +
(*ipsec ? NFP_NET_META_IPSEC_FIELD_SIZE : 0);
if (unlikely(skb_cow_head(skb, md_bytes)))
return -ENOMEM;
data = skb_push(skb, md_bytes) + md_bytes;
if (md_dst) {
data -= NFP_NET_META_PORTID_SIZE;
put_unaligned_be32(md_dst->u.port_info.port_id, data);
meta_id = NFP_NET_META_PORTID;
}
if (vlan_insert) {
data -= NFP_NET_META_VLAN_SIZE;
/* data type of skb->vlan_proto is __be16
* so it fills metadata without calling put_unaligned_be16
*/
memcpy(data, &skb->vlan_proto, sizeof(skb->vlan_proto));
put_unaligned_be16(skb_vlan_tag_get(skb), data + sizeof(skb->vlan_proto));
meta_id <<= NFP_NET_META_FIELD_SIZE;
meta_id |= NFP_NET_META_VLAN;
}
if (*ipsec) {
data -= NFP_NET_META_IPSEC_SIZE;
put_unaligned_be32(offload_info.seq_hi, data);
Annotation
- Immediate include surface: `linux/bpf_trace.h`, `linux/netdevice.h`, `linux/overflow.h`, `linux/sizes.h`, `linux/bitfield.h`, `net/xfrm.h`, `../nfp_app.h`, `../nfp_net.h`.
- Detected declarations: `function nfp_nfdk_tx_ring_should_wake`, `function nfp_nfdk_tx_ring_should_stop`, `function nfp_nfdk_tx_ring_stop`, `function nfp_nfdk_tx_tso`, `function nfp_nfdk_tx_csum`, `function nfp_nfdk_tx_maybe_close_block`, `function nfp_nfdk_prep_tx_meta`, `function nfp_nfdk_tx`, `function nfp_nfdk_tx_complete`, `function nfp_nfdk_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.