overview.rst 15 KB

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