1*86d7f5d3SJohn Marino /* 2*86d7f5d3SJohn Marino * Copyright (c) 1997, 1998 Kenneth D. Merry. 3*86d7f5d3SJohn Marino * All rights reserved. 4*86d7f5d3SJohn Marino * 5*86d7f5d3SJohn Marino * Redistribution and use in source and binary forms, with or without 6*86d7f5d3SJohn Marino * modification, are permitted provided that the following conditions 7*86d7f5d3SJohn Marino * are met: 8*86d7f5d3SJohn Marino * 1. Redistributions of source code must retain the above copyright 9*86d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer. 10*86d7f5d3SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright 11*86d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer in the 12*86d7f5d3SJohn Marino * documentation and/or other materials provided with the distribution. 13*86d7f5d3SJohn Marino * 3. The name of the author may not be used to endorse or promote products 14*86d7f5d3SJohn Marino * derived from this software without specific prior written permission. 15*86d7f5d3SJohn Marino * 16*86d7f5d3SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17*86d7f5d3SJohn Marino * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*86d7f5d3SJohn Marino * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*86d7f5d3SJohn Marino * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20*86d7f5d3SJohn Marino * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21*86d7f5d3SJohn Marino * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22*86d7f5d3SJohn Marino * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23*86d7f5d3SJohn Marino * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24*86d7f5d3SJohn Marino * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25*86d7f5d3SJohn Marino * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26*86d7f5d3SJohn Marino * SUCH DAMAGE. 27*86d7f5d3SJohn Marino * 28*86d7f5d3SJohn Marino * $FreeBSD: src/lib/libdevstat/devstat.h,v 1.3 1999/08/28 00:04:27 peter Exp $ 29*86d7f5d3SJohn Marino * $DragonFly: src/lib/libdevstat/devstat.h,v 1.4 2005/01/08 19:19:26 joerg Exp $ 30*86d7f5d3SJohn Marino */ 31*86d7f5d3SJohn Marino 32*86d7f5d3SJohn Marino #ifndef _DEVSTAT_H 33*86d7f5d3SJohn Marino #define _DEVSTAT_H 34*86d7f5d3SJohn Marino #include <sys/cdefs.h> 35*86d7f5d3SJohn Marino #include <sys/devicestat.h> 36*86d7f5d3SJohn Marino 37*86d7f5d3SJohn Marino #define DEVSTAT_ERRBUF_SIZE 2048 /* size of the devstat library error string */ 38*86d7f5d3SJohn Marino 39*86d7f5d3SJohn Marino extern char devstat_errbuf[]; 40*86d7f5d3SJohn Marino 41*86d7f5d3SJohn Marino typedef enum { 42*86d7f5d3SJohn Marino DEVSTAT_MATCH_NONE = 0x00, 43*86d7f5d3SJohn Marino DEVSTAT_MATCH_TYPE = 0x01, 44*86d7f5d3SJohn Marino DEVSTAT_MATCH_IF = 0x02, 45*86d7f5d3SJohn Marino DEVSTAT_MATCH_PASS = 0x04 46*86d7f5d3SJohn Marino } devstat_match_flags; 47*86d7f5d3SJohn Marino 48*86d7f5d3SJohn Marino struct devstat_match { 49*86d7f5d3SJohn Marino devstat_match_flags match_fields; 50*86d7f5d3SJohn Marino devstat_type_flags device_type; 51*86d7f5d3SJohn Marino int num_match_categories; 52*86d7f5d3SJohn Marino }; 53*86d7f5d3SJohn Marino 54*86d7f5d3SJohn Marino struct devstat_match_table { 55*86d7f5d3SJohn Marino const char *match_str; 56*86d7f5d3SJohn Marino devstat_type_flags type; 57*86d7f5d3SJohn Marino devstat_match_flags match_field; 58*86d7f5d3SJohn Marino }; 59*86d7f5d3SJohn Marino 60*86d7f5d3SJohn Marino struct device_selection { 61*86d7f5d3SJohn Marino u_int32_t device_number; 62*86d7f5d3SJohn Marino char device_name[DEVSTAT_NAME_LEN]; 63*86d7f5d3SJohn Marino int unit_number; 64*86d7f5d3SJohn Marino int selected; 65*86d7f5d3SJohn Marino u_int64_t bytes; 66*86d7f5d3SJohn Marino int position; 67*86d7f5d3SJohn Marino }; 68*86d7f5d3SJohn Marino 69*86d7f5d3SJohn Marino struct devinfo { 70*86d7f5d3SJohn Marino struct devstat *devices; 71*86d7f5d3SJohn Marino u_int8_t *mem_ptr; 72*86d7f5d3SJohn Marino long generation; 73*86d7f5d3SJohn Marino int numdevs; 74*86d7f5d3SJohn Marino }; 75*86d7f5d3SJohn Marino 76*86d7f5d3SJohn Marino struct statinfo { 77*86d7f5d3SJohn Marino struct devinfo *dinfo; 78*86d7f5d3SJohn Marino struct timeval busy_time; 79*86d7f5d3SJohn Marino }; 80*86d7f5d3SJohn Marino 81*86d7f5d3SJohn Marino typedef enum { 82*86d7f5d3SJohn Marino DS_SELECT_ADD, 83*86d7f5d3SJohn Marino DS_SELECT_ONLY, 84*86d7f5d3SJohn Marino DS_SELECT_REMOVE, 85*86d7f5d3SJohn Marino DS_SELECT_ADDONLY 86*86d7f5d3SJohn Marino } devstat_select_mode; 87*86d7f5d3SJohn Marino 88*86d7f5d3SJohn Marino __BEGIN_DECLS 89*86d7f5d3SJohn Marino int getnumdevs(void); 90*86d7f5d3SJohn Marino long getgeneration(void); 91*86d7f5d3SJohn Marino int getversion(void); 92*86d7f5d3SJohn Marino int checkversion(void); 93*86d7f5d3SJohn Marino int getdevs(struct statinfo *stats); 94*86d7f5d3SJohn Marino int selectdevs(struct device_selection **dev_select, int *num_selected, 95*86d7f5d3SJohn Marino int *num_selections, long *select_generation, 96*86d7f5d3SJohn Marino long current_generation, struct devstat *devices, int numdevs, 97*86d7f5d3SJohn Marino struct devstat_match *matches, int num_matches, 98*86d7f5d3SJohn Marino char **dev_selections, int num_dev_selections, 99*86d7f5d3SJohn Marino devstat_select_mode select_mode, int maxshowdevs, 100*86d7f5d3SJohn Marino int perf_select); 101*86d7f5d3SJohn Marino int buildmatch(const char *match_str, struct devstat_match **matches, 102*86d7f5d3SJohn Marino int *num_matches); 103*86d7f5d3SJohn Marino int compute_stats(struct devstat *current, struct devstat *previous, 104*86d7f5d3SJohn Marino long double etime, u_int64_t *total_bytes, 105*86d7f5d3SJohn Marino u_int64_t *total_transfers, u_int64_t *total_blocks, 106*86d7f5d3SJohn Marino long double *kb_per_transfer, 107*86d7f5d3SJohn Marino long double *transfers_per_second, long double *mb_per_second, 108*86d7f5d3SJohn Marino long double *blocks_per_second, 109*86d7f5d3SJohn Marino long double *ms_per_transaction); 110*86d7f5d3SJohn Marino int compute_stats_read(struct devstat *current, struct devstat *previous, 111*86d7f5d3SJohn Marino long double etime, u_int64_t *total_bytes, 112*86d7f5d3SJohn Marino u_int64_t *total_transfers, u_int64_t *total_blocks, 113*86d7f5d3SJohn Marino long double *kb_per_transfer, 114*86d7f5d3SJohn Marino long double *transfers_per_second, long double *mb_per_second, 115*86d7f5d3SJohn Marino long double *blocks_per_second, 116*86d7f5d3SJohn Marino long double *ms_per_transaction); 117*86d7f5d3SJohn Marino int compute_stats_write(struct devstat *current, struct devstat *previous, 118*86d7f5d3SJohn Marino long double etime, u_int64_t *total_bytes, 119*86d7f5d3SJohn Marino u_int64_t *total_transfers, u_int64_t *total_blocks, 120*86d7f5d3SJohn Marino long double *kb_per_transfer, 121*86d7f5d3SJohn Marino long double *transfers_per_second, long double *mb_per_second, 122*86d7f5d3SJohn Marino long double *blocks_per_second, 123*86d7f5d3SJohn Marino long double *ms_per_transaction); 124*86d7f5d3SJohn Marino long double compute_etime(struct timeval cur_time, struct timeval prev_time); 125*86d7f5d3SJohn Marino __END_DECLS 126*86d7f5d3SJohn Marino 127*86d7f5d3SJohn Marino #endif /* _DEVSTAT_H */ 128