README.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. Copyright (C) 2015 Freescale Semiconductor Inc.
  2. DPAA2 (Data Path Acceleration Architecture Gen2)
  3. ------------------------------------------------
  4. This document provides an overview of the Freescale DPAA2 architecture
  5. and how it is integrated into the Linux kernel.
  6. Contents summary
  7. -DPAA2 overview
  8. -Overview of DPAA2 objects
  9. -DPAA2 Linux driver architecture overview
  10. -bus driver
  11. -DPRC driver
  12. -allocator
  13. -DPIO driver
  14. -Ethernet
  15. -MAC
  16. DPAA2 Overview
  17. --------------
  18. DPAA2 is a hardware architecture designed for high-speeed network
  19. packet processing. DPAA2 consists of sophisticated mechanisms for
  20. processing Ethernet packets, queue management, buffer management,
  21. autonomous L2 switching, virtual Ethernet bridging, and accelerator
  22. (e.g. crypto) sharing.
  23. A DPAA2 hardware component called the Management Complex (or MC) manages the
  24. DPAA2 hardware resources. The MC provides an object-based abstraction for
  25. software drivers to use the DPAA2 hardware.
  26. The MC uses DPAA2 hardware resources such as queues, buffer pools, and
  27. network ports to create functional objects/devices such as network
  28. interfaces, an L2 switch, or accelerator instances.
  29. The MC provides memory-mapped I/O command interfaces (MC portals)
  30. which DPAA2 software drivers use to operate on DPAA2 objects:
  31. The diagram below shows an overview of the DPAA2 resource management
  32. architecture:
  33. +--------------------------------------+
  34. | OS |
  35. | DPAA2 drivers |
  36. | | |
  37. +-----------------------------|--------+
  38. |
  39. | (create,discover,connect
  40. | config,use,destroy)
  41. |
  42. DPAA2 |
  43. +------------------------| mc portal |-+
  44. | | |
  45. | +- - - - - - - - - - - - -V- - -+ |
  46. | | | |
  47. | | Management Complex (MC) | |
  48. | | | |
  49. | +- - - - - - - - - - - - - - - -+ |
  50. | |
  51. | Hardware Hardware |
  52. | Resources Objects |
  53. | --------- ------- |
  54. | -queues -DPRC |
  55. | -buffer pools -DPMCP |
  56. | -Eth MACs/ports -DPIO |
  57. | -network interface -DPNI |
  58. | profiles -DPMAC |
  59. | -queue portals -DPBP |
  60. | -MC portals ... |
  61. | ... |
  62. | |
  63. +--------------------------------------+
  64. The MC mediates operations such as create, discover,
  65. connect, configuration, and destroy. Fast-path operations
  66. on data, such as packet transmit/receive, are not mediated by
  67. the MC and are done directly using memory mapped regions in
  68. DPIO objects.
  69. Overview of DPAA2 Objects
  70. -------------------------
  71. The section provides a brief overview of some key DPAA2 objects.
  72. A simple scenario is described illustrating the objects involved
  73. in creating a network interfaces.
  74. -DPRC (Datapath Resource Container)
  75. A DPRC is a container object that holds all the other
  76. types of DPAA2 objects. In the example diagram below there
  77. are 8 objects of 5 types (DPMCP, DPIO, DPBP, DPNI, and DPMAC)
  78. in the container.
  79. +---------------------------------------------------------+
  80. | DPRC |
  81. | |
  82. | +-------+ +-------+ +-------+ +-------+ +-------+ |
  83. | | DPMCP | | DPIO | | DPBP | | DPNI | | DPMAC | |
  84. | +-------+ +-------+ +-------+ +---+---+ +---+---+ |
  85. | | DPMCP | | DPIO | |
  86. | +-------+ +-------+ |
  87. | | DPMCP | |
  88. | +-------+ |
  89. | |
  90. +---------------------------------------------------------+
  91. From the point of view of an OS, a DPRC behaves similar to a plug and
  92. play bus, like PCI. DPRC commands can be used to enumerate the contents
  93. of the DPRC, discover the hardware objects present (including mappable
  94. regions and interrupts).
  95. DPRC.1 (bus)
  96. |
  97. +--+--------+-------+-------+-------+
  98. | | | | |
  99. DPMCP.1 DPIO.1 DPBP.1 DPNI.1 DPMAC.1
  100. DPMCP.2 DPIO.2
  101. DPMCP.3
  102. Hardware objects can be created and destroyed dynamically, providing
  103. the ability to hot plug/unplug objects in and out of the DPRC.
  104. A DPRC has a mappable MMIO region (an MC portal) that can be used
  105. to send MC commands. It has an interrupt for status events (like
  106. hotplug).
  107. All objects in a container share the same hardware "isolation context".
  108. This means that with respect to an IOMMU the isolation granularity
  109. is at the DPRC (container) level, not at the individual object
  110. level.
  111. DPRCs can be defined statically and populated with objects
  112. via a config file passed to the MC when firmware starts
  113. it. There is also a Linux user space tool called "restool"
  114. that can be used to create/destroy containers and objects
  115. dynamically.
  116. -DPAA2 Objects for an Ethernet Network Interface
  117. A typical Ethernet NIC is monolithic-- the NIC device contains TX/RX
  118. queuing mechanisms, configuration mechanisms, buffer management,
  119. physical ports, and interrupts. DPAA2 uses a more granular approach
  120. utilizing multiple hardware objects. Each object provides specialized
  121. functions. Groups of these objects are used by software to provide
  122. Ethernet network interface functionality. This approach provides
  123. efficient use of finite hardware resources, flexibility, and
  124. performance advantages.
  125. The diagram below shows the objects needed for a simple
  126. network interface configuration on a system with 2 CPUs.
  127. +---+---+ +---+---+
  128. CPU0 CPU1
  129. +---+---+ +---+---+
  130. | |
  131. +---+---+ +---+---+
  132. DPIO DPIO
  133. +---+---+ +---+---+
  134. \ /
  135. \ /
  136. \ /
  137. +---+---+
  138. DPNI --- DPBP,DPMCP
  139. +---+---+
  140. |
  141. |
  142. +---+---+
  143. DPMAC
  144. +---+---+
  145. |
  146. port/PHY
  147. Below the objects are described. For each object a brief description
  148. is provided along with a summary of the kinds of operations the object
  149. supports and a summary of key resources of the object (MMIO regions
  150. and IRQs).
  151. -DPMAC (Datapath Ethernet MAC): represents an Ethernet MAC, a
  152. hardware device that connects to an Ethernet PHY and allows
  153. physical transmission and reception of Ethernet frames.
  154. -MMIO regions: none
  155. -IRQs: DPNI link change
  156. -commands: set link up/down, link config, get stats,
  157. IRQ config, enable, reset
  158. -DPNI (Datapath Network Interface): contains TX/RX queues,
  159. network interface configuration, and RX buffer pool configuration
  160. mechanisms. The TX/RX queues are in memory and are identified by
  161. queue number.
  162. -MMIO regions: none
  163. -IRQs: link state
  164. -commands: port config, offload config, queue config,
  165. parse/classify config, IRQ config, enable, reset
  166. -DPIO (Datapath I/O): provides interfaces to enqueue and dequeue
  167. packets and do hardware buffer pool management operations. The DPAA2
  168. architecture separates the mechanism to access queues (the DPIO object)
  169. from the queues themselves. The DPIO provides an MMIO interface to
  170. enqueue/dequeue packets. To enqueue something a descriptor is written
  171. to the DPIO MMIO region, which includes the target queue number.
  172. There will typically be one DPIO assigned to each CPU. This allows all
  173. CPUs to simultaneously perform enqueue/dequeued operations. DPIOs are
  174. expected to be shared by different DPAA2 drivers.
  175. -MMIO regions: queue operations, buffer management
  176. -IRQs: data availability, congestion notification, buffer
  177. pool depletion
  178. -commands: IRQ config, enable, reset
  179. -DPBP (Datapath Buffer Pool): represents a hardware buffer
  180. pool.
  181. -MMIO regions: none
  182. -IRQs: none
  183. -commands: enable, reset
  184. -DPMCP (Datapath MC Portal): provides an MC command portal.
  185. Used by drivers to send commands to the MC to manage
  186. objects.
  187. -MMIO regions: MC command portal
  188. -IRQs: command completion
  189. -commands: IRQ config, enable, reset
  190. Object Connections
  191. ------------------
  192. Some objects have explicit relationships that must
  193. be configured:
  194. -DPNI <--> DPMAC
  195. -DPNI <--> DPNI
  196. -DPNI <--> L2-switch-port
  197. A DPNI must be connected to something such as a DPMAC,
  198. another DPNI, or L2 switch port. The DPNI connection
  199. is made via a DPRC command.
  200. +-------+ +-------+
  201. | DPNI | | DPMAC |
  202. +---+---+ +---+---+
  203. | |
  204. +==========+
  205. -DPNI <--> DPBP
  206. A network interface requires a 'buffer pool' (DPBP
  207. object) which provides a list of pointers to memory
  208. where received Ethernet data is to be copied. The
  209. Ethernet driver configures the DPBPs associated with
  210. the network interface.
  211. Interrupts
  212. ----------
  213. All interrupts generated by DPAA2 objects are message
  214. interrupts. At the hardware level message interrupts
  215. generated by devices will normally have 3 components--
  216. 1) a non-spoofable 'device-id' expressed on the hardware
  217. bus, 2) an address, 3) a data value.
  218. In the case of DPAA2 devices/objects, all objects in the
  219. same container/DPRC share the same 'device-id'.
  220. For ARM-based SoC this is the same as the stream ID.
  221. DPAA2 Linux Driver Overview
  222. ---------------------------
  223. This section provides an overview of the Linux kernel drivers for
  224. DPAA2-- 1) the bus driver and associated "DPAA2 infrastructure"
  225. drivers and 2) functional object drivers (such as Ethernet).
  226. As described previously, a DPRC is a container that holds the other
  227. types of DPAA2 objects. It is functionally similar to a plug-and-play
  228. bus controller.
  229. Each object in the DPRC is a Linux "device" and is bound to a driver.
  230. The diagram below shows the Linux drivers involved in a networking
  231. scenario and the objects bound to each driver. A brief description
  232. of each driver follows.
  233. +------------+
  234. | OS Network |
  235. | Stack |
  236. +------------+ +------------+
  237. | Allocator |. . . . . . . | Ethernet |
  238. |(DPMCP,DPBP)| | (DPNI) |
  239. +-.----------+ +---+---+----+
  240. . . ^ |
  241. . . <data avail, | |<enqueue,
  242. . . tx confirm> | | dequeue>
  243. +-------------+ . | |
  244. | DPRC driver | . +---+---V----+ +---------+
  245. | (DPRC) | . . . . . .| DPIO driver| | MAC |
  246. +----------+--+ | (DPIO) | | (DPMAC) |
  247. | +------+-----+ +-----+---+
  248. |<dev add/remove> | |
  249. | | |
  250. +----+--------------+ | +--+---+
  251. | MC-bus driver | | | PHY |
  252. | | | |driver|
  253. | /soc/fsl-mc | | +--+---+
  254. +-------------------+ | |
  255. | |
  256. ================================ HARDWARE =========|=================|======
  257. DPIO |
  258. | |
  259. DPNI---DPBP |
  260. | |
  261. DPMAC |
  262. | |
  263. PHY ---------------+
  264. ===================================================|========================
  265. A brief description of each driver is provided below.
  266. MC-bus driver
  267. -------------
  268. The MC-bus driver is a platform driver and is probed from a
  269. node in the device tree (compatible "fsl,qoriq-mc") passed in by boot
  270. firmware. It is responsible for bootstrapping the DPAA2 kernel
  271. infrastructure.
  272. Key functions include:
  273. -registering a new bus type named "fsl-mc" with the kernel,
  274. and implementing bus call-backs (e.g. match/uevent/dev_groups)
  275. -implementing APIs for DPAA2 driver registration and for device
  276. add/remove
  277. -creates an MSI IRQ domain
  278. -doing a 'device add' to expose the 'root' DPRC, in turn triggering
  279. a bind of the root DPRC to the DPRC driver
  280. DPRC driver
  281. -----------
  282. The DPRC driver is bound to DPRC objects and does runtime management
  283. of a bus instance. It performs the initial bus scan of the DPRC
  284. and handles interrupts for container events such as hot plug by
  285. re-scanning the DPRC.
  286. Allocator
  287. ----------
  288. Certain objects such as DPMCP and DPBP are generic and fungible,
  289. and are intended to be used by other drivers. For example,
  290. the DPAA2 Ethernet driver needs:
  291. -DPMCPs to send MC commands, to configure network interfaces
  292. -DPBPs for network buffer pools
  293. The allocator driver registers for these allocatable object types
  294. and those objects are bound to the allocator when the bus is probed.
  295. The allocator maintains a pool of objects that are available for
  296. allocation by other DPAA2 drivers.
  297. DPIO driver
  298. -----------
  299. The DPIO driver is bound to DPIO objects and provides services that allow
  300. other drivers such as the Ethernet driver to enqueue and dequeue data for
  301. their respective objects.
  302. Key services include:
  303. -data availability notifications
  304. -hardware queuing operations (enqueue and dequeue of data)
  305. -hardware buffer pool management
  306. To transmit a packet the Ethernet driver puts data on a queue and
  307. invokes a DPIO API. For receive, the Ethernet driver registers
  308. a data availability notification callback. To dequeue a packet
  309. a DPIO API is used.
  310. There is typically one DPIO object per physical CPU for optimum
  311. performance, allowing different CPUs to simultaneously enqueue
  312. and dequeue data.
  313. The DPIO driver operates on behalf of all DPAA2 drivers
  314. active in the kernel-- Ethernet, crypto, compression,
  315. etc.
  316. Ethernet
  317. --------
  318. The Ethernet driver is bound to a DPNI and implements the kernel
  319. interfaces needed to connect the DPAA2 network interface to
  320. the network stack.
  321. Each DPNI corresponds to a Linux network interface.
  322. MAC driver
  323. ----------
  324. An Ethernet PHY is an off-chip, board specific component and is managed
  325. by the appropriate PHY driver via an mdio bus. The MAC driver
  326. plays a role of being a proxy between the PHY driver and the
  327. MC. It does this proxy via the MC commands to a DPMAC object.
  328. If the PHY driver signals a link change, the MAC driver notifies
  329. the MC via a DPMAC command. If a network interface is brought
  330. up or down, the MC notifies the DPMAC driver via an interrupt and
  331. the driver can take appropriate action.