main.h revision 6e112132382b6442b636ee39b02951d771408e8f
1/*
2* Disktest
3* Copyright (c) International Business Machines Corp., 2001
4*
5*
6* This program is free software; you can redistribute it and/or modify
7* it under the terms of the GNU General Public License as published by
8* the Free Software Foundation; either version 2 of the License, or
9* (at your option) any later version.
10*
11* This program is distributed in the hope that it will be useful,
12* but WITHOUT ANY WARRANTY; without even the implied warranty of
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14* GNU General Public License for more details.
15*
16* You should have received a copy of the GNU General Public License
17* along with this program; if not, write to the Free Software
18* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19*
20*  Please send e-mail to yardleyb@us.ibm.com if you have
21*  questions or comments.
22*
23*  Project Website:  TBD
24*
25*
26* $Id: main.h,v 1.1 2002/02/21 16:49:04 robbiew Exp $
27* $Log: main.h,v $
28* Revision 1.1  2002/02/21 16:49:04  robbiew
29* Relocated disktest to /kernel/io/.
30*
31* Revision 1.6  2002/02/20 18:45:00  yardleyb
32* Set revision number v1.0.0
33*
34* Revision 1.5  2002/02/19 02:46:37  yardleyb
35* Added changes to compile for AIX.
36* Update getvsiz so it returns a -1
37* if the ioctl fails and we handle
38* that fact correctly.  Added check
39* to force vsiz to always be greater
40* then stop_lba.
41*
42* Revision 1.4  2002/02/04 20:35:38  yardleyb
43* Changed max. number of threads to 64k.
44* Check for max threads in parsing.
45* Fixed windows getopt to return correctly
46* when a bad option is given.
47* Update time output to be in the format:
48*   YEAR/MONTH/DAY-HOUR:MIN:SEC
49* instead of epoch time.
50*
51* Revision 1.3  2002/01/31 20:12:21  yardleyb
52* Updated the performance counters
53* to reflect run time based on duty
54* cycle not on total.
55*
56* Revision 1.2  2001/12/07 23:33:29  yardleyb
57* Fixed bug where a false positive data
58* miscompare could occur when running
59* multi cycle testing with mark block
60* enabled.
61*
62* Revision 1.1  2001/12/04 18:51:06  yardleyb
63* Checkin of new source files and removal
64* of outdated source
65*
66* Revision 1.11  2001/10/10 00:18:26  yardleyb
67* Updated revision to 0.9.2
68*
69* Revision 1.10  2001/10/10 00:17:14  yardleyb
70* Added Copyright and GPL license text.
71* Miner bug fixes throughout text.
72*
73* Revision 1.9  2001/10/01 23:30:58  yardleyb
74* Increased overall disktest revision number.
75*
76* Revision 1.8  2001/10/01 23:18:15  yardleyb
77* Changed all time related variables to time_t.
78* Rearranged some of the CLD_FLGs
79*
80* Revision 1.7  2001/09/26 23:38:31  yardleyb
81* Changed default seeks to 1000.
82* Added version string.
83*
84* Revision 1.6  2001/09/22 03:42:56  yardleyb
85* Anyother major update.  fixed bugs in IO routines,
86* added more error checking on input.  Added heartbeat
87* option, up-and-up and up-down-up seek routines, pass/fail
88* output, pMsg level discription, veriable length data comare
89* checking.  Lots of lint cleanup.
90*
91* Revision 1.5  2001/09/07 02:13:31  yardleyb
92* Major rewrite of main IO function.  Fixed bug in duty cycle were percentages
93* were off by one.  Got rid of some sloppy memory usage.  Major performance
94* increase overall.
95*
96* Revision 1.4  2001/09/06 21:59:23  yardleyb
97* Fixed a bug in the -L/-K where it ther ewere to many childern be created.
98* also more code cleanup.  Changed 'loops' to 'seeks' throughout.
99*
100* Revision 1.3  2001/09/06 18:23:30  yardleyb
101* Added duty cycle -D.  Updated usage. Added
102* make option to create .tar.gz of all files
103*
104* Revision 1.2  2001/09/05 22:44:42  yardleyb
105* Split out some of the special functions.
106* added O_DIRECT -Id.  Updated usage.  Lots
107* of clean up to functions.  Added header info
108* to pMsg.
109*
110* Revision 1.1  2001/09/04 19:28:08  yardleyb
111* Split usage out. Split header out.  Added usage text.
112* Made signal handler one function. code cleanup.
113*
114*
115*/
116
117#ifndef _DISKTEST_H
118#define _DISKTEST_H
119
120#ifdef WIN32
121#include <windows.h>
122#include <winioctl.h>
123#include <io.h>
124#include <process.h>
125#include <sys/stat.h>
126#else
127#include <sys/types.h>
128#include <sys/ioctl.h>
129#include <unistd.h>
130#endif
131
132#include <stdio.h>
133#include <stdlib.h>
134#include <stdarg.h>
135#include <signal.h>
136#include <time.h>
137#include <errno.h>
138#include <fcntl.h>
139#include "defs.h"
140
141#define VER_STR "v1.0.0"
142#define BLKGETSIZE _IO(0x12,96)
143#define BLKSSZGET  _IO(0x12,104)
144
145#define BLK_SIZE	512
146#define M_BLK_SIZE	512
147#define T_MAX_SIZE	M_BLK_SIZE*BLK_SIZE*2
148#define ALIGNSIZE	4096	/* 4k alignment works in all cases ?? */
149#define ALIGN(x, bs) ((x + (bs - 1)) & ~(bs - 1))
150/* #define ALIGN2(x, bs) ((x/bs) * bs) */
151#define BUFALIGN(x) (void *) (((unsigned long)x + (ALIGNSIZE - 1)) & ~(ALIGNSIZE - 1))
152#define MASK(x,y) (x & y)
153
154/* each is a 64b number.  offsets are in 8B*offset placement */
155#define OFF_TST_STAT	0	/* offset in memseg were global test status lives */
156#define OFF_RLBA	1	/* offset in memseg of current read LBA */
157#define OFF_WLBA	2	/* offset in memseg of current write LBA */
158#define OFF_WCOUNT	3	/* offset in memseg were total write count lives */
159#define OFF_RCOUNT	4	/* offset in memseg were total read count lives */
160#define OFF_RBYTES	5	/* bytes read */
161#define OFF_WBYTES	6	/* bytes written */
162
163#define BMP_OFFSET	7*sizeof(OFF_T)		/* bitmap starts here */
164
165#define TST_STS(x)			(x & 0x1)	/* current testing status */
166#define SET_STS_PASS(x)		(x | 0x01)
167#define SET_STS_FAIL(x)		(x & ~0x01)
168#define TST_wFST_TIME(x)	(x & 0x02)	/* first write lba access */
169#define SET_wFST_TIME(x)	(x | 0x02)
170#define CLR_wFST_TIME(x)	(x & ~0x02)
171#define TST_rFST_TIME(x)	(x & 0x04)	/* first read lba access */
172#define SET_rFST_TIME(x)	(x | 0x04)
173#define CLR_rFST_TIME(x)	(x & ~0x04)
174#define TST_DIRCTN(x)	(x & 0x08)		/* lba inc/dec 1 is inc, 0 is dec */
175#define DIRCT_INC(x)    (x | 0x08)
176#define DIRCT_DEC(x)    (x & ~0x08)
177#define DIRCT_CNG(x)    (x & 0x08) ? (x & ~0x08) : (x | 0x08)
178#define TST_OPER(x) (short) ((x & 0x10) >> 4)	/* last transfer operation (write = 0, read = 1) */
179#define SET_OPER_R(x)	(x | 0x10)
180#define SET_OPER_W(x)	(x & ~0x10)
181#define CNG_OPER(x)		(x & 0x10) ? (x & ~0x10) : (x | 0x10)
182
183#define DBUF_SIZE	(1*T_MAX_SIZE)
184#define OFF_DATA	(0*T_MAX_SIZE)
185
186#define CLD_FLG_CMPR	0x000000001	/* will cause readers to compare data read */
187#define CLD_FLG_MBLK	0x000000002	/* will add header info to fist block, fc lun, lba, etc */
188#define CLD_FLG_SQNCE	0x000000004	/* forces IOs to be queued one at a time */
189#define CLD_FLG_RTRSIZ	0x000000008	/* Ignore weither a block has been written */
190
191/* Perforamnce Flags */
192#define CLD_FLG_XFERS	0x000000010	/* reports # of transfers */
193#define CLD_FLG_TPUTS	0x000000020	/* reports calculated throughtput */
194#define CLD_FLG_RUNT	0x000000040	/* reports run time */
195
196/* Seek Flags */
197#define CLD_FLG_RANDOM	0x000000100	/* child seeks are random */
198#define CLD_FLG_LINEAR	0x000000200	/* child seeks are linear */
199#define CLD_FLG_PP		0x000000400	/* ping pong seeks: start/end/start+1/end-1 */
200#define CLD_FLG_NTRLVD	0x000000800	/* reads and writes are mixed during sequential IO */
201#define CLD_FLG_SKTYPS	(CLD_FLG_RANDOM|CLD_FLG_LINEAR|CLD_FLG_PP)
202
203/* IO Type Flags */
204#define CLD_FLG_RAW		0x000001000	/* child IO is to a RAW device */
205#define CLD_FLG_BLK		0x000002000	/* child IO is to a BLOCK device */
206#define CLD_FLG_FILE	0x000004000	/* child IO is to a file */
207#define CLD_FLG_DIRECT	0x000008000	/* child IO has direct disk access */
208#define CLD_FLG_IOTYPS	(CLD_FLG_RAW|CLD_FLG_BLK|CLD_FLG_FILE|CLD_FLG_DIRECT)
209
210/* Pattern Flags */
211#define CLD_FLG_RPTYPE	0x000010000	/* random pattern */
212#define CLD_FLG_FPTYPE	0x000020000	/* fixed pattern */
213#define CLD_FLG_CPTYPE	0x000040000	/* counting pattern */
214#define CLD_FLG_LPTYPE	0x000080000	/* lba pattern */
215#define CLD_FLG_PTYPS	(CLD_FLG_RPTYPE|CLD_FLG_FPTYPE|CLD_FLG_CPTYPE|CLD_FLG_LPTYPE)
216
217/* Duration Flags */
218#define CLD_FLG_TMD		0x000100000	/* set if using time */
219#define CLD_FLG_SKS		0x000200000	/* set if seeks are used */
220#define CLD_FLG_CYC		0x000400000	/* set if cycles are used */
221#define CLD_FLG_DUTY	0x000800000	/* set if a duty cycle is used while running */
222
223#define CLD_FLG_LBA_RNG	0x001000000	/* write multipule read multipule, must define multiple */
224#define CLD_FLG_BLK_RNG	0x002000000	/* write once read multiple, must define multiple */
225#define CLD_FLG_ALLDIE	0x004000000	/* will force all children to die on any error if set */
226
227#define CLD_FLG_LUNU	0x010000000	/* seek start/end and then start/end */
228#define CLD_FLG_LUND	0x020000000	/* seek start/end and then end/start */
229#define CLD_FLG_W		0x040000000	/* there are child writers */
230#define CLD_FLG_R		0x080000000	/* there are child readers */
231
232/* startup defaults */
233#define TRSIZ	1		/* default transfer size in blocks */
234#define VSIZ	2000	/* default volume capacity in LBAs */
235#define SEEKS	1000	/* default seeks */
236#define KIDS	4		/* default number of children */
237
238typedef enum op {
239	WRITER,READER,NONE
240} op_t;
241
242typedef struct child_args {
243	char *device;			/* pointer to device name */
244	OFF_T vsiz;				/* volume size in blocks */
245	unsigned long ltrsiz;	/* low bound of transfer size in blocks */
246	unsigned long htrsiz;	/* high bound of transfer size in blocks */
247	unsigned long offset;	/* lba offset */
248	OFF_T pattern;			/* pattern data */
249	time_t run_time;		/* run time in seconds */
250	OFF_T seeks;			/* number of seeks */
251	unsigned long cycles;	/* number of cycles */
252	OFF_T start_blk;		/* starting transfer block */
253	OFF_T stop_blk;			/* ending transfer block */
254	OFF_T start_lba;		/* starting LBA */
255	OFF_T stop_lba;			/* ending LBA */
256	unsigned int retries;	/* number of retries */
257	time_t hbeat;			/* Statistics will be reported every hbeats seconds */
258	OFF_T flags;			/* common flags that a child uses */
259	unsigned long rcount;	/* number of reads a child should perform, 0 is unbound  */
260	unsigned long wcount;	/* number of writes a child should perform, 0 is unbound  */
261	short rperc;			/* percent of IO that should be reads */
262	short wperc;			/* percent of IO that should be write */
263	unsigned short t_kids;	/* total children, max is 64k */
264	unsigned int cmp_lng;	/* how much of the data should be compared */
265	short mrk_flag;			/* how the tranfsers should be marked */
266} child_args_t;
267
268#endif /* _DISKTEST_H */
269