xref: /freebsd/share/man/man9/devstat.9 (revision fe27e01fac0772a68ff54da28b534b278b49a9ed)
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
32c61d88e0SJustin T. Gibbs.Os FreeBSD 3.0
33c61d88e0SJustin T. Gibbs.Sh NAME
34fe27e01fSAlexey Zelkin.Nm devstat ,
35fe27e01fSAlexey Zelkin.Nm devstat_add_entry ,
36fe27e01fSAlexey Zelkin.Nm devstat_remove_entry ,
37fe27e01fSAlexey Zelkin.Nm devstat_start_transaction ,
38fe27e01fSAlexey Zelkin.Nm devstat_end_transaction
39c61d88e0SJustin T. Gibbs.Nd kernel interface for keeping device statistics
40c61d88e0SJustin T. Gibbs.Sh SYNOPSIS
41c61d88e0SJustin T. Gibbs.Fd #include <sys/devicestat.h>
42c61d88e0SJustin T. Gibbs.Ft void
43c61d88e0SJustin T. Gibbs.Fo devstat_add_entry
44c61d88e0SJustin T. Gibbs.Fa "struct devstat *ds"
45399eae0dSBruce Evans.Fa "const char *dev_name"
46c61d88e0SJustin T. Gibbs.Fa "int unit_number"
47c61d88e0SJustin T. Gibbs.Fa "u_int32_t block_size"
48c61d88e0SJustin T. Gibbs.Fa "devstat_support_flags flags"
49c61d88e0SJustin T. Gibbs.Fa "devstat_type_flags device_type"
502a888f93SKenneth D. Merry.Fa "devstat_priority priority"
51c61d88e0SJustin T. Gibbs.Fc
52c61d88e0SJustin T. Gibbs.Ft void
53c61d88e0SJustin T. Gibbs.Fn devstat_remove_entry "struct devstat *ds"
54c61d88e0SJustin T. Gibbs.Ft void
55c61d88e0SJustin T. Gibbs.Fn devstat_start_transaction "struct devstat *ds"
56c61d88e0SJustin T. Gibbs.Ft void
57c61d88e0SJustin T. Gibbs.Fo devstat_end_transaction
58c61d88e0SJustin T. Gibbs.Fa "struct devstat *ds"
59c61d88e0SJustin T. Gibbs.Fa "u_int32_t bytes"
60c61d88e0SJustin T. Gibbs.Fa "devstat_tag_type tag_type"
61c61d88e0SJustin T. Gibbs.Fa "devstat_trans_flags flags"
62c61d88e0SJustin T. Gibbs.Fc
63bd9e52dcSPoul-Henning Kamp.Ft void
64bd9e52dcSPoul-Henning Kamp.Fo devstat_end_transaction_buf
65bd9e52dcSPoul-Henning Kamp.Fa "struct devstat *ds"
66bd9e52dcSPoul-Henning Kamp.Fa "struct buf *bp"
67bd9e52dcSPoul-Henning Kamp.Fc
68c61d88e0SJustin T. Gibbs.Sh DESCRIPTION
692a888f93SKenneth D. MerryThe devstat subsystem is an interface for recording device
70c61d88e0SJustin T. Gibbsstatistics, as its name implies.  The idea is to keep reasonably detailed
71c61d88e0SJustin T. Gibbsstatistics while utilizing a minimum amount of CPU time to record them.
72c61d88e0SJustin T. GibbsThus, no statistical calculations are actually performed in the kernel
73c61d88e0SJustin T. Gibbsportion of the
74fe27e01fSAlexey Zelkin.Nm devstat
75c61d88e0SJustin T. Gibbscode. Instead, that is left for user programs to handle.
76c61d88e0SJustin T. Gibbs.Pp
77c61d88e0SJustin T. Gibbs.Fn devstat_add_entry
78c61d88e0SJustin T. Gibbsregisters a device with the
79c61d88e0SJustin T. Gibbs.Nm
80c61d88e0SJustin T. Gibbssubsystem.  The caller is expected to have already allocated \fBand zeroed\fR
81c61d88e0SJustin T. Gibbsthe devstat structure before calling this function.
82c61d88e0SJustin T. Gibbs.Fn devstat_add_entry
83c61d88e0SJustin T. Gibbstakes several arguments:
84c61d88e0SJustin T. Gibbs.Bl -tag -width device_type
85c61d88e0SJustin T. Gibbs.It ds
86c61d88e0SJustin T. GibbsThe
87c61d88e0SJustin T. Gibbs.Va devstat
88c61d88e0SJustin T. Gibbsstructure, allocated and zeroed by the client.
89c61d88e0SJustin T. Gibbs.It dev_name
90c61d88e0SJustin T. GibbsThe device name. e.g. da, cd, sa.
91c61d88e0SJustin T. Gibbs.It unit_number
92c61d88e0SJustin T. GibbsDevice unit number.
93c61d88e0SJustin T. Gibbs.It block_size
94c61d88e0SJustin T. GibbsBlock size of the device, if supported.  If the device does not support a
95c61d88e0SJustin T. Gibbsblock size, or if the blocksize is unknown at the time the device is added
96c61d88e0SJustin T. Gibbsto the
97c61d88e0SJustin T. Gibbs.Nm
98c61d88e0SJustin T. Gibbslist, it should be set to 0.
99c61d88e0SJustin T. Gibbs.It flags
100c61d88e0SJustin T. GibbsFlags indicating operations supported or not supported by the device.  See
101c61d88e0SJustin T. Gibbsbelow for details.
102c61d88e0SJustin T. Gibbs.It device_type
103c61d88e0SJustin T. GibbsThe device type.  This is broken into three sections:  base device type
104c61d88e0SJustin T. Gibbs(e.g. direct access, CDROM, sequential access), interface type (IDE, SCSI
105c61d88e0SJustin T. Gibbsor other) and a passthrough flag to indicate pasthrough devices.  See below
106c61d88e0SJustin T. Gibbsfor a complete list of types.
1072a888f93SKenneth D. Merry.It priority
1082a888f93SKenneth D. MerryThe device priority.  The priority is used to determine how devices are
1092a888f93SKenneth D. Merrysorted within
1102a888f93SKenneth D. Merry.Nm devstat's
1112a888f93SKenneth D. Merrylist of devices.  Devices are sorted first by priority (highest to lowest),
1122a888f93SKenneth D. Merryand then by attach order.  See below for a complete list of available
1132a888f93SKenneth D. Merrypriorities.
114c61d88e0SJustin T. Gibbs.El
115c61d88e0SJustin T. Gibbs.Pp
116c61d88e0SJustin T. Gibbs.Fn devstat_remove_entry
117c61d88e0SJustin T. Gibbsremoves a device from the
118c61d88e0SJustin T. Gibbs.Nm
119c61d88e0SJustin T. Gibbssubsystem.  It takes the devstat structure for the device in question as
120c61d88e0SJustin T. Gibbsan argument.  The
121c61d88e0SJustin T. Gibbs.Nm
122c61d88e0SJustin T. Gibbsgeneration number is incremented and the number of devices is decremented.
123c61d88e0SJustin T. Gibbs.Pp
124c61d88e0SJustin T. Gibbs.Fn devstat_start_transaction
125c61d88e0SJustin T. Gibbsregisters the start of a transaction with the
126c61d88e0SJustin T. Gibbs.Nm
127c61d88e0SJustin T. Gibbssubsystem.  The busy count is incremented with each transaction start.
128c61d88e0SJustin T. GibbsWhen a device goes from idle to busy, the system uptime is recorded in the
129c61d88e0SJustin T. Gibbs.Va start_time
130c61d88e0SJustin T. Gibbsfield of the
131c61d88e0SJustin T. Gibbs.Va devstat
132c61d88e0SJustin T. Gibbsstructure.
133c61d88e0SJustin T. Gibbs.Pp
134c61d88e0SJustin T. Gibbs.Fn devstat_end_transaction
135c61d88e0SJustin T. Gibbsregisters the end of a transaction with the
136c61d88e0SJustin T. Gibbs.Nm
137c61d88e0SJustin T. Gibbssubsystem.  It takes four arguments:
138c61d88e0SJustin T. Gibbs.Bl -tag -width tag_type
139c61d88e0SJustin T. Gibbs.It ds
140c61d88e0SJustin T. GibbsThe
141c61d88e0SJustin T. Gibbs.Va devstat
142c61d88e0SJustin T. Gibbsstructure for the device in question.
143c61d88e0SJustin T. Gibbs.It bytes
144c61d88e0SJustin T. GibbsThe number of bytes transferred in this transaction.
145c61d88e0SJustin T. Gibbs.It tag_type
146c61d88e0SJustin T. GibbsTransaction tag type.  See below for tag types.
147c61d88e0SJustin T. Gibbs.It flags
148c61d88e0SJustin T. GibbsTransaction flags indicating whether the transaction was a read, write, or
149c61d88e0SJustin T. Gibbswhether no data was transferred.
150c61d88e0SJustin T. Gibbs.El
151c61d88e0SJustin T. Gibbs.Pp
152bd9e52dcSPoul-Henning Kamp.Fn devstat_end_transaction_buf
153bd9e52dcSPoul-Henning Kampis a wrapper for
154bd9e52dcSPoul-Henning Kamp.Fn devstat_end_transaction
155bd9e52dcSPoul-Henning Kampwhich pulls all the information from a
156bd9e52dcSPoul-Henning Kamp.Va "struct buf"
157bd9e52dcSPoul-Henning Kampwhich is ready for biodone().
158bd9e52dcSPoul-Henning Kamp.Pp
159c61d88e0SJustin T. GibbsThe
160c61d88e0SJustin T. Gibbs.Va devstat
161c61d88e0SJustin T. Gibbsstructure is composed of the following fields:
162c61d88e0SJustin T. Gibbs.Bl -tag -width dev_creation_time
163c61d88e0SJustin T. Gibbs.It dev_links
164c61d88e0SJustin T. GibbsEach
165c61d88e0SJustin T. Gibbs.Va devstat
166c61d88e0SJustin T. Gibbsstructure is placed in a linked list when it is registered.  The
167c61d88e0SJustin T. Gibbs.Va dev_links
168c61d88e0SJustin T. Gibbsfield contains a pointer to the next entry in the list of
169c61d88e0SJustin T. Gibbs.Va devstat
170c61d88e0SJustin T. Gibbsstructures.
171c61d88e0SJustin T. Gibbs.It device_number
172c61d88e0SJustin T. GibbsThe device number is a unique identifier for each device.  The device
173c61d88e0SJustin T. Gibbsnumber is incremented for each new device that is registered.  The device
174c61d88e0SJustin T. Gibbsnumber is currently only a 32-bit integer, but it could be enlarged if
175c61d88e0SJustin T. Gibbssomeone has a system with more than four billion device arrival events.
176c61d88e0SJustin T. Gibbs.It device_name
177c61d88e0SJustin T. GibbsThe device name is a text string given by the registering driver to
178c61d88e0SJustin T. Gibbsidentify itself.  (e.g.
179c61d88e0SJustin T. Gibbs.Dq da ,
180c61d88e0SJustin T. Gibbs.Dq cd ,
181c61d88e0SJustin T. Gibbs.Dq sa ,
182c61d88e0SJustin T. Gibbsetc.)
183c61d88e0SJustin T. Gibbs.It unit_number
184c61d88e0SJustin T. GibbsThe unit number identifies the particular instance of the peripheral driver
185c61d88e0SJustin T. Gibbsin question.
186c61d88e0SJustin T. Gibbs.It bytes_written
187c61d88e0SJustin T. GibbsThis is the number of bytes that have been written to the device.  This
188c61d88e0SJustin T. Gibbsnumber is currently an unsigned 64 bit integer.  This will hopefully
189c61d88e0SJustin T. Gibbseliminate the counter wrap that would come very quickly on some systems if
190c61d88e0SJustin T. Gibbs32 bit integers were used.
191c61d88e0SJustin T. Gibbs.It bytes_read
192c61d88e0SJustin T. GibbsThis is the number of bytes that have been read from the device.
193c61d88e0SJustin T. Gibbs.It num_reads
194c61d88e0SJustin T. GibbsThis is the number of reads from the device.
195c61d88e0SJustin T. Gibbs.It num_writes
196c61d88e0SJustin T. GibbsThis is the number of writes to the device.
197c61d88e0SJustin T. Gibbs.It num_other
198c61d88e0SJustin T. GibbsThis is the number of transactions to the device which are neither reads or
199c61d88e0SJustin T. Gibbswrites.  For instance,
200c61d88e0SJustin T. Gibbs.Tn SCSI
201c61d88e0SJustin T. Gibbsdrivers often send a test unit ready command to
202c61d88e0SJustin T. Gibbs.Tn SCSI
203c61d88e0SJustin T. Gibbsdevices.  The test unit ready command does not read or write any data.  It
204c61d88e0SJustin T. Gibbsmerely causes the device to return its status.
205c61d88e0SJustin T. Gibbs.It busy_count
206c61d88e0SJustin T. GibbsThis is the current number of outstanding transactions for the device.
207c61d88e0SJustin T. GibbsThis should never go below zero, and on an idle device it should be zero.
208c61d88e0SJustin T. GibbsIf either one of these conditions is not true, it indicates a problem in
209c61d88e0SJustin T. Gibbsthe way
210c61d88e0SJustin T. Gibbs.Fn devstat_start_transaction
211c61d88e0SJustin T. Gibbsand
212c61d88e0SJustin T. Gibbs.Fn devstat_end_transaction
213c61d88e0SJustin T. Gibbsare being called in client code.  There should be one and only one
214c61d88e0SJustin T. Gibbstransaction start event and one transaction end event for each transaction.
215c61d88e0SJustin T. Gibbs.It block_size
216c61d88e0SJustin T. GibbsThis is the block size of the device, if the device has a block size.
217c61d88e0SJustin T. Gibbs.It tag_types
218c61d88e0SJustin T. GibbsThis is an array of counters to record the number of various tag types that
219c61d88e0SJustin T. Gibbsare sent to a device.  See below for a list of tag types.
220c61d88e0SJustin T. Gibbs.It dev_creation_time
221c61d88e0SJustin T. GibbsThis is the time, as reported by
222c61d88e0SJustin T. Gibbs.Fn getmicrotime
223c61d88e0SJustin T. Gibbsthat the device was registered.
224c61d88e0SJustin T. Gibbs.It busy_time
225c61d88e0SJustin T. GibbsThis is the amount of time that the device busy count has been greater than
226c61d88e0SJustin T. Gibbszero.  This is only updated when the busy count returns to zero.
227c61d88e0SJustin T. Gibbs.It start_time
228c61d88e0SJustin T. GibbsThis is the time, as reported by
229c61d88e0SJustin T. Gibbs.Fn getmicrouptime
230c61d88e0SJustin T. Gibbsthat the device busy count went from zero to one.
231c61d88e0SJustin T. Gibbs.It last_comp_time
232c61d88e0SJustin T. GibbsThis is the time as reported by
233c61d88e0SJustin T. Gibbs.Fn getmicrouptime
234c61d88e0SJustin T. Gibbsthat a transaction last completed.  It is used along with
235c61d88e0SJustin T. Gibbs.Va start_time
236c61d88e0SJustin T. Gibbsto calculate the device busy time.
237c61d88e0SJustin T. Gibbs.It flags
238c61d88e0SJustin T. GibbsThese flags indicate which statistics measurements are supported by a
239c61d88e0SJustin T. Gibbsparticular device.  These flags are primarily intended to serve as an aid
240c61d88e0SJustin T. Gibbsto userland programs that decipher the statistics.
241c61d88e0SJustin T. Gibbs.It device_type
242c61d88e0SJustin T. GibbsThis is the device type.  It consists of three parts:  the device type
243c61d88e0SJustin T. Gibbs(e.g. direct access, CDROM, sequential access, etc.), the interface (IDE,
244c61d88e0SJustin T. GibbsSCSI or other) and whether or not the device in question is a passthrough
245c61d88e0SJustin T. Gibbsdriver.  See below for a complete list of device types.
2462a888f93SKenneth D. Merry.It priority
2472a888f93SKenneth D. MerryThis is the priority.  This is the first parameter used to determine where
2482a888f93SKenneth D. Merryto insert a device in the
2492a888f93SKenneth D. Merry.Nm devstat
2502a888f93SKenneth D. Merrylist.  The second parameter is attach order.  See below for a list of
2512a888f93SKenneth D. Merryavailable priorities.
252c61d88e0SJustin T. Gibbs.El
253c61d88e0SJustin T. Gibbs.Pp
254c61d88e0SJustin T. GibbsEach device is given a device type.  Passthrough devices have the same
255c61d88e0SJustin T. Gibbsunderlying device type and interface as the device they provide an
256c61d88e0SJustin T. Gibbsinterface for, but they also have the passthrough flag set.  The base
257c61d88e0SJustin T. Gibbsdevice types are identical to the
258c61d88e0SJustin T. Gibbs.Tn SCSI
259c61d88e0SJustin T. Gibbsdevice type numbers, so with
260c61d88e0SJustin T. Gibbs.Tn SCSI
261c61d88e0SJustin T. Gibbsperipherals, the device type returned from an inquiry is usually ORed with
262c61d88e0SJustin T. Gibbsthe
263c61d88e0SJustin T. Gibbs.Tn SCSI
264c61d88e0SJustin T. Gibbsinterface type and the passthrough flag if appropriate.  The device type
265c61d88e0SJustin T. Gibbsflags are as follows:
266c61d88e0SJustin T. Gibbs.Bd -literal -offset indent
267c61d88e0SJustin T. Gibbstypedef enum {
268c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_DIRECT	= 0x000,
269c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_SEQUENTIAL	= 0x001,
270c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_PRINTER	= 0x002,
271c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_PROCESSOR	= 0x003,
272c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_WORM	= 0x004,
273c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_CDROM	= 0x005,
274c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_SCANNER	= 0x006,
275c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_OPTICAL	= 0x007,
276c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_CHANGER	= 0x008,
277c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_COMM	= 0x009,
278c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_ASC0	= 0x00a,
279c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_ASC1	= 0x00b,
280c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_STORARRAY	= 0x00c,
281c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_ENCLOSURE	= 0x00d,
282c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_FLOPPY	= 0x00e,
283c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_MASK	= 0x00f,
284c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_IF_SCSI	= 0x010,
285c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_IF_IDE	= 0x020,
286c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_IF_OTHER	= 0x030,
287c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_IF_MASK	= 0x0f0,
288c61d88e0SJustin T. Gibbs	DEVSTAT_TYPE_PASS	= 0x100
289c61d88e0SJustin T. Gibbs} devstat_type_flags;
290c61d88e0SJustin T. Gibbs.Ed
291c61d88e0SJustin T. Gibbs.Pp
2922a888f93SKenneth D. MerryDevices have a priority associated with them, which controls roughly where
2932a888f93SKenneth D. Merrythey are placed in the
2942a888f93SKenneth D. Merry.Nm devstat
2952a888f93SKenneth D. Merrylist.  The priorities are as follows:
2962a888f93SKenneth D. Merry.Bd -literal -offset indent
2972a888f93SKenneth D. Merrytypedef enum {
2982a888f93SKenneth D. Merry	DEVSTAT_PRIORITY_MIN	= 0x000,
2992a888f93SKenneth D. Merry	DEVSTAT_PRIORITY_OTHER	= 0x020,
3002a888f93SKenneth D. Merry	DEVSTAT_PRIORITY_PASS	= 0x030,
3012a888f93SKenneth D. Merry	DEVSTAT_PRIORITY_FD	= 0x040,
3022a888f93SKenneth D. Merry	DEVSTAT_PRIORITY_WFD	= 0x050,
3032a888f93SKenneth D. Merry	DEVSTAT_PRIORITY_SA	= 0x060,
3042a888f93SKenneth D. Merry	DEVSTAT_PRIORITY_OCD	= 0x070,
3052a888f93SKenneth D. Merry	DEVSTAT_PRIORITY_WCD	= 0x080,
3062a888f93SKenneth D. Merry	DEVSTAT_PRIORITY_CD	= 0x090,
3072a888f93SKenneth D. Merry	DEVSTAT_PRIORITY_WD	= 0x100,
3082a888f93SKenneth D. Merry	DEVSTAT_PRIORITY_DA	= 0x110,
3092a888f93SKenneth D. Merry	DEVSTAT_PRIORITY_CCD	= 0x120,
3102a888f93SKenneth D. Merry	DEVSTAT_PRIORITY_MAX	= 0xfff
3112a888f93SKenneth D. Merry} devstat_priority;
3122a888f93SKenneth D. Merry.Ed
3132a888f93SKenneth D. Merry.Pp
314c61d88e0SJustin T. GibbsEach device has associated with it flags to indicate what operations are
315c61d88e0SJustin T. Gibbssupported or not supported.  The
316c61d88e0SJustin T. Gibbs.Va devstat_support_flags
317c61d88e0SJustin T. Gibbsvalues are as follows:
318c61d88e0SJustin T. Gibbs.Bl -tag -width DEVSTAT_NO_ORDERED_TAGS
319c61d88e0SJustin T. Gibbs.It DEVSTAT_ALL_SUPPORTED
320c61d88e0SJustin T. GibbsEvery statistic type is supported by the device.
321c61d88e0SJustin T. Gibbs.It DEVSTAT_NO_BLOCKSIZE
322c61d88e0SJustin T. GibbsThis device does not have a blocksize.
323c61d88e0SJustin T. Gibbs.It DEVSTAT_NO_ORDERED_TAGS
324c61d88e0SJustin T. GibbsThis device does not support ordered tags.
325c61d88e0SJustin T. Gibbs.It DEVSTAT_BS_UNAVAILABLE
326c61d88e0SJustin T. GibbsThis device supports a blocksize, but it is currently unavailable.  This
327c61d88e0SJustin T. Gibbsflag is most often used with removable media drives.
328c61d88e0SJustin T. Gibbs.El
329c61d88e0SJustin T. Gibbs.Pp
330c61d88e0SJustin T. GibbsTransactions to a device fall into one of three categories, which are
331c61d88e0SJustin T. Gibbsrepresented in the
332c61d88e0SJustin T. Gibbs.Va flags
333c61d88e0SJustin T. Gibbspassed into
334c61d88e0SJustin T. Gibbs.Fn devstat_end_transaction .
335c61d88e0SJustin T. GibbsThe transaction types are as follows:
336c61d88e0SJustin T. Gibbs.Bd -literal -offset indent
337c61d88e0SJustin T. Gibbstypedef enum {
338c61d88e0SJustin T. Gibbs	DEVSTAT_NO_DATA	= 0x00,
339c61d88e0SJustin T. Gibbs	DEVSTAT_READ	= 0x01,
340c61d88e0SJustin T. Gibbs	DEVSTAT_WRITE	= 0x02
341c61d88e0SJustin T. Gibbs} devstat_trans_flags;
342c61d88e0SJustin T. Gibbs.Ed
343c61d88e0SJustin T. Gibbs.Pp
344c61d88e0SJustin T. GibbsThere are four possible values for the
345c61d88e0SJustin T. Gibbs.Va tag_type
346c61d88e0SJustin T. Gibbsargument to
347c61d88e0SJustin T. Gibbs.Fn devstat_end_transaction :
348c61d88e0SJustin T. Gibbs.Bl -tag -width DEVSTAT_TAG_ORDERED
349c61d88e0SJustin T. Gibbs.It DEVSTAT_TAG_SIMPLE
350c61d88e0SJustin T. GibbsThe transaction had a simple tag.
351c61d88e0SJustin T. Gibbs.It DEVSTAT_TAG_HEAD
352c61d88e0SJustin T. GibbsThe transaction had a head of queue tag.
353c61d88e0SJustin T. Gibbs.It DEVSTAT_TAG_ORDERED
354c61d88e0SJustin T. GibbsThe transaction had an ordered tag.
355c61d88e0SJustin T. Gibbs.It DEVSTAT_TAG_NONE
356c61d88e0SJustin T. GibbsThe device doesn't support tags.
357c61d88e0SJustin T. Gibbs.El
358c61d88e0SJustin T. Gibbs.Pp
359c61d88e0SJustin T. GibbsThe tag type values correspond to the lower four bits of the
360c61d88e0SJustin T. Gibbs.Tn SCSI
361c61d88e0SJustin T. Gibbstag definitions.  In CAM, for instance, the
362c61d88e0SJustin T. Gibbs.Va tag_action
363c61d88e0SJustin T. Gibbsfrom the CCB is ORed with 0xf to determine the tag type to pass in to
364c61d88e0SJustin T. Gibbs.Fn devstat_end_transaction .
365c61d88e0SJustin T. Gibbs.Pp
366c61d88e0SJustin T. GibbsThere is a macro,
367c61d88e0SJustin T. Gibbs.Dv DEVSTAT_VERSION
368c61d88e0SJustin T. Gibbsthat is defined in
369c61d88e0SJustin T. Gibbs.Aq sys/devicestat.h .
370c61d88e0SJustin T. GibbsThis is the current version of the
371c61d88e0SJustin T. Gibbs.Nm
372c61d88e0SJustin T. Gibbssubsystem, and it should be incremented each time a change is made that
373c61d88e0SJustin T. Gibbswould require recompilation of userland programs that access
374c61d88e0SJustin T. Gibbs.Nm
375c61d88e0SJustin T. Gibbsstatistics.  Userland programs use this version, via the
376c61d88e0SJustin T. Gibbs.Va kern.devstat.version
377c61d88e0SJustin T. Gibbs.Nm sysctl
378c61d88e0SJustin T. Gibbsvariable to determine whether they are in sync with the kernel
379c61d88e0SJustin T. Gibbs.Nm
380c61d88e0SJustin T. Gibbsstructures.
381c61d88e0SJustin T. Gibbs.Sh SEE ALSO
382c61d88e0SJustin T. Gibbs.Xr systat 1 ,
383c61d88e0SJustin T. Gibbs.Xr devstat 3 ,
384c61d88e0SJustin T. Gibbs.Xr iostat 8 ,
385c61d88e0SJustin T. Gibbs.Xr rpc.rstatd 8 ,
386c61d88e0SJustin T. Gibbs.Xr vmstat 8
387c61d88e0SJustin T. Gibbs.Sh HISTORY
388c61d88e0SJustin T. GibbsThe
389c61d88e0SJustin T. Gibbs.Nm
390c61d88e0SJustin T. Gibbsstatistics system appeared in
391c61d88e0SJustin T. Gibbs.Fx 3.0 .
392c61d88e0SJustin T. Gibbs.Sh AUTHORS
393def37e7cSMike Pritchard.An Kenneth Merry Aq ken@FreeBSD.org
394c61d88e0SJustin T. Gibbs.Sh BUGS
395c61d88e0SJustin T. GibbsThere may be a need for
396c61d88e0SJustin T. Gibbs.Fn spl
397c61d88e0SJustin T. Gibbsprotection around some of the
398c61d88e0SJustin T. Gibbs.Nm
399c61d88e0SJustin T. Gibbslist manipulation code to insure, for example, that the list of devices
400c61d88e0SJustin T. Gibbsis not changed while someone is fetching the
401c61d88e0SJustin T. Gibbs.Va kern.devstat.all
402c61d88e0SJustin T. Gibbs.Nm sysctl
403c61d88e0SJustin T. Gibbsvariable.
404c61d88e0SJustin T. Gibbs.Pp
405c61d88e0SJustin T. GibbsIt is impossible with the current
406c61d88e0SJustin T. Gibbs.Nm
407c61d88e0SJustin T. Gibbsarchitecture to accurately measure time per transaction.  The only feasible
408c61d88e0SJustin T. Gibbsway to accurately measure time per transaction would be to record a
409c61d88e0SJustin T. Gibbstimestamp for every transaction.  This measurement is probably not
410c61d88e0SJustin T. Gibbsworthwhile for most people as it would adversely affect the performance of
411c61d88e0SJustin T. Gibbsthe system and cost space to store the timestamps for individual
412c61d88e0SJustin T. Gibbstransactions.
413