xref: /linux/drivers/s390/cio/css.h (revision f3d9478b2ce468c3115b02ecae7e975990697f15)
1 #ifndef _CSS_H
2 #define _CSS_H
3 
4 #include <linux/mutex.h>
5 #include <linux/wait.h>
6 #include <linux/workqueue.h>
7 
8 #include <asm/cio.h>
9 
10 #include "schid.h"
11 
12 /*
13  * path grouping stuff
14  */
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
20 
21 #define SNID_STATE1_RESET	   0
22 #define SNID_STATE1_UNGROUPED	   2
23 #define SNID_STATE1_GROUPED	   3
24 
25 #define SNID_STATE2_NOT_RESVD	   0
26 #define SNID_STATE2_RESVD_ELSE	   2
27 #define SNID_STATE2_RESVD_SELF	   3
28 
29 #define SNID_STATE3_MULTI_PATH	   1
30 #define SNID_STATE3_SINGLE_PATH	   0
31 
32 struct path_state {
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));
38 
39 struct extended_cssid {
40 	u8 version;
41 	u8 cssid;
42 } __attribute__ ((packed));
43 
44 struct pgid {
45 	union {
46 		__u8 fc;   	/* SPID function code */
47 		struct path_state ps;	/* SNID path state */
48 	} __attribute__ ((packed)) inf;
49 	union {
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));
57 
58 #define MAX_CIWS 8
59 
60 /*
61  * sense-id response buffer layout
62  */
63 struct senseid {
64 	/* common part */
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 */
71 	/* extended part */
72 	struct ciw ciw[MAX_CIWS];	/* variable # of CIWs */
73 }  __attribute__ ((packed,aligned(4)));
74 
75 struct ccw_device_private {
76 	int state;		/* device state */
77 	atomic_t onoff;
78 	unsigned long registered;
79 	__u16 devno;		/* device number */
80 	__u16 sch_no;		/* subchannel number */
81 	__u8 ssid;              /* subchannel set id */
82 	__u8 imask;		/* lpm mask for SNID/SID/SPGID */
83 	int iretry;		/* retry counter SNID/SID/SPGID */
84 	struct {
85 		unsigned int fast:1;	/* post with "channel end" */
86 		unsigned int repall:1;	/* report every interrupt status */
87 		unsigned int pgroup:1;  /* do path grouping */
88 		unsigned int force:1;   /* allow forced online */
89 	} __attribute__ ((packed)) options;
90 	struct {
91 		unsigned int pgid_single:1; /* use single path for Set PGID */
92 		unsigned int esid:1;        /* Ext. SenseID supported by HW */
93 		unsigned int dosense:1;	    /* delayed SENSE required */
94 		unsigned int doverify:1;    /* delayed path verification */
95 		unsigned int donotify:1;    /* call notify function */
96 		unsigned int recog_done:1;  /* dev. recog. complete */
97 		unsigned int fake_irb:1;    /* deliver faked irb */
98 	} __attribute__((packed)) flags;
99 	unsigned long intparm;	/* user interruption parameter */
100 	struct qdio_irq *qdio_data;
101 	struct irb irb;		/* device status */
102 	struct senseid senseid;	/* SenseID info */
103 	struct pgid pgid;	/* path group ID */
104 	struct ccw1 iccws[2];	/* ccws for SNID/SID/SPGID commands */
105 	struct work_struct kick_work;
106 	wait_queue_head_t wait_q;
107 	struct timer_list timer;
108 	void *cmb;			/* measurement information */
109 	struct list_head cmb_list;	/* list of measured devices */
110 	u64 cmb_start_time;		/* clock value of cmb reset */
111 	void *cmb_wait;			/* deferred cmb enable/disable */
112 };
113 
114 /*
115  * A css driver handles all subchannels of one type.
116  * Currently, we only care about I/O subchannels (type 0), these
117  * have a ccw_device connected to them.
118  */
119 struct subchannel;
120 struct css_driver {
121 	unsigned int subchannel_type;
122 	struct device_driver drv;
123 	void (*irq)(struct device *);
124 	int (*notify)(struct device *, int);
125 	void (*verify)(struct device *);
126 	void (*termination)(struct device *);
127 	int (*probe)(struct subchannel *);
128 	int (*remove)(struct subchannel *);
129 	void (*shutdown)(struct subchannel *);
130 };
131 
132 /*
133  * all css_drivers have the css_bus_type
134  */
135 extern struct bus_type css_bus_type;
136 extern struct css_driver io_subchannel_driver;
137 
138 extern int css_probe_device(struct subchannel_id);
139 extern struct subchannel * get_subchannel_by_schid(struct subchannel_id);
140 extern int css_init_done;
141 extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *);
142 
143 #define __MAX_SUBCHANNEL 65535
144 #define __MAX_SSID 3
145 #define __MAX_CHPID 255
146 #define __MAX_CSSID 0
147 
148 struct channel_subsystem {
149 	u8 cssid;
150 	int valid;
151 	struct channel_path *chps[__MAX_CHPID + 1];
152 	struct device device;
153 	struct pgid global_pgid;
154 	struct mutex mutex;
155 	/* channel measurement related */
156 	int cm_enabled;
157 	void *cub_addr1;
158 	void *cub_addr2;
159 };
160 #define to_css(dev) container_of(dev, struct channel_subsystem, device)
161 
162 extern struct bus_type css_bus_type;
163 extern struct channel_subsystem *css[];
164 
165 /* Some helper functions for disconnected state. */
166 int device_is_disconnected(struct subchannel *);
167 void device_set_disconnected(struct subchannel *);
168 void device_trigger_reprobe(struct subchannel *);
169 
170 /* Helper functions for vary on/off. */
171 int device_is_online(struct subchannel *);
172 void device_set_waiting(struct subchannel *);
173 
174 /* Machine check helper function. */
175 void device_kill_pending_timer(struct subchannel *);
176 
177 /* Helper functions to build lists for the slow path. */
178 extern int css_enqueue_subchannel_slow(struct subchannel_id schid);
179 void css_walk_subchannel_slow_list(void (*fn)(unsigned long));
180 void css_clear_subchannel_slow_list(void);
181 int css_slow_subchannels_exist(void);
182 extern int need_rescan;
183 
184 extern struct workqueue_struct *slow_path_wq;
185 extern struct work_struct slow_path_work;
186 #endif
187