1*37002bc6SCosta Shulyupin============================= 2*37002bc6SCosta ShulyupinS/390 driver model interfaces 3*37002bc6SCosta Shulyupin============================= 4*37002bc6SCosta Shulyupin 5*37002bc6SCosta Shulyupin1. CCW devices 6*37002bc6SCosta Shulyupin-------------- 7*37002bc6SCosta Shulyupin 8*37002bc6SCosta ShulyupinAll devices which can be addressed by means of ccws are called 'CCW devices' - 9*37002bc6SCosta Shulyupineven if they aren't actually driven by ccws. 10*37002bc6SCosta Shulyupin 11*37002bc6SCosta ShulyupinAll ccw devices are accessed via a subchannel, this is reflected in the 12*37002bc6SCosta Shulyupinstructures under devices/:: 13*37002bc6SCosta Shulyupin 14*37002bc6SCosta Shulyupin devices/ 15*37002bc6SCosta Shulyupin - system/ 16*37002bc6SCosta Shulyupin - css0/ 17*37002bc6SCosta Shulyupin - 0.0.0000/0.0.0815/ 18*37002bc6SCosta Shulyupin - 0.0.0001/0.0.4711/ 19*37002bc6SCosta Shulyupin - 0.0.0002/ 20*37002bc6SCosta Shulyupin - 0.1.0000/0.1.1234/ 21*37002bc6SCosta Shulyupin ... 22*37002bc6SCosta Shulyupin - defunct/ 23*37002bc6SCosta Shulyupin 24*37002bc6SCosta ShulyupinIn this example, device 0815 is accessed via subchannel 0 in subchannel set 0, 25*37002bc6SCosta Shulyupindevice 4711 via subchannel 1 in subchannel set 0, and subchannel 2 is a non-I/O 26*37002bc6SCosta Shulyupinsubchannel. Device 1234 is accessed via subchannel 0 in subchannel set 1. 27*37002bc6SCosta Shulyupin 28*37002bc6SCosta ShulyupinThe subchannel named 'defunct' does not represent any real subchannel on the 29*37002bc6SCosta Shulyupinsystem; it is a pseudo subchannel where disconnected ccw devices are moved to 30*37002bc6SCosta Shulyupinif they are displaced by another ccw device becoming operational on their 31*37002bc6SCosta Shulyupinformer subchannel. The ccw devices will be moved again to a proper subchannel 32*37002bc6SCosta Shulyupinif they become operational again on that subchannel. 33*37002bc6SCosta Shulyupin 34*37002bc6SCosta ShulyupinYou should address a ccw device via its bus id (e.g. 0.0.4711); the device can 35*37002bc6SCosta Shulyupinbe found under bus/ccw/devices/. 36*37002bc6SCosta Shulyupin 37*37002bc6SCosta ShulyupinAll ccw devices export some data via sysfs. 38*37002bc6SCosta Shulyupin 39*37002bc6SCosta Shulyupincutype: 40*37002bc6SCosta Shulyupin The control unit type / model. 41*37002bc6SCosta Shulyupin 42*37002bc6SCosta Shulyupindevtype: 43*37002bc6SCosta Shulyupin The device type / model, if applicable. 44*37002bc6SCosta Shulyupin 45*37002bc6SCosta Shulyupinavailability: 46*37002bc6SCosta Shulyupin Can be 'good' or 'boxed'; 'no path' or 'no device' for 47*37002bc6SCosta Shulyupin disconnected devices. 48*37002bc6SCosta Shulyupin 49*37002bc6SCosta Shulyupinonline: 50*37002bc6SCosta Shulyupin An interface to set the device online and offline. 51*37002bc6SCosta Shulyupin In the special case of the device being disconnected (see the 52*37002bc6SCosta Shulyupin notify function under 1.2), piping 0 to online will forcibly delete 53*37002bc6SCosta Shulyupin the device. 54*37002bc6SCosta Shulyupin 55*37002bc6SCosta ShulyupinThe device drivers can add entries to export per-device data and interfaces. 56*37002bc6SCosta Shulyupin 57*37002bc6SCosta ShulyupinThere is also some data exported on a per-subchannel basis (see under 58*37002bc6SCosta Shulyupinbus/css/devices/): 59*37002bc6SCosta Shulyupin 60*37002bc6SCosta Shulyupinchpids: 61*37002bc6SCosta Shulyupin Via which chpids the device is connected. 62*37002bc6SCosta Shulyupin 63*37002bc6SCosta Shulyupinpimpampom: 64*37002bc6SCosta Shulyupin The path installed, path available and path operational masks. 65*37002bc6SCosta Shulyupin 66*37002bc6SCosta ShulyupinThere also might be additional data, for example for block devices. 67*37002bc6SCosta Shulyupin 68*37002bc6SCosta Shulyupin 69*37002bc6SCosta Shulyupin1.1 Bringing up a ccw device 70*37002bc6SCosta Shulyupin---------------------------- 71*37002bc6SCosta Shulyupin 72*37002bc6SCosta ShulyupinThis is done in several steps. 73*37002bc6SCosta Shulyupin 74*37002bc6SCosta Shulyupina. Each driver can provide one or more parameter interfaces where parameters can 75*37002bc6SCosta Shulyupin be specified. These interfaces are also in the driver's responsibility. 76*37002bc6SCosta Shulyupinb. After a. has been performed, if necessary, the device is finally brought up 77*37002bc6SCosta Shulyupin via the 'online' interface. 78*37002bc6SCosta Shulyupin 79*37002bc6SCosta Shulyupin 80*37002bc6SCosta Shulyupin1.2 Writing a driver for ccw devices 81*37002bc6SCosta Shulyupin------------------------------------ 82*37002bc6SCosta Shulyupin 83*37002bc6SCosta ShulyupinThe basic struct ccw_device and struct ccw_driver data structures can be found 84*37002bc6SCosta Shulyupinunder include/asm/ccwdev.h:: 85*37002bc6SCosta Shulyupin 86*37002bc6SCosta Shulyupin struct ccw_device { 87*37002bc6SCosta Shulyupin spinlock_t *ccwlock; 88*37002bc6SCosta Shulyupin struct ccw_device_private *private; 89*37002bc6SCosta Shulyupin struct ccw_device_id id; 90*37002bc6SCosta Shulyupin 91*37002bc6SCosta Shulyupin struct ccw_driver *drv; 92*37002bc6SCosta Shulyupin struct device dev; 93*37002bc6SCosta Shulyupin int online; 94*37002bc6SCosta Shulyupin 95*37002bc6SCosta Shulyupin void (*handler) (struct ccw_device *dev, unsigned long intparm, 96*37002bc6SCosta Shulyupin struct irb *irb); 97*37002bc6SCosta Shulyupin }; 98*37002bc6SCosta Shulyupin 99*37002bc6SCosta Shulyupin struct ccw_driver { 100*37002bc6SCosta Shulyupin struct module *owner; 101*37002bc6SCosta Shulyupin struct ccw_device_id *ids; 102*37002bc6SCosta Shulyupin int (*probe) (struct ccw_device *); 103*37002bc6SCosta Shulyupin int (*remove) (struct ccw_device *); 104*37002bc6SCosta Shulyupin int (*set_online) (struct ccw_device *); 105*37002bc6SCosta Shulyupin int (*set_offline) (struct ccw_device *); 106*37002bc6SCosta Shulyupin int (*notify) (struct ccw_device *, int); 107*37002bc6SCosta Shulyupin struct device_driver driver; 108*37002bc6SCosta Shulyupin char *name; 109*37002bc6SCosta Shulyupin }; 110*37002bc6SCosta Shulyupin 111*37002bc6SCosta ShulyupinThe 'private' field contains data needed for internal i/o operation only, and 112*37002bc6SCosta Shulyupinis not available to the device driver. 113*37002bc6SCosta Shulyupin 114*37002bc6SCosta ShulyupinEach driver should declare in a MODULE_DEVICE_TABLE into which CU types/models 115*37002bc6SCosta Shulyupinand/or device types/models it is interested. This information can later be found 116*37002bc6SCosta Shulyupinin the struct ccw_device_id fields:: 117*37002bc6SCosta Shulyupin 118*37002bc6SCosta Shulyupin struct ccw_device_id { 119*37002bc6SCosta Shulyupin __u16 match_flags; 120*37002bc6SCosta Shulyupin 121*37002bc6SCosta Shulyupin __u16 cu_type; 122*37002bc6SCosta Shulyupin __u16 dev_type; 123*37002bc6SCosta Shulyupin __u8 cu_model; 124*37002bc6SCosta Shulyupin __u8 dev_model; 125*37002bc6SCosta Shulyupin 126*37002bc6SCosta Shulyupin unsigned long driver_info; 127*37002bc6SCosta Shulyupin }; 128*37002bc6SCosta Shulyupin 129*37002bc6SCosta ShulyupinThe functions in ccw_driver should be used in the following way: 130*37002bc6SCosta Shulyupin 131*37002bc6SCosta Shulyupinprobe: 132*37002bc6SCosta Shulyupin This function is called by the device layer for each device the driver 133*37002bc6SCosta Shulyupin is interested in. The driver should only allocate private structures 134*37002bc6SCosta Shulyupin to put in dev->driver_data and create attributes (if needed). Also, 135*37002bc6SCosta Shulyupin the interrupt handler (see below) should be set here. 136*37002bc6SCosta Shulyupin 137*37002bc6SCosta Shulyupin:: 138*37002bc6SCosta Shulyupin 139*37002bc6SCosta Shulyupin int (*probe) (struct ccw_device *cdev); 140*37002bc6SCosta Shulyupin 141*37002bc6SCosta ShulyupinParameters: 142*37002bc6SCosta Shulyupin cdev 143*37002bc6SCosta Shulyupin - the device to be probed. 144*37002bc6SCosta Shulyupin 145*37002bc6SCosta Shulyupin 146*37002bc6SCosta Shulyupinremove: 147*37002bc6SCosta Shulyupin This function is called by the device layer upon removal of the driver, 148*37002bc6SCosta Shulyupin the device or the module. The driver should perform cleanups here. 149*37002bc6SCosta Shulyupin 150*37002bc6SCosta Shulyupin:: 151*37002bc6SCosta Shulyupin 152*37002bc6SCosta Shulyupin int (*remove) (struct ccw_device *cdev); 153*37002bc6SCosta Shulyupin 154*37002bc6SCosta ShulyupinParameters: 155*37002bc6SCosta Shulyupin cdev 156*37002bc6SCosta Shulyupin - the device to be removed. 157*37002bc6SCosta Shulyupin 158*37002bc6SCosta Shulyupin 159*37002bc6SCosta Shulyupinset_online: 160*37002bc6SCosta Shulyupin This function is called by the common I/O layer when the device is 161*37002bc6SCosta Shulyupin activated via the 'online' attribute. The driver should finally 162*37002bc6SCosta Shulyupin setup and activate the device here. 163*37002bc6SCosta Shulyupin 164*37002bc6SCosta Shulyupin:: 165*37002bc6SCosta Shulyupin 166*37002bc6SCosta Shulyupin int (*set_online) (struct ccw_device *); 167*37002bc6SCosta Shulyupin 168*37002bc6SCosta ShulyupinParameters: 169*37002bc6SCosta Shulyupin cdev 170*37002bc6SCosta Shulyupin - the device to be activated. The common layer has 171*37002bc6SCosta Shulyupin verified that the device is not already online. 172*37002bc6SCosta Shulyupin 173*37002bc6SCosta Shulyupin 174*37002bc6SCosta Shulyupinset_offline: This function is called by the common I/O layer when the device is 175*37002bc6SCosta Shulyupin de-activated via the 'online' attribute. The driver should shut 176*37002bc6SCosta Shulyupin down the device, but not de-allocate its private data. 177*37002bc6SCosta Shulyupin 178*37002bc6SCosta Shulyupin:: 179*37002bc6SCosta Shulyupin 180*37002bc6SCosta Shulyupin int (*set_offline) (struct ccw_device *); 181*37002bc6SCosta Shulyupin 182*37002bc6SCosta ShulyupinParameters: 183*37002bc6SCosta Shulyupin cdev 184*37002bc6SCosta Shulyupin - the device to be deactivated. The common layer has 185*37002bc6SCosta Shulyupin verified that the device is online. 186*37002bc6SCosta Shulyupin 187*37002bc6SCosta Shulyupin 188*37002bc6SCosta Shulyupinnotify: 189*37002bc6SCosta Shulyupin This function is called by the common I/O layer for some state changes 190*37002bc6SCosta Shulyupin of the device. 191*37002bc6SCosta Shulyupin 192*37002bc6SCosta Shulyupin Signalled to the driver are: 193*37002bc6SCosta Shulyupin 194*37002bc6SCosta Shulyupin * In online state, device detached (CIO_GONE) or last path gone 195*37002bc6SCosta Shulyupin (CIO_NO_PATH). The driver must return !0 to keep the device; for 196*37002bc6SCosta Shulyupin return code 0, the device will be deleted as usual (also when no 197*37002bc6SCosta Shulyupin notify function is registered). If the driver wants to keep the 198*37002bc6SCosta Shulyupin device, it is moved into disconnected state. 199*37002bc6SCosta Shulyupin * In disconnected state, device operational again (CIO_OPER). The 200*37002bc6SCosta Shulyupin common I/O layer performs some sanity checks on device number and 201*37002bc6SCosta Shulyupin Device / CU to be reasonably sure if it is still the same device. 202*37002bc6SCosta Shulyupin If not, the old device is removed and a new one registered. By the 203*37002bc6SCosta Shulyupin return code of the notify function the device driver signals if it 204*37002bc6SCosta Shulyupin wants the device back: !0 for keeping, 0 to make the device being 205*37002bc6SCosta Shulyupin removed and re-registered. 206*37002bc6SCosta Shulyupin 207*37002bc6SCosta Shulyupin:: 208*37002bc6SCosta Shulyupin 209*37002bc6SCosta Shulyupin int (*notify) (struct ccw_device *, int); 210*37002bc6SCosta Shulyupin 211*37002bc6SCosta ShulyupinParameters: 212*37002bc6SCosta Shulyupin cdev 213*37002bc6SCosta Shulyupin - the device whose state changed. 214*37002bc6SCosta Shulyupin 215*37002bc6SCosta Shulyupin event 216*37002bc6SCosta Shulyupin - the event that happened. This can be one of CIO_GONE, 217*37002bc6SCosta Shulyupin CIO_NO_PATH or CIO_OPER. 218*37002bc6SCosta Shulyupin 219*37002bc6SCosta ShulyupinThe handler field of the struct ccw_device is meant to be set to the interrupt 220*37002bc6SCosta Shulyupinhandler for the device. In order to accommodate drivers which use several 221*37002bc6SCosta Shulyupindistinct handlers (e.g. multi subchannel devices), this is a member of ccw_device 222*37002bc6SCosta Shulyupininstead of ccw_driver. 223*37002bc6SCosta ShulyupinThe handler is registered with the common layer during set_online() processing 224*37002bc6SCosta Shulyupinbefore the driver is called, and is deregistered during set_offline() after the 225*37002bc6SCosta Shulyupindriver has been called. Also, after registering / before deregistering, path 226*37002bc6SCosta Shulyupingrouping resp. disbanding of the path group (if applicable) are performed. 227*37002bc6SCosta Shulyupin 228*37002bc6SCosta Shulyupin:: 229*37002bc6SCosta Shulyupin 230*37002bc6SCosta Shulyupin void (*handler) (struct ccw_device *dev, unsigned long intparm, struct irb *irb); 231*37002bc6SCosta Shulyupin 232*37002bc6SCosta ShulyupinParameters: dev - the device the handler is called for 233*37002bc6SCosta Shulyupin intparm - the intparm which allows the device driver to identify 234*37002bc6SCosta Shulyupin the i/o the interrupt is associated with, or to recognize 235*37002bc6SCosta Shulyupin the interrupt as unsolicited. 236*37002bc6SCosta Shulyupin irb - interruption response block which contains the accumulated 237*37002bc6SCosta Shulyupin status. 238*37002bc6SCosta Shulyupin 239*37002bc6SCosta ShulyupinThe device driver is called from the common ccw_device layer and can retrieve 240*37002bc6SCosta Shulyupininformation about the interrupt from the irb parameter. 241*37002bc6SCosta Shulyupin 242*37002bc6SCosta Shulyupin 243*37002bc6SCosta Shulyupin1.3 ccwgroup devices 244*37002bc6SCosta Shulyupin-------------------- 245*37002bc6SCosta Shulyupin 246*37002bc6SCosta ShulyupinThe ccwgroup mechanism is designed to handle devices consisting of multiple ccw 247*37002bc6SCosta Shulyupindevices, like lcs or ctc. 248*37002bc6SCosta Shulyupin 249*37002bc6SCosta ShulyupinThe ccw driver provides a 'group' attribute. Piping bus ids of ccw devices to 250*37002bc6SCosta Shulyupinthis attributes creates a ccwgroup device consisting of these ccw devices (if 251*37002bc6SCosta Shulyupinpossible). This ccwgroup device can be set online or offline just like a normal 252*37002bc6SCosta Shulyupinccw device. 253*37002bc6SCosta Shulyupin 254*37002bc6SCosta ShulyupinEach ccwgroup device also provides an 'ungroup' attribute to destroy the device 255*37002bc6SCosta Shulyupinagain (only when offline). This is a generic ccwgroup mechanism (the driver does 256*37002bc6SCosta Shulyupinnot need to implement anything beyond normal removal routines). 257*37002bc6SCosta Shulyupin 258*37002bc6SCosta ShulyupinA ccw device which is a member of a ccwgroup device carries a pointer to the 259*37002bc6SCosta Shulyupinccwgroup device in the driver_data of its device struct. This field must not be 260*37002bc6SCosta Shulyupintouched by the driver - it should use the ccwgroup device's driver_data for its 261*37002bc6SCosta Shulyupinprivate data. 262*37002bc6SCosta Shulyupin 263*37002bc6SCosta ShulyupinTo implement a ccwgroup driver, please refer to include/asm/ccwgroup.h. Keep in 264*37002bc6SCosta Shulyupinmind that most drivers will need to implement both a ccwgroup and a ccw 265*37002bc6SCosta Shulyupindriver. 266*37002bc6SCosta Shulyupin 267*37002bc6SCosta Shulyupin 268*37002bc6SCosta Shulyupin2. Channel paths 269*37002bc6SCosta Shulyupin----------------- 270*37002bc6SCosta Shulyupin 271*37002bc6SCosta ShulyupinChannel paths show up, like subchannels, under the channel subsystem root (css0) 272*37002bc6SCosta Shulyupinand are called 'chp0.<chpid>'. They have no driver and do not belong to any bus. 273*37002bc6SCosta ShulyupinPlease note, that unlike /proc/chpids in 2.4, the channel path objects reflect 274*37002bc6SCosta Shulyupinonly the logical state and not the physical state, since we cannot track the 275*37002bc6SCosta Shulyupinlatter consistently due to lacking machine support (we don't need to be aware 276*37002bc6SCosta Shulyupinof it anyway). 277*37002bc6SCosta Shulyupin 278*37002bc6SCosta Shulyupinstatus 279*37002bc6SCosta Shulyupin - Can be 'online' or 'offline'. 280*37002bc6SCosta Shulyupin Piping 'on' or 'off' sets the chpid logically online/offline. 281*37002bc6SCosta Shulyupin Piping 'on' to an online chpid triggers path reprobing for all devices 282*37002bc6SCosta Shulyupin the chpid connects to. This can be used to force the kernel to re-use 283*37002bc6SCosta Shulyupin a channel path the user knows to be online, but the machine hasn't 284*37002bc6SCosta Shulyupin created a machine check for. 285*37002bc6SCosta Shulyupin 286*37002bc6SCosta Shulyupintype 287*37002bc6SCosta Shulyupin - The physical type of the channel path. 288*37002bc6SCosta Shulyupin 289*37002bc6SCosta Shulyupinshared 290*37002bc6SCosta Shulyupin - Whether the channel path is shared. 291*37002bc6SCosta Shulyupin 292*37002bc6SCosta Shulyupincmg 293*37002bc6SCosta Shulyupin - The channel measurement group. 294*37002bc6SCosta Shulyupin 295*37002bc6SCosta Shulyupin3. System devices 296*37002bc6SCosta Shulyupin----------------- 297*37002bc6SCosta Shulyupin 298*37002bc6SCosta Shulyupin3.1 xpram 299*37002bc6SCosta Shulyupin--------- 300*37002bc6SCosta Shulyupin 301*37002bc6SCosta Shulyupinxpram shows up under devices/system/ as 'xpram'. 302*37002bc6SCosta Shulyupin 303*37002bc6SCosta Shulyupin3.2 cpus 304*37002bc6SCosta Shulyupin-------- 305*37002bc6SCosta Shulyupin 306*37002bc6SCosta ShulyupinFor each cpu, a directory is created under devices/system/cpu/. Each cpu has an 307*37002bc6SCosta Shulyupinattribute 'online' which can be 0 or 1. 308*37002bc6SCosta Shulyupin 309*37002bc6SCosta Shulyupin 310*37002bc6SCosta Shulyupin4. Other devices 311*37002bc6SCosta Shulyupin---------------- 312*37002bc6SCosta Shulyupin 313*37002bc6SCosta Shulyupin4.1 Netiucv 314*37002bc6SCosta Shulyupin----------- 315*37002bc6SCosta Shulyupin 316*37002bc6SCosta ShulyupinThe netiucv driver creates an attribute 'connection' under 317*37002bc6SCosta Shulyupinbus/iucv/drivers/netiucv. Piping to this attribute creates a new netiucv 318*37002bc6SCosta Shulyupinconnection to the specified host. 319*37002bc6SCosta Shulyupin 320*37002bc6SCosta ShulyupinNetiucv connections show up under devices/iucv/ as "netiucv<ifnum>". The interface 321*37002bc6SCosta Shulyupinnumber is assigned sequentially to the connections defined via the 'connection' 322*37002bc6SCosta Shulyupinattribute. 323*37002bc6SCosta Shulyupin 324*37002bc6SCosta Shulyupinuser 325*37002bc6SCosta Shulyupin - shows the connection partner. 326*37002bc6SCosta Shulyupin 327*37002bc6SCosta Shulyupinbuffer 328*37002bc6SCosta Shulyupin - maximum buffer size. Pipe to it to change buffer size. 329