1*4882a593Smuzhiyun=================================== 2*4882a593SmuzhiyunWriting s390 channel device drivers 3*4882a593Smuzhiyun=================================== 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun:Author: Cornelia Huck 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunIntroduction 8*4882a593Smuzhiyun============ 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunThis document describes the interfaces available for device drivers that 11*4882a593Smuzhiyundrive s390 based channel attached I/O devices. This includes interfaces 12*4882a593Smuzhiyunfor interaction with the hardware and interfaces for interacting with 13*4882a593Smuzhiyunthe common driver core. Those interfaces are provided by the s390 common 14*4882a593SmuzhiyunI/O layer. 15*4882a593Smuzhiyun 16*4882a593SmuzhiyunThe document assumes a familarity with the technical terms associated 17*4882a593Smuzhiyunwith the s390 channel I/O architecture. For a description of this 18*4882a593Smuzhiyunarchitecture, please refer to the "z/Architecture: Principles of 19*4882a593SmuzhiyunOperation", IBM publication no. SA22-7832. 20*4882a593Smuzhiyun 21*4882a593SmuzhiyunWhile most I/O devices on a s390 system are typically driven through the 22*4882a593Smuzhiyunchannel I/O mechanism described here, there are various other methods 23*4882a593Smuzhiyun(like the diag interface). These are out of the scope of this document. 24*4882a593Smuzhiyun 25*4882a593SmuzhiyunThe s390 common I/O layer also provides access to some devices that are 26*4882a593Smuzhiyunnot strictly considered I/O devices. They are considered here as well, 27*4882a593Smuzhiyunalthough they are not the focus of this document. 28*4882a593Smuzhiyun 29*4882a593SmuzhiyunSome additional information can also be found in the kernel source under 30*4882a593SmuzhiyunDocumentation/s390/driver-model.rst. 31*4882a593Smuzhiyun 32*4882a593SmuzhiyunThe css bus 33*4882a593Smuzhiyun=========== 34*4882a593Smuzhiyun 35*4882a593SmuzhiyunThe css bus contains the subchannels available on the system. They fall 36*4882a593Smuzhiyuninto several categories: 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun* Standard I/O subchannels, for use by the system. They have a child 39*4882a593Smuzhiyun device on the ccw bus and are described below. 40*4882a593Smuzhiyun* I/O subchannels bound to the vfio-ccw driver. See 41*4882a593Smuzhiyun Documentation/s390/vfio-ccw.rst. 42*4882a593Smuzhiyun* Message subchannels. No Linux driver currently exists. 43*4882a593Smuzhiyun* CHSC subchannels (at most one). The chsc subchannel driver can be used 44*4882a593Smuzhiyun to send asynchronous chsc commands. 45*4882a593Smuzhiyun* eADM subchannels. Used for talking to storage class memory. 46*4882a593Smuzhiyun 47*4882a593SmuzhiyunThe ccw bus 48*4882a593Smuzhiyun=========== 49*4882a593Smuzhiyun 50*4882a593SmuzhiyunThe ccw bus typically contains the majority of devices available to a 51*4882a593Smuzhiyuns390 system. Named after the channel command word (ccw), the basic 52*4882a593Smuzhiyuncommand structure used to address its devices, the ccw bus contains 53*4882a593Smuzhiyunso-called channel attached devices. They are addressed via I/O 54*4882a593Smuzhiyunsubchannels, visible on the css bus. A device driver for 55*4882a593Smuzhiyunchannel-attached devices, however, will never interact with the 56*4882a593Smuzhiyunsubchannel directly, but only via the I/O device on the ccw bus, the ccw 57*4882a593Smuzhiyundevice. 58*4882a593Smuzhiyun 59*4882a593SmuzhiyunI/O functions for channel-attached devices 60*4882a593Smuzhiyun------------------------------------------ 61*4882a593Smuzhiyun 62*4882a593SmuzhiyunSome hardware structures have been translated into C structures for use 63*4882a593Smuzhiyunby the common I/O layer and device drivers. For more information on the 64*4882a593Smuzhiyunhardware structures represented here, please consult the Principles of 65*4882a593SmuzhiyunOperation. 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun.. kernel-doc:: arch/s390/include/asm/cio.h 68*4882a593Smuzhiyun :internal: 69*4882a593Smuzhiyun 70*4882a593Smuzhiyunccw devices 71*4882a593Smuzhiyun----------- 72*4882a593Smuzhiyun 73*4882a593SmuzhiyunDevices that want to initiate channel I/O need to attach to the ccw bus. 74*4882a593SmuzhiyunInteraction with the driver core is done via the common I/O layer, which 75*4882a593Smuzhiyunprovides the abstractions of ccw devices and ccw device drivers. 76*4882a593Smuzhiyun 77*4882a593SmuzhiyunThe functions that initiate or terminate channel I/O all act upon a ccw 78*4882a593Smuzhiyundevice structure. Device drivers must not bypass those functions or 79*4882a593Smuzhiyunstrange side effects may happen. 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun.. kernel-doc:: arch/s390/include/asm/ccwdev.h 82*4882a593Smuzhiyun :internal: 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun.. kernel-doc:: drivers/s390/cio/device.c 85*4882a593Smuzhiyun :export: 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun.. kernel-doc:: drivers/s390/cio/device_ops.c 88*4882a593Smuzhiyun :export: 89*4882a593Smuzhiyun 90*4882a593SmuzhiyunThe channel-measurement facility 91*4882a593Smuzhiyun-------------------------------- 92*4882a593Smuzhiyun 93*4882a593SmuzhiyunThe channel-measurement facility provides a means to collect measurement 94*4882a593Smuzhiyundata which is made available by the channel subsystem for each channel 95*4882a593Smuzhiyunattached device. 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun.. kernel-doc:: arch/s390/include/uapi/asm/cmb.h 98*4882a593Smuzhiyun :internal: 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun.. kernel-doc:: drivers/s390/cio/cmf.c 101*4882a593Smuzhiyun :export: 102*4882a593Smuzhiyun 103*4882a593SmuzhiyunThe ccwgroup bus 104*4882a593Smuzhiyun================ 105*4882a593Smuzhiyun 106*4882a593SmuzhiyunThe ccwgroup bus only contains artificial devices, created by the user. 107*4882a593SmuzhiyunMany networking devices (e.g. qeth) are in fact composed of several ccw 108*4882a593Smuzhiyundevices (like read, write and data channel for qeth). The ccwgroup bus 109*4882a593Smuzhiyunprovides a mechanism to create a meta-device which contains those ccw 110*4882a593Smuzhiyundevices as slave devices and can be associated with the netdevice. 111*4882a593Smuzhiyun 112*4882a593Smuzhiyunccw group devices 113*4882a593Smuzhiyun----------------- 114*4882a593Smuzhiyun 115*4882a593Smuzhiyun.. kernel-doc:: arch/s390/include/asm/ccwgroup.h 116*4882a593Smuzhiyun :internal: 117*4882a593Smuzhiyun 118*4882a593Smuzhiyun.. kernel-doc:: drivers/s390/cio/ccwgroup.c 119*4882a593Smuzhiyun :export: 120*4882a593Smuzhiyun 121*4882a593SmuzhiyunGeneric interfaces 122*4882a593Smuzhiyun================== 123*4882a593Smuzhiyun 124*4882a593SmuzhiyunThe following section contains interfaces in use not only by drivers 125*4882a593Smuzhiyundealing with ccw devices, but drivers for various other s390 hardware 126*4882a593Smuzhiyunas well. 127*4882a593Smuzhiyun 128*4882a593SmuzhiyunAdapter interrupts 129*4882a593Smuzhiyun------------------ 130*4882a593Smuzhiyun 131*4882a593SmuzhiyunThe common I/O layer provides helper functions for dealing with adapter 132*4882a593Smuzhiyuninterrupts and interrupt vectors. 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun.. kernel-doc:: drivers/s390/cio/airq.c 135*4882a593Smuzhiyun :export: 136