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