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