Merge tag 'edac_for_4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp
[sfrench/cifs-2.6.git] / arch / s390 / include / asm / cio.h
1 /*
2  * Common interface for I/O on S/390
3  */
4 #ifndef _ASM_S390_CIO_H_
5 #define _ASM_S390_CIO_H_
6
7 #include <linux/spinlock.h>
8 #include <linux/bitops.h>
9 #include <asm/types.h>
10
11 #define LPM_ANYPATH 0xff
12 #define __MAX_CSSID 0
13 #define __MAX_SUBCHANNEL 65535
14 #define __MAX_SSID 3
15
16 #include <asm/scsw.h>
17
18 /**
19  * struct ccw1 - channel command word
20  * @cmd_code: command code
21  * @flags: flags, like IDA addressing, etc.
22  * @count: byte count
23  * @cda: data address
24  *
25  * The ccw is the basic structure to build channel programs that perform
26  * operations with the device or the control unit. Only Format-1 channel
27  * command words are supported.
28  */
29 struct ccw1 {
30         __u8  cmd_code;
31         __u8  flags;
32         __u16 count;
33         __u32 cda;
34 } __attribute__ ((packed,aligned(8)));
35
36 #define CCW_FLAG_DC             0x80
37 #define CCW_FLAG_CC             0x40
38 #define CCW_FLAG_SLI            0x20
39 #define CCW_FLAG_SKIP           0x10
40 #define CCW_FLAG_PCI            0x08
41 #define CCW_FLAG_IDA            0x04
42 #define CCW_FLAG_SUSPEND        0x02
43
44 #define CCW_CMD_READ_IPL        0x02
45 #define CCW_CMD_NOOP            0x03
46 #define CCW_CMD_BASIC_SENSE     0x04
47 #define CCW_CMD_TIC             0x08
48 #define CCW_CMD_STLCK           0x14
49 #define CCW_CMD_SENSE_PGID      0x34
50 #define CCW_CMD_SUSPEND_RECONN  0x5B
51 #define CCW_CMD_RDC             0x64
52 #define CCW_CMD_RELEASE         0x94
53 #define CCW_CMD_SET_PGID        0xAF
54 #define CCW_CMD_SENSE_ID        0xE4
55 #define CCW_CMD_DCTL            0xF3
56
57 #define SENSE_MAX_COUNT         0x20
58
59 /**
60  * struct erw - extended report word
61  * @res0: reserved
62  * @auth: authorization check
63  * @pvrf: path-verification-required flag
64  * @cpt: channel-path timeout
65  * @fsavf: failing storage address validity flag
66  * @cons: concurrent sense
67  * @scavf: secondary ccw address validity flag
68  * @fsaf: failing storage address format
69  * @scnt: sense count, if @cons == %1
70  * @res16: reserved
71  */
72 struct erw {
73         __u32 res0  : 3;
74         __u32 auth  : 1;
75         __u32 pvrf  : 1;
76         __u32 cpt   : 1;
77         __u32 fsavf : 1;
78         __u32 cons  : 1;
79         __u32 scavf : 1;
80         __u32 fsaf  : 1;
81         __u32 scnt  : 6;
82         __u32 res16 : 16;
83 } __attribute__ ((packed));
84
85 /**
86  * struct erw_eadm - EADM Subchannel extended report word
87  * @b: aob error
88  * @r: arsb error
89  */
90 struct erw_eadm {
91         __u32 : 16;
92         __u32 b : 1;
93         __u32 r : 1;
94         __u32  : 14;
95 } __packed;
96
97 /**
98  * struct sublog - subchannel logout area
99  * @res0: reserved
100  * @esf: extended status flags
101  * @lpum: last path used mask
102  * @arep: ancillary report
103  * @fvf: field-validity flags
104  * @sacc: storage access code
105  * @termc: termination code
106  * @devsc: device-status check
107  * @serr: secondary error
108  * @ioerr: i/o-error alert
109  * @seqc: sequence code
110  */
111 struct sublog {
112         __u32 res0  : 1;
113         __u32 esf   : 7;
114         __u32 lpum  : 8;
115         __u32 arep  : 1;
116         __u32 fvf   : 5;
117         __u32 sacc  : 2;
118         __u32 termc : 2;
119         __u32 devsc : 1;
120         __u32 serr  : 1;
121         __u32 ioerr : 1;
122         __u32 seqc  : 3;
123 } __attribute__ ((packed));
124
125 /**
126  * struct esw0 - Format 0 Extended Status Word (ESW)
127  * @sublog: subchannel logout
128  * @erw: extended report word
129  * @faddr: failing storage address
130  * @saddr: secondary ccw address
131  */
132 struct esw0 {
133         struct sublog sublog;
134         struct erw erw;
135         __u32  faddr[2];
136         __u32  saddr;
137 } __attribute__ ((packed));
138
139 /**
140  * struct esw1 - Format 1 Extended Status Word (ESW)
141  * @zero0: reserved zeros
142  * @lpum: last path used mask
143  * @zero16: reserved zeros
144  * @erw: extended report word
145  * @zeros: three fullwords of zeros
146  */
147 struct esw1 {
148         __u8  zero0;
149         __u8  lpum;
150         __u16 zero16;
151         struct erw erw;
152         __u32 zeros[3];
153 } __attribute__ ((packed));
154
155 /**
156  * struct esw2 - Format 2 Extended Status Word (ESW)
157  * @zero0: reserved zeros
158  * @lpum: last path used mask
159  * @dcti: device-connect-time interval
160  * @erw: extended report word
161  * @zeros: three fullwords of zeros
162  */
163 struct esw2 {
164         __u8  zero0;
165         __u8  lpum;
166         __u16 dcti;
167         struct erw erw;
168         __u32 zeros[3];
169 } __attribute__ ((packed));
170
171 /**
172  * struct esw3 - Format 3 Extended Status Word (ESW)
173  * @zero0: reserved zeros
174  * @lpum: last path used mask
175  * @res: reserved
176  * @erw: extended report word
177  * @zeros: three fullwords of zeros
178  */
179 struct esw3 {
180         __u8  zero0;
181         __u8  lpum;
182         __u16 res;
183         struct erw erw;
184         __u32 zeros[3];
185 } __attribute__ ((packed));
186
187 /**
188  * struct esw_eadm - EADM Subchannel Extended Status Word (ESW)
189  * @sublog: subchannel logout
190  * @erw: extended report word
191  */
192 struct esw_eadm {
193         __u32 sublog;
194         struct erw_eadm erw;
195         __u32 : 32;
196         __u32 : 32;
197         __u32 : 32;
198 } __packed;
199
200 /**
201  * struct irb - interruption response block
202  * @scsw: subchannel status word
203  * @esw: extended status word
204  * @ecw: extended control word
205  *
206  * The irb that is handed to the device driver when an interrupt occurs. For
207  * solicited interrupts, the common I/O layer already performs checks whether
208  * a field is valid; a field not being valid is always passed as %0.
209  * If a unit check occurred, @ecw may contain sense data; this is retrieved
210  * by the common I/O layer itself if the device doesn't support concurrent
211  * sense (so that the device driver never needs to perform basic sene itself).
212  * For unsolicited interrupts, the irb is passed as-is (expect for sense data,
213  * if applicable).
214  */
215 struct irb {
216         union scsw scsw;
217         union {
218                 struct esw0 esw0;
219                 struct esw1 esw1;
220                 struct esw2 esw2;
221                 struct esw3 esw3;
222                 struct esw_eadm eadm;
223         } esw;
224         __u8   ecw[32];
225 } __attribute__ ((packed,aligned(4)));
226
227 /**
228  * struct ciw - command information word  (CIW) layout
229  * @et: entry type
230  * @reserved: reserved bits
231  * @ct: command type
232  * @cmd: command code
233  * @count: command count
234  */
235 struct ciw {
236         __u32 et       :  2;
237         __u32 reserved :  2;
238         __u32 ct       :  4;
239         __u32 cmd      :  8;
240         __u32 count    : 16;
241 } __attribute__ ((packed));
242
243 #define CIW_TYPE_RCD    0x0     /* read configuration data */
244 #define CIW_TYPE_SII    0x1     /* set interface identifier */
245 #define CIW_TYPE_RNI    0x2     /* read node identifier */
246
247 /*
248  * Flags used as input parameters for do_IO()
249  */
250 #define DOIO_ALLOW_SUSPEND       0x0001 /* allow for channel prog. suspend */
251 #define DOIO_DENY_PREFETCH       0x0002 /* don't allow for CCW prefetch */
252 #define DOIO_SUPPRESS_INTER      0x0004 /* suppress intermediate inter. */
253                                         /* ... for suspended CCWs */
254 /* Device or subchannel gone. */
255 #define CIO_GONE       0x0001
256 /* No path to device. */
257 #define CIO_NO_PATH    0x0002
258 /* Device has appeared. */
259 #define CIO_OPER       0x0004
260 /* Sick revalidation of device. */
261 #define CIO_REVALIDATE 0x0008
262 /* Device did not respond in time. */
263 #define CIO_BOXED      0x0010
264
265 /**
266  * struct ccw_dev_id - unique identifier for ccw devices
267  * @ssid: subchannel set id
268  * @devno: device number
269  *
270  * This structure is not directly based on any hardware structure. The
271  * hardware identifies a device by its device number and its subchannel,
272  * which is in turn identified by its id. In order to get a unique identifier
273  * for ccw devices across subchannel sets, @struct ccw_dev_id has been
274  * introduced.
275  */
276 struct ccw_dev_id {
277         u8 ssid;
278         u16 devno;
279 };
280
281 /**
282  * ccw_device_id_is_equal() - compare two ccw_dev_ids
283  * @dev_id1: a ccw_dev_id
284  * @dev_id2: another ccw_dev_id
285  * Returns:
286  *  %1 if the two structures are equal field-by-field,
287  *  %0 if not.
288  * Context:
289  *  any
290  */
291 static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
292                                       struct ccw_dev_id *dev_id2)
293 {
294         if ((dev_id1->ssid == dev_id2->ssid) &&
295             (dev_id1->devno == dev_id2->devno))
296                 return 1;
297         return 0;
298 }
299
300 /**
301  * pathmask_to_pos() - find the position of the left-most bit in a pathmask
302  * @mask: pathmask with at least one bit set
303  */
304 static inline u8 pathmask_to_pos(u8 mask)
305 {
306         return 8 - ffs(mask);
307 }
308
309 void channel_subsystem_reinit(void);
310 extern void css_schedule_reprobe(void);
311
312 extern void reipl_ccw_dev(struct ccw_dev_id *id);
313
314 struct cio_iplinfo {
315         u8 ssid;
316         u16 devno;
317         int is_qdio;
318 };
319
320 extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo);
321
322 /* Function from drivers/s390/cio/chsc.c */
323 int chsc_sstpc(void *page, unsigned int op, u16 ctrl, u64 *clock_delta);
324 int chsc_sstpi(void *page, void *result, size_t size);
325
326 #endif