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