cio.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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. * subchannel status word
  16. */
  17. struct scsw {
  18. __u32 key : 4; /* subchannel key */
  19. __u32 sctl : 1; /* suspend control */
  20. __u32 eswf : 1; /* ESW format */
  21. __u32 cc : 2; /* deferred condition code */
  22. __u32 fmt : 1; /* format */
  23. __u32 pfch : 1; /* prefetch */
  24. __u32 isic : 1; /* initial-status interruption control */
  25. __u32 alcc : 1; /* address-limit checking control */
  26. __u32 ssi : 1; /* supress-suspended interruption */
  27. __u32 zcc : 1; /* zero condition code */
  28. __u32 ectl : 1; /* extended control */
  29. __u32 pno : 1; /* path not operational */
  30. __u32 res : 1; /* reserved */
  31. __u32 fctl : 3; /* function control */
  32. __u32 actl : 7; /* activity control */
  33. __u32 stctl : 5; /* status control */
  34. __u32 cpa; /* channel program address */
  35. __u32 dstat : 8; /* device status */
  36. __u32 cstat : 8; /* subchannel status */
  37. __u32 count : 16; /* residual count */
  38. } __attribute__ ((packed));
  39. #define SCSW_FCTL_CLEAR_FUNC 0x1
  40. #define SCSW_FCTL_HALT_FUNC 0x2
  41. #define SCSW_FCTL_START_FUNC 0x4
  42. #define SCSW_ACTL_SUSPENDED 0x1
  43. #define SCSW_ACTL_DEVACT 0x2
  44. #define SCSW_ACTL_SCHACT 0x4
  45. #define SCSW_ACTL_CLEAR_PEND 0x8
  46. #define SCSW_ACTL_HALT_PEND 0x10
  47. #define SCSW_ACTL_START_PEND 0x20
  48. #define SCSW_ACTL_RESUME_PEND 0x40
  49. #define SCSW_STCTL_STATUS_PEND 0x1
  50. #define SCSW_STCTL_SEC_STATUS 0x2
  51. #define SCSW_STCTL_PRIM_STATUS 0x4
  52. #define SCSW_STCTL_INTER_STATUS 0x8
  53. #define SCSW_STCTL_ALERT_STATUS 0x10
  54. #define DEV_STAT_ATTENTION 0x80
  55. #define DEV_STAT_STAT_MOD 0x40
  56. #define DEV_STAT_CU_END 0x20
  57. #define DEV_STAT_BUSY 0x10
  58. #define DEV_STAT_CHN_END 0x08
  59. #define DEV_STAT_DEV_END 0x04
  60. #define DEV_STAT_UNIT_CHECK 0x02
  61. #define DEV_STAT_UNIT_EXCEP 0x01
  62. #define SCHN_STAT_PCI 0x80
  63. #define SCHN_STAT_INCORR_LEN 0x40
  64. #define SCHN_STAT_PROG_CHECK 0x20
  65. #define SCHN_STAT_PROT_CHECK 0x10
  66. #define SCHN_STAT_CHN_DATA_CHK 0x08
  67. #define SCHN_STAT_CHN_CTRL_CHK 0x04
  68. #define SCHN_STAT_INTF_CTRL_CHK 0x02
  69. #define SCHN_STAT_CHAIN_CHECK 0x01
  70. /*
  71. * architectured values for first sense byte
  72. */
  73. #define SNS0_CMD_REJECT 0x80
  74. #define SNS_CMD_REJECT SNS0_CMD_REJEC
  75. #define SNS0_INTERVENTION_REQ 0x40
  76. #define SNS0_BUS_OUT_CHECK 0x20
  77. #define SNS0_EQUIPMENT_CHECK 0x10
  78. #define SNS0_DATA_CHECK 0x08
  79. #define SNS0_OVERRUN 0x04
  80. #define SNS0_INCOMPL_DOMAIN 0x01
  81. /*
  82. * architectured values for second sense byte
  83. */
  84. #define SNS1_PERM_ERR 0x80
  85. #define SNS1_INV_TRACK_FORMAT 0x40
  86. #define SNS1_EOC 0x20
  87. #define SNS1_MESSAGE_TO_OPER 0x10
  88. #define SNS1_NO_REC_FOUND 0x08
  89. #define SNS1_FILE_PROTECTED 0x04
  90. #define SNS1_WRITE_INHIBITED 0x02
  91. #define SNS1_INPRECISE_END 0x01
  92. /*
  93. * architectured values for third sense byte
  94. */
  95. #define SNS2_REQ_INH_WRITE 0x80
  96. #define SNS2_CORRECTABLE 0x40
  97. #define SNS2_FIRST_LOG_ERR 0x20
  98. #define SNS2_ENV_DATA_PRESENT 0x10
  99. #define SNS2_INPRECISE_END 0x04
  100. struct ccw1 {
  101. __u8 cmd_code; /* command code */
  102. __u8 flags; /* flags, like IDA addressing, etc. */
  103. __u16 count; /* byte count */
  104. __u32 cda; /* data address */
  105. } __attribute__ ((packed,aligned(8)));
  106. #define CCW_FLAG_DC 0x80
  107. #define CCW_FLAG_CC 0x40
  108. #define CCW_FLAG_SLI 0x20
  109. #define CCW_FLAG_SKIP 0x10
  110. #define CCW_FLAG_PCI 0x08
  111. #define CCW_FLAG_IDA 0x04
  112. #define CCW_FLAG_SUSPEND 0x02
  113. #define CCW_CMD_READ_IPL 0x02
  114. #define CCW_CMD_NOOP 0x03
  115. #define CCW_CMD_BASIC_SENSE 0x04
  116. #define CCW_CMD_TIC 0x08
  117. #define CCW_CMD_STLCK 0x14
  118. #define CCW_CMD_SENSE_PGID 0x34
  119. #define CCW_CMD_SUSPEND_RECONN 0x5B
  120. #define CCW_CMD_RDC 0x64
  121. #define CCW_CMD_RELEASE 0x94
  122. #define CCW_CMD_SET_PGID 0xAF
  123. #define CCW_CMD_SENSE_ID 0xE4
  124. #define CCW_CMD_DCTL 0xF3
  125. #define SENSE_MAX_COUNT 0x20
  126. struct erw {
  127. __u32 res0 : 3; /* reserved */
  128. __u32 auth : 1; /* Authorization check */
  129. __u32 pvrf : 1; /* path-verification-required flag */
  130. __u32 cpt : 1; /* channel-path timeout */
  131. __u32 fsavf : 1; /* Failing storage address validity flag */
  132. __u32 cons : 1; /* concurrent-sense */
  133. __u32 scavf : 1; /* Secondary ccw address validity flag */
  134. __u32 fsaf : 1; /* Failing storage address format */
  135. __u32 scnt : 6; /* sense count if cons == 1 */
  136. __u32 res16 : 16; /* reserved */
  137. } __attribute__ ((packed));
  138. /*
  139. * subchannel logout area
  140. */
  141. struct sublog {
  142. __u32 res0 : 1; /* reserved */
  143. __u32 esf : 7; /* extended status flags */
  144. __u32 lpum : 8; /* last path used mask */
  145. __u32 arep : 1; /* ancillary report */
  146. __u32 fvf : 5; /* field-validity flags */
  147. __u32 sacc : 2; /* storage access code */
  148. __u32 termc : 2; /* termination code */
  149. __u32 devsc : 1; /* device-status check */
  150. __u32 serr : 1; /* secondary error */
  151. __u32 ioerr : 1; /* i/o-error alert */
  152. __u32 seqc : 3; /* sequence code */
  153. } __attribute__ ((packed));
  154. /*
  155. * Format 0 Extended Status Word (ESW)
  156. */
  157. struct esw0 {
  158. struct sublog sublog; /* subchannel logout */
  159. struct erw erw; /* extended report word */
  160. __u32 faddr[2]; /* failing storage address */
  161. __u32 saddr; /* secondary ccw address */
  162. } __attribute__ ((packed));
  163. /*
  164. * Format 1 Extended Status Word (ESW)
  165. */
  166. struct esw1 {
  167. __u8 zero0; /* reserved zeros */
  168. __u8 lpum; /* last path used mask */
  169. __u16 zero16; /* reserved zeros */
  170. struct erw erw; /* extended report word */
  171. __u32 zeros[3]; /* 2 fullwords of zeros */
  172. } __attribute__ ((packed));
  173. /*
  174. * Format 2 Extended Status Word (ESW)
  175. */
  176. struct esw2 {
  177. __u8 zero0; /* reserved zeros */
  178. __u8 lpum; /* last path used mask */
  179. __u16 dcti; /* device-connect-time interval */
  180. struct erw erw; /* extended report word */
  181. __u32 zeros[3]; /* 2 fullwords of zeros */
  182. } __attribute__ ((packed));
  183. /*
  184. * Format 3 Extended Status Word (ESW)
  185. */
  186. struct esw3 {
  187. __u8 zero0; /* reserved zeros */
  188. __u8 lpum; /* last path used mask */
  189. __u16 res; /* reserved */
  190. struct erw erw; /* extended report word */
  191. __u32 zeros[3]; /* 2 fullwords of zeros */
  192. } __attribute__ ((packed));
  193. /*
  194. * interruption response block
  195. */
  196. struct irb {
  197. struct scsw scsw; /* subchannel status word */
  198. union { /* extended status word, 4 formats */
  199. struct esw0 esw0;
  200. struct esw1 esw1;
  201. struct esw2 esw2;
  202. struct esw3 esw3;
  203. } esw;
  204. __u8 ecw[32]; /* extended control word */
  205. } __attribute__ ((packed,aligned(4)));
  206. /*
  207. * command information word (CIW) layout
  208. */
  209. struct ciw {
  210. __u32 et : 2; /* entry type */
  211. __u32 reserved : 2; /* reserved */
  212. __u32 ct : 4; /* command type */
  213. __u32 cmd : 8; /* command */
  214. __u32 count : 16; /* coun */
  215. } __attribute__ ((packed));
  216. #define CIW_TYPE_RCD 0x0 /* read configuration data */
  217. #define CIW_TYPE_SII 0x1 /* set interface identifier */
  218. #define CIW_TYPE_RNI 0x2 /* read node identifier */
  219. /*
  220. * Flags used as input parameters for do_IO()
  221. */
  222. #define DOIO_ALLOW_SUSPEND 0x0001 /* allow for channel prog. suspend */
  223. #define DOIO_DENY_PREFETCH 0x0002 /* don't allow for CCW prefetch */
  224. #define DOIO_SUPPRESS_INTER 0x0004 /* suppress intermediate inter. */
  225. /* ... for suspended CCWs */
  226. /* Device or subchannel gone. */
  227. #define CIO_GONE 0x0001
  228. /* No path to device. */
  229. #define CIO_NO_PATH 0x0002
  230. /* Device has appeared. */
  231. #define CIO_OPER 0x0004
  232. /* Sick revalidation of device. */
  233. #define CIO_REVALIDATE 0x0008
  234. struct diag210 {
  235. __u16 vrdcdvno : 16; /* device number (input) */
  236. __u16 vrdclen : 16; /* data block length (input) */
  237. __u32 vrdcvcla : 8; /* virtual device class (output) */
  238. __u32 vrdcvtyp : 8; /* virtual device type (output) */
  239. __u32 vrdcvsta : 8; /* virtual device status (output) */
  240. __u32 vrdcvfla : 8; /* virtual device flags (output) */
  241. __u32 vrdcrccl : 8; /* real device class (output) */
  242. __u32 vrdccrty : 8; /* real device type (output) */
  243. __u32 vrdccrmd : 8; /* real device model (output) */
  244. __u32 vrdccrft : 8; /* real device feature (output) */
  245. } __attribute__ ((packed,aligned(4)));
  246. struct ccw_dev_id {
  247. u8 ssid;
  248. u16 devno;
  249. };
  250. static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
  251. struct ccw_dev_id *dev_id2)
  252. {
  253. if ((dev_id1->ssid == dev_id2->ssid) &&
  254. (dev_id1->devno == dev_id2->devno))
  255. return 1;
  256. return 0;
  257. }
  258. extern int diag210(struct diag210 *addr);
  259. extern void wait_cons_dev(void);
  260. extern void css_schedule_reprobe(void);
  261. extern void reipl_ccw_dev(struct ccw_dev_id *id);
  262. struct cio_iplinfo {
  263. u16 devno;
  264. int is_qdio;
  265. };
  266. extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo);
  267. #endif
  268. #endif