1c61d88e0SJustin T. Gibbs.\" 22a888f93SKenneth D. Merry.\" Copyright (c) 1998, 1999 Kenneth D. Merry. 3c61d88e0SJustin T. Gibbs.\" All rights reserved. 4c61d88e0SJustin T. Gibbs.\" 5c61d88e0SJustin T. Gibbs.\" Redistribution and use in source and binary forms, with or without 6c61d88e0SJustin T. Gibbs.\" modification, are permitted provided that the following conditions 7c61d88e0SJustin T. Gibbs.\" are met: 8c61d88e0SJustin T. Gibbs.\" 1. Redistributions of source code must retain the above copyright 9c61d88e0SJustin T. Gibbs.\" notice, this list of conditions and the following disclaimer. 10c61d88e0SJustin T. Gibbs.\" 2. Redistributions in binary form must reproduce the above copyright 11c61d88e0SJustin T. Gibbs.\" notice, this list of conditions and the following disclaimer in the 12c61d88e0SJustin T. Gibbs.\" documentation and/or other materials provided with the distribution. 13c61d88e0SJustin T. Gibbs.\" 3. The name of the author may not be used to endorse or promote products 14c61d88e0SJustin T. Gibbs.\" derived from this software without specific prior written permission. 15c61d88e0SJustin T. Gibbs.\" 16c61d88e0SJustin T. Gibbs.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17c61d88e0SJustin T. Gibbs.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18c61d88e0SJustin T. Gibbs.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19c61d88e0SJustin T. Gibbs.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20c61d88e0SJustin T. Gibbs.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21c61d88e0SJustin T. Gibbs.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22c61d88e0SJustin T. Gibbs.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23c61d88e0SJustin T. Gibbs.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24c61d88e0SJustin T. Gibbs.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25c61d88e0SJustin T. Gibbs.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26c61d88e0SJustin T. Gibbs.\" SUCH DAMAGE. 27c61d88e0SJustin T. Gibbs.\" 287f3dea24SPeter Wemm.\" $FreeBSD$ 29c61d88e0SJustin T. Gibbs.\" 30c61d88e0SJustin T. Gibbs.Dd May 22, 1998 31c61d88e0SJustin T. Gibbs.Dt DEVSTAT 9 323d45e180SRuslan Ermilov.Os 33c61d88e0SJustin T. Gibbs.Sh NAME 34fe27e01fSAlexey Zelkin.Nm devstat , 35fe27e01fSAlexey Zelkin.Nm devstat_add_entry , 360dc03e01SAlexey Zelkin.Nm devstat_end_transaction , 37b1f2329cSBruce Evans.Nm devstat_end_transaction_bio , 38fe27e01fSAlexey Zelkin.Nm devstat_remove_entry , 390dc03e01SAlexey Zelkin.Nm devstat_start_transaction 40c61d88e0SJustin T. Gibbs.Nd kernel interface for keeping device statistics 41c61d88e0SJustin T. Gibbs.Sh SYNOPSIS 4232eef9aeSRuslan Ermilov.In sys/devicestat.h 43c61d88e0SJustin T. Gibbs.Ft void 44c61d88e0SJustin T. Gibbs.Fo devstat_add_entry 45c61d88e0SJustin T. Gibbs.Fa "struct devstat *ds" 46399eae0dSBruce Evans.Fa "const char *dev_name" 47c61d88e0SJustin T. Gibbs.Fa "int unit_number" 48c61d88e0SJustin T. Gibbs.Fa "u_int32_t block_size" 49c61d88e0SJustin T. Gibbs.Fa "devstat_support_flags flags" 50c61d88e0SJustin T. Gibbs.Fa "devstat_type_flags device_type" 512a888f93SKenneth D. Merry.Fa "devstat_priority priority" 52c61d88e0SJustin T. Gibbs.Fc 53c61d88e0SJustin T. Gibbs.Ft void 54c61d88e0SJustin T. Gibbs.Fn devstat_remove_entry "struct devstat *ds" 55c61d88e0SJustin T. Gibbs.Ft void 56c61d88e0SJustin T. Gibbs.Fn devstat_start_transaction "struct devstat *ds" 57c61d88e0SJustin T. Gibbs.Ft void 58c61d88e0SJustin T. Gibbs.Fo devstat_end_transaction 59c61d88e0SJustin T. Gibbs.Fa "struct devstat *ds" 60c61d88e0SJustin T. Gibbs.Fa "u_int32_t bytes" 61c61d88e0SJustin T. Gibbs.Fa "devstat_tag_type tag_type" 62c61d88e0SJustin T. Gibbs.Fa "devstat_trans_flags flags" 63c61d88e0SJustin T. Gibbs.Fc 64bd9e52dcSPoul-Henning Kamp.Ft void 65b1f2329cSBruce Evans.Fo devstat_end_transaction_bio 66bd9e52dcSPoul-Henning Kamp.Fa "struct devstat *ds" 67b1f2329cSBruce Evans.Fa "struct bio *bp" 68bd9e52dcSPoul-Henning Kamp.Fc 69c61d88e0SJustin T. Gibbs.Sh DESCRIPTION 702a888f93SKenneth D. MerryThe devstat subsystem is an interface for recording device 71a0942a60SHiten Pandyastatistics, as its name implies. 72a0942a60SHiten PandyaThe idea is to keep reasonably detailed 73c61d88e0SJustin T. Gibbsstatistics while utilizing a minimum amount of CPU time to record them. 74c61d88e0SJustin T. GibbsThus, no statistical calculations are actually performed in the kernel 75c61d88e0SJustin T. Gibbsportion of the 764b66483fSRuslan Ermilov.Nm 77c61d88e0SJustin T. Gibbscode. Instead, that is left for user programs to handle. 78c61d88e0SJustin T. Gibbs.Pp 79c61d88e0SJustin T. Gibbs.Fn devstat_add_entry 80c61d88e0SJustin T. Gibbsregisters a device with the 81c61d88e0SJustin T. Gibbs.Nm 82a0942a60SHiten Pandyasubsystem. 83a0942a60SHiten PandyaThe caller is expected to have already allocated \fBand zeroed\fR 84c61d88e0SJustin T. Gibbsthe devstat structure before calling this function. 85c61d88e0SJustin T. Gibbs.Fn devstat_add_entry 86c61d88e0SJustin T. Gibbstakes several arguments: 87c61d88e0SJustin T. Gibbs.Bl -tag -width device_type 88c61d88e0SJustin T. Gibbs.It ds 89c61d88e0SJustin T. GibbsThe 90c61d88e0SJustin T. Gibbs.Va devstat 91c61d88e0SJustin T. Gibbsstructure, allocated and zeroed by the client. 92c61d88e0SJustin T. Gibbs.It dev_name 93c61d88e0SJustin T. GibbsThe device name. e.g. da, cd, sa. 94c61d88e0SJustin T. Gibbs.It unit_number 95c61d88e0SJustin T. GibbsDevice unit number. 96c61d88e0SJustin T. Gibbs.It block_size 97a0942a60SHiten PandyaBlock size of the device, if supported. 98a0942a60SHiten PandyaIf the device does not support a 99c61d88e0SJustin T. Gibbsblock size, or if the blocksize is unknown at the time the device is added 100c61d88e0SJustin T. Gibbsto the 101c61d88e0SJustin T. Gibbs.Nm 102c61d88e0SJustin T. Gibbslist, it should be set to 0. 103c61d88e0SJustin T. Gibbs.It flags 104a0942a60SHiten PandyaFlags indicating operations supported or not supported by the device. 105a0942a60SHiten PandyaSee below for details. 106c61d88e0SJustin T. Gibbs.It device_type 107a0942a60SHiten PandyaThe device type. 108a0942a60SHiten PandyaThis is broken into three sections: base device type 109c61d88e0SJustin T. Gibbs(e.g. direct access, CDROM, sequential access), interface type (IDE, SCSI 110a0942a60SHiten Pandyaor other) and a pass-through flag to indicate pas-through devices. 111a0942a60SHiten PandyaSee below for a complete list of types. 1122a888f93SKenneth D. Merry.It priority 113a0942a60SHiten PandyaThe device priority. 114a0942a60SHiten PandyaThe priority is used to determine how devices are 1152a888f93SKenneth D. Merrysorted within 1164b66483fSRuslan Ermilov.Nm devstat Ns 's 117a0942a60SHiten Pandyalist of devices. 118a0942a60SHiten PandyaDevices are sorted first by priority (highest to lowest), 119a0942a60SHiten Pandyaand then by attach order. 120a0942a60SHiten PandyaSee below for a complete list of available 1212a888f93SKenneth D. Merrypriorities. 122c61d88e0SJustin T. Gibbs.El 123c61d88e0SJustin T. Gibbs.Pp 124c61d88e0SJustin T. Gibbs.Fn devstat_remove_entry 125c61d88e0SJustin T. Gibbsremoves a device from the 126c61d88e0SJustin T. Gibbs.Nm 127a0942a60SHiten Pandyasubsystem. 128a0942a60SHiten PandyaIt takes the devstat structure for the device in question as 129a0942a60SHiten Pandyaan argument. 130a0942a60SHiten PandyaThe 131c61d88e0SJustin T. Gibbs.Nm 132c61d88e0SJustin T. Gibbsgeneration number is incremented and the number of devices is decremented. 133c61d88e0SJustin T. Gibbs.Pp 134c61d88e0SJustin T. Gibbs.Fn devstat_start_transaction 135c61d88e0SJustin T. Gibbsregisters the start of a transaction with the 136c61d88e0SJustin T. Gibbs.Nm 137a0942a60SHiten Pandyasubsystem. 138a0942a60SHiten PandyaThe busy count is incremented with each transaction start. 139c61d88e0SJustin T. GibbsWhen a device goes from idle to busy, the system uptime is recorded in the 140c61d88e0SJustin T. Gibbs.Va start_time 141c61d88e0SJustin T. Gibbsfield of the 142c61d88e0SJustin T. Gibbs.Va devstat 143c61d88e0SJustin T. Gibbsstructure. 144c61d88e0SJustin T. Gibbs.Pp 145c61d88e0SJustin T. Gibbs.Fn devstat_end_transaction 146c61d88e0SJustin T. Gibbsregisters the end of a transaction with the 147c61d88e0SJustin T. Gibbs.Nm 148a0942a60SHiten Pandyasubsystem. 149a0942a60SHiten PandyaIt takes four arguments: 150c61d88e0SJustin T. Gibbs.Bl -tag -width tag_type 151c61d88e0SJustin T. Gibbs.It ds 152c61d88e0SJustin T. GibbsThe 153c61d88e0SJustin T. Gibbs.Va devstat 154c61d88e0SJustin T. Gibbsstructure for the device in question. 155c61d88e0SJustin T. Gibbs.It bytes 156c61d88e0SJustin T. GibbsThe number of bytes transferred in this transaction. 157c61d88e0SJustin T. Gibbs.It tag_type 158a0942a60SHiten PandyaTransaction tag type. 159a0942a60SHiten PandyaSee below for tag types. 160c61d88e0SJustin T. Gibbs.It flags 161c61d88e0SJustin T. GibbsTransaction flags indicating whether the transaction was a read, write, or 162c61d88e0SJustin T. Gibbswhether no data was transferred. 163c61d88e0SJustin T. Gibbs.El 164c61d88e0SJustin T. Gibbs.Pp 165b1f2329cSBruce Evans.Fn devstat_end_transaction_bio 166bd9e52dcSPoul-Henning Kampis a wrapper for 167bd9e52dcSPoul-Henning Kamp.Fn devstat_end_transaction 168bd9e52dcSPoul-Henning Kampwhich pulls all the information from a 169b1f2329cSBruce Evans.Va "struct bio" 170bd9e52dcSPoul-Henning Kampwhich is ready for biodone(). 171bd9e52dcSPoul-Henning Kamp.Pp 172c61d88e0SJustin T. GibbsThe 173c61d88e0SJustin T. Gibbs.Va devstat 174c61d88e0SJustin T. Gibbsstructure is composed of the following fields: 175c61d88e0SJustin T. Gibbs.Bl -tag -width dev_creation_time 176c61d88e0SJustin T. Gibbs.It dev_links 177c61d88e0SJustin T. GibbsEach 178c61d88e0SJustin T. Gibbs.Va devstat 179a0942a60SHiten Pandyastructure is placed in a linked list when it is registered. 180a0942a60SHiten PandyaThe 181c61d88e0SJustin T. Gibbs.Va dev_links 182c61d88e0SJustin T. Gibbsfield contains a pointer to the next entry in the list of 183c61d88e0SJustin T. Gibbs.Va devstat 184c61d88e0SJustin T. Gibbsstructures. 185c61d88e0SJustin T. Gibbs.It device_number 186a0942a60SHiten PandyaThe device number is a unique identifier for each device. 187a0942a60SHiten PandyaThe device 188a0942a60SHiten Pandyanumber is incremented for each new device that is registered. 189a0942a60SHiten PandyaThe device 190c61d88e0SJustin T. Gibbsnumber is currently only a 32-bit integer, but it could be enlarged if 191c61d88e0SJustin T. Gibbssomeone has a system with more than four billion device arrival events. 192c61d88e0SJustin T. Gibbs.It device_name 193c61d88e0SJustin T. GibbsThe device name is a text string given by the registering driver to 194a0942a60SHiten Pandyaidentify itself. 195a0942a60SHiten Pandya(e.g.\& 196c61d88e0SJustin T. Gibbs.Dq da , 197c61d88e0SJustin T. Gibbs.Dq cd , 198c61d88e0SJustin T. Gibbs.Dq sa , 199c61d88e0SJustin T. Gibbsetc.) 200c61d88e0SJustin T. Gibbs.It unit_number 201c61d88e0SJustin T. GibbsThe unit number identifies the particular instance of the peripheral driver 202c61d88e0SJustin T. Gibbsin question. 203c61d88e0SJustin T. Gibbs.It bytes_written 204a0942a60SHiten PandyaThis is the number of bytes that have been written to the device. 205a0942a60SHiten PandyaThis number is currently an unsigned 64 bit integer. 206a0942a60SHiten PandyaThis will hopefully 207c61d88e0SJustin T. Gibbseliminate the counter wrap that would come very quickly on some systems if 208c61d88e0SJustin T. Gibbs32 bit integers were used. 209c61d88e0SJustin T. Gibbs.It bytes_read 210c61d88e0SJustin T. GibbsThis is the number of bytes that have been read from the device. 21104a22538SPoul-Henning Kamp.It bytes_freed 21204a22538SPoul-Henning KampThis is the number of bytes that have been freed/erased on the device. 213c61d88e0SJustin T. Gibbs.It num_reads 214c61d88e0SJustin T. GibbsThis is the number of reads from the device. 215c61d88e0SJustin T. Gibbs.It num_writes 216c61d88e0SJustin T. GibbsThis is the number of writes to the device. 21704a22538SPoul-Henning Kamp.It num_frees 21804a22538SPoul-Henning KampThis is the number of free/erase operations on the device. 219c61d88e0SJustin T. Gibbs.It num_other 220c61d88e0SJustin T. GibbsThis is the number of transactions to the device which are neither reads or 221a0942a60SHiten Pandyawrites. 222a0942a60SHiten PandyaFor instance, 223c61d88e0SJustin T. Gibbs.Tn SCSI 224c61d88e0SJustin T. Gibbsdrivers often send a test unit ready command to 225c61d88e0SJustin T. Gibbs.Tn SCSI 226a0942a60SHiten Pandyadevices. 227a0942a60SHiten PandyaThe test unit ready command does not read or write any data. 228a0942a60SHiten PandyaIt merely causes the device to return its status. 229c61d88e0SJustin T. Gibbs.It busy_count 230c61d88e0SJustin T. GibbsThis is the current number of outstanding transactions for the device. 231c61d88e0SJustin T. GibbsThis should never go below zero, and on an idle device it should be zero. 232c61d88e0SJustin T. GibbsIf either one of these conditions is not true, it indicates a problem in 233c61d88e0SJustin T. Gibbsthe way 234c61d88e0SJustin T. Gibbs.Fn devstat_start_transaction 235c61d88e0SJustin T. Gibbsand 236c61d88e0SJustin T. Gibbs.Fn devstat_end_transaction 237a0942a60SHiten Pandyaare being called in client code. 238a0942a60SHiten PandyaThere should be one and only one 239c61d88e0SJustin T. Gibbstransaction start event and one transaction end event for each transaction. 240c61d88e0SJustin T. Gibbs.It block_size 241c61d88e0SJustin T. GibbsThis is the block size of the device, if the device has a block size. 242c61d88e0SJustin T. Gibbs.It tag_types 243c61d88e0SJustin T. GibbsThis is an array of counters to record the number of various tag types that 244a0942a60SHiten Pandyaare sent to a device. 245a0942a60SHiten PandyaSee below for a list of tag types. 246c61d88e0SJustin T. Gibbs.It dev_creation_time 247c61d88e0SJustin T. GibbsThis is the time, as reported by 248c61d88e0SJustin T. Gibbs.Fn getmicrotime 249c61d88e0SJustin T. Gibbsthat the device was registered. 250c61d88e0SJustin T. Gibbs.It busy_time 251c61d88e0SJustin T. GibbsThis is the amount of time that the device busy count has been greater than 252a0942a60SHiten Pandyazero. 253a0942a60SHiten PandyaThis is only updated when the busy count returns to zero. 254c61d88e0SJustin T. Gibbs.It start_time 255c61d88e0SJustin T. GibbsThis is the time, as reported by 256c61d88e0SJustin T. Gibbs.Fn getmicrouptime 257c61d88e0SJustin T. Gibbsthat the device busy count went from zero to one. 258c61d88e0SJustin T. Gibbs.It last_comp_time 259c61d88e0SJustin T. GibbsThis is the time as reported by 260c61d88e0SJustin T. Gibbs.Fn getmicrouptime 261a0942a60SHiten Pandyathat a transaction last completed. 262a0942a60SHiten PandyaIt is used along with 263c61d88e0SJustin T. Gibbs.Va start_time 264c61d88e0SJustin T. Gibbsto calculate the device busy time. 265c61d88e0SJustin T. Gibbs.It flags 266c61d88e0SJustin T. GibbsThese flags indicate which statistics measurements are supported by a 267a0942a60SHiten Pandyaparticular device. 268a0942a60SHiten PandyaThese flags are primarily intended to serve as an aid 269c61d88e0SJustin T. Gibbsto userland programs that decipher the statistics. 270c61d88e0SJustin T. Gibbs.It device_type 271a0942a60SHiten PandyaThis is the device type. 272a0942a60SHiten PandyaIt consists of three parts: the device type 273c61d88e0SJustin T. Gibbs(e.g. direct access, CDROM, sequential access, etc.), the interface (IDE, 274b82af3f5SMike PritchardSCSI or other) and whether or not the device in question is a pass-through 275a0942a60SHiten Pandyadriver. 276a0942a60SHiten PandyaSee below for a complete list of device types. 2772a888f93SKenneth D. Merry.It priority 278a0942a60SHiten PandyaThis is the priority. 279a0942a60SHiten PandyaThis is the first parameter used to determine where 2802a888f93SKenneth D. Merryto insert a device in the 2814b66483fSRuslan Ermilov.Nm 282a0942a60SHiten Pandyalist. 283a0942a60SHiten PandyaThe second parameter is attach order. 284a0942a60SHiten PandyaSee below for a list of 2852a888f93SKenneth D. Merryavailable priorities. 286c61d88e0SJustin T. Gibbs.El 287c61d88e0SJustin T. Gibbs.Pp 288a0942a60SHiten PandyaEach device is given a device type. 289a0942a60SHiten PandyaPass-through devices have the same 290c61d88e0SJustin T. Gibbsunderlying device type and interface as the device they provide an 291a0942a60SHiten Pandyainterface for, but they also have the pass-through flag set. 292a0942a60SHiten PandyaThe base 293c61d88e0SJustin T. Gibbsdevice types are identical to the 294c61d88e0SJustin T. Gibbs.Tn SCSI 295c61d88e0SJustin T. Gibbsdevice type numbers, so with 296c61d88e0SJustin T. Gibbs.Tn SCSI 297c61d88e0SJustin T. Gibbsperipherals, the device type returned from an inquiry is usually ORed with 298c61d88e0SJustin T. Gibbsthe 299c61d88e0SJustin T. Gibbs.Tn SCSI 300a0942a60SHiten Pandyainterface type and the pass-through flag if appropriate. 301a0942a60SHiten PandyaThe device type 302c61d88e0SJustin T. Gibbsflags are as follows: 303c61d88e0SJustin T. Gibbs.Bd -literal -offset indent 304c61d88e0SJustin T. Gibbstypedef enum { 305c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_DIRECT = 0x000, 306c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_SEQUENTIAL = 0x001, 307c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_PRINTER = 0x002, 308c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_PROCESSOR = 0x003, 309c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_WORM = 0x004, 310c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_CDROM = 0x005, 311c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_SCANNER = 0x006, 312c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_OPTICAL = 0x007, 313c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_CHANGER = 0x008, 314c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_COMM = 0x009, 315c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_ASC0 = 0x00a, 316c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_ASC1 = 0x00b, 317c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_STORARRAY = 0x00c, 318c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_ENCLOSURE = 0x00d, 319c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_FLOPPY = 0x00e, 320c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_MASK = 0x00f, 321c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_IF_SCSI = 0x010, 322c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_IF_IDE = 0x020, 323c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_IF_OTHER = 0x030, 324c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_IF_MASK = 0x0f0, 325c61d88e0SJustin T. Gibbs DEVSTAT_TYPE_PASS = 0x100 326c61d88e0SJustin T. Gibbs} devstat_type_flags; 327c61d88e0SJustin T. Gibbs.Ed 328c61d88e0SJustin T. Gibbs.Pp 3292a888f93SKenneth D. MerryDevices have a priority associated with them, which controls roughly where 3302a888f93SKenneth D. Merrythey are placed in the 3314b66483fSRuslan Ermilov.Nm 332a0942a60SHiten Pandyalist. 333a0942a60SHiten PandyaThe priorities are as follows: 3342a888f93SKenneth D. Merry.Bd -literal -offset indent 3352a888f93SKenneth D. Merrytypedef enum { 3362a888f93SKenneth D. Merry DEVSTAT_PRIORITY_MIN = 0x000, 3372a888f93SKenneth D. Merry DEVSTAT_PRIORITY_OTHER = 0x020, 3382a888f93SKenneth D. Merry DEVSTAT_PRIORITY_PASS = 0x030, 3392a888f93SKenneth D. Merry DEVSTAT_PRIORITY_FD = 0x040, 3402a888f93SKenneth D. Merry DEVSTAT_PRIORITY_WFD = 0x050, 34186b2c846SKenneth D. Merry DEVSTAT_PRIORITY_TAPE = 0x060, 3422a888f93SKenneth D. Merry DEVSTAT_PRIORITY_CD = 0x090, 34386b2c846SKenneth D. Merry DEVSTAT_PRIORITY_DISK = 0x110, 34486b2c846SKenneth D. Merry DEVSTAT_PRIORITY_ARRAY = 0x120, 3452a888f93SKenneth D. Merry DEVSTAT_PRIORITY_MAX = 0xfff 3462a888f93SKenneth D. Merry} devstat_priority; 3472a888f93SKenneth D. Merry.Ed 3482a888f93SKenneth D. Merry.Pp 349c61d88e0SJustin T. GibbsEach device has associated with it flags to indicate what operations are 350a0942a60SHiten Pandyasupported or not supported. 351a0942a60SHiten PandyaThe 352c61d88e0SJustin T. Gibbs.Va devstat_support_flags 353c61d88e0SJustin T. Gibbsvalues are as follows: 354c61d88e0SJustin T. Gibbs.Bl -tag -width DEVSTAT_NO_ORDERED_TAGS 355c61d88e0SJustin T. Gibbs.It DEVSTAT_ALL_SUPPORTED 356c61d88e0SJustin T. GibbsEvery statistic type is supported by the device. 357c61d88e0SJustin T. Gibbs.It DEVSTAT_NO_BLOCKSIZE 358c61d88e0SJustin T. GibbsThis device does not have a blocksize. 359c61d88e0SJustin T. Gibbs.It DEVSTAT_NO_ORDERED_TAGS 360c61d88e0SJustin T. GibbsThis device does not support ordered tags. 361c61d88e0SJustin T. Gibbs.It DEVSTAT_BS_UNAVAILABLE 362a0942a60SHiten PandyaThis device supports a blocksize, but it is currently unavailable. 363a0942a60SHiten PandyaThis 364c61d88e0SJustin T. Gibbsflag is most often used with removable media drives. 365c61d88e0SJustin T. Gibbs.El 366c61d88e0SJustin T. Gibbs.Pp 367c61d88e0SJustin T. GibbsTransactions to a device fall into one of three categories, which are 368c61d88e0SJustin T. Gibbsrepresented in the 369c61d88e0SJustin T. Gibbs.Va flags 370c61d88e0SJustin T. Gibbspassed into 371c61d88e0SJustin T. Gibbs.Fn devstat_end_transaction . 372c61d88e0SJustin T. GibbsThe transaction types are as follows: 373c61d88e0SJustin T. Gibbs.Bd -literal -offset indent 374c61d88e0SJustin T. Gibbstypedef enum { 375c61d88e0SJustin T. Gibbs DEVSTAT_NO_DATA = 0x00, 376c61d88e0SJustin T. Gibbs DEVSTAT_READ = 0x01, 37704a22538SPoul-Henning Kamp DEVSTAT_WRITE = 0x02, 37804a22538SPoul-Henning Kamp DEVSTAT_FREE = 0x03 379c61d88e0SJustin T. Gibbs} devstat_trans_flags; 380c61d88e0SJustin T. Gibbs.Ed 381c61d88e0SJustin T. Gibbs.Pp 382c61d88e0SJustin T. GibbsThere are four possible values for the 383c61d88e0SJustin T. Gibbs.Va tag_type 384c61d88e0SJustin T. Gibbsargument to 385c61d88e0SJustin T. Gibbs.Fn devstat_end_transaction : 386c61d88e0SJustin T. Gibbs.Bl -tag -width DEVSTAT_TAG_ORDERED 387c61d88e0SJustin T. Gibbs.It DEVSTAT_TAG_SIMPLE 388c61d88e0SJustin T. GibbsThe transaction had a simple tag. 389c61d88e0SJustin T. Gibbs.It DEVSTAT_TAG_HEAD 390c61d88e0SJustin T. GibbsThe transaction had a head of queue tag. 391c61d88e0SJustin T. Gibbs.It DEVSTAT_TAG_ORDERED 392c61d88e0SJustin T. GibbsThe transaction had an ordered tag. 393c61d88e0SJustin T. Gibbs.It DEVSTAT_TAG_NONE 394c61d88e0SJustin T. GibbsThe device doesn't support tags. 395c61d88e0SJustin T. Gibbs.El 396c61d88e0SJustin T. Gibbs.Pp 397c61d88e0SJustin T. GibbsThe tag type values correspond to the lower four bits of the 398c61d88e0SJustin T. Gibbs.Tn SCSI 399a0942a60SHiten Pandyatag definitions. 400a0942a60SHiten PandyaIn CAM, for instance, the 401c61d88e0SJustin T. Gibbs.Va tag_action 402c61d88e0SJustin T. Gibbsfrom the CCB is ORed with 0xf to determine the tag type to pass in to 403c61d88e0SJustin T. Gibbs.Fn devstat_end_transaction . 404c61d88e0SJustin T. Gibbs.Pp 405c61d88e0SJustin T. GibbsThere is a macro, 406c61d88e0SJustin T. Gibbs.Dv DEVSTAT_VERSION 407c61d88e0SJustin T. Gibbsthat is defined in 408743d5d51SRuslan Ermilov.In sys/devicestat.h . 409c61d88e0SJustin T. GibbsThis is the current version of the 410c61d88e0SJustin T. Gibbs.Nm 411c61d88e0SJustin T. Gibbssubsystem, and it should be incremented each time a change is made that 412c61d88e0SJustin T. Gibbswould require recompilation of userland programs that access 413c61d88e0SJustin T. Gibbs.Nm 414a0942a60SHiten Pandyastatistics. 415a0942a60SHiten PandyaUserland programs use this version, via the 416c61d88e0SJustin T. Gibbs.Va kern.devstat.version 417c61d88e0SJustin T. Gibbs.Nm sysctl 418c61d88e0SJustin T. Gibbsvariable to determine whether they are in sync with the kernel 419c61d88e0SJustin T. Gibbs.Nm 420c61d88e0SJustin T. Gibbsstructures. 421c61d88e0SJustin T. Gibbs.Sh SEE ALSO 422c61d88e0SJustin T. Gibbs.Xr systat 1 , 423c61d88e0SJustin T. Gibbs.Xr devstat 3 , 424c61d88e0SJustin T. Gibbs.Xr iostat 8 , 425c61d88e0SJustin T. Gibbs.Xr rpc.rstatd 8 , 426c61d88e0SJustin T. Gibbs.Xr vmstat 8 427c61d88e0SJustin T. Gibbs.Sh HISTORY 428c61d88e0SJustin T. GibbsThe 429c61d88e0SJustin T. Gibbs.Nm 430c61d88e0SJustin T. Gibbsstatistics system appeared in 431c61d88e0SJustin T. Gibbs.Fx 3.0 . 432c61d88e0SJustin T. Gibbs.Sh AUTHORS 433def37e7cSMike Pritchard.An Kenneth Merry Aq ken@FreeBSD.org 434c61d88e0SJustin T. Gibbs.Sh BUGS 435c61d88e0SJustin T. GibbsThere may be a need for 436c61d88e0SJustin T. Gibbs.Fn spl 437c61d88e0SJustin T. Gibbsprotection around some of the 438c61d88e0SJustin T. Gibbs.Nm 439c61d88e0SJustin T. Gibbslist manipulation code to insure, for example, that the list of devices 440c61d88e0SJustin T. Gibbsis not changed while someone is fetching the 441c61d88e0SJustin T. Gibbs.Va kern.devstat.all 442c61d88e0SJustin T. Gibbs.Nm sysctl 443c61d88e0SJustin T. Gibbsvariable. 444c61d88e0SJustin T. Gibbs.Pp 445c61d88e0SJustin T. GibbsIt is impossible with the current 446c61d88e0SJustin T. Gibbs.Nm 447a0942a60SHiten Pandyaarchitecture to accurately measure time per transaction. 448a0942a60SHiten PandyaThe only feasible 449c61d88e0SJustin T. Gibbsway to accurately measure time per transaction would be to record a 450a0942a60SHiten Pandyatimestamp for every transaction. 451a0942a60SHiten PandyaThis measurement is probably not 452c61d88e0SJustin T. Gibbsworthwhile for most people as it would adversely affect the performance of 453c61d88e0SJustin T. Gibbsthe system and cost space to store the timestamps for individual 454c61d88e0SJustin T. Gibbstransactions. 455