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