tools/testing/selftests/bpf/netcnt_common.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/netcnt_common.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/netcnt_common.h- Extension
.h- Size
- 926 bytes
- Lines
- 45
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.h
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#ifndef __NETCNT_COMMON_H
#define __NETCNT_COMMON_H
#include <linux/types.h>
#define MAX_PERCPU_PACKETS 32
/* sizeof(struct bpf_local_storage_elem):
*
* It is about 128 bytes on x86_64 and 512 bytes on s390x, but allocate more to
* account for possible layout changes, different architectures, etc.
* The kernel will wrap up to PAGE_SIZE internally anyway.
*/
#define SIZEOF_BPF_LOCAL_STORAGE_ELEM 768
/* Try to estimate kernel's BPF_LOCAL_STORAGE_MAX_VALUE_SIZE: */
#define BPF_LOCAL_STORAGE_MAX_VALUE_SIZE (0xFFFF - \
SIZEOF_BPF_LOCAL_STORAGE_ELEM)
#define PCPU_MIN_UNIT_SIZE 32768
union percpu_net_cnt {
struct {
__u64 packets;
__u64 bytes;
__u64 prev_ts;
__u64 prev_packets;
__u64 prev_bytes;
};
__u8 data[PCPU_MIN_UNIT_SIZE];
};
union net_cnt {
struct {
__u64 packets;
__u64 bytes;
};
__u8 data[BPF_LOCAL_STORAGE_MAX_VALUE_SIZE];
};
#endif
Annotation
- Immediate include surface: `linux/types.h`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.