device.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #ifndef S390_DEVICE_H
  2. #define S390_DEVICE_H
  3. #include <asm/ccwdev.h>
  4. #include <linux/atomic.h>
  5. #include <linux/wait.h>
  6. #include <linux/notifier.h>
  7. #include <linux/kernel_stat.h>
  8. #include "io_sch.h"
  9. /*
  10. * states of the device statemachine
  11. */
  12. enum dev_state {
  13. DEV_STATE_NOT_OPER,
  14. DEV_STATE_SENSE_PGID,
  15. DEV_STATE_SENSE_ID,
  16. DEV_STATE_OFFLINE,
  17. DEV_STATE_VERIFY,
  18. DEV_STATE_ONLINE,
  19. DEV_STATE_W4SENSE,
  20. DEV_STATE_DISBAND_PGID,
  21. DEV_STATE_BOXED,
  22. /* states to wait for i/o completion before doing something */
  23. DEV_STATE_TIMEOUT_KILL,
  24. DEV_STATE_QUIESCE,
  25. /* special states for devices gone not operational */
  26. DEV_STATE_DISCONNECTED,
  27. DEV_STATE_DISCONNECTED_SENSE_ID,
  28. DEV_STATE_CMFCHANGE,
  29. DEV_STATE_CMFUPDATE,
  30. DEV_STATE_STEAL_LOCK,
  31. /* last element! */
  32. NR_DEV_STATES
  33. };
  34. /*
  35. * asynchronous events of the device statemachine
  36. */
  37. enum dev_event {
  38. DEV_EVENT_NOTOPER,
  39. DEV_EVENT_INTERRUPT,
  40. DEV_EVENT_TIMEOUT,
  41. DEV_EVENT_VERIFY,
  42. /* last element! */
  43. NR_DEV_EVENTS
  44. };
  45. struct ccw_device;
  46. /*
  47. * action called through jumptable
  48. */
  49. typedef void (fsm_func_t)(struct ccw_device *, enum dev_event);
  50. extern fsm_func_t *dev_jumptable[NR_DEV_STATES][NR_DEV_EVENTS];
  51. static inline void
  52. dev_fsm_event(struct ccw_device *cdev, enum dev_event dev_event)
  53. {
  54. int state = cdev->private->state;
  55. if (dev_event == DEV_EVENT_INTERRUPT) {
  56. if (state == DEV_STATE_ONLINE)
  57. kstat_cpu(smp_processor_id()).
  58. irqs[cdev->private->int_class]++;
  59. else if (state != DEV_STATE_CMFCHANGE &&
  60. state != DEV_STATE_CMFUPDATE)
  61. kstat_cpu(smp_processor_id()).irqs[IOINT_CIO]++;
  62. }
  63. dev_jumptable[state][dev_event](cdev, dev_event);
  64. }
  65. /*
  66. * Delivers 1 if the device state is final.
  67. */
  68. static inline int
  69. dev_fsm_final_state(struct ccw_device *cdev)
  70. {
  71. return (cdev->private->state == DEV_STATE_NOT_OPER ||
  72. cdev->private->state == DEV_STATE_OFFLINE ||
  73. cdev->private->state == DEV_STATE_ONLINE ||
  74. cdev->private->state == DEV_STATE_BOXED);
  75. }
  76. extern wait_queue_head_t ccw_device_init_wq;
  77. extern atomic_t ccw_device_init_count;
  78. int __init io_subchannel_init(void);
  79. void io_subchannel_recog_done(struct ccw_device *cdev);
  80. void io_subchannel_init_config(struct subchannel *sch);
  81. int ccw_device_cancel_halt_clear(struct ccw_device *);
  82. int ccw_device_is_orphan(struct ccw_device *);
  83. void ccw_device_recognition(struct ccw_device *);
  84. int ccw_device_online(struct ccw_device *);
  85. int ccw_device_offline(struct ccw_device *);
  86. void ccw_device_update_sense_data(struct ccw_device *);
  87. int ccw_device_test_sense_data(struct ccw_device *);
  88. void ccw_device_schedule_sch_unregister(struct ccw_device *);
  89. int ccw_purge_blacklisted(void);
  90. void ccw_device_sched_todo(struct ccw_device *cdev, enum cdev_todo todo);
  91. /* Function prototypes for device status and basic sense stuff. */
  92. void ccw_device_accumulate_irb(struct ccw_device *, struct irb *);
  93. void ccw_device_accumulate_basic_sense(struct ccw_device *, struct irb *);
  94. int ccw_device_accumulate_and_sense(struct ccw_device *, struct irb *);
  95. int ccw_device_do_sense(struct ccw_device *, struct irb *);
  96. /* Function prototype for internal request handling. */
  97. int lpm_adjust(int lpm, int mask);
  98. void ccw_request_start(struct ccw_device *);
  99. int ccw_request_cancel(struct ccw_device *cdev);
  100. void ccw_request_handler(struct ccw_device *cdev);
  101. void ccw_request_timeout(struct ccw_device *cdev);
  102. void ccw_request_notoper(struct ccw_device *cdev);
  103. /* Function prototypes for sense id stuff. */
  104. void ccw_device_sense_id_start(struct ccw_device *);
  105. void ccw_device_sense_id_done(struct ccw_device *, int);
  106. /* Function prototypes for path grouping stuff. */
  107. void ccw_device_verify_start(struct ccw_device *);
  108. void ccw_device_verify_done(struct ccw_device *, int);
  109. void ccw_device_disband_start(struct ccw_device *);
  110. void ccw_device_disband_done(struct ccw_device *, int);
  111. void ccw_device_stlck_start(struct ccw_device *, void *, void *, void *);
  112. void ccw_device_stlck_done(struct ccw_device *, void *, int);
  113. int ccw_device_call_handler(struct ccw_device *);
  114. int ccw_device_stlck(struct ccw_device *);
  115. /* Helper function for machine check handling. */
  116. void ccw_device_trigger_reprobe(struct ccw_device *);
  117. void ccw_device_kill_io(struct ccw_device *);
  118. int ccw_device_notify(struct ccw_device *, int);
  119. void ccw_device_set_disconnected(struct ccw_device *cdev);
  120. void ccw_device_set_notoper(struct ccw_device *cdev);
  121. /* qdio needs this. */
  122. void ccw_device_set_timeout(struct ccw_device *, int);
  123. extern struct subchannel_id ccw_device_get_subchannel_id(struct ccw_device *);
  124. /* Channel measurement facility related */
  125. void retry_set_schib(struct ccw_device *cdev);
  126. void cmf_retry_copy_block(struct ccw_device *);
  127. int cmf_reenable(struct ccw_device *);
  128. int ccw_set_cmf(struct ccw_device *cdev, int enable);
  129. extern struct device_attribute dev_attr_cmb_enable;
  130. #endif