Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * Common interface for I/O on S/390 |
| 4 | */ |
| 5 | #ifndef _ASM_S390_CIO_H_ |
| 6 | #define _ASM_S390_CIO_H_ |
| 7 | |
| 8 | #include <linux/spinlock.h> |
Sebastian Ott | 9d49f86 | 2015-09-21 18:40:33 +0200 | [diff] [blame] | 9 | #include <linux/bitops.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <asm/types.h> |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #define LPM_ANYPATH 0xff |
Peter Oberparleiter | e5854a5 | 2007-04-27 16:01:31 +0200 | [diff] [blame] | 13 | #define __MAX_CSSID 0 |
Cornelia Huck | 619506d | 2012-04-02 18:22:45 +0200 | [diff] [blame] | 14 | #define __MAX_SUBCHANNEL 65535 |
| 15 | #define __MAX_SSID 3 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Heiko Carstens | 62733e5 | 2009-09-11 10:28:15 +0200 | [diff] [blame] | 17 | #include <asm/scsw.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 19 | /** |
| 20 | * struct ccw1 - channel command word |
| 21 | * @cmd_code: command code |
Daniel Mack | 3ad2f3f | 2010-02-03 08:01:28 +0800 | [diff] [blame] | 22 | * @flags: flags, like IDA addressing, etc. |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 23 | * @count: byte count |
| 24 | * @cda: data address |
| 25 | * |
| 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. |
| 29 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | struct ccw1 { |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 31 | __u8 cmd_code; |
| 32 | __u8 flags; |
| 33 | __u16 count; |
| 34 | __u32 cda; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | } __attribute__ ((packed,aligned(8))); |
| 36 | |
Dong Jia Shi | d686f21 | 2017-03-17 04:17:42 +0100 | [diff] [blame] | 37 | /** |
| 38 | * struct ccw0 - channel command word |
| 39 | * @cmd_code: command code |
| 40 | * @cda: data address |
| 41 | * @flags: flags, like IDA addressing, etc. |
| 42 | * @reserved: will be ignored |
| 43 | * @count: byte count |
| 44 | * |
| 45 | * The format-0 ccw structure. |
| 46 | */ |
| 47 | struct ccw0 { |
| 48 | __u8 cmd_code; |
| 49 | __u32 cda : 24; |
| 50 | __u8 flags; |
| 51 | __u8 reserved; |
| 52 | __u16 count; |
| 53 | } __packed __aligned(8); |
| 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
| 62 | |
| 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 |
| 75 | |
| 76 | #define SENSE_MAX_COUNT 0x20 |
| 77 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 78 | /** |
| 79 | * struct erw - extended report word |
| 80 | * @res0: reserved |
| 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 |
| 89 | * @res16: reserved |
| 90 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | struct erw { |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 92 | __u32 res0 : 3; |
| 93 | __u32 auth : 1; |
| 94 | __u32 pvrf : 1; |
| 95 | __u32 cpt : 1; |
| 96 | __u32 fsavf : 1; |
| 97 | __u32 cons : 1; |
| 98 | __u32 scavf : 1; |
| 99 | __u32 fsaf : 1; |
| 100 | __u32 scnt : 6; |
| 101 | __u32 res16 : 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | } __attribute__ ((packed)); |
| 103 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 104 | /** |
Sebastian Ott | d2fc439b | 2012-08-28 16:44:51 +0200 | [diff] [blame] | 105 | * struct erw_eadm - EADM Subchannel extended report word |
| 106 | * @b: aob error |
| 107 | * @r: arsb error |
| 108 | */ |
| 109 | struct erw_eadm { |
| 110 | __u32 : 16; |
| 111 | __u32 b : 1; |
| 112 | __u32 r : 1; |
| 113 | __u32 : 14; |
| 114 | } __packed; |
| 115 | |
| 116 | /** |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 117 | * struct sublog - subchannel logout area |
| 118 | * @res0: reserved |
| 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | */ |
| 130 | struct sublog { |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 131 | __u32 res0 : 1; |
| 132 | __u32 esf : 7; |
| 133 | __u32 lpum : 8; |
| 134 | __u32 arep : 1; |
| 135 | __u32 fvf : 5; |
| 136 | __u32 sacc : 2; |
| 137 | __u32 termc : 2; |
| 138 | __u32 devsc : 1; |
| 139 | __u32 serr : 1; |
| 140 | __u32 ioerr : 1; |
| 141 | __u32 seqc : 3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | } __attribute__ ((packed)); |
| 143 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 144 | /** |
| 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | */ |
| 151 | struct esw0 { |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 152 | struct sublog sublog; |
| 153 | struct erw erw; |
| 154 | __u32 faddr[2]; |
| 155 | __u32 saddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | } __attribute__ ((packed)); |
| 157 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 158 | /** |
| 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | */ |
| 166 | struct esw1 { |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 167 | __u8 zero0; |
| 168 | __u8 lpum; |
| 169 | __u16 zero16; |
| 170 | struct erw erw; |
| 171 | __u32 zeros[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | } __attribute__ ((packed)); |
| 173 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 174 | /** |
| 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | */ |
| 182 | struct esw2 { |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 183 | __u8 zero0; |
| 184 | __u8 lpum; |
| 185 | __u16 dcti; |
| 186 | struct erw erw; |
| 187 | __u32 zeros[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | } __attribute__ ((packed)); |
| 189 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 190 | /** |
| 191 | * struct esw3 - Format 3 Extended Status Word (ESW) |
| 192 | * @zero0: reserved zeros |
| 193 | * @lpum: last path used mask |
| 194 | * @res: reserved |
| 195 | * @erw: extended report word |
| 196 | * @zeros: three fullwords of zeros |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | */ |
| 198 | struct esw3 { |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 199 | __u8 zero0; |
| 200 | __u8 lpum; |
| 201 | __u16 res; |
| 202 | struct erw erw; |
| 203 | __u32 zeros[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | } __attribute__ ((packed)); |
| 205 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 206 | /** |
Sebastian Ott | d2fc439b | 2012-08-28 16:44:51 +0200 | [diff] [blame] | 207 | * struct esw_eadm - EADM Subchannel Extended Status Word (ESW) |
| 208 | * @sublog: subchannel logout |
| 209 | * @erw: extended report word |
| 210 | */ |
| 211 | struct esw_eadm { |
| 212 | __u32 sublog; |
| 213 | struct erw_eadm erw; |
| 214 | __u32 : 32; |
| 215 | __u32 : 32; |
| 216 | __u32 : 32; |
| 217 | } __packed; |
| 218 | |
| 219 | /** |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 220 | * struct irb - interruption response block |
| 221 | * @scsw: subchannel status word |
Masanari Iida | e227867 | 2014-02-18 22:54:36 +0900 | [diff] [blame] | 222 | * @esw: extended status word |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 223 | * @ecw: extended control word |
| 224 | * |
| 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. |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 228 | * 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] | 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, |
| 232 | * if applicable). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | */ |
| 234 | struct irb { |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame] | 235 | union scsw scsw; |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 236 | union { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | struct esw0 esw0; |
| 238 | struct esw1 esw1; |
| 239 | struct esw2 esw2; |
| 240 | struct esw3 esw3; |
Sebastian Ott | d2fc439b | 2012-08-28 16:44:51 +0200 | [diff] [blame] | 241 | struct esw_eadm eadm; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | } esw; |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 243 | __u8 ecw[32]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | } __attribute__ ((packed,aligned(4))); |
| 245 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 246 | /** |
| 247 | * struct ciw - command information word (CIW) layout |
| 248 | * @et: entry type |
| 249 | * @reserved: reserved bits |
| 250 | * @ct: command type |
| 251 | * @cmd: command code |
| 252 | * @count: command count |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | */ |
| 254 | struct ciw { |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 255 | __u32 et : 2; |
| 256 | __u32 reserved : 2; |
| 257 | __u32 ct : 4; |
| 258 | __u32 cmd : 8; |
| 259 | __u32 count : 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | } __attribute__ ((packed)); |
| 261 | |
| 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 */ |
| 265 | |
| 266 | /* |
| 267 | * Flags used as input parameters for do_IO() |
| 268 | */ |
| 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 |
Sebastian Ott | 47593bf | 2009-03-31 19:16:05 +0200 | [diff] [blame] | 281 | /* Device did not respond in time. */ |
| 282 | #define CIO_BOXED 0x0010 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 284 | /** |
| 285 | * struct ccw_dev_id - unique identifier for ccw devices |
| 286 | * @ssid: subchannel set id |
| 287 | * @devno: device number |
| 288 | * |
| 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 |
| 293 | * introduced. |
| 294 | */ |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 295 | struct ccw_dev_id { |
| 296 | u8 ssid; |
| 297 | u16 devno; |
| 298 | }; |
| 299 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 300 | /** |
| 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 |
| 304 | * Returns: |
| 305 | * %1 if the two structures are equal field-by-field, |
| 306 | * %0 if not. |
| 307 | * Context: |
| 308 | * any |
| 309 | */ |
Cornelia Huck | 7896426 | 2006-10-11 15:31:38 +0200 | [diff] [blame] | 310 | static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1, |
| 311 | struct ccw_dev_id *dev_id2) |
| 312 | { |
Cornelia Huck | ce26a85 | 2006-12-04 15:40:54 +0100 | [diff] [blame] | 313 | if ((dev_id1->ssid == dev_id2->ssid) && |
| 314 | (dev_id1->devno == dev_id2->devno)) |
| 315 | return 1; |
| 316 | return 0; |
Cornelia Huck | 7896426 | 2006-10-11 15:31:38 +0200 | [diff] [blame] | 317 | } |
| 318 | |
Sebastian Ott | 9d49f86 | 2015-09-21 18:40:33 +0200 | [diff] [blame] | 319 | /** |
| 320 | * pathmask_to_pos() - find the position of the left-most bit in a pathmask |
| 321 | * @mask: pathmask with at least one bit set |
| 322 | */ |
| 323 | static inline u8 pathmask_to_pos(u8 mask) |
| 324 | { |
| 325 | return 8 - ffs(mask); |
| 326 | } |
| 327 | |
Sebastian Ott | 77e844b | 2013-08-29 19:36:49 +0200 | [diff] [blame] | 328 | void channel_subsystem_reinit(void); |
Peter Oberparleiter | 40154b8 | 2006-06-29 14:57:03 +0200 | [diff] [blame] | 329 | extern void css_schedule_reprobe(void); |
| 330 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 331 | extern void reipl_ccw_dev(struct ccw_dev_id *id); |
| 332 | |
Heiko Carstens | 6fc321f | 2007-04-27 16:01:25 +0200 | [diff] [blame] | 333 | struct cio_iplinfo { |
Sebastian Ott | 18e22a1 | 2015-06-29 18:39:54 +0200 | [diff] [blame] | 334 | u8 ssid; |
Heiko Carstens | 6fc321f | 2007-04-27 16:01:25 +0200 | [diff] [blame] | 335 | u16 devno; |
| 336 | int is_qdio; |
| 337 | }; |
| 338 | |
| 339 | extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo); |
| 340 | |
Heiko Carstens | a806170 | 2008-04-17 07:46:26 +0200 | [diff] [blame] | 341 | /* Function from drivers/s390/cio/chsc.c */ |
Martin Schwidefsky | 2f82f57 | 2016-05-31 09:09:57 +0200 | [diff] [blame] | 342 | int chsc_sstpc(void *page, unsigned int op, u16 ctrl, u64 *clock_delta); |
Heiko Carstens | a806170 | 2008-04-17 07:46:26 +0200 | [diff] [blame] | 343 | int chsc_sstpi(void *page, void *result, size_t size); |
| 344 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | #endif |