blob: a3aa056d72453d0900a5e1a99c0f4bba1f9f8d96 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef S390_DEVICE_H
2#define S390_DEVICE_H
3
4/*
5 * states of the device statemachine
6 */
7enum dev_state {
8 DEV_STATE_NOT_OPER,
9 DEV_STATE_SENSE_PGID,
10 DEV_STATE_SENSE_ID,
11 DEV_STATE_OFFLINE,
12 DEV_STATE_VERIFY,
13 DEV_STATE_ONLINE,
14 DEV_STATE_W4SENSE,
15 DEV_STATE_DISBAND_PGID,
16 DEV_STATE_BOXED,
17 /* states to wait for i/o completion before doing something */
18 DEV_STATE_CLEAR_VERIFY,
19 DEV_STATE_TIMEOUT_KILL,
20 DEV_STATE_WAIT4IO,
21 DEV_STATE_QUIESCE,
22 /* special states for devices gone not operational */
23 DEV_STATE_DISCONNECTED,
24 DEV_STATE_DISCONNECTED_SENSE_ID,
25 DEV_STATE_CMFCHANGE,
26 /* last element! */
27 NR_DEV_STATES
28};
29
30/*
31 * asynchronous events of the device statemachine
32 */
33enum dev_event {
34 DEV_EVENT_NOTOPER,
35 DEV_EVENT_INTERRUPT,
36 DEV_EVENT_TIMEOUT,
37 DEV_EVENT_VERIFY,
38 /* last element! */
39 NR_DEV_EVENTS
40};
41
42struct ccw_device;
43
44/*
45 * action called through jumptable
46 */
47typedef void (fsm_func_t)(struct ccw_device *, enum dev_event);
48extern fsm_func_t *dev_jumptable[NR_DEV_STATES][NR_DEV_EVENTS];
49
50static inline void
51dev_fsm_event(struct ccw_device *cdev, enum dev_event dev_event)
52{
53 dev_jumptable[cdev->private->state][dev_event](cdev, dev_event);
54}
55
56/*
57 * Delivers 1 if the device state is final.
58 */
59static inline int
60dev_fsm_final_state(struct ccw_device *cdev)
61{
62 return (cdev->private->state == DEV_STATE_NOT_OPER ||
63 cdev->private->state == DEV_STATE_OFFLINE ||
64 cdev->private->state == DEV_STATE_ONLINE ||
65 cdev->private->state == DEV_STATE_BOXED);
66}
67
68extern struct workqueue_struct *ccw_device_work;
69extern struct workqueue_struct *ccw_device_notify_work;
70
71void io_subchannel_recog_done(struct ccw_device *cdev);
72
73int ccw_device_cancel_halt_clear(struct ccw_device *);
74
75int ccw_device_register(struct ccw_device *);
76void ccw_device_do_unreg_rereg(void *);
77void ccw_device_call_sch_unregister(void *);
78
79int ccw_device_recognition(struct ccw_device *);
80int ccw_device_online(struct ccw_device *);
81int ccw_device_offline(struct ccw_device *);
82
83/* Function prototypes for device status and basic sense stuff. */
84void ccw_device_accumulate_irb(struct ccw_device *, struct irb *);
85void ccw_device_accumulate_basic_sense(struct ccw_device *, struct irb *);
86int ccw_device_accumulate_and_sense(struct ccw_device *, struct irb *);
87int ccw_device_do_sense(struct ccw_device *, struct irb *);
88
89/* Function prototypes for sense id stuff. */
90void ccw_device_sense_id_start(struct ccw_device *);
91void ccw_device_sense_id_irq(struct ccw_device *, enum dev_event);
92void ccw_device_sense_id_done(struct ccw_device *, int);
93
94/* Function prototypes for path grouping stuff. */
95void ccw_device_sense_pgid_start(struct ccw_device *);
96void ccw_device_sense_pgid_irq(struct ccw_device *, enum dev_event);
97void ccw_device_sense_pgid_done(struct ccw_device *, int);
98
99void ccw_device_verify_start(struct ccw_device *);
100void ccw_device_verify_irq(struct ccw_device *, enum dev_event);
101void ccw_device_verify_done(struct ccw_device *, int);
102
103void ccw_device_disband_start(struct ccw_device *);
104void ccw_device_disband_irq(struct ccw_device *, enum dev_event);
105void ccw_device_disband_done(struct ccw_device *, int);
106
107int ccw_device_call_handler(struct ccw_device *);
108
109int ccw_device_stlck(struct ccw_device *);
110
111/* qdio needs this. */
112void ccw_device_set_timeout(struct ccw_device *, int);
113
114void retry_set_schib(struct ccw_device *cdev);
115#endif