device.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #ifndef S390_DEVICE_H
  2. #define S390_DEVICE_H
  3. #include <asm/ccwdev.h>
  4. #include <asm/atomic.h>
  5. #include <linux/wait.h>
  6. #include "io_sch.h"
  7. /*
  8. * states of the device statemachine
  9. */
  10. enum dev_state {
  11. DEV_STATE_NOT_OPER,
  12. DEV_STATE_SENSE_PGID,
  13. DEV_STATE_SENSE_ID,
  14. DEV_STATE_OFFLINE,
  15. DEV_STATE_VERIFY,
  16. DEV_STATE_ONLINE,
  17. DEV_STATE_W4SENSE,
  18. DEV_STATE_DISBAND_PGID,
  19. DEV_STATE_BOXED,
  20. /* states to wait for i/o completion before doing something */
  21. DEV_STATE_CLEAR_VERIFY,
  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. /* last element! */
  30. NR_DEV_STATES
  31. };
  32. /*
  33. * asynchronous events of the device statemachine
  34. */
  35. enum dev_event {
  36. DEV_EVENT_NOTOPER,
  37. DEV_EVENT_INTERRUPT,
  38. DEV_EVENT_TIMEOUT,
  39. DEV_EVENT_VERIFY,
  40. /* last element! */
  41. NR_DEV_EVENTS
  42. };
  43. struct ccw_device;
  44. /*
  45. * action called through jumptable
  46. */
  47. typedef void (fsm_func_t)(struct ccw_device *, enum dev_event);
  48. extern fsm_func_t *dev_jumptable[NR_DEV_STATES][NR_DEV_EVENTS];
  49. static inline void
  50. dev_fsm_event(struct ccw_device *cdev, enum dev_event dev_event)
  51. {
  52. dev_jumptable[cdev->private->state][dev_event](cdev, dev_event);
  53. }
  54. /*
  55. * Delivers 1 if the device state is final.
  56. */
  57. static inline int
  58. dev_fsm_final_state(struct ccw_device *cdev)
  59. {
  60. return (cdev->private->state == DEV_STATE_NOT_OPER ||
  61. cdev->private->state == DEV_STATE_OFFLINE ||
  62. cdev->private->state == DEV_STATE_ONLINE ||
  63. cdev->private->state == DEV_STATE_BOXED);
  64. }
  65. extern struct workqueue_struct *ccw_device_work;
  66. extern wait_queue_head_t ccw_device_init_wq;
  67. extern atomic_t ccw_device_init_count;
  68. void io_subchannel_recog_done(struct ccw_device *cdev);
  69. int ccw_device_cancel_halt_clear(struct ccw_device *);
  70. void ccw_device_do_unreg_rereg(struct work_struct *);
  71. void ccw_device_move_to_orphanage(struct work_struct *);
  72. int ccw_device_is_orphan(struct ccw_device *);
  73. int ccw_device_recognition(struct ccw_device *);
  74. int ccw_device_online(struct ccw_device *);
  75. int ccw_device_offline(struct ccw_device *);
  76. int ccw_purge_blacklisted(void);
  77. /* Function prototypes for device status and basic sense stuff. */
  78. void ccw_device_accumulate_irb(struct ccw_device *, struct irb *);
  79. void ccw_device_accumulate_basic_sense(struct ccw_device *, struct irb *);
  80. int ccw_device_accumulate_and_sense(struct ccw_device *, struct irb *);
  81. int ccw_device_do_sense(struct ccw_device *, struct irb *);
  82. /* Function prototypes for sense id stuff. */
  83. void ccw_device_sense_id_start(struct ccw_device *);
  84. void ccw_device_sense_id_irq(struct ccw_device *, enum dev_event);
  85. void ccw_device_sense_id_done(struct ccw_device *, int);
  86. /* Function prototypes for path grouping stuff. */
  87. void ccw_device_sense_pgid_start(struct ccw_device *);
  88. void ccw_device_sense_pgid_irq(struct ccw_device *, enum dev_event);
  89. void ccw_device_sense_pgid_done(struct ccw_device *, int);
  90. void ccw_device_verify_start(struct ccw_device *);
  91. void ccw_device_verify_irq(struct ccw_device *, enum dev_event);
  92. void ccw_device_verify_done(struct ccw_device *, int);
  93. void ccw_device_disband_start(struct ccw_device *);
  94. void ccw_device_disband_irq(struct ccw_device *, enum dev_event);
  95. void ccw_device_disband_done(struct ccw_device *, int);
  96. int ccw_device_call_handler(struct ccw_device *);
  97. int ccw_device_stlck(struct ccw_device *);
  98. /* Helper function for machine check handling. */
  99. void ccw_device_trigger_reprobe(struct ccw_device *);
  100. void ccw_device_kill_io(struct ccw_device *);
  101. int ccw_device_notify(struct ccw_device *, int);
  102. void ccw_device_set_notoper(struct ccw_device *cdev);
  103. /* qdio needs this. */
  104. void ccw_device_set_timeout(struct ccw_device *, int);
  105. extern struct subchannel_id ccw_device_get_subchannel_id(struct ccw_device *);
  106. extern struct bus_type ccw_bus_type;
  107. /* Channel measurement facility related */
  108. void retry_set_schib(struct ccw_device *cdev);
  109. void cmf_retry_copy_block(struct ccw_device *);
  110. int cmf_reenable(struct ccw_device *);
  111. extern struct device_attribute dev_attr_cmb_enable;
  112. #endif