| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _CSS_H | 
 | 2 | #define _CSS_H | 
 | 3 |  | 
| Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 4 | #include <linux/mutex.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | #include <linux/wait.h> | 
 | 6 | #include <linux/workqueue.h> | 
 | 7 |  | 
 | 8 | #include <asm/cio.h> | 
 | 9 |  | 
| Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 10 | #include "schid.h" | 
 | 11 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |  | 
| Cornelia Huck | a28c694 | 2006-01-06 00:19:23 -0800 | [diff] [blame] | 39 | struct extended_cssid { | 
 | 40 | 	u8 version; | 
 | 41 | 	u8 cssid; | 
 | 42 | } __attribute__ ((packed)); | 
 | 43 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | struct pgid { | 
 | 45 | 	union { | 
 | 46 | 		__u8 fc;   	/* SPID function code */ | 
 | 47 | 		struct path_state ps;	/* SNID path state */ | 
| Peter Oberparleiter | 4ae9538 | 2006-06-04 02:51:28 -0700 | [diff] [blame] | 48 | 	} __attribute__ ((packed)) inf; | 
| Cornelia Huck | a28c694 | 2006-01-06 00:19:23 -0800 | [diff] [blame] | 49 | 	union { | 
 | 50 | 		__u32 cpu_addr	: 16;	/* CPU address */ | 
 | 51 | 		struct extended_cssid ext_cssid; | 
| Peter Oberparleiter | 4ae9538 | 2006-06-04 02:51:28 -0700 | [diff] [blame] | 52 | 	} __attribute__ ((packed)) pgid_high; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 */ | 
| Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 80 | 	__u16 sch_no;		/* subchannel number */ | 
| Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 81 | 	__u8 ssid;              /* subchannel set id */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 */ | 
| Cornelia Huck | 7e56081 | 2006-07-12 16:40:19 +0200 | [diff] [blame] | 103 | 	struct pgid pgid[8];	/* path group IDs per chpid*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |  */ | 
| Cornelia Huck | 8bbace7 | 2006-01-11 10:56:22 +0100 | [diff] [blame] | 119 | struct subchannel; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 *); | 
| Cornelia Huck | 8bbace7 | 2006-01-11 10:56:22 +0100 | [diff] [blame] | 127 | 	int (*probe)(struct subchannel *); | 
 | 128 | 	int (*remove)(struct subchannel *); | 
 | 129 | 	void (*shutdown)(struct subchannel *); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |  | 
| Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 138 | extern int css_probe_device(struct subchannel_id); | 
| Cornelia Huck | 6ab4879 | 2006-07-12 16:39:50 +0200 | [diff] [blame] | 139 | extern int css_sch_device_register(struct subchannel *); | 
 | 140 | extern void css_sch_device_unregister(struct subchannel *); | 
| Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 141 | extern struct subchannel * get_subchannel_by_schid(struct subchannel_id); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | extern int css_init_done; | 
| Cornelia Huck | f97a56f | 2006-01-06 00:19:22 -0800 | [diff] [blame] | 143 | extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 |  | 
| Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 145 | #define __MAX_SUBCHANNEL 65535 | 
| Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 146 | #define __MAX_SSID 3 | 
| Cornelia Huck | a28c694 | 2006-01-06 00:19:23 -0800 | [diff] [blame] | 147 | #define __MAX_CHPID 255 | 
 | 148 | #define __MAX_CSSID 0 | 
 | 149 |  | 
 | 150 | struct channel_subsystem { | 
 | 151 | 	u8 cssid; | 
 | 152 | 	int valid; | 
| Cornelia Huck | 871931c | 2006-01-14 13:21:03 -0800 | [diff] [blame] | 153 | 	struct channel_path *chps[__MAX_CHPID + 1]; | 
| Cornelia Huck | a28c694 | 2006-01-06 00:19:23 -0800 | [diff] [blame] | 154 | 	struct device device; | 
 | 155 | 	struct pgid global_pgid; | 
| Cornelia Huck | 495a5b4 | 2006-03-24 03:15:14 -0800 | [diff] [blame] | 156 | 	struct mutex mutex; | 
 | 157 | 	/* channel measurement related */ | 
 | 158 | 	int cm_enabled; | 
 | 159 | 	void *cub_addr1; | 
 | 160 | 	void *cub_addr2; | 
| Cornelia Huck | a28c694 | 2006-01-06 00:19:23 -0800 | [diff] [blame] | 161 | }; | 
 | 162 | #define to_css(dev) container_of(dev, struct channel_subsystem, device) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 |  | 
 | 164 | extern struct bus_type css_bus_type; | 
| Cornelia Huck | a28c694 | 2006-01-06 00:19:23 -0800 | [diff] [blame] | 165 | extern struct channel_subsystem *css[]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 |  | 
 | 167 | /* Some helper functions for disconnected state. */ | 
 | 168 | int device_is_disconnected(struct subchannel *); | 
 | 169 | void device_set_disconnected(struct subchannel *); | 
 | 170 | void device_trigger_reprobe(struct subchannel *); | 
 | 171 |  | 
 | 172 | /* Helper functions for vary on/off. */ | 
 | 173 | int device_is_online(struct subchannel *); | 
 | 174 | void device_set_waiting(struct subchannel *); | 
 | 175 |  | 
 | 176 | /* Machine check helper function. */ | 
 | 177 | void device_kill_pending_timer(struct subchannel *); | 
 | 178 |  | 
 | 179 | /* Helper functions to build lists for the slow path. */ | 
| Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 180 | extern int css_enqueue_subchannel_slow(struct subchannel_id schid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | void css_walk_subchannel_slow_list(void (*fn)(unsigned long)); | 
 | 182 | void css_clear_subchannel_slow_list(void); | 
 | 183 | int css_slow_subchannels_exist(void); | 
 | 184 | extern int need_rescan; | 
 | 185 |  | 
 | 186 | extern struct workqueue_struct *slow_path_wq; | 
 | 187 | extern struct work_struct slow_path_work; | 
 | 188 | #endif |