1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Common interface for I/O on S/390
5 #ifndef _ASM_S390_CIO_H_
6 #define _ASM_S390_CIO_H_
8 #include <linux/spinlock.h>
9 #include <linux/bitops.h>
10 #include <asm/types.h>
12 #define LPM_ANYPATH 0xff
14 #define __MAX_SUBCHANNEL 65535
20 * struct ccw1 - channel command word
21 * @cmd_code: command code
22 * @flags: flags, like IDA addressing, etc.
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.
35 } __attribute__ ((packed
,aligned(8)));
38 * struct ccw0 - channel command word
39 * @cmd_code: command code
41 * @flags: flags, like IDA addressing, etc.
42 * @reserved: will be ignored
45 * The format-0 ccw structure.
53 } __packed
__aligned(8);
55 #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
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
76 #define SENSE_MAX_COUNT 0x20
79 * struct erw - extended report word
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
102 } __attribute__ ((packed
));
105 * struct erw_eadm - EADM Subchannel extended report word
117 * struct sublog - subchannel logout area
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
142 } __attribute__ ((packed
));
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
152 struct sublog sublog
;
156 } __attribute__ ((packed
));
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
172 } __attribute__ ((packed
));
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
188 } __attribute__ ((packed
));
191 * struct esw3 - Format 3 Extended Status Word (ESW)
192 * @zero0: reserved zeros
193 * @lpum: last path used mask
195 * @erw: extended report word
196 * @zeros: three fullwords of zeros
204 } __attribute__ ((packed
));
207 * struct esw_eadm - EADM Subchannel Extended Status Word (ESW)
208 * @sublog: subchannel logout
209 * @erw: extended report word
220 * struct irb - interruption response block
221 * @scsw: subchannel status word
222 * @esw: extended status word
223 * @ecw: extended control word
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.
228 * If a unit check occurred, @ecw may contain sense data; this is retrieved
229 * 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,
241 struct esw_eadm eadm
;
244 } __attribute__ ((packed
,aligned(4)));
247 * struct ciw - command information word (CIW) layout
249 * @reserved: reserved bits
252 * @count: command count
260 } __attribute__ ((packed
));
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 */
267 * Flags used as input parameters for do_IO()
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
281 /* Device did not respond in time. */
282 #define CIO_BOXED 0x0010
285 * struct ccw_dev_id - unique identifier for ccw devices
286 * @ssid: subchannel set id
287 * @devno: device number
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
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
305 * %1 if the two structures are equal field-by-field,
310 static inline int ccw_dev_id_is_equal(struct ccw_dev_id
*dev_id1
,
311 struct ccw_dev_id
*dev_id2
)
313 if ((dev_id1
->ssid
== dev_id2
->ssid
) &&
314 (dev_id1
->devno
== dev_id2
->devno
))
320 * pathmask_to_pos() - find the position of the left-most bit in a pathmask
321 * @mask: pathmask with at least one bit set
323 static inline u8
pathmask_to_pos(u8 mask
)
325 return 8 - ffs(mask
);
328 void channel_subsystem_reinit(void);
329 extern void css_schedule_reprobe(void);
331 extern void reipl_ccw_dev(struct ccw_dev_id
*id
);
339 extern int cio_get_iplinfo(struct cio_iplinfo
*iplinfo
);
341 /* Function from drivers/s390/cio/chsc.c */
342 int chsc_sstpc(void *page
, unsigned int op
, u16 ctrl
, u64
*clock_delta
);
343 int chsc_sstpi(void *page
, void *result
, size_t size
);