1
2
3
4
5
6
7
8
9#ifndef DASD_INT_H
10#define DASD_INT_H
11
12
13#define DASD_PER_MAJOR (1U << (MINORBITS - DASD_PARTN_BITS))
14#define DASD_PARTN_MASK ((1 << DASD_PARTN_BITS) - 1)
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39#define DASD_STATE_NEW 0
40#define DASD_STATE_KNOWN 1
41#define DASD_STATE_BASIC 2
42#define DASD_STATE_UNFMT 3
43#define DASD_STATE_READY 4
44#define DASD_STATE_ONLINE 5
45
46#include <linux/module.h>
47#include <linux/wait.h>
48#include <linux/blkdev.h>
49#include <linux/genhd.h>
50#include <linux/hdreg.h>
51#include <linux/interrupt.h>
52#include <linux/log2.h>
53#include <asm/ccwdev.h>
54#include <linux/workqueue.h>
55#include <asm/debug.h>
56#include <asm/dasd.h>
57#include <asm/idals.h>
58#include <linux/bitops.h>
59
60
61#define DASD_ECKD_MAGIC 0xC5C3D2C4
62#define DASD_DIAG_MAGIC 0xC4C9C1C7
63#define DASD_FBA_MAGIC 0xC6C2C140
64
65
66
67
68struct dasd_device;
69struct dasd_block;
70
71
72#define DASD_SENSE_BIT_0 0x80
73#define DASD_SENSE_BIT_1 0x40
74#define DASD_SENSE_BIT_2 0x20
75#define DASD_SENSE_BIT_3 0x10
76
77
78#define DASD_SIM_SENSE 0x0F
79#define DASD_SIM_MSG_TO_OP 0x03
80#define DASD_SIM_LOG 0x0C
81
82
83#define CDEV_NESTED_FIRST 1
84#define CDEV_NESTED_SECOND 2
85
86
87
88
89#define DBF_DEV_EVENT(d_level, d_device, d_str, d_data...) \
90do { \
91 debug_sprintf_event(d_device->debug_area, \
92 d_level, \
93 d_str "\n", \
94 d_data); \
95} while(0)
96
97#define DBF_DEV_EXC(d_level, d_device, d_str, d_data...) \
98do { \
99 debug_sprintf_exception(d_device->debug_area, \
100 d_level, \
101 d_str "\n", \
102 d_data); \
103} while(0)
104
105#define DBF_EVENT(d_level, d_str, d_data...)\
106do { \
107 debug_sprintf_event(dasd_debug_area, \
108 d_level,\
109 d_str "\n", \
110 d_data); \
111} while(0)
112
113#define DBF_EVENT_DEVID(d_level, d_cdev, d_str, d_data...) \
114do { \
115 struct ccw_dev_id __dev_id; \
116 ccw_device_get_id(d_cdev, &__dev_id); \
117 debug_sprintf_event(dasd_debug_area, \
118 d_level, \
119 "0.%x.%04x " d_str "\n", \
120 __dev_id.ssid, __dev_id.devno, d_data); \
121} while (0)
122
123#define DBF_EXC(d_level, d_str, d_data...)\
124do { \
125 debug_sprintf_exception(dasd_debug_area, \
126 d_level,\
127 d_str "\n", \
128 d_data); \
129} while(0)
130
131
132#define ERRORLENGTH 30
133
134
135#define DBF_EMERG 0
136#define DBF_ALERT 1
137#define DBF_CRIT 2
138#define DBF_ERR 3
139#define DBF_WARNING 4
140#define DBF_NOTICE 5
141#define DBF_INFO 6
142#define DBF_DEBUG 6
143
144
145#define DEV_MESSAGE(d_loglevel,d_device,d_string,d_args...)\
146do { \
147 printk(d_loglevel PRINTK_HEADER " %s: " d_string "\n", \
148 dev_name(&d_device->cdev->dev), d_args); \
149 DBF_DEV_EVENT(DBF_ALERT, d_device, d_string, d_args); \
150} while(0)
151
152#define MESSAGE(d_loglevel,d_string,d_args...)\
153do { \
154 printk(d_loglevel PRINTK_HEADER " " d_string "\n", d_args); \
155 DBF_EVENT(DBF_ALERT, d_string, d_args); \
156} while(0)
157
158
159#define DEV_MESSAGE_LOG(d_loglevel,d_device,d_string,d_args...)\
160do { \
161 printk(d_loglevel PRINTK_HEADER " %s: " d_string "\n", \
162 dev_name(&d_device->cdev->dev), d_args); \
163} while(0)
164
165#define MESSAGE_LOG(d_loglevel,d_string,d_args...)\
166do { \
167 printk(d_loglevel PRINTK_HEADER " " d_string "\n", d_args); \
168} while(0)
169
170
171#define BLOCKS_PER_PAGE(blksize) (PAGE_SIZE / blksize)
172
173struct dasd_ccw_req {
174 unsigned int magic;
175 struct list_head devlist;
176 struct list_head blocklist;
177
178
179 struct dasd_block *block;
180 struct dasd_device *memdev;
181 struct dasd_device *startdev;
182 struct dasd_device *basedev;
183 void *cpaddr;
184 unsigned char cpmode;
185 char status;
186 short retries;
187 unsigned long flags;
188
189
190 unsigned long starttime;
191 unsigned long expires;
192 char lpm;
193 void *data;
194
195
196 int intrc;
197 struct irb irb;
198 struct dasd_ccw_req *refers;
199 void *function;
200
201
202 unsigned long long buildclk;
203 unsigned long long startclk;
204 unsigned long long stopclk;
205 unsigned long long endclk;
206
207
208 void (*callback)(struct dasd_ccw_req *, void *data);
209 void *callback_data;
210};
211
212
213
214
215#define DASD_CQR_FILLED 0x00
216#define DASD_CQR_DONE 0x01
217#define DASD_CQR_NEED_ERP 0x02
218#define DASD_CQR_IN_ERP 0x03
219#define DASD_CQR_FAILED 0x04
220#define DASD_CQR_TERMINATED 0x05
221
222#define DASD_CQR_QUEUED 0x80
223#define DASD_CQR_IN_IO 0x81
224#define DASD_CQR_ERROR 0x82
225#define DASD_CQR_CLEAR_PENDING 0x83
226#define DASD_CQR_CLEARED 0x84
227#define DASD_CQR_SUCCESS 0x85
228
229
230#define DASD_EXPIRES 300
231#define DASD_EXPIRES_MAX 40000000
232
233
234#define DASD_CQR_FLAGS_USE_ERP 0
235#define DASD_CQR_FLAGS_FAILFAST 1
236#define DASD_CQR_VERIFY_PATH 2
237#define DASD_CQR_ALLOW_SLOCK 3
238
239
240
241
242
243
244#define DASD_CQR_SUPPRESS_NRF 4
245#define DASD_CQR_SUPPRESS_FP 5
246#define DASD_CQR_SUPPRESS_IL 6
247#define DASD_CQR_SUPPRESS_CR 7
248
249
250typedef struct dasd_ccw_req *(*dasd_erp_fn_t) (struct dasd_ccw_req *);
251
252
253
254
255
256
257#define DASD_CQR_MAX_CCW 255
258
259
260
261
262#define UA_NOT_CONFIGURED 0x00
263#define UA_BASE_DEVICE 0x01
264#define UA_BASE_PAV_ALIAS 0x02
265#define UA_HYPER_PAV_ALIAS 0x03
266
267struct dasd_uid {
268 __u8 type;
269 char vendor[4];
270 char serial[15];
271 __u16 ssid;
272 __u8 real_unit_addr;
273 __u8 base_unit_addr;
274 char vduit[33];
275};
276
277
278
279
280
281
282
283struct dasd_discipline {
284 struct module *owner;
285 char ebcname[8];
286 char name[8];
287 int max_blocks;
288
289 struct list_head list;
290
291
292
293
294
295
296
297
298 int (*check_device) (struct dasd_device *);
299 void (*uncheck_device) (struct dasd_device *);
300
301
302
303
304
305
306
307
308 int (*do_analysis) (struct dasd_block *);
309
310
311
312
313
314
315
316 int (*verify_path)(struct dasd_device *, __u8);
317
318
319
320
321
322 int (*basic_to_ready) (struct dasd_device *);
323 int (*online_to_ready) (struct dasd_device *);
324 int (*basic_to_known)(struct dasd_device *);
325
326
327
328
329
330
331
332
333
334
335 struct dasd_ccw_req *(*build_cp) (struct dasd_device *,
336 struct dasd_block *,
337 struct request *);
338 int (*start_IO) (struct dasd_ccw_req *);
339 int (*term_IO) (struct dasd_ccw_req *);
340 void (*handle_terminated_request) (struct dasd_ccw_req *);
341 int (*format_device) (struct dasd_device *,
342 struct format_data_t *, int);
343 int (*check_device_format)(struct dasd_device *,
344 struct format_check_t *, int);
345 int (*free_cp) (struct dasd_ccw_req *, struct request *);
346
347
348
349
350
351
352
353
354
355
356 dasd_erp_fn_t(*erp_action) (struct dasd_ccw_req *);
357 dasd_erp_fn_t(*erp_postaction) (struct dasd_ccw_req *);
358 void (*dump_sense) (struct dasd_device *, struct dasd_ccw_req *,
359 struct irb *);
360 void (*dump_sense_dbf) (struct dasd_device *, struct irb *, char *);
361 void (*check_for_device_change) (struct dasd_device *,
362 struct dasd_ccw_req *,
363 struct irb *);
364
365
366 int (*fill_geometry) (struct dasd_block *, struct hd_geometry *);
367 int (*fill_info) (struct dasd_device *, struct dasd_information2_t *);
368 int (*ioctl) (struct dasd_block *, unsigned int, void __user *);
369
370
371 int (*freeze) (struct dasd_device *);
372 int (*restore) (struct dasd_device *);
373
374
375 int (*reload) (struct dasd_device *);
376
377 int (*get_uid) (struct dasd_device *, struct dasd_uid *);
378 void (*kick_validate) (struct dasd_device *);
379 int (*check_attention)(struct dasd_device *, __u8);
380 int (*host_access_count)(struct dasd_device *);
381 int (*hosts_print)(struct dasd_device *, struct seq_file *);
382 void (*handle_hpf_error)(struct dasd_device *, struct irb *);
383 void (*disable_hpf)(struct dasd_device *);
384 int (*hpf_enabled)(struct dasd_device *);
385 void (*reset_path)(struct dasd_device *, __u8);
386};
387
388extern struct dasd_discipline *dasd_diag_discipline_pointer;
389
390
391
392
393
394
395
396
397#define DASD_EER_DISABLE 0
398#define DASD_EER_TRIGGER 1
399
400
401#define DASD_EER_FATALERROR 1
402#define DASD_EER_NOPATH 2
403#define DASD_EER_STATECHANGE 3
404#define DASD_EER_PPRCSUSPEND 4
405
406
407
408#define DASD_PATH_OPERATIONAL 1
409#define DASD_PATH_TBV 2
410#define DASD_PATH_PP 3
411#define DASD_PATH_NPP 4
412#define DASD_PATH_MISCABLED 5
413#define DASD_PATH_NOHPF 6
414#define DASD_PATH_CUIR 7
415#define DASD_PATH_IFCC 8
416
417#define DASD_THRHLD_MAX 4294967295U
418#define DASD_INTERVAL_MAX 4294967295U
419
420struct dasd_path {
421 unsigned long flags;
422 u8 cssid;
423 u8 ssid;
424 u8 chpid;
425 struct dasd_conf_data *conf_data;
426 atomic_t error_count;
427 unsigned long long errorclk;
428};
429
430
431struct dasd_profile_info {
432
433 unsigned int dasd_io_reqs;
434 unsigned int dasd_io_sects;
435 unsigned int dasd_io_secs[32];
436 unsigned int dasd_io_times[32];
437 unsigned int dasd_io_timps[32];
438 unsigned int dasd_io_time1[32];
439 unsigned int dasd_io_time2[32];
440 unsigned int dasd_io_time2ps[32];
441 unsigned int dasd_io_time3[32];
442 unsigned int dasd_io_nr_req[32];
443
444
445 struct timespec starttod;
446 unsigned int dasd_io_alias;
447 unsigned int dasd_io_tpm;
448 unsigned int dasd_read_reqs;
449 unsigned int dasd_read_sects;
450 unsigned int dasd_read_alias;
451 unsigned int dasd_read_tpm;
452 unsigned int dasd_read_secs[32];
453 unsigned int dasd_read_times[32];
454 unsigned int dasd_read_time1[32];
455 unsigned int dasd_read_time2[32];
456 unsigned int dasd_read_time3[32];
457 unsigned int dasd_read_nr_req[32];
458};
459
460struct dasd_profile {
461 struct dentry *dentry;
462 struct dasd_profile_info *data;
463 spinlock_t lock;
464};
465
466struct dasd_device {
467
468 struct dasd_block *block;
469
470 unsigned int devindex;
471 unsigned long flags;
472 unsigned short features;
473
474
475 struct dasd_ccw_req *eer_cqr;
476
477
478 struct dasd_discipline *discipline;
479 struct dasd_discipline *base_discipline;
480 void *private;
481 struct dasd_path path[8];
482 __u8 opm;
483
484
485 int state, target;
486 struct mutex state_mutex;
487 int stopped;
488
489
490 atomic_t ref_count;
491
492
493 struct list_head ccw_queue;
494 spinlock_t mem_lock;
495 void *ccw_mem;
496 void *erp_mem;
497 struct list_head ccw_chunks;
498 struct list_head erp_chunks;
499
500 atomic_t tasklet_scheduled;
501 struct tasklet_struct tasklet;
502 struct work_struct kick_work;
503 struct work_struct restore_device;
504 struct work_struct reload_device;
505 struct work_struct kick_validate;
506 struct work_struct requeue_requests;
507 struct timer_list timer;
508
509 debug_info_t *debug_area;
510
511 struct ccw_device *cdev;
512
513
514 struct list_head alias_list;
515
516
517 unsigned long default_expires;
518
519 unsigned long path_thrhld;
520 unsigned long path_interval;
521
522 struct dentry *debugfs_dentry;
523 struct dentry *hosts_dentry;
524 struct dasd_profile profile;
525};
526
527struct dasd_block {
528
529 struct gendisk *gdp;
530 struct request_queue *request_queue;
531 spinlock_t request_queue_lock;
532 struct block_device *bdev;
533 atomic_t open_count;
534
535 unsigned long long blocks;
536 unsigned int bp_block;
537 unsigned int s2b_shift;
538
539 struct dasd_device *base;
540 struct list_head ccw_queue;
541 spinlock_t queue_lock;
542
543 atomic_t tasklet_scheduled;
544 struct tasklet_struct tasklet;
545 struct timer_list timer;
546
547 struct dentry *debugfs_dentry;
548 struct dasd_profile profile;
549};
550
551struct dasd_attention_data {
552 struct dasd_device *device;
553 __u8 lpum;
554};
555
556
557#define DASD_STOPPED_NOT_ACC 1
558#define DASD_STOPPED_QUIESCE 2
559#define DASD_STOPPED_PENDING 4
560#define DASD_STOPPED_DC_WAIT 8
561#define DASD_STOPPED_SU 16
562#define DASD_STOPPED_PM 32
563#define DASD_UNRESUMED_PM 64
564
565
566#define DASD_FLAG_OFFLINE 3
567#define DASD_FLAG_EER_SNSS 4
568#define DASD_FLAG_EER_IN_USE 5
569#define DASD_FLAG_DEVICE_RO 6
570
571
572
573#define DASD_FLAG_IS_RESERVED 7
574#define DASD_FLAG_LOCK_STOLEN 8
575#define DASD_FLAG_SUSPENDED 9
576#define DASD_FLAG_SAFE_OFFLINE 10
577#define DASD_FLAG_SAFE_OFFLINE_RUNNING 11
578#define DASD_FLAG_PATH_VERIFY 12
579
580
581void dasd_put_device_wake(struct dasd_device *);
582
583
584
585
586static inline void
587dasd_get_device(struct dasd_device *device)
588{
589 atomic_inc(&device->ref_count);
590}
591
592static inline void
593dasd_put_device(struct dasd_device *device)
594{
595 if (atomic_dec_return(&device->ref_count) == 0)
596 dasd_put_device_wake(device);
597}
598
599
600
601
602
603struct dasd_mchunk
604{
605 struct list_head list;
606 unsigned long size;
607} __attribute__ ((aligned(8)));
608
609static inline void
610dasd_init_chunklist(struct list_head *chunk_list, void *mem,
611 unsigned long size)
612{
613 struct dasd_mchunk *chunk;
614
615 INIT_LIST_HEAD(chunk_list);
616 chunk = (struct dasd_mchunk *) mem;
617 chunk->size = size - sizeof(struct dasd_mchunk);
618 list_add(&chunk->list, chunk_list);
619}
620
621static inline void *
622dasd_alloc_chunk(struct list_head *chunk_list, unsigned long size)
623{
624 struct dasd_mchunk *chunk, *tmp;
625
626 size = (size + 7L) & -8L;
627 list_for_each_entry(chunk, chunk_list, list) {
628 if (chunk->size < size)
629 continue;
630 if (chunk->size > size + sizeof(struct dasd_mchunk)) {
631 char *endaddr = (char *) (chunk + 1) + chunk->size;
632 tmp = (struct dasd_mchunk *) (endaddr - size) - 1;
633 tmp->size = size;
634 chunk->size -= size + sizeof(struct dasd_mchunk);
635 chunk = tmp;
636 } else
637 list_del(&chunk->list);
638 return (void *) (chunk + 1);
639 }
640 return NULL;
641}
642
643static inline void
644dasd_free_chunk(struct list_head *chunk_list, void *mem)
645{
646 struct dasd_mchunk *chunk, *tmp;
647 struct list_head *p, *left;
648
649 chunk = (struct dasd_mchunk *)
650 ((char *) mem - sizeof(struct dasd_mchunk));
651
652 left = chunk_list;
653 list_for_each(p, chunk_list) {
654 if (list_entry(p, struct dasd_mchunk, list) > chunk)
655 break;
656 left = p;
657 }
658
659 if (left->next != chunk_list) {
660 tmp = list_entry(left->next, struct dasd_mchunk, list);
661 if ((char *) (chunk + 1) + chunk->size == (char *) tmp) {
662 list_del(&tmp->list);
663 chunk->size += tmp->size + sizeof(struct dasd_mchunk);
664 }
665 }
666
667 if (left != chunk_list) {
668 tmp = list_entry(left, struct dasd_mchunk, list);
669 if ((char *) (tmp + 1) + tmp->size == (char *) chunk) {
670 tmp->size += chunk->size + sizeof(struct dasd_mchunk);
671 return;
672 }
673 }
674 __list_add(&chunk->list, left, left->next);
675}
676
677
678
679
680static inline int
681dasd_check_blocksize(int bsize)
682{
683 if (bsize < 512 || bsize > 4096 || !is_power_of_2(bsize))
684 return -EMEDIUMTYPE;
685 return 0;
686}
687
688
689#define DASD_PROFILE_OFF 0
690#define DASD_PROFILE_ON 1
691#define DASD_PROFILE_GLOBAL_ONLY 2
692
693extern debug_info_t *dasd_debug_area;
694extern struct dasd_profile_info dasd_global_profile_data;
695extern unsigned int dasd_global_profile_level;
696extern const struct block_device_operations dasd_device_operations;
697
698extern struct kmem_cache *dasd_page_cache;
699
700struct dasd_ccw_req *
701dasd_kmalloc_request(int , int, int, struct dasd_device *);
702struct dasd_ccw_req *
703dasd_smalloc_request(int , int, int, struct dasd_device *);
704void dasd_kfree_request(struct dasd_ccw_req *, struct dasd_device *);
705void dasd_sfree_request(struct dasd_ccw_req *, struct dasd_device *);
706void dasd_wakeup_cb(struct dasd_ccw_req *, void *);
707
708static inline int
709dasd_kmalloc_set_cda(struct ccw1 *ccw, void *cda, struct dasd_device *device)
710{
711 return set_normalized_cda(ccw, cda);
712}
713
714struct dasd_device *dasd_alloc_device(void);
715void dasd_free_device(struct dasd_device *);
716
717struct dasd_block *dasd_alloc_block(void);
718void dasd_free_block(struct dasd_block *);
719
720void dasd_enable_device(struct dasd_device *);
721void dasd_set_target_state(struct dasd_device *, int);
722void dasd_kick_device(struct dasd_device *);
723void dasd_restore_device(struct dasd_device *);
724void dasd_reload_device(struct dasd_device *);
725void dasd_schedule_requeue(struct dasd_device *);
726
727void dasd_add_request_head(struct dasd_ccw_req *);
728void dasd_add_request_tail(struct dasd_ccw_req *);
729int dasd_start_IO(struct dasd_ccw_req *);
730int dasd_term_IO(struct dasd_ccw_req *);
731void dasd_schedule_device_bh(struct dasd_device *);
732void dasd_schedule_block_bh(struct dasd_block *);
733int dasd_sleep_on(struct dasd_ccw_req *);
734int dasd_sleep_on_queue(struct list_head *);
735int dasd_sleep_on_immediatly(struct dasd_ccw_req *);
736int dasd_sleep_on_interruptible(struct dasd_ccw_req *);
737void dasd_device_set_timer(struct dasd_device *, int);
738void dasd_device_clear_timer(struct dasd_device *);
739void dasd_block_set_timer(struct dasd_block *, int);
740void dasd_block_clear_timer(struct dasd_block *);
741int dasd_cancel_req(struct dasd_ccw_req *);
742int dasd_flush_device_queue(struct dasd_device *);
743int dasd_generic_probe (struct ccw_device *, struct dasd_discipline *);
744void dasd_generic_remove (struct ccw_device *cdev);
745int dasd_generic_set_online(struct ccw_device *, struct dasd_discipline *);
746int dasd_generic_set_offline (struct ccw_device *cdev);
747int dasd_generic_notify(struct ccw_device *, int);
748int dasd_generic_last_path_gone(struct dasd_device *);
749int dasd_generic_path_operational(struct dasd_device *);
750void dasd_generic_shutdown(struct ccw_device *);
751
752void dasd_generic_handle_state_change(struct dasd_device *);
753int dasd_generic_pm_freeze(struct ccw_device *);
754int dasd_generic_restore_device(struct ccw_device *);
755enum uc_todo dasd_generic_uc_handler(struct ccw_device *, struct irb *);
756void dasd_generic_path_event(struct ccw_device *, int *);
757int dasd_generic_verify_path(struct dasd_device *, __u8);
758
759int dasd_generic_read_dev_chars(struct dasd_device *, int, void *, int);
760char *dasd_get_sense(struct irb *);
761
762void dasd_device_set_stop_bits(struct dasd_device *, int);
763void dasd_device_remove_stop_bits(struct dasd_device *, int);
764
765int dasd_device_is_ro(struct dasd_device *);
766
767void dasd_profile_reset(struct dasd_profile *);
768int dasd_profile_on(struct dasd_profile *);
769void dasd_profile_off(struct dasd_profile *);
770void dasd_global_profile_reset(void);
771char *dasd_get_user_string(const char __user *, size_t);
772
773
774extern int dasd_max_devindex;
775extern int dasd_probeonly;
776extern int dasd_autodetect;
777extern int dasd_nopav;
778extern int dasd_nofcx;
779
780int dasd_devmap_init(void);
781void dasd_devmap_exit(void);
782
783struct dasd_device *dasd_create_device(struct ccw_device *);
784void dasd_delete_device(struct dasd_device *);
785
786int dasd_get_feature(struct ccw_device *, int);
787int dasd_set_feature(struct ccw_device *, int, int);
788
789int dasd_add_sysfs_files(struct ccw_device *);
790void dasd_remove_sysfs_files(struct ccw_device *);
791
792struct dasd_device *dasd_device_from_cdev(struct ccw_device *);
793struct dasd_device *dasd_device_from_cdev_locked(struct ccw_device *);
794struct dasd_device *dasd_device_from_devindex(int);
795
796void dasd_add_link_to_gendisk(struct gendisk *, struct dasd_device *);
797struct dasd_device *dasd_device_from_gendisk(struct gendisk *);
798
799int dasd_parse(void);
800int dasd_busid_known(const char *);
801
802
803int dasd_gendisk_init(void);
804void dasd_gendisk_exit(void);
805int dasd_gendisk_alloc(struct dasd_block *);
806void dasd_gendisk_free(struct dasd_block *);
807int dasd_scan_partitions(struct dasd_block *);
808void dasd_destroy_partitions(struct dasd_block *);
809
810
811int dasd_ioctl(struct block_device *, fmode_t, unsigned int, unsigned long);
812
813
814int dasd_proc_init(void);
815void dasd_proc_exit(void);
816
817
818struct dasd_ccw_req *dasd_default_erp_action(struct dasd_ccw_req *);
819struct dasd_ccw_req *dasd_default_erp_postaction(struct dasd_ccw_req *);
820struct dasd_ccw_req *dasd_alloc_erp_request(char *, int, int,
821 struct dasd_device *);
822void dasd_free_erp_request(struct dasd_ccw_req *, struct dasd_device *);
823void dasd_log_sense(struct dasd_ccw_req *, struct irb *);
824void dasd_log_sense_dbf(struct dasd_ccw_req *cqr, struct irb *irb);
825
826
827struct dasd_ccw_req *dasd_3990_erp_action(struct dasd_ccw_req *);
828void dasd_3990_erp_handle_sim(struct dasd_device *, char *);
829
830
831#ifdef CONFIG_DASD_EER
832int dasd_eer_init(void);
833void dasd_eer_exit(void);
834int dasd_eer_enable(struct dasd_device *);
835void dasd_eer_disable(struct dasd_device *);
836void dasd_eer_write(struct dasd_device *, struct dasd_ccw_req *cqr,
837 unsigned int id);
838void dasd_eer_snss(struct dasd_device *);
839
840static inline int dasd_eer_enabled(struct dasd_device *device)
841{
842 return device->eer_cqr != NULL;
843}
844#else
845#define dasd_eer_init() (0)
846#define dasd_eer_exit() do { } while (0)
847#define dasd_eer_enable(d) (0)
848#define dasd_eer_disable(d) do { } while (0)
849#define dasd_eer_write(d,c,i) do { } while (0)
850#define dasd_eer_snss(d) do { } while (0)
851#define dasd_eer_enabled(d) (0)
852#endif
853
854
855
856
857
858
859
860static inline int dasd_path_is_operational(struct dasd_device *device, int chp)
861{
862 return test_bit(DASD_PATH_OPERATIONAL, &device->path[chp].flags);
863}
864
865static inline int dasd_path_need_verify(struct dasd_device *device, int chp)
866{
867 return test_bit(DASD_PATH_TBV, &device->path[chp].flags);
868}
869
870static inline void dasd_path_verify(struct dasd_device *device, int chp)
871{
872 __set_bit(DASD_PATH_TBV, &device->path[chp].flags);
873}
874
875static inline void dasd_path_clear_verify(struct dasd_device *device, int chp)
876{
877 __clear_bit(DASD_PATH_TBV, &device->path[chp].flags);
878}
879
880static inline void dasd_path_clear_all_verify(struct dasd_device *device)
881{
882 int chp;
883
884 for (chp = 0; chp < 8; chp++)
885 dasd_path_clear_verify(device, chp);
886}
887
888static inline void dasd_path_operational(struct dasd_device *device, int chp)
889{
890 __set_bit(DASD_PATH_OPERATIONAL, &device->path[chp].flags);
891 device->opm |= (0x80 >> chp);
892}
893
894static inline void dasd_path_nonpreferred(struct dasd_device *device, int chp)
895{
896 __set_bit(DASD_PATH_NPP, &device->path[chp].flags);
897}
898
899static inline int dasd_path_is_nonpreferred(struct dasd_device *device, int chp)
900{
901 return test_bit(DASD_PATH_NPP, &device->path[chp].flags);
902}
903
904static inline void dasd_path_clear_nonpreferred(struct dasd_device *device,
905 int chp)
906{
907 __clear_bit(DASD_PATH_NPP, &device->path[chp].flags);
908}
909
910static inline void dasd_path_preferred(struct dasd_device *device, int chp)
911{
912 __set_bit(DASD_PATH_PP, &device->path[chp].flags);
913}
914
915static inline int dasd_path_is_preferred(struct dasd_device *device, int chp)
916{
917 return test_bit(DASD_PATH_PP, &device->path[chp].flags);
918}
919
920static inline void dasd_path_clear_preferred(struct dasd_device *device,
921 int chp)
922{
923 __clear_bit(DASD_PATH_PP, &device->path[chp].flags);
924}
925
926static inline void dasd_path_clear_oper(struct dasd_device *device, int chp)
927{
928 __clear_bit(DASD_PATH_OPERATIONAL, &device->path[chp].flags);
929 device->opm &= ~(0x80 >> chp);
930}
931
932static inline void dasd_path_clear_cable(struct dasd_device *device, int chp)
933{
934 __clear_bit(DASD_PATH_MISCABLED, &device->path[chp].flags);
935}
936
937static inline void dasd_path_cuir(struct dasd_device *device, int chp)
938{
939 __set_bit(DASD_PATH_CUIR, &device->path[chp].flags);
940}
941
942static inline int dasd_path_is_cuir(struct dasd_device *device, int chp)
943{
944 return test_bit(DASD_PATH_CUIR, &device->path[chp].flags);
945}
946
947static inline void dasd_path_clear_cuir(struct dasd_device *device, int chp)
948{
949 __clear_bit(DASD_PATH_CUIR, &device->path[chp].flags);
950}
951
952static inline void dasd_path_ifcc(struct dasd_device *device, int chp)
953{
954 set_bit(DASD_PATH_IFCC, &device->path[chp].flags);
955}
956
957static inline int dasd_path_is_ifcc(struct dasd_device *device, int chp)
958{
959 return test_bit(DASD_PATH_IFCC, &device->path[chp].flags);
960}
961
962static inline void dasd_path_clear_ifcc(struct dasd_device *device, int chp)
963{
964 clear_bit(DASD_PATH_IFCC, &device->path[chp].flags);
965}
966
967static inline void dasd_path_clear_nohpf(struct dasd_device *device, int chp)
968{
969 __clear_bit(DASD_PATH_NOHPF, &device->path[chp].flags);
970}
971
972static inline void dasd_path_miscabled(struct dasd_device *device, int chp)
973{
974 __set_bit(DASD_PATH_MISCABLED, &device->path[chp].flags);
975}
976
977static inline int dasd_path_is_miscabled(struct dasd_device *device, int chp)
978{
979 return test_bit(DASD_PATH_MISCABLED, &device->path[chp].flags);
980}
981
982static inline void dasd_path_nohpf(struct dasd_device *device, int chp)
983{
984 __set_bit(DASD_PATH_NOHPF, &device->path[chp].flags);
985}
986
987static inline int dasd_path_is_nohpf(struct dasd_device *device, int chp)
988{
989 return test_bit(DASD_PATH_NOHPF, &device->path[chp].flags);
990}
991
992
993
994
995
996
997static inline __u8 dasd_path_get_opm(struct dasd_device *device)
998{
999 return device->opm;
1000}
1001
1002static inline __u8 dasd_path_get_tbvpm(struct dasd_device *device)
1003{
1004 int chp;
1005 __u8 tbvpm = 0x00;
1006
1007 for (chp = 0; chp < 8; chp++)
1008 if (dasd_path_need_verify(device, chp))
1009 tbvpm |= 0x80 >> chp;
1010 return tbvpm;
1011}
1012
1013static inline __u8 dasd_path_get_nppm(struct dasd_device *device)
1014{
1015 int chp;
1016 __u8 npm = 0x00;
1017
1018 for (chp = 0; chp < 8; chp++) {
1019 if (dasd_path_is_nonpreferred(device, chp))
1020 npm |= 0x80 >> chp;
1021 }
1022 return npm;
1023}
1024
1025static inline __u8 dasd_path_get_ppm(struct dasd_device *device)
1026{
1027 int chp;
1028 __u8 ppm = 0x00;
1029
1030 for (chp = 0; chp < 8; chp++)
1031 if (dasd_path_is_preferred(device, chp))
1032 ppm |= 0x80 >> chp;
1033 return ppm;
1034}
1035
1036static inline __u8 dasd_path_get_cablepm(struct dasd_device *device)
1037{
1038 int chp;
1039 __u8 cablepm = 0x00;
1040
1041 for (chp = 0; chp < 8; chp++)
1042 if (dasd_path_is_miscabled(device, chp))
1043 cablepm |= 0x80 >> chp;
1044 return cablepm;
1045}
1046
1047static inline __u8 dasd_path_get_cuirpm(struct dasd_device *device)
1048{
1049 int chp;
1050 __u8 cuirpm = 0x00;
1051
1052 for (chp = 0; chp < 8; chp++)
1053 if (dasd_path_is_cuir(device, chp))
1054 cuirpm |= 0x80 >> chp;
1055 return cuirpm;
1056}
1057
1058static inline __u8 dasd_path_get_ifccpm(struct dasd_device *device)
1059{
1060 int chp;
1061 __u8 ifccpm = 0x00;
1062
1063 for (chp = 0; chp < 8; chp++)
1064 if (dasd_path_is_ifcc(device, chp))
1065 ifccpm |= 0x80 >> chp;
1066 return ifccpm;
1067}
1068
1069static inline __u8 dasd_path_get_hpfpm(struct dasd_device *device)
1070{
1071 int chp;
1072 __u8 hpfpm = 0x00;
1073
1074 for (chp = 0; chp < 8; chp++)
1075 if (dasd_path_is_nohpf(device, chp))
1076 hpfpm |= 0x80 >> chp;
1077 return hpfpm;
1078}
1079
1080
1081
1082
1083
1084static inline void dasd_path_add_tbvpm(struct dasd_device *device, __u8 pm)
1085{
1086 int chp;
1087
1088 for (chp = 0; chp < 8; chp++)
1089 if (pm & (0x80 >> chp))
1090 dasd_path_verify(device, chp);
1091}
1092
1093static inline __u8 dasd_path_get_notoperpm(struct dasd_device *device)
1094{
1095 int chp;
1096 __u8 nopm = 0x00;
1097
1098 for (chp = 0; chp < 8; chp++)
1099 if (dasd_path_is_nohpf(device, chp) ||
1100 dasd_path_is_ifcc(device, chp) ||
1101 dasd_path_is_cuir(device, chp) ||
1102 dasd_path_is_miscabled(device, chp))
1103 nopm |= 0x80 >> chp;
1104 return nopm;
1105}
1106
1107static inline void dasd_path_add_opm(struct dasd_device *device, __u8 pm)
1108{
1109 int chp;
1110
1111 for (chp = 0; chp < 8; chp++)
1112 if (pm & (0x80 >> chp)) {
1113 dasd_path_operational(device, chp);
1114
1115
1116
1117
1118 dasd_path_clear_nohpf(device, chp);
1119 dasd_path_clear_cuir(device, chp);
1120 dasd_path_clear_cable(device, chp);
1121 dasd_path_clear_ifcc(device, chp);
1122 }
1123}
1124
1125static inline void dasd_path_add_cablepm(struct dasd_device *device, __u8 pm)
1126{
1127 int chp;
1128
1129 for (chp = 0; chp < 8; chp++)
1130 if (pm & (0x80 >> chp))
1131 dasd_path_miscabled(device, chp);
1132}
1133
1134static inline void dasd_path_add_cuirpm(struct dasd_device *device, __u8 pm)
1135{
1136 int chp;
1137
1138 for (chp = 0; chp < 8; chp++)
1139 if (pm & (0x80 >> chp))
1140 dasd_path_cuir(device, chp);
1141}
1142
1143static inline void dasd_path_add_ifccpm(struct dasd_device *device, __u8 pm)
1144{
1145 int chp;
1146
1147 for (chp = 0; chp < 8; chp++)
1148 if (pm & (0x80 >> chp))
1149 dasd_path_ifcc(device, chp);
1150}
1151
1152static inline void dasd_path_add_nppm(struct dasd_device *device, __u8 pm)
1153{
1154 int chp;
1155
1156 for (chp = 0; chp < 8; chp++)
1157 if (pm & (0x80 >> chp))
1158 dasd_path_nonpreferred(device, chp);
1159}
1160
1161static inline void dasd_path_add_nohpfpm(struct dasd_device *device, __u8 pm)
1162{
1163 int chp;
1164
1165 for (chp = 0; chp < 8; chp++)
1166 if (pm & (0x80 >> chp))
1167 dasd_path_nohpf(device, chp);
1168}
1169
1170static inline void dasd_path_add_ppm(struct dasd_device *device, __u8 pm)
1171{
1172 int chp;
1173
1174 for (chp = 0; chp < 8; chp++)
1175 if (pm & (0x80 >> chp))
1176 dasd_path_preferred(device, chp);
1177}
1178
1179
1180
1181
1182
1183static inline void dasd_path_set_tbvpm(struct dasd_device *device, __u8 pm)
1184{
1185 int chp;
1186
1187 for (chp = 0; chp < 8; chp++)
1188 if (pm & (0x80 >> chp))
1189 dasd_path_verify(device, chp);
1190 else
1191 dasd_path_clear_verify(device, chp);
1192}
1193
1194static inline void dasd_path_set_opm(struct dasd_device *device, __u8 pm)
1195{
1196 int chp;
1197
1198 for (chp = 0; chp < 8; chp++) {
1199 dasd_path_clear_oper(device, chp);
1200 if (pm & (0x80 >> chp)) {
1201 dasd_path_operational(device, chp);
1202
1203
1204
1205
1206 dasd_path_clear_nohpf(device, chp);
1207 dasd_path_clear_cuir(device, chp);
1208 dasd_path_clear_cable(device, chp);
1209 dasd_path_clear_ifcc(device, chp);
1210 }
1211 }
1212}
1213
1214
1215
1216
1217
1218static inline void dasd_path_remove_opm(struct dasd_device *device, __u8 pm)
1219{
1220 int chp;
1221
1222 for (chp = 0; chp < 8; chp++) {
1223 if (pm & (0x80 >> chp))
1224 dasd_path_clear_oper(device, chp);
1225 }
1226}
1227
1228
1229
1230
1231
1232static inline void dasd_path_available(struct dasd_device *device, int chp)
1233{
1234 dasd_path_clear_oper(device, chp);
1235 dasd_path_verify(device, chp);
1236}
1237
1238static inline void dasd_path_notoper(struct dasd_device *device, int chp)
1239{
1240 dasd_path_clear_oper(device, chp);
1241 dasd_path_clear_preferred(device, chp);
1242 dasd_path_clear_nonpreferred(device, chp);
1243}
1244
1245
1246
1247
1248static inline void dasd_path_no_path(struct dasd_device *device)
1249{
1250 int chp;
1251
1252 for (chp = 0; chp < 8; chp++)
1253 dasd_path_notoper(device, chp);
1254
1255 dasd_path_clear_all_verify(device);
1256}
1257
1258
1259
1260#endif
1261