blob: af571d8d6925e7a8bb4f35db7e0a7c8aff1bdbf8 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Cornelia Huckcd6b4f22008-01-26 14:10:43 +01002#ifndef S390_IO_SCH_H
3#define S390_IO_SCH_H
4
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +01005#include <linux/types.h>
Cornelia Huck9d92a7e2008-07-14 09:59:05 +02006#include <asm/schid.h>
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +01007#include <asm/ccwdev.h>
Peter Oberparleiterde400d62011-10-30 15:16:04 +01008#include <asm/irq.h>
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +01009#include "css.h"
Sebastian Ott9e6f9f82011-03-15 17:08:23 +010010#include "orb.h"
Peter Oberparleiter83262d62008-07-14 09:58:51 +020011
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010012struct io_subchannel_private {
Peter Oberparleiter83262d62008-07-14 09:58:51 +020013 union orb orb; /* operation request block */
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010014 struct ccw1 sense_ccw; /* static ccw for sense command */
Sebastian Ott97eb6bfc2011-03-15 17:08:26 +010015 struct ccw_device *cdev;/* pointer to the child ccw device */
Sebastian Ottc513d072011-03-15 17:08:25 +010016 struct {
17 unsigned int suspend:1; /* allow suspend */
18 unsigned int prefetch:1;/* deny prefetch */
19 unsigned int inter:1; /* suppress intermediate interrupts */
20 } __packed options;
21} __aligned(8);
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010022
Sebastian Ottf92519e2011-03-15 17:08:27 +010023#define to_io_private(n) ((struct io_subchannel_private *) \
24 dev_get_drvdata(&(n)->dev))
25#define set_io_private(n, p) (dev_set_drvdata(&(n)->dev, p))
Sebastian Ott97eb6bfc2011-03-15 17:08:26 +010026
27static inline struct ccw_device *sch_get_cdev(struct subchannel *sch)
28{
29 struct io_subchannel_private *priv = to_io_private(sch);
30 return priv ? priv->cdev : NULL;
31}
32
33static inline void sch_set_cdev(struct subchannel *sch,
34 struct ccw_device *cdev)
35{
36 struct io_subchannel_private *priv = to_io_private(sch);
37 if (priv)
38 priv->cdev = cdev;
39}
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010040
41#define MAX_CIWS 8
42
43/*
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +010044 * Possible status values for a CCW request's I/O.
45 */
46enum io_status {
47 IO_DONE,
48 IO_RUNNING,
49 IO_STATUS_ERROR,
50 IO_PATH_ERROR,
51 IO_REJECTED,
52 IO_KILLED
53};
54
55/**
56 * ccw_request - Internal CCW request.
57 * @cp: channel program to start
58 * @timeout: maximum allowable time in jiffies between start I/O and interrupt
59 * @maxretries: number of retries per I/O operation and path
60 * @lpm: mask of paths to use
61 * @check: optional callback that determines if results are final
62 * @filter: optional callback to adjust request status based on IRB data
63 * @callback: final callback
64 * @data: user-defined pointer passed to all callbacks
Sebastian Ott982bdf82010-08-09 18:12:53 +020065 * @singlepath: if set, use only one path from @lpm per start I/O
66 * @cancel: non-zero if request was cancelled
67 * @done: non-zero if request was finished
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +010068 * @mask: current path mask
69 * @retries: current number of retries
70 * @drc: delayed return code
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +010071 */
72struct ccw_request {
73 struct ccw1 *cp;
74 unsigned long timeout;
75 u16 maxretries;
76 u8 lpm;
77 int (*check)(struct ccw_device *, void *);
78 enum io_status (*filter)(struct ccw_device *, void *, struct irb *,
79 enum io_status);
80 void (*callback)(struct ccw_device *, void *, int);
81 void *data;
Sebastian Ott982bdf82010-08-09 18:12:53 +020082 unsigned int singlepath:1;
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +010083 /* These fields are used internally. */
Sebastian Ott982bdf82010-08-09 18:12:53 +020084 unsigned int cancel:1;
85 unsigned int done:1;
Peter Oberparleiterde1b0432009-12-07 12:51:40 +010086 u16 mask;
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +010087 u16 retries;
88 int drc;
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +010089} __attribute__((packed));
90
91/*
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010092 * sense-id response buffer layout
93 */
94struct senseid {
95 /* common part */
96 u8 reserved; /* always 0x'FF' */
97 u16 cu_type; /* control unit type */
98 u8 cu_model; /* control unit model */
99 u16 dev_type; /* device type */
100 u8 dev_model; /* device model */
101 u8 unused; /* padding byte */
102 /* extended part */
103 struct ciw ciw[MAX_CIWS]; /* variable # of CIWs */
104} __attribute__ ((packed, aligned(4)));
105
Peter Oberparleiter37de53b2009-12-07 12:51:19 +0100106enum cdev_todo {
107 CDEV_TODO_NOTHING,
108 CDEV_TODO_ENABLE_CMF,
109 CDEV_TODO_REBIND,
110 CDEV_TODO_REGISTER,
111 CDEV_TODO_UNREG,
112 CDEV_TODO_UNREG_EVAL,
113};
114
Sebastian Ott50c8e312011-12-01 13:32:21 +0100115#define FAKE_CMD_IRB 1
116#define FAKE_TM_IRB 2
117
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100118struct ccw_device_private {
119 struct ccw_device *cdev;
120 struct subchannel *sch;
121 int state; /* device state */
122 atomic_t onoff;
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100123 struct ccw_dev_id dev_id; /* device id */
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +0100124 struct ccw_request req; /* internal I/O request */
Peter Oberparleiter9679baa2009-12-07 12:51:27 +0100125 int iretry;
Sebastian Ott585b9542010-10-25 16:10:34 +0200126 u8 pgid_valid_mask; /* mask of valid PGIDs */
127 u8 pgid_todo_mask; /* mask of PGIDs to be adjusted */
128 u8 pgid_reset_mask; /* mask of PGIDs which were reset */
Sebastian Ott69f55762013-01-28 19:29:43 +0100129 u8 path_noirq_mask; /* mask of paths for which no irq was
130 received */
131 u8 path_notoper_mask; /* mask of paths which were found
132 not operable */
Sebastian Ott585b9542010-10-25 16:10:34 +0200133 u8 path_gone_mask; /* mask of paths, that became unavailable */
134 u8 path_new_mask; /* mask of paths, that became available */
Sebastian Ott55fb7342017-09-14 13:55:22 +0200135 u8 path_broken_mask; /* mask of paths, which were found to be
136 unusable */
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100137 struct {
138 unsigned int fast:1; /* post with "channel end" */
139 unsigned int repall:1; /* report every interrupt status */
140 unsigned int pgroup:1; /* do path grouping */
141 unsigned int force:1; /* allow forced online */
Peter Oberparleiter454e1fa2009-12-07 12:51:30 +0100142 unsigned int mpath:1; /* do multipathing */
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100143 } __attribute__ ((packed)) options;
144 struct {
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100145 unsigned int esid:1; /* Ext. SenseID supported by HW */
146 unsigned int dosense:1; /* delayed SENSE required */
147 unsigned int doverify:1; /* delayed path verification */
148 unsigned int donotify:1; /* call notify function */
149 unsigned int recog_done:1; /* dev. recog. complete */
Sebastian Ott50c8e312011-12-01 13:32:21 +0100150 unsigned int fake_irb:2; /* deliver faked irb */
Sebastian Ott823d4942009-06-16 10:30:20 +0200151 unsigned int resuming:1; /* recognition while resume */
Peter Oberparleiter454e1fa2009-12-07 12:51:30 +0100152 unsigned int pgroup:1; /* pathgroup is set up */
153 unsigned int mpath:1; /* multipathing is set up */
Sebastian Ott69f55762013-01-28 19:29:43 +0100154 unsigned int pgid_unknown:1;/* unknown pgid state */
Sebastian Ott24a18722009-12-07 12:51:34 +0100155 unsigned int initialized:1; /* set if initial reference held */
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100156 } __attribute__((packed)) flags;
157 unsigned long intparm; /* user interruption parameter */
158 struct qdio_irq *qdio_data;
159 struct irb irb; /* device status */
160 struct senseid senseid; /* SenseID info */
161 struct pgid pgid[8]; /* path group IDs per chpid*/
162 struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */
Peter Oberparleiter37de53b2009-12-07 12:51:19 +0100163 struct work_struct todo_work;
164 enum cdev_todo todo;
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100165 wait_queue_head_t wait_q;
166 struct timer_list timer;
167 void *cmb; /* measurement information */
168 struct list_head cmb_list; /* list of measured devices */
169 u64 cmb_start_time; /* clock value of cmb reset */
170 void *cmb_wait; /* deferred cmb enable/disable */
Peter Oberparleiterde400d62011-10-30 15:16:04 +0100171 enum interruption_class int_class;
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100172};
173
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100174#endif