Skip to content

Commit

Permalink
Merge pull request #649 from albertxu216/develop
Browse files Browse the repository at this point in the history
Add some struct
  • Loading branch information
chenamy2017 committed Jan 23, 2024
2 parents 2c8d082 + c893555 commit 03b3652
Showing 1 changed file with 63 additions and 3 deletions.
66 changes: 63 additions & 3 deletions eBPF_Supermarket/CPU_Subsystem/cpu_watcher/cpu_watcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// author: [email protected]
//
// eBPF map for libbpf sar
#include <asm/types.h>
#include <linux/version.h>

typedef long long unsigned int u64;
typedef unsigned int u32;
Expand All @@ -27,7 +29,7 @@ typedef unsigned int u32;
struct event {
long unsigned int t1;
long unsigned int t2;
long unsigned int delay;
long unsigned int delay;
};
#endif /* __CS_DELAY_H */

Expand Down Expand Up @@ -66,10 +68,68 @@ struct __irq_info {
/*----------------------------------------------*/
struct idleStruct {
u64 pad;
int state;
u32 cpu_id;
unsigned int state;
unsigned int cpu_id;
};


/*----------------------------------------------*/
/* 一些maps结构体的宏定义 */
/*----------------------------------------------*/
/// @brief 创建一个指定名字和键值类型的ebpf数组
/// @param name 新散列表的名字
/// @param type1 键的类型
/// @param type2 值的类型
/// @param MAX_ENTRIES map容量
#define BPF_ARRAY(name, type1,type2,MAX_ENTRIES ) \
struct \
{ \
__uint(type, BPF_MAP_TYPE_ARRAY); \
__uint(key_size, sizeof(type1)); \
__uint(value_size, sizeof(type2)); \
__uint(max_entries, MAX_ENTRIES); \
} name SEC(".maps")

/// @brief 创建一个指定名字和键值类型的ebpf散列表
/// @param name 新散列表的名字
/// @param type1 键的类型
/// @param type2 值的类型
/// @param MAX_ENTRIES 哈希map容量
#define BPF_HASH(name, type1,type2,MAX_ENTRIES ) \
struct \
{ \
__uint(type, BPF_MAP_TYPE_HASH); \
__uint(key_size, sizeof(type1)); \
__uint(value_size, sizeof(type2)); \
__uint(max_entries, MAX_ENTRIES); \
} name SEC(".maps")

/// @brief 创建一个指定名字和键值类型的ebpf每CPU数组
/// @param name 新散列表的名字
/// @param type1 键的类型
/// @param type2 值的类型
/// @param MAX_ENTRIES map容量
#define BPF_PERCPU_ARRAY(name, type1,type2,MAX_ENTRIES ) \
struct \
{ \
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); \
__uint(key_size, sizeof(type1)); \
__uint(value_size, sizeof(type2)); \
__uint(max_entries, MAX_ENTRIES); \
} name SEC(".maps")

/// @brief 创建一个指定名字和键值类型的ebpf每CPU散列表
/// @param name 新散列表的名字
/// @param type1 键的类型
/// @param type2 值的类型
/// @param MAX_ENTRIES map容量
#define BPF_PERCPU_HASH(name, type1,type2,MAX_ENTRIES ) \
struct \
{ \
__uint(type, BPF_MAP_TYPE_PERCPU_HASH); \
__uint(key_size, sizeof(type1)); \
__uint(value_size, sizeof(type2)); \
__uint(max_entries, MAX_ENTRIES); \
} name SEC(".maps")


0 comments on commit 03b3652

Please sign in to comment.