io_sch.h 5.7 KB

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