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