xref: /linux/arch/s390/include/uapi/asm/dasd.h (revision f85f5ae45ad945270a8884261de8249431e8b5a6)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4  * Bugreports.to..: <Linux390@de.ibm.com>
5  * Copyright IBM Corp. 1999, 2000
6  * EMC Symmetrix ioctl Copyright EMC Corporation, 2008
7  * Author.........: Nigel Hislop <hislop_nigel@emc.com>
8  *
9  * This file is the interface of the DASD device driver, which is exported to user space
10  * any future changes wrt the API will result in a change of the APIVERSION reported
11  * to userspace by the DASDAPIVER-ioctl
12  *
13  */
14 
15 #ifndef DASD_H
16 #define DASD_H
17 #include <linux/types.h>
18 #include <linux/ioctl.h>
19 
20 #define DASD_IOCTL_LETTER 'D'
21 
22 #define DASD_API_VERSION 6
23 
24 /*
25  * struct dasd_information2_t
26  * represents any data about the device, which is visible to userspace.
27  *  including format and featueres.
28  */
29 typedef struct dasd_information2_t {
30 	unsigned int devno;	    /* S/390 devno */
31 	unsigned int real_devno;    /* for aliases */
32 	unsigned int schid;	    /* S/390 subchannel identifier */
33 	unsigned int cu_type  : 16; /* from SenseID */
34 	unsigned int cu_model :  8; /* from SenseID */
35 	unsigned int dev_type : 16; /* from SenseID */
36 	unsigned int dev_model : 8; /* from SenseID */
37 	unsigned int open_count;
38 	unsigned int req_queue_len;
39 	unsigned int chanq_len;     /* length of chanq */
40 	char type[4];		    /* from discipline.name, 'none' for unknown */
41 	unsigned int status;	    /* current device level */
42 	unsigned int label_block;   /* where to find the VOLSER */
43 	unsigned int FBA_layout;    /* fixed block size (like AIXVOL) */
44 	unsigned int characteristics_size;
45 	unsigned int confdata_size;
46 	char characteristics[64];   /* from read_device_characteristics */
47 	char configuration_data[256]; /* from read_configuration_data */
48 	unsigned int format;	      /* format info like formatted/cdl/ldl/... */
49 	unsigned int features;	      /* dasd features like 'ro',...		*/
50 	unsigned int reserved0;       /* reserved for further use ,...		*/
51 	unsigned int reserved1;       /* reserved for further use ,...		*/
52 	unsigned int reserved2;       /* reserved for further use ,...		*/
53 	unsigned int reserved3;       /* reserved for further use ,...		*/
54 	unsigned int reserved4;       /* reserved for further use ,...		*/
55 	unsigned int reserved5;       /* reserved for further use ,...		*/
56 	unsigned int reserved6;       /* reserved for further use ,...		*/
57 	unsigned int reserved7;       /* reserved for further use ,...		*/
58 } dasd_information2_t;
59 
60 /*
61  * values to be used for dasd_information_t.format
62  * 0x00: NOT formatted
63  * 0x01: Linux disc layout
64  * 0x02: Common disc layout
65  */
66 #define DASD_FORMAT_NONE 0
67 #define DASD_FORMAT_LDL  1
68 #define DASD_FORMAT_CDL  2
69 /*
70  * values to be used for dasd_information_t.features
71  * 0x100: default features
72  * 0x001: readonly (ro)
73  * 0x002: use diag discipline (diag)
74  * 0x004: set the device initially online (internal use only)
75  * 0x008: enable ERP related logging
76  * 0x010: allow I/O to fail on lost paths
77  * 0x020: allow I/O to fail when a lock was stolen
78  * 0x040: give access to raw eckd data
79  * 0x080: enable discard support
80  * 0x100: enable autodisable for IFCC errors (default)
81  * 0x200: enable requeue of all requests on autoquiesce
82  */
83 #define DASD_FEATURE_READONLY	      0x001
84 #define DASD_FEATURE_USEDIAG	      0x002
85 #define DASD_FEATURE_INITIAL_ONLINE   0x004
86 #define DASD_FEATURE_ERPLOG	      0x008
87 #define DASD_FEATURE_FAILFAST	      0x010
88 #define DASD_FEATURE_FAILONSLCK       0x020
89 #define DASD_FEATURE_USERAW	      0x040
90 #define DASD_FEATURE_DISCARD	      0x080
91 #define DASD_FEATURE_PATH_AUTODISABLE 0x100
92 #define DASD_FEATURE_REQUEUEQUIESCE   0x200
93 #define DASD_FEATURE_DEFAULT	      DASD_FEATURE_PATH_AUTODISABLE
94 
95 #define DASD_PARTN_BITS 2
96 
97 /*
98  * struct dasd_information_t
99  * represents any data about the data, which is visible to userspace
100  */
101 typedef struct dasd_information_t {
102 	unsigned int devno;	    /* S/390 devno */
103 	unsigned int real_devno;    /* for aliases */
104 	unsigned int schid;	    /* S/390 subchannel identifier */
105 	unsigned int cu_type  : 16; /* from SenseID */
106 	unsigned int cu_model :  8; /* from SenseID */
107 	unsigned int dev_type : 16; /* from SenseID */
108 	unsigned int dev_model : 8; /* from SenseID */
109 	unsigned int open_count;
110 	unsigned int req_queue_len;
111 	unsigned int chanq_len;     /* length of chanq */
112 	char type[4];		    /* from discipline.name, 'none' for unknown */
113 	unsigned int status;	    /* current device level */
114 	unsigned int label_block;   /* where to find the VOLSER */
115 	unsigned int FBA_layout;    /* fixed block size (like AIXVOL) */
116 	unsigned int characteristics_size;
117 	unsigned int confdata_size;
118 	char characteristics[64];   /* from read_device_characteristics */
119 	char configuration_data[256]; /* from read_configuration_data */
120 } dasd_information_t;
121 
122 /*
123  * Read Subsystem Data - Performance Statistics
124  */
125 typedef struct dasd_rssd_perf_stats_t {
126 	unsigned char  invalid:1;
127 	unsigned char  format:3;
128 	unsigned char  data_format:4;
129 	unsigned char  unit_address;
130 	unsigned short device_status;
131 	unsigned int   nr_read_normal;
132 	unsigned int   nr_read_normal_hits;
133 	unsigned int   nr_write_normal;
134 	unsigned int   nr_write_fast_normal_hits;
135 	unsigned int   nr_read_seq;
136 	unsigned int   nr_read_seq_hits;
137 	unsigned int   nr_write_seq;
138 	unsigned int   nr_write_fast_seq_hits;
139 	unsigned int   nr_read_cache;
140 	unsigned int   nr_read_cache_hits;
141 	unsigned int   nr_write_cache;
142 	unsigned int   nr_write_fast_cache_hits;
143 	unsigned int   nr_inhibit_cache;
144 	unsigned int   nr_bybass_cache;
145 	unsigned int   nr_seq_dasd_to_cache;
146 	unsigned int   nr_dasd_to_cache;
147 	unsigned int   nr_cache_to_dasd;
148 	unsigned int   nr_delayed_fast_write;
149 	unsigned int   nr_normal_fast_write;
150 	unsigned int   nr_seq_fast_write;
151 	unsigned int   nr_cache_miss;
152 	unsigned char  status2;
153 	unsigned int   nr_quick_write_promotes;
154 	unsigned char  reserved;
155 	unsigned short ssid;
156 	unsigned char  reseved2[96];
157 } __attribute__((packed)) dasd_rssd_perf_stats_t;
158 
159 /*
160  * struct profile_info_t
161  * holds the profinling information
162  */
163 typedef struct dasd_profile_info_t {
164 	unsigned int dasd_io_reqs;	 /* number of requests processed at all */
165 	unsigned int dasd_io_sects;	 /* number of sectors processed at all */
166 	unsigned int dasd_io_secs[32];	 /* histogram of request's sizes */
167 	unsigned int dasd_io_times[32];	 /* histogram of requests's times */
168 	unsigned int dasd_io_timps[32];	 /* histogram of requests's times per sector */
169 	unsigned int dasd_io_time1[32];	 /* histogram of time from build to start */
170 	unsigned int dasd_io_time2[32];	 /* histogram of time from start to irq */
171 	unsigned int dasd_io_time2ps[32]; /* histogram of time from start to irq */
172 	unsigned int dasd_io_time3[32];	 /* histogram of time from irq to end */
173 	unsigned int dasd_io_nr_req[32]; /* histogram of # of requests in chanq */
174 } dasd_profile_info_t;
175 
176 /*
177  * struct format_data_t
178  * represents all data necessary to format a dasd
179  */
180 typedef struct format_data_t {
181 	unsigned int start_unit; /* from track */
182 	unsigned int stop_unit;  /* to track */
183 	unsigned int blksize;	 /* sectorsize */
184 	unsigned int intensity;
185 } format_data_t;
186 
187 /*
188  * struct dasd_copypair_swap_data_t
189  * represents all data necessary to issue a swap of the copy pair relation
190  */
191 struct dasd_copypair_swap_data_t {
192 	char primary[20]; /* BUSID of primary */
193 	char secondary[20]; /* BUSID of secondary */
194 
195 	/* Reserved for future updates. */
196 	__u8 reserved[64];
197 };
198 
199 /*
200  * values to be used for format_data_t.intensity
201  * 0/8: normal format
202  * 1/9: also write record zero
203  * 3/11: also write home address
204  * 4/12: invalidate track
205  */
206 #define DASD_FMT_INT_FMT_R0	1	/* write record zero */
207 #define DASD_FMT_INT_FMT_HA	2	/* write home address, also set FMT_R0 ! */
208 #define DASD_FMT_INT_INVAL	4	/* invalidate tracks */
209 #define DASD_FMT_INT_COMPAT	8	/* use OS/390 compatible disk layout */
210 #define DASD_FMT_INT_FMT_NOR0	16	/* remove permission to write record zero */
211 #define DASD_FMT_INT_ESE_FULL	32	/* release space for entire volume */
212 
213 /*
214  * struct format_check_t
215  * represents all data necessary to evaluate the format of
216  * different tracks of a dasd
217  */
218 typedef struct format_check_t {
219 	/* Input */
220 	struct format_data_t expect;
221 
222 	/* Output */
223 	unsigned int result;		/* Error indication (DASD_FMT_ERR_*) */
224 	unsigned int unit;		/* Track that is in error */
225 	unsigned int rec;		/* Record that is in error */
226 	unsigned int num_records;	/* Records in the track in error */
227 	unsigned int blksize;		/* Blocksize of first record in error */
228 	unsigned int key_length;	/* Key length of first record in error */
229 } format_check_t;
230 
231 /* Values returned in format_check_t when a format error is detected: */
232 /* Too few records were found on a single track */
233 #define DASD_FMT_ERR_TOO_FEW_RECORDS	1
234 /* Too many records were found on a single track */
235 #define DASD_FMT_ERR_TOO_MANY_RECORDS	2
236 /* Blocksize/data-length of a record was wrong */
237 #define DASD_FMT_ERR_BLKSIZE		3
238 /* A record ID is defined by cylinder, head, and record number (CHR). */
239 /* On mismatch, this error is set */
240 #define DASD_FMT_ERR_RECORD_ID		4
241 /* If key-length was != 0 */
242 #define DASD_FMT_ERR_KEY_LENGTH		5
243 
244 /*
245  * struct attrib_data_t
246  * represents the operation (cache) bits for the device.
247  * Used in DE to influence caching of the DASD.
248  */
249 typedef struct attrib_data_t {
250 	unsigned char operation:3;     /* cache operation mode */
251 	unsigned char reserved:5;      /* cache operation mode */
252 	__u16         nr_cyl;          /* no of cyliners for read ahaed */
253 	__u8          reserved2[29];   /* for future use */
254 } __attribute__ ((packed)) attrib_data_t;
255 
256 /* definition of operation (cache) bits within attributes of DE */
257 #define DASD_NORMAL_CACHE  0x0
258 #define DASD_BYPASS_CACHE  0x1
259 #define DASD_INHIBIT_LOAD  0x2
260 #define DASD_SEQ_ACCESS    0x3
261 #define DASD_SEQ_PRESTAGE  0x4
262 #define DASD_REC_ACCESS    0x5
263 
264 /*
265  * Perform EMC Symmetrix I/O
266  */
267 typedef struct dasd_symmio_parms {
268 	unsigned char reserved[8];	/* compat with older releases */
269 	unsigned long long psf_data;	/* char * cast to u64 */
270 	unsigned long long rssd_result; /* char * cast to u64 */
271 	int psf_data_len;
272 	int rssd_result_len;
273 } __attribute__ ((packed)) dasd_symmio_parms_t;
274 
275 /*
276  * Data returned by Sense Path Group ID (SNID)
277  */
278 struct dasd_snid_data {
279 	struct {
280 		__u8 group:2;
281 		__u8 reserve:2;
282 		__u8 mode:1;
283 		__u8 res:3;
284 	} __attribute__ ((packed)) path_state;
285 	__u8 pgid[11];
286 } __attribute__ ((packed));
287 
288 struct dasd_snid_ioctl_data {
289 	struct dasd_snid_data data;
290 	__u8 path_mask;
291 } __attribute__ ((packed));
292 
293 
294 /********************************************************************************
295  * SECTION: Definition of IOCTLs
296  *
297  * Here ist how the ioctl-nr should be used:
298  *    0 -   31   DASD driver itself
299  *   32 -  239   still open
300  *  240 -  255	 reserved for EMC
301  *******************************************************************************/
302 
303 /* Disable the volume (for Linux) */
304 #define BIODASDDISABLE _IO(DASD_IOCTL_LETTER,0)
305 /* Enable the volume (for Linux) */
306 #define BIODASDENABLE  _IO(DASD_IOCTL_LETTER,1)
307 /* Issue a reserve/release command, rsp. */
308 #define BIODASDRSRV    _IO(DASD_IOCTL_LETTER,2) /* reserve */
309 #define BIODASDRLSE    _IO(DASD_IOCTL_LETTER,3) /* release */
310 #define BIODASDSLCK    _IO(DASD_IOCTL_LETTER,4) /* steal lock */
311 /* reset profiling information of a device */
312 #define BIODASDPRRST   _IO(DASD_IOCTL_LETTER,5)
313 /* Quiesce IO on device */
314 #define BIODASDQUIESCE _IO(DASD_IOCTL_LETTER,6)
315 /* Resume IO on device */
316 #define BIODASDRESUME  _IO(DASD_IOCTL_LETTER,7)
317 /* Abort all I/O on a device */
318 #define BIODASDABORTIO _IO(DASD_IOCTL_LETTER, 240)
319 /* Allow I/O on a device */
320 #define BIODASDALLOWIO _IO(DASD_IOCTL_LETTER, 241)
321 
322 
323 /* retrieve API version number */
324 #define DASDAPIVER     _IOR(DASD_IOCTL_LETTER,0,int)
325 /* Get information on a dasd device */
326 #define BIODASDINFO    _IOR(DASD_IOCTL_LETTER,1,dasd_information_t)
327 /* retrieve profiling information of a device */
328 #define BIODASDPRRD    _IOR(DASD_IOCTL_LETTER,2,dasd_profile_info_t)
329 /* Get information on a dasd device (enhanced) */
330 #define BIODASDINFO2   _IOR(DASD_IOCTL_LETTER,3,dasd_information2_t)
331 /* Performance Statistics Read */
332 #define BIODASDPSRD    _IOR(DASD_IOCTL_LETTER,4,dasd_rssd_perf_stats_t)
333 /* Get Attributes (cache operations) */
334 #define BIODASDGATTR   _IOR(DASD_IOCTL_LETTER,5,attrib_data_t)
335 
336 
337 /* #define BIODASDFORMAT  _IOW(IOCTL_LETTER,0,format_data_t) , deprecated */
338 #define BIODASDFMT     _IOW(DASD_IOCTL_LETTER,1,format_data_t)
339 /* Set Attributes (cache operations) */
340 #define BIODASDSATTR   _IOW(DASD_IOCTL_LETTER,2,attrib_data_t)
341 /* Release Allocated Space */
342 #define BIODASDRAS     _IOW(DASD_IOCTL_LETTER, 3, format_data_t)
343 /* Swap copy pair relation */
344 #define BIODASDCOPYPAIRSWAP _IOW(DASD_IOCTL_LETTER, 4, struct dasd_copypair_swap_data_t)
345 
346 /* Get Sense Path Group ID (SNID) data */
347 #define BIODASDSNID    _IOWR(DASD_IOCTL_LETTER, 1, struct dasd_snid_ioctl_data)
348 /* Check device format according to format_check_t */
349 #define BIODASDCHECKFMT _IOWR(DASD_IOCTL_LETTER, 2, format_check_t)
350 
351 #define BIODASDSYMMIO  _IOWR(DASD_IOCTL_LETTER, 240, dasd_symmio_parms_t)
352 
353 #endif				/* DASD_H */
354 
355