xref: /openbmc/linux/drivers/s390/block/dasd_eckd.h (revision a36954f5)
1 /*
2  * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
3  *		    Horst Hummel <Horst.Hummel@de.ibm.com>
4  * Bugreports.to..: <Linux390@de.ibm.com>
5  * Copyright IBM Corp. 1999, 2000
6  *
7  */
8 
9 #ifndef DASD_ECKD_H
10 #define DASD_ECKD_H
11 
12 /*****************************************************************************
13  * SECTION: CCW Definitions
14  ****************************************************************************/
15 #define DASD_ECKD_CCW_WRITE		 0x05
16 #define DASD_ECKD_CCW_READ		 0x06
17 #define DASD_ECKD_CCW_WRITE_HOME_ADDRESS 0x09
18 #define DASD_ECKD_CCW_READ_HOME_ADDRESS	 0x0a
19 #define DASD_ECKD_CCW_WRITE_KD		 0x0d
20 #define DASD_ECKD_CCW_READ_KD		 0x0e
21 #define DASD_ECKD_CCW_ERASE		 0x11
22 #define DASD_ECKD_CCW_READ_COUNT	 0x12
23 #define DASD_ECKD_CCW_SLCK		 0x14
24 #define DASD_ECKD_CCW_WRITE_RECORD_ZERO	 0x15
25 #define DASD_ECKD_CCW_READ_RECORD_ZERO	 0x16
26 #define DASD_ECKD_CCW_WRITE_CKD		 0x1d
27 #define DASD_ECKD_CCW_READ_CKD		 0x1e
28 #define DASD_ECKD_CCW_PSF		 0x27
29 #define DASD_ECKD_CCW_SNID		 0x34
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_READ_COUNT_MT	 0x92
39 #define DASD_ECKD_CCW_RELEASE		 0x94
40 #define DASD_ECKD_CCW_WRITE_FULL_TRACK	 0x95
41 #define DASD_ECKD_CCW_READ_CKD_MT	 0x9e
42 #define DASD_ECKD_CCW_WRITE_CKD_MT	 0x9d
43 #define DASD_ECKD_CCW_WRITE_TRACK_DATA	 0xA5
44 #define DASD_ECKD_CCW_READ_TRACK_DATA	 0xA6
45 #define DASD_ECKD_CCW_RESERVE		 0xB4
46 #define DASD_ECKD_CCW_READ_TRACK	 0xDE
47 #define DASD_ECKD_CCW_PFX		 0xE7
48 #define DASD_ECKD_CCW_PFX_READ		 0xEA
49 #define DASD_ECKD_CCW_RSCK		 0xF9
50 #define DASD_ECKD_CCW_RCD		 0xFA
51 
52 /*
53  * Perform Subsystem Function / Sub-Orders
54  */
55 #define PSF_ORDER_PRSSD			 0x18
56 #define PSF_ORDER_CUIR_RESPONSE		 0x1A
57 #define PSF_SUBORDER_QHA		 0x1C
58 #define PSF_ORDER_SSC			 0x1D
59 
60 /*
61  * CUIR response condition codes
62  */
63 #define PSF_CUIR_INVALID		 0x00
64 #define PSF_CUIR_COMPLETED		 0x01
65 #define PSF_CUIR_NOT_SUPPORTED		 0x02
66 #define PSF_CUIR_ERROR_IN_REQ		 0x03
67 #define PSF_CUIR_DENIED			 0x04
68 #define PSF_CUIR_LAST_PATH		 0x05
69 #define PSF_CUIR_DEVICE_ONLINE		 0x06
70 #define PSF_CUIR_VARY_FAILURE		 0x07
71 #define PSF_CUIR_SOFTWARE_FAILURE	 0x08
72 #define PSF_CUIR_NOT_RECOGNIZED		 0x09
73 
74 /*
75  * CUIR codes
76  */
77 #define CUIR_QUIESCE			 0x01
78 #define CUIR_RESUME			 0x02
79 
80 /*
81  * attention message definitions
82  */
83 #define ATTENTION_LENGTH_CUIR		 0x0e
84 #define ATTENTION_FORMAT_CUIR		 0x01
85 
86 #define DASD_ECKD_PG_GROUPED		 0x10
87 
88 /*
89  * Size that is reportet for large volumes in the old 16-bit no_cyl field
90  */
91 #define LV_COMPAT_CYL 0xFFFE
92 
93 
94 #define FCX_MAX_DATA_FACTOR 65536
95 #define DASD_ECKD_RCD_DATA_SIZE 256
96 
97 #define DASD_ECKD_PATH_THRHLD		 256
98 #define DASD_ECKD_PATH_INTERVAL		 300
99 
100 /*****************************************************************************
101  * SECTION: Type Definitions
102  ****************************************************************************/
103 
104 struct eckd_count {
105 	__u16 cyl;
106 	__u16 head;
107 	__u8 record;
108 	__u8 kl;
109 	__u16 dl;
110 } __attribute__ ((packed));
111 
112 struct ch_t {
113 	__u16 cyl;
114 	__u16 head;
115 } __attribute__ ((packed));
116 
117 struct chs_t {
118 	__u16 cyl;
119 	__u16 head;
120 	__u32 sector;
121 } __attribute__ ((packed));
122 
123 struct chr_t {
124 	__u16 cyl;
125 	__u16 head;
126 	__u8 record;
127 } __attribute__ ((packed));
128 
129 struct geom_t {
130 	__u16 cyl;
131 	__u16 head;
132 	__u32 sector;
133 } __attribute__ ((packed));
134 
135 struct eckd_home {
136 	__u8 skip_control[14];
137 	__u16 cell_number;
138 	__u8 physical_addr[3];
139 	__u8 flag;
140 	struct ch_t track_addr;
141 	__u8 reserved;
142 	__u8 key_length;
143 	__u8 reserved2[2];
144 } __attribute__ ((packed));
145 
146 struct DE_eckd_data {
147 	struct {
148 		unsigned char perm:2;	/* Permissions on this extent */
149 		unsigned char reserved:1;
150 		unsigned char seek:2;	/* Seek control */
151 		unsigned char auth:2;	/* Access authorization */
152 		unsigned char pci:1;	/* PCI Fetch mode */
153 	} __attribute__ ((packed)) mask;
154 	struct {
155 		unsigned char mode:2;	/* Architecture mode */
156 		unsigned char ckd:1;	/* CKD Conversion */
157 		unsigned char operation:3;	/* Operation mode */
158 		unsigned char cfw:1;	/* Cache fast write */
159 		unsigned char dfw:1;	/* DASD fast write */
160 	} __attribute__ ((packed)) attributes;
161 	__u16 blk_size;		/* Blocksize */
162 	__u16 fast_write_id;
163 	__u8 ga_additional;	/* Global Attributes Additional */
164 	__u8 ga_extended;	/* Global Attributes Extended	*/
165 	struct ch_t beg_ext;
166 	struct ch_t end_ext;
167 	unsigned long long ep_sys_time; /* Ext Parameter - System Time Stamp */
168 	__u8 ep_format;        /* Extended Parameter format byte       */
169 	__u8 ep_prio;          /* Extended Parameter priority I/O byte */
170 	__u8 ep_reserved1;     /* Extended Parameter Reserved	       */
171 	__u8 ep_rec_per_track; /* Number of records on a track	       */
172 	__u8 ep_reserved[4];   /* Extended Parameter Reserved	       */
173 } __attribute__ ((packed));
174 
175 struct LO_eckd_data {
176 	struct {
177 		unsigned char orientation:2;
178 		unsigned char operation:6;
179 	} __attribute__ ((packed)) operation;
180 	struct {
181 		unsigned char last_bytes_used:1;
182 		unsigned char reserved:6;
183 		unsigned char read_count_suffix:1;
184 	} __attribute__ ((packed)) auxiliary;
185 	__u8 unused;
186 	__u8 count;
187 	struct ch_t seek_addr;
188 	struct chr_t search_arg;
189 	__u8 sector;
190 	__u16 length;
191 } __attribute__ ((packed));
192 
193 struct LRE_eckd_data {
194 	struct {
195 		unsigned char orientation:2;
196 		unsigned char operation:6;
197 	} __attribute__ ((packed)) operation;
198 	struct {
199 		unsigned char length_valid:1;
200 		unsigned char length_scope:1;
201 		unsigned char imbedded_ccw_valid:1;
202 		unsigned char check_bytes:2;
203 		unsigned char imbedded_count_valid:1;
204 		unsigned char reserved:1;
205 		unsigned char read_count_suffix:1;
206 	} __attribute__ ((packed)) auxiliary;
207 	__u8 imbedded_ccw;
208 	__u8 count;
209 	struct ch_t seek_addr;
210 	struct chr_t search_arg;
211 	__u8 sector;
212 	__u16 length;
213 	__u8 imbedded_count;
214 	__u8 extended_operation;
215 	__u16 extended_parameter_length;
216 	__u8 extended_parameter[0];
217 } __attribute__ ((packed));
218 
219 /* Prefix data for format 0x00 and 0x01 */
220 struct PFX_eckd_data {
221 	unsigned char format;
222 	struct {
223 		unsigned char define_extent:1;
224 		unsigned char time_stamp:1;
225 		unsigned char verify_base:1;
226 		unsigned char hyper_pav:1;
227 		unsigned char reserved:4;
228 	} __attribute__ ((packed)) validity;
229 	__u8 base_address;
230 	__u8 aux;
231 	__u8 base_lss;
232 	__u8 reserved[7];
233 	struct DE_eckd_data define_extent;
234 	struct LRE_eckd_data locate_record;
235 } __attribute__ ((packed));
236 
237 struct dasd_eckd_characteristics {
238 	__u16 cu_type;
239 	struct {
240 		unsigned char support:2;
241 		unsigned char async:1;
242 		unsigned char reserved:1;
243 		unsigned char cache_info:1;
244 		unsigned char model:3;
245 	} __attribute__ ((packed)) cu_model;
246 	__u16 dev_type;
247 	__u8 dev_model;
248 	struct {
249 		unsigned char mult_burst:1;
250 		unsigned char RT_in_LR:1;
251 		unsigned char reserved1:1;
252 		unsigned char RD_IN_LR:1;
253 		unsigned char reserved2:4;
254 		unsigned char reserved3:8;
255 		unsigned char defect_wr:1;
256 		unsigned char XRC_supported:1;
257 		unsigned char reserved4:1;
258 		unsigned char striping:1;
259 		unsigned char reserved5:4;
260 		unsigned char cfw:1;
261 		unsigned char reserved6:2;
262 		unsigned char cache:1;
263 		unsigned char dual_copy:1;
264 		unsigned char dfw:1;
265 		unsigned char reset_alleg:1;
266 		unsigned char sense_down:1;
267 	} __attribute__ ((packed)) facilities;
268 	__u8 dev_class;
269 	__u8 unit_type;
270 	__u16 no_cyl;
271 	__u16 trk_per_cyl;
272 	__u8 sec_per_trk;
273 	__u8 byte_per_track[3];
274 	__u16 home_bytes;
275 	__u8 formula;
276 	union {
277 		struct {
278 			__u8 f1;
279 			__u16 f2;
280 			__u16 f3;
281 		} __attribute__ ((packed)) f_0x01;
282 		struct {
283 			__u8 f1;
284 			__u8 f2;
285 			__u8 f3;
286 			__u8 f4;
287 			__u8 f5;
288 		} __attribute__ ((packed)) f_0x02;
289 	} __attribute__ ((packed)) factors;
290 	__u16 first_alt_trk;
291 	__u16 no_alt_trk;
292 	__u16 first_dia_trk;
293 	__u16 no_dia_trk;
294 	__u16 first_sup_trk;
295 	__u16 no_sup_trk;
296 	__u8 MDR_ID;
297 	__u8 OBR_ID;
298 	__u8 director;
299 	__u8 rd_trk_set;
300 	__u16 max_rec_zero;
301 	__u8 reserved1;
302 	__u8 RWANY_in_LR;
303 	__u8 factor6;
304 	__u8 factor7;
305 	__u8 factor8;
306 	__u8 reserved2[3];
307 	__u8 reserved3[6];
308 	__u32 long_no_cyl;
309 } __attribute__ ((packed));
310 
311 /* elements of the configuration data */
312 struct dasd_ned {
313 	struct {
314 		__u8 identifier:2;
315 		__u8 token_id:1;
316 		__u8 sno_valid:1;
317 		__u8 subst_sno:1;
318 		__u8 recNED:1;
319 		__u8 emuNED:1;
320 		__u8 reserved:1;
321 	} __attribute__ ((packed)) flags;
322 	__u8 descriptor;
323 	__u8 dev_class;
324 	__u8 reserved;
325 	__u8 dev_type[6];
326 	__u8 dev_model[3];
327 	__u8 HDA_manufacturer[3];
328 	__u8 HDA_location[2];
329 	__u8 HDA_seqno[12];
330 	__u8 ID;
331 	__u8 unit_addr;
332 } __attribute__ ((packed));
333 
334 struct dasd_sneq {
335 	struct {
336 		__u8 identifier:2;
337 		__u8 reserved:6;
338 	} __attribute__ ((packed)) flags;
339 	__u8 res1;
340 	__u16 format;
341 	__u8 res2[4];		/* byte  4- 7 */
342 	__u8 sua_flags;		/* byte  8    */
343 	__u8 base_unit_addr;	/* byte  9    */
344 	__u8 res3[22];		/* byte 10-31 */
345 } __attribute__ ((packed));
346 
347 struct vd_sneq {
348 	struct {
349 		__u8 identifier:2;
350 		__u8 reserved:6;
351 	} __attribute__ ((packed)) flags;
352 	__u8 res1;
353 	__u16 format;
354 	__u8 res2[4];	/* byte  4- 7 */
355 	__u8 uit[16];	/* byte  8-23 */
356 	__u8 res3[8];	/* byte 24-31 */
357 } __attribute__ ((packed));
358 
359 struct dasd_gneq {
360 	struct {
361 		__u8 identifier:2;
362 		__u8 reserved:6;
363 	} __attribute__ ((packed)) flags;
364 	__u8 record_selector;
365 	__u8 reserved[4];
366 	struct {
367 		__u8 value:2;
368 		__u8 number:6;
369 	} __attribute__ ((packed)) timeout;
370 	__u8 reserved3;
371 	__u16 subsystemID;
372 	__u8 reserved2[22];
373 } __attribute__ ((packed));
374 
375 struct dasd_rssd_features {
376 	char feature[256];
377 } __attribute__((packed));
378 
379 struct dasd_rssd_messages {
380 	__u16 length;
381 	__u8 format;
382 	__u8 code;
383 	__u32 message_id;
384 	__u8 flags;
385 	char messages[4087];
386 } __packed;
387 
388 struct dasd_cuir_message {
389 	__u16 length;
390 	__u8 format;
391 	__u8 code;
392 	__u32 message_id;
393 	__u8 flags;
394 	__u8 neq_map[3];
395 	__u8 ned_map;
396 	__u8 record_selector;
397 } __packed;
398 
399 struct dasd_psf_cuir_response {
400 	__u8 order;
401 	__u8 flags;
402 	__u8 cc;
403 	__u8 chpid;
404 	__u16 device_nr;
405 	__u16 reserved;
406 	__u32 message_id;
407 	__u64 system_id;
408 	__u8 cssid;
409 	__u8 ssid;
410 } __packed;
411 
412 struct dasd_ckd_path_group_entry {
413 	__u8 status_flags;
414 	__u8 pgid[11];
415 	__u8 sysplex_name[8];
416 	__u32 timestamp;
417 	__u32 cylinder;
418 	__u8 reserved[4];
419 } __packed;
420 
421 struct dasd_ckd_host_information {
422 	__u8 access_flags;
423 	__u8 entry_size;
424 	__u16 entry_count;
425 	__u8 entry[16390];
426 } __packed;
427 
428 struct dasd_psf_query_host_access {
429 	__u8 access_flag;
430 	__u8 version;
431 	__u16 CKD_length;
432 	__u16 SCSI_length;
433 	__u8 unused[10];
434 	__u8 host_access_information[16394];
435 } __packed;
436 
437 /*
438  * Perform Subsystem Function - Prepare for Read Subsystem Data
439  */
440 struct dasd_psf_prssd_data {
441 	unsigned char order;
442 	unsigned char flags;
443 	unsigned char reserved1;
444 	unsigned char reserved2;
445 	unsigned char lss;
446 	unsigned char volume;
447 	unsigned char suborder;
448 	unsigned char varies[5];
449 } __attribute__ ((packed));
450 
451 /*
452  * Perform Subsystem Function - Set Subsystem Characteristics
453  */
454 struct dasd_psf_ssc_data {
455 	unsigned char order;
456 	unsigned char flags;
457 	unsigned char cu_type[4];
458 	unsigned char suborder;
459 	unsigned char reserved[59];
460 } __attribute__((packed));
461 
462 
463 /*
464  * some structures and definitions for alias handling
465  */
466 struct dasd_unit_address_configuration {
467 	struct {
468 		char ua_type;
469 		char base_ua;
470 	} unit[256];
471 } __attribute__((packed));
472 
473 
474 #define MAX_DEVICES_PER_LCU 256
475 
476 /* flags on the LCU  */
477 #define NEED_UAC_UPDATE  0x01
478 #define UPDATE_PENDING	0x02
479 
480 enum pavtype {NO_PAV, BASE_PAV, HYPER_PAV};
481 
482 
483 struct alias_root {
484 	struct list_head serverlist;
485 	spinlock_t lock;
486 };
487 
488 struct alias_server {
489 	struct list_head server;
490 	struct dasd_uid uid;
491 	struct list_head lculist;
492 };
493 
494 struct summary_unit_check_work_data {
495 	char reason;
496 	struct dasd_device *device;
497 	struct work_struct worker;
498 };
499 
500 struct read_uac_work_data {
501 	struct dasd_device *device;
502 	struct delayed_work dwork;
503 };
504 
505 struct alias_lcu {
506 	struct list_head lcu;
507 	struct dasd_uid uid;
508 	enum pavtype pav;
509 	char flags;
510 	spinlock_t lock;
511 	struct list_head grouplist;
512 	struct list_head active_devices;
513 	struct list_head inactive_devices;
514 	struct dasd_unit_address_configuration *uac;
515 	struct summary_unit_check_work_data suc_data;
516 	struct read_uac_work_data ruac_data;
517 	struct dasd_ccw_req *rsu_cqr;
518 	struct completion lcu_setup;
519 };
520 
521 struct alias_pav_group {
522 	struct list_head group;
523 	struct dasd_uid uid;
524 	struct alias_lcu *lcu;
525 	struct list_head baselist;
526 	struct list_head aliaslist;
527 	struct dasd_device *next;
528 };
529 
530 struct dasd_conf_data {
531 	struct dasd_ned neds[5];
532 	u8 reserved[64];
533 	struct dasd_gneq gneq;
534 } __packed;
535 
536 struct dasd_eckd_private {
537 	struct dasd_eckd_characteristics rdc_data;
538 	u8 *conf_data;
539 	int conf_len;
540 
541 	/* pointers to specific parts in the conf_data */
542 	struct dasd_ned *ned;
543 	struct dasd_sneq *sneq;
544 	struct vd_sneq *vdsneq;
545 	struct dasd_gneq *gneq;
546 
547 	struct eckd_count count_area[5];
548 	int init_cqr_status;
549 	int uses_cdl;
550 	struct attrib_data_t attrib;	/* e.g. cache operations */
551 	struct dasd_rssd_features features;
552 	u32 real_cyl;
553 
554 	/* alias managemnet */
555 	struct dasd_uid uid;
556 	struct alias_pav_group *pavgroup;
557 	struct alias_lcu *lcu;
558 	int count;
559 
560 	u32 fcx_max_data;
561 	char suc_reason;
562 };
563 
564 
565 
566 int dasd_alias_make_device_known_to_lcu(struct dasd_device *);
567 void dasd_alias_disconnect_device_from_lcu(struct dasd_device *);
568 int dasd_alias_add_device(struct dasd_device *);
569 int dasd_alias_remove_device(struct dasd_device *);
570 struct dasd_device *dasd_alias_get_start_dev(struct dasd_device *);
571 void dasd_alias_handle_summary_unit_check(struct work_struct *);
572 void dasd_eckd_reset_ccw_to_base_io(struct dasd_ccw_req *);
573 void dasd_alias_lcu_setup_complete(struct dasd_device *);
574 void dasd_alias_wait_for_lcu_setup(struct dasd_device *);
575 int dasd_alias_update_add_device(struct dasd_device *);
576 #endif				/* DASD_ECKD_H */
577