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