blob: b74659cab0af125f99f3febd81e6e5f4c3ecf63e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _CSS_H
2#define _CSS_H
3
4#include <linux/wait.h>
5#include <linux/workqueue.h>
6
7#include <asm/cio.h>
8
Cornelia Hucka8237fc2006-01-06 00:19:21 -08009#include "schid.h"
10
Linus Torvalds1da177e2005-04-16 15:20:36 -070011/*
12 * path grouping stuff
13 */
14#define SPID_FUNC_SINGLE_PATH 0x00
15#define SPID_FUNC_MULTI_PATH 0x80
16#define SPID_FUNC_ESTABLISH 0x00
17#define SPID_FUNC_RESIGN 0x40
18#define SPID_FUNC_DISBAND 0x20
19
20#define SNID_STATE1_RESET 0
21#define SNID_STATE1_UNGROUPED 2
22#define SNID_STATE1_GROUPED 3
23
24#define SNID_STATE2_NOT_RESVD 0
25#define SNID_STATE2_RESVD_ELSE 2
26#define SNID_STATE2_RESVD_SELF 3
27
28#define SNID_STATE3_MULTI_PATH 1
29#define SNID_STATE3_SINGLE_PATH 0
30
31struct path_state {
32 __u8 state1 : 2; /* path state value 1 */
33 __u8 state2 : 2; /* path state value 2 */
34 __u8 state3 : 1; /* path state value 3 */
35 __u8 resvd : 3; /* reserved */
36} __attribute__ ((packed));
37
Cornelia Hucka28c6942006-01-06 00:19:23 -080038struct extended_cssid {
39 u8 version;
40 u8 cssid;
41} __attribute__ ((packed));
42
Linus Torvalds1da177e2005-04-16 15:20:36 -070043struct pgid {
44 union {
45 __u8 fc; /* SPID function code */
46 struct path_state ps; /* SNID path state */
47 } inf;
Cornelia Hucka28c6942006-01-06 00:19:23 -080048 union {
49 __u32 cpu_addr : 16; /* CPU address */
50 struct extended_cssid ext_cssid;
51 } pgid_high;
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 __u32 cpu_id : 24; /* CPU identification */
53 __u32 cpu_model : 16; /* CPU model */
54 __u32 tod_high; /* high word TOD clock */
55} __attribute__ ((packed));
56
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#define MAX_CIWS 8
58
59/*
60 * sense-id response buffer layout
61 */
62struct senseid {
63 /* common part */
64 __u8 reserved; /* always 0x'FF' */
65 __u16 cu_type; /* control unit type */
66 __u8 cu_model; /* control unit model */
67 __u16 dev_type; /* device type */
68 __u8 dev_model; /* device model */
69 __u8 unused; /* padding byte */
70 /* extended part */
71 struct ciw ciw[MAX_CIWS]; /* variable # of CIWs */
72} __attribute__ ((packed,aligned(4)));
73
74struct ccw_device_private {
75 int state; /* device state */
76 atomic_t onoff;
77 unsigned long registered;
78 __u16 devno; /* device number */
Cornelia Hucka8237fc2006-01-06 00:19:21 -080079 __u16 sch_no; /* subchannel number */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 __u8 imask; /* lpm mask for SNID/SID/SPGID */
81 int iretry; /* retry counter SNID/SID/SPGID */
82 struct {
83 unsigned int fast:1; /* post with "channel end" */
84 unsigned int repall:1; /* report every interrupt status */
85 unsigned int pgroup:1; /* do path grouping */
86 unsigned int force:1; /* allow forced online */
87 } __attribute__ ((packed)) options;
88 struct {
89 unsigned int pgid_single:1; /* use single path for Set PGID */
90 unsigned int esid:1; /* Ext. SenseID supported by HW */
91 unsigned int dosense:1; /* delayed SENSE required */
92 unsigned int doverify:1; /* delayed path verification */
93 unsigned int donotify:1; /* call notify function */
94 unsigned int recog_done:1; /* dev. recog. complete */
95 unsigned int fake_irb:1; /* deliver faked irb */
96 } __attribute__((packed)) flags;
97 unsigned long intparm; /* user interruption parameter */
98 struct qdio_irq *qdio_data;
99 struct irb irb; /* device status */
100 struct senseid senseid; /* SenseID info */
101 struct pgid pgid; /* path group ID */
102 struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */
103 struct work_struct kick_work;
104 wait_queue_head_t wait_q;
105 struct timer_list timer;
106 void *cmb; /* measurement information */
107 struct list_head cmb_list; /* list of measured devices */
108 u64 cmb_start_time; /* clock value of cmb reset */
109 void *cmb_wait; /* deferred cmb enable/disable */
110};
111
112/*
113 * A css driver handles all subchannels of one type.
114 * Currently, we only care about I/O subchannels (type 0), these
115 * have a ccw_device connected to them.
116 */
117struct css_driver {
118 unsigned int subchannel_type;
119 struct device_driver drv;
120 void (*irq)(struct device *);
121 int (*notify)(struct device *, int);
122 void (*verify)(struct device *);
123 void (*termination)(struct device *);
124};
125
126/*
127 * all css_drivers have the css_bus_type
128 */
129extern struct bus_type css_bus_type;
130extern struct css_driver io_subchannel_driver;
131
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800132extern int css_probe_device(struct subchannel_id);
133extern struct subchannel * get_subchannel_by_schid(struct subchannel_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134extern int css_init_done;
Cornelia Huckf97a56f2006-01-06 00:19:22 -0800135extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800137#define __MAX_SUBCHANNEL 65535
Cornelia Hucka28c6942006-01-06 00:19:23 -0800138#define __MAX_CHPID 255
139#define __MAX_CSSID 0
140
141struct channel_subsystem {
142 u8 cssid;
143 int valid;
144 struct channel_path *chps[__MAX_CHPID];
145 struct device device;
146 struct pgid global_pgid;
147};
148#define to_css(dev) container_of(dev, struct channel_subsystem, device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
150extern struct bus_type css_bus_type;
Cornelia Hucka28c6942006-01-06 00:19:23 -0800151extern struct channel_subsystem *css[];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
153/* Some helper functions for disconnected state. */
154int device_is_disconnected(struct subchannel *);
155void device_set_disconnected(struct subchannel *);
156void device_trigger_reprobe(struct subchannel *);
157
158/* Helper functions for vary on/off. */
159int device_is_online(struct subchannel *);
160void device_set_waiting(struct subchannel *);
161
162/* Machine check helper function. */
163void device_kill_pending_timer(struct subchannel *);
164
165/* Helper functions to build lists for the slow path. */
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800166extern int css_enqueue_subchannel_slow(struct subchannel_id schid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167void css_walk_subchannel_slow_list(void (*fn)(unsigned long));
168void css_clear_subchannel_slow_list(void);
169int css_slow_subchannels_exist(void);
170extern int need_rescan;
171
172extern struct workqueue_struct *slow_path_wq;
173extern struct work_struct slow_path_work;
174#endif