blob: 4c8d4d5b8bd2ca545a1e35dcacaa4f45b115c083 [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#define LPM_ANYPATH 0xff
Peter Oberparleitere5854a52007-04-27 16:01:31 +020014#define __MAX_CSSID 0
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/**
86 * struct sublog - subchannel logout area
87 * @res0: reserved
88 * @esf: extended status flags
89 * @lpum: last path used mask
90 * @arep: ancillary report
91 * @fvf: field-validity flags
92 * @sacc: storage access code
93 * @termc: termination code
94 * @devsc: device-status check
95 * @serr: secondary error
96 * @ioerr: i/o-error alert
97 * @seqc: sequence code
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 */
99struct sublog {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200100 __u32 res0 : 1;
101 __u32 esf : 7;
102 __u32 lpum : 8;
103 __u32 arep : 1;
104 __u32 fvf : 5;
105 __u32 sacc : 2;
106 __u32 termc : 2;
107 __u32 devsc : 1;
108 __u32 serr : 1;
109 __u32 ioerr : 1;
110 __u32 seqc : 3;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111} __attribute__ ((packed));
112
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200113/**
114 * struct esw0 - Format 0 Extended Status Word (ESW)
115 * @sublog: subchannel logout
116 * @erw: extended report word
117 * @faddr: failing storage address
118 * @saddr: secondary ccw address
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 */
120struct esw0 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200121 struct sublog sublog;
122 struct erw erw;
123 __u32 faddr[2];
124 __u32 saddr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125} __attribute__ ((packed));
126
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200127/**
128 * struct esw1 - Format 1 Extended Status Word (ESW)
129 * @zero0: reserved zeros
130 * @lpum: last path used mask
131 * @zero16: reserved zeros
132 * @erw: extended report word
133 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 */
135struct esw1 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200136 __u8 zero0;
137 __u8 lpum;
138 __u16 zero16;
139 struct erw erw;
140 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141} __attribute__ ((packed));
142
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200143/**
144 * struct esw2 - Format 2 Extended Status Word (ESW)
145 * @zero0: reserved zeros
146 * @lpum: last path used mask
147 * @dcti: device-connect-time interval
148 * @erw: extended report word
149 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 */
151struct esw2 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200152 __u8 zero0;
153 __u8 lpum;
154 __u16 dcti;
155 struct erw erw;
156 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157} __attribute__ ((packed));
158
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200159/**
160 * struct esw3 - Format 3 Extended Status Word (ESW)
161 * @zero0: reserved zeros
162 * @lpum: last path used mask
163 * @res: reserved
164 * @erw: extended report word
165 * @zeros: three fullwords of zeros
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 */
167struct esw3 {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200168 __u8 zero0;
169 __u8 lpum;
170 __u16 res;
171 struct erw erw;
172 __u32 zeros[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173} __attribute__ ((packed));
174
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200175/**
176 * struct irb - interruption response block
177 * @scsw: subchannel status word
178 * @esw: extened status word, 4 formats
179 * @ecw: extended control word
180 *
181 * The irb that is handed to the device driver when an interrupt occurs. For
182 * solicited interrupts, the common I/O layer already performs checks whether
183 * a field is valid; a field not being valid is always passed as %0.
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300184 * If a unit check occurred, @ecw may contain sense data; this is retrieved
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200185 * by the common I/O layer itself if the device doesn't support concurrent
186 * sense (so that the device driver never needs to perform basic sene itself).
187 * For unsolicited interrupts, the irb is passed as-is (expect for sense data,
188 * if applicable).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 */
190struct irb {
Peter Oberparleiter23d805b2008-07-14 09:58:50 +0200191 union scsw scsw;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200192 union {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 struct esw0 esw0;
194 struct esw1 esw1;
195 struct esw2 esw2;
196 struct esw3 esw3;
197 } esw;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200198 __u8 ecw[32];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199} __attribute__ ((packed,aligned(4)));
200
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200201/**
202 * struct ciw - command information word (CIW) layout
203 * @et: entry type
204 * @reserved: reserved bits
205 * @ct: command type
206 * @cmd: command code
207 * @count: command count
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 */
209struct ciw {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200210 __u32 et : 2;
211 __u32 reserved : 2;
212 __u32 ct : 4;
213 __u32 cmd : 8;
214 __u32 count : 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215} __attribute__ ((packed));
216
217#define CIW_TYPE_RCD 0x0 /* read configuration data */
218#define CIW_TYPE_SII 0x1 /* set interface identifier */
219#define CIW_TYPE_RNI 0x2 /* read node identifier */
220
221/*
222 * Flags used as input parameters for do_IO()
223 */
224#define DOIO_ALLOW_SUSPEND 0x0001 /* allow for channel prog. suspend */
225#define DOIO_DENY_PREFETCH 0x0002 /* don't allow for CCW prefetch */
226#define DOIO_SUPPRESS_INTER 0x0004 /* suppress intermediate inter. */
227 /* ... for suspended CCWs */
228/* Device or subchannel gone. */
229#define CIO_GONE 0x0001
230/* No path to device. */
231#define CIO_NO_PATH 0x0002
232/* Device has appeared. */
233#define CIO_OPER 0x0004
234/* Sick revalidation of device. */
235#define CIO_REVALIDATE 0x0008
Sebastian Ott47593bf2009-03-31 19:16:05 +0200236/* Device did not respond in time. */
237#define CIO_BOXED 0x0010
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200239/**
240 * struct ccw_dev_id - unique identifier for ccw devices
241 * @ssid: subchannel set id
242 * @devno: device number
243 *
244 * This structure is not directly based on any hardware structure. The
245 * hardware identifies a device by its device number and its subchannel,
246 * which is in turn identified by its id. In order to get a unique identifier
247 * for ccw devices across subchannel sets, @struct ccw_dev_id has been
248 * introduced.
249 */
Michael Holzheuff6b8ea2006-09-20 15:58:49 +0200250struct ccw_dev_id {
251 u8 ssid;
252 u16 devno;
253};
254
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200255/**
256 * ccw_device_id_is_equal() - compare two ccw_dev_ids
257 * @dev_id1: a ccw_dev_id
258 * @dev_id2: another ccw_dev_id
259 * Returns:
260 * %1 if the two structures are equal field-by-field,
261 * %0 if not.
262 * Context:
263 * any
264 */
Cornelia Huck78964262006-10-11 15:31:38 +0200265static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
266 struct ccw_dev_id *dev_id2)
267{
Cornelia Huckce26a852006-12-04 15:40:54 +0100268 if ((dev_id1->ssid == dev_id2->ssid) &&
269 (dev_id1->devno == dev_id2->devno))
270 return 1;
271 return 0;
Cornelia Huck78964262006-10-11 15:31:38 +0200272}
273
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274extern void wait_cons_dev(void);
275
Peter Oberparleiter40154b82006-06-29 14:57:03 +0200276extern void css_schedule_reprobe(void);
277
Michael Holzheuff6b8ea2006-09-20 15:58:49 +0200278extern void reipl_ccw_dev(struct ccw_dev_id *id);
279
Heiko Carstens6fc321f2007-04-27 16:01:25 +0200280struct cio_iplinfo {
281 u16 devno;
282 int is_qdio;
283};
284
285extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo);
286
Heiko Carstensa8061702008-04-17 07:46:26 +0200287/* Function from drivers/s390/cio/chsc.c */
288int chsc_sstpc(void *page, unsigned int op, u16 ctrl);
289int chsc_sstpi(void *page, void *result, size_t size);
290
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291#endif