cio.h 7.6 KB

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