File: /usr/src/linux/include/asm-s390x/chandev.h
1 /*
2 * include/asm-s390/chandev.h
3 *
4 * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
5 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
6 *
7 * Generic channel device initialisation support.
8 */
9 #ifndef __S390_CHANDEV_H
10 #define __S390_CHANDEV_H
11 #include <linux/version.h>
12 #include <asm/types.h>
13 #include <linux/netdevice.h>
14
15
16 /* Setting this flag to true causes a device name to be built based on the read_devno of the device */
17 /* this is exported so external code can look at this flags setting */
18 extern int chandev_use_devno_names;
19
20
21 /* chandev_type is a bitmask for registering & describing device types. */
22 typedef enum
23 {
24 chandev_type_none=0x0,
25 chandev_type_ctc=0x1,
26 chandev_type_escon=0x2,
27 chandev_type_lcs=0x4,
28 chandev_type_osad=0x8,
29 chandev_type_qeth=0x10,
30 chandev_type_claw=0x20,
31 } chandev_type;
32
33 typedef enum
34 {
35 chandev_category_none,
36 chandev_category_network_device,
37 chandev_category_serial_device,
38 } chandev_category;
39
40
41
42 typedef struct
43 {
44 int irq;
45 u16 devno;
46 u16 cu_type; /* control unit type */
47 u8 cu_model; /* control unit model */
48 u16 dev_type; /* device type */
49 u8 dev_model; /* device model */
50 u8 pim; /* path installed mask */
51 u8 chpid[8]; /* CHPID 0-7 (if available) */
52 } chandev_subchannel_info;
53
54 #define CLAW_NAMELEN 9
55 /* CLAW specific parameters other drivers should ignore these fields */
56 typedef struct
57 {
58
59 char host_name[CLAW_NAMELEN]; /* local host name */
60 char adapter_name[CLAW_NAMELEN]; /* workstation adapter name */
61 char api_type[CLAW_NAMELEN]; /* API type either TCPIP or API */
62 } chandev_claw_info;
63
64 /*
65 * The chandev_probeinfo structure is passed to the device driver with configuration
66 * info for which irq's & ports to use when attempting to probe the device.
67 */
68 typedef struct
69 {
70 chandev_subchannel_info read;
71 chandev_subchannel_info write;
72 chandev_subchannel_info data;
73 /* memory_usage_in_k is the suggested memory the driver should attempt to use for io */
74 /* buffers -1 means use the driver default the driver should set this field to the */
75 /* amount of memory it actually uses when returning this probeinfo to the channel */
76 /* device layer with chandev_initdevice */
77 s32 memory_usage_in_k;
78 chandev_claw_info claw;
79 u8 data_exists; /* whether this device has a data channel */
80 u8 cu_dev_info_inconsistent; /* either ctc or we possibly had a bad sense_id */
81 u8 chpid_info_inconsistent; /* either ctc or schib info bad */
82 s16 port_protocol_no; /* 0 by default, set specifically when forcing */
83 u8 hint_port_no; /* lcs specific */
84 u8 max_port_no; /* lcs/qeth specific */
85 chandev_type chan_type;
86 u8 checksum_received_ip_pkts;
87 u8 use_hw_stats; /* where available e.g. lcs */
88 u8 device_forced; /* indicates the device hasn't been autodetected */
89 char *parmstr; /* driver specific parameters added by add_parms keyword */
90 /* newdevice used internally by chandev.c */
91 struct chandev_activelist *newdevice;
92 s32 devif_num;
93 /* devif_num=-1 implies don't care,0 implies tr0, info used by chandev_initnetdevice */
94 } chandev_probeinfo;
95
96 /*
97 * This is a wrapper to the machine check handler & should be used
98 * instead of reqest_irq or s390_request_irq_special for anything
99 * using the channel device layer.
100 */
101 int chandev_request_irq(unsigned int irq,
102 void (*handler)(int, void *, struct pt_regs *),
103 unsigned long irqflags,
104 const char *devname,
105 void *dev_id);
106 /*
107 * I originally believed this function wouldn't be necessary
108 * I subsequently found that reprobing failed in certain cases :-(,
109 * It is just a wrapper for free irq.
110 */
111 void chandev_free_irq(unsigned int irq, void *dev_id);
112
113 typedef enum
114 {
115 chandev_status_good,
116 chandev_status_not_oper,
117 chandev_status_first_msck=chandev_status_not_oper,
118 chandev_status_no_path,
119 chandev_status_revalidate,
120 chandev_status_gone,
121 chandev_status_last_msck,
122 chandev_status_all_chans_good /* pseudo machine check to indicate all channels are healthy */
123 } chandev_msck_status;
124
125 typedef int (*chandev_probefunc)(chandev_probeinfo *probeinfo);
126 typedef int (*chandev_shutdownfunc)(void *device);
127 typedef void (*chandev_unregfunc)(void *device);
128 typedef void (*chandev_msck_notification_func)(void *device,int msck_irq,
129 chandev_msck_status prevstatus,chandev_msck_status newstatus);
130
131
132
133 /* A driver should call chandev_register_and_probe when ready to be probed,
134 * after registeration the drivers probefunction will be called asynchronously
135 * when more devices become available at normal task time.
136 * The shutdownfunc parameter is used so that the channel layer
137 * can request a driver to close unregister itself & release its interrupts.
138 * repoper func is used when a device becomes operational again after being temporarily
139 * not operational the previous status is sent in the prevstatus variable.
140 * This can be used in cases when the default handling isn't quite adequete
141 * e.g. if a ssch is needed to reinitialize long running channel programs.
142 */
143 int chandev_register_and_probe(chandev_probefunc probefunc,
144 chandev_shutdownfunc shutdownfunc,
145 chandev_msck_notification_func msck_notfunc,
146 chandev_type chan_type);
147
148 /* The chandev_unregister function is typically called when a module is being removed
149 * from the system. The shutdown parameter if TRUE calls shutdownfunc for each
150 * device instance so the driver writer doesn't have to.
151 */
152 void chandev_unregister(chandev_probefunc probefunc,int call_shutdown);
153
154 /* chandev_initdevice should be called immeadiately before returning after */
155 /* a successful probe. */
156 int chandev_initdevice(chandev_probeinfo *probeinfo,void *dev_ptr,u8 port_no,char *devname,
157 chandev_category category,chandev_unregfunc unreg_dev);
158
159 /* This function builds a device name & copies it into destnamebuff suitable for calling
160 init_trdev or whatever & it honours the use_devno_names flag, it is used by chandev_initnetdevice
161 setting the buildfullname flag to TRUE will cause it to always build a full unique name based
162 on basename either honouring the chandev_use_devno_names flag if set or starting at index
163 0 & checking the namespace of the channel device layer itself for a free index, this
164 may be useful when one doesn't have control of the name an upper layer may choose.
165 It returns NULL on error.
166 */
167 char *chandev_build_device_name(chandev_probeinfo *probeinfo,char *destnamebuff,char *basename,int buildfullname);
168
169
170
171
172 /* chandev_init_netdev registers with the normal network device layer */
173 /* it doesn't update any of the chandev internal structures. */
174 /* i.e. it is optional */
175 /* it was part of chandev_initnetdevice but I separated it as */
176 /* chandev_initnetdevice may make too many assumptions for some users */
177 /* chandev_initnetdevice = chandev_initdevice followed by chandev_init_netdev */
178 #if LINUX_VERSION_CODE>=KERNEL_VERSION(2,3,0)
179 struct net_device *chandev_init_netdev(chandev_probeinfo *probeinfo,char *basename,
180 struct net_device *dev, int sizeof_priv,struct net_device *(*init_netdevfunc)(struct net_device *dev, int sizeof_priv));
181 #else
182 struct device *chandev_init_netdev(chandev_probeinfo *probeinfo,char *basename,
183 struct device *dev, int sizeof_priv,struct device *(*init_netdevfunc)(struct device *dev, int sizeof_priv));
184 #endif
185
186 /* chandev_initnetdevice registers a network device with the channel layer.
187 * It returns the device structure if successful,if dev=NULL it kmallocs it,
188 * On device initialisation failure it will kfree it under ALL curcumstances
189 * i.e. if dev is not NULL on entering this routine it MUST be malloced with kmalloc.
190 * The base name is tr ( e.g. tr0 without the 0 ), for token ring eth for ethernet,
191 * ctc or escon for ctc device drivers.
192 * If valid function pointers are given they will be called to setup,
193 * register & unregister the device.
194 * An example of setup is eth_setup in drivers/net/net_init.c.
195 * An example of init_dev is init_trdev(struct net_device *dev)
196 * & an example of unregister is unregister_trdev,
197 * unregister_netdev should be used for escon & ctc
198 * as there is no network unregister_ctcdev in the kernel.
199 */
200
201 #if LINUX_VERSION_CODE>=KERNEL_VERSION(2,3,0)
202 struct net_device *chandev_initnetdevice(chandev_probeinfo *probeinfo,u8 port_no,
203 struct net_device *dev,int sizeof_priv,
204 char *basename,
205 struct net_device *(*init_netdevfunc)
206 (struct net_device *dev, int sizeof_priv),
207 void (*unreg_netdevfunc)(struct net_device *dev));
208 #else
209 struct device *chandev_initnetdevice(chandev_probeinfo *probeinfo,u8 port_no,
210 struct device *dev,int sizeof_priv,
211 char *basename,
212 struct device *(*init_netdevfunc)
213 (struct device *dev, int sizeof_priv),
214 void (*unreg_netdevfunc)(struct device *dev));
215 #endif
216
217 /* chandev_add & delete model shouldn't normally be needed by drivers except if */
218 /* someone is developing a driver which the channel device layer doesn't know about */
219 void chandev_add_model(chandev_type chan_type,s32 cu_type,s16 cu_model,
220 s32 dev_type,s16 dev_model,u8 max_port_no,int auto_msck_recovery,
221 u8 default_checksum_received_ip_pkts,u8 default_use_hw_stats);
222 void chandev_del_model(s32 cu_type,s16 cu_model,s32 dev_type,s16 dev_model);
223
224 /* modules should use chandev_persist to see if they should stay loaded */
225 /* this is useful for debugging purposes where you may wish to examine */
226 /* /proc/s390dbf/ entries */
227 int chandev_persist(chandev_type chan_type);
228 #endif /* __S390_CHANDEV_H */
229
230
231
232
233
234