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