devicestat.h revision 51375
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 51375 1999-09-18 21:28:09Z phk $ 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/* 40187983Sluigi * ATTENTION: The devstat version below should be incremented any time a 41187604Sluigi * 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 43136071Sgreen * would require a recompile -- i.e. re-arranging the order of an 4498943Sluigi * enumerated type or something like that.) This version number is used by 45169424Smaxim * userland utilities to determine whether or not they are in sync with the 46187983Sluigi * kernel. 4798943Sluigi */ 48187983Sluigi#define DEVSTAT_VERSION 3 4998943Sluigi 5098943Sluigi/* 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 */ 55187767Sluigitypedef enum { 5698943Sluigi DEVSTAT_ALL_SUPPORTED = 0x00, 57187767Sluigi DEVSTAT_NO_BLOCKSIZE = 0x01, 58187764Sluigi DEVSTAT_NO_ORDERED_TAGS = 0x02, 59159636Soleg DEVSTAT_BS_UNAVAILABLE = 0x04 60204591Sluigi} devstat_support_flags; 61159636Soleg 62159636Solegtypedef enum { 63159636Soleg DEVSTAT_NO_DATA = 0x00, 64159636Soleg DEVSTAT_READ = 0x01, 65159636Soleg DEVSTAT_WRITE = 0x02, 66159636Soleg DEVSTAT_FREE = 0x03 67159636Soleg} devstat_trans_flags; 68204591Sluigi 69159636Solegtypedef enum { 70159636Soleg DEVSTAT_TAG_SIMPLE = 0x00, 71204591Sluigi DEVSTAT_TAG_HEAD = 0x01, 72159636Soleg DEVSTAT_TAG_ORDERED = 0x02, 73204591Sluigi DEVSTAT_TAG_NONE = 0x03 74159636Soleg} devstat_tag_type; 75159636Soleg 76159636Solegtypedef enum { 77204591Sluigi DEVSTAT_PRIORITY_MIN = 0x000, 78159636Soleg DEVSTAT_PRIORITY_OTHER = 0x020, 79159636Soleg DEVSTAT_PRIORITY_PASS = 0x030, 80159636Soleg DEVSTAT_PRIORITY_FD = 0x040, 81204591Sluigi DEVSTAT_PRIORITY_WFD = 0x050, 82159636Soleg DEVSTAT_PRIORITY_SA = 0x060, 83159636Soleg DEVSTAT_PRIORITY_OCD = 0x070, 84204591Sluigi DEVSTAT_PRIORITY_WCD = 0x080, 85159636Soleg DEVSTAT_PRIORITY_CD = 0x090, 86158879Soleg DEVSTAT_PRIORITY_WD = 0x100, 87158879Soleg DEVSTAT_PRIORITY_DA = 0x110, 88187762Sluigi DEVSTAT_PRIORITY_CCD = 0x120, 89187762Sluigi DEVSTAT_PRIORITY_MAX = 0xfff 90187762Sluigi} devstat_priority; 91187762Sluigi 92187762Sluigi/* 93187762Sluigi * These types are intended to aid statistics gathering/display programs. 94187762Sluigi * The first 13 types (up to the 'target' flag) are identical numerically 95187762Sluigi * to the SCSI device type numbers. The next 3 types designate the device 96187762Sluigi * interface. Currently the choices are IDE, SCSI, and 'other'. The last 97187762Sluigi * flag specifies whether or not the given device is a passthrough device 98159636Soleg * or not. If it is a passthrough device, the lower 4 bits specify which 9998943Sluigi * type of physical device lies under the passthrough device, and the next 10098943Sluigi * 4 bits specify the interface. 10198943Sluigi */ 10298943Sluigitypedef enum { 10398943Sluigi DEVSTAT_TYPE_DIRECT = 0x000, 10498943Sluigi DEVSTAT_TYPE_SEQUENTIAL = 0x001, 10598943Sluigi DEVSTAT_TYPE_PRINTER = 0x002, 10698943Sluigi DEVSTAT_TYPE_PROCESSOR = 0x003, 10798943Sluigi DEVSTAT_TYPE_WORM = 0x004, 10898943Sluigi DEVSTAT_TYPE_CDROM = 0x005, 10998943Sluigi DEVSTAT_TYPE_SCANNER = 0x006, 11098943Sluigi DEVSTAT_TYPE_OPTICAL = 0x007, 11198943Sluigi DEVSTAT_TYPE_CHANGER = 0x008, 11298943Sluigi DEVSTAT_TYPE_COMM = 0x009, 11398943Sluigi DEVSTAT_TYPE_ASC0 = 0x00a, 11498943Sluigi DEVSTAT_TYPE_ASC1 = 0x00b, 11598943Sluigi DEVSTAT_TYPE_STORARRAY = 0x00c, 11698943Sluigi DEVSTAT_TYPE_ENCLOSURE = 0x00d, 11798943Sluigi DEVSTAT_TYPE_FLOPPY = 0x00e, 11898943Sluigi DEVSTAT_TYPE_MASK = 0x00f, 11998943Sluigi DEVSTAT_TYPE_IF_SCSI = 0x010, 12098943Sluigi DEVSTAT_TYPE_IF_IDE = 0x020, 12198943Sluigi DEVSTAT_TYPE_IF_OTHER = 0x030, 12298943Sluigi DEVSTAT_TYPE_IF_MASK = 0x0f0, 12398943Sluigi DEVSTAT_TYPE_PASS = 0x100 12498943Sluigi} devstat_type_flags; 12598943Sluigi 12698943Sluigistruct devstat { 12798943Sluigi STAILQ_ENTRY(devstat) dev_links; 12898943Sluigi u_int32_t device_number; /* 12998943Sluigi * Devstat device 13098943Sluigi * number. 13198943Sluigi */ 13298943Sluigi char device_name[DEVSTAT_NAME_LEN]; 13398943Sluigi int unit_number; 13498943Sluigi u_int64_t bytes_read; /* 13598943Sluigi * Total bytes read 13698943Sluigi * from a device. 13798943Sluigi */ 13898943Sluigi u_int64_t bytes_written; /* 13998943Sluigi * Total bytes written 140172801Srpaulo * to a device. 141172801Srpaulo */ 14298943Sluigi u_int64_t bytes_freed; /* 14398943Sluigi * Total bytes freed 14498943Sluigi * from a device. 14598943Sluigi */ 14698943Sluigi u_int64_t num_reads; /* 14798943Sluigi * Total number of 14898943Sluigi * read requests to 14998943Sluigi * the device. 15098943Sluigi */ 15198943Sluigi u_int64_t num_writes; /* 15298943Sluigi * Total number of 15398943Sluigi * write requests to 15498943Sluigi * the device. 15598943Sluigi */ 15698943Sluigi u_int64_t num_frees; /* 15798943Sluigi * Total number of 15898943Sluigi * free requests to 15998943Sluigi * the device. 16098943Sluigi */ 16198943Sluigi u_int64_t num_other; /* 16298943Sluigi * Total number of 16398943Sluigi * transactions that 16498943Sluigi * don't read or write 16598943Sluigi * data. 16698943Sluigi */ 16798943Sluigi int32_t busy_count; /* 16898943Sluigi * Total number of 16998943Sluigi * transactions 17098943Sluigi * outstanding for 17198943Sluigi * the device. 17298943Sluigi */ 17398943Sluigi u_int32_t block_size; /* Block size, bytes */ 17498943Sluigi u_int64_t tag_types[3]; /* 17598943Sluigi * The number of 17698943Sluigi * simple, ordered, 17798943Sluigi * and head of queue 17898943Sluigi * tags sent. 17998943Sluigi */ 18098943Sluigi struct timeval dev_creation_time; /* 18198943Sluigi * Time the device was 18298943Sluigi * created. 18398943Sluigi */ 18498943Sluigi struct timeval busy_time; /* 18598943Sluigi * Total amount of 18698943Sluigi * time drive has spent 18798943Sluigi * processing requests. 18898943Sluigi */ 189187769Sluigi struct timeval start_time; /* 19098943Sluigi * The time when 19198943Sluigi * busy_count was 19298943Sluigi * last == 0. Or, the 19398943Sluigi * start of the latest 19498943Sluigi * busy period. 19598943Sluigi */ 19698943Sluigi struct timeval last_comp_time; /* 19798943Sluigi * Last time a 19898943Sluigi * transaction was 199141351Sglebius * completed. 200141351Sglebius */ 20198943Sluigi 20298943Sluigi devstat_support_flags flags; /* 20398943Sluigi * Which statistics 20498943Sluigi * are supported by a 20598943Sluigi * given device. 20698943Sluigi */ 207149020Sbz devstat_type_flags device_type; /* Device type */ 20898943Sluigi devstat_priority priority; /* Controls list pos. */ 209149020Sbz}; 21099475Sluigi 21198943Sluigi#ifdef KERNEL 212117469Sluigistruct buf; 213165648Spisovoid devstat_add_entry(struct devstat *ds, const char *dev_name, 214190633Spiso int unit_number, u_int32_t block_size, 215178888Sjulian devstat_support_flags flags, 216117328Sluigi devstat_type_flags device_type, 21798943Sluigi devstat_priority priority); 21898943Sluigivoid devstat_remove_entry(struct devstat *ds); 219187769Sluigivoid devstat_start_transaction(struct devstat *ds); 220136071Sgreenvoid devstat_end_transaction(struct devstat *ds, u_int32_t bytes, 221136071Sgreen devstat_tag_type tag_type, 222158879Soleg devstat_trans_flags flags); 223158879Solegvoid devstat_end_transaction_buf(struct devstat *ds, struct buf *); 224136071Sgreen#endif 225136071Sgreen 226136071Sgreen#endif /* _DEVICESTAT_H */ 227200567Sluigi