|
|
@ -8,18 +8,18 @@ use crate::{
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#[repr(transparent)]
|
|
|
|
#[repr(transparent)]
|
|
|
|
pub struct PerfMap<T> {
|
|
|
|
pub struct PerfEventArray<T> {
|
|
|
|
def: bpf_map_def,
|
|
|
|
def: bpf_map_def,
|
|
|
|
_t: PhantomData<T>,
|
|
|
|
_t: PhantomData<T>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl<T> PerfMap<T> {
|
|
|
|
impl<T> PerfEventArray<T> {
|
|
|
|
pub const fn new(flags: u32) -> PerfMap<T> {
|
|
|
|
pub const fn new(flags: u32) -> PerfEventArray<T> {
|
|
|
|
PerfMap::with_max_entries(0, flags)
|
|
|
|
PerfEventArray::with_max_entries(0, flags)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub const fn with_max_entries(max_entries: u32, flags: u32) -> PerfMap<T> {
|
|
|
|
pub const fn with_max_entries(max_entries: u32, flags: u32) -> PerfEventArray<T> {
|
|
|
|
PerfMap {
|
|
|
|
PerfEventArray {
|
|
|
|
def: bpf_map_def {
|
|
|
|
def: bpf_map_def {
|
|
|
|
type_: BPF_MAP_TYPE_PERF_EVENT_ARRAY,
|
|
|
|
type_: BPF_MAP_TYPE_PERF_EVENT_ARRAY,
|
|
|
|
key_size: mem::size_of::<u32>() as u32,
|
|
|
|
key_size: mem::size_of::<u32>() as u32,
|
|
|
@ -33,8 +33,8 @@ impl<T> PerfMap<T> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub const fn pinned(max_entries: u32, flags: u32) -> PerfMap<T> {
|
|
|
|
pub const fn pinned(max_entries: u32, flags: u32) -> PerfEventArray<T> {
|
|
|
|
PerfMap {
|
|
|
|
PerfEventArray {
|
|
|
|
def: bpf_map_def {
|
|
|
|
def: bpf_map_def {
|
|
|
|
type_: BPF_MAP_TYPE_PERF_EVENT_ARRAY,
|
|
|
|
type_: BPF_MAP_TYPE_PERF_EVENT_ARRAY,
|
|
|
|
key_size: mem::size_of::<u32>() as u32,
|
|
|
|
key_size: mem::size_of::<u32>() as u32,
|