blob: 2ebb492a5c17dcb8a9e05fb23209162edb43d849 [file] [log] [blame]
Cornelia Huckcd6b4f22008-01-26 14:10:43 +01001#ifndef S390_IO_SCH_H
2#define S390_IO_SCH_H
3
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +01004#include <linux/types.h>
Cornelia Huck9d92a7e2008-07-14 09:59:05 +02005#include <asm/schid.h>
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +01006#include <asm/ccwdev.h>
Peter Oberparleiterde400d62011-10-30 15:16:04 +01007#include <asm/irq.h>
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +01008#include "css.h"
Sebastian Ott9e6f9f82011-03-15 17:08:23 +01009#include "orb.h"
Peter Oberparleiter83262d62008-07-14 09:58:51 +020010
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010011struct io_subchannel_private {
Peter Oberparleiter83262d62008-07-14 09:58:51 +020012 union orb orb; /* operation request block */
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010013 struct ccw1 sense_ccw; /* static ccw for sense command */
Sebastian Ott97eb6bf2011-03-15 17:08:26 +010014 struct ccw_device *cdev;/* pointer to the child ccw device */
Sebastian Ottc513d072011-03-15 17:08:25 +010015 struct {
16 unsigned int suspend:1; /* allow suspend */
17 unsigned int prefetch:1;/* deny prefetch */
18 unsigned int inter:1; /* suppress intermediate interrupts */
19 } __packed options;
20} __aligned(8);
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010021
Sebastian Ottf92519e2011-03-15 17:08:27 +010022#define to_io_private(n) ((struct io_subchannel_private *) \
23 dev_get_drvdata(&(n)->dev))
24#define set_io_private(n, p) (dev_set_drvdata(&(n)->dev, p))
Sebastian Ott97eb6bf2011-03-15 17:08:26 +010025
26static inline struct ccw_device *sch_get_cdev(struct subchannel *sch)
27{
28 struct io_subchannel_private *priv = to_io_private(sch);
29 return priv ? priv->cdev : NULL;
30}
31
32static inline void sch_set_cdev(struct subchannel *sch,
33 struct ccw_device *cdev)
34{
35 struct io_subchannel_private *priv = to_io_private(sch);
36 if (priv)
37 priv->cdev = cdev;
38}
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010039
40#define MAX_CIWS 8
41
42/*
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +010043 * Possible status values for a CCW request's I/O.
44 */
45enum io_status {
46 IO_DONE,
47 IO_RUNNING,
48 IO_STATUS_ERROR,
49 IO_PATH_ERROR,
50 IO_REJECTED,
51 IO_KILLED
52};
53
54/**
55 * ccw_request - Internal CCW request.
56 * @cp: channel program to start
57 * @timeout: maximum allowable time in jiffies between start I/O and interrupt
58 * @maxretries: number of retries per I/O operation and path
59 * @lpm: mask of paths to use
60 * @check: optional callback that determines if results are final
61 * @filter: optional callback to adjust request status based on IRB data
62 * @callback: final callback
63 * @data: user-defined pointer passed to all callbacks
Sebastian Ott982bdf82010-08-09 18:12:53 +020064 * @singlepath: if set, use only one path from @lpm per start I/O
65 * @cancel: non-zero if request was cancelled
66 * @done: non-zero if request was finished
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +010067 * @mask: current path mask
68 * @retries: current number of retries
69 * @drc: delayed return code
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +010070 */
71struct ccw_request {
72 struct ccw1 *cp;
73 unsigned long timeout;
74 u16 maxretries;
75 u8 lpm;
76 int (*check)(struct ccw_device *, void *);
77 enum io_status (*filter)(struct ccw_device *, void *, struct irb *,
78 enum io_status);
79 void (*callback)(struct ccw_device *, void *, int);
80 void *data;
Sebastian Ott982bdf82010-08-09 18:12:53 +020081 unsigned int singlepath:1;
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +010082 /* These fields are used internally. */
Sebastian Ott982bdf82010-08-09 18:12:53 +020083 unsigned int cancel:1;
84 unsigned int done:1;
Peter Oberparleiterde1b0432009-12-07 12:51:40 +010085 u16 mask;
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +010086 u16 retries;
87 int drc;
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +010088} __attribute__((packed));
89
90/*
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010091 * sense-id response buffer layout
92 */
93struct senseid {
94 /* common part */
95 u8 reserved; /* always 0x'FF' */
96 u16 cu_type; /* control unit type */
97 u8 cu_model; /* control unit model */
98 u16 dev_type; /* device type */
99 u8 dev_model; /* device model */
100 u8 unused; /* padding byte */
101 /* extended part */
102 struct ciw ciw[MAX_CIWS]; /* variable # of CIWs */
103} __attribute__ ((packed, aligned(4)));
104
Peter Oberparleiter37de53b2009-12-07 12:51:19 +0100105enum cdev_todo {
106 CDEV_TODO_NOTHING,
107 CDEV_TODO_ENABLE_CMF,
108 CDEV_TODO_REBIND,
109 CDEV_TODO_REGISTER,
110 CDEV_TODO_UNREG,
111 CDEV_TODO_UNREG_EVAL,
112};
113
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100114struct ccw_device_private {
115 struct ccw_device *cdev;
116 struct subchannel *sch;
117 int state; /* device state */
118 atomic_t onoff;
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100119 struct ccw_dev_id dev_id; /* device id */
120 struct subchannel_id schid; /* subchannel number */
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +0100121 struct ccw_request req; /* internal I/O request */
Peter Oberparleiter9679baa2009-12-07 12:51:27 +0100122 int iretry;
Sebastian Ott585b9542010-10-25 16:10:34 +0200123 u8 pgid_valid_mask; /* mask of valid PGIDs */
124 u8 pgid_todo_mask; /* mask of PGIDs to be adjusted */
125 u8 pgid_reset_mask; /* mask of PGIDs which were reset */
126 u8 path_gone_mask; /* mask of paths, that became unavailable */
127 u8 path_new_mask; /* mask of paths, that became available */
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100128 struct {
129 unsigned int fast:1; /* post with "channel end" */
130 unsigned int repall:1; /* report every interrupt status */
131 unsigned int pgroup:1; /* do path grouping */
132 unsigned int force:1; /* allow forced online */
Peter Oberparleiter454e1fa2009-12-07 12:51:30 +0100133 unsigned int mpath:1; /* do multipathing */
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100134 } __attribute__ ((packed)) options;
135 struct {
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100136 unsigned int esid:1; /* Ext. SenseID supported by HW */
137 unsigned int dosense:1; /* delayed SENSE required */
138 unsigned int doverify:1; /* delayed path verification */
139 unsigned int donotify:1; /* call notify function */
140 unsigned int recog_done:1; /* dev. recog. complete */
141 unsigned int fake_irb:1; /* deliver faked irb */
Sebastian Ott823d4942009-06-16 10:30:20 +0200142 unsigned int resuming:1; /* recognition while resume */
Peter Oberparleiter454e1fa2009-12-07 12:51:30 +0100143 unsigned int pgroup:1; /* pathgroup is set up */
144 unsigned int mpath:1; /* multipathing is set up */
Sebastian Ott24a18722009-12-07 12:51:34 +0100145 unsigned int initialized:1; /* set if initial reference held */
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100146 } __attribute__((packed)) flags;
147 unsigned long intparm; /* user interruption parameter */
148 struct qdio_irq *qdio_data;
149 struct irb irb; /* device status */
150 struct senseid senseid; /* SenseID info */
151 struct pgid pgid[8]; /* path group IDs per chpid*/
152 struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */
Peter Oberparleiter37de53b2009-12-07 12:51:19 +0100153 struct work_struct todo_work;
154 enum cdev_todo todo;
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100155 wait_queue_head_t wait_q;
156 struct timer_list timer;
157 void *cmb; /* measurement information */
158 struct list_head cmb_list; /* list of measured devices */
159 u64 cmb_start_time; /* clock value of cmb reset */
160 void *cmb_wait; /* deferred cmb enable/disable */
Peter Oberparleiterde400d62011-10-30 15:16:04 +0100161 enum interruption_class int_class;
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100162};
163
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100164static inline int rsch(struct subchannel_id schid)
165{
166 register struct subchannel_id reg1 asm("1") = schid;
167 int ccode;
168
169 asm volatile(
170 " rsch\n"
171 " ipm %0\n"
172 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200173 : "=d" (ccode)
174 : "d" (reg1)
175 : "cc", "memory");
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100176 return ccode;
177}
178
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100179static inline int hsch(struct subchannel_id schid)
180{
181 register struct subchannel_id reg1 asm("1") = schid;
182 int ccode;
183
184 asm volatile(
185 " hsch\n"
186 " ipm %0\n"
187 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200188 : "=d" (ccode)
189 : "d" (reg1)
190 : "cc");
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100191 return ccode;
192}
193
194static inline int xsch(struct subchannel_id schid)
195{
196 register struct subchannel_id reg1 asm("1") = schid;
197 int ccode;
198
199 asm volatile(
200 " .insn rre,0xb2760000,%1,0\n"
201 " ipm %0\n"
202 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200203 : "=d" (ccode)
204 : "d" (reg1)
205 : "cc");
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100206 return ccode;
207}
208
209#endif