cio.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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 erw_eadm - EADM Subchannel extended report word
  75. * @b: aob error
  76. * @r: arsb error
  77. */
  78. struct erw_eadm {
  79. __u32 : 16;
  80. __u32 b : 1;
  81. __u32 r : 1;
  82. __u32 : 14;
  83. } __packed;
  84. /**
  85. * struct sublog - subchannel logout area
  86. * @res0: reserved
  87. * @esf: extended status flags
  88. * @lpum: last path used mask
  89. * @arep: ancillary report
  90. * @fvf: field-validity flags
  91. * @sacc: storage access code
  92. * @termc: termination code
  93. * @devsc: device-status check
  94. * @serr: secondary error
  95. * @ioerr: i/o-error alert
  96. * @seqc: sequence code
  97. */
  98. struct sublog {
  99. __u32 res0 : 1;
  100. __u32 esf : 7;
  101. __u32 lpum : 8;
  102. __u32 arep : 1;
  103. __u32 fvf : 5;
  104. __u32 sacc : 2;
  105. __u32 termc : 2;
  106. __u32 devsc : 1;
  107. __u32 serr : 1;
  108. __u32 ioerr : 1;
  109. __u32 seqc : 3;
  110. } __attribute__ ((packed));
  111. /**
  112. * struct esw0 - Format 0 Extended Status Word (ESW)
  113. * @sublog: subchannel logout
  114. * @erw: extended report word
  115. * @faddr: failing storage address
  116. * @saddr: secondary ccw address
  117. */
  118. struct esw0 {
  119. struct sublog sublog;
  120. struct erw erw;
  121. __u32 faddr[2];
  122. __u32 saddr;
  123. } __attribute__ ((packed));
  124. /**
  125. * struct esw1 - Format 1 Extended Status Word (ESW)
  126. * @zero0: reserved zeros
  127. * @lpum: last path used mask
  128. * @zero16: reserved zeros
  129. * @erw: extended report word
  130. * @zeros: three fullwords of zeros
  131. */
  132. struct esw1 {
  133. __u8 zero0;
  134. __u8 lpum;
  135. __u16 zero16;
  136. struct erw erw;
  137. __u32 zeros[3];
  138. } __attribute__ ((packed));
  139. /**
  140. * struct esw2 - Format 2 Extended Status Word (ESW)
  141. * @zero0: reserved zeros
  142. * @lpum: last path used mask
  143. * @dcti: device-connect-time interval
  144. * @erw: extended report word
  145. * @zeros: three fullwords of zeros
  146. */
  147. struct esw2 {
  148. __u8 zero0;
  149. __u8 lpum;
  150. __u16 dcti;
  151. struct erw erw;
  152. __u32 zeros[3];
  153. } __attribute__ ((packed));
  154. /**
  155. * struct esw3 - Format 3 Extended Status Word (ESW)
  156. * @zero0: reserved zeros
  157. * @lpum: last path used mask
  158. * @res: reserved
  159. * @erw: extended report word
  160. * @zeros: three fullwords of zeros
  161. */
  162. struct esw3 {
  163. __u8 zero0;
  164. __u8 lpum;
  165. __u16 res;
  166. struct erw erw;
  167. __u32 zeros[3];
  168. } __attribute__ ((packed));
  169. /**
  170. * struct esw_eadm - EADM Subchannel Extended Status Word (ESW)
  171. * @sublog: subchannel logout
  172. * @erw: extended report word
  173. */
  174. struct esw_eadm {
  175. __u32 sublog;
  176. struct erw_eadm erw;
  177. __u32 : 32;
  178. __u32 : 32;
  179. __u32 : 32;
  180. } __packed;
  181. /**
  182. * struct irb - interruption response block
  183. * @scsw: subchannel status word
  184. * @esw: extened status word
  185. * @ecw: extended control word
  186. *
  187. * The irb that is handed to the device driver when an interrupt occurs. For
  188. * solicited interrupts, the common I/O layer already performs checks whether
  189. * a field is valid; a field not being valid is always passed as %0.
  190. * If a unit check occurred, @ecw may contain sense data; this is retrieved
  191. * by the common I/O layer itself if the device doesn't support concurrent
  192. * sense (so that the device driver never needs to perform basic sene itself).
  193. * For unsolicited interrupts, the irb is passed as-is (expect for sense data,
  194. * if applicable).
  195. */
  196. struct irb {
  197. union scsw scsw;
  198. union {
  199. struct esw0 esw0;
  200. struct esw1 esw1;
  201. struct esw2 esw2;
  202. struct esw3 esw3;
  203. struct esw_eadm eadm;
  204. } esw;
  205. __u8 ecw[32];
  206. } __attribute__ ((packed,aligned(4)));
  207. /**
  208. * struct ciw - command information word (CIW) layout
  209. * @et: entry type
  210. * @reserved: reserved bits
  211. * @ct: command type
  212. * @cmd: command code
  213. * @count: command count
  214. */
  215. struct ciw {
  216. __u32 et : 2;
  217. __u32 reserved : 2;
  218. __u32 ct : 4;
  219. __u32 cmd : 8;
  220. __u32 count : 16;
  221. } __attribute__ ((packed));
  222. #define CIW_TYPE_RCD 0x0 /* read configuration data */
  223. #define CIW_TYPE_SII 0x1 /* set interface identifier */
  224. #define CIW_TYPE_RNI 0x2 /* read node identifier */
  225. /*
  226. * Flags used as input parameters for do_IO()
  227. */
  228. #define DOIO_ALLOW_SUSPEND 0x0001 /* allow for channel prog. suspend */
  229. #define DOIO_DENY_PREFETCH 0x0002 /* don't allow for CCW prefetch */
  230. #define DOIO_SUPPRESS_INTER 0x0004 /* suppress intermediate inter. */
  231. /* ... for suspended CCWs */
  232. /* Device or subchannel gone. */
  233. #define CIO_GONE 0x0001
  234. /* No path to device. */
  235. #define CIO_NO_PATH 0x0002
  236. /* Device has appeared. */
  237. #define CIO_OPER 0x0004
  238. /* Sick revalidation of device. */
  239. #define CIO_REVALIDATE 0x0008
  240. /* Device did not respond in time. */
  241. #define CIO_BOXED 0x0010
  242. /**
  243. * struct ccw_dev_id - unique identifier for ccw devices
  244. * @ssid: subchannel set id
  245. * @devno: device number
  246. *
  247. * This structure is not directly based on any hardware structure. The
  248. * hardware identifies a device by its device number and its subchannel,
  249. * which is in turn identified by its id. In order to get a unique identifier
  250. * for ccw devices across subchannel sets, @struct ccw_dev_id has been
  251. * introduced.
  252. */
  253. struct ccw_dev_id {
  254. u8 ssid;
  255. u16 devno;
  256. };
  257. /**
  258. * ccw_device_id_is_equal() - compare two ccw_dev_ids
  259. * @dev_id1: a ccw_dev_id
  260. * @dev_id2: another ccw_dev_id
  261. * Returns:
  262. * %1 if the two structures are equal field-by-field,
  263. * %0 if not.
  264. * Context:
  265. * any
  266. */
  267. static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
  268. struct ccw_dev_id *dev_id2)
  269. {
  270. if ((dev_id1->ssid == dev_id2->ssid) &&
  271. (dev_id1->devno == dev_id2->devno))
  272. return 1;
  273. return 0;
  274. }
  275. extern void wait_cons_dev(void);
  276. extern void css_schedule_reprobe(void);
  277. extern void reipl_ccw_dev(struct ccw_dev_id *id);
  278. struct cio_iplinfo {
  279. u16 devno;
  280. int is_qdio;
  281. };
  282. extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo);
  283. /* Function from drivers/s390/cio/chsc.c */
  284. int chsc_sstpc(void *page, unsigned int op, u16 ctrl);
  285. int chsc_sstpi(void *page, void *result, size_t size);
  286. #endif