device.h 4.3 KB

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