device.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef S390_DEVICE_H
  3. #define S390_DEVICE_H
  4. #include <asm/ccwdev.h>
  5. #include <linux/atomic.h>
  6. #include <linux/timer.h>
  7. #include <linux/wait.h>
  8. #include <linux/notifier.h>
  9. #include <linux/kernel_stat.h>
  10. #include "io_sch.h"
  11. /*
  12. * states of the device statemachine
  13. */
  14. enum dev_state {
  15. DEV_STATE_NOT_OPER,
  16. DEV_STATE_SENSE_ID,
  17. DEV_STATE_OFFLINE,
  18. DEV_STATE_VERIFY,
  19. DEV_STATE_ONLINE,
  20. DEV_STATE_W4SENSE,
  21. DEV_STATE_DISBAND_PGID,
  22. DEV_STATE_BOXED,
  23. /* states to wait for i/o completion before doing something */
  24. DEV_STATE_TIMEOUT_KILL,
  25. DEV_STATE_QUIESCE,
  26. /* special states for devices gone not operational */
  27. DEV_STATE_DISCONNECTED,
  28. DEV_STATE_DISCONNECTED_SENSE_ID,
  29. DEV_STATE_CMFCHANGE,
  30. DEV_STATE_CMFUPDATE,
  31. DEV_STATE_STEAL_LOCK,
  32. /* last element! */
  33. NR_DEV_STATES
  34. };
  35. /*
  36. * asynchronous events of the device statemachine
  37. */
  38. enum dev_event {
  39. DEV_EVENT_NOTOPER,
  40. DEV_EVENT_INTERRUPT,
  41. DEV_EVENT_TIMEOUT,
  42. DEV_EVENT_VERIFY,
  43. /* last element! */
  44. NR_DEV_EVENTS
  45. };
  46. struct ccw_device;
  47. /*
  48. * action called through jumptable
  49. */
  50. typedef void (fsm_func_t)(struct ccw_device *, enum dev_event);
  51. extern fsm_func_t *dev_jumptable[NR_DEV_STATES][NR_DEV_EVENTS];
  52. static inline void
  53. dev_fsm_event(struct ccw_device *cdev, enum dev_event dev_event)
  54. {
  55. int state = cdev->private->state;
  56. if (dev_event == DEV_EVENT_INTERRUPT) {
  57. if (state == DEV_STATE_ONLINE)
  58. inc_irq_stat(cdev->private->int_class);
  59. else if (state != DEV_STATE_CMFCHANGE &&
  60. state != DEV_STATE_CMFUPDATE)
  61. inc_irq_stat(IRQIO_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. int __init io_subchannel_init(void);
  77. void io_subchannel_recog_done(struct ccw_device *cdev);
  78. void io_subchannel_init_config(struct subchannel *sch);
  79. int ccw_device_cancel_halt_clear(struct ccw_device *);
  80. int ccw_device_is_orphan(struct ccw_device *);
  81. void ccw_device_recognition(struct ccw_device *);
  82. int ccw_device_online(struct ccw_device *);
  83. int ccw_device_offline(struct ccw_device *);
  84. void ccw_device_update_sense_data(struct ccw_device *);
  85. int ccw_device_test_sense_data(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_timeout(struct timer_list *t);
  117. void ccw_device_set_timeout(struct ccw_device *, int);
  118. void ccw_device_schedule_recovery(void);
  119. /* Channel measurement facility related */
  120. void retry_set_schib(struct ccw_device *cdev);
  121. void cmf_retry_copy_block(struct ccw_device *);
  122. int cmf_reenable(struct ccw_device *);
  123. void cmf_reactivate(void);
  124. extern struct device_attribute dev_attr_cmb_enable;
  125. #endif