4 #include <linux/mutex.h>
5 #include <linux/wait.h>
6 #include <linux/workqueue.h>
15 #define SPID_FUNC_SINGLE_PATH 0x00
16 #define SPID_FUNC_MULTI_PATH 0x80
17 #define SPID_FUNC_ESTABLISH 0x00
18 #define SPID_FUNC_RESIGN 0x40
19 #define SPID_FUNC_DISBAND 0x20
21 #define SNID_STATE1_RESET 0
22 #define SNID_STATE1_UNGROUPED 2
23 #define SNID_STATE1_GROUPED 3
25 #define SNID_STATE2_NOT_RESVD 0
26 #define SNID_STATE2_RESVD_ELSE 2
27 #define SNID_STATE2_RESVD_SELF 3
29 #define SNID_STATE3_MULTI_PATH 1
30 #define SNID_STATE3_SINGLE_PATH 0
33 __u8 state1 : 2; /* path state value 1 */
34 __u8 state2 : 2; /* path state value 2 */
35 __u8 state3 : 1; /* path state value 3 */
36 __u8 resvd : 3; /* reserved */
37 } __attribute__ ((packed));
39 struct extended_cssid {
42 } __attribute__ ((packed));
46 __u8 fc; /* SPID function code */
47 struct path_state ps; /* SNID path state */
48 } __attribute__ ((packed)) inf;
50 __u32 cpu_addr : 16; /* CPU address */
51 struct extended_cssid ext_cssid;
52 } __attribute__ ((packed)) pgid_high;
53 __u32 cpu_id : 24; /* CPU identification */
54 __u32 cpu_model : 16; /* CPU model */
55 __u32 tod_high; /* high word TOD clock */
56 } __attribute__ ((packed));
61 * sense-id response buffer layout
65 __u8 reserved; /* always 0x'FF' */
66 __u16 cu_type; /* control unit type */
67 __u8 cu_model; /* control unit model */
68 __u16 dev_type; /* device type */
69 __u8 dev_model; /* device model */
70 __u8 unused; /* padding byte */
72 struct ciw ciw[MAX_CIWS]; /* variable # of CIWs */
73 } __attribute__ ((packed,aligned(4)));
75 struct ccw_device_private {
76 struct ccw_device *cdev;
77 struct subchannel *sch;
78 int state; /* device state */
80 unsigned long registered;
81 struct ccw_dev_id dev_id; /* device id */
82 struct subchannel_id schid; /* subchannel number */
83 __u8 imask; /* lpm mask for SNID/SID/SPGID */
84 int iretry; /* retry counter SNID/SID/SPGID */
86 unsigned int fast:1; /* post with "channel end" */
87 unsigned int repall:1; /* report every interrupt status */
88 unsigned int pgroup:1; /* do path grouping */
89 unsigned int force:1; /* allow forced online */
90 } __attribute__ ((packed)) options;
92 unsigned int pgid_single:1; /* use single path for Set PGID */
93 unsigned int esid:1; /* Ext. SenseID supported by HW */
94 unsigned int dosense:1; /* delayed SENSE required */
95 unsigned int doverify:1; /* delayed path verification */
96 unsigned int donotify:1; /* call notify function */
97 unsigned int recog_done:1; /* dev. recog. complete */
98 unsigned int fake_irb:1; /* deliver faked irb */
99 unsigned int intretry:1; /* retry internal operation */
100 } __attribute__((packed)) flags;
101 unsigned long intparm; /* user interruption parameter */
102 struct qdio_irq *qdio_data;
103 struct irb irb; /* device status */
104 struct senseid senseid; /* SenseID info */
105 struct pgid pgid[8]; /* path group IDs per chpid*/
106 struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */
107 struct work_struct kick_work;
108 wait_queue_head_t wait_q;
109 struct timer_list timer;
110 void *cmb; /* measurement information */
111 struct list_head cmb_list; /* list of measured devices */
112 u64 cmb_start_time; /* clock value of cmb reset */
113 void *cmb_wait; /* deferred cmb enable/disable */
117 * A css driver handles all subchannels of one type.
118 * Currently, we only care about I/O subchannels (type 0), these
119 * have a ccw_device connected to them.
123 unsigned int subchannel_type;
124 struct device_driver drv;
125 void (*irq)(struct device *);
126 int (*notify)(struct device *, int);
127 void (*verify)(struct device *);
128 void (*termination)(struct device *);
129 int (*probe)(struct subchannel *);
130 int (*remove)(struct subchannel *);
131 void (*shutdown)(struct subchannel *);
135 * all css_drivers have the css_bus_type
137 extern struct bus_type css_bus_type;
138 extern struct css_driver io_subchannel_driver;
140 extern int css_probe_device(struct subchannel_id);
141 extern int css_sch_device_register(struct subchannel *);
142 extern void css_sch_device_unregister(struct subchannel *);
143 extern struct subchannel * get_subchannel_by_schid(struct subchannel_id);
144 extern int css_init_done;
145 extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *);
146 extern int css_process_crw(int, int);
147 extern void css_reiterate_subchannels(void);
149 #define __MAX_SUBCHANNEL 65535
151 #define __MAX_CHPID 255
152 #define __MAX_CSSID 0
154 struct channel_subsystem {
157 struct channel_path *chps[__MAX_CHPID + 1];
158 struct device device;
159 struct pgid global_pgid;
161 /* channel measurement related */
165 /* for orphaned ccw devices */
166 struct subchannel *pseudo_subchannel;
168 #define to_css(dev) container_of(dev, struct channel_subsystem, device)
170 extern struct bus_type css_bus_type;
171 extern struct channel_subsystem *css[];
173 /* Some helper functions for disconnected state. */
174 int device_is_disconnected(struct subchannel *);
175 void device_set_disconnected(struct subchannel *);
176 void device_trigger_reprobe(struct subchannel *);
178 /* Helper functions for vary on/off. */
179 int device_is_online(struct subchannel *);
180 void device_kill_io(struct subchannel *);
181 void device_set_intretry(struct subchannel *sch);
182 int device_trigger_verify(struct subchannel *sch);
184 /* Machine check helper function. */
185 void device_kill_pending_timer(struct subchannel *);
187 /* Helper functions to build lists for the slow path. */
188 extern int css_enqueue_subchannel_slow(struct subchannel_id schid);
189 void css_walk_subchannel_slow_list(void (*fn)(unsigned long));
190 void css_clear_subchannel_slow_list(void);
191 int css_slow_subchannels_exist(void);
192 extern int need_rescan;
194 int sch_is_pseudo_sch(struct subchannel *);
196 extern struct workqueue_struct *slow_path_wq;
197 extern struct work_struct slow_path_work;
199 int subchannel_add_files (struct device *);
200 extern struct attribute_group *subch_attr_groups[];