io_sch.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. * @mask: current path mask
  87. * @retries: current number of retries
  88. * @drc: delayed return code
  89. * @cancel: non-zero if request was cancelled
  90. * @done: non-zero if request was finished
  91. */
  92. struct ccw_request {
  93. struct ccw1 *cp;
  94. unsigned long timeout;
  95. u16 maxretries;
  96. u8 lpm;
  97. int (*check)(struct ccw_device *, void *);
  98. enum io_status (*filter)(struct ccw_device *, void *, struct irb *,
  99. enum io_status);
  100. void (*callback)(struct ccw_device *, void *, int);
  101. void *data;
  102. /* These fields are used internally. */
  103. u16 mask;
  104. u16 retries;
  105. int drc;
  106. int cancel:1;
  107. int done:1;
  108. } __attribute__((packed));
  109. /*
  110. * sense-id response buffer layout
  111. */
  112. struct senseid {
  113. /* common part */
  114. u8 reserved; /* always 0x'FF' */
  115. u16 cu_type; /* control unit type */
  116. u8 cu_model; /* control unit model */
  117. u16 dev_type; /* device type */
  118. u8 dev_model; /* device model */
  119. u8 unused; /* padding byte */
  120. /* extended part */
  121. struct ciw ciw[MAX_CIWS]; /* variable # of CIWs */
  122. } __attribute__ ((packed, aligned(4)));
  123. enum cdev_todo {
  124. CDEV_TODO_NOTHING,
  125. CDEV_TODO_ENABLE_CMF,
  126. CDEV_TODO_REBIND,
  127. CDEV_TODO_REGISTER,
  128. CDEV_TODO_UNREG,
  129. CDEV_TODO_UNREG_EVAL,
  130. };
  131. struct ccw_device_private {
  132. struct ccw_device *cdev;
  133. struct subchannel *sch;
  134. int state; /* device state */
  135. atomic_t onoff;
  136. struct ccw_dev_id dev_id; /* device id */
  137. struct subchannel_id schid; /* subchannel number */
  138. struct ccw_request req; /* internal I/O request */
  139. int iretry;
  140. u8 pgid_valid_mask; /* mask of valid PGIDs */
  141. u8 pgid_todo_mask; /* mask of PGIDs to be adjusted */
  142. struct {
  143. unsigned int fast:1; /* post with "channel end" */
  144. unsigned int repall:1; /* report every interrupt status */
  145. unsigned int pgroup:1; /* do path grouping */
  146. unsigned int force:1; /* allow forced online */
  147. unsigned int mpath:1; /* do multipathing */
  148. } __attribute__ ((packed)) options;
  149. struct {
  150. unsigned int esid:1; /* Ext. SenseID supported by HW */
  151. unsigned int dosense:1; /* delayed SENSE required */
  152. unsigned int doverify:1; /* delayed path verification */
  153. unsigned int donotify:1; /* call notify function */
  154. unsigned int recog_done:1; /* dev. recog. complete */
  155. unsigned int fake_irb:1; /* deliver faked irb */
  156. unsigned int resuming:1; /* recognition while resume */
  157. unsigned int pgroup:1; /* pathgroup is set up */
  158. unsigned int mpath:1; /* multipathing is set up */
  159. unsigned int initialized:1; /* set if initial reference held */
  160. } __attribute__((packed)) flags;
  161. unsigned long intparm; /* user interruption parameter */
  162. struct qdio_irq *qdio_data;
  163. struct irb irb; /* device status */
  164. struct senseid senseid; /* SenseID info */
  165. struct pgid pgid[8]; /* path group IDs per chpid*/
  166. struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */
  167. struct work_struct todo_work;
  168. enum cdev_todo todo;
  169. wait_queue_head_t wait_q;
  170. struct timer_list timer;
  171. void *cmb; /* measurement information */
  172. struct list_head cmb_list; /* list of measured devices */
  173. u64 cmb_start_time; /* clock value of cmb reset */
  174. void *cmb_wait; /* deferred cmb enable/disable */
  175. };
  176. static inline int ssch(struct subchannel_id schid, union orb *addr)
  177. {
  178. register struct subchannel_id reg1 asm("1") = schid;
  179. int ccode = -EIO;
  180. asm volatile(
  181. " ssch 0(%2)\n"
  182. "0: ipm %0\n"
  183. " srl %0,28\n"
  184. "1:\n"
  185. EX_TABLE(0b, 1b)
  186. : "+d" (ccode)
  187. : "d" (reg1), "a" (addr), "m" (*addr)
  188. : "cc", "memory");
  189. return ccode;
  190. }
  191. static inline int rsch(struct subchannel_id schid)
  192. {
  193. register struct subchannel_id reg1 asm("1") = schid;
  194. int ccode;
  195. asm volatile(
  196. " rsch\n"
  197. " ipm %0\n"
  198. " srl %0,28"
  199. : "=d" (ccode)
  200. : "d" (reg1)
  201. : "cc", "memory");
  202. return ccode;
  203. }
  204. static inline int csch(struct subchannel_id schid)
  205. {
  206. register struct subchannel_id reg1 asm("1") = schid;
  207. int ccode;
  208. asm volatile(
  209. " csch\n"
  210. " ipm %0\n"
  211. " srl %0,28"
  212. : "=d" (ccode)
  213. : "d" (reg1)
  214. : "cc");
  215. return ccode;
  216. }
  217. static inline int hsch(struct subchannel_id schid)
  218. {
  219. register struct subchannel_id reg1 asm("1") = schid;
  220. int ccode;
  221. asm volatile(
  222. " hsch\n"
  223. " ipm %0\n"
  224. " srl %0,28"
  225. : "=d" (ccode)
  226. : "d" (reg1)
  227. : "cc");
  228. return ccode;
  229. }
  230. static inline int xsch(struct subchannel_id schid)
  231. {
  232. register struct subchannel_id reg1 asm("1") = schid;
  233. int ccode;
  234. asm volatile(
  235. " .insn rre,0xb2760000,%1,0\n"
  236. " ipm %0\n"
  237. " srl %0,28"
  238. : "=d" (ccode)
  239. : "d" (reg1)
  240. : "cc");
  241. return ccode;
  242. }
  243. #endif