cio.h 8.0 KB

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