io_sch.h 5.2 KB

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