blob: 71fe380f86f6ecb6233374d7553c7419435481f9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _CSS_H
2#define _CSS_H
3
Cornelia Huck495a5b42006-03-24 03:15:14 -08004#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005#include <linux/wait.h>
6#include <linux/workqueue.h>
7
8#include <asm/cio.h>
9
Cornelia Hucka8237fc2006-01-06 00:19:21 -080010#include "schid.h"
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012/*
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
32struct 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
Cornelia Hucka28c6942006-01-06 00:19:23 -080039struct extended_cssid {
40 u8 version;
41 u8 cssid;
42} __attribute__ ((packed));
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044struct pgid {
45 union {
46 __u8 fc; /* SPID function code */
47 struct path_state ps; /* SNID path state */
Peter Oberparleiter4ae95382006-06-04 02:51:28 -070048 } __attribute__ ((packed)) inf;
Cornelia Hucka28c6942006-01-06 00:19:23 -080049 union {
50 __u32 cpu_addr : 16; /* CPU address */
51 struct extended_cssid ext_cssid;
Peter Oberparleiter4ae95382006-06-04 02:51:28 -070052 } __attribute__ ((packed)) pgid_high;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 __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
Linus Torvalds1da177e2005-04-16 15:20:36 -070058#define MAX_CIWS 8
59
60/*
61 * sense-id response buffer layout
62 */
63struct 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
75struct ccw_device_private {
Martin Schwidefskyc1637532006-12-08 15:53:57 +010076 struct ccw_device *cdev;
77 struct subchannel *sch;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 int state; /* device state */
79 atomic_t onoff;
80 unsigned long registered;
Cornelia Huck78964262006-10-11 15:31:38 +020081 struct ccw_dev_id dev_id; /* device id */
82 struct subchannel_id schid; /* subchannel number */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 __u8 imask; /* lpm mask for SNID/SID/SPGID */
84 int iretry; /* retry counter SNID/SID/SPGID */
85 struct {
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;
91 struct {
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 */
Cornelia Huckd23861f2006-12-04 15:41:04 +010099 unsigned int intretry:1; /* retry internal operation */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 } __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 */
Cornelia Huck7e560812006-07-12 16:40:19 +0200105 struct pgid pgid[8]; /* path group IDs per chpid*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 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 */
114};
115
116/*
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.
120 */
Cornelia Huck8bbace72006-01-11 10:56:22 +0100121struct subchannel;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122struct css_driver {
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 *);
Cornelia Huck8bbace72006-01-11 10:56:22 +0100129 int (*probe)(struct subchannel *);
130 int (*remove)(struct subchannel *);
131 void (*shutdown)(struct subchannel *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132};
133
134/*
135 * all css_drivers have the css_bus_type
136 */
137extern struct bus_type css_bus_type;
138extern struct css_driver io_subchannel_driver;
139
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800140extern int css_probe_device(struct subchannel_id);
Cornelia Huck6ab48792006-07-12 16:39:50 +0200141extern int css_sch_device_register(struct subchannel *);
142extern void css_sch_device_unregister(struct subchannel *);
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800143extern struct subchannel * get_subchannel_by_schid(struct subchannel_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144extern int css_init_done;
Cornelia Huckf97a56f2006-01-06 00:19:22 -0800145extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800147#define __MAX_SUBCHANNEL 65535
Cornelia Huckfb6958a2006-01-06 00:19:25 -0800148#define __MAX_SSID 3
Cornelia Hucka28c6942006-01-06 00:19:23 -0800149#define __MAX_CHPID 255
150#define __MAX_CSSID 0
151
152struct channel_subsystem {
153 u8 cssid;
154 int valid;
Cornelia Huck871931c2006-01-14 13:21:03 -0800155 struct channel_path *chps[__MAX_CHPID + 1];
Cornelia Hucka28c6942006-01-06 00:19:23 -0800156 struct device device;
157 struct pgid global_pgid;
Cornelia Huck495a5b42006-03-24 03:15:14 -0800158 struct mutex mutex;
159 /* channel measurement related */
160 int cm_enabled;
161 void *cub_addr1;
162 void *cub_addr2;
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +0100163 /* for orphaned ccw devices */
164 struct subchannel *pseudo_subchannel;
Cornelia Hucka28c6942006-01-06 00:19:23 -0800165};
166#define to_css(dev) container_of(dev, struct channel_subsystem, device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
168extern struct bus_type css_bus_type;
Cornelia Hucka28c6942006-01-06 00:19:23 -0800169extern struct channel_subsystem *css[];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
171/* Some helper functions for disconnected state. */
172int device_is_disconnected(struct subchannel *);
173void device_set_disconnected(struct subchannel *);
174void device_trigger_reprobe(struct subchannel *);
175
176/* Helper functions for vary on/off. */
177int device_is_online(struct subchannel *);
Cornelia Hucke7769b42006-10-11 15:31:41 +0200178void device_kill_io(struct subchannel *);
Cornelia Huckd23861f2006-12-04 15:41:04 +0100179void device_set_intretry(struct subchannel *sch);
Cornelia Huck24cb5b42006-12-04 15:41:01 +0100180int device_trigger_verify(struct subchannel *sch);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
182/* Machine check helper function. */
183void device_kill_pending_timer(struct subchannel *);
184
185/* Helper functions to build lists for the slow path. */
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800186extern int css_enqueue_subchannel_slow(struct subchannel_id schid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187void css_walk_subchannel_slow_list(void (*fn)(unsigned long));
188void css_clear_subchannel_slow_list(void);
189int css_slow_subchannels_exist(void);
190extern int need_rescan;
191
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +0100192int sch_is_pseudo_sch(struct subchannel *);
193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194extern struct workqueue_struct *slow_path_wq;
195extern struct work_struct slow_path_work;
Cornelia Huck7674da72006-12-08 15:54:21 +0100196
197int subchannel_add_files (struct device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198#endif