rapidio.txt 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. After all active master
  63. ports are registered with a RapidIO subsystem, the rio_init_mports() routine
  64. is called to perform enumeration and discovery.
  65. In the current PowerPC-based implementation a subsys_initcall() is specified to
  66. perform controller initialization and mport registration. At the end it directly
  67. calls rio_init_mports() to execute RapidIO enumeration and discovery.
  68. 4. Enumeration and Discovery
  69. ----------------------------
  70. When rio_init_mports() is called it scans a list of registered master ports and
  71. calls an enumeration or discovery routine depending on the configured role of a
  72. master port: host or agent.
  73. Enumeration is performed by a master port if it is configured as a host port by
  74. assigning a host device ID greater than or equal to zero. A host device ID is
  75. assigned to a master port through the kernel command line parameter "riohdid=",
  76. or can be configured in a platform-specific manner. If the host device ID for
  77. a specific master port is set to -1, the discovery process will be performed
  78. for it.
  79. The enumeration and discovery routines use RapidIO maintenance transactions
  80. to access the configuration space of devices.
  81. The enumeration process is implemented according to the enumeration algorithm
  82. outlined in the RapidIO Interconnect Specification: Annex I [1].
  83. The enumeration process traverses the network using a recursive depth-first
  84. algorithm. When a new device is found, the enumerator takes ownership of that
  85. device by writing into the Host Device ID Lock CSR. It does this to ensure that
  86. the enumerator has exclusive right to enumerate the device. If device ownership
  87. is successfully acquired, the enumerator allocates a new rio_dev structure and
  88. initializes it according to device capabilities.
  89. If the device is an endpoint, a unique device ID is assigned to it and its value
  90. is written into the device's Base Device ID CSR.
  91. If the device is a switch, the enumerator allocates an additional rio_switch
  92. structure to store switch specific information. Then the switch's vendor ID and
  93. device ID are queried against a table of known RapidIO switches. Each switch
  94. table entry contains a pointer to a switch-specific initialization routine that
  95. initializes pointers to the rest of switch specific operations, and performs
  96. hardware initialization if necessary. A RapidIO switch does not have a unique
  97. device ID; it relies on hopcount and routing for device ID of an attached
  98. endpoint if access to its configuration registers is required. If a switch (or
  99. chain of switches) does not have any endpoint (except enumerator) attached to
  100. it, a fake device ID will be assigned to configure a route to that switch.
  101. In the case of a chain of switches without endpoint, one fake device ID is used
  102. to configure a route through the entire chain and switches are differentiated by
  103. their hopcount value.
  104. For both endpoints and switches the enumerator writes a unique component tag
  105. into device's Component Tag CSR. That unique value is used by the error
  106. management notification mechanism to identify a device that is reporting an
  107. error management event.
  108. Enumeration beyond a switch is completed by iterating over each active egress
  109. port of that switch. For each active link, a route to a default device ID
  110. (0xFF for 8-bit systems and 0xFFFF for 16-bit systems) is temporarily written
  111. into the routing table. The algorithm recurs by calling itself with hopcount + 1
  112. and the default device ID in order to access the device on the active port.
  113. After the host has completed enumeration of the entire network it releases
  114. devices by clearing device ID locks (calls rio_clear_locks()). For each endpoint
  115. in the system, it sets the Discovered bit in the Port General Control CSR
  116. to indicate that enumeration is completed and agents are allowed to execute
  117. passive discovery of the network.
  118. The discovery process is performed by agents and is similar to the enumeration
  119. process that is described above. However, the discovery process is performed
  120. without changes to the existing routing because agents only gather information
  121. about RapidIO network structure and are building an internal map of discovered
  122. devices. This way each Linux-based component of the RapidIO subsystem has
  123. a complete view of the network. The discovery process can be performed
  124. simultaneously by several agents. After initializing its RapidIO master port
  125. each agent waits for enumeration completion by the host for the configured wait
  126. time period. If this wait time period expires before enumeration is completed,
  127. an agent skips RapidIO discovery and continues with remaining kernel
  128. initialization.
  129. 5. References
  130. -------------
  131. [1] RapidIO Trade Association. RapidIO Interconnect Specifications.
  132. http://www.rapidio.org.
  133. [2] Rapidio TA. Technology Comparisons.
  134. http://www.rapidio.org/education/technology_comparisons/
  135. [3] RapidIO support for Linux.
  136. http://lwn.net/Articles/139118/
  137. [4] Matt Porter. RapidIO for Linux. Ottawa Linux Symposium, 2005
  138. http://www.kernel.org/doc/ols/2005/ols2005v2-pages-43-56.pdf