cio.h 7.0 KB

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