]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
1da177e4 LT |
2 | * 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> | |
9d49f86d | 8 | #include <linux/bitops.h> |
1da177e4 LT |
9 | #include <asm/types.h> |
10 | ||
1da177e4 | 11 | #define LPM_ANYPATH 0xff |
e5854a58 | 12 | #define __MAX_CSSID 0 |
619506d5 CH |
13 | #define __MAX_SUBCHANNEL 65535 |
14 | #define __MAX_SSID 3 | |
1da177e4 | 15 | |
62733e5a | 16 | #include <asm/scsw.h> |
1da177e4 | 17 | |
b2ffd8e9 CH |
18 | /** |
19 | * struct ccw1 - channel command word | |
20 | * @cmd_code: command code | |
3ad2f3fb | 21 | * @flags: flags, like IDA addressing, etc. |
b2ffd8e9 CH |
22 | * @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 | */ | |
1da177e4 | 29 | struct ccw1 { |
b2ffd8e9 CH |
30 | __u8 cmd_code; |
31 | __u8 flags; | |
32 | __u16 count; | |
33 | __u32 cda; | |
1da177e4 LT |
34 | } __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 | ||
b2ffd8e9 CH |
59 | /** |
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 | */ | |
1da177e4 | 72 | struct erw { |
b2ffd8e9 CH |
73 | __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; | |
1da177e4 LT |
83 | } __attribute__ ((packed)); |
84 | ||
d2fc439b SO |
85 | /** |
86 | * struct erw_eadm - EADM Subchannel extended report word | |
87 | * @b: aob error | |
88 | * @r: arsb error | |
89 | */ | |
90 | struct erw_eadm { | |
91 | __u32 : 16; | |
92 | __u32 b : 1; | |
93 | __u32 r : 1; | |
94 | __u32 : 14; | |
95 | } __packed; | |
96 | ||
b2ffd8e9 CH |
97 | /** |
98 | * 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 | |
1da177e4 LT |
110 | */ |
111 | struct sublog { | |
b2ffd8e9 CH |
112 | __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; | |
1da177e4 LT |
123 | } __attribute__ ((packed)); |
124 | ||
b2ffd8e9 CH |
125 | /** |
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 | |
1da177e4 LT |
131 | */ |
132 | struct esw0 { | |
b2ffd8e9 CH |
133 | struct sublog sublog; |
134 | struct erw erw; | |
135 | __u32 faddr[2]; | |
136 | __u32 saddr; | |
1da177e4 LT |
137 | } __attribute__ ((packed)); |
138 | ||
b2ffd8e9 CH |
139 | /** |
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 | |
1da177e4 LT |
146 | */ |
147 | struct esw1 { | |
b2ffd8e9 CH |
148 | __u8 zero0; |
149 | __u8 lpum; | |
150 | __u16 zero16; | |
151 | struct erw erw; | |
152 | __u32 zeros[3]; | |
1da177e4 LT |
153 | } __attribute__ ((packed)); |
154 | ||
b2ffd8e9 CH |
155 | /** |
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 | |
1da177e4 LT |
162 | */ |
163 | struct esw2 { | |
b2ffd8e9 CH |
164 | __u8 zero0; |
165 | __u8 lpum; | |
166 | __u16 dcti; | |
167 | struct erw erw; | |
168 | __u32 zeros[3]; | |
1da177e4 LT |
169 | } __attribute__ ((packed)); |
170 | ||
b2ffd8e9 CH |
171 | /** |
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 | |
1da177e4 LT |
178 | */ |
179 | struct esw3 { | |
b2ffd8e9 CH |
180 | __u8 zero0; |
181 | __u8 lpum; | |
182 | __u16 res; | |
183 | struct erw erw; | |
184 | __u32 zeros[3]; | |
1da177e4 LT |
185 | } __attribute__ ((packed)); |
186 | ||
d2fc439b SO |
187 | /** |
188 | * struct esw_eadm - EADM Subchannel Extended Status Word (ESW) | |
189 | * @sublog: subchannel logout | |
190 | * @erw: extended report word | |
191 | */ | |
192 | struct esw_eadm { | |
193 | __u32 sublog; | |
194 | struct erw_eadm erw; | |
195 | __u32 : 32; | |
196 | __u32 : 32; | |
197 | __u32 : 32; | |
198 | } __packed; | |
199 | ||
b2ffd8e9 CH |
200 | /** |
201 | * struct irb - interruption response block | |
202 | * @scsw: subchannel status word | |
e227867f | 203 | * @esw: extended status word |
b2ffd8e9 CH |
204 | * @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. | |
25985edc | 209 | * If a unit check occurred, @ecw may contain sense data; this is retrieved |
b2ffd8e9 CH |
210 | * 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). | |
1da177e4 LT |
214 | */ |
215 | struct irb { | |
23d805b6 | 216 | union scsw scsw; |
b2ffd8e9 | 217 | union { |
1da177e4 LT |
218 | struct esw0 esw0; |
219 | struct esw1 esw1; | |
220 | struct esw2 esw2; | |
221 | struct esw3 esw3; | |
d2fc439b | 222 | struct esw_eadm eadm; |
1da177e4 | 223 | } esw; |
b2ffd8e9 | 224 | __u8 ecw[32]; |
1da177e4 LT |
225 | } __attribute__ ((packed,aligned(4))); |
226 | ||
b2ffd8e9 CH |
227 | /** |
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 | |
1da177e4 LT |
234 | */ |
235 | struct ciw { | |
b2ffd8e9 CH |
236 | __u32 et : 2; |
237 | __u32 reserved : 2; | |
238 | __u32 ct : 4; | |
239 | __u32 cmd : 8; | |
240 | __u32 count : 16; | |
1da177e4 LT |
241 | } __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 | |
47593bfa SO |
262 | /* Device did not respond in time. */ |
263 | #define CIO_BOXED 0x0010 | |
1da177e4 | 264 | |
b2ffd8e9 CH |
265 | /** |
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 | */ | |
ff6b8ea6 MH |
276 | struct ccw_dev_id { |
277 | u8 ssid; | |
278 | u16 devno; | |
279 | }; | |
280 | ||
b2ffd8e9 CH |
281 | /** |
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 | */ | |
78964268 CH |
291 | static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1, |
292 | struct ccw_dev_id *dev_id2) | |
293 | { | |
ce26a853 CH |
294 | if ((dev_id1->ssid == dev_id2->ssid) && |
295 | (dev_id1->devno == dev_id2->devno)) | |
296 | return 1; | |
297 | return 0; | |
78964268 CH |
298 | } |
299 | ||
9d49f86d SO |
300 | /** |
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 | */ | |
304 | static inline u8 pathmask_to_pos(u8 mask) | |
305 | { | |
306 | return 8 - ffs(mask); | |
307 | } | |
308 | ||
77e844b9 | 309 | void channel_subsystem_reinit(void); |
40154b82 PO |
310 | extern void css_schedule_reprobe(void); |
311 | ||
ff6b8ea6 MH |
312 | extern void reipl_ccw_dev(struct ccw_dev_id *id); |
313 | ||
6fc321fd | 314 | struct cio_iplinfo { |
18e22a17 | 315 | u8 ssid; |
6fc321fd HC |
316 | u16 devno; |
317 | int is_qdio; | |
318 | }; | |
319 | ||
320 | extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo); | |
321 | ||
a806170e HC |
322 | /* Function from drivers/s390/cio/chsc.c */ |
323 | int chsc_sstpc(void *page, unsigned int op, u16 ctrl); | |
324 | int chsc_sstpi(void *page, void *result, size_t size); | |
325 | ||
1da177e4 | 326 | #endif |