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