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