cio.h 7.4 KB

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