io_sch.h 5.3 KB

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