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