blob: 0c5d8ee657f06ecf8537f11ed93e4ecd6e04ee82 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * 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>
Sebastian Ott9d49f862015-09-21 18:40:33 +02008#include <linux/bitops.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <asm/types.h>
10
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#define LPM_ANYPATH 0xff
Peter Oberparleitere5854a52007-04-27 16:01:31 +020012#define __MAX_CSSID 0
Cornelia Huck619506d2012-04-02 18:22:45 +020013#define __MAX_SUBCHANNEL 65535
14#define __MAX_SSID 3
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
Heiko Carstens62733e52009-09-11 10:28:15 +020016#include <asm/scsw.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020018/**
19 * struct ccw1 - channel command word
20 * @cmd_code: command code
Daniel Mack3ad2f3f2010-02-03 08:01:28 +080021 * @flags: flags, like IDA addressing, etc.
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020022 * @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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070029struct ccw1 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020030 __u8 cmd_code;
31 __u8 flags;
32 __u16 count;
33 __u32 cda;
Linus Torvalds1da177e2005-04-16 15:20:36 -070034} __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
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020059/**
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070072struct erw {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020073 __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;
Linus Torvalds1da177e2005-04-16 15:20:36 -070083} __attribute__ ((packed));
84
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020085/**
Sebastian Ottd2fc439b2012-08-28 16:44:51 +020086 * struct erw_eadm - EADM Subchannel extended report word
87 * @b: aob error
88 * @r: arsb error
89 */
90struct erw_eadm {
91 __u32 : 16;
92 __u32 b : 1;
93 __u32 r : 1;
94 __u32 : 14;
95} __packed;
96
97/**
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020098 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 */
111struct sublog {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200112 __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;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123} __attribute__ ((packed));
124
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200125/**
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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 */
132struct esw0 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200133 struct sublog sublog;
134 struct erw erw;
135 __u32 faddr[2];
136 __u32 saddr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137} __attribute__ ((packed));
138
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200139/**
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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 */
147struct esw1 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200148 __u8 zero0;
149 __u8 lpum;
150 __u16 zero16;
151 struct erw erw;
152 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153} __attribute__ ((packed));
154
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200155/**
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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 */
163struct esw2 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200164 __u8 zero0;
165 __u8 lpum;
166 __u16 dcti;
167 struct erw erw;
168 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169} __attribute__ ((packed));
170
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200171/**
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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 */
179struct esw3 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200180 __u8 zero0;
181 __u8 lpum;
182 __u16 res;
183 struct erw erw;
184 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185} __attribute__ ((packed));
186
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200187/**
Sebastian Ottd2fc439b2012-08-28 16:44:51 +0200188 * struct esw_eadm - EADM Subchannel Extended Status Word (ESW)
189 * @sublog: subchannel logout
190 * @erw: extended report word
191 */
192struct esw_eadm {
193 __u32 sublog;
194 struct erw_eadm erw;
195 __u32 : 32;
196 __u32 : 32;
197 __u32 : 32;
198} __packed;
199
200/**
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200201 * struct irb - interruption response block
202 * @scsw: subchannel status word
Masanari Iidae2278672014-02-18 22:54:36 +0900203 * @esw: extended status word
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200204 * @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.
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300209 * If a unit check occurred, @ecw may contain sense data; this is retrieved
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200210 * 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).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 */
215struct irb {
Peter Oberparleiter23d805b2008-07-14 09:58:50 +0200216 union scsw scsw;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200217 union {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 struct esw0 esw0;
219 struct esw1 esw1;
220 struct esw2 esw2;
221 struct esw3 esw3;
Sebastian Ottd2fc439b2012-08-28 16:44:51 +0200222 struct esw_eadm eadm;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 } esw;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200224 __u8 ecw[32];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225} __attribute__ ((packed,aligned(4)));
226
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200227/**
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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 */
235struct ciw {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200236 __u32 et : 2;
237 __u32 reserved : 2;
238 __u32 ct : 4;
239 __u32 cmd : 8;
240 __u32 count : 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241} __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
Sebastian Ott47593bf2009-03-31 19:16:05 +0200262/* Device did not respond in time. */
263#define CIO_BOXED 0x0010
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200265/**
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 */
Michael Holzheuff6b8ea2006-09-20 15:58:49 +0200276struct ccw_dev_id {
277 u8 ssid;
278 u16 devno;
279};
280
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200281/**
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 */
Cornelia Huck78964262006-10-11 15:31:38 +0200291static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
292 struct ccw_dev_id *dev_id2)
293{
Cornelia Huckce26a852006-12-04 15:40:54 +0100294 if ((dev_id1->ssid == dev_id2->ssid) &&
295 (dev_id1->devno == dev_id2->devno))
296 return 1;
297 return 0;
Cornelia Huck78964262006-10-11 15:31:38 +0200298}
299
Sebastian Ott9d49f862015-09-21 18:40:33 +0200300/**
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 */
304static inline u8 pathmask_to_pos(u8 mask)
305{
306 return 8 - ffs(mask);
307}
308
Sebastian Ott77e844b2013-08-29 19:36:49 +0200309void channel_subsystem_reinit(void);
Peter Oberparleiter40154b82006-06-29 14:57:03 +0200310extern void css_schedule_reprobe(void);
311
Michael Holzheuff6b8ea2006-09-20 15:58:49 +0200312extern void reipl_ccw_dev(struct ccw_dev_id *id);
313
Heiko Carstens6fc321f2007-04-27 16:01:25 +0200314struct cio_iplinfo {
315 u16 devno;
316 int is_qdio;
317};
318
319extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo);
320
Heiko Carstensa8061702008-04-17 07:46:26 +0200321/* Function from drivers/s390/cio/chsc.c */
322int chsc_sstpc(void *page, unsigned int op, u16 ctrl);
323int chsc_sstpi(void *page, void *result, size_t size);
324
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325#endif