ocxl.rst 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. ========================================================
  2. OpenCAPI (Open Coherent Accelerator Processor Interface)
  3. ========================================================
  4. OpenCAPI is an interface between processors and accelerators. It aims
  5. at being low-latency and high-bandwidth. The specification is
  6. developed by the `OpenCAPI Consortium <http://opencapi.org/>`_.
  7. It allows an accelerator (which could be an FPGA, ASICs, ...) to access
  8. the host memory coherently, using virtual addresses. An OpenCAPI
  9. device can also host its own memory, that can be accessed from the
  10. host.
  11. OpenCAPI is known in linux as 'ocxl', as the open, processor-agnostic
  12. evolution of 'cxl' (the driver for the IBM CAPI interface for
  13. powerpc), which was named that way to avoid confusion with the ISDN
  14. CAPI subsystem.
  15. High-level view
  16. ===============
  17. OpenCAPI defines a Data Link Layer (DL) and Transaction Layer (TL), to
  18. be implemented on top of a physical link. Any processor or device
  19. implementing the DL and TL can start sharing memory.
  20. ::
  21. +-----------+ +-------------+
  22. | | | |
  23. | | | Accelerated |
  24. | Processor | | Function |
  25. | | +--------+ | Unit | +--------+
  26. | |--| Memory | | (AFU) |--| Memory |
  27. | | +--------+ | | +--------+
  28. +-----------+ +-------------+
  29. | |
  30. +-----------+ +-------------+
  31. | TL | | TLX |
  32. +-----------+ +-------------+
  33. | |
  34. +-----------+ +-------------+
  35. | DL | | DLX |
  36. +-----------+ +-------------+
  37. | |
  38. | PHY |
  39. +---------------------------------------+
  40. Device discovery
  41. ================
  42. OpenCAPI relies on a PCI-like configuration space, implemented on the
  43. device. So the host can discover AFUs by querying the config space.
  44. OpenCAPI devices in Linux are treated like PCI devices (with a few
  45. caveats). The firmware is expected to abstract the hardware as if it
  46. was a PCI link. A lot of the existing PCI infrastructure is reused:
  47. devices are scanned and BARs are assigned during the standard PCI
  48. enumeration. Commands like 'lspci' can therefore be used to see what
  49. devices are available.
  50. The configuration space defines the AFU(s) that can be found on the
  51. physical adapter, such as its name, how many memory contexts it can
  52. work with, the size of its MMIO areas, ...
  53. MMIO
  54. ====
  55. OpenCAPI defines two MMIO areas for each AFU:
  56. * the global MMIO area, with registers pertinent to the whole AFU.
  57. * a per-process MMIO area, which has a fixed size for each context.
  58. AFU interrupts
  59. ==============
  60. OpenCAPI includes the possibility for an AFU to send an interrupt to a
  61. host process. It is done through a 'intrp_req' defined in the
  62. Transaction Layer, specifying a 64-bit object handle which defines the
  63. interrupt.
  64. The driver allows a process to allocate an interrupt and obtain its
  65. 64-bit object handle, that can be passed to the AFU.
  66. char devices
  67. ============
  68. The driver creates one char device per AFU found on the physical
  69. device. A physical device may have multiple functions and each
  70. function can have multiple AFUs. At the time of this writing though,
  71. it has only been tested with devices exporting only one AFU.
  72. Char devices can be found in /dev/ocxl/ and are named as:
  73. /dev/ocxl/<AFU name>.<location>.<index>
  74. where <AFU name> is a max 20-character long name, as found in the
  75. config space of the AFU.
  76. <location> is added by the driver and can help distinguish devices
  77. when a system has more than one instance of the same OpenCAPI device.
  78. <index> is also to help distinguish AFUs in the unlikely case where a
  79. device carries multiple copies of the same AFU.
  80. Sysfs class
  81. ===========
  82. An ocxl class is added for the devices representing the AFUs. See
  83. /sys/class/ocxl. The layout is described in
  84. Documentation/ABI/testing/sysfs-class-ocxl
  85. User API
  86. ========
  87. open
  88. ----
  89. Based on the AFU definition found in the config space, an AFU may
  90. support working with more than one memory context, in which case the
  91. associated char device may be opened multiple times by different
  92. processes.
  93. ioctl
  94. -----
  95. OCXL_IOCTL_ATTACH:
  96. Attach the memory context of the calling process to the AFU so that
  97. the AFU can access its memory.
  98. OCXL_IOCTL_IRQ_ALLOC:
  99. Allocate an AFU interrupt and return an identifier.
  100. OCXL_IOCTL_IRQ_FREE:
  101. Free a previously allocated AFU interrupt.
  102. OCXL_IOCTL_IRQ_SET_FD:
  103. Associate an event fd to an AFU interrupt so that the user process
  104. can be notified when the AFU sends an interrupt.
  105. OCXL_IOCTL_GET_METADATA:
  106. Obtains configuration information from the card, such at the size of
  107. MMIO areas, the AFU version, and the PASID for the current context.
  108. OCXL_IOCTL_ENABLE_P9_WAIT:
  109. Allows the AFU to wake a userspace thread executing 'wait'. Returns
  110. information to userspace to allow it to configure the AFU. Note that
  111. this is only available on POWER9.
  112. OCXL_IOCTL_GET_FEATURES:
  113. Reports on which CPU features that affect OpenCAPI are usable from
  114. userspace.
  115. mmap
  116. ----
  117. A process can mmap the per-process MMIO area for interactions with the
  118. AFU.