xref: /titanic_41/usr/src/uts/common/sys/exacct_impl.h (revision da14cebe459d3275048785f25bd869cb09b5307f)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*da14cebeSEric Cheng  * Common Development and Distribution License (the "License").
6*da14cebeSEric Cheng  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*da14cebeSEric Cheng  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_EXACCT_IMPL_H
277c478bd9Sstevel@tonic-gate #define	_SYS_EXACCT_IMPL_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/types.h>
347c478bd9Sstevel@tonic-gate #include <sys/utsname.h>
357c478bd9Sstevel@tonic-gate #include <sys/zone.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate /*
387c478bd9Sstevel@tonic-gate  * Setting the exacct error code.  libexacct provides more detailed codes for
397c478bd9Sstevel@tonic-gate  * identifying causes of operational failure; the kernel doesn't use this
407c478bd9Sstevel@tonic-gate  * facility, since the kernel operations can't fail.  (KM_SLEEP allocations,
417c478bd9Sstevel@tonic-gate  * for instance.)
427c478bd9Sstevel@tonic-gate  */
437c478bd9Sstevel@tonic-gate #ifdef _KERNEL
447c478bd9Sstevel@tonic-gate #define	EXACCT_SET_ERR(x)
457c478bd9Sstevel@tonic-gate #else /* _KERNEL */
467c478bd9Sstevel@tonic-gate extern void exacct_seterr(int);
477c478bd9Sstevel@tonic-gate #define	EXACCT_SET_ERR(x)   exacct_seterr(x)
487c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate typedef struct task_usage {
517c478bd9Sstevel@tonic-gate 	hrtime_t tu_utime;	/* user time */
527c478bd9Sstevel@tonic-gate 	hrtime_t tu_stime;	/* system time */
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate 	uint64_t tu_minflt;	/* minor faults */
557c478bd9Sstevel@tonic-gate 	uint64_t tu_majflt;	/* major faults */
567c478bd9Sstevel@tonic-gate 	uint64_t tu_sndmsg;	/* messages sent */
577c478bd9Sstevel@tonic-gate 	uint64_t tu_rcvmsg;	/* messages received */
587c478bd9Sstevel@tonic-gate 	uint64_t tu_ioch;	/* characters read and written */
597c478bd9Sstevel@tonic-gate 	uint64_t tu_iblk;	/* input blocks */
607c478bd9Sstevel@tonic-gate 	uint64_t tu_oblk;	/* output blocks */
617c478bd9Sstevel@tonic-gate 	uint64_t tu_vcsw;	/* voluntary context switches */
627c478bd9Sstevel@tonic-gate 	uint64_t tu_icsw;	/* involuntary context switches */
637c478bd9Sstevel@tonic-gate 	uint64_t tu_nsig;	/* signals received */
647c478bd9Sstevel@tonic-gate 	uint64_t tu_nswp;	/* swaps */
657c478bd9Sstevel@tonic-gate 	uint64_t tu_nscl;	/* system calls */
667c478bd9Sstevel@tonic-gate 	uint64_t tu_startsec;	/* start time (seconds) */
677c478bd9Sstevel@tonic-gate 	uint64_t tu_startnsec;	/* start time (nanoseconds) */
687c478bd9Sstevel@tonic-gate 	uint64_t tu_finishsec;	/* finish time (seconds) */
697c478bd9Sstevel@tonic-gate 	uint64_t tu_finishnsec;	/* finish time (nanoseconds) */
707c478bd9Sstevel@tonic-gate 	taskid_t tu_anctaskid;	/* ancestor task's ID */
717c478bd9Sstevel@tonic-gate } task_usage_t;
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate typedef struct proc_usage {
747c478bd9Sstevel@tonic-gate 	uint64_t pu_minflt;	/* minor faults */
757c478bd9Sstevel@tonic-gate 	uint64_t pu_majflt;	/* major faults */
767c478bd9Sstevel@tonic-gate 	uint64_t pu_sndmsg;	/* messages sent */
777c478bd9Sstevel@tonic-gate 	uint64_t pu_rcvmsg;	/* messages received */
787c478bd9Sstevel@tonic-gate 	uint64_t pu_ioch;	/* characters read and written */
797c478bd9Sstevel@tonic-gate 	uint64_t pu_iblk;	/* input blocks */
807c478bd9Sstevel@tonic-gate 	uint64_t pu_oblk;	/* output blocks */
817c478bd9Sstevel@tonic-gate 	uint64_t pu_vcsw;	/* voluntary context switches */
827c478bd9Sstevel@tonic-gate 	uint64_t pu_icsw;	/* involuntary context switches */
837c478bd9Sstevel@tonic-gate 	uint64_t pu_nsig;	/* signals received */
847c478bd9Sstevel@tonic-gate 	uint64_t pu_nswp;	/* swaps */
857c478bd9Sstevel@tonic-gate 	uint64_t pu_nscl;	/* system calls */
867c478bd9Sstevel@tonic-gate 	uint64_t pu_utimesec;	/* user time (seconds) */
877c478bd9Sstevel@tonic-gate 	uint64_t pu_utimensec;	/* user time (nanoseconds) */
887c478bd9Sstevel@tonic-gate 	uint64_t pu_stimesec;	/* system time (seconds) */
897c478bd9Sstevel@tonic-gate 	uint64_t pu_stimensec;	/* system time (nanoseconds) */
907c478bd9Sstevel@tonic-gate 	uint64_t pu_startsec;	/* start time (seconds) */
917c478bd9Sstevel@tonic-gate 	uint64_t pu_startnsec;	/* start time (nanoseconds) */
927c478bd9Sstevel@tonic-gate 	uint64_t pu_finishsec;	/* finish time (seconds) */
937c478bd9Sstevel@tonic-gate 	uint64_t pu_finishnsec;	/* finish time (nanoseconds) */
947c478bd9Sstevel@tonic-gate 	uint64_t pu_mem_rss_avg;	/* average RSS (K) */
957c478bd9Sstevel@tonic-gate 	uint64_t pu_mem_rss_max;	/* peak RSS (K) */
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate 	pid_t pu_pid;		/* process ID */
987c478bd9Sstevel@tonic-gate 	uid_t pu_ruid;		/* user ID */
997c478bd9Sstevel@tonic-gate 	gid_t pu_rgid;		/* group ID */
1007c478bd9Sstevel@tonic-gate 	projid_t pu_projid;	/* project ID */
1017c478bd9Sstevel@tonic-gate 	taskid_t pu_taskid;	/* task ID */
1027c478bd9Sstevel@tonic-gate 	uint32_t pu_acflag;	/* accounting flags */
1037c478bd9Sstevel@tonic-gate 	char *pu_command;	/* command string */
1047c478bd9Sstevel@tonic-gate 	uint32_t pu_major;	/* major number of controlling tty */
1057c478bd9Sstevel@tonic-gate 	uint32_t pu_minor;	/* minor number of controlling tty */
1067c478bd9Sstevel@tonic-gate 	int pu_wstat;		/* wait() status */
1077c478bd9Sstevel@tonic-gate 	pid_t pu_ancpid;	/* ancestor process's ID */
1087c478bd9Sstevel@tonic-gate 	char pu_zonename[ZONENAME_MAX];	/* Zone name */
1097c478bd9Sstevel@tonic-gate 	char pu_nodename[_SYS_NMLN];
1107c478bd9Sstevel@tonic-gate } proc_usage_t;
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate typedef struct flow_usage {
1137c478bd9Sstevel@tonic-gate 	uint32_t fu_saddr[4];	/* source address */
1147c478bd9Sstevel@tonic-gate 	uint32_t fu_daddr[4];	/* remote address */
1157c478bd9Sstevel@tonic-gate 	uint8_t fu_protocol;	/* protocol type */
1167c478bd9Sstevel@tonic-gate 	uint16_t fu_sport;	/* source port */
1177c478bd9Sstevel@tonic-gate 	uint16_t fu_dport;	/* remote port */
1187c478bd9Sstevel@tonic-gate 	uint8_t fu_dsfield;	/* DS field */
1197c478bd9Sstevel@tonic-gate 	uint32_t fu_nbytes;	/* number of bytes (incl. IP header) */
1207c478bd9Sstevel@tonic-gate 	uint32_t fu_npackets;	/* number of packets */
1217c478bd9Sstevel@tonic-gate 	uint64_t fu_ctime;	/* creation time for this item */
1227c478bd9Sstevel@tonic-gate 	uint64_t fu_lseen;	/* when the last item of this desc. was seen */
1237c478bd9Sstevel@tonic-gate 	projid_t fu_projid;	/* project ID */
1247c478bd9Sstevel@tonic-gate 	uid_t fu_userid;		/* user ID */
1257c478bd9Sstevel@tonic-gate 	boolean_t fu_isv4;	/* to extract the correct l/r-addr */
1267c478bd9Sstevel@tonic-gate 	char *fu_aname;		/* action instance name */
1277c478bd9Sstevel@tonic-gate } flow_usage_t;
1287c478bd9Sstevel@tonic-gate 
129*da14cebeSEric Cheng #define	EX_NET_LNDESC_REC 1
130*da14cebeSEric Cheng #define	EX_NET_FLDESC_REC 2
131*da14cebeSEric Cheng #define	EX_NET_LNSTAT_REC 3
132*da14cebeSEric Cheng #define	EX_NET_FLSTAT_REC 4
133*da14cebeSEric Cheng 
134*da14cebeSEric Cheng typedef struct net_stat_s {
135*da14cebeSEric Cheng 	char		*ns_name;
136*da14cebeSEric Cheng 	uint64_t	ns_ibytes;
137*da14cebeSEric Cheng 	uint64_t	ns_obytes;
138*da14cebeSEric Cheng 	uint64_t	ns_ipackets;
139*da14cebeSEric Cheng 	uint64_t	ns_opackets;
140*da14cebeSEric Cheng 	uint64_t	ns_ierrors;
141*da14cebeSEric Cheng 	uint64_t	ns_oerrors;
142*da14cebeSEric Cheng 	boolean_t	ns_isref;
143*da14cebeSEric Cheng } net_stat_t;
144*da14cebeSEric Cheng 
145*da14cebeSEric Cheng typedef struct net_desc_s {
146*da14cebeSEric Cheng 	char		*nd_name;
147*da14cebeSEric Cheng 	char		*nd_devname;
148*da14cebeSEric Cheng 	uchar_t		nd_ehost[6];
149*da14cebeSEric Cheng 	uchar_t		nd_edest[6];
150*da14cebeSEric Cheng 	ushort_t	nd_vlan_tpid;
151*da14cebeSEric Cheng 	ushort_t	nd_vlan_tci;
152*da14cebeSEric Cheng 	ushort_t	nd_sap;
153*da14cebeSEric Cheng 	ushort_t	nd_priority;
154*da14cebeSEric Cheng 	uint64_t	nd_bw_limit;
155*da14cebeSEric Cheng 	uint32_t	nd_saddr[4];
156*da14cebeSEric Cheng 	uint32_t	nd_daddr[4];
157*da14cebeSEric Cheng 	boolean_t	nd_isv4;
158*da14cebeSEric Cheng 	uint16_t	nd_sport;
159*da14cebeSEric Cheng 	uint16_t	nd_dport;
160*da14cebeSEric Cheng 	uint8_t		nd_protocol;
161*da14cebeSEric Cheng 	uint8_t		nd_dsfield;
162*da14cebeSEric Cheng 	int		nd_type;
163*da14cebeSEric Cheng } net_desc_t;
164*da14cebeSEric Cheng 
1657c478bd9Sstevel@tonic-gate extern void exacct_order16(uint16_t *);
1667c478bd9Sstevel@tonic-gate extern void exacct_order32(uint32_t *);
1677c478bd9Sstevel@tonic-gate extern void exacct_order64(uint64_t *);
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1707c478bd9Sstevel@tonic-gate }
1717c478bd9Sstevel@tonic-gate #endif
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate #endif	/* _SYS_EXACCT_IMPL_H */
174