drivers/net/ethernet/netronome/nfp/bpf/cmsg.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/bpf/cmsg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/bpf/cmsg.c- Extension
.c- Size
- 12047 bytes
- Lines
- 482
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bpf.hlinux/bitops.hlinux/bug.hlinux/jiffies.hlinux/skbuff.hlinux/timekeeping.h../ccm.h../nfp_app.h../nfp_net.hfw.hmain.h
Detected Declarations
function nfp_bpf_cmsg_allocfunction nfp_bpf_cmsg_map_req_sizefunction nfp_bpf_cmsg_map_req_allocfunction nfp_bpf_cmsg_map_reply_sizefunction nfp_bpf_ctrl_rc_to_errnofunction nfp_bpf_ctrl_alloc_mapfunction nfp_bpf_ctrl_free_mapfunction nfp_bpf_ctrl_req_keyfunction nfp_bpf_ctrl_req_valfunction nfp_bpf_ctrl_reply_keyfunction nfp_bpf_ctrl_reply_valfunction nfp_bpf_ctrl_op_cache_invalidatefunction nfp_bpf_ctrl_op_cache_capablefunction nfp_bpf_ctrl_op_cache_fillfunction nfp_bpf_ctrl_op_cache_getfunction nfp_bpf_ctrl_op_cache_putfunction nfp_bpf_ctrl_entry_opfunction nfp_bpf_ctrl_update_entryfunction nfp_bpf_ctrl_del_entryfunction nfp_bpf_ctrl_lookup_entryfunction nfp_bpf_ctrl_getfirst_entryfunction nfp_bpf_ctrl_getnext_entryfunction nfp_bpf_ctrl_cmsg_min_mtufunction nfp_bpf_ctrl_cmsg_mtufunction nfp_bpf_ctrl_cmsg_cache_cntfunction nfp_bpf_ctrl_msg_rxfunction nfp_bpf_ctrl_msg_rx_raw
Annotated Snippet
if (op == NFP_CCM_TYPE_BPF_MAP_GETNEXT) {
if (i + 1 == count)
break;
memcpy(out_key,
nfp_bpf_ctrl_reply_key(bpf, reply, i + 1),
map->key_size);
}
n_entries = 0;
goto exit_unlock;
}
goto exit_unlock;
exit_block:
nfp_map->cache_blockers++;
exit_invalidate:
dev_consume_skb_any(nfp_map->cache);
nfp_map->cache = NULL;
exit_unlock:
spin_unlock(&nfp_map->cache_lock);
return n_entries;
}
static void
nfp_bpf_ctrl_op_cache_put(struct nfp_bpf_map *nfp_map, enum nfp_ccm_type op,
struct sk_buff *skb, u32 cache_gen)
{
bool blocker, filler;
blocker = nfp_bpf_ctrl_op_cache_invalidate(op);
filler = nfp_bpf_ctrl_op_cache_fill(op);
if (blocker || filler) {
u64 to = 0;
if (filler)
to = ktime_get_ns() + NFP_BPF_MAP_CACHE_TIME_NS;
spin_lock(&nfp_map->cache_lock);
if (blocker) {
nfp_map->cache_blockers--;
nfp_map->cache_gen++;
}
if (filler && !nfp_map->cache_blockers &&
nfp_map->cache_gen == cache_gen) {
nfp_map->cache_to = to;
swap(nfp_map->cache, skb);
}
spin_unlock(&nfp_map->cache_lock);
}
dev_consume_skb_any(skb);
}
static int
nfp_bpf_ctrl_entry_op(struct bpf_offloaded_map *offmap, enum nfp_ccm_type op,
u8 *key, u8 *value, u64 flags, u8 *out_key, u8 *out_value)
{
struct nfp_bpf_map *nfp_map = offmap->dev_priv;
unsigned int n_entries, reply_entries, count;
struct nfp_app_bpf *bpf = nfp_map->bpf;
struct bpf_map *map = &offmap->map;
struct cmsg_reply_map_op *reply;
struct cmsg_req_map_op *req;
struct sk_buff *skb;
u32 cache_gen;
int err;
/* FW messages have no space for more than 32 bits of flags */
if (flags >> 32)
return -EOPNOTSUPP;
/* Handle op cache */
n_entries = nfp_bpf_ctrl_op_cache_get(nfp_map, op, key, out_key,
out_value, &cache_gen);
if (!n_entries)
return 0;
skb = nfp_bpf_cmsg_map_req_alloc(bpf, 1);
if (!skb) {
err = -ENOMEM;
goto err_cache_put;
}
req = (void *)skb->data;
req->tid = cpu_to_be32(nfp_map->tid);
req->count = cpu_to_be32(n_entries);
req->flags = cpu_to_be32(flags);
/* Copy inputs */
Annotation
- Immediate include surface: `linux/bpf.h`, `linux/bitops.h`, `linux/bug.h`, `linux/jiffies.h`, `linux/skbuff.h`, `linux/timekeeping.h`, `../ccm.h`, `../nfp_app.h`.
- Detected declarations: `function nfp_bpf_cmsg_alloc`, `function nfp_bpf_cmsg_map_req_size`, `function nfp_bpf_cmsg_map_req_alloc`, `function nfp_bpf_cmsg_map_reply_size`, `function nfp_bpf_ctrl_rc_to_errno`, `function nfp_bpf_ctrl_alloc_map`, `function nfp_bpf_ctrl_free_map`, `function nfp_bpf_ctrl_req_key`, `function nfp_bpf_ctrl_req_val`, `function nfp_bpf_ctrl_reply_key`.
- 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.
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.