drivers/net/ethernet/netronome/nfp/bpf/main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/bpf/main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/bpf/main.c- Extension
.c- Size
- 13310 bytes
- Lines
- 548
- 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.
- 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/pkt_cls.h../nfpcore/nfp_cpp.h../nfpcore/nfp_nffw.h../nfpcore/nfp_nsp.h../nfp_app.h../nfp_main.h../nfp_net.h../nfp_port.hfw.hmain.h
Detected Declarations
function nfp_net_ebpf_capablefunction nfp_bpf_xdp_offloadfunction nfp_bpf_vnic_allocfunction nfp_bpf_vnic_freefunction nfp_bpf_setup_tc_block_cbfunction tcf_exts_has_actionsfunction nfp_bpf_setup_tcfunction nfp_bpf_check_mtufunction nfp_bpf_parse_cap_adjust_headfunction nfp_bpf_parse_cap_funcfunction nfp_bpf_parse_cap_mapsfunction nfp_bpf_parse_cap_randomfunction nfp_bpf_parse_cap_qselfunction nfp_bpf_parse_cap_adjust_tailfunction nfp_bpf_parse_cap_cmsg_multi_entfunction nfp_bpf_parse_cap_abi_versionfunction nfp_bpf_parse_capabilitiesfunction nfp_bpf_init_capabilitiesfunction nfp_bpf_ndo_initfunction nfp_bpf_ndo_uninitfunction nfp_bpf_startfunction nfp_bpf_initfunction nfp_bpf_clean
Annotated Snippet
tcf_exts_has_actions(cls_bpf->exts)) {
NL_SET_ERR_MSG_MOD(cls_bpf->common.extack,
"only direct action with no legacy actions supported");
return -EOPNOTSUPP;
}
if (cls_bpf->command != TC_CLSBPF_OFFLOAD)
return -EOPNOTSUPP;
bv = nn->app_priv;
oldprog = cls_bpf->oldprog;
/* Don't remove if oldprog doesn't match driver's state */
if (bv->tc_prog != oldprog) {
oldprog = NULL;
if (!cls_bpf->prog)
return 0;
}
err = nfp_net_bpf_offload(nn, cls_bpf->prog, oldprog,
cls_bpf->common.extack);
if (err)
return err;
bv->tc_prog = cls_bpf->prog;
nn->port->tc_offload_cnt = !!bv->tc_prog;
return 0;
}
static LIST_HEAD(nfp_bpf_block_cb_list);
static int nfp_bpf_setup_tc(struct nfp_app *app, struct net_device *netdev,
enum tc_setup_type type, void *type_data)
{
struct nfp_net *nn = netdev_priv(netdev);
switch (type) {
case TC_SETUP_BLOCK:
return flow_block_cb_setup_simple(type_data,
&nfp_bpf_block_cb_list,
nfp_bpf_setup_tc_block_cb,
nn, nn, true);
default:
return -EOPNOTSUPP;
}
}
static int
nfp_bpf_check_mtu(struct nfp_app *app, struct net_device *netdev, int new_mtu)
{
struct nfp_net *nn = netdev_priv(netdev);
struct nfp_bpf_vnic *bv;
struct bpf_prog *prog;
if (~nn->dp.ctrl & NFP_NET_CFG_CTRL_BPF)
return 0;
if (nn->xdp_hw.prog) {
prog = nn->xdp_hw.prog;
} else {
bv = nn->app_priv;
prog = bv->tc_prog;
}
if (nfp_bpf_offload_check_mtu(nn, prog, new_mtu)) {
nn_info(nn, "BPF offload active, potential packet access beyond hardware packet boundary");
return -EBUSY;
}
return 0;
}
static int
nfp_bpf_parse_cap_adjust_head(struct nfp_app_bpf *bpf, void __iomem *value,
u32 length)
{
struct nfp_bpf_cap_tlv_adjust_head __iomem *cap = value;
struct nfp_cpp *cpp = bpf->app->pf->cpp;
if (length < sizeof(*cap)) {
nfp_err(cpp, "truncated adjust_head TLV: %d\n", length);
return -EINVAL;
}
bpf->adjust_head.flags = readl(&cap->flags);
bpf->adjust_head.off_min = readl(&cap->off_min);
bpf->adjust_head.off_max = readl(&cap->off_max);
bpf->adjust_head.guaranteed_sub = readl(&cap->guaranteed_sub);
bpf->adjust_head.guaranteed_add = readl(&cap->guaranteed_add);
if (bpf->adjust_head.off_min > bpf->adjust_head.off_max) {
Annotation
- Immediate include surface: `net/pkt_cls.h`, `../nfpcore/nfp_cpp.h`, `../nfpcore/nfp_nffw.h`, `../nfpcore/nfp_nsp.h`, `../nfp_app.h`, `../nfp_main.h`, `../nfp_net.h`, `../nfp_port.h`.
- Detected declarations: `function nfp_net_ebpf_capable`, `function nfp_bpf_xdp_offload`, `function nfp_bpf_vnic_alloc`, `function nfp_bpf_vnic_free`, `function nfp_bpf_setup_tc_block_cb`, `function tcf_exts_has_actions`, `function nfp_bpf_setup_tc`, `function nfp_bpf_check_mtu`, `function nfp_bpf_parse_cap_adjust_head`, `function nfp_bpf_parse_cap_func`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.