device.h 4.4 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3
#ifndef S390_DEVICE_H
#define S390_DEVICE_H

4
#include <asm/ccwdev.h>
A
Arun Sharma 已提交
5
#include <linux/atomic.h>
6
#include <linux/wait.h>
7
#include <linux/notifier.h>
8
#include <linux/kernel_stat.h>
9 10
#include "io_sch.h"

L
Linus Torvalds 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/*
 * states of the device statemachine
 */
enum dev_state {
	DEV_STATE_NOT_OPER,
	DEV_STATE_SENSE_ID,
	DEV_STATE_OFFLINE,
	DEV_STATE_VERIFY,
	DEV_STATE_ONLINE,
	DEV_STATE_W4SENSE,
	DEV_STATE_DISBAND_PGID,
	DEV_STATE_BOXED,
	/* states to wait for i/o completion before doing something */
	DEV_STATE_TIMEOUT_KILL,
	DEV_STATE_QUIESCE,
	/* special states for devices gone not operational */
	DEV_STATE_DISCONNECTED,
	DEV_STATE_DISCONNECTED_SENSE_ID,
	DEV_STATE_CMFCHANGE,
30
	DEV_STATE_CMFUPDATE,
31
	DEV_STATE_STEAL_LOCK,
L
Linus Torvalds 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
	/* last element! */
	NR_DEV_STATES
};

/*
 * asynchronous events of the device statemachine
 */
enum dev_event {
	DEV_EVENT_NOTOPER,
	DEV_EVENT_INTERRUPT,
	DEV_EVENT_TIMEOUT,
	DEV_EVENT_VERIFY,
	/* last element! */
	NR_DEV_EVENTS
};

struct ccw_device;

/*
 * action called through jumptable
 */
typedef void (fsm_func_t)(struct ccw_device *, enum dev_event);
extern fsm_func_t *dev_jumptable[NR_DEV_STATES][NR_DEV_EVENTS];

static inline void
dev_fsm_event(struct ccw_device *cdev, enum dev_event dev_event)
{
59 60 61 62
	int state = cdev->private->state;

	if (dev_event == DEV_EVENT_INTERRUPT) {
		if (state == DEV_STATE_ONLINE)
63
			inc_irq_stat(cdev->private->int_class);
64 65
		else if (state != DEV_STATE_CMFCHANGE &&
			 state != DEV_STATE_CMFUPDATE)
66
			inc_irq_stat(IRQIO_CIO);
67 68
	}
	dev_jumptable[state][dev_event](cdev, dev_event);
L
Linus Torvalds 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81 82
}

/*
 * Delivers 1 if the device state is final.
 */
static inline int
dev_fsm_final_state(struct ccw_device *cdev)
{
	return (cdev->private->state == DEV_STATE_NOT_OPER ||
		cdev->private->state == DEV_STATE_OFFLINE ||
		cdev->private->state == DEV_STATE_ONLINE ||
		cdev->private->state == DEV_STATE_BOXED);
}

S
Sebastian Ott 已提交
83
int __init io_subchannel_init(void);
L
Linus Torvalds 已提交
84 85

void io_subchannel_recog_done(struct ccw_device *cdev);
86
void io_subchannel_init_config(struct subchannel *sch);
L
Linus Torvalds 已提交
87 88 89

int ccw_device_cancel_halt_clear(struct ccw_device *);

90
int ccw_device_is_orphan(struct ccw_device *);
L
Linus Torvalds 已提交
91

92
void ccw_device_recognition(struct ccw_device *);
L
Linus Torvalds 已提交
93 94
int ccw_device_online(struct ccw_device *);
int ccw_device_offline(struct ccw_device *);
95 96
void ccw_device_update_sense_data(struct ccw_device *);
int ccw_device_test_sense_data(struct ccw_device *);
97
void ccw_device_schedule_sch_unregister(struct ccw_device *);
98
int ccw_purge_blacklisted(void);
99
void ccw_device_sched_todo(struct ccw_device *cdev, enum cdev_todo todo);
100
struct ccw_device *get_ccwdev_by_dev_id(struct ccw_dev_id *dev_id);
L
Linus Torvalds 已提交
101 102 103 104 105 106 107

/* Function prototypes for device status and basic sense stuff. */
void ccw_device_accumulate_irb(struct ccw_device *, struct irb *);
void ccw_device_accumulate_basic_sense(struct ccw_device *, struct irb *);
int ccw_device_accumulate_and_sense(struct ccw_device *, struct irb *);
int ccw_device_do_sense(struct ccw_device *, struct irb *);

108 109 110 111 112 113 114 115
/* Function prototype for internal request handling. */
int lpm_adjust(int lpm, int mask);
void ccw_request_start(struct ccw_device *);
int ccw_request_cancel(struct ccw_device *cdev);
void ccw_request_handler(struct ccw_device *cdev);
void ccw_request_timeout(struct ccw_device *cdev);
void ccw_request_notoper(struct ccw_device *cdev);

L
Linus Torvalds 已提交
116 117 118 119 120 121 122 123 124 125 126 127 128
/* Function prototypes for sense id stuff. */
void ccw_device_sense_id_start(struct ccw_device *);
void ccw_device_sense_id_done(struct ccw_device *, int);

/* Function prototypes for path grouping stuff. */
void ccw_device_verify_start(struct ccw_device *);
void ccw_device_verify_done(struct ccw_device *, int);

void ccw_device_disband_start(struct ccw_device *);
void ccw_device_disband_done(struct ccw_device *, int);

int ccw_device_stlck(struct ccw_device *);

C
Cornelia Huck 已提交
129 130 131 132
/* Helper function for machine check handling. */
void ccw_device_trigger_reprobe(struct ccw_device *);
void ccw_device_kill_io(struct ccw_device *);
int ccw_device_notify(struct ccw_device *, int);
133
void ccw_device_set_disconnected(struct ccw_device *cdev);
134
void ccw_device_set_notoper(struct ccw_device *cdev);
C
Cornelia Huck 已提交
135

L
Linus Torvalds 已提交
136
void ccw_device_set_timeout(struct ccw_device *, int);
S
Sebastian Ott 已提交
137
void ccw_device_schedule_recovery(void);
L
Linus Torvalds 已提交
138

139
/* Channel measurement facility related */
L
Linus Torvalds 已提交
140
void retry_set_schib(struct ccw_device *cdev);
141 142
void cmf_retry_copy_block(struct ccw_device *);
int cmf_reenable(struct ccw_device *);
143
void cmf_reactivate(void);
144
int ccw_set_cmf(struct ccw_device *cdev, int enable);
145
extern struct device_attribute dev_attr_cmb_enable;
L
Linus Torvalds 已提交
146
#endif