cio.h 7.0 KB

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