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