patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / s390 / cio / css.h
1 #ifndef _CSS_H
2 #define _CSS_H
3
4 #include <linux/wait.h>
5 #include <linux/workqueue.h>
6
7 #include <asm/cio.h>
8
9 /*
10  * path grouping stuff
11  */
12 #define SPID_FUNC_SINGLE_PATH      0x00
13 #define SPID_FUNC_MULTI_PATH       0x80
14 #define SPID_FUNC_ESTABLISH        0x00
15 #define SPID_FUNC_RESIGN           0x40
16 #define SPID_FUNC_DISBAND          0x20
17
18 #define SNID_STATE1_RESET          0
19 #define SNID_STATE1_UNGROUPED      2
20 #define SNID_STATE1_GROUPED        3
21
22 #define SNID_STATE2_NOT_RESVD      0
23 #define SNID_STATE2_RESVD_ELSE     2
24 #define SNID_STATE2_RESVD_SELF     3
25
26 #define SNID_STATE3_MULTI_PATH     1
27 #define SNID_STATE3_SINGLE_PATH    0
28
29 struct path_state {
30         __u8  state1 : 2;       /* path state value 1 */
31         __u8  state2 : 2;       /* path state value 2 */
32         __u8  state3 : 1;       /* path state value 3 */
33         __u8  resvd  : 3;       /* reserved */
34 } __attribute__ ((packed));
35
36 struct pgid {
37         union {
38                 __u8 fc;        /* SPID function code */
39                 struct path_state ps;   /* SNID path state */
40         } inf;
41         __u32 cpu_addr  : 16;   /* CPU address */
42         __u32 cpu_id    : 24;   /* CPU identification */
43         __u32 cpu_model : 16;   /* CPU model */
44         __u32 tod_high;         /* high word TOD clock */
45 } __attribute__ ((packed));
46
47 extern struct pgid global_pgid;
48
49 #define MAX_CIWS 8
50
51 /*
52  * sense-id response buffer layout
53  */
54 struct senseid {
55         /* common part */
56         __u8  reserved;         /* always 0x'FF' */
57         __u16 cu_type;          /* control unit type */
58         __u8  cu_model;         /* control unit model */
59         __u16 dev_type;         /* device type */
60         __u8  dev_model;        /* device model */
61         __u8  unused;           /* padding byte */
62         /* extended part */
63         struct ciw ciw[MAX_CIWS];       /* variable # of CIWs */
64 }  __attribute__ ((packed,aligned(4)));
65
66 struct ccw_device_private {
67         int state;              /* device state */
68         atomic_t onoff;
69         __u16 devno;            /* device number */
70         __u16 irq;              /* subchannel number */
71         __u8 imask;             /* lpm mask for SNID/SID/SPGID */
72         int iretry;             /* retry counter SNID/SID/SPGID */
73         struct {
74                 unsigned int fast:1;    /* post with "channel end" */
75                 unsigned int repall:1;  /* report every interrupt status */
76                 unsigned int pgroup:1;  /* do path grouping */
77                 unsigned int force:1;   /* allow forced online */
78         } __attribute__ ((packed)) options;
79         struct {
80                 unsigned int pgid_single:1; /* use single path for Set PGID */
81                 unsigned int esid:1;        /* Ext. SenseID supported by HW */
82                 unsigned int dosense:1;     /* delayed SENSE required */
83                 unsigned int doverify:1;    /* delayed path verification */
84                 unsigned int donotify:1;    /* call notify function */
85                 unsigned int recog_done:1;  /* dev. recog. complete */
86         } __attribute__((packed)) flags;
87         unsigned long intparm;  /* user interruption parameter */
88         struct qdio_irq *qdio_data;
89         struct irb irb;         /* device status */
90         struct senseid senseid; /* SenseID info */
91         struct pgid pgid;       /* path group ID */
92         struct ccw1 iccws[2];   /* ccws for SNID/SID/SPGID commands */
93         struct work_struct kick_work;
94         wait_queue_head_t wait_q;
95         struct timer_list timer;
96         void *cmb;                      /* measurement information */
97         struct list_head cmb_list;      /* list of measured devices */
98         u64 cmb_start_time;             /* clock value of cmb reset */
99         void *cmb_wait;                 /* deferred cmb enable/disable */
100 };
101
102 /*
103  * A css driver handles all subchannels of one type.
104  * Currently, we only care about I/O subchannels (type 0), these
105  * have a ccw_device connected to them.
106  */
107 struct css_driver {
108         unsigned int subchannel_type;
109         struct device_driver drv;
110         void (*irq)(struct device *);
111         int (*notify)(struct device *, int);
112         void (*verify)(struct device *);
113         void (*termination)(struct device *);
114 };
115
116 /*
117  * all css_drivers have the css_bus_type
118  */
119 extern struct bus_type css_bus_type;
120 extern struct css_driver io_subchannel_driver;
121
122 int css_probe_device(int irq);
123 extern struct subchannel * get_subchannel_by_schid(int irq);
124 extern unsigned int highest_subchannel;
125 extern int css_init_done;
126
127 #define __MAX_SUBCHANNELS 65536
128
129 extern struct bus_type css_bus_type;
130 extern struct device css_bus_device;
131
132 /* Some helper functions for disconnected state. */
133 int device_is_disconnected(struct subchannel *);
134 void device_set_disconnected(struct subchannel *);
135 void device_trigger_reprobe(struct subchannel *);
136
137 /* Helper functions for vary on/off. */
138 void device_set_waiting(struct subchannel *);
139
140 /* Helper functions to build lists for the slow path. */
141 int css_enqueue_subchannel_slow(unsigned long schid);
142 void css_walk_subchannel_slow_list(void (*fn)(unsigned long));
143 void css_clear_subchannel_slow_list(void);
144 int css_slow_subchannels_exist(void);
145 extern int need_rescan;
146
147 extern struct workqueue_struct *slow_path_wq;
148 extern struct work_struct slow_path_work;
149 #endif