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