blob: 9ff064e71767657480ae3ee5dc185a05e334cd96 [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 {
76 int state; /* device state */
77 atomic_t onoff;
78 unsigned long registered;
Cornelia Huck78964262006-10-11 15:31:38 +020079 struct ccw_dev_id dev_id; /* device id */
80 struct subchannel_id schid; /* subchannel number */
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 __u8 imask; /* lpm mask for SNID/SID/SPGID */
82 int iretry; /* retry counter SNID/SID/SPGID */
83 struct {
84 unsigned int fast:1; /* post with "channel end" */
85 unsigned int repall:1; /* report every interrupt status */
86 unsigned int pgroup:1; /* do path grouping */
87 unsigned int force:1; /* allow forced online */
88 } __attribute__ ((packed)) options;
89 struct {
90 unsigned int pgid_single:1; /* use single path for Set PGID */
91 unsigned int esid:1; /* Ext. SenseID supported by HW */
92 unsigned int dosense:1; /* delayed SENSE required */
93 unsigned int doverify:1; /* delayed path verification */
94 unsigned int donotify:1; /* call notify function */
95 unsigned int recog_done:1; /* dev. recog. complete */
96 unsigned int fake_irb:1; /* deliver faked irb */
Cornelia Huckd23861f2006-12-04 15:41:04 +010097 unsigned int intretry:1; /* retry internal operation */
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 } __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 */
Cornelia Huck7e560812006-07-12 16:40:19 +0200103 struct pgid pgid[8]; /* path group IDs per chpid*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 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 */
Cornelia Huck8bbace72006-01-11 10:56:22 +0100119struct subchannel;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120struct 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 *);
Cornelia Huck8bbace72006-01-11 10:56:22 +0100127 int (*probe)(struct subchannel *);
128 int (*remove)(struct subchannel *);
129 void (*shutdown)(struct subchannel *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130};
131
132/*
133 * all css_drivers have the css_bus_type
134 */
135extern struct bus_type css_bus_type;
136extern struct css_driver io_subchannel_driver;
137
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800138extern int css_probe_device(struct subchannel_id);
Cornelia Huck6ab48792006-07-12 16:39:50 +0200139extern int css_sch_device_register(struct subchannel *);
140extern void css_sch_device_unregister(struct subchannel *);
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800141extern struct subchannel * get_subchannel_by_schid(struct subchannel_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142extern int css_init_done;
Cornelia Huckf97a56f2006-01-06 00:19:22 -0800143extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800145#define __MAX_SUBCHANNEL 65535
Cornelia Huckfb6958a2006-01-06 00:19:25 -0800146#define __MAX_SSID 3
Cornelia Hucka28c6942006-01-06 00:19:23 -0800147#define __MAX_CHPID 255
148#define __MAX_CSSID 0
149
150struct channel_subsystem {
151 u8 cssid;
152 int valid;
Cornelia Huck871931c2006-01-14 13:21:03 -0800153 struct channel_path *chps[__MAX_CHPID + 1];
Cornelia Hucka28c6942006-01-06 00:19:23 -0800154 struct device device;
155 struct pgid global_pgid;
Cornelia Huck495a5b42006-03-24 03:15:14 -0800156 struct mutex mutex;
157 /* channel measurement related */
158 int cm_enabled;
159 void *cub_addr1;
160 void *cub_addr2;
Cornelia Hucka28c6942006-01-06 00:19:23 -0800161};
162#define to_css(dev) container_of(dev, struct channel_subsystem, device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
164extern struct bus_type css_bus_type;
Cornelia Hucka28c6942006-01-06 00:19:23 -0800165extern struct channel_subsystem *css[];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166
167/* Some helper functions for disconnected state. */
168int device_is_disconnected(struct subchannel *);
169void device_set_disconnected(struct subchannel *);
170void device_trigger_reprobe(struct subchannel *);
171
172/* Helper functions for vary on/off. */
173int device_is_online(struct subchannel *);
Cornelia Hucke7769b42006-10-11 15:31:41 +0200174void device_kill_io(struct subchannel *);
Cornelia Huckd23861f2006-12-04 15:41:04 +0100175void device_set_intretry(struct subchannel *sch);
Cornelia Huck24cb5b42006-12-04 15:41:01 +0100176int device_trigger_verify(struct subchannel *sch);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177
178/* Machine check helper function. */
179void device_kill_pending_timer(struct subchannel *);
180
181/* Helper functions to build lists for the slow path. */
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800182extern int css_enqueue_subchannel_slow(struct subchannel_id schid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183void css_walk_subchannel_slow_list(void (*fn)(unsigned long));
184void css_clear_subchannel_slow_list(void);
185int css_slow_subchannels_exist(void);
186extern int need_rescan;
187
188extern struct workqueue_struct *slow_path_wq;
189extern struct work_struct slow_path_work;
190#endif