xref: /openbmc/linux/arch/s390/include/asm/cio.h (revision 95e9fd10)
1 /*
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>
8 #include <asm/types.h>
9 
10 #define LPM_ANYPATH 0xff
11 #define __MAX_CSSID 0
12 
13 #include <asm/scsw.h>
14 
15 /**
16  * struct ccw1 - channel command word
17  * @cmd_code: command code
18  * @flags: flags, like IDA addressing, etc.
19  * @count: byte count
20  * @cda: data address
21  *
22  * The ccw is the basic structure to build channel programs that perform
23  * operations with the device or the control unit. Only Format-1 channel
24  * command words are supported.
25  */
26 struct ccw1 {
27 	__u8  cmd_code;
28 	__u8  flags;
29 	__u16 count;
30 	__u32 cda;
31 } __attribute__ ((packed,aligned(8)));
32 
33 #define CCW_FLAG_DC		0x80
34 #define CCW_FLAG_CC		0x40
35 #define CCW_FLAG_SLI		0x20
36 #define CCW_FLAG_SKIP		0x10
37 #define CCW_FLAG_PCI		0x08
38 #define CCW_FLAG_IDA		0x04
39 #define CCW_FLAG_SUSPEND	0x02
40 
41 #define CCW_CMD_READ_IPL	0x02
42 #define CCW_CMD_NOOP		0x03
43 #define CCW_CMD_BASIC_SENSE	0x04
44 #define CCW_CMD_TIC		0x08
45 #define CCW_CMD_STLCK           0x14
46 #define CCW_CMD_SENSE_PGID	0x34
47 #define CCW_CMD_SUSPEND_RECONN	0x5B
48 #define CCW_CMD_RDC		0x64
49 #define CCW_CMD_RELEASE		0x94
50 #define CCW_CMD_SET_PGID	0xAF
51 #define CCW_CMD_SENSE_ID	0xE4
52 #define CCW_CMD_DCTL		0xF3
53 
54 #define SENSE_MAX_COUNT		0x20
55 
56 /**
57  * struct erw - extended report word
58  * @res0: reserved
59  * @auth: authorization check
60  * @pvrf: path-verification-required flag
61  * @cpt: channel-path timeout
62  * @fsavf: failing storage address validity flag
63  * @cons: concurrent sense
64  * @scavf: secondary ccw address validity flag
65  * @fsaf: failing storage address format
66  * @scnt: sense count, if @cons == %1
67  * @res16: reserved
68  */
69 struct erw {
70 	__u32 res0  : 3;
71 	__u32 auth  : 1;
72 	__u32 pvrf  : 1;
73 	__u32 cpt   : 1;
74 	__u32 fsavf : 1;
75 	__u32 cons  : 1;
76 	__u32 scavf : 1;
77 	__u32 fsaf  : 1;
78 	__u32 scnt  : 6;
79 	__u32 res16 : 16;
80 } __attribute__ ((packed));
81 
82 /**
83  * struct sublog - subchannel logout area
84  * @res0: reserved
85  * @esf: extended status flags
86  * @lpum: last path used mask
87  * @arep: ancillary report
88  * @fvf: field-validity flags
89  * @sacc: storage access code
90  * @termc: termination code
91  * @devsc: device-status check
92  * @serr: secondary error
93  * @ioerr: i/o-error alert
94  * @seqc: sequence code
95  */
96 struct sublog {
97 	__u32 res0  : 1;
98 	__u32 esf   : 7;
99 	__u32 lpum  : 8;
100 	__u32 arep  : 1;
101 	__u32 fvf   : 5;
102 	__u32 sacc  : 2;
103 	__u32 termc : 2;
104 	__u32 devsc : 1;
105 	__u32 serr  : 1;
106 	__u32 ioerr : 1;
107 	__u32 seqc  : 3;
108 } __attribute__ ((packed));
109 
110 /**
111  * struct esw0 - Format 0 Extended Status Word (ESW)
112  * @sublog: subchannel logout
113  * @erw: extended report word
114  * @faddr: failing storage address
115  * @saddr: secondary ccw address
116  */
117 struct esw0 {
118 	struct sublog sublog;
119 	struct erw erw;
120 	__u32  faddr[2];
121 	__u32  saddr;
122 } __attribute__ ((packed));
123 
124 /**
125  * struct esw1 - Format 1 Extended Status Word (ESW)
126  * @zero0: reserved zeros
127  * @lpum: last path used mask
128  * @zero16: reserved zeros
129  * @erw: extended report word
130  * @zeros: three fullwords of zeros
131  */
132 struct esw1 {
133 	__u8  zero0;
134 	__u8  lpum;
135 	__u16 zero16;
136 	struct erw erw;
137 	__u32 zeros[3];
138 } __attribute__ ((packed));
139 
140 /**
141  * struct esw2 - Format 2 Extended Status Word (ESW)
142  * @zero0: reserved zeros
143  * @lpum: last path used mask
144  * @dcti: device-connect-time interval
145  * @erw: extended report word
146  * @zeros: three fullwords of zeros
147  */
148 struct esw2 {
149 	__u8  zero0;
150 	__u8  lpum;
151 	__u16 dcti;
152 	struct erw erw;
153 	__u32 zeros[3];
154 } __attribute__ ((packed));
155 
156 /**
157  * struct esw3 - Format 3 Extended Status Word (ESW)
158  * @zero0: reserved zeros
159  * @lpum: last path used mask
160  * @res: reserved
161  * @erw: extended report word
162  * @zeros: three fullwords of zeros
163  */
164 struct esw3 {
165 	__u8  zero0;
166 	__u8  lpum;
167 	__u16 res;
168 	struct erw erw;
169 	__u32 zeros[3];
170 } __attribute__ ((packed));
171 
172 /**
173  * struct irb - interruption response block
174  * @scsw: subchannel status word
175  * @esw: extened status word, 4 formats
176  * @ecw: extended control word
177  *
178  * The irb that is handed to the device driver when an interrupt occurs. For
179  * solicited interrupts, the common I/O layer already performs checks whether
180  * a field is valid; a field not being valid is always passed as %0.
181  * If a unit check occurred, @ecw may contain sense data; this is retrieved
182  * by the common I/O layer itself if the device doesn't support concurrent
183  * sense (so that the device driver never needs to perform basic sene itself).
184  * For unsolicited interrupts, the irb is passed as-is (expect for sense data,
185  * if applicable).
186  */
187 struct irb {
188 	union scsw scsw;
189 	union {
190 		struct esw0 esw0;
191 		struct esw1 esw1;
192 		struct esw2 esw2;
193 		struct esw3 esw3;
194 	} esw;
195 	__u8   ecw[32];
196 } __attribute__ ((packed,aligned(4)));
197 
198 /**
199  * struct ciw - command information word  (CIW) layout
200  * @et: entry type
201  * @reserved: reserved bits
202  * @ct: command type
203  * @cmd: command code
204  * @count: command count
205  */
206 struct ciw {
207 	__u32 et       :  2;
208 	__u32 reserved :  2;
209 	__u32 ct       :  4;
210 	__u32 cmd      :  8;
211 	__u32 count    : 16;
212 } __attribute__ ((packed));
213 
214 #define CIW_TYPE_RCD	0x0    	/* read configuration data */
215 #define CIW_TYPE_SII	0x1    	/* set interface identifier */
216 #define CIW_TYPE_RNI	0x2    	/* read node identifier */
217 
218 /*
219  * Flags used as input parameters for do_IO()
220  */
221 #define DOIO_ALLOW_SUSPEND	 0x0001 /* allow for channel prog. suspend */
222 #define DOIO_DENY_PREFETCH	 0x0002 /* don't allow for CCW prefetch */
223 #define DOIO_SUPPRESS_INTER	 0x0004 /* suppress intermediate inter. */
224 					/* ... for suspended CCWs */
225 /* Device or subchannel gone. */
226 #define CIO_GONE       0x0001
227 /* No path to device. */
228 #define CIO_NO_PATH    0x0002
229 /* Device has appeared. */
230 #define CIO_OPER       0x0004
231 /* Sick revalidation of device. */
232 #define CIO_REVALIDATE 0x0008
233 /* Device did not respond in time. */
234 #define CIO_BOXED      0x0010
235 
236 /**
237  * struct ccw_dev_id - unique identifier for ccw devices
238  * @ssid: subchannel set id
239  * @devno: device number
240  *
241  * This structure is not directly based on any hardware structure. The
242  * hardware identifies a device by its device number and its subchannel,
243  * which is in turn identified by its id. In order to get a unique identifier
244  * for ccw devices across subchannel sets, @struct ccw_dev_id has been
245  * introduced.
246  */
247 struct ccw_dev_id {
248 	u8 ssid;
249 	u16 devno;
250 };
251 
252 /**
253  * ccw_device_id_is_equal() - compare two ccw_dev_ids
254  * @dev_id1: a ccw_dev_id
255  * @dev_id2: another ccw_dev_id
256  * Returns:
257  *  %1 if the two structures are equal field-by-field,
258  *  %0 if not.
259  * Context:
260  *  any
261  */
262 static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
263 				      struct ccw_dev_id *dev_id2)
264 {
265 	if ((dev_id1->ssid == dev_id2->ssid) &&
266 	    (dev_id1->devno == dev_id2->devno))
267 		return 1;
268 	return 0;
269 }
270 
271 extern void wait_cons_dev(void);
272 
273 extern void css_schedule_reprobe(void);
274 
275 extern void reipl_ccw_dev(struct ccw_dev_id *id);
276 
277 struct cio_iplinfo {
278 	u16 devno;
279 	int is_qdio;
280 };
281 
282 extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo);
283 
284 /* Function from drivers/s390/cio/chsc.c */
285 int chsc_sstpc(void *page, unsigned int op, u16 ctrl);
286 int chsc_sstpi(void *page, void *result, size_t size);
287 
288 #endif
289