/Documentation/s390/driver-model.txt

https://bitbucket.org/evzijst/gittest · Plain Text · 265 lines · 186 code · 79 blank · 0 comment · 0 complexity · dbff6855eb2b473fe4528b4794a3b416 MD5 · raw file

  1. S/390 driver model interfaces
  2. -----------------------------
  3. 1. CCW devices
  4. --------------
  5. All devices which can be addressed by means of ccws are called 'CCW devices' -
  6. even if they aren't actually driven by ccws.
  7. All ccw devices are accessed via a subchannel, this is reflected in the
  8. structures under root/:
  9. root/
  10. - sys
  11. - legacy
  12. - css0/
  13. - 0.0.0000/0.0.0815/
  14. - 0.0.0001/0.0.4711/
  15. - 0.0.0002/
  16. ...
  17. In this example, device 0815 is accessed via subchannel 0, device 4711 via
  18. subchannel 1, and subchannel 2 is a non-I/O subchannel.
  19. You should address a ccw device via its bus id (e.g. 0.0.4711); the device can
  20. be found under bus/ccw/devices/.
  21. All ccw devices export some data via sysfs.
  22. cutype: The control unit type / model.
  23. devtype: The device type / model, if applicable.
  24. availability: Can be 'good' or 'boxed'; 'no path' or 'no device' for
  25. disconnected devices.
  26. online: An interface to set the device online and offline.
  27. In the special case of the device being disconnected (see the
  28. notify function under 1.2), piping 0 to online will focibly delete
  29. the device.
  30. The device drivers can add entries to export per-device data and interfaces.
  31. There is also some data exported on a per-subchannel basis (see under
  32. bus/css/devices/):
  33. chpids: Via which chpids the device is connected.
  34. pimpampom: The path installed, path available and path operational masks.
  35. There also might be additional data, for example for block devices.
  36. 1.1 Bringing up a ccw device
  37. ----------------------------
  38. This is done in several steps.
  39. a. Each driver can provide one or more parameter interfaces where parameters can
  40. be specified. These interfaces are also in the driver's responsibility.
  41. b. After a. has been performed, if necessary, the device is finally brought up
  42. via the 'online' interface.
  43. 1.2 Writing a driver for ccw devices
  44. ------------------------------------
  45. The basic struct ccw_device and struct ccw_driver data structures can be found
  46. under include/asm/ccwdev.h.
  47. struct ccw_device {
  48. spinlock_t *ccwlock;
  49. struct ccw_device_private *private;
  50. struct ccw_device_id id;
  51. struct ccw_driver *drv;
  52. struct device dev;
  53. int online;
  54. void (*handler) (struct ccw_device *dev, unsigned long intparm,
  55. struct irb *irb);
  56. };
  57. struct ccw_driver {
  58. struct module *owner;
  59. struct ccw_device_id *ids;
  60. int (*probe) (struct ccw_device *);
  61. int (*remove) (struct ccw_device *);
  62. int (*set_online) (struct ccw_device *);
  63. int (*set_offline) (struct ccw_device *);
  64. int (*notify) (struct ccw_device *, int);
  65. struct device_driver driver;
  66. char *name;
  67. };
  68. The 'private' field contains data needed for internal i/o operation only, and
  69. is not available to the device driver.
  70. Each driver should declare in a MODULE_DEVICE_TABLE into which CU types/models
  71. and/or device types/models it is interested. This information can later be found
  72. found in the struct ccw_device_id fields:
  73. struct ccw_device_id {
  74. __u16 match_flags;
  75. __u16 cu_type;
  76. __u16 dev_type;
  77. __u8 cu_model;
  78. __u8 dev_model;
  79. unsigned long driver_info;
  80. };
  81. The functions in ccw_driver should be used in the following way:
  82. probe: This function is called by the device layer for each device the driver
  83. is interested in. The driver should only allocate private structures
  84. to put in dev->driver_data and create attributes (if needed). Also,
  85. the interrupt handler (see below) should be set here.
  86. int (*probe) (struct ccw_device *cdev);
  87. Parameters: cdev - the device to be probed.
  88. remove: This function is called by the device layer upon removal of the driver,
  89. the device or the module. The driver should perform cleanups here.
  90. int (*remove) (struct ccw_device *cdev);
  91. Parameters: cdev - the device to be removed.
  92. set_online: This function is called by the common I/O layer when the device is
  93. activated via the 'online' attribute. The driver should finally
  94. setup and activate the device here.
  95. int (*set_online) (struct ccw_device *);
  96. Parameters: cdev - the device to be activated. The common layer has
  97. verified that the device is not already online.
  98. set_offline: This function is called by the common I/O layer when the device is
  99. de-activated via the 'online' attribute. The driver should shut
  100. down the device, but not de-allocate its private data.
  101. int (*set_offline) (struct ccw_device *);
  102. Parameters: cdev - the device to be deactivated. The common layer has
  103. verified that the device is online.
  104. notify: This function is called by the common I/O layer for some state changes
  105. of the device.
  106. Signalled to the driver are:
  107. * In online state, device detached (CIO_GONE) or last path gone
  108. (CIO_NO_PATH). The driver must return !0 to keep the device; for
  109. return code 0, the device will be deleted as usual (also when no
  110. notify function is registerd). If the driver wants to keep the
  111. device, it is moved into disconnected state.
  112. * In disconnected state, device operational again (CIO_OPER). The
  113. common I/O layer performs some sanity checks on device number and
  114. Device / CU to be reasonably sure if it is still the same device.
  115. If not, the old device is removed and a new one registered. By the
  116. return code of the notify function the device driver signals if it
  117. wants the device back: !0 for keeping, 0 to make the device being
  118. removed and re-registered.
  119. int (*notify) (struct ccw_device *, int);
  120. Parameters: cdev - the device whose state changed.
  121. event - the event that happened. This can be one of CIO_GONE,
  122. CIO_NO_PATH or CIO_OPER.
  123. The handler field of the struct ccw_device is meant to be set to the interrupt
  124. handler for the device. In order to accommodate drivers which use several
  125. distinct handlers (e.g. multi subchannel devices), this is a member of ccw_device
  126. instead of ccw_driver.
  127. The handler is registered with the common layer during set_online() processing
  128. before the driver is called, and is deregistered during set_offline() after the
  129. driver has been called. Also, after registering / before deregistering, path
  130. grouping resp. disbanding of the path group (if applicable) are performed.
  131. void (*handler) (struct ccw_device *dev, unsigned long intparm, struct irb *irb);
  132. Parameters: dev - the device the handler is called for
  133. intparm - the intparm which allows the device driver to identify
  134. the i/o the interrupt is associated with, or to recognize
  135. the interrupt as unsolicited.
  136. irb - interruption response block which contains the accumulated
  137. status.
  138. The device driver is called from the common ccw_device layer and can retrieve
  139. information about the interrupt from the irb parameter.
  140. 1.3 ccwgroup devices
  141. --------------------
  142. The ccwgroup mechanism is designed to handle devices consisting of multiple ccw
  143. devices, like lcs or ctc.
  144. The ccw driver provides a 'group' attribute. Piping bus ids of ccw devices to
  145. this attributes creates a ccwgroup device consisting of these ccw devices (if
  146. possible). This ccwgroup device can be set online or offline just like a normal
  147. ccw device.
  148. Each ccwgroup device also provides an 'ungroup' attribute to destroy the device
  149. again (only when offline). This is a generic ccwgroup mechanism (the driver does
  150. not need to implement anything beyond normal removal routines).
  151. To implement a ccwgroup driver, please refer to include/asm/ccwgroup.h. Keep in
  152. mind that most drivers will need to implement both a ccwgroup and a ccw driver
  153. (unless you have a meta ccw driver, like cu3088 for lcs and ctc).
  154. 2. Channel paths
  155. -----------------
  156. Channel paths show up, like subchannels, under the channel subsystem root (css0)
  157. and are called 'chp0.<chpid>'. They have no driver and do not belong to any bus.
  158. Please note, that unlike /proc/chpids in 2.4, the channel path objects reflect
  159. only the logical state and not the physical state, since we cannot track the
  160. latter consistently due to lacking machine support (we don't need to be aware
  161. of anyway).
  162. status - Can be 'online' or 'offline'.
  163. Piping 'on' or 'off' sets the chpid logically online/offline.
  164. Piping 'on' to an online chpid triggers path reprobing for all devices
  165. the chpid connects to. This can be used to force the kernel to re-use
  166. a channel path the user knows to be online, but the machine hasn't
  167. created a machine check for.
  168. 3. System devices
  169. -----------------
  170. Note: cpus may yet be added here.
  171. 3.1 xpram
  172. ---------
  173. xpram shows up under sys/ as 'xpram'.
  174. 4. Other devices
  175. ----------------
  176. 4.1 Netiucv
  177. -----------
  178. The netiucv driver creates an attribute 'connection' under
  179. bus/iucv/drivers/netiucv. Piping to this attibute creates a new netiucv
  180. connection to the specified host.
  181. Netiucv connections show up under devices/iucv/ as "netiucv<ifnum>". The interface
  182. number is assigned sequentially to the connections defined via the 'connection'
  183. attribute.
  184. user - shows the connection partner.
  185. buffer - maximum buffer size.
  186. Pipe to it to change buffer size.