1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved.
3 
4 * The hiebpf_types.h is dual licensed: you can use it either under the terms of
5 * the GPL V2, or the 3-Clause BSD license, at your option.
6 * See the LICENSE file in the root of this repository for complete details.
7 */
8 
9 #ifndef HIEBPF_EVENT_STRUCTS_H
10 #define HIEBPF_EVENT_STRUCTS_H
11 
12 
13 /******************************* fstrace types BEGIN *******************************/
14 #include "fstrace_types.h"
15 struct fstrace_cmplt_event_t {
16     __u32 tracer;
17     struct fstrace_start_event_t start_event;
18     __u64 ctime;
19     __u32 pid;
20     __u32 tgid;
21     __u32 uid;
22     __u32 gid;
23     char comm[MAX_COMM_LEN];
24     int32_t retval;
25     __u32 nips;
26     __u64 ips[MAX_STACK_LIMIT];
27 };
28 /******************************* fstrace types END *******************************/
29 
30 
31 /******************************* pftrace types BEGIN *******************************/
32 enum PFTraceEventType:int {
33     PF_FILE_BACKED_IN = 1,
34     PF_PAGE_CACHE_HIT,
35     PF_SWAP_FROM_ZRAM,
36     PF_SWAP_FROM_DISK,
37     PF_ZERO_FILL_PAGE,
38     PF_FAKE_ZERO_PAGE,
39     PF_COPY_ON_WRITE,
40     PF_MAX_EVENT_TYPE,
41 };
42 
43 struct pftrace_start_event_t {
44     __u32 type;
45     __u64 stime;
46     __u64 addr;
47 };
48 
49 struct pftrace_cmplt_event_t {
50     __u32 tracer;
51     struct pftrace_start_event_t start_event;
52     __u64 ctime;
53     __u32 pid;
54     __u32 tgid;
55     __u32 uid;
56     __u32 gid;
57     char comm[MAX_COMM_LEN];
58     __u32 size;     // number pf pages operated, generally either is 1 or 0
59     __u32 nips;
60     __u64 ips[MAX_STACK_LIMIT];
61 };
62 
63 struct pf_stat_t {
64     __u64 count;          // total number of the event
65     __u64 tot_duration;   // total duration
66     __u32 min_duration;   // minimum duration
67     __u32 avg_duration;   // average duration
68     __u32 dev_duration;   // square of standard deviation duration
69     __u32 max_duration;   // maximum duration
70 };
71 /******************************* pstrace types END *******************************/
72 
73 
74 /******************************* biotrace types END *******************************/
75 enum BIOTraceEventType:__u32 {
76     BIO_DATA_READ = 1,
77     BIO_DATA_WRITE,
78     BIO_METADATA_READ,
79     BIO_METADATA_WRITE,
80     BIO_PAGE_IN,
81     BIO_PAGE_OUT,
82 };
83 
84 struct biotrace_start_event_t {
85     __u32 type;
86     __u32 pid;
87     __u64 stime;
88     __u32 tgid;
89     __u32 size;
90     char comm[MAX_COMM_LEN];
91 };
92 
93 struct biotrace_cmplt_event_t {
94     __u32 tracer;
95     struct biotrace_start_event_t start_event;
96     __u64 ctime;
97     __u64 blkcnt;
98     __u32 prio;
99     __u32 nips;
100     __u64 ips[MAX_STACK_LIMIT];
101 };
102 /******************************* biotrace types END *******************************/
103 
104 
105 /******************************* strtrace types BEGIN *******************************/
106 /* strtrace is artificial tracer used to collect user space strings */
107 struct strtrace_start_event_t {
108     __u32 type;
109     __u32 stracer;  // the source tracer which generates the strtrace event
110     __u64 stime;
111     const void *addr;
112 };
113 
114 struct strtrace_cmplt_event_t {
115     __u32 tracer;
116     struct strtrace_start_event_t start_event;
117     __u32 pid;
118     __u32 tgid;
119     __u32 len;
120     char filename[MAX_FILENAME_LEN];
121 };
122 /******************************* strtrace types END *******************************/
123 
124 /******************************* uprobe types BEGIN *******************************/
125 struct dlopen_trace_start_event_t {
126     __u32 type;
127     __u32 tgid;
128 };
129 /******************************* uprobe types END *********************************/
130 
131 /******************************* hiebpf types BEGIN *******************************/
132 struct start_event_t {
133     /* useless definition */
134     union {
135         struct fstrace_start_event_t fs_se;
136         struct pftrace_start_event_t pf_se;
137         struct biotrace_start_event_t bio_se;
138     };
139 };
140 
141 enum TracerType:__u32 {
142     MAPSTRACE = 0,
143     SYMBOLTRACE,
144     FSTRACE,
145     PFTRACE,
146     BIOTRACE,
147     STRTRACE,
148     DLOPEN_TRACE,
149     KERNEL_SYM = 0x10001,
150     BADTRACE,
151 };
152 
153 enum LIBBPFLogLevel:int {
154     LIBBPF_NONE = -10,
155     LIBBPF_FATAL,
156     LIBBPF_ERROR,
157 };
158 
159 enum FSTraceEventGroup:int {
160     SYS_GROUP_OPEN = 1,
161     SYS_GROUP_READ,
162     SYS_GROUP_WRITE,
163     SYS_GROUP_CLOSE,
164 };
165 
166 /******************************* hiebpf types END *******************************/
167 #endif