drivers/net/ethernet/netronome/nfp/bpf/verifier.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/bpf/verifier.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/bpf/verifier.c- Extension
.c- Size
- 24522 bytes
- Lines
- 864
- 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
linux/bpf.hlinux/bpf_verifier.hlinux/kernel.hlinux/netdevice.hlinux/pkt_cls.h../nfp_app.h../nfp_main.h../nfp_net.hfw.hmain.h
Detected Declarations
function nfp_bpf_goto_metafunction nfp_record_adjust_headfunction nfp_bpf_map_update_value_okfunction nfp_bpf_stack_arg_okfunction nfp_bpf_map_call_okfunction nfp_bpf_check_helper_callfunction nfp_bpf_check_exitfunction nfp_bpf_check_stack_accessfunction nfp_bpf_map_mark_used_onefunction nfp_bpf_map_mark_usedfunction nfp_bpf_check_ptrfunction nfp_bpf_check_storefunction nfp_bpf_check_atomicfunction nfp_bpf_check_alufunction nfp_verify_insnfunction nfp_assign_subprog_idx_and_regsfunction list_for_each_entryfunction nfp_bpf_get_stack_usagefunction nfp_bpf_insn_flag_zextfunction list_for_each_entryfunction nfp_bpf_finalizefunction nfp_bpf_opt_replace_insnfunction nfp_bpf_opt_remove_insns
Annotated Snippet
if (nfp_map->use_map[i / 4].type == NFP_MAP_USE_ATOMIC_CNT) {
pr_vlog(env, "value at offset %d/%d may be non-zero, bpf_map_update_elem() is required to initialize atomic counters to zero to avoid offload endian issues\n",
i, soff);
return false;
}
nfp_map->use_map[i / 4].non_zero_update = 1;
}
return true;
}
static int
nfp_bpf_stack_arg_ok(const char *fname, struct bpf_verifier_env *env,
const struct bpf_reg_state *reg,
struct nfp_bpf_reg_state *old_arg)
{
s64 off, old_off;
if (reg->type != PTR_TO_STACK) {
pr_vlog(env, "%s: unsupported ptr type %d\n",
fname, reg->type);
return false;
}
if (!tnum_is_const(reg->var_off)) {
pr_vlog(env, "%s: variable pointer\n", fname);
return false;
}
off = reg->var_off.value;
if (-off % 4) {
pr_vlog(env, "%s: unaligned stack pointer %lld\n", fname, -off);
return false;
}
/* Rest of the checks is only if we re-parse the same insn */
if (!old_arg)
return true;
old_off = old_arg->reg.var_off.value;
old_arg->var_off |= off != old_off;
return true;
}
static bool
nfp_bpf_map_call_ok(const char *fname, struct bpf_verifier_env *env,
struct nfp_insn_meta *meta,
u32 helper_tgt, const struct bpf_reg_state *reg1)
{
if (!helper_tgt) {
pr_vlog(env, "%s: not supported by FW\n", fname);
return false;
}
return true;
}
static int
nfp_bpf_check_helper_call(struct nfp_prog *nfp_prog,
struct bpf_verifier_env *env,
struct nfp_insn_meta *meta)
{
const struct bpf_reg_state *reg1 = cur_regs(env) + BPF_REG_1;
const struct bpf_reg_state *reg2 = cur_regs(env) + BPF_REG_2;
const struct bpf_reg_state *reg3 = cur_regs(env) + BPF_REG_3;
struct nfp_app_bpf *bpf = nfp_prog->bpf;
u32 func_id = meta->insn.imm;
switch (func_id) {
case BPF_FUNC_xdp_adjust_head:
if (!bpf->adjust_head.off_max) {
pr_vlog(env, "adjust_head not supported by FW\n");
return -EOPNOTSUPP;
}
if (!(bpf->adjust_head.flags & NFP_BPF_ADJUST_HEAD_NO_META)) {
pr_vlog(env, "adjust_head: FW requires shifting metadata, not supported by the driver\n");
return -EOPNOTSUPP;
}
nfp_record_adjust_head(bpf, nfp_prog, meta, reg2);
break;
case BPF_FUNC_xdp_adjust_tail:
if (!bpf->adjust_tail) {
pr_vlog(env, "adjust_tail not supported by FW\n");
return -EOPNOTSUPP;
}
break;
case BPF_FUNC_map_lookup_elem:
Annotation
- Immediate include surface: `linux/bpf.h`, `linux/bpf_verifier.h`, `linux/kernel.h`, `linux/netdevice.h`, `linux/pkt_cls.h`, `../nfp_app.h`, `../nfp_main.h`, `../nfp_net.h`.
- Detected declarations: `function nfp_bpf_goto_meta`, `function nfp_record_adjust_head`, `function nfp_bpf_map_update_value_ok`, `function nfp_bpf_stack_arg_ok`, `function nfp_bpf_map_call_ok`, `function nfp_bpf_check_helper_call`, `function nfp_bpf_check_exit`, `function nfp_bpf_check_stack_access`, `function nfp_bpf_map_mark_used_one`, `function nfp_bpf_map_mark_used`.
- 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.