FreeBSD/Linux Kernel Cross Reference
sys/sys/devicestat.h
1 /*
2 * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: releng/5.0/sys/sys/devicestat.h 103330 2002-09-14 19:34:11Z phk $
29 */
30
31 #ifndef _DEVICESTAT_H
32 #define _DEVICESTAT_H
33
34 #include <sys/queue.h>
35 #include <sys/time.h>
36
37 #define DEVSTAT_NAME_LEN 16
38
39 /*
40 * ATTENTION: The devstat version below should be incremented any time a
41 * change is made in struct devstat, or any time a change is made in the
42 * enumerated types that struct devstat uses. (Only if those changes
43 * would require a recompile -- i.e. re-arranging the order of an
44 * enumerated type or something like that.) This version number is used by
45 * userland utilities to determine whether or not they are in sync with the
46 * kernel.
47 */
48 #define DEVSTAT_VERSION 4
49
50 /*
51 * These flags specify which statistics features are supported or not
52 * supported by a particular device. The default is all statistics are
53 * supported.
54 */
55 typedef enum {
56 DEVSTAT_ALL_SUPPORTED = 0x00,
57 DEVSTAT_NO_BLOCKSIZE = 0x01,
58 DEVSTAT_NO_ORDERED_TAGS = 0x02,
59 DEVSTAT_BS_UNAVAILABLE = 0x04
60 } devstat_support_flags;
61
62 typedef enum {
63 DEVSTAT_NO_DATA = 0x00,
64 DEVSTAT_READ = 0x01,
65 DEVSTAT_WRITE = 0x02,
66 DEVSTAT_FREE = 0x03
67 } devstat_trans_flags;
68
69 typedef enum {
70 DEVSTAT_TAG_SIMPLE = 0x00,
71 DEVSTAT_TAG_HEAD = 0x01,
72 DEVSTAT_TAG_ORDERED = 0x02,
73 DEVSTAT_TAG_NONE = 0x03
74 } devstat_tag_type;
75
76 typedef enum {
77 DEVSTAT_PRIORITY_MIN = 0x000,
78 DEVSTAT_PRIORITY_OTHER = 0x020,
79 DEVSTAT_PRIORITY_PASS = 0x030,
80 DEVSTAT_PRIORITY_FD = 0x040,
81 DEVSTAT_PRIORITY_WFD = 0x050,
82 DEVSTAT_PRIORITY_TAPE = 0x060,
83 DEVSTAT_PRIORITY_CD = 0x090,
84 DEVSTAT_PRIORITY_DISK = 0x110,
85 DEVSTAT_PRIORITY_ARRAY = 0x120,
86 DEVSTAT_PRIORITY_MAX = 0xfff
87 } devstat_priority;
88
89 /*
90 * These types are intended to aid statistics gathering/display programs.
91 * The first 13 types (up to the 'target' flag) are identical numerically
92 * to the SCSI device type numbers. The next 3 types designate the device
93 * interface. Currently the choices are IDE, SCSI, and 'other'. The last
94 * flag specifies whether or not the given device is a passthrough device
95 * or not. If it is a passthrough device, the lower 4 bits specify which
96 * type of physical device lies under the passthrough device, and the next
97 * 4 bits specify the interface.
98 */
99 typedef enum {
100 DEVSTAT_TYPE_DIRECT = 0x000,
101 DEVSTAT_TYPE_SEQUENTIAL = 0x001,
102 DEVSTAT_TYPE_PRINTER = 0x002,
103 DEVSTAT_TYPE_PROCESSOR = 0x003,
104 DEVSTAT_TYPE_WORM = 0x004,
105 DEVSTAT_TYPE_CDROM = 0x005,
106 DEVSTAT_TYPE_SCANNER = 0x006,
107 DEVSTAT_TYPE_OPTICAL = 0x007,
108 DEVSTAT_TYPE_CHANGER = 0x008,
109 DEVSTAT_TYPE_COMM = 0x009,
110 DEVSTAT_TYPE_ASC0 = 0x00a,
111 DEVSTAT_TYPE_ASC1 = 0x00b,
112 DEVSTAT_TYPE_STORARRAY = 0x00c,
113 DEVSTAT_TYPE_ENCLOSURE = 0x00d,
114 DEVSTAT_TYPE_FLOPPY = 0x00e,
115 DEVSTAT_TYPE_MASK = 0x00f,
116 DEVSTAT_TYPE_IF_SCSI = 0x010,
117 DEVSTAT_TYPE_IF_IDE = 0x020,
118 DEVSTAT_TYPE_IF_OTHER = 0x030,
119 DEVSTAT_TYPE_IF_MASK = 0x0f0,
120 DEVSTAT_TYPE_PASS = 0x100
121 } devstat_type_flags;
122
123 struct devstat {
124 STAILQ_ENTRY(devstat) dev_links;
125 u_int32_t device_number; /*
126 * Devstat device
127 * number.
128 */
129 char device_name[DEVSTAT_NAME_LEN];
130 int unit_number;
131 u_int64_t bytes_read; /*
132 * Total bytes read
133 * from a device.
134 */
135 u_int64_t bytes_written; /*
136 * Total bytes written
137 * to a device.
138 */
139 u_int64_t bytes_freed; /*
140 * Total bytes freed
141 * from a device.
142 */
143 u_int64_t num_reads; /*
144 * Total number of
145 * read requests to
146 * the device.
147 */
148 u_int64_t num_writes; /*
149 * Total number of
150 * write requests to
151 * the device.
152 */
153 u_int64_t num_frees; /*
154 * Total number of
155 * free requests to
156 * the device.
157 */
158 u_int64_t num_other; /*
159 * Total number of
160 * transactions that
161 * don't read or write
162 * data.
163 */
164 int32_t busy_count; /*
165 * Total number of
166 * transactions
167 * outstanding for
168 * the device.
169 */
170 u_int32_t block_size; /* Block size, bytes */
171 u_int64_t tag_types[3]; /*
172 * The number of
173 * simple, ordered,
174 * and head of queue
175 * tags sent.
176 */
177 struct timeval dev_creation_time; /*
178 * Time the device was
179 * created.
180 */
181 struct timeval busy_time; /*
182 * Total amount of
183 * time drive has spent
184 * processing requests.
185 */
186 struct timeval start_time; /*
187 * The time when
188 * busy_count was
189 * last == 0. Or, the
190 * start of the latest
191 * busy period.
192 */
193 struct timeval last_comp_time; /*
194 * Last time a
195 * transaction was
196 * completed.
197 */
198
199 devstat_support_flags flags; /*
200 * Which statistics
201 * are supported by a
202 * given device.
203 */
204 devstat_type_flags device_type; /* Device type */
205 devstat_priority priority; /* Controls list pos. */
206 };
207
208 STAILQ_HEAD(devstatlist, devstat);
209
210 #ifdef _KERNEL
211 struct bio;
212
213 void devstat_add_entry(struct devstat *ds, const char *dev_name,
214 int unit_number, u_int32_t block_size,
215 devstat_support_flags flags,
216 devstat_type_flags device_type,
217 devstat_priority priority);
218 void devstat_remove_entry(struct devstat *ds);
219 void devstat_start_transaction(struct devstat *ds);
220 void devstat_end_transaction(struct devstat *ds, u_int32_t bytes,
221 devstat_tag_type tag_type,
222 devstat_trans_flags flags);
223 void devstat_end_transaction_bio(struct devstat *ds, struct bio *bp);
224 #endif
225
226 #endif /* _DEVICESTAT_H */
Cache object: 6420c5380566364ece0dfe1910bb1ef3
|