blob: 123b557c3ff4d19c29b42bd1dec2f570787cef36 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * include/asm-s390/cio.h
3 * include/asm-s390x/cio.h
4 *
5 * Common interface for I/O on S/390
6 */
7#ifndef _ASM_S390_CIO_H_
8#define _ASM_S390_CIO_H_
9
10#include <linux/spinlock.h>
11#include <asm/types.h>
12
13#ifdef __KERNEL__
14
15#define LPM_ANYPATH 0xff
Peter Oberparleitere5854a52007-04-27 16:01:31 +020016#define __MAX_CSSID 0
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020018/**
19 * struct scsw - subchannel status word
20 * @key: subchannel key
21 * @sctl: suspend control
22 * @eswf: esw format
23 * @cc: deferred condition code
24 * @fmt: format
25 * @pfch: prefetch
26 * @isic: initial-status interruption control
Joe Perches58002662008-01-26 14:11:19 +010027 * @alcc: address-limit checking control
28 * @ssi: suppress-suspended interruption
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020029 * @zcc: zero condition code
30 * @ectl: extended control
31 * @pno: path not operational
32 * @res: reserved
33 * @fctl: function control
34 * @actl: activity control
35 * @stctl: status control
36 * @cpa: channel program address
37 * @dstat: device status
38 * @cstat: subchannel status
39 * @count: residual count
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 */
41struct scsw {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020042 __u32 key : 4;
43 __u32 sctl : 1;
44 __u32 eswf : 1;
45 __u32 cc : 2;
46 __u32 fmt : 1;
47 __u32 pfch : 1;
48 __u32 isic : 1;
49 __u32 alcc : 1;
50 __u32 ssi : 1;
51 __u32 zcc : 1;
52 __u32 ectl : 1;
53 __u32 pno : 1;
54 __u32 res : 1;
55 __u32 fctl : 3;
56 __u32 actl : 7;
57 __u32 stctl : 5;
58 __u32 cpa;
59 __u32 dstat : 8;
60 __u32 cstat : 8;
61 __u32 count : 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -070062} __attribute__ ((packed));
63
64#define SCSW_FCTL_CLEAR_FUNC 0x1
65#define SCSW_FCTL_HALT_FUNC 0x2
66#define SCSW_FCTL_START_FUNC 0x4
67
68#define SCSW_ACTL_SUSPENDED 0x1
69#define SCSW_ACTL_DEVACT 0x2
70#define SCSW_ACTL_SCHACT 0x4
71#define SCSW_ACTL_CLEAR_PEND 0x8
72#define SCSW_ACTL_HALT_PEND 0x10
73#define SCSW_ACTL_START_PEND 0x20
74#define SCSW_ACTL_RESUME_PEND 0x40
75
76#define SCSW_STCTL_STATUS_PEND 0x1
77#define SCSW_STCTL_SEC_STATUS 0x2
78#define SCSW_STCTL_PRIM_STATUS 0x4
79#define SCSW_STCTL_INTER_STATUS 0x8
80#define SCSW_STCTL_ALERT_STATUS 0x10
81
82#define DEV_STAT_ATTENTION 0x80
83#define DEV_STAT_STAT_MOD 0x40
84#define DEV_STAT_CU_END 0x20
85#define DEV_STAT_BUSY 0x10
86#define DEV_STAT_CHN_END 0x08
87#define DEV_STAT_DEV_END 0x04
88#define DEV_STAT_UNIT_CHECK 0x02
89#define DEV_STAT_UNIT_EXCEP 0x01
90
91#define SCHN_STAT_PCI 0x80
92#define SCHN_STAT_INCORR_LEN 0x40
93#define SCHN_STAT_PROG_CHECK 0x20
94#define SCHN_STAT_PROT_CHECK 0x10
95#define SCHN_STAT_CHN_DATA_CHK 0x08
96#define SCHN_STAT_CHN_CTRL_CHK 0x04
97#define SCHN_STAT_INTF_CTRL_CHK 0x02
98#define SCHN_STAT_CHAIN_CHECK 0x01
99
100/*
101 * architectured values for first sense byte
102 */
103#define SNS0_CMD_REJECT 0x80
104#define SNS_CMD_REJECT SNS0_CMD_REJEC
105#define SNS0_INTERVENTION_REQ 0x40
106#define SNS0_BUS_OUT_CHECK 0x20
107#define SNS0_EQUIPMENT_CHECK 0x10
108#define SNS0_DATA_CHECK 0x08
109#define SNS0_OVERRUN 0x04
110#define SNS0_INCOMPL_DOMAIN 0x01
111
112/*
113 * architectured values for second sense byte
114 */
115#define SNS1_PERM_ERR 0x80
116#define SNS1_INV_TRACK_FORMAT 0x40
117#define SNS1_EOC 0x20
118#define SNS1_MESSAGE_TO_OPER 0x10
119#define SNS1_NO_REC_FOUND 0x08
120#define SNS1_FILE_PROTECTED 0x04
121#define SNS1_WRITE_INHIBITED 0x02
122#define SNS1_INPRECISE_END 0x01
123
124/*
125 * architectured values for third sense byte
126 */
127#define SNS2_REQ_INH_WRITE 0x80
128#define SNS2_CORRECTABLE 0x40
129#define SNS2_FIRST_LOG_ERR 0x20
130#define SNS2_ENV_DATA_PRESENT 0x10
131#define SNS2_INPRECISE_END 0x04
132
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200133/**
134 * struct ccw1 - channel command word
135 * @cmd_code: command code
136 * @flags: flags, like IDA adressing, etc.
137 * @count: byte count
138 * @cda: data address
139 *
140 * The ccw is the basic structure to build channel programs that perform
141 * operations with the device or the control unit. Only Format-1 channel
142 * command words are supported.
143 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144struct ccw1 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200145 __u8 cmd_code;
146 __u8 flags;
147 __u16 count;
148 __u32 cda;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149} __attribute__ ((packed,aligned(8)));
150
151#define CCW_FLAG_DC 0x80
152#define CCW_FLAG_CC 0x40
153#define CCW_FLAG_SLI 0x20
154#define CCW_FLAG_SKIP 0x10
155#define CCW_FLAG_PCI 0x08
156#define CCW_FLAG_IDA 0x04
157#define CCW_FLAG_SUSPEND 0x02
158
159#define CCW_CMD_READ_IPL 0x02
160#define CCW_CMD_NOOP 0x03
161#define CCW_CMD_BASIC_SENSE 0x04
162#define CCW_CMD_TIC 0x08
163#define CCW_CMD_STLCK 0x14
164#define CCW_CMD_SENSE_PGID 0x34
165#define CCW_CMD_SUSPEND_RECONN 0x5B
166#define CCW_CMD_RDC 0x64
167#define CCW_CMD_RELEASE 0x94
168#define CCW_CMD_SET_PGID 0xAF
169#define CCW_CMD_SENSE_ID 0xE4
170#define CCW_CMD_DCTL 0xF3
171
172#define SENSE_MAX_COUNT 0x20
173
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200174/**
175 * struct erw - extended report word
176 * @res0: reserved
177 * @auth: authorization check
178 * @pvrf: path-verification-required flag
179 * @cpt: channel-path timeout
180 * @fsavf: failing storage address validity flag
181 * @cons: concurrent sense
182 * @scavf: secondary ccw address validity flag
183 * @fsaf: failing storage address format
184 * @scnt: sense count, if @cons == %1
185 * @res16: reserved
186 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187struct erw {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200188 __u32 res0 : 3;
189 __u32 auth : 1;
190 __u32 pvrf : 1;
191 __u32 cpt : 1;
192 __u32 fsavf : 1;
193 __u32 cons : 1;
194 __u32 scavf : 1;
195 __u32 fsaf : 1;
196 __u32 scnt : 6;
197 __u32 res16 : 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198} __attribute__ ((packed));
199
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200200/**
201 * struct sublog - subchannel logout area
202 * @res0: reserved
203 * @esf: extended status flags
204 * @lpum: last path used mask
205 * @arep: ancillary report
206 * @fvf: field-validity flags
207 * @sacc: storage access code
208 * @termc: termination code
209 * @devsc: device-status check
210 * @serr: secondary error
211 * @ioerr: i/o-error alert
212 * @seqc: sequence code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 */
214struct sublog {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200215 __u32 res0 : 1;
216 __u32 esf : 7;
217 __u32 lpum : 8;
218 __u32 arep : 1;
219 __u32 fvf : 5;
220 __u32 sacc : 2;
221 __u32 termc : 2;
222 __u32 devsc : 1;
223 __u32 serr : 1;
224 __u32 ioerr : 1;
225 __u32 seqc : 3;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226} __attribute__ ((packed));
227
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200228/**
229 * struct esw0 - Format 0 Extended Status Word (ESW)
230 * @sublog: subchannel logout
231 * @erw: extended report word
232 * @faddr: failing storage address
233 * @saddr: secondary ccw address
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 */
235struct esw0 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200236 struct sublog sublog;
237 struct erw erw;
238 __u32 faddr[2];
239 __u32 saddr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240} __attribute__ ((packed));
241
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200242/**
243 * struct esw1 - Format 1 Extended Status Word (ESW)
244 * @zero0: reserved zeros
245 * @lpum: last path used mask
246 * @zero16: reserved zeros
247 * @erw: extended report word
248 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 */
250struct esw1 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200251 __u8 zero0;
252 __u8 lpum;
253 __u16 zero16;
254 struct erw erw;
255 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256} __attribute__ ((packed));
257
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200258/**
259 * struct esw2 - Format 2 Extended Status Word (ESW)
260 * @zero0: reserved zeros
261 * @lpum: last path used mask
262 * @dcti: device-connect-time interval
263 * @erw: extended report word
264 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 */
266struct esw2 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200267 __u8 zero0;
268 __u8 lpum;
269 __u16 dcti;
270 struct erw erw;
271 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272} __attribute__ ((packed));
273
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200274/**
275 * struct esw3 - Format 3 Extended Status Word (ESW)
276 * @zero0: reserved zeros
277 * @lpum: last path used mask
278 * @res: reserved
279 * @erw: extended report word
280 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 */
282struct esw3 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200283 __u8 zero0;
284 __u8 lpum;
285 __u16 res;
286 struct erw erw;
287 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288} __attribute__ ((packed));
289
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200290/**
291 * struct irb - interruption response block
292 * @scsw: subchannel status word
293 * @esw: extened status word, 4 formats
294 * @ecw: extended control word
295 *
296 * The irb that is handed to the device driver when an interrupt occurs. For
297 * solicited interrupts, the common I/O layer already performs checks whether
298 * a field is valid; a field not being valid is always passed as %0.
299 * If a unit check occured, @ecw may contain sense data; this is retrieved
300 * by the common I/O layer itself if the device doesn't support concurrent
301 * sense (so that the device driver never needs to perform basic sene itself).
302 * For unsolicited interrupts, the irb is passed as-is (expect for sense data,
303 * if applicable).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 */
305struct irb {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200306 struct scsw scsw;
307 union {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 struct esw0 esw0;
309 struct esw1 esw1;
310 struct esw2 esw2;
311 struct esw3 esw3;
312 } esw;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200313 __u8 ecw[32];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314} __attribute__ ((packed,aligned(4)));
315
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200316/**
317 * struct ciw - command information word (CIW) layout
318 * @et: entry type
319 * @reserved: reserved bits
320 * @ct: command type
321 * @cmd: command code
322 * @count: command count
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 */
324struct ciw {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200325 __u32 et : 2;
326 __u32 reserved : 2;
327 __u32 ct : 4;
328 __u32 cmd : 8;
329 __u32 count : 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330} __attribute__ ((packed));
331
332#define CIW_TYPE_RCD 0x0 /* read configuration data */
333#define CIW_TYPE_SII 0x1 /* set interface identifier */
334#define CIW_TYPE_RNI 0x2 /* read node identifier */
335
336/*
337 * Flags used as input parameters for do_IO()
338 */
339#define DOIO_ALLOW_SUSPEND 0x0001 /* allow for channel prog. suspend */
340#define DOIO_DENY_PREFETCH 0x0002 /* don't allow for CCW prefetch */
341#define DOIO_SUPPRESS_INTER 0x0004 /* suppress intermediate inter. */
342 /* ... for suspended CCWs */
343/* Device or subchannel gone. */
344#define CIO_GONE 0x0001
345/* No path to device. */
346#define CIO_NO_PATH 0x0002
347/* Device has appeared. */
348#define CIO_OPER 0x0004
349/* Sick revalidation of device. */
350#define CIO_REVALIDATE 0x0008
351
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200352/**
353 * struct ccw_dev_id - unique identifier for ccw devices
354 * @ssid: subchannel set id
355 * @devno: device number
356 *
357 * This structure is not directly based on any hardware structure. The
358 * hardware identifies a device by its device number and its subchannel,
359 * which is in turn identified by its id. In order to get a unique identifier
360 * for ccw devices across subchannel sets, @struct ccw_dev_id has been
361 * introduced.
362 */
Michael Holzheuff6b8ea2006-09-20 15:58:49 +0200363struct ccw_dev_id {
364 u8 ssid;
365 u16 devno;
366};
367
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200368/**
369 * ccw_device_id_is_equal() - compare two ccw_dev_ids
370 * @dev_id1: a ccw_dev_id
371 * @dev_id2: another ccw_dev_id
372 * Returns:
373 * %1 if the two structures are equal field-by-field,
374 * %0 if not.
375 * Context:
376 * any
377 */
Cornelia Huck78964262006-10-11 15:31:38 +0200378static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
379 struct ccw_dev_id *dev_id2)
380{
Cornelia Huckce26a852006-12-04 15:40:54 +0100381 if ((dev_id1->ssid == dev_id2->ssid) &&
382 (dev_id1->devno == dev_id2->devno))
383 return 1;
384 return 0;
Cornelia Huck78964262006-10-11 15:31:38 +0200385}
386
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387extern void wait_cons_dev(void);
388
Peter Oberparleiter40154b82006-06-29 14:57:03 +0200389extern void css_schedule_reprobe(void);
390
Michael Holzheuff6b8ea2006-09-20 15:58:49 +0200391extern void reipl_ccw_dev(struct ccw_dev_id *id);
392
Heiko Carstens6fc321f2007-04-27 16:01:25 +0200393struct cio_iplinfo {
394 u16 devno;
395 int is_qdio;
396};
397
398extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo);
399
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400#endif
401
402#endif