cio.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. /*
  2. * include/asm-s390/cio.h
  3. * include/asm-s390x/cio.h
  4. *
  5. * Common interface for I/O on S/390
  6. */
  7. #ifndef _ASM_S390_CIO_H_
  8. #define _ASM_S390_CIO_H_
  9. #include <linux/spinlock.h>
  10. #include <asm/types.h>
  11. #ifdef __KERNEL__
  12. #define LPM_ANYPATH 0xff
  13. #define __MAX_CSSID 0
  14. /**
  15. * struct scsw - subchannel status word
  16. * @key: subchannel key
  17. * @sctl: suspend control
  18. * @eswf: esw format
  19. * @cc: deferred condition code
  20. * @fmt: format
  21. * @pfch: prefetch
  22. * @isic: initial-status interruption control
  23. * @alcc: adress-limit checking control
  24. * @ssi: supress-suspended interruption
  25. * @zcc: zero condition code
  26. * @ectl: extended control
  27. * @pno: path not operational
  28. * @res: reserved
  29. * @fctl: function control
  30. * @actl: activity control
  31. * @stctl: status control
  32. * @cpa: channel program address
  33. * @dstat: device status
  34. * @cstat: subchannel status
  35. * @count: residual count
  36. */
  37. struct scsw {
  38. __u32 key : 4;
  39. __u32 sctl : 1;
  40. __u32 eswf : 1;
  41. __u32 cc : 2;
  42. __u32 fmt : 1;
  43. __u32 pfch : 1;
  44. __u32 isic : 1;
  45. __u32 alcc : 1;
  46. __u32 ssi : 1;
  47. __u32 zcc : 1;
  48. __u32 ectl : 1;
  49. __u32 pno : 1;
  50. __u32 res : 1;
  51. __u32 fctl : 3;
  52. __u32 actl : 7;
  53. __u32 stctl : 5;
  54. __u32 cpa;
  55. __u32 dstat : 8;
  56. __u32 cstat : 8;
  57. __u32 count : 16;
  58. } __attribute__ ((packed));
  59. #define SCSW_FCTL_CLEAR_FUNC 0x1
  60. #define SCSW_FCTL_HALT_FUNC 0x2
  61. #define SCSW_FCTL_START_FUNC 0x4
  62. #define SCSW_ACTL_SUSPENDED 0x1
  63. #define SCSW_ACTL_DEVACT 0x2
  64. #define SCSW_ACTL_SCHACT 0x4
  65. #define SCSW_ACTL_CLEAR_PEND 0x8
  66. #define SCSW_ACTL_HALT_PEND 0x10
  67. #define SCSW_ACTL_START_PEND 0x20
  68. #define SCSW_ACTL_RESUME_PEND 0x40
  69. #define SCSW_STCTL_STATUS_PEND 0x1
  70. #define SCSW_STCTL_SEC_STATUS 0x2
  71. #define SCSW_STCTL_PRIM_STATUS 0x4
  72. #define SCSW_STCTL_INTER_STATUS 0x8
  73. #define SCSW_STCTL_ALERT_STATUS 0x10
  74. #define DEV_STAT_ATTENTION 0x80
  75. #define DEV_STAT_STAT_MOD 0x40
  76. #define DEV_STAT_CU_END 0x20
  77. #define DEV_STAT_BUSY 0x10
  78. #define DEV_STAT_CHN_END 0x08
  79. #define DEV_STAT_DEV_END 0x04
  80. #define DEV_STAT_UNIT_CHECK 0x02
  81. #define DEV_STAT_UNIT_EXCEP 0x01
  82. #define SCHN_STAT_PCI 0x80
  83. #define SCHN_STAT_INCORR_LEN 0x40
  84. #define SCHN_STAT_PROG_CHECK 0x20
  85. #define SCHN_STAT_PROT_CHECK 0x10
  86. #define SCHN_STAT_CHN_DATA_CHK 0x08
  87. #define SCHN_STAT_CHN_CTRL_CHK 0x04
  88. #define SCHN_STAT_INTF_CTRL_CHK 0x02
  89. #define SCHN_STAT_CHAIN_CHECK 0x01
  90. /*
  91. * architectured values for first sense byte
  92. */
  93. #define SNS0_CMD_REJECT 0x80
  94. #define SNS_CMD_REJECT SNS0_CMD_REJEC
  95. #define SNS0_INTERVENTION_REQ 0x40
  96. #define SNS0_BUS_OUT_CHECK 0x20
  97. #define SNS0_EQUIPMENT_CHECK 0x10
  98. #define SNS0_DATA_CHECK 0x08
  99. #define SNS0_OVERRUN 0x04
  100. #define SNS0_INCOMPL_DOMAIN 0x01
  101. /*
  102. * architectured values for second sense byte
  103. */
  104. #define SNS1_PERM_ERR 0x80
  105. #define SNS1_INV_TRACK_FORMAT 0x40
  106. #define SNS1_EOC 0x20
  107. #define SNS1_MESSAGE_TO_OPER 0x10
  108. #define SNS1_NO_REC_FOUND 0x08
  109. #define SNS1_FILE_PROTECTED 0x04
  110. #define SNS1_WRITE_INHIBITED 0x02
  111. #define SNS1_INPRECISE_END 0x01
  112. /*
  113. * architectured values for third sense byte
  114. */
  115. #define SNS2_REQ_INH_WRITE 0x80
  116. #define SNS2_CORRECTABLE 0x40
  117. #define SNS2_FIRST_LOG_ERR 0x20
  118. #define SNS2_ENV_DATA_PRESENT 0x10
  119. #define SNS2_INPRECISE_END 0x04
  120. /**
  121. * struct ccw1 - channel command word
  122. * @cmd_code: command code
  123. * @flags: flags, like IDA adressing, etc.
  124. * @count: byte count
  125. * @cda: data address
  126. *
  127. * The ccw is the basic structure to build channel programs that perform
  128. * operations with the device or the control unit. Only Format-1 channel
  129. * command words are supported.
  130. */
  131. struct ccw1 {
  132. __u8 cmd_code;
  133. __u8 flags;
  134. __u16 count;
  135. __u32 cda;
  136. } __attribute__ ((packed,aligned(8)));
  137. #define CCW_FLAG_DC 0x80
  138. #define CCW_FLAG_CC 0x40
  139. #define CCW_FLAG_SLI 0x20
  140. #define CCW_FLAG_SKIP 0x10
  141. #define CCW_FLAG_PCI 0x08
  142. #define CCW_FLAG_IDA 0x04
  143. #define CCW_FLAG_SUSPEND 0x02
  144. #define CCW_CMD_READ_IPL 0x02
  145. #define CCW_CMD_NOOP 0x03
  146. #define CCW_CMD_BASIC_SENSE 0x04
  147. #define CCW_CMD_TIC 0x08
  148. #define CCW_CMD_STLCK 0x14
  149. #define CCW_CMD_SENSE_PGID 0x34
  150. #define CCW_CMD_SUSPEND_RECONN 0x5B
  151. #define CCW_CMD_RDC 0x64
  152. #define CCW_CMD_RELEASE 0x94
  153. #define CCW_CMD_SET_PGID 0xAF
  154. #define CCW_CMD_SENSE_ID 0xE4
  155. #define CCW_CMD_DCTL 0xF3
  156. #define SENSE_MAX_COUNT 0x20
  157. /**
  158. * struct erw - extended report word
  159. * @res0: reserved
  160. * @auth: authorization check
  161. * @pvrf: path-verification-required flag
  162. * @cpt: channel-path timeout
  163. * @fsavf: failing storage address validity flag
  164. * @cons: concurrent sense
  165. * @scavf: secondary ccw address validity flag
  166. * @fsaf: failing storage address format
  167. * @scnt: sense count, if @cons == %1
  168. * @res16: reserved
  169. */
  170. struct erw {
  171. __u32 res0 : 3;
  172. __u32 auth : 1;
  173. __u32 pvrf : 1;
  174. __u32 cpt : 1;
  175. __u32 fsavf : 1;
  176. __u32 cons : 1;
  177. __u32 scavf : 1;
  178. __u32 fsaf : 1;
  179. __u32 scnt : 6;
  180. __u32 res16 : 16;
  181. } __attribute__ ((packed));
  182. /**
  183. * struct sublog - subchannel logout area
  184. * @res0: reserved
  185. * @esf: extended status flags
  186. * @lpum: last path used mask
  187. * @arep: ancillary report
  188. * @fvf: field-validity flags
  189. * @sacc: storage access code
  190. * @termc: termination code
  191. * @devsc: device-status check
  192. * @serr: secondary error
  193. * @ioerr: i/o-error alert
  194. * @seqc: sequence code
  195. */
  196. struct sublog {
  197. __u32 res0 : 1;
  198. __u32 esf : 7;
  199. __u32 lpum : 8;
  200. __u32 arep : 1;
  201. __u32 fvf : 5;
  202. __u32 sacc : 2;
  203. __u32 termc : 2;
  204. __u32 devsc : 1;
  205. __u32 serr : 1;
  206. __u32 ioerr : 1;
  207. __u32 seqc : 3;
  208. } __attribute__ ((packed));
  209. /**
  210. * struct esw0 - Format 0 Extended Status Word (ESW)
  211. * @sublog: subchannel logout
  212. * @erw: extended report word
  213. * @faddr: failing storage address
  214. * @saddr: secondary ccw address
  215. */
  216. struct esw0 {
  217. struct sublog sublog;
  218. struct erw erw;
  219. __u32 faddr[2];
  220. __u32 saddr;
  221. } __attribute__ ((packed));
  222. /**
  223. * struct esw1 - Format 1 Extended Status Word (ESW)
  224. * @zero0: reserved zeros
  225. * @lpum: last path used mask
  226. * @zero16: reserved zeros
  227. * @erw: extended report word
  228. * @zeros: three fullwords of zeros
  229. */
  230. struct esw1 {
  231. __u8 zero0;
  232. __u8 lpum;
  233. __u16 zero16;
  234. struct erw erw;
  235. __u32 zeros[3];
  236. } __attribute__ ((packed));
  237. /**
  238. * struct esw2 - Format 2 Extended Status Word (ESW)
  239. * @zero0: reserved zeros
  240. * @lpum: last path used mask
  241. * @dcti: device-connect-time interval
  242. * @erw: extended report word
  243. * @zeros: three fullwords of zeros
  244. */
  245. struct esw2 {
  246. __u8 zero0;
  247. __u8 lpum;
  248. __u16 dcti;
  249. struct erw erw;
  250. __u32 zeros[3];
  251. } __attribute__ ((packed));
  252. /**
  253. * struct esw3 - Format 3 Extended Status Word (ESW)
  254. * @zero0: reserved zeros
  255. * @lpum: last path used mask
  256. * @res: reserved
  257. * @erw: extended report word
  258. * @zeros: three fullwords of zeros
  259. */
  260. struct esw3 {
  261. __u8 zero0;
  262. __u8 lpum;
  263. __u16 res;
  264. struct erw erw;
  265. __u32 zeros[3];
  266. } __attribute__ ((packed));
  267. /**
  268. * struct irb - interruption response block
  269. * @scsw: subchannel status word
  270. * @esw: extened status word, 4 formats
  271. * @ecw: extended control word
  272. *
  273. * The irb that is handed to the device driver when an interrupt occurs. For
  274. * solicited interrupts, the common I/O layer already performs checks whether
  275. * a field is valid; a field not being valid is always passed as %0.
  276. * If a unit check occured, @ecw may contain sense data; this is retrieved
  277. * by the common I/O layer itself if the device doesn't support concurrent
  278. * sense (so that the device driver never needs to perform basic sene itself).
  279. * For unsolicited interrupts, the irb is passed as-is (expect for sense data,
  280. * if applicable).
  281. */
  282. struct irb {
  283. struct scsw scsw;
  284. union {
  285. struct esw0 esw0;
  286. struct esw1 esw1;
  287. struct esw2 esw2;
  288. struct esw3 esw3;
  289. } esw;
  290. __u8 ecw[32];
  291. } __attribute__ ((packed,aligned(4)));
  292. /**
  293. * struct ciw - command information word (CIW) layout
  294. * @et: entry type
  295. * @reserved: reserved bits
  296. * @ct: command type
  297. * @cmd: command code
  298. * @count: command count
  299. */
  300. struct ciw {
  301. __u32 et : 2;
  302. __u32 reserved : 2;
  303. __u32 ct : 4;
  304. __u32 cmd : 8;
  305. __u32 count : 16;
  306. } __attribute__ ((packed));
  307. #define CIW_TYPE_RCD 0x0 /* read configuration data */
  308. #define CIW_TYPE_SII 0x1 /* set interface identifier */
  309. #define CIW_TYPE_RNI 0x2 /* read node identifier */
  310. /*
  311. * Flags used as input parameters for do_IO()
  312. */
  313. #define DOIO_ALLOW_SUSPEND 0x0001 /* allow for channel prog. suspend */
  314. #define DOIO_DENY_PREFETCH 0x0002 /* don't allow for CCW prefetch */
  315. #define DOIO_SUPPRESS_INTER 0x0004 /* suppress intermediate inter. */
  316. /* ... for suspended CCWs */
  317. /* Device or subchannel gone. */
  318. #define CIO_GONE 0x0001
  319. /* No path to device. */
  320. #define CIO_NO_PATH 0x0002
  321. /* Device has appeared. */
  322. #define CIO_OPER 0x0004
  323. /* Sick revalidation of device. */
  324. #define CIO_REVALIDATE 0x0008
  325. /**
  326. * struct ccw_dev_id - unique identifier for ccw devices
  327. * @ssid: subchannel set id
  328. * @devno: device number
  329. *
  330. * This structure is not directly based on any hardware structure. The
  331. * hardware identifies a device by its device number and its subchannel,
  332. * which is in turn identified by its id. In order to get a unique identifier
  333. * for ccw devices across subchannel sets, @struct ccw_dev_id has been
  334. * introduced.
  335. */
  336. struct ccw_dev_id {
  337. u8 ssid;
  338. u16 devno;
  339. };
  340. /**
  341. * ccw_device_id_is_equal() - compare two ccw_dev_ids
  342. * @dev_id1: a ccw_dev_id
  343. * @dev_id2: another ccw_dev_id
  344. * Returns:
  345. * %1 if the two structures are equal field-by-field,
  346. * %0 if not.
  347. * Context:
  348. * any
  349. */
  350. static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
  351. struct ccw_dev_id *dev_id2)
  352. {
  353. if ((dev_id1->ssid == dev_id2->ssid) &&
  354. (dev_id1->devno == dev_id2->devno))
  355. return 1;
  356. return 0;
  357. }
  358. extern void wait_cons_dev(void);
  359. extern void css_schedule_reprobe(void);
  360. extern void reipl_ccw_dev(struct ccw_dev_id *id);
  361. struct cio_iplinfo {
  362. u16 devno;
  363. int is_qdio;
  364. };
  365. extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo);
  366. #endif
  367. #endif