io_sch.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. #include "orb.h"
  8. struct io_subchannel_private {
  9. union orb orb; /* operation request block */
  10. struct ccw1 sense_ccw; /* static ccw for sense command */
  11. struct ccw_device *cdev;/* pointer to the child ccw device */
  12. struct {
  13. unsigned int suspend:1; /* allow suspend */
  14. unsigned int prefetch:1;/* deny prefetch */
  15. unsigned int inter:1; /* suppress intermediate interrupts */
  16. } __packed options;
  17. } __aligned(8);
  18. #define to_io_private(n) ((struct io_subchannel_private *)n->private)
  19. static inline struct ccw_device *sch_get_cdev(struct subchannel *sch)
  20. {
  21. struct io_subchannel_private *priv = to_io_private(sch);
  22. return priv ? priv->cdev : NULL;
  23. }
  24. static inline void sch_set_cdev(struct subchannel *sch,
  25. struct ccw_device *cdev)
  26. {
  27. struct io_subchannel_private *priv = to_io_private(sch);
  28. if (priv)
  29. priv->cdev = cdev;
  30. }
  31. #define MAX_CIWS 8
  32. /*
  33. * Possible status values for a CCW request's I/O.
  34. */
  35. enum io_status {
  36. IO_DONE,
  37. IO_RUNNING,
  38. IO_STATUS_ERROR,
  39. IO_PATH_ERROR,
  40. IO_REJECTED,
  41. IO_KILLED
  42. };
  43. /**
  44. * ccw_request - Internal CCW request.
  45. * @cp: channel program to start
  46. * @timeout: maximum allowable time in jiffies between start I/O and interrupt
  47. * @maxretries: number of retries per I/O operation and path
  48. * @lpm: mask of paths to use
  49. * @check: optional callback that determines if results are final
  50. * @filter: optional callback to adjust request status based on IRB data
  51. * @callback: final callback
  52. * @data: user-defined pointer passed to all callbacks
  53. * @singlepath: if set, use only one path from @lpm per start I/O
  54. * @cancel: non-zero if request was cancelled
  55. * @done: non-zero if request was finished
  56. * @mask: current path mask
  57. * @retries: current number of retries
  58. * @drc: delayed return code
  59. */
  60. struct ccw_request {
  61. struct ccw1 *cp;
  62. unsigned long timeout;
  63. u16 maxretries;
  64. u8 lpm;
  65. int (*check)(struct ccw_device *, void *);
  66. enum io_status (*filter)(struct ccw_device *, void *, struct irb *,
  67. enum io_status);
  68. void (*callback)(struct ccw_device *, void *, int);
  69. void *data;
  70. unsigned int singlepath:1;
  71. /* These fields are used internally. */
  72. unsigned int cancel:1;
  73. unsigned int done:1;
  74. u16 mask;
  75. u16 retries;
  76. int drc;
  77. } __attribute__((packed));
  78. /*
  79. * sense-id response buffer layout
  80. */
  81. struct senseid {
  82. /* common part */
  83. u8 reserved; /* always 0x'FF' */
  84. u16 cu_type; /* control unit type */
  85. u8 cu_model; /* control unit model */
  86. u16 dev_type; /* device type */
  87. u8 dev_model; /* device model */
  88. u8 unused; /* padding byte */
  89. /* extended part */
  90. struct ciw ciw[MAX_CIWS]; /* variable # of CIWs */
  91. } __attribute__ ((packed, aligned(4)));
  92. enum cdev_todo {
  93. CDEV_TODO_NOTHING,
  94. CDEV_TODO_ENABLE_CMF,
  95. CDEV_TODO_REBIND,
  96. CDEV_TODO_REGISTER,
  97. CDEV_TODO_UNREG,
  98. CDEV_TODO_UNREG_EVAL,
  99. };
  100. struct ccw_device_private {
  101. struct ccw_device *cdev;
  102. struct subchannel *sch;
  103. int state; /* device state */
  104. atomic_t onoff;
  105. struct ccw_dev_id dev_id; /* device id */
  106. struct subchannel_id schid; /* subchannel number */
  107. struct ccw_request req; /* internal I/O request */
  108. int iretry;
  109. u8 pgid_valid_mask; /* mask of valid PGIDs */
  110. u8 pgid_todo_mask; /* mask of PGIDs to be adjusted */
  111. u8 pgid_reset_mask; /* mask of PGIDs which were reset */
  112. u8 path_gone_mask; /* mask of paths, that became unavailable */
  113. u8 path_new_mask; /* mask of paths, that became available */
  114. struct {
  115. unsigned int fast:1; /* post with "channel end" */
  116. unsigned int repall:1; /* report every interrupt status */
  117. unsigned int pgroup:1; /* do path grouping */
  118. unsigned int force:1; /* allow forced online */
  119. unsigned int mpath:1; /* do multipathing */
  120. } __attribute__ ((packed)) options;
  121. struct {
  122. unsigned int esid:1; /* Ext. SenseID supported by HW */
  123. unsigned int dosense:1; /* delayed SENSE required */
  124. unsigned int doverify:1; /* delayed path verification */
  125. unsigned int donotify:1; /* call notify function */
  126. unsigned int recog_done:1; /* dev. recog. complete */
  127. unsigned int fake_irb:1; /* deliver faked irb */
  128. unsigned int resuming:1; /* recognition while resume */
  129. unsigned int pgroup:1; /* pathgroup is set up */
  130. unsigned int mpath:1; /* multipathing is set up */
  131. unsigned int initialized:1; /* set if initial reference held */
  132. } __attribute__((packed)) flags;
  133. unsigned long intparm; /* user interruption parameter */
  134. struct qdio_irq *qdio_data;
  135. struct irb irb; /* device status */
  136. struct senseid senseid; /* SenseID info */
  137. struct pgid pgid[8]; /* path group IDs per chpid*/
  138. struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */
  139. struct work_struct todo_work;
  140. enum cdev_todo todo;
  141. wait_queue_head_t wait_q;
  142. struct timer_list timer;
  143. void *cmb; /* measurement information */
  144. struct list_head cmb_list; /* list of measured devices */
  145. u64 cmb_start_time; /* clock value of cmb reset */
  146. void *cmb_wait; /* deferred cmb enable/disable */
  147. };
  148. static inline int rsch(struct subchannel_id schid)
  149. {
  150. register struct subchannel_id reg1 asm("1") = schid;
  151. int ccode;
  152. asm volatile(
  153. " rsch\n"
  154. " ipm %0\n"
  155. " srl %0,28"
  156. : "=d" (ccode)
  157. : "d" (reg1)
  158. : "cc", "memory");
  159. return ccode;
  160. }
  161. static inline int hsch(struct subchannel_id schid)
  162. {
  163. register struct subchannel_id reg1 asm("1") = schid;
  164. int ccode;
  165. asm volatile(
  166. " hsch\n"
  167. " ipm %0\n"
  168. " srl %0,28"
  169. : "=d" (ccode)
  170. : "d" (reg1)
  171. : "cc");
  172. return ccode;
  173. }
  174. static inline int xsch(struct subchannel_id schid)
  175. {
  176. register struct subchannel_id reg1 asm("1") = schid;
  177. int ccode;
  178. asm volatile(
  179. " .insn rre,0xb2760000,%1,0\n"
  180. " ipm %0\n"
  181. " srl %0,28"
  182. : "=d" (ccode)
  183. : "d" (reg1)
  184. : "cc");
  185. return ccode;
  186. }
  187. #endif