blob: 7a38ca85190b84ba7842ffa6067c562bb1c4debd [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
Dong Jia Shid686f212017-03-17 04:17:42 +010036/**
37 * struct ccw0 - channel command word
38 * @cmd_code: command code
39 * @cda: data address
40 * @flags: flags, like IDA addressing, etc.
41 * @reserved: will be ignored
42 * @count: byte count
43 *
44 * The format-0 ccw structure.
45 */
46struct ccw0 {
47 __u8 cmd_code;
48 __u32 cda : 24;
49 __u8 flags;
50 __u8 reserved;
51 __u16 count;
52} __packed __aligned(8);
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#define CCW_FLAG_DC 0x80
55#define CCW_FLAG_CC 0x40
56#define CCW_FLAG_SLI 0x20
57#define CCW_FLAG_SKIP 0x10
58#define CCW_FLAG_PCI 0x08
59#define CCW_FLAG_IDA 0x04
60#define CCW_FLAG_SUSPEND 0x02
61
62#define CCW_CMD_READ_IPL 0x02
63#define CCW_CMD_NOOP 0x03
64#define CCW_CMD_BASIC_SENSE 0x04
65#define CCW_CMD_TIC 0x08
66#define CCW_CMD_STLCK 0x14
67#define CCW_CMD_SENSE_PGID 0x34
68#define CCW_CMD_SUSPEND_RECONN 0x5B
69#define CCW_CMD_RDC 0x64
70#define CCW_CMD_RELEASE 0x94
71#define CCW_CMD_SET_PGID 0xAF
72#define CCW_CMD_SENSE_ID 0xE4
73#define CCW_CMD_DCTL 0xF3
74
75#define SENSE_MAX_COUNT 0x20
76
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020077/**
78 * struct erw - extended report word
79 * @res0: reserved
80 * @auth: authorization check
81 * @pvrf: path-verification-required flag
82 * @cpt: channel-path timeout
83 * @fsavf: failing storage address validity flag
84 * @cons: concurrent sense
85 * @scavf: secondary ccw address validity flag
86 * @fsaf: failing storage address format
87 * @scnt: sense count, if @cons == %1
88 * @res16: reserved
89 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070090struct erw {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020091 __u32 res0 : 3;
92 __u32 auth : 1;
93 __u32 pvrf : 1;
94 __u32 cpt : 1;
95 __u32 fsavf : 1;
96 __u32 cons : 1;
97 __u32 scavf : 1;
98 __u32 fsaf : 1;
99 __u32 scnt : 6;
100 __u32 res16 : 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101} __attribute__ ((packed));
102
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200103/**
Sebastian Ottd2fc439b2012-08-28 16:44:51 +0200104 * struct erw_eadm - EADM Subchannel extended report word
105 * @b: aob error
106 * @r: arsb error
107 */
108struct erw_eadm {
109 __u32 : 16;
110 __u32 b : 1;
111 __u32 r : 1;
112 __u32 : 14;
113} __packed;
114
115/**
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200116 * struct sublog - subchannel logout area
117 * @res0: reserved
118 * @esf: extended status flags
119 * @lpum: last path used mask
120 * @arep: ancillary report
121 * @fvf: field-validity flags
122 * @sacc: storage access code
123 * @termc: termination code
124 * @devsc: device-status check
125 * @serr: secondary error
126 * @ioerr: i/o-error alert
127 * @seqc: sequence code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 */
129struct sublog {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200130 __u32 res0 : 1;
131 __u32 esf : 7;
132 __u32 lpum : 8;
133 __u32 arep : 1;
134 __u32 fvf : 5;
135 __u32 sacc : 2;
136 __u32 termc : 2;
137 __u32 devsc : 1;
138 __u32 serr : 1;
139 __u32 ioerr : 1;
140 __u32 seqc : 3;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141} __attribute__ ((packed));
142
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200143/**
144 * struct esw0 - Format 0 Extended Status Word (ESW)
145 * @sublog: subchannel logout
146 * @erw: extended report word
147 * @faddr: failing storage address
148 * @saddr: secondary ccw address
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 */
150struct esw0 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200151 struct sublog sublog;
152 struct erw erw;
153 __u32 faddr[2];
154 __u32 saddr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155} __attribute__ ((packed));
156
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200157/**
158 * struct esw1 - Format 1 Extended Status Word (ESW)
159 * @zero0: reserved zeros
160 * @lpum: last path used mask
161 * @zero16: reserved zeros
162 * @erw: extended report word
163 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 */
165struct esw1 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200166 __u8 zero0;
167 __u8 lpum;
168 __u16 zero16;
169 struct erw erw;
170 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171} __attribute__ ((packed));
172
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200173/**
174 * struct esw2 - Format 2 Extended Status Word (ESW)
175 * @zero0: reserved zeros
176 * @lpum: last path used mask
177 * @dcti: device-connect-time interval
178 * @erw: extended report word
179 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 */
181struct esw2 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200182 __u8 zero0;
183 __u8 lpum;
184 __u16 dcti;
185 struct erw erw;
186 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187} __attribute__ ((packed));
188
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200189/**
190 * struct esw3 - Format 3 Extended Status Word (ESW)
191 * @zero0: reserved zeros
192 * @lpum: last path used mask
193 * @res: reserved
194 * @erw: extended report word
195 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 */
197struct esw3 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200198 __u8 zero0;
199 __u8 lpum;
200 __u16 res;
201 struct erw erw;
202 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203} __attribute__ ((packed));
204
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200205/**
Sebastian Ottd2fc439b2012-08-28 16:44:51 +0200206 * struct esw_eadm - EADM Subchannel Extended Status Word (ESW)
207 * @sublog: subchannel logout
208 * @erw: extended report word
209 */
210struct esw_eadm {
211 __u32 sublog;
212 struct erw_eadm erw;
213 __u32 : 32;
214 __u32 : 32;
215 __u32 : 32;
216} __packed;
217
218/**
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200219 * struct irb - interruption response block
220 * @scsw: subchannel status word
Masanari Iidae2278672014-02-18 22:54:36 +0900221 * @esw: extended status word
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200222 * @ecw: extended control word
223 *
224 * The irb that is handed to the device driver when an interrupt occurs. For
225 * solicited interrupts, the common I/O layer already performs checks whether
226 * a field is valid; a field not being valid is always passed as %0.
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300227 * If a unit check occurred, @ecw may contain sense data; this is retrieved
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200228 * by the common I/O layer itself if the device doesn't support concurrent
229 * sense (so that the device driver never needs to perform basic sene itself).
230 * For unsolicited interrupts, the irb is passed as-is (expect for sense data,
231 * if applicable).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 */
233struct irb {
Peter Oberparleiter23d805b2008-07-14 09:58:50 +0200234 union scsw scsw;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200235 union {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 struct esw0 esw0;
237 struct esw1 esw1;
238 struct esw2 esw2;
239 struct esw3 esw3;
Sebastian Ottd2fc439b2012-08-28 16:44:51 +0200240 struct esw_eadm eadm;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 } esw;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200242 __u8 ecw[32];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243} __attribute__ ((packed,aligned(4)));
244
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200245/**
246 * struct ciw - command information word (CIW) layout
247 * @et: entry type
248 * @reserved: reserved bits
249 * @ct: command type
250 * @cmd: command code
251 * @count: command count
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 */
253struct ciw {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200254 __u32 et : 2;
255 __u32 reserved : 2;
256 __u32 ct : 4;
257 __u32 cmd : 8;
258 __u32 count : 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259} __attribute__ ((packed));
260
261#define CIW_TYPE_RCD 0x0 /* read configuration data */
262#define CIW_TYPE_SII 0x1 /* set interface identifier */
263#define CIW_TYPE_RNI 0x2 /* read node identifier */
264
265/*
266 * Flags used as input parameters for do_IO()
267 */
268#define DOIO_ALLOW_SUSPEND 0x0001 /* allow for channel prog. suspend */
269#define DOIO_DENY_PREFETCH 0x0002 /* don't allow for CCW prefetch */
270#define DOIO_SUPPRESS_INTER 0x0004 /* suppress intermediate inter. */
271 /* ... for suspended CCWs */
272/* Device or subchannel gone. */
273#define CIO_GONE 0x0001
274/* No path to device. */
275#define CIO_NO_PATH 0x0002
276/* Device has appeared. */
277#define CIO_OPER 0x0004
278/* Sick revalidation of device. */
279#define CIO_REVALIDATE 0x0008
Sebastian Ott47593bf2009-03-31 19:16:05 +0200280/* Device did not respond in time. */
281#define CIO_BOXED 0x0010
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200283/**
284 * struct ccw_dev_id - unique identifier for ccw devices
285 * @ssid: subchannel set id
286 * @devno: device number
287 *
288 * This structure is not directly based on any hardware structure. The
289 * hardware identifies a device by its device number and its subchannel,
290 * which is in turn identified by its id. In order to get a unique identifier
291 * for ccw devices across subchannel sets, @struct ccw_dev_id has been
292 * introduced.
293 */
Michael Holzheuff6b8ea2006-09-20 15:58:49 +0200294struct ccw_dev_id {
295 u8 ssid;
296 u16 devno;
297};
298
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200299/**
300 * ccw_device_id_is_equal() - compare two ccw_dev_ids
301 * @dev_id1: a ccw_dev_id
302 * @dev_id2: another ccw_dev_id
303 * Returns:
304 * %1 if the two structures are equal field-by-field,
305 * %0 if not.
306 * Context:
307 * any
308 */
Cornelia Huck78964262006-10-11 15:31:38 +0200309static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
310 struct ccw_dev_id *dev_id2)
311{
Cornelia Huckce26a852006-12-04 15:40:54 +0100312 if ((dev_id1->ssid == dev_id2->ssid) &&
313 (dev_id1->devno == dev_id2->devno))
314 return 1;
315 return 0;
Cornelia Huck78964262006-10-11 15:31:38 +0200316}
317
Sebastian Ott9d49f862015-09-21 18:40:33 +0200318/**
319 * pathmask_to_pos() - find the position of the left-most bit in a pathmask
320 * @mask: pathmask with at least one bit set
321 */
322static inline u8 pathmask_to_pos(u8 mask)
323{
324 return 8 - ffs(mask);
325}
326
Sebastian Ott77e844b2013-08-29 19:36:49 +0200327void channel_subsystem_reinit(void);
Peter Oberparleiter40154b82006-06-29 14:57:03 +0200328extern void css_schedule_reprobe(void);
329
Michael Holzheuff6b8ea2006-09-20 15:58:49 +0200330extern void reipl_ccw_dev(struct ccw_dev_id *id);
331
Heiko Carstens6fc321f2007-04-27 16:01:25 +0200332struct cio_iplinfo {
Sebastian Ott18e22a12015-06-29 18:39:54 +0200333 u8 ssid;
Heiko Carstens6fc321f2007-04-27 16:01:25 +0200334 u16 devno;
335 int is_qdio;
336};
337
338extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo);
339
Heiko Carstensa8061702008-04-17 07:46:26 +0200340/* Function from drivers/s390/cio/chsc.c */
Martin Schwidefsky2f82f572016-05-31 09:09:57 +0200341int chsc_sstpc(void *page, unsigned int op, u16 ctrl, u64 *clock_delta);
Heiko Carstensa8061702008-04-17 07:46:26 +0200342int chsc_sstpi(void *page, void *result, size_t size);
343
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344#endif