blob: ddab7df36e25dddd0b471f1a71525a7282e975e5 [file] [log] [blame]
Horst Hummel138c0142006-06-29 14:58:12 +02001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
Horst Hummel138c0142006-06-29 14:58:12 +02003 * Horst Hummel <Horst.Hummel@de.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * Bugreports.to..: <Linux390@de.ibm.com>
Heiko Carstensa53c8fa2012-07-20 11:15:04 +02005 * Copyright IBM Corp. 1999, 2000
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 */
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
Stefan Weinhuber196339f2010-10-29 16:50:43 +020029#define DASD_ECKD_CCW_SNID 0x34
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#define DASD_ECKD_CCW_RSSD 0x3e
31#define DASD_ECKD_CCW_LOCATE_RECORD 0x47
Stefan Weinhuber20c64462006-03-24 03:15:25 -080032#define DASD_ECKD_CCW_SNSS 0x54
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#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
Stefan Haberlande4dbb0f2011-01-05 12:48:06 +010039#define DASD_ECKD_CCW_WRITE_FULL_TRACK 0x95
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#define DASD_ECKD_CCW_READ_CKD_MT 0x9e
41#define DASD_ECKD_CCW_WRITE_CKD_MT 0x9d
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +010042#define DASD_ECKD_CCW_WRITE_TRACK_DATA 0xA5
43#define DASD_ECKD_CCW_READ_TRACK_DATA 0xA6
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#define DASD_ECKD_CCW_RESERVE 0xB4
Stefan Haberlande4dbb0f2011-01-05 12:48:06 +010045#define DASD_ECKD_CCW_READ_TRACK 0xDE
Stefan Weinhuber8e09f212008-01-26 14:11:23 +010046#define DASD_ECKD_CCW_PFX 0xE7
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +010047#define DASD_ECKD_CCW_PFX_READ 0xEA
Stefan Weinhuber8e09f212008-01-26 14:11:23 +010048#define DASD_ECKD_CCW_RSCK 0xF9
Stefan Weinhubera4d26c62011-01-05 12:48:03 +010049#define DASD_ECKD_CCW_RCD 0xFA
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51/*
Horst Hummel40545572006-06-29 15:08:18 +020052 * Perform Subsystem Function / Sub-Orders
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 */
Stefan Haberland5db84402014-10-01 14:39:47 +020054#define PSF_ORDER_PRSSD 0x18
55#define PSF_ORDER_CUIR_RESPONSE 0x1A
56#define PSF_ORDER_SSC 0x1D
57
58/*
59 * CUIR response condition codes
60 */
61#define PSF_CUIR_INVALID 0x00
62#define PSF_CUIR_COMPLETED 0x01
63#define PSF_CUIR_NOT_SUPPORTED 0x02
64#define PSF_CUIR_ERROR_IN_REQ 0x03
65#define PSF_CUIR_DENIED 0x04
66#define PSF_CUIR_LAST_PATH 0x05
67#define PSF_CUIR_DEVICE_ONLINE 0x06
68#define PSF_CUIR_VARY_FAILURE 0x07
69#define PSF_CUIR_SOFTWARE_FAILURE 0x08
70#define PSF_CUIR_NOT_RECOGNIZED 0x09
71
72/*
73 * CUIR codes
74 */
75#define CUIR_QUIESCE 0x01
76#define CUIR_RESUME 0x02
77
78/*
79 * attention message definitions
80 */
81#define ATTENTION_LENGTH_CUIR 0x0e
82#define ATTENTION_FORMAT_CUIR 0x01
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
Stefan Weinhuberb44b0ab32009-03-26 15:23:47 +010084/*
85 * Size that is reportet for large volumes in the old 16-bit no_cyl field
86 */
87#define LV_COMPAT_CYL 0xFFFE
88
Stefan Weinhuberef19298b2011-01-05 12:48:02 +010089
90#define FCX_MAX_DATA_FACTOR 65536
Stefan Weinhubera4d26c62011-01-05 12:48:03 +010091#define DASD_ECKD_RCD_DATA_SIZE 256
Stefan Weinhuberef19298b2011-01-05 12:48:02 +010092
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094/*****************************************************************************
95 * SECTION: Type Definitions
96 ****************************************************************************/
97
98struct eckd_count {
99 __u16 cyl;
100 __u16 head;
101 __u8 record;
102 __u8 kl;
103 __u16 dl;
104} __attribute__ ((packed));
105
106struct ch_t {
107 __u16 cyl;
108 __u16 head;
109} __attribute__ ((packed));
110
111struct chs_t {
112 __u16 cyl;
113 __u16 head;
114 __u32 sector;
115} __attribute__ ((packed));
116
117struct chr_t {
118 __u16 cyl;
119 __u16 head;
120 __u8 record;
121} __attribute__ ((packed));
122
123struct geom_t {
124 __u16 cyl;
125 __u16 head;
126 __u32 sector;
127} __attribute__ ((packed));
128
129struct eckd_home {
130 __u8 skip_control[14];
131 __u16 cell_number;
132 __u8 physical_addr[3];
133 __u8 flag;
134 struct ch_t track_addr;
135 __u8 reserved;
136 __u8 key_length;
137 __u8 reserved2[2];
138} __attribute__ ((packed));
139
140struct DE_eckd_data {
141 struct {
142 unsigned char perm:2; /* Permissions on this extent */
143 unsigned char reserved:1;
144 unsigned char seek:2; /* Seek control */
145 unsigned char auth:2; /* Access authorization */
146 unsigned char pci:1; /* PCI Fetch mode */
147 } __attribute__ ((packed)) mask;
148 struct {
149 unsigned char mode:2; /* Architecture mode */
150 unsigned char ckd:1; /* CKD Conversion */
151 unsigned char operation:3; /* Operation mode */
152 unsigned char cfw:1; /* Cache fast write */
153 unsigned char dfw:1; /* DASD fast write */
154 } __attribute__ ((packed)) attributes;
155 __u16 blk_size; /* Blocksize */
156 __u16 fast_write_id;
157 __u8 ga_additional; /* Global Attributes Additional */
158 __u8 ga_extended; /* Global Attributes Extended */
159 struct ch_t beg_ext;
160 struct ch_t end_ext;
161 unsigned long long ep_sys_time; /* Ext Parameter - System Time Stamp */
162 __u8 ep_format; /* Extended Parameter format byte */
163 __u8 ep_prio; /* Extended Parameter priority I/O byte */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +0100164 __u8 ep_reserved1; /* Extended Parameter Reserved */
165 __u8 ep_rec_per_track; /* Number of records on a track */
166 __u8 ep_reserved[4]; /* Extended Parameter Reserved */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167} __attribute__ ((packed));
168
169struct LO_eckd_data {
170 struct {
171 unsigned char orientation:2;
172 unsigned char operation:6;
173 } __attribute__ ((packed)) operation;
174 struct {
175 unsigned char last_bytes_used:1;
176 unsigned char reserved:6;
177 unsigned char read_count_suffix:1;
178 } __attribute__ ((packed)) auxiliary;
179 __u8 unused;
180 __u8 count;
181 struct ch_t seek_addr;
182 struct chr_t search_arg;
183 __u8 sector;
184 __u16 length;
185} __attribute__ ((packed));
186
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +0100187struct LRE_eckd_data {
188 struct {
189 unsigned char orientation:2;
190 unsigned char operation:6;
191 } __attribute__ ((packed)) operation;
192 struct {
193 unsigned char length_valid:1;
194 unsigned char length_scope:1;
195 unsigned char imbedded_ccw_valid:1;
196 unsigned char check_bytes:2;
197 unsigned char imbedded_count_valid:1;
198 unsigned char reserved:1;
199 unsigned char read_count_suffix:1;
200 } __attribute__ ((packed)) auxiliary;
201 __u8 imbedded_ccw;
202 __u8 count;
203 struct ch_t seek_addr;
204 struct chr_t search_arg;
205 __u8 sector;
206 __u16 length;
207 __u8 imbedded_count;
208 __u8 extended_operation;
209 __u16 extended_parameter_length;
210 __u8 extended_parameter[0];
211} __attribute__ ((packed));
212
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100213/* Prefix data for format 0x00 and 0x01 */
214struct PFX_eckd_data {
215 unsigned char format;
216 struct {
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +0100217 unsigned char define_extent:1;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100218 unsigned char time_stamp:1;
219 unsigned char verify_base:1;
220 unsigned char hyper_pav:1;
221 unsigned char reserved:4;
222 } __attribute__ ((packed)) validity;
223 __u8 base_address;
224 __u8 aux;
225 __u8 base_lss;
226 __u8 reserved[7];
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +0100227 struct DE_eckd_data define_extent;
228 struct LRE_eckd_data locate_record;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100229} __attribute__ ((packed));
230
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231struct dasd_eckd_characteristics {
232 __u16 cu_type;
233 struct {
234 unsigned char support:2;
235 unsigned char async:1;
236 unsigned char reserved:1;
237 unsigned char cache_info:1;
238 unsigned char model:3;
239 } __attribute__ ((packed)) cu_model;
240 __u16 dev_type;
241 __u8 dev_model;
242 struct {
243 unsigned char mult_burst:1;
244 unsigned char RT_in_LR:1;
245 unsigned char reserved1:1;
246 unsigned char RD_IN_LR:1;
247 unsigned char reserved2:4;
248 unsigned char reserved3:8;
249 unsigned char defect_wr:1;
Horst Hummel138c0142006-06-29 14:58:12 +0200250 unsigned char XRC_supported:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 unsigned char reserved4:1;
252 unsigned char striping:1;
253 unsigned char reserved5:4;
254 unsigned char cfw:1;
255 unsigned char reserved6:2;
256 unsigned char cache:1;
257 unsigned char dual_copy:1;
258 unsigned char dfw:1;
259 unsigned char reset_alleg:1;
260 unsigned char sense_down:1;
261 } __attribute__ ((packed)) facilities;
262 __u8 dev_class;
263 __u8 unit_type;
264 __u16 no_cyl;
265 __u16 trk_per_cyl;
266 __u8 sec_per_trk;
267 __u8 byte_per_track[3];
268 __u16 home_bytes;
269 __u8 formula;
270 union {
271 struct {
272 __u8 f1;
273 __u16 f2;
274 __u16 f3;
275 } __attribute__ ((packed)) f_0x01;
276 struct {
277 __u8 f1;
278 __u8 f2;
279 __u8 f3;
280 __u8 f4;
281 __u8 f5;
282 } __attribute__ ((packed)) f_0x02;
283 } __attribute__ ((packed)) factors;
284 __u16 first_alt_trk;
285 __u16 no_alt_trk;
286 __u16 first_dia_trk;
287 __u16 no_dia_trk;
288 __u16 first_sup_trk;
289 __u16 no_sup_trk;
290 __u8 MDR_ID;
291 __u8 OBR_ID;
292 __u8 director;
293 __u8 rd_trk_set;
294 __u16 max_rec_zero;
295 __u8 reserved1;
296 __u8 RWANY_in_LR;
297 __u8 factor6;
298 __u8 factor7;
299 __u8 factor8;
300 __u8 reserved2[3];
Stefan Weinhuberb44b0ab32009-03-26 15:23:47 +0100301 __u8 reserved3[6];
302 __u32 long_no_cyl;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303} __attribute__ ((packed));
304
Stefan Weinhuber4abb08c2008-08-01 16:39:09 +0200305/* elements of the configuration data */
306struct dasd_ned {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 struct {
Stefan Weinhuber4abb08c2008-08-01 16:39:09 +0200308 __u8 identifier:2;
309 __u8 token_id:1;
310 __u8 sno_valid:1;
311 __u8 subst_sno:1;
312 __u8 recNED:1;
313 __u8 emuNED:1;
314 __u8 reserved:1;
315 } __attribute__ ((packed)) flags;
316 __u8 descriptor;
317 __u8 dev_class;
318 __u8 reserved;
319 __u8 dev_type[6];
320 __u8 dev_model[3];
321 __u8 HDA_manufacturer[3];
322 __u8 HDA_location[2];
323 __u8 HDA_seqno[12];
324 __u8 ID;
325 __u8 unit_addr;
326} __attribute__ ((packed));
327
328struct dasd_sneq {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 struct {
Stefan Weinhuber4abb08c2008-08-01 16:39:09 +0200330 __u8 identifier:2;
331 __u8 reserved:6;
332 } __attribute__ ((packed)) flags;
333 __u8 res1;
334 __u16 format;
335 __u8 res2[4]; /* byte 4- 7 */
336 __u8 sua_flags; /* byte 8 */
337 __u8 base_unit_addr; /* byte 9 */
338 __u8 res3[22]; /* byte 10-31 */
339} __attribute__ ((packed));
340
341struct vd_sneq {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 struct {
Stefan Weinhuber4abb08c2008-08-01 16:39:09 +0200343 __u8 identifier:2;
344 __u8 reserved:6;
345 } __attribute__ ((packed)) flags;
346 __u8 res1;
347 __u16 format;
348 __u8 res2[4]; /* byte 4- 7 */
349 __u8 uit[16]; /* byte 8-23 */
350 __u8 res3[8]; /* byte 24-31 */
351} __attribute__ ((packed));
352
353struct dasd_gneq {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 struct {
Stefan Weinhuber4abb08c2008-08-01 16:39:09 +0200355 __u8 identifier:2;
356 __u8 reserved:6;
357 } __attribute__ ((packed)) flags;
Stefan Haberland7c8faa82010-08-09 18:13:00 +0200358 __u8 reserved[5];
359 struct {
360 __u8 value:2;
361 __u8 number:6;
362 } __attribute__ ((packed)) timeout;
363 __u8 reserved3;
Stefan Weinhuber4abb08c2008-08-01 16:39:09 +0200364 __u16 subsystemID;
365 __u8 reserved2[22];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366} __attribute__ ((packed));
367
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100368struct dasd_rssd_features {
369 char feature[256];
370} __attribute__((packed));
371
Stefan Haberland5db84402014-10-01 14:39:47 +0200372struct dasd_rssd_messages {
373 __u16 length;
374 __u8 format;
375 __u8 code;
376 __u32 message_id;
377 __u8 flags;
378 char messages[4087];
379} __packed;
380
381struct dasd_cuir_message {
382 __u16 length;
383 __u8 format;
384 __u8 code;
385 __u32 message_id;
386 __u8 flags;
387 __u8 neq_map[3];
388 __u8 ned_map;
389 __u8 record_selector;
390} __packed;
391
392struct dasd_psf_cuir_response {
393 __u8 order;
394 __u8 flags;
395 __u8 cc;
396 __u8 chpid;
397 __u16 device_nr;
398 __u16 reserved;
399 __u32 message_id;
400 __u64 system_id;
401 __u8 cssid;
402 __u8 ssid;
403} __packed;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100404
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405/*
Horst Hummel138c0142006-06-29 14:58:12 +0200406 * Perform Subsystem Function - Prepare for Read Subsystem Data
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 */
408struct dasd_psf_prssd_data {
409 unsigned char order;
410 unsigned char flags;
411 unsigned char reserved[4];
412 unsigned char suborder;
Stefan Weinhuber49fd38b2008-08-21 19:46:38 +0200413 unsigned char varies[5];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414} __attribute__ ((packed));
415
Horst Hummel40545572006-06-29 15:08:18 +0200416/*
417 * Perform Subsystem Function - Set Subsystem Characteristics
418 */
419struct dasd_psf_ssc_data {
420 unsigned char order;
421 unsigned char flags;
422 unsigned char cu_type[4];
423 unsigned char suborder;
424 unsigned char reserved[59];
425} __attribute__((packed));
426
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100427
428/*
429 * some structures and definitions for alias handling
430 */
431struct dasd_unit_address_configuration {
432 struct {
433 char ua_type;
434 char base_ua;
435 } unit[256];
436} __attribute__((packed));
437
438
439#define MAX_DEVICES_PER_LCU 256
440
441/* flags on the LCU */
442#define NEED_UAC_UPDATE 0x01
443#define UPDATE_PENDING 0x02
444
445enum pavtype {NO_PAV, BASE_PAV, HYPER_PAV};
446
447
448struct alias_root {
449 struct list_head serverlist;
450 spinlock_t lock;
451};
452
453struct alias_server {
454 struct list_head server;
455 struct dasd_uid uid;
456 struct list_head lculist;
457};
458
459struct summary_unit_check_work_data {
460 char reason;
461 struct dasd_device *device;
462 struct work_struct worker;
463};
464
465struct read_uac_work_data {
466 struct dasd_device *device;
467 struct delayed_work dwork;
468};
469
470struct alias_lcu {
471 struct list_head lcu;
472 struct dasd_uid uid;
473 enum pavtype pav;
474 char flags;
475 spinlock_t lock;
476 struct list_head grouplist;
477 struct list_head active_devices;
478 struct list_head inactive_devices;
479 struct dasd_unit_address_configuration *uac;
480 struct summary_unit_check_work_data suc_data;
481 struct read_uac_work_data ruac_data;
482 struct dasd_ccw_req *rsu_cqr;
Stefan Weinhuberf4ac1d02009-12-07 12:51:53 +0100483 struct completion lcu_setup;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100484};
485
486struct alias_pav_group {
487 struct list_head group;
488 struct dasd_uid uid;
489 struct alias_lcu *lcu;
490 struct list_head baselist;
491 struct list_head aliaslist;
492 struct dasd_device *next;
493};
494
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100495struct dasd_eckd_private {
496 struct dasd_eckd_characteristics rdc_data;
Stefan Weinhuber4abb08c2008-08-01 16:39:09 +0200497 u8 *conf_data;
498 int conf_len;
499 /* pointers to specific parts in the conf_data */
500 struct dasd_ned *ned;
501 struct dasd_sneq *sneq;
502 struct vd_sneq *vdsneq;
503 struct dasd_gneq *gneq;
504
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100505 struct eckd_count count_area[5];
506 int init_cqr_status;
507 int uses_cdl;
508 struct attrib_data_t attrib; /* e.g. cache operations */
509 struct dasd_rssd_features features;
Stefan Weinhuberb44b0ab32009-03-26 15:23:47 +0100510 u32 real_cyl;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100511
512 /* alias managemnet */
513 struct dasd_uid uid;
514 struct alias_pav_group *pavgroup;
515 struct alias_lcu *lcu;
516 int count;
Stefan Weinhuberef19298b2011-01-05 12:48:02 +0100517
518 u32 fcx_max_data;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100519};
520
521
522
523int dasd_alias_make_device_known_to_lcu(struct dasd_device *);
524void dasd_alias_disconnect_device_from_lcu(struct dasd_device *);
525int dasd_alias_add_device(struct dasd_device *);
526int dasd_alias_remove_device(struct dasd_device *);
527struct dasd_device *dasd_alias_get_start_dev(struct dasd_device *);
528void dasd_alias_handle_summary_unit_check(struct dasd_device *, struct irb *);
529void dasd_eckd_reset_ccw_to_base_io(struct dasd_ccw_req *);
Stefan Weinhuberf4ac1d02009-12-07 12:51:53 +0100530void dasd_alias_lcu_setup_complete(struct dasd_device *);
531void dasd_alias_wait_for_lcu_setup(struct dasd_device *);
Stefan Haberland501183f2010-05-17 10:00:10 +0200532int dasd_alias_update_add_device(struct dasd_device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533#endif /* DASD_ECKD_H */