cio.h 7.8 KB

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