Home | History | Annotate | Download | only in common
      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	_FB_STATS_H
     27 #define	_FB_STATS_H
     28 
     29 #include "config.h"
     30 #ifdef HAVE_STDINT_H
     31 #include <stdint.h>
     32 #endif
     33 
     34 #ifdef	__cplusplus
     35 extern "C" {
     36 #endif
     37 
     38 var_t *stats_findvar(var_t *var, char *name);
     39 void stats_init(void);
     40 void stats_clear(void);
     41 void stats_snap(void);
     42 void stats_dump(char *filename);
     43 void stats_xmldump(char *filename);
     44 void stats_multidump(char *filename);
     45 
     46 #ifndef HAVE_HRTIME
     47 /* typedef uint64_t hrtime_t; */
     48 #define	hrtime_t uint64_t
     49 #endif
     50 
     51 #define	STATS_VAR "stats."
     52 
     53 #define	FLOW_MSTATES 4
     54 #define	FLOW_MSTATE_LAT 0	/* Total service time of op */
     55 #define	FLOW_MSTATE_CPU 1	/* On-cpu time of op */
     56 #define	FLOW_MSTATE_WAIT 2	/* Wait-time, excluding waiting for CPU */
     57 #define	FLOW_MSTATE_OHEAD 3	/* overhead time, around op */
     58 
     59 typedef struct flowstats {
     60 	int		fs_children;	/* Number of contributors */
     61 	int		fs_active;	/* Number of active contributors */
     62 	int		fs_count;	/* Number of ops */
     63 	uint64_t	fs_rbytes;	/* Number of bytes  */
     64 	uint64_t	fs_wbytes;	/* Number of bytes  */
     65 	uint64_t	fs_bytes;	/* Number of bytes  */
     66 	uint64_t	fs_rcount;	/* Number of ops */
     67 	uint64_t	fs_wcount;	/* Number of ops */
     68 	hrtime_t	fs_stime;	/* Time stats for flow started */
     69 	hrtime_t	fs_etime;	/* Time stats for flow ended */
     70 	hrtime_t	fs_mstate[FLOW_MSTATES]; /* Microstate breakdown */
     71 	hrtime_t	fs_syscpu;	/* System wide cpu, global only */
     72 } flowstat_t;
     73 
     74 
     75 #define	IS_FLOW_IOP(x) (x->fo_stats.fs_rcount + x->fo_stats.fs_wcount)
     76 #define	STAT_IOPS(x)   ((x->fs_rcount) + (x->fs_wcount))
     77 #define	IS_FLOW_ACTIVE(x) (x->fo_stats.fs_count)
     78 #define	STAT_CPUTIME(x) (x->fs_cpu_op)
     79 #define	STAT_OHEADTIME(x) (x->fs_cpu_ohead)
     80 
     81 #ifdef	__cplusplus
     82 }
     83 #endif
     84 
     85 #endif	/* _FB_STATS_H */
     86