blob: dc84a0171bb3d1a24c7fc8cd14345891feff9504 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Common interface for I/O on S/390
4 */
5#ifndef _ASM_S390_CIO_H_
6#define _ASM_S390_CIO_H_
7
8#include <linux/spinlock.h>
Sebastian Ott9d49f862015-09-21 18:40:33 +02009#include <linux/bitops.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <asm/types.h>
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#define LPM_ANYPATH 0xff
Peter Oberparleitere5854a52007-04-27 16:01:31 +020013#define __MAX_CSSID 0
Cornelia Huck619506d2012-04-02 18:22:45 +020014#define __MAX_SUBCHANNEL 65535
15#define __MAX_SSID 3
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Heiko Carstens62733e52009-09-11 10:28:15 +020017#include <asm/scsw.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020019/**
20 * struct ccw1 - channel command word
21 * @cmd_code: command code
Daniel Mack3ad2f3f2010-02-03 08:01:28 +080022 * @flags: flags, like IDA addressing, etc.
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020023 * @count: byte count
24 * @cda: data address
25 *
26 * The ccw is the basic structure to build channel programs that perform
27 * operations with the device or the control unit. Only Format-1 channel
28 * command words are supported.
29 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070030struct ccw1 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020031 __u8 cmd_code;
32 __u8 flags;
33 __u16 count;
34 __u32 cda;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035} __attribute__ ((packed,aligned(8)));
36
Dong Jia Shid686f212017-03-17 04:17:42 +010037/**
38 * struct ccw0 - channel command word
39 * @cmd_code: command code
40 * @cda: data address
41 * @flags: flags, like IDA addressing, etc.
42 * @reserved: will be ignored
43 * @count: byte count
44 *
45 * The format-0 ccw structure.
46 */
47struct ccw0 {
48 __u8 cmd_code;
49 __u32 cda : 24;
50 __u8 flags;
51 __u8 reserved;
52 __u16 count;
53} __packed __aligned(8);
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#define CCW_FLAG_DC 0x80
56#define CCW_FLAG_CC 0x40
57#define CCW_FLAG_SLI 0x20
58#define CCW_FLAG_SKIP 0x10
59#define CCW_FLAG_PCI 0x08
60#define CCW_FLAG_IDA 0x04
61#define CCW_FLAG_SUSPEND 0x02
62
63#define CCW_CMD_READ_IPL 0x02
64#define CCW_CMD_NOOP 0x03
65#define CCW_CMD_BASIC_SENSE 0x04
66#define CCW_CMD_TIC 0x08
67#define CCW_CMD_STLCK 0x14
68#define CCW_CMD_SENSE_PGID 0x34
69#define CCW_CMD_SUSPEND_RECONN 0x5B
70#define CCW_CMD_RDC 0x64
71#define CCW_CMD_RELEASE 0x94
72#define CCW_CMD_SET_PGID 0xAF
73#define CCW_CMD_SENSE_ID 0xE4
74#define CCW_CMD_DCTL 0xF3
75
76#define SENSE_MAX_COUNT 0x20
77
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020078/**
79 * struct erw - extended report word
80 * @res0: reserved
81 * @auth: authorization check
82 * @pvrf: path-verification-required flag
83 * @cpt: channel-path timeout
84 * @fsavf: failing storage address validity flag
85 * @cons: concurrent sense
86 * @scavf: secondary ccw address validity flag
87 * @fsaf: failing storage address format
88 * @scnt: sense count, if @cons == %1
89 * @res16: reserved
90 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070091struct erw {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020092 __u32 res0 : 3;
93 __u32 auth : 1;
94 __u32 pvrf : 1;
95 __u32 cpt : 1;
96 __u32 fsavf : 1;
97 __u32 cons : 1;
98 __u32 scavf : 1;
99 __u32 fsaf : 1;
100 __u32 scnt : 6;
101 __u32 res16 : 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102} __attribute__ ((packed));
103
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200104/**
Sebastian Ottd2fc439b2012-08-28 16:44:51 +0200105 * struct erw_eadm - EADM Subchannel extended report word
106 * @b: aob error
107 * @r: arsb error
108 */
109struct erw_eadm {
110 __u32 : 16;
111 __u32 b : 1;
112 __u32 r : 1;
113 __u32 : 14;
114} __packed;
115
116/**
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200117 * struct sublog - subchannel logout area
118 * @res0: reserved
119 * @esf: extended status flags
120 * @lpum: last path used mask
121 * @arep: ancillary report
122 * @fvf: field-validity flags
123 * @sacc: storage access code
124 * @termc: termination code
125 * @devsc: device-status check
126 * @serr: secondary error
127 * @ioerr: i/o-error alert
128 * @seqc: sequence code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 */
130struct sublog {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200131 __u32 res0 : 1;
132 __u32 esf : 7;
133 __u32 lpum : 8;
134 __u32 arep : 1;
135 __u32 fvf : 5;
136 __u32 sacc : 2;
137 __u32 termc : 2;
138 __u32 devsc : 1;
139 __u32 serr : 1;
140 __u32 ioerr : 1;
141 __u32 seqc : 3;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142} __attribute__ ((packed));
143
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200144/**
145 * struct esw0 - Format 0 Extended Status Word (ESW)
146 * @sublog: subchannel logout
147 * @erw: extended report word
148 * @faddr: failing storage address
149 * @saddr: secondary ccw address
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 */
151struct esw0 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200152 struct sublog sublog;
153 struct erw erw;
154 __u32 faddr[2];
155 __u32 saddr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156} __attribute__ ((packed));
157
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200158/**
159 * struct esw1 - Format 1 Extended Status Word (ESW)
160 * @zero0: reserved zeros
161 * @lpum: last path used mask
162 * @zero16: reserved zeros
163 * @erw: extended report word
164 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 */
166struct esw1 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200167 __u8 zero0;
168 __u8 lpum;
169 __u16 zero16;
170 struct erw erw;
171 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172} __attribute__ ((packed));
173
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200174/**
175 * struct esw2 - Format 2 Extended Status Word (ESW)
176 * @zero0: reserved zeros
177 * @lpum: last path used mask
178 * @dcti: device-connect-time interval
179 * @erw: extended report word
180 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 */
182struct esw2 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200183 __u8 zero0;
184 __u8 lpum;
185 __u16 dcti;
186 struct erw erw;
187 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188} __attribute__ ((packed));
189
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200190/**
191 * struct esw3 - Format 3 Extended Status Word (ESW)
192 * @zero0: reserved zeros
193 * @lpum: last path used mask
194 * @res: reserved
195 * @erw: extended report word
196 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 */
198struct esw3 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200199 __u8 zero0;
200 __u8 lpum;
201 __u16 res;
202 struct erw erw;
203 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204} __attribute__ ((packed));
205
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200206/**
Sebastian Ottd2fc439b2012-08-28 16:44:51 +0200207 * struct esw_eadm - EADM Subchannel Extended Status Word (ESW)
208 * @sublog: subchannel logout
209 * @erw: extended report word
210 */
211struct esw_eadm {
212 __u32 sublog;
213 struct erw_eadm erw;
214 __u32 : 32;
215 __u32 : 32;
216 __u32 : 32;
217} __packed;
218
219/**
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200220 * struct irb - interruption response block
221 * @scsw: subchannel status word
Masanari Iidae2278672014-02-18 22:54:36 +0900222 * @esw: extended status word
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200223 * @ecw: extended control word
224 *
225 * The irb that is handed to the device driver when an interrupt occurs. For
226 * solicited interrupts, the common I/O layer already performs checks whether
227 * a field is valid; a field not being valid is always passed as %0.
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300228 * If a unit check occurred, @ecw may contain sense data; this is retrieved
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200229 * by the common I/O layer itself if the device doesn't support concurrent
230 * sense (so that the device driver never needs to perform basic sene itself).
231 * For unsolicited interrupts, the irb is passed as-is (expect for sense data,
232 * if applicable).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 */
234struct irb {
Peter Oberparleiter23d805b2008-07-14 09:58:50 +0200235 union scsw scsw;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200236 union {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 struct esw0 esw0;
238 struct esw1 esw1;
239 struct esw2 esw2;
240 struct esw3 esw3;
Sebastian Ottd2fc439b2012-08-28 16:44:51 +0200241 struct esw_eadm eadm;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 } esw;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200243 __u8 ecw[32];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244} __attribute__ ((packed,aligned(4)));
245
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200246/**
247 * struct ciw - command information word (CIW) layout
248 * @et: entry type
249 * @reserved: reserved bits
250 * @ct: command type
251 * @cmd: command code
252 * @count: command count
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 */
254struct ciw {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200255 __u32 et : 2;
256 __u32 reserved : 2;
257 __u32 ct : 4;
258 __u32 cmd : 8;
259 __u32 count : 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260} __attribute__ ((packed));
261
262#define CIW_TYPE_RCD 0x0 /* read configuration data */
263#define CIW_TYPE_SII 0x1 /* set interface identifier */
264#define CIW_TYPE_RNI 0x2 /* read node identifier */
265
266/*
267 * Flags used as input parameters for do_IO()
268 */
269#define DOIO_ALLOW_SUSPEND 0x0001 /* allow for channel prog. suspend */
270#define DOIO_DENY_PREFETCH 0x0002 /* don't allow for CCW prefetch */
271#define DOIO_SUPPRESS_INTER 0x0004 /* suppress intermediate inter. */
272 /* ... for suspended CCWs */
273/* Device or subchannel gone. */
274#define CIO_GONE 0x0001
275/* No path to device. */
276#define CIO_NO_PATH 0x0002
277/* Device has appeared. */
278#define CIO_OPER 0x0004
279/* Sick revalidation of device. */
280#define CIO_REVALIDATE 0x0008
Sebastian Ott47593bf2009-03-31 19:16:05 +0200281/* Device did not respond in time. */
282#define CIO_BOXED 0x0010
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200284/**
285 * struct ccw_dev_id - unique identifier for ccw devices
286 * @ssid: subchannel set id
287 * @devno: device number
288 *
289 * This structure is not directly based on any hardware structure. The
290 * hardware identifies a device by its device number and its subchannel,
291 * which is in turn identified by its id. In order to get a unique identifier
292 * for ccw devices across subchannel sets, @struct ccw_dev_id has been
293 * introduced.
294 */
Michael Holzheuff6b8ea2006-09-20 15:58:49 +0200295struct ccw_dev_id {
296 u8 ssid;
297 u16 devno;
298};
299
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200300/**
301 * ccw_device_id_is_equal() - compare two ccw_dev_ids
302 * @dev_id1: a ccw_dev_id
303 * @dev_id2: another ccw_dev_id
304 * Returns:
305 * %1 if the two structures are equal field-by-field,
306 * %0 if not.
307 * Context:
308 * any
309 */
Cornelia Huck78964262006-10-11 15:31:38 +0200310static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
311 struct ccw_dev_id *dev_id2)
312{
Cornelia Huckce26a852006-12-04 15:40:54 +0100313 if ((dev_id1->ssid == dev_id2->ssid) &&
314 (dev_id1->devno == dev_id2->devno))
315 return 1;
316 return 0;
Cornelia Huck78964262006-10-11 15:31:38 +0200317}
318
Sebastian Ott9d49f862015-09-21 18:40:33 +0200319/**
320 * pathmask_to_pos() - find the position of the left-most bit in a pathmask
321 * @mask: pathmask with at least one bit set
322 */
323static inline u8 pathmask_to_pos(u8 mask)
324{
325 return 8 - ffs(mask);
326}
327
Sebastian Ott77e844b2013-08-29 19:36:49 +0200328void channel_subsystem_reinit(void);
Peter Oberparleiter40154b82006-06-29 14:57:03 +0200329extern void css_schedule_reprobe(void);
330
Michael Holzheuff6b8ea2006-09-20 15:58:49 +0200331extern void reipl_ccw_dev(struct ccw_dev_id *id);
332
Heiko Carstens6fc321f2007-04-27 16:01:25 +0200333struct cio_iplinfo {
Sebastian Ott18e22a12015-06-29 18:39:54 +0200334 u8 ssid;
Heiko Carstens6fc321f2007-04-27 16:01:25 +0200335 u16 devno;
336 int is_qdio;
337};
338
339extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo);
340
Heiko Carstensa8061702008-04-17 07:46:26 +0200341/* Function from drivers/s390/cio/chsc.c */
Martin Schwidefsky2f82f572016-05-31 09:09:57 +0200342int chsc_sstpc(void *page, unsigned int op, u16 ctrl, u64 *clock_delta);
Heiko Carstensa8061702008-04-17 07:46:26 +0200343int chsc_sstpi(void *page, void *result, size_t size);
344
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345#endif