rapidio.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. The Linux RapidIO Subsystem
  2. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. The RapidIO standard is a packet-based fabric interconnect standard designed for
  4. use in embedded systems. Development of the RapidIO standard is directed by the
  5. RapidIO Trade Association (RTA). The current version of the RapidIO specification
  6. is publicly available for download from the RTA web-site [1].
  7. This document describes the basics of the Linux RapidIO subsystem and provides
  8. information on its major components.
  9. 1 Overview
  10. ----------
  11. Because the RapidIO subsystem follows the Linux device model it is integrated
  12. into the kernel similarly to other buses by defining RapidIO-specific device and
  13. bus types and registering them within the device model.
  14. The Linux RapidIO subsystem is architecture independent and therefore defines
  15. architecture-specific interfaces that provide support for common RapidIO
  16. subsystem operations.
  17. 2. Core Components
  18. ------------------
  19. A typical RapidIO network is a combination of endpoints and switches.
  20. Each of these components is represented in the subsystem by an associated data
  21. structure. The core logical components of the RapidIO subsystem are defined
  22. in include/linux/rio.h file.
  23. 2.1 Master Port
  24. A master port (or mport) is a RapidIO interface controller that is local to the
  25. processor executing the Linux code. A master port generates and receives RapidIO
  26. packets (transactions). In the RapidIO subsystem each master port is represented
  27. by a rio_mport data structure. This structure contains master port specific
  28. resources such as mailboxes and doorbells. The rio_mport also includes a unique
  29. host device ID that is valid when a master port is configured as an enumerating
  30. host.
  31. RapidIO master ports are serviced by subsystem specific mport device drivers
  32. that provide functionality defined for this subsystem. To provide a hardware
  33. independent interface for RapidIO subsystem operations, rio_mport structure
  34. includes rio_ops data structure which contains pointers to hardware specific
  35. implementations of RapidIO functions.
  36. 2.2 Device
  37. A RapidIO device is any endpoint (other than mport) or switch in the network.
  38. All devices are presented in the RapidIO subsystem by corresponding rio_dev data
  39. structure. Devices form one global device list and per-network device lists
  40. (depending on number of available mports and networks).
  41. 2.3 Switch
  42. A RapidIO switch is a special class of device that routes packets between its
  43. ports towards their final destination. The packet destination port within a
  44. switch is defined by an internal routing table. A switch is presented in the
  45. RapidIO subsystem by rio_dev data structure expanded by additional rio_switch
  46. data structure, which contains switch specific information such as copy of the
  47. routing table and pointers to switch specific functions.
  48. The RapidIO subsystem defines the format and initialization method for subsystem
  49. specific switch drivers that are designed to provide hardware-specific
  50. implementation of common switch management routines.
  51. 2.4 Network
  52. A RapidIO network is a combination of interconnected endpoint and switch devices.
  53. Each RapidIO network known to the system is represented by corresponding rio_net
  54. data structure. This structure includes lists of all devices and local master
  55. ports that form the same network. It also contains a pointer to the default
  56. master port that is used to communicate with devices within the network.
  57. 3. Subsystem Initialization
  58. ---------------------------
  59. In order to initialize the RapidIO subsystem, a platform must initialize and
  60. register at least one master port within the RapidIO network. To register mport
  61. within the subsystem controller driver initialization code calls function
  62. rio_register_mport() for each available master port.
  63. RapidIO subsystem uses subsys_initcall() or device_initcall() to perform
  64. controller initialization (depending on controller device type).
  65. After all active master ports are registered with a RapidIO subsystem,
  66. an enumeration and/or discovery routine may be called automatically or
  67. by user-space command.
  68. 4. Enumeration and Discovery
  69. ----------------------------
  70. 4.1 Overview
  71. ------------
  72. RapidIO subsystem configuration options allow users to specify enumeration and
  73. discovery methods as statically linked components or loadable modules.
  74. An enumeration/discovery method implementation and available input parameters
  75. define how any given method can be attached to available RapidIO mports:
  76. simply to all available mports OR individually to the specified mport device.
  77. Depending on selected enumeration/discovery build configuration, there are
  78. several methods to initiate an enumeration and/or discovery process:
  79. (a) Statically linked enumeration and discovery process can be started
  80. automatically during kernel initialization time using corresponding module
  81. parameters. This was the original method used since introduction of RapidIO
  82. subsystem. Now this method relies on enumerator module parameter which is
  83. 'rio-scan.scan' for existing basic enumeration/discovery method.
  84. When automatic start of enumeration/discovery is used a user has to ensure
  85. that all discovering endpoints are started before the enumerating endpoint
  86. and are waiting for enumeration to be completed.
  87. Configuration option CONFIG_RAPIDIO_DISC_TIMEOUT defines time that discovering
  88. endpoint waits for enumeration to be completed. If the specified timeout
  89. expires the discovery process is terminated without obtaining RapidIO network
  90. information. NOTE: a timed out discovery process may be restarted later using
  91. a user-space command as it is described later if the given endpoint was
  92. enumerated successfully.
  93. (b) Statically linked enumeration and discovery process can be started by
  94. a command from user space. This initiation method provides more flexibility
  95. for a system startup compared to the option (a) above. After all participating
  96. endpoints have been successfully booted, an enumeration process shall be
  97. started first by issuing a user-space command, after an enumeration is
  98. completed a discovery process can be started on all remaining endpoints.
  99. (c) Modular enumeration and discovery process can be started by a command from
  100. user space. After an enumeration/discovery module is loaded, a network scan
  101. process can be started by issuing a user-space command.
  102. Similar to the option (b) above, an enumerator has to be started first.
  103. (d) Modular enumeration and discovery process can be started by a module
  104. initialization routine. In this case an enumerating module shall be loaded
  105. first.
  106. When a network scan process is started it calls an enumeration or discovery
  107. routine depending on the configured role of a master port: host or agent.
  108. Enumeration is performed by a master port if it is configured as a host port by
  109. assigning a host device ID greater than or equal to zero. A host device ID is
  110. assigned to a master port through the kernel command line parameter "riohdid=",
  111. or can be configured in a platform-specific manner. If the host device ID for
  112. a specific master port is set to -1, the discovery process will be performed
  113. for it.
  114. The enumeration and discovery routines use RapidIO maintenance transactions
  115. to access the configuration space of devices.
  116. 4.2 Automatic Start of Enumeration and Discovery
  117. ------------------------------------------------
  118. Automatic enumeration/discovery start method is applicable only to built-in
  119. enumeration/discovery RapidIO configuration selection. To enable automatic
  120. enumeration/discovery start by existing basic enumerator method set use boot
  121. command line parameter "rio-scan.scan=1".
  122. This configuration requires synchronized start of all RapidIO endpoints that
  123. form a network which will be enumerated/discovered. Discovering endpoints have
  124. to be started before an enumeration starts to ensure that all RapidIO
  125. controllers have been initialized and are ready to be discovered. Configuration
  126. parameter CONFIG_RAPIDIO_DISC_TIMEOUT defines time (in seconds) which
  127. a discovering endpoint will wait for enumeration to be completed.
  128. When automatic enumeration/discovery start is selected, basic method's
  129. initialization routine calls rio_init_mports() to perform enumeration or
  130. discovery for all known mport devices.
  131. Depending on RapidIO network size and configuration this automatic
  132. enumeration/discovery start method may be difficult to use due to the
  133. requirement for synchronized start of all endpoints.
  134. 4.3 User-space Start of Enumeration and Discovery
  135. -------------------------------------------------
  136. User-space start of enumeration and discovery can be used with built-in and
  137. modular build configurations. For user-space controlled start RapidIO subsystem
  138. creates the sysfs write-only attribute file '/sys/bus/rapidio/scan'. To initiate
  139. an enumeration or discovery process on specific mport device, a user needs to
  140. write mport_ID (not RapidIO destination ID) into that file. The mport_ID is a
  141. sequential number (0 ... RIO_MAX_MPORTS) assigned during mport device
  142. registration. For example for machine with single RapidIO controller, mport_ID
  143. for that controller always will be 0.
  144. To initiate RapidIO enumeration/discovery on all available mports a user may
  145. write '-1' (or RIO_MPORT_ANY) into the scan attribute file.
  146. 4.4 Basic Enumeration Method
  147. ----------------------------
  148. This is an original enumeration/discovery method which is available since
  149. first release of RapidIO subsystem code. The enumeration process is
  150. implemented according to the enumeration algorithm outlined in the RapidIO
  151. Interconnect Specification: Annex I [1].
  152. This method can be configured as statically linked or loadable module.
  153. The method's single parameter "scan" allows to trigger the enumeration/discovery
  154. process from module initialization routine.
  155. This enumeration/discovery method can be started only once and does not support
  156. unloading if it is built as a module.
  157. The enumeration process traverses the network using a recursive depth-first
  158. algorithm. When a new device is found, the enumerator takes ownership of that
  159. device by writing into the Host Device ID Lock CSR. It does this to ensure that
  160. the enumerator has exclusive right to enumerate the device. If device ownership
  161. is successfully acquired, the enumerator allocates a new rio_dev structure and
  162. initializes it according to device capabilities.
  163. If the device is an endpoint, a unique device ID is assigned to it and its value
  164. is written into the device's Base Device ID CSR.
  165. If the device is a switch, the enumerator allocates an additional rio_switch
  166. structure to store switch specific information. Then the switch's vendor ID and
  167. device ID are queried against a table of known RapidIO switches. Each switch
  168. table entry contains a pointer to a switch-specific initialization routine that
  169. initializes pointers to the rest of switch specific operations, and performs
  170. hardware initialization if necessary. A RapidIO switch does not have a unique
  171. device ID; it relies on hopcount and routing for device ID of an attached
  172. endpoint if access to its configuration registers is required. If a switch (or
  173. chain of switches) does not have any endpoint (except enumerator) attached to
  174. it, a fake device ID will be assigned to configure a route to that switch.
  175. In the case of a chain of switches without endpoint, one fake device ID is used
  176. to configure a route through the entire chain and switches are differentiated by
  177. their hopcount value.
  178. For both endpoints and switches the enumerator writes a unique component tag
  179. into device's Component Tag CSR. That unique value is used by the error
  180. management notification mechanism to identify a device that is reporting an
  181. error management event.
  182. Enumeration beyond a switch is completed by iterating over each active egress
  183. port of that switch. For each active link, a route to a default device ID
  184. (0xFF for 8-bit systems and 0xFFFF for 16-bit systems) is temporarily written
  185. into the routing table. The algorithm recurs by calling itself with hopcount + 1
  186. and the default device ID in order to access the device on the active port.
  187. After the host has completed enumeration of the entire network it releases
  188. devices by clearing device ID locks (calls rio_clear_locks()). For each endpoint
  189. in the system, it sets the Discovered bit in the Port General Control CSR
  190. to indicate that enumeration is completed and agents are allowed to execute
  191. passive discovery of the network.
  192. The discovery process is performed by agents and is similar to the enumeration
  193. process that is described above. However, the discovery process is performed
  194. without changes to the existing routing because agents only gather information
  195. about RapidIO network structure and are building an internal map of discovered
  196. devices. This way each Linux-based component of the RapidIO subsystem has
  197. a complete view of the network. The discovery process can be performed
  198. simultaneously by several agents. After initializing its RapidIO master port
  199. each agent waits for enumeration completion by the host for the configured wait
  200. time period. If this wait time period expires before enumeration is completed,
  201. an agent skips RapidIO discovery and continues with remaining kernel
  202. initialization.
  203. 4.5 Adding New Enumeration/Discovery Method
  204. -------------------------------------------
  205. RapidIO subsystem code organization allows addition of new enumeration/discovery
  206. methods as new configuration options without significant impact to to the core
  207. RapidIO code.
  208. A new enumeration/discovery method has to be attached to one or more mport
  209. devices before an enumeration/discovery process can be started. Normally,
  210. method's module initialization routine calls rio_register_scan() to attach
  211. an enumerator to a specified mport device (or devices). The basic enumerator
  212. implementation demonstrates this process.
  213. 5. References
  214. -------------
  215. [1] RapidIO Trade Association. RapidIO Interconnect Specifications.
  216. http://www.rapidio.org.
  217. [2] Rapidio TA. Technology Comparisons.
  218. http://www.rapidio.org/education/technology_comparisons/
  219. [3] RapidIO support for Linux.
  220. http://lwn.net/Articles/139118/
  221. [4] Matt Porter. RapidIO for Linux. Ottawa Linux Symposium, 2005
  222. http://www.kernel.org/doc/ols/2005/ols2005v2-pages-43-56.pdf