device.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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_TIMEOUT_KILL,
  22. DEV_STATE_QUIESCE,
  23. /* special states for devices gone not operational */
  24. DEV_STATE_DISCONNECTED,
  25. DEV_STATE_DISCONNECTED_SENSE_ID,
  26. DEV_STATE_CMFCHANGE,
  27. DEV_STATE_CMFUPDATE,
  28. DEV_STATE_STEAL_LOCK,
  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. int __init io_subchannel_init(void);
  69. void io_subchannel_recog_done(struct ccw_device *cdev);
  70. void io_subchannel_init_config(struct subchannel *sch);
  71. int ccw_device_cancel_halt_clear(struct ccw_device *);
  72. int ccw_device_is_orphan(struct ccw_device *);
  73. void ccw_device_recognition(struct ccw_device *);
  74. int ccw_device_online(struct ccw_device *);
  75. int ccw_device_offline(struct ccw_device *);
  76. void ccw_device_update_sense_data(struct ccw_device *);
  77. int ccw_device_test_sense_data(struct ccw_device *);
  78. void ccw_device_schedule_sch_unregister(struct ccw_device *);
  79. int ccw_purge_blacklisted(void);
  80. void ccw_device_sched_todo(struct ccw_device *cdev, enum cdev_todo todo);
  81. /* Function prototypes for device status and basic sense stuff. */
  82. void ccw_device_accumulate_irb(struct ccw_device *, struct irb *);
  83. void ccw_device_accumulate_basic_sense(struct ccw_device *, struct irb *);
  84. int ccw_device_accumulate_and_sense(struct ccw_device *, struct irb *);
  85. int ccw_device_do_sense(struct ccw_device *, struct irb *);
  86. /* Function prototype for internal request handling. */
  87. int lpm_adjust(int lpm, int mask);
  88. void ccw_request_start(struct ccw_device *);
  89. int ccw_request_cancel(struct ccw_device *cdev);
  90. void ccw_request_handler(struct ccw_device *cdev);
  91. void ccw_request_timeout(struct ccw_device *cdev);
  92. void ccw_request_notoper(struct ccw_device *cdev);
  93. /* Function prototypes for sense id stuff. */
  94. void ccw_device_sense_id_start(struct ccw_device *);
  95. void ccw_device_sense_id_done(struct ccw_device *, int);
  96. /* Function prototypes for path grouping stuff. */
  97. void ccw_device_verify_start(struct ccw_device *);
  98. void ccw_device_verify_done(struct ccw_device *, int);
  99. void ccw_device_disband_start(struct ccw_device *);
  100. void ccw_device_disband_done(struct ccw_device *, int);
  101. void ccw_device_stlck_start(struct ccw_device *, void *, void *, void *);
  102. void ccw_device_stlck_done(struct ccw_device *, void *, int);
  103. int ccw_device_call_handler(struct ccw_device *);
  104. int ccw_device_stlck(struct ccw_device *);
  105. /* Helper function for machine check handling. */
  106. void ccw_device_trigger_reprobe(struct ccw_device *);
  107. void ccw_device_kill_io(struct ccw_device *);
  108. int ccw_device_notify(struct ccw_device *, int);
  109. void ccw_device_set_disconnected(struct ccw_device *cdev);
  110. void ccw_device_set_notoper(struct ccw_device *cdev);
  111. /* qdio needs this. */
  112. void ccw_device_set_timeout(struct ccw_device *, int);
  113. extern struct subchannel_id ccw_device_get_subchannel_id(struct ccw_device *);
  114. extern struct bus_type ccw_bus_type;
  115. /* Channel measurement facility related */
  116. void retry_set_schib(struct ccw_device *cdev);
  117. void cmf_retry_copy_block(struct ccw_device *);
  118. int cmf_reenable(struct ccw_device *);
  119. int ccw_set_cmf(struct ccw_device *cdev, int enable);
  120. extern struct device_attribute dev_attr_cmb_enable;
  121. #endif