1 /*
2  * File...........: linux/drivers/s390/block/dasd.c
3  * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4  * Bugreports.to..: <Linux390@de.ibm.com>
5  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
6  *
7  * This file is the interface of the DASD device driver, which is exported to user space
8  * any future changes wrt the API will result in a change of the APIVERSION reported
9  * to userspace by the DASDAPIVER-ioctl
10  *
11  * $Revision: 1.53 $
12  *
13  * History of changes (starts July 2000)
14  * 05/04/01 created by moving the kernel interface to drivers/s390/block/dasd_int.h
15  * 12/06/01 DASD_API_VERSION 2 - binary compatible to 0 (new BIODASDINFO2)
16  * 01/23/02 DASD_API_VERSION 3 - added BIODASDPSRD IOCTL
17  * 02/15/02 DASD_API_VERSION 4 - added BIODASDSATTR IOCTL
18  * 06/07/02 DASD_API_VERSION 5 - added 'boxed DASD' support
19  *
20  */
21 
22 #ifndef DASD_H
23 #define DASD_H
24 #include <linux/ioctl.h>
25 
26 #define DASD_IOCTL_LETTER 'D'
27 
28 #define DASD_API_VERSION 5
29 
30 /*
31  * struct dasd_information2_t
32  * represents any data about the device, which is visible to userspace.
33  *  including foramt and featueres.
34  */
35 typedef struct dasd_information2_t {
36         unsigned int devno;         /* S/390 devno */
37         unsigned int real_devno;    /* for aliases */
38         unsigned int schid;         /* S/390 subchannel identifier */
39         unsigned int cu_type  : 16; /* from SenseID */
40         unsigned int cu_model :  8; /* from SenseID */
41         unsigned int dev_type : 16; /* from SenseID */
42         unsigned int dev_model : 8; /* from SenseID */
43         unsigned int open_count;
44         unsigned int req_queue_len;
45         unsigned int chanq_len;     /* length of chanq */
46         char type[4];               /* from discipline.name, 'none' for unknown */
47         unsigned int status;        /* current device level */
48         unsigned int label_block;   /* where to find the VOLSER */
49         unsigned int FBA_layout;    /* fixed block size (like AIXVOL) */
50         unsigned int characteristics_size;
51         unsigned int confdata_size;
52         char characteristics[64];   /* from read_device_characteristics */
53         char configuration_data[256]; /* from read_configuration_data */
54         unsigned int format;          /* format info like formatted/cdl/ldl/... */
55         unsigned int features;        /* dasd features like 'ro',...            */
56         unsigned int reserved0;       /* reserved for further use ,...          */
57         unsigned int reserved1;       /* reserved for further use ,...          */
58         unsigned int reserved2;       /* reserved for further use ,...          */
59         unsigned int reserved3;       /* reserved for further use ,...          */
60         unsigned int reserved4;       /* reserved for further use ,...          */
61         unsigned int reserved5;       /* reserved for further use ,...          */
62         unsigned int reserved6;       /* reserved for further use ,...          */
63         unsigned int reserved7;       /* reserved for further use ,...          */
64 } dasd_information2_t;
65 
66 /*
67  * values to be used for dasd_information_t.format
68  * 0x00: NOT formatted
69  * 0x01: Linux disc layout
70  * 0x02: Common disc layout
71  */
72 #define DASD_FORMAT_NONE 0
73 #define DASD_FORMAT_LDL  1
74 #define DASD_FORMAT_CDL  2
75 /*
76  * values to be used for dasd_information_t.features
77  * 0x00: default features
78  * 0x01: readonly (ro)
79  */
80 #define DASD_FEATURE_DEFAULT  0
81 #define DASD_FEATURE_READONLY 1
82 
83 #define DASD_PARTN_BITS 2
84 
85 /*
86  * struct dasd_information_t
87  * represents any data about the data, which is visible to userspace
88  */
89 typedef struct dasd_information_t {
90         unsigned int devno;         /* S/390 devno */
91         unsigned int real_devno;    /* for aliases */
92         unsigned int schid;         /* S/390 subchannel identifier */
93         unsigned int cu_type  : 16; /* from SenseID */
94         unsigned int cu_model :  8; /* from SenseID */
95         unsigned int dev_type : 16; /* from SenseID */
96         unsigned int dev_model : 8; /* from SenseID */
97         unsigned int open_count;
98         unsigned int req_queue_len;
99         unsigned int chanq_len;     /* length of chanq */
100         char type[4];               /* from discipline.name, 'none' for unknown */
101         unsigned int status;        /* current device level */
102         unsigned int label_block;   /* where to find the VOLSER */
103         unsigned int FBA_layout;    /* fixed block size (like AIXVOL) */
104         unsigned int characteristics_size;
105         unsigned int confdata_size;
106         char characteristics[64];   /* from read_device_characteristics */
107         char configuration_data[256]; /* from read_configuration_data */
108 } dasd_information_t;
109 
110 /*
111  * Read Subsystem Data - Perfomance Statistics
112  */
113 typedef struct dasd_rssd_perf_stats_t {
114 	unsigned char  invalid:1;
115 	unsigned char  format:3;
116 	unsigned char  data_format:4;
117 	unsigned char  unit_address;
118 	unsigned short device_status;
119 	unsigned int   nr_read_normal;
120 	unsigned int   nr_read_normal_hits;
121 	unsigned int   nr_write_normal;
122 	unsigned int   nr_write_fast_normal_hits;
123 	unsigned int   nr_read_seq;
124 	unsigned int   nr_read_seq_hits;
125 	unsigned int   nr_write_seq;
126 	unsigned int   nr_write_fast_seq_hits;
127 	unsigned int   nr_read_cache;
128 	unsigned int   nr_read_cache_hits;
129 	unsigned int   nr_write_cache;
130 	unsigned int   nr_write_fast_cache_hits;
131 	unsigned int   nr_inhibit_cache;
132 	unsigned int   nr_bybass_cache;
133 	unsigned int   nr_seq_dasd_to_cache;
134 	unsigned int   nr_dasd_to_cache;
135 	unsigned int   nr_cache_to_dasd;
136 	unsigned int   nr_delayed_fast_write;
137 	unsigned int   nr_normal_fast_write;
138 	unsigned int   nr_seq_fast_write;
139 	unsigned int   nr_cache_miss;
140 	unsigned char  status2;
141 	unsigned int   nr_quick_write_promotes;
142 	unsigned char  reserved;
143 	unsigned short ssid;
144 	unsigned char  reseved2[96];
145 } __attribute__((packed)) dasd_rssd_perf_stats_t;
146 
147 /*
148  * struct profile_info_t
149  * holds the profinling information
150  */
151 typedef struct dasd_profile_info_t {
152         unsigned int dasd_io_reqs;	 /* number of requests processed at all */
153         unsigned int dasd_io_sects;	 /* number of sectors processed at all */
154         unsigned int dasd_io_secs[32];	 /* histogram of request's sizes */
155         unsigned int dasd_io_times[32];	 /* histogram of requests's times */
156         unsigned int dasd_io_timps[32];	 /* histogram of requests's times per sector */
157         unsigned int dasd_io_time1[32];	 /* histogram of time from build to start */
158         unsigned int dasd_io_time2[32];	 /* histogram of time from start to irq */
159         unsigned int dasd_io_time2ps[32]; /* histogram of time from start to irq */
160         unsigned int dasd_io_time3[32];	 /* histogram of time from irq to end */
161         unsigned int dasd_io_nr_req[32]; /* histogram of # of requests in chanq */
162 } dasd_profile_info_t;
163 
164 /*
165  * struct format_data_t
166  * represents all data necessary to format a dasd
167  */
168 typedef struct format_data_t {
169 	int start_unit; /* from track */
170 	int stop_unit;  /* to track */
171 	int blksize;    /* sectorsize */
172         int intensity;
173 } format_data_t;
174 
175 /*
176  * values to be used for format_data_t.intensity
177  * 0/8: normal format
178  * 1/9: also write record zero
179  * 3/11: also write home address
180  * 4/12: invalidate track
181  */
182 #define DASD_FMT_INT_FMT_R0 1 /* write record zero */
183 #define DASD_FMT_INT_FMT_HA 2 /* write home address, also set FMT_R0 ! */
184 #define DASD_FMT_INT_INVAL  4 /* invalidate tracks */
185 #define DASD_FMT_INT_COMPAT 8 /* use OS/390 compatible disk layout */
186 
187 
188 /*
189  * struct attrib_data_t
190  * represents the operation (cache) bits for the device.
191  * Used in DE to influence caching of the DASD.
192  */
193 typedef struct attrib_data_t {
194 	unsigned char   operation:3;     /* cache operation mode */
195 	unsigned char   reserved:5;      /* cache operation mode */
196 	unsigned short  nr_cyl;          /* no of cyliners for read ahaed */
197 	unsigned char   reserved2[29];   /* for future use */
198 } __attribute__ ((packed)) attrib_data_t;
199 
200 /* definition of operation (cache) bits within attributes of DE */
201 #define DASD_NORMAL_CACHE  0x0
202 #define DASD_BYPASS_CACHE  0x1
203 #define DASD_INHIBIT_LOAD  0x2
204 #define DASD_SEQ_ACCESS    0x3
205 #define DASD_SEQ_PRESTAGE  0x4
206 #define DASD_REC_ACCESS    0x5
207 
208 
209 /********************************************************************************
210  * SECTION: Definition of IOCTLs
211  *
212  * Here ist how the ioctl-nr should be used:
213  *    0 -   31   DASD driver itself
214  *   32 -  239   still open
215  *  240 -  255   reserved for EMC
216  *******************************************************************************/
217 
218 /* Disable the volume (for Linux) */
219 #define BIODASDDISABLE _IO(DASD_IOCTL_LETTER,0)
220 /* Enable the volume (for Linux) */
221 #define BIODASDENABLE  _IO(DASD_IOCTL_LETTER,1)
222 /* Issue a reserve/release command, rsp. */
223 #define BIODASDRSRV    _IO(DASD_IOCTL_LETTER,2) /* reserve */
224 #define BIODASDRLSE    _IO(DASD_IOCTL_LETTER,3) /* release */
225 #define BIODASDSLCK    _IO(DASD_IOCTL_LETTER,4) /* steal lock */
226 /* reset profiling information of a device */
227 #define BIODASDPRRST   _IO(DASD_IOCTL_LETTER,5)
228 /* Quiesce IO on device */
229 #define BIODASDQUIESCE _IO(DASD_IOCTL_LETTER,6)
230 /* Resume IO on device */
231 #define BIODASDRESUME  _IO(DASD_IOCTL_LETTER,7)
232 
233 
234 /* retrieve API version number */
235 #define DASDAPIVER     _IOR(DASD_IOCTL_LETTER,0,int)
236 /* Get information on a dasd device */
237 #define BIODASDINFO    _IOR(DASD_IOCTL_LETTER,1,dasd_information_t)
238 /* retrieve profiling information of a device */
239 #define BIODASDPRRD    _IOR(DASD_IOCTL_LETTER,2,dasd_profile_info_t)
240 /* Get information on a dasd device (enhanced) */
241 #define BIODASDINFO2   _IOR(DASD_IOCTL_LETTER,3,dasd_information2_t)
242 /* Performance Statistics Read */
243 #define BIODASDPSRD    _IOR(DASD_IOCTL_LETTER,4,dasd_rssd_perf_stats_t)
244 /* Get Attributes (cache operations) */
245 #define BIODASDGATTR   _IOR(DASD_IOCTL_LETTER,5,attrib_data_t)
246 
247 
248 /* #define BIODASDFORMAT  _IOW(IOCTL_LETTER,0,format_data_t) , deprecated */
249 #define BIODASDFMT     _IOW(DASD_IOCTL_LETTER,1,format_data_t)
250 /* Set Attributes (cache operations) */
251 #define BIODASDSATTR   _IOW(DASD_IOCTL_LETTER,2,attrib_data_t)
252 
253 
254 #endif				/* DASD_H */
255 
256 /*
257  * Overrides for Emacs so that we follow Linus's tabbing style.
258  * Emacs will notice this stuff at the end of the file and automatically
259  * adjust the settings for this buffer only.  This must remain at the end
260  * of the file.
261  * ---------------------------------------------------------------------------
262  * Local variables:
263  * c-indent-level: 4
264  * c-brace-imaginary-offset: 0
265  * c-brace-offset: -4
266  * c-argdecl-indent: 4
267  * c-label-offset: -4
268  * c-continued-statement-offset: 4
269  * c-continued-brace-offset: 0
270  * indent-tabs-mode: nil
271  * tab-width: 8
272  * End:
273  */
274