cio.h 6.9 KB

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