io_sch.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. #ifndef S390_IO_SCH_H
  2. #define S390_IO_SCH_H
  3. #include <linux/types.h>
  4. #include <asm/schid.h>
  5. #include <asm/ccwdev.h>
  6. #include "css.h"
  7. /*
  8. * command-mode operation request block
  9. */
  10. struct cmd_orb {
  11. u32 intparm; /* interruption parameter */
  12. u32 key : 4; /* flags, like key, suspend control, etc. */
  13. u32 spnd : 1; /* suspend control */
  14. u32 res1 : 1; /* reserved */
  15. u32 mod : 1; /* modification control */
  16. u32 sync : 1; /* synchronize control */
  17. u32 fmt : 1; /* format control */
  18. u32 pfch : 1; /* prefetch control */
  19. u32 isic : 1; /* initial-status-interruption control */
  20. u32 alcc : 1; /* address-limit-checking control */
  21. u32 ssic : 1; /* suppress-suspended-interr. control */
  22. u32 res2 : 1; /* reserved */
  23. u32 c64 : 1; /* IDAW/QDIO 64 bit control */
  24. u32 i2k : 1; /* IDAW 2/4kB block size control */
  25. u32 lpm : 8; /* logical path mask */
  26. u32 ils : 1; /* incorrect length */
  27. u32 zero : 6; /* reserved zeros */
  28. u32 orbx : 1; /* ORB extension control */
  29. u32 cpa; /* channel program address */
  30. } __attribute__ ((packed, aligned(4)));
  31. /*
  32. * transport-mode operation request block
  33. */
  34. struct tm_orb {
  35. u32 intparm;
  36. u32 key:4;
  37. u32 :9;
  38. u32 b:1;
  39. u32 :2;
  40. u32 lpm:8;
  41. u32 :7;
  42. u32 x:1;
  43. u32 tcw;
  44. u32 prio:8;
  45. u32 :8;
  46. u32 rsvpgm:8;
  47. u32 :8;
  48. u32 :32;
  49. u32 :32;
  50. u32 :32;
  51. u32 :32;
  52. } __attribute__ ((packed, aligned(4)));
  53. union orb {
  54. struct cmd_orb cmd;
  55. struct tm_orb tm;
  56. } __attribute__ ((packed, aligned(4)));
  57. struct io_subchannel_private {
  58. union orb orb; /* operation request block */
  59. struct ccw1 sense_ccw; /* static ccw for sense command */
  60. } __attribute__ ((aligned(8)));
  61. #define to_io_private(n) ((struct io_subchannel_private *)n->private)
  62. #define sch_get_cdev(n) (dev_get_drvdata(&n->dev))
  63. #define sch_set_cdev(n, c) (dev_set_drvdata(&n->dev, c))
  64. #define MAX_CIWS 8
  65. /*
  66. * Possible status values for a CCW request's I/O.
  67. */
  68. enum io_status {
  69. IO_DONE,
  70. IO_RUNNING,
  71. IO_STATUS_ERROR,
  72. IO_PATH_ERROR,
  73. IO_REJECTED,
  74. IO_KILLED
  75. };
  76. /**
  77. * ccw_request - Internal CCW request.
  78. * @cp: channel program to start
  79. * @timeout: maximum allowable time in jiffies between start I/O and interrupt
  80. * @maxretries: number of retries per I/O operation and path
  81. * @lpm: mask of paths to use
  82. * @check: optional callback that determines if results are final
  83. * @filter: optional callback to adjust request status based on IRB data
  84. * @callback: final callback
  85. * @data: user-defined pointer passed to all callbacks
  86. * @singlepath: if set, use only one path from @lpm per start I/O
  87. * @cancel: non-zero if request was cancelled
  88. * @done: non-zero if request was finished
  89. * @mask: current path mask
  90. * @retries: current number of retries
  91. * @drc: delayed return code
  92. */
  93. struct ccw_request {
  94. struct ccw1 *cp;
  95. unsigned long timeout;
  96. u16 maxretries;
  97. u8 lpm;
  98. int (*check)(struct ccw_device *, void *);
  99. enum io_status (*filter)(struct ccw_device *, void *, struct irb *,
  100. enum io_status);
  101. void (*callback)(struct ccw_device *, void *, int);
  102. void *data;
  103. unsigned int singlepath:1;
  104. /* These fields are used internally. */
  105. unsigned int cancel:1;
  106. unsigned int done:1;
  107. u16 mask;
  108. u16 retries;
  109. int drc;
  110. } __attribute__((packed));
  111. /*
  112. * sense-id response buffer layout
  113. */
  114. struct senseid {
  115. /* common part */
  116. u8 reserved; /* always 0x'FF' */
  117. u16 cu_type; /* control unit type */
  118. u8 cu_model; /* control unit model */
  119. u16 dev_type; /* device type */
  120. u8 dev_model; /* device model */
  121. u8 unused; /* padding byte */
  122. /* extended part */
  123. struct ciw ciw[MAX_CIWS]; /* variable # of CIWs */
  124. } __attribute__ ((packed, aligned(4)));
  125. enum cdev_todo {
  126. CDEV_TODO_NOTHING,
  127. CDEV_TODO_ENABLE_CMF,
  128. CDEV_TODO_REBIND,
  129. CDEV_TODO_REGISTER,
  130. CDEV_TODO_UNREG,
  131. CDEV_TODO_UNREG_EVAL,
  132. };
  133. struct ccw_device_private {
  134. struct ccw_device *cdev;
  135. struct subchannel *sch;
  136. int state; /* device state */
  137. atomic_t onoff;
  138. struct ccw_dev_id dev_id; /* device id */
  139. struct subchannel_id schid; /* subchannel number */
  140. struct ccw_request req; /* internal I/O request */
  141. int iretry;
  142. u8 pgid_valid_mask; /* mask of valid PGIDs */
  143. u8 pgid_todo_mask; /* mask of PGIDs to be adjusted */
  144. u8 pgid_reset_mask; /* mask of PGIDs which were reset */
  145. u8 path_gone_mask; /* mask of paths, that became unavailable */
  146. u8 path_new_mask; /* mask of paths, that became available */
  147. struct {
  148. unsigned int fast:1; /* post with "channel end" */
  149. unsigned int repall:1; /* report every interrupt status */
  150. unsigned int pgroup:1; /* do path grouping */
  151. unsigned int force:1; /* allow forced online */
  152. unsigned int mpath:1; /* do multipathing */
  153. } __attribute__ ((packed)) options;
  154. struct {
  155. unsigned int esid:1; /* Ext. SenseID supported by HW */
  156. unsigned int dosense:1; /* delayed SENSE required */
  157. unsigned int doverify:1; /* delayed path verification */
  158. unsigned int donotify:1; /* call notify function */
  159. unsigned int recog_done:1; /* dev. recog. complete */
  160. unsigned int fake_irb:1; /* deliver faked irb */
  161. unsigned int resuming:1; /* recognition while resume */
  162. unsigned int pgroup:1; /* pathgroup is set up */
  163. unsigned int mpath:1; /* multipathing is set up */
  164. unsigned int initialized:1; /* set if initial reference held */
  165. } __attribute__((packed)) flags;
  166. unsigned long intparm; /* user interruption parameter */
  167. struct qdio_irq *qdio_data;
  168. struct irb irb; /* device status */
  169. struct senseid senseid; /* SenseID info */
  170. struct pgid pgid[8]; /* path group IDs per chpid*/
  171. struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */
  172. struct work_struct todo_work;
  173. enum cdev_todo todo;
  174. wait_queue_head_t wait_q;
  175. struct timer_list timer;
  176. void *cmb; /* measurement information */
  177. struct list_head cmb_list; /* list of measured devices */
  178. u64 cmb_start_time; /* clock value of cmb reset */
  179. void *cmb_wait; /* deferred cmb enable/disable */
  180. };
  181. static inline int ssch(struct subchannel_id schid, union orb *addr)
  182. {
  183. register struct subchannel_id reg1 asm("1") = schid;
  184. int ccode = -EIO;
  185. asm volatile(
  186. " ssch 0(%2)\n"
  187. "0: ipm %0\n"
  188. " srl %0,28\n"
  189. "1:\n"
  190. EX_TABLE(0b, 1b)
  191. : "+d" (ccode)
  192. : "d" (reg1), "a" (addr), "m" (*addr)
  193. : "cc", "memory");
  194. return ccode;
  195. }
  196. static inline int rsch(struct subchannel_id schid)
  197. {
  198. register struct subchannel_id reg1 asm("1") = schid;
  199. int ccode;
  200. asm volatile(
  201. " rsch\n"
  202. " ipm %0\n"
  203. " srl %0,28"
  204. : "=d" (ccode)
  205. : "d" (reg1)
  206. : "cc", "memory");
  207. return ccode;
  208. }
  209. static inline int csch(struct subchannel_id schid)
  210. {
  211. register struct subchannel_id reg1 asm("1") = schid;
  212. int ccode;
  213. asm volatile(
  214. " csch\n"
  215. " ipm %0\n"
  216. " srl %0,28"
  217. : "=d" (ccode)
  218. : "d" (reg1)
  219. : "cc");
  220. return ccode;
  221. }
  222. static inline int hsch(struct subchannel_id schid)
  223. {
  224. register struct subchannel_id reg1 asm("1") = schid;
  225. int ccode;
  226. asm volatile(
  227. " hsch\n"
  228. " ipm %0\n"
  229. " srl %0,28"
  230. : "=d" (ccode)
  231. : "d" (reg1)
  232. : "cc");
  233. return ccode;
  234. }
  235. static inline int xsch(struct subchannel_id schid)
  236. {
  237. register struct subchannel_id reg1 asm("1") = schid;
  238. int ccode;
  239. asm volatile(
  240. " .insn rre,0xb2760000,%1,0\n"
  241. " ipm %0\n"
  242. " srl %0,28"
  243. : "=d" (ccode)
  244. : "d" (reg1)
  245. : "cc");
  246. return ccode;
  247. }
  248. #endif