xref: /openbmc/linux/drivers/s390/block/dasd_eckd.h (revision a09d2831)
1 /*
2  * File...........: linux/drivers/s390/block/dasd_eckd.h
3  * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4  *		    Horst Hummel <Horst.Hummel@de.ibm.com>
5  * Bugreports.to..: <Linux390@de.ibm.com>
6  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
7  *
8  */
9 
10 #ifndef DASD_ECKD_H
11 #define DASD_ECKD_H
12 
13 /*****************************************************************************
14  * SECTION: CCW Definitions
15  ****************************************************************************/
16 #define DASD_ECKD_CCW_WRITE		 0x05
17 #define DASD_ECKD_CCW_READ		 0x06
18 #define DASD_ECKD_CCW_WRITE_HOME_ADDRESS 0x09
19 #define DASD_ECKD_CCW_READ_HOME_ADDRESS	 0x0a
20 #define DASD_ECKD_CCW_WRITE_KD		 0x0d
21 #define DASD_ECKD_CCW_READ_KD		 0x0e
22 #define DASD_ECKD_CCW_ERASE		 0x11
23 #define DASD_ECKD_CCW_READ_COUNT	 0x12
24 #define DASD_ECKD_CCW_SLCK		 0x14
25 #define DASD_ECKD_CCW_WRITE_RECORD_ZERO	 0x15
26 #define DASD_ECKD_CCW_READ_RECORD_ZERO	 0x16
27 #define DASD_ECKD_CCW_WRITE_CKD		 0x1d
28 #define DASD_ECKD_CCW_READ_CKD		 0x1e
29 #define DASD_ECKD_CCW_PSF		 0x27
30 #define DASD_ECKD_CCW_RSSD		 0x3e
31 #define DASD_ECKD_CCW_LOCATE_RECORD	 0x47
32 #define DASD_ECKD_CCW_SNSS		 0x54
33 #define DASD_ECKD_CCW_DEFINE_EXTENT	 0x63
34 #define DASD_ECKD_CCW_WRITE_MT		 0x85
35 #define DASD_ECKD_CCW_READ_MT		 0x86
36 #define DASD_ECKD_CCW_WRITE_KD_MT	 0x8d
37 #define DASD_ECKD_CCW_READ_KD_MT	 0x8e
38 #define DASD_ECKD_CCW_RELEASE		 0x94
39 #define DASD_ECKD_CCW_READ_CKD_MT	 0x9e
40 #define DASD_ECKD_CCW_WRITE_CKD_MT	 0x9d
41 #define DASD_ECKD_CCW_WRITE_TRACK_DATA	 0xA5
42 #define DASD_ECKD_CCW_READ_TRACK_DATA	 0xA6
43 #define DASD_ECKD_CCW_RESERVE		 0xB4
44 #define DASD_ECKD_CCW_PFX		 0xE7
45 #define DASD_ECKD_CCW_PFX_READ		 0xEA
46 #define DASD_ECKD_CCW_RSCK		 0xF9
47 
48 /*
49  * Perform Subsystem Function / Sub-Orders
50  */
51 #define PSF_ORDER_PRSSD 0x18
52 #define PSF_ORDER_SSC	0x1D
53 
54 /*
55  * Size that is reportet for large volumes in the old 16-bit no_cyl field
56  */
57 #define LV_COMPAT_CYL 0xFFFE
58 
59 /*****************************************************************************
60  * SECTION: Type Definitions
61  ****************************************************************************/
62 
63 struct eckd_count {
64 	__u16 cyl;
65 	__u16 head;
66 	__u8 record;
67 	__u8 kl;
68 	__u16 dl;
69 } __attribute__ ((packed));
70 
71 struct ch_t {
72 	__u16 cyl;
73 	__u16 head;
74 } __attribute__ ((packed));
75 
76 struct chs_t {
77 	__u16 cyl;
78 	__u16 head;
79 	__u32 sector;
80 } __attribute__ ((packed));
81 
82 struct chr_t {
83 	__u16 cyl;
84 	__u16 head;
85 	__u8 record;
86 } __attribute__ ((packed));
87 
88 struct geom_t {
89 	__u16 cyl;
90 	__u16 head;
91 	__u32 sector;
92 } __attribute__ ((packed));
93 
94 struct eckd_home {
95 	__u8 skip_control[14];
96 	__u16 cell_number;
97 	__u8 physical_addr[3];
98 	__u8 flag;
99 	struct ch_t track_addr;
100 	__u8 reserved;
101 	__u8 key_length;
102 	__u8 reserved2[2];
103 } __attribute__ ((packed));
104 
105 struct DE_eckd_data {
106 	struct {
107 		unsigned char perm:2;	/* Permissions on this extent */
108 		unsigned char reserved:1;
109 		unsigned char seek:2;	/* Seek control */
110 		unsigned char auth:2;	/* Access authorization */
111 		unsigned char pci:1;	/* PCI Fetch mode */
112 	} __attribute__ ((packed)) mask;
113 	struct {
114 		unsigned char mode:2;	/* Architecture mode */
115 		unsigned char ckd:1;	/* CKD Conversion */
116 		unsigned char operation:3;	/* Operation mode */
117 		unsigned char cfw:1;	/* Cache fast write */
118 		unsigned char dfw:1;	/* DASD fast write */
119 	} __attribute__ ((packed)) attributes;
120 	__u16 blk_size;		/* Blocksize */
121 	__u16 fast_write_id;
122 	__u8 ga_additional;	/* Global Attributes Additional */
123 	__u8 ga_extended;	/* Global Attributes Extended	*/
124 	struct ch_t beg_ext;
125 	struct ch_t end_ext;
126 	unsigned long long ep_sys_time; /* Ext Parameter - System Time Stamp */
127 	__u8 ep_format;        /* Extended Parameter format byte       */
128 	__u8 ep_prio;          /* Extended Parameter priority I/O byte */
129 	__u8 ep_reserved1;     /* Extended Parameter Reserved	       */
130 	__u8 ep_rec_per_track; /* Number of records on a track	       */
131 	__u8 ep_reserved[4];   /* Extended Parameter Reserved	       */
132 } __attribute__ ((packed));
133 
134 struct LO_eckd_data {
135 	struct {
136 		unsigned char orientation:2;
137 		unsigned char operation:6;
138 	} __attribute__ ((packed)) operation;
139 	struct {
140 		unsigned char last_bytes_used:1;
141 		unsigned char reserved:6;
142 		unsigned char read_count_suffix:1;
143 	} __attribute__ ((packed)) auxiliary;
144 	__u8 unused;
145 	__u8 count;
146 	struct ch_t seek_addr;
147 	struct chr_t search_arg;
148 	__u8 sector;
149 	__u16 length;
150 } __attribute__ ((packed));
151 
152 struct LRE_eckd_data {
153 	struct {
154 		unsigned char orientation:2;
155 		unsigned char operation:6;
156 	} __attribute__ ((packed)) operation;
157 	struct {
158 		unsigned char length_valid:1;
159 		unsigned char length_scope:1;
160 		unsigned char imbedded_ccw_valid:1;
161 		unsigned char check_bytes:2;
162 		unsigned char imbedded_count_valid:1;
163 		unsigned char reserved:1;
164 		unsigned char read_count_suffix:1;
165 	} __attribute__ ((packed)) auxiliary;
166 	__u8 imbedded_ccw;
167 	__u8 count;
168 	struct ch_t seek_addr;
169 	struct chr_t search_arg;
170 	__u8 sector;
171 	__u16 length;
172 	__u8 imbedded_count;
173 	__u8 extended_operation;
174 	__u16 extended_parameter_length;
175 	__u8 extended_parameter[0];
176 } __attribute__ ((packed));
177 
178 /* Prefix data for format 0x00 and 0x01 */
179 struct PFX_eckd_data {
180 	unsigned char format;
181 	struct {
182 		unsigned char define_extent:1;
183 		unsigned char time_stamp:1;
184 		unsigned char verify_base:1;
185 		unsigned char hyper_pav:1;
186 		unsigned char reserved:4;
187 	} __attribute__ ((packed)) validity;
188 	__u8 base_address;
189 	__u8 aux;
190 	__u8 base_lss;
191 	__u8 reserved[7];
192 	struct DE_eckd_data define_extent;
193 	struct LRE_eckd_data locate_record;
194 } __attribute__ ((packed));
195 
196 struct dasd_eckd_characteristics {
197 	__u16 cu_type;
198 	struct {
199 		unsigned char support:2;
200 		unsigned char async:1;
201 		unsigned char reserved:1;
202 		unsigned char cache_info:1;
203 		unsigned char model:3;
204 	} __attribute__ ((packed)) cu_model;
205 	__u16 dev_type;
206 	__u8 dev_model;
207 	struct {
208 		unsigned char mult_burst:1;
209 		unsigned char RT_in_LR:1;
210 		unsigned char reserved1:1;
211 		unsigned char RD_IN_LR:1;
212 		unsigned char reserved2:4;
213 		unsigned char reserved3:8;
214 		unsigned char defect_wr:1;
215 		unsigned char XRC_supported:1;
216 		unsigned char reserved4:1;
217 		unsigned char striping:1;
218 		unsigned char reserved5:4;
219 		unsigned char cfw:1;
220 		unsigned char reserved6:2;
221 		unsigned char cache:1;
222 		unsigned char dual_copy:1;
223 		unsigned char dfw:1;
224 		unsigned char reset_alleg:1;
225 		unsigned char sense_down:1;
226 	} __attribute__ ((packed)) facilities;
227 	__u8 dev_class;
228 	__u8 unit_type;
229 	__u16 no_cyl;
230 	__u16 trk_per_cyl;
231 	__u8 sec_per_trk;
232 	__u8 byte_per_track[3];
233 	__u16 home_bytes;
234 	__u8 formula;
235 	union {
236 		struct {
237 			__u8 f1;
238 			__u16 f2;
239 			__u16 f3;
240 		} __attribute__ ((packed)) f_0x01;
241 		struct {
242 			__u8 f1;
243 			__u8 f2;
244 			__u8 f3;
245 			__u8 f4;
246 			__u8 f5;
247 		} __attribute__ ((packed)) f_0x02;
248 	} __attribute__ ((packed)) factors;
249 	__u16 first_alt_trk;
250 	__u16 no_alt_trk;
251 	__u16 first_dia_trk;
252 	__u16 no_dia_trk;
253 	__u16 first_sup_trk;
254 	__u16 no_sup_trk;
255 	__u8 MDR_ID;
256 	__u8 OBR_ID;
257 	__u8 director;
258 	__u8 rd_trk_set;
259 	__u16 max_rec_zero;
260 	__u8 reserved1;
261 	__u8 RWANY_in_LR;
262 	__u8 factor6;
263 	__u8 factor7;
264 	__u8 factor8;
265 	__u8 reserved2[3];
266 	__u8 reserved3[6];
267 	__u32 long_no_cyl;
268 } __attribute__ ((packed));
269 
270 /* elements of the configuration data */
271 struct dasd_ned {
272 	struct {
273 		__u8 identifier:2;
274 		__u8 token_id:1;
275 		__u8 sno_valid:1;
276 		__u8 subst_sno:1;
277 		__u8 recNED:1;
278 		__u8 emuNED:1;
279 		__u8 reserved:1;
280 	} __attribute__ ((packed)) flags;
281 	__u8 descriptor;
282 	__u8 dev_class;
283 	__u8 reserved;
284 	__u8 dev_type[6];
285 	__u8 dev_model[3];
286 	__u8 HDA_manufacturer[3];
287 	__u8 HDA_location[2];
288 	__u8 HDA_seqno[12];
289 	__u8 ID;
290 	__u8 unit_addr;
291 } __attribute__ ((packed));
292 
293 struct dasd_sneq {
294 	struct {
295 		__u8 identifier:2;
296 		__u8 reserved:6;
297 	} __attribute__ ((packed)) flags;
298 	__u8 res1;
299 	__u16 format;
300 	__u8 res2[4];		/* byte  4- 7 */
301 	__u8 sua_flags;		/* byte  8    */
302 	__u8 base_unit_addr;	/* byte  9    */
303 	__u8 res3[22];		/* byte 10-31 */
304 } __attribute__ ((packed));
305 
306 struct vd_sneq {
307 	struct {
308 		__u8 identifier:2;
309 		__u8 reserved:6;
310 	} __attribute__ ((packed)) flags;
311 	__u8 res1;
312 	__u16 format;
313 	__u8 res2[4];	/* byte  4- 7 */
314 	__u8 uit[16];	/* byte  8-23 */
315 	__u8 res3[8];	/* byte 24-31 */
316 } __attribute__ ((packed));
317 
318 struct dasd_gneq {
319 	struct {
320 		__u8 identifier:2;
321 		__u8 reserved:6;
322 	} __attribute__ ((packed)) flags;
323 	__u8 reserved[7];
324 	__u16 subsystemID;
325 	__u8 reserved2[22];
326 } __attribute__ ((packed));
327 
328 struct dasd_eckd_path {
329 	__u8 opm;
330 	__u8 ppm;
331 	__u8 npm;
332 };
333 
334 struct dasd_rssd_features {
335 	char feature[256];
336 } __attribute__((packed));
337 
338 
339 /*
340  * Perform Subsystem Function - Prepare for Read Subsystem Data
341  */
342 struct dasd_psf_prssd_data {
343 	unsigned char order;
344 	unsigned char flags;
345 	unsigned char reserved[4];
346 	unsigned char suborder;
347 	unsigned char varies[5];
348 } __attribute__ ((packed));
349 
350 /*
351  * Perform Subsystem Function - Set Subsystem Characteristics
352  */
353 struct dasd_psf_ssc_data {
354 	unsigned char order;
355 	unsigned char flags;
356 	unsigned char cu_type[4];
357 	unsigned char suborder;
358 	unsigned char reserved[59];
359 } __attribute__((packed));
360 
361 
362 /*
363  * some structures and definitions for alias handling
364  */
365 struct dasd_unit_address_configuration {
366 	struct {
367 		char ua_type;
368 		char base_ua;
369 	} unit[256];
370 } __attribute__((packed));
371 
372 
373 #define MAX_DEVICES_PER_LCU 256
374 
375 /* flags on the LCU  */
376 #define NEED_UAC_UPDATE  0x01
377 #define UPDATE_PENDING	0x02
378 
379 enum pavtype {NO_PAV, BASE_PAV, HYPER_PAV};
380 
381 
382 struct alias_root {
383 	struct list_head serverlist;
384 	spinlock_t lock;
385 };
386 
387 struct alias_server {
388 	struct list_head server;
389 	struct dasd_uid uid;
390 	struct list_head lculist;
391 };
392 
393 struct summary_unit_check_work_data {
394 	char reason;
395 	struct dasd_device *device;
396 	struct work_struct worker;
397 };
398 
399 struct read_uac_work_data {
400 	struct dasd_device *device;
401 	struct delayed_work dwork;
402 };
403 
404 struct alias_lcu {
405 	struct list_head lcu;
406 	struct dasd_uid uid;
407 	enum pavtype pav;
408 	char flags;
409 	spinlock_t lock;
410 	struct list_head grouplist;
411 	struct list_head active_devices;
412 	struct list_head inactive_devices;
413 	struct dasd_unit_address_configuration *uac;
414 	struct summary_unit_check_work_data suc_data;
415 	struct read_uac_work_data ruac_data;
416 	struct dasd_ccw_req *rsu_cqr;
417 	struct completion lcu_setup;
418 };
419 
420 struct alias_pav_group {
421 	struct list_head group;
422 	struct dasd_uid uid;
423 	struct alias_lcu *lcu;
424 	struct list_head baselist;
425 	struct list_head aliaslist;
426 	struct dasd_device *next;
427 };
428 
429 
430 struct dasd_eckd_private {
431 	struct dasd_eckd_characteristics rdc_data;
432 	u8 *conf_data;
433 	int conf_len;
434 	/* pointers to specific parts in the conf_data */
435 	struct dasd_ned *ned;
436 	struct dasd_sneq *sneq;
437 	struct vd_sneq *vdsneq;
438 	struct dasd_gneq *gneq;
439 
440 	struct dasd_eckd_path path_data;
441 	struct eckd_count count_area[5];
442 	int init_cqr_status;
443 	int uses_cdl;
444 	struct attrib_data_t attrib;	/* e.g. cache operations */
445 	struct dasd_rssd_features features;
446 	u32 real_cyl;
447 
448 	/* alias managemnet */
449 	struct dasd_uid uid;
450 	struct alias_pav_group *pavgroup;
451 	struct alias_lcu *lcu;
452 	int count;
453 };
454 
455 
456 
457 int dasd_alias_make_device_known_to_lcu(struct dasd_device *);
458 void dasd_alias_disconnect_device_from_lcu(struct dasd_device *);
459 int dasd_alias_add_device(struct dasd_device *);
460 int dasd_alias_remove_device(struct dasd_device *);
461 struct dasd_device *dasd_alias_get_start_dev(struct dasd_device *);
462 void dasd_alias_handle_summary_unit_check(struct dasd_device *, struct irb *);
463 void dasd_eckd_reset_ccw_to_base_io(struct dasd_ccw_req *);
464 void dasd_alias_lcu_setup_complete(struct dasd_device *);
465 void dasd_alias_wait_for_lcu_setup(struct dasd_device *);
466 #endif				/* DASD_ECKD_H */
467