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