io_sch.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. struct {
  145. unsigned int fast:1; /* post with "channel end" */
  146. unsigned int repall:1; /* report every interrupt status */
  147. unsigned int pgroup:1; /* do path grouping */
  148. unsigned int force:1; /* allow forced online */
  149. unsigned int mpath:1; /* do multipathing */
  150. } __attribute__ ((packed)) options;
  151. struct {
  152. unsigned int esid:1; /* Ext. SenseID supported by HW */
  153. unsigned int dosense:1; /* delayed SENSE required */
  154. unsigned int doverify:1; /* delayed path verification */
  155. unsigned int donotify:1; /* call notify function */
  156. unsigned int recog_done:1; /* dev. recog. complete */
  157. unsigned int fake_irb:1; /* deliver faked irb */
  158. unsigned int resuming:1; /* recognition while resume */
  159. unsigned int pgroup:1; /* pathgroup is set up */
  160. unsigned int mpath:1; /* multipathing is set up */
  161. unsigned int initialized:1; /* set if initial reference held */
  162. } __attribute__((packed)) flags;
  163. unsigned long intparm; /* user interruption parameter */
  164. struct qdio_irq *qdio_data;
  165. struct irb irb; /* device status */
  166. struct senseid senseid; /* SenseID info */
  167. struct pgid pgid[8]; /* path group IDs per chpid*/
  168. struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */
  169. struct work_struct todo_work;
  170. enum cdev_todo todo;
  171. wait_queue_head_t wait_q;
  172. struct timer_list timer;
  173. void *cmb; /* measurement information */
  174. struct list_head cmb_list; /* list of measured devices */
  175. u64 cmb_start_time; /* clock value of cmb reset */
  176. void *cmb_wait; /* deferred cmb enable/disable */
  177. };
  178. static inline int ssch(struct subchannel_id schid, union orb *addr)
  179. {
  180. register struct subchannel_id reg1 asm("1") = schid;
  181. int ccode = -EIO;
  182. asm volatile(
  183. " ssch 0(%2)\n"
  184. "0: ipm %0\n"
  185. " srl %0,28\n"
  186. "1:\n"
  187. EX_TABLE(0b, 1b)
  188. : "+d" (ccode)
  189. : "d" (reg1), "a" (addr), "m" (*addr)
  190. : "cc", "memory");
  191. return ccode;
  192. }
  193. static inline int rsch(struct subchannel_id schid)
  194. {
  195. register struct subchannel_id reg1 asm("1") = schid;
  196. int ccode;
  197. asm volatile(
  198. " rsch\n"
  199. " ipm %0\n"
  200. " srl %0,28"
  201. : "=d" (ccode)
  202. : "d" (reg1)
  203. : "cc", "memory");
  204. return ccode;
  205. }
  206. static inline int csch(struct subchannel_id schid)
  207. {
  208. register struct subchannel_id reg1 asm("1") = schid;
  209. int ccode;
  210. asm volatile(
  211. " csch\n"
  212. " ipm %0\n"
  213. " srl %0,28"
  214. : "=d" (ccode)
  215. : "d" (reg1)
  216. : "cc");
  217. return ccode;
  218. }
  219. static inline int hsch(struct subchannel_id schid)
  220. {
  221. register struct subchannel_id reg1 asm("1") = schid;
  222. int ccode;
  223. asm volatile(
  224. " hsch\n"
  225. " ipm %0\n"
  226. " srl %0,28"
  227. : "=d" (ccode)
  228. : "d" (reg1)
  229. : "cc");
  230. return ccode;
  231. }
  232. static inline int xsch(struct subchannel_id schid)
  233. {
  234. register struct subchannel_id reg1 asm("1") = schid;
  235. int ccode;
  236. asm volatile(
  237. " .insn rre,0xb2760000,%1,0\n"
  238. " ipm %0\n"
  239. " srl %0,28"
  240. : "=d" (ccode)
  241. : "d" (reg1)
  242. : "cc");
  243. return ccode;
  244. }
  245. #endif