devicestat.h revision 60833
198943Sluigi/* 2117328Sluigi * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry. 398943Sluigi * All rights reserved. 498943Sluigi * 598943Sluigi * Redistribution and use in source and binary forms, with or without 698943Sluigi * modification, are permitted provided that the following conditions 798943Sluigi * are met: 898943Sluigi * 1. Redistributions of source code must retain the above copyright 998943Sluigi * notice, this list of conditions and the following disclaimer. 1098943Sluigi * 2. Redistributions in binary form must reproduce the above copyright 1198943Sluigi * notice, this list of conditions and the following disclaimer in the 1298943Sluigi * documentation and/or other materials provided with the distribution. 1398943Sluigi * 3. The name of the author may not be used to endorse or promote products 1498943Sluigi * derived from this software without specific prior written permission. 1598943Sluigi * 1698943Sluigi * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1798943Sluigi * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1898943Sluigi * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1998943Sluigi * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2098943Sluigi * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2198943Sluigi * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2298943Sluigi * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23187604Sluigi * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2498943Sluigi * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2598943Sluigi * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2698943Sluigi * SUCH DAMAGE. 2798943Sluigi * 28187767Sluigi * $FreeBSD: head/sys/sys/devicestat.h 60833 2000-05-23 20:41:01Z jake $ 29187767Sluigi */ 3098943Sluigi 3198943Sluigi#ifndef _DEVICESTAT_H 3298943Sluigi#define _DEVICESTAT_H 3398943Sluigi 3498943Sluigi#include <sys/queue.h> 3598943Sluigi#include <sys/time.h> 3698943Sluigi 3798943Sluigi#define DEVSTAT_NAME_LEN 16 3898943Sluigi 3998943Sluigi/* 40187604Sluigi * ATTENTION: The devstat version below should be incremented any time a 41136071Sgreen * change is made in struct devstat, or any time a change is made in the 42136071Sgreen * enumerated types that struct devstat uses. (Only if those changes 4398943Sluigi * would require a recompile -- i.e. re-arranging the order of an 44175659Srwatson * enumerated type or something like that.) This version number is used by 45175659Srwatson * userland utilities to determine whether or not they are in sync with the 46169424Smaxim * kernel. 4798943Sluigi */ 48165648Spiso#define DEVSTAT_VERSION 4 49136071Sgreen 50145246Sbrooks/* 5198943Sluigi * These flags specify which statistics features are supported or not 5298943Sluigi * supported by a particular device. The default is all statistics are 5398943Sluigi * supported. 5498943Sluigi */ 5598943Sluigitypedef enum { 5698943Sluigi DEVSTAT_ALL_SUPPORTED = 0x00, 5798943Sluigi DEVSTAT_NO_BLOCKSIZE = 0x01, 5898943Sluigi DEVSTAT_NO_ORDERED_TAGS = 0x02, 59187767Sluigi DEVSTAT_BS_UNAVAILABLE = 0x04 6098943Sluigi} devstat_support_flags; 61187767Sluigi 62187764Sluigitypedef enum { 63159636Soleg DEVSTAT_NO_DATA = 0x00, 64159636Soleg DEVSTAT_READ = 0x01, 65159636Soleg DEVSTAT_WRITE = 0x02, 66159636Soleg DEVSTAT_FREE = 0x03 67159636Soleg} devstat_trans_flags; 68159636Soleg 69159636Solegtypedef enum { 70159636Soleg DEVSTAT_TAG_SIMPLE = 0x00, 71159636Soleg DEVSTAT_TAG_HEAD = 0x01, 72159636Soleg DEVSTAT_TAG_ORDERED = 0x02, 73159636Soleg DEVSTAT_TAG_NONE = 0x03 74159636Soleg} devstat_tag_type; 75159636Soleg 76159636Solegtypedef enum { 77159636Soleg DEVSTAT_PRIORITY_MIN = 0x000, 78159636Soleg DEVSTAT_PRIORITY_OTHER = 0x020, 79159636Soleg DEVSTAT_PRIORITY_PASS = 0x030, 80159636Soleg DEVSTAT_PRIORITY_FD = 0x040, 81159636Soleg DEVSTAT_PRIORITY_WFD = 0x050, 82159636Soleg DEVSTAT_PRIORITY_TAPE = 0x060, 83159636Soleg DEVSTAT_PRIORITY_CD = 0x090, 84159636Soleg DEVSTAT_PRIORITY_DISK = 0x110, 85159636Soleg DEVSTAT_PRIORITY_ARRAY = 0x120, 86159636Soleg DEVSTAT_PRIORITY_MAX = 0xfff 87159636Soleg} devstat_priority; 88159636Soleg 89159636Soleg/* 90158879Soleg * These types are intended to aid statistics gathering/display programs. 91158879Soleg * The first 13 types (up to the 'target' flag) are identical numerically 92187762Sluigi * to the SCSI device type numbers. The next 3 types designate the device 93187762Sluigi * interface. Currently the choices are IDE, SCSI, and 'other'. The last 94187762Sluigi * flag specifies whether or not the given device is a passthrough device 95187762Sluigi * or not. If it is a passthrough device, the lower 4 bits specify which 96187762Sluigi * type of physical device lies under the passthrough device, and the next 97187762Sluigi * 4 bits specify the interface. 98187762Sluigi */ 99187762Sluigitypedef enum { 100187762Sluigi DEVSTAT_TYPE_DIRECT = 0x000, 101187762Sluigi DEVSTAT_TYPE_SEQUENTIAL = 0x001, 102159636Soleg DEVSTAT_TYPE_PRINTER = 0x002, 10398943Sluigi DEVSTAT_TYPE_PROCESSOR = 0x003, 10498943Sluigi DEVSTAT_TYPE_WORM = 0x004, 10598943Sluigi DEVSTAT_TYPE_CDROM = 0x005, 10698943Sluigi DEVSTAT_TYPE_SCANNER = 0x006, 10798943Sluigi DEVSTAT_TYPE_OPTICAL = 0x007, 10898943Sluigi DEVSTAT_TYPE_CHANGER = 0x008, 10998943Sluigi DEVSTAT_TYPE_COMM = 0x009, 11098943Sluigi DEVSTAT_TYPE_ASC0 = 0x00a, 11198943Sluigi DEVSTAT_TYPE_ASC1 = 0x00b, 11298943Sluigi DEVSTAT_TYPE_STORARRAY = 0x00c, 11398943Sluigi DEVSTAT_TYPE_ENCLOSURE = 0x00d, 11498943Sluigi DEVSTAT_TYPE_FLOPPY = 0x00e, 11598943Sluigi DEVSTAT_TYPE_MASK = 0x00f, 11698943Sluigi DEVSTAT_TYPE_IF_SCSI = 0x010, 11798943Sluigi DEVSTAT_TYPE_IF_IDE = 0x020, 11898943Sluigi DEVSTAT_TYPE_IF_OTHER = 0x030, 11998943Sluigi DEVSTAT_TYPE_IF_MASK = 0x0f0, 12098943Sluigi DEVSTAT_TYPE_PASS = 0x100 12198943Sluigi} devstat_type_flags; 12298943Sluigi 12398943Sluigistruct devstat { 12498943Sluigi STAILQ_ENTRY(struct devstat) dev_links; 12598943Sluigi u_int32_t device_number; /* 12698943Sluigi * Devstat device 12798943Sluigi * number. 12898943Sluigi */ 12998943Sluigi char device_name[DEVSTAT_NAME_LEN]; 13098943Sluigi int unit_number; 13198943Sluigi u_int64_t bytes_read; /* 13298943Sluigi * Total bytes read 13398943Sluigi * from a device. 13498943Sluigi */ 13598943Sluigi u_int64_t bytes_written; /* 13698943Sluigi * Total bytes written 13798943Sluigi * to a device. 13898943Sluigi */ 13998943Sluigi u_int64_t bytes_freed; /* 14098943Sluigi * Total bytes freed 14198943Sluigi * from a device. 14298943Sluigi */ 14398943Sluigi u_int64_t num_reads; /* 144172801Srpaulo * Total number of 145172801Srpaulo * read requests to 14698943Sluigi * the device. 14798943Sluigi */ 14898943Sluigi u_int64_t num_writes; /* 14998943Sluigi * Total number of 15098943Sluigi * write requests to 15198943Sluigi * the device. 15298943Sluigi */ 15398943Sluigi u_int64_t num_frees; /* 15498943Sluigi * Total number of 15598943Sluigi * free requests to 15698943Sluigi * the device. 15798943Sluigi */ 15898943Sluigi u_int64_t num_other; /* 15998943Sluigi * Total number of 16098943Sluigi * transactions that 16198943Sluigi * don't read or write 16298943Sluigi * data. 16398943Sluigi */ 16498943Sluigi int32_t busy_count; /* 16598943Sluigi * Total number of 16698943Sluigi * transactions 16798943Sluigi * outstanding for 16898943Sluigi * the device. 16998943Sluigi */ 17098943Sluigi u_int32_t block_size; /* Block size, bytes */ 17198943Sluigi u_int64_t tag_types[3]; /* 17298943Sluigi * The number of 17398943Sluigi * simple, ordered, 17498943Sluigi * and head of queue 17598943Sluigi * tags sent. 17698943Sluigi */ 17798943Sluigi struct timeval dev_creation_time; /* 17898943Sluigi * Time the device was 17998943Sluigi * created. 18098943Sluigi */ 18198943Sluigi struct timeval busy_time; /* 18298943Sluigi * Total amount of 18398943Sluigi * time drive has spent 18498943Sluigi * processing requests. 18598943Sluigi */ 18698943Sluigi struct timeval start_time; /* 18798943Sluigi * The time when 18898943Sluigi * busy_count was 18998943Sluigi * last == 0. Or, the 19098943Sluigi * start of the latest 19198943Sluigi * busy period. 19298943Sluigi */ 193187769Sluigi struct timeval last_comp_time; /* 19498943Sluigi * Last time a 19598943Sluigi * transaction was 19698943Sluigi * completed. 19798943Sluigi */ 19898943Sluigi 19998943Sluigi devstat_support_flags flags; /* 20098943Sluigi * Which statistics 20198943Sluigi * are supported by a 20298943Sluigi * given device. 203141351Sglebius */ 204141351Sglebius devstat_type_flags device_type; /* Device type */ 20598943Sluigi devstat_priority priority; /* Controls list pos. */ 20698943Sluigi}; 20798943Sluigi 20898943Sluigi#ifdef _KERNEL 20998943Sluigistruct bio; 21098943Sluigi 211149020Sbzvoid devstat_add_entry(struct devstat *ds, const char *dev_name, 21298943Sluigi int unit_number, u_int32_t block_size, 213149020Sbz devstat_support_flags flags, 21499475Sluigi devstat_type_flags device_type, 21598943Sluigi devstat_priority priority); 216117469Sluigivoid devstat_remove_entry(struct devstat *ds); 217165648Spisovoid devstat_start_transaction(struct devstat *ds); 218178888Sjulianvoid devstat_end_transaction(struct devstat *ds, u_int32_t bytes, 219117328Sluigi devstat_tag_type tag_type, 22098943Sluigi devstat_trans_flags flags); 22198943Sluigivoid devstat_end_transaction_bio(struct devstat *ds, struct bio *bp); 222187769Sluigi#endif 223136071Sgreen 224136071Sgreen#endif /* _DEVICESTAT_H */ 225158879Soleg