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