xref: /titanic_44/usr/src/uts/common/sys/exacct_impl.h (revision b00044a2eb43864b8718585d21949611a2ee59ef)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_EXACCT_IMPL_H
28 #define	_SYS_EXACCT_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/types.h>
37 #include <sys/utsname.h>
38 #include <sys/zone.h>
39 
40 /*
41  * Setting the exacct error code.  libexacct provides more detailed codes for
42  * identifying causes of operational failure; the kernel doesn't use this
43  * facility, since the kernel operations can't fail.  (KM_SLEEP allocations,
44  * for instance.)
45  */
46 #ifdef _KERNEL
47 #define	EXACCT_SET_ERR(x)
48 #else /* _KERNEL */
49 extern void exacct_seterr(int);
50 #define	EXACCT_SET_ERR(x)   exacct_seterr(x)
51 #endif /* _KERNEL */
52 
53 typedef struct task_usage {
54 	hrtime_t tu_utime;	/* user time */
55 	hrtime_t tu_stime;	/* system time */
56 
57 	uint64_t tu_minflt;	/* minor faults */
58 	uint64_t tu_majflt;	/* major faults */
59 	uint64_t tu_sndmsg;	/* messages sent */
60 	uint64_t tu_rcvmsg;	/* messages received */
61 	uint64_t tu_ioch;	/* characters read and written */
62 	uint64_t tu_iblk;	/* input blocks */
63 	uint64_t tu_oblk;	/* output blocks */
64 	uint64_t tu_vcsw;	/* voluntary context switches */
65 	uint64_t tu_icsw;	/* involuntary context switches */
66 	uint64_t tu_nsig;	/* signals received */
67 	uint64_t tu_nswp;	/* swaps */
68 	uint64_t tu_nscl;	/* system calls */
69 	uint64_t tu_startsec;	/* start time (seconds) */
70 	uint64_t tu_startnsec;	/* start time (nanoseconds) */
71 	uint64_t tu_finishsec;	/* finish time (seconds) */
72 	uint64_t tu_finishnsec;	/* finish time (nanoseconds) */
73 	taskid_t tu_anctaskid;	/* ancestor task's ID */
74 } task_usage_t;
75 
76 typedef struct proc_usage {
77 	uint64_t pu_minflt;	/* minor faults */
78 	uint64_t pu_majflt;	/* major faults */
79 	uint64_t pu_sndmsg;	/* messages sent */
80 	uint64_t pu_rcvmsg;	/* messages received */
81 	uint64_t pu_ioch;	/* characters read and written */
82 	uint64_t pu_iblk;	/* input blocks */
83 	uint64_t pu_oblk;	/* output blocks */
84 	uint64_t pu_vcsw;	/* voluntary context switches */
85 	uint64_t pu_icsw;	/* involuntary context switches */
86 	uint64_t pu_nsig;	/* signals received */
87 	uint64_t pu_nswp;	/* swaps */
88 	uint64_t pu_nscl;	/* system calls */
89 	uint64_t pu_utimesec;	/* user time (seconds) */
90 	uint64_t pu_utimensec;	/* user time (nanoseconds) */
91 	uint64_t pu_stimesec;	/* system time (seconds) */
92 	uint64_t pu_stimensec;	/* system time (nanoseconds) */
93 	uint64_t pu_startsec;	/* start time (seconds) */
94 	uint64_t pu_startnsec;	/* start time (nanoseconds) */
95 	uint64_t pu_finishsec;	/* finish time (seconds) */
96 	uint64_t pu_finishnsec;	/* finish time (nanoseconds) */
97 	uint64_t pu_mem_rss_avg;	/* average RSS (K) */
98 	uint64_t pu_mem_rss_max;	/* peak RSS (K) */
99 
100 	pid_t pu_pid;		/* process ID */
101 	uid_t pu_ruid;		/* user ID */
102 	gid_t pu_rgid;		/* group ID */
103 	projid_t pu_projid;	/* project ID */
104 	taskid_t pu_taskid;	/* task ID */
105 	uint32_t pu_acflag;	/* accounting flags */
106 	char *pu_command;	/* command string */
107 	uint32_t pu_major;	/* major number of controlling tty */
108 	uint32_t pu_minor;	/* minor number of controlling tty */
109 	int pu_wstat;		/* wait() status */
110 	pid_t pu_ancpid;	/* ancestor process's ID */
111 	char pu_zonename[ZONENAME_MAX];	/* Zone name */
112 	char pu_nodename[_SYS_NMLN];
113 } proc_usage_t;
114 
115 typedef struct flow_usage {
116 	uint32_t fu_saddr[4];	/* source address */
117 	uint32_t fu_daddr[4];	/* remote address */
118 	uint8_t fu_protocol;	/* protocol type */
119 	uint16_t fu_sport;	/* source port */
120 	uint16_t fu_dport;	/* remote port */
121 	uint8_t fu_dsfield;	/* DS field */
122 	uint32_t fu_nbytes;	/* number of bytes (incl. IP header) */
123 	uint32_t fu_npackets;	/* number of packets */
124 	uint64_t fu_ctime;	/* creation time for this item */
125 	uint64_t fu_lseen;	/* when the last item of this desc. was seen */
126 	projid_t fu_projid;	/* project ID */
127 	uid_t fu_userid;		/* user ID */
128 	boolean_t fu_isv4;	/* to extract the correct l/r-addr */
129 	char *fu_aname;		/* action instance name */
130 } flow_usage_t;
131 
132 extern void exacct_order16(uint16_t *);
133 extern void exacct_order32(uint32_t *);
134 extern void exacct_order64(uint64_t *);
135 
136 #ifdef	__cplusplus
137 }
138 #endif
139 
140 #endif	/* _SYS_EXACCT_IMPL_H */
141