device.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. inc_irq_stat(cdev->private->int_class);
  58. else if (state != DEV_STATE_CMFCHANGE &&
  59. state != DEV_STATE_CMFUPDATE)
  60. inc_irq_stat(IRQIO_CIO);
  61. }
  62. dev_jumptable[state][dev_event](cdev, dev_event);
  63. }
  64. /*
  65. * Delivers 1 if the device state is final.
  66. */
  67. static inline int
  68. dev_fsm_final_state(struct ccw_device *cdev)
  69. {
  70. return (cdev->private->state == DEV_STATE_NOT_OPER ||
  71. cdev->private->state == DEV_STATE_OFFLINE ||
  72. cdev->private->state == DEV_STATE_ONLINE ||
  73. cdev->private->state == DEV_STATE_BOXED);
  74. }
  75. int __init io_subchannel_init(void);
  76. void io_subchannel_recog_done(struct ccw_device *cdev);
  77. void io_subchannel_init_config(struct subchannel *sch);
  78. int ccw_device_cancel_halt_clear(struct ccw_device *);
  79. int ccw_device_is_orphan(struct ccw_device *);
  80. void ccw_device_recognition(struct ccw_device *);
  81. int ccw_device_online(struct ccw_device *);
  82. int ccw_device_offline(struct ccw_device *);
  83. void ccw_device_update_sense_data(struct ccw_device *);
  84. int ccw_device_test_sense_data(struct ccw_device *);
  85. void ccw_device_schedule_sch_unregister(struct ccw_device *);
  86. int ccw_purge_blacklisted(void);
  87. void ccw_device_sched_todo(struct ccw_device *cdev, enum cdev_todo todo);
  88. struct ccw_device *get_ccwdev_by_dev_id(struct ccw_dev_id *dev_id);
  89. /* Function prototypes for device status and basic sense stuff. */
  90. void ccw_device_accumulate_irb(struct ccw_device *, struct irb *);
  91. void ccw_device_accumulate_basic_sense(struct ccw_device *, struct irb *);
  92. int ccw_device_accumulate_and_sense(struct ccw_device *, struct irb *);
  93. int ccw_device_do_sense(struct ccw_device *, struct irb *);
  94. /* Function prototype for internal request handling. */
  95. int lpm_adjust(int lpm, int mask);
  96. void ccw_request_start(struct ccw_device *);
  97. int ccw_request_cancel(struct ccw_device *cdev);
  98. void ccw_request_handler(struct ccw_device *cdev);
  99. void ccw_request_timeout(struct ccw_device *cdev);
  100. void ccw_request_notoper(struct ccw_device *cdev);
  101. /* Function prototypes for sense id stuff. */
  102. void ccw_device_sense_id_start(struct ccw_device *);
  103. void ccw_device_sense_id_done(struct ccw_device *, int);
  104. /* Function prototypes for path grouping stuff. */
  105. void ccw_device_verify_start(struct ccw_device *);
  106. void ccw_device_verify_done(struct ccw_device *, int);
  107. void ccw_device_disband_start(struct ccw_device *);
  108. void ccw_device_disband_done(struct ccw_device *, int);
  109. int ccw_device_stlck(struct ccw_device *);
  110. /* Helper function for machine check handling. */
  111. void ccw_device_trigger_reprobe(struct ccw_device *);
  112. void ccw_device_kill_io(struct ccw_device *);
  113. int ccw_device_notify(struct ccw_device *, int);
  114. void ccw_device_set_disconnected(struct ccw_device *cdev);
  115. void ccw_device_set_notoper(struct ccw_device *cdev);
  116. void ccw_device_set_timeout(struct ccw_device *, int);
  117. /* Channel measurement facility related */
  118. void retry_set_schib(struct ccw_device *cdev);
  119. void cmf_retry_copy_block(struct ccw_device *);
  120. int cmf_reenable(struct ccw_device *);
  121. void cmf_reactivate(void);
  122. int ccw_set_cmf(struct ccw_device *cdev, int enable);
  123. extern struct device_attribute dev_attr_cmb_enable;
  124. #endif