1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2023 Huawei Device Co., Ltd.
4  */
5 #ifndef __UNIFIED_COLLECTION_DATA__
6 #define __UNIFIED_COLLECTION_DATA__
7 
8 #include <linux/ioctl.h>
9 
10 // kernel struct, modify at the same time
11 struct ucollection_process_cpu_item {
12 	int pid;
13 	unsigned int thread_total;
14 	unsigned long long min_flt;
15 	unsigned long long maj_flt;
16 	unsigned long long cpu_usage_utime;
17 	unsigned long long cpu_usage_stime;
18 	unsigned long long cpu_load_time;
19 };
20 
21 struct ucollection_process_filter {
22 	int uid;
23 	int pid;
24 	int tid;
25 };
26 
27 struct ucollection_process_cpu_entry {
28 	int magic;
29 	unsigned int total_count;
30 	unsigned int cur_count;
31 	struct ucollection_process_filter filter;
32 	struct ucollection_process_cpu_item datas[];
33 };
34 
35 struct ucollection_process_thread_count {
36 	int pid;
37 	unsigned int thread_count;
38 };
39 
40 struct ucollection_thread_cpu_item {
41 	int tid;
42 	char name[16]; // 16 : max length of thread name
43 	unsigned long long cpu_usage_utime;
44 	unsigned long long cpu_usage_stime;
45 	unsigned long long cpu_load_time;
46 };
47 
48 struct ucollection_thread_filter {
49 	int uid;
50 	int pid;
51 	int tid;
52 };
53 
54 struct ucollection_thread_cpu_entry {
55 	int magic;
56 	unsigned int total_count;
57 	unsigned int cur_count;
58 	struct ucollection_thread_filter filter;
59 	struct ucollection_thread_cpu_item datas[];
60 };
61 
62 enum collection_type {
63 	COLLECT_ALL_PROC = 1,
64 	COLLECT_THE_PROC,
65 	COLLECT_APP_PROC,
66 	COLLECT_PROC_COUNT,
67 	COLLECT_THREAD_COUNT,
68 	COLLECT_APP_THREAD,
69 	COLLECT_THE_THREAD,
70 	COLLECT_APP_THREAD_COUNT,
71 };
72 
73 #define DMIPS_NUM 128
74 #define IOCTRL_COLLECT_CPU_BASE 0
75 #define IOCTRL_COLLECT_ALL_PROC_CPU _IOR(IOCTRL_COLLECT_CPU_BASE, COLLECT_ALL_PROC, \
76 	struct ucollection_process_cpu_entry)
77 #define IOCTRL_COLLECT_THE_PROC_CPU _IOR(IOCTRL_COLLECT_CPU_BASE, COLLECT_THE_PROC, \
78 	struct ucollection_process_cpu_entry)
79 #define IOCTRL_COLLECT_THREAD_COUNT _IOR(IOCTRL_COLLECT_CPU_BASE, COLLECT_THREAD_COUNT, \
80 	struct ucollection_process_thread_count)
81 #define IOCTRL_COLLECT_APP_THREAD_COUNT _IOR(IOCTRL_COLLECT_CPU_BASE, COLLECT_APP_THREAD_COUNT, \
82 	struct ucollection_process_thread_count)
83 #define IOCTRL_COLLECT_APP_THREAD _IOR(IOCTRL_COLLECT_CPU_BASE, COLLECT_APP_THREAD, struct ucollection_thread_cpu_entry)
84 #define IOCTRL_COLLECT_THE_THREAD _IOR(IOCTRL_COLLECT_CPU_BASE, COLLECT_THE_THREAD, struct ucollection_thread_cpu_entry)
85 #define IOCTRL_COLLECT_PROC_COUNT _IOR(IOCTRL_COLLECT_CPU_BASE, COLLECT_PROC_COUNT, unsigned int)
86 #endif // __UNIFIED_COLLECTION_DATA__