← Documents Documentation/userspace-api/accelerators/ocxl.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API

OpenCAPI 사용자 API

OpenCAPI의 coherent memory architecture, AFU discovery, MMIO, interrupt와 ocxl character-device ioctl ABI를 설명합니다.

Source pathDocumentation/userspace-api/accelerators/ocxl.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

ocxl.rst:1-179

OpenCAPI의 coherent memory architecture, AFU discovery, MMIO, interrupt와 ocxl character-device ioctl ABI를 설명합니다.

원문 ABI name, ioctl, sysfs path, 수치, code symbol과 줄 좌표를 유지해 모든 절을 한국어로 옮겼습니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

OpenCAPI 소개

1-21

OpenCAPI(Open Coherent Accelerator Processor Interface)는 processor와 accelerator 사이의 low-latency, high-bandwidth interface입니다.

specification은 OpenCAPI Consortium이 개발했으며 현재 Compute Express Link Consortium의 `https://computeexpresslink.org/resource/opencapi-specification-archive/`에서 제공합니다.

FPGA, ASIC 같은 accelerator가 virtual address를 사용해 host memory에 coherent하게 접근할 수 있습니다. OpenCAPI device는 자체 memory를 가질 수도 있고 host가 그 memory에 접근할 수 있습니다.

Linux에서는 OpenCAPI를 `ocxl`이라고 부릅니다. powerpc의 IBM CAPI interface driver인 `cxl`이 ISDN CAPI subsystem과 혼동을 피하려고 그렇게 명명되었고, ocxl은 그 개방적이고 processor-agnostic한 진화라는 뜻입니다.

OpenCAPI 성격
항목설명
Goallow latency, high bandwidth
AcceleratorFPGA, ASIC 등
Host memoryvirtual-address coherent access
Device memoryhost에서 접근 가능
Linux nameocxl

processor와 accelerator가 공유하는 memory model입니다.

========================================================
OpenCAPI (Open Coherent Accelerator Processor Interface)
========================================================

OpenCAPI is an interface between processors and accelerators. It aims
at being low-latency and high-bandwidth.

The specification was developed by the OpenCAPI Consortium, and is now
available from the `Compute Express Link Consortium
<https://computeexpresslink.org/resource/opencapi-specification-archive/>`_.

It allows an accelerator (which could be an FPGA, ASICs, ...) to access
the host memory coherently, using virtual addresses. An OpenCAPI
device can also host its own memory, that can be accessed from the
host.

OpenCAPI is known in linux as 'ocxl', as the open, processor-agnostic
evolution of 'cxl' (the driver for the IBM CAPI interface for
powerpc), which was named that way to avoid confusion with the ISDN
CAPI subsystem.

High-level view

22-53

OpenCAPI는 physical link 위에 구현할 Data Link Layer(DL)와 Transaction Layer(TL)를 정의합니다. DL과 TL을 구현한 processor나 device는 memory sharing을 시작할 수 있습니다.

processor 쪽 memory는 TL과 DL을 거쳐 PHY에 연결되고, accelerator 쪽 AFU(Accelerated Function Unit)와 memory는 TLX와 DLX를 거쳐 같은 PHY link에 연결됩니다.

OpenCAPI layer 구조
Processor + MemoryTLDLPHY
AFU + MemoryTLXDLXPHY

원문의 양쪽 ASCII stack을 같은 연결 관계로 구조화했습니다.

OpenCAPI layer
항목설명
Processor sideTL -> DL -> PHY
Accelerator sideAFU/Memory -> TLX -> DLX -> PHY
Shared resultcoherent memory sharing

processor와 AFU 측 layer 명칭입니다.


High-level view
===============

OpenCAPI defines a Data Link Layer (DL) and Transaction Layer (TL), to
be implemented on top of a physical link. Any processor or device
implementing the DL and TL can start sharing memory.

::

  +-----------+                         +-------------+
  |           |                         |             |
  |           |                         | Accelerated |
  | Processor |                         |  Function   |
  |           |  +--------+             |    Unit     |  +--------+
  |           |--| Memory |             |    (AFU)    |--| Memory |
  |           |  +--------+             |             |  +--------+
  +-----------+                         +-------------+
       |                                       |
  +-----------+                         +-------------+
  |    TL     |                         |    TLX      |
  +-----------+                         +-------------+
       |                                       |
  +-----------+                         +-------------+
  |    DL     |                         |    DLX      |
  +-----------+                         +-------------+
       |                                       |
       |                   PHY                 |
       +---------------------------------------+


Device discovery

54-72

OpenCAPI는 device가 구현하는 PCI-like configuration space에 의존합니다. host는 config space를 query해 AFU를 발견합니다.

Linux에서 OpenCAPI device는 몇 가지 예외를 빼면 PCI device처럼 취급합니다. firmware는 hardware를 PCI link인 것처럼 추상화해야 합니다.

기존 PCI infrastructure를 많이 재사용하여 standard PCI enumeration 중 device를 scan하고 BAR를 할당합니다. 따라서 `lspci`로 사용 가능한 장치를 확인할 수 있습니다.

configuration space는 physical adapter에 있는 AFU의 이름, 사용할 수 있는 memory context 수, MMIO area 크기 등을 정의합니다.

AFU discovery
Firmware가 OpenCAPI를 PCI-like link로 추상화Standard PCI enumerationDevice scan 및 BAR 할당Config space에서 AFU 정보 조회lspci로 확인

firmware abstraction부터 사용자 확인까지의 경로입니다.

Device discovery
================

OpenCAPI relies on a PCI-like configuration space, implemented on the
device. So the host can discover AFUs by querying the config space.

OpenCAPI devices in Linux are treated like PCI devices (with a few
caveats). The firmware is expected to abstract the hardware as if it
was a PCI link. A lot of the existing PCI infrastructure is reused:
devices are scanned and BARs are assigned during the standard PCI
enumeration. Commands like 'lspci' can therefore be used to see what
devices are available.

The configuration space defines the AFU(s) that can be found on the
physical adapter, such as its name, how many memory contexts it can
work with, the size of its MMIO areas, ...


MMIO 영역

73-82

OpenCAPI는 각 AFU에 두 MMIO area를 정의합니다.

global MMIO area에는 AFU 전체와 관련된 register가 있고, per-process MMIO area는 context마다 고정 크기를 갖습니다.

AFU MMIO
항목설명
Global MMIOAFU 전체에 적용되는 register
Per-process MMIOmemory context마다 고정 크기

scope에 따른 두 register 영역입니다.

MMIO
====

OpenCAPI defines two MMIO areas for each AFU:

* the global MMIO area, with registers pertinent to the whole AFU.
* a per-process MMIO area, which has a fixed size for each context.


AFU interrupt

83-95

OpenCAPI AFU는 host process에 interrupt를 보낼 수 있습니다. Transaction Layer의 `intrp_req`가 interrupt를 정의하는 64-bit object handle을 지정해 전달합니다.

driver는 process가 interrupt를 allocate하고 그 64-bit object handle을 얻도록 하며, process는 handle을 AFU에 전달할 수 있습니다.

AFU interrupt 전달
Process가 driver에서 interrupt allocate64-bit object handle 획득Handle을 AFU에 전달AFU가 intrp_req 전송Host process notification

사용자 process가 handle을 설정하고 AFU가 알림을 보내는 관계입니다.

AFU interrupts
==============

OpenCAPI includes the possibility for an AFU to send an interrupt to a
host process. It is done through a 'intrp_req' defined in the
Transaction Layer, specifying a 64-bit object handle which defines the
interrupt.

The driver allows a process to allocate an interrupt and obtain its
64-bit object handle, that can be passed to the AFU.


Character device

96-115

driver는 physical device에서 발견한 AFU마다 character device 하나를 만듭니다. physical device는 여러 function을 가질 수 있고 function마다 여러 AFU가 있을 수 있지만, 문서 작성 시점에는 AFU 하나만 export하는 장치에서만 시험했습니다.

character device는 `/dev/ocxl/` 아래 `/dev/ocxl/<AFU name>.<location>.<index>` 형식으로 나타납니다.

`<AFU name>`은 AFU config space의 최대 20-character 이름입니다. `<location>`은 동일 OpenCAPI device가 여러 개 있을 때 구분하도록 driver가 붙입니다. `<index>`는 한 device에 같은 AFU copy가 여러 개 있는 드문 경우를 구분합니다.

ocxl device name
항목설명
Directory/dev/ocxl/
Pattern<AFU name>.<location>.<index>
AFU nameconfig space에서 읽은 최대 20 characters
location동일 device instance 구분
index동일 AFU copy 구분

AFU character-device 경로 구성 요소입니다.

char devices
============

The driver creates one char device per AFU found on the physical
device. A physical device may have multiple functions and each
function can have multiple AFUs. At the time of this writing though,
it has only been tested with devices exporting only one AFU.

Char devices can be found in /dev/ocxl/ and are named as:
/dev/ocxl/<AFU name>.<location>.<index>

where <AFU name> is a max 20-character long name, as found in the
config space of the AFU.
<location> is added by the driver and can help distinguish devices
when a system has more than one instance of the same OpenCAPI device.
<index> is also to help distinguish AFUs in the unlikely case where a
device carries multiple copies of the same AFU.


Sysfs class

116-124

AFU를 나타내는 device를 위해 `ocxl` class가 추가되며 `/sys/class/ocxl`에서 확인합니다.

layout은 `Documentation/ABI/testing/sysfs-class-ocxl`에 설명되어 있습니다.

ocxl sysfs
항목설명
Class/sys/class/ocxl
ABIDocumentation/ABI/testing/sysfs-class-ocxl

class path와 ABI 문서입니다.

Sysfs class
===========

An ocxl class is added for the devices representing the AFUs. See
/sys/class/ocxl. The layout is described in
Documentation/ABI/testing/sysfs-class-ocxl


User API: open

125-136

config space의 AFU 정의에 따라 AFU가 여러 memory context와 함께 동작할 수 있습니다.

그 경우 서로 다른 process가 연결된 character device를 여러 번 open할 수 있습니다.

open semantics
항목설명
Single contextAFU가 허용하는 범위에서 open
Multiple contexts서로 다른 process가 char device를 여러 번 open

AFU context capability가 open 수를 결정합니다.

User API
========

open
----

Based on the AFU definition found in the config space, an AFU may
support working with more than one memory context, in which case the
associated char device may be opened multiple times by different
processes.

User API: ioctl

137-174

`OCXL_IOCTL_ATTACH`는 calling process의 memory context를 AFU에 attach하여 AFU가 그 memory에 접근하게 합니다.

`OCXL_IOCTL_IRQ_ALLOC`은 AFU interrupt를 allocate하고 identifier를 반환하며, `OCXL_IOCTL_IRQ_FREE`는 이전에 allocate한 interrupt를 free합니다.

`OCXL_IOCTL_IRQ_SET_FD`는 event fd를 AFU interrupt에 연결하여 AFU가 interrupt를 보낼 때 user process가 notification을 받게 합니다.

`OCXL_IOCTL_GET_METADATA`는 MMIO area 크기, AFU version, 현재 context의 PASID 같은 card configuration 정보를 얻습니다.

`OCXL_IOCTL_ENABLE_P9_WAIT`는 AFU가 `wait`를 실행 중인 userspace thread를 깨우게 하고 AFU 설정에 필요한 정보를 userspace에 반환합니다. POWER9에서만 사용할 수 있습니다.

`OCXL_IOCTL_GET_FEATURES`는 OpenCAPI에 영향을 주는 CPU feature 중 userspace에서 사용할 수 있는 항목을 보고합니다.

ocxl ioctl
항목설명
OCXL_IOCTL_ATTACHcalling process memory context를 AFU에 attach
OCXL_IOCTL_IRQ_ALLOCAFU interrupt allocate, identifier 반환
OCXL_IOCTL_IRQ_FREEallocate한 interrupt free
OCXL_IOCTL_IRQ_SET_FDevent fd와 interrupt 연결
OCXL_IOCTL_GET_METADATAMMIO size, AFU version, PASID 조회
OCXL_IOCTL_ENABLE_P9_WAITAFU가 wait thread wake; POWER9 only
OCXL_IOCTL_GET_FEATURESuserspace가 쓸 수 있는 OpenCAPI 관련 CPU feature

AFU context, interrupt와 metadata 제어 command입니다.

ioctl
-----

OCXL_IOCTL_ATTACH:

  Attach the memory context of the calling process to the AFU so that
  the AFU can access its memory.

OCXL_IOCTL_IRQ_ALLOC:

  Allocate an AFU interrupt and return an identifier.

OCXL_IOCTL_IRQ_FREE:

  Free a previously allocated AFU interrupt.

OCXL_IOCTL_IRQ_SET_FD:

  Associate an event fd to an AFU interrupt so that the user process
  can be notified when the AFU sends an interrupt.

OCXL_IOCTL_GET_METADATA:

  Obtains configuration information from the card, such at the size of
  MMIO areas, the AFU version, and the PASID for the current context.

OCXL_IOCTL_ENABLE_P9_WAIT:

  Allows the AFU to wake a userspace thread executing 'wait'. Returns
  information to userspace to allow it to configure the AFU. Note that
  this is only available on POWER9.

OCXL_IOCTL_GET_FEATURES:

  Reports on which CPU features that affect OpenCAPI are usable from
  userspace.

User API: mmap

175-179

process는 AFU와 상호작용하기 위해 per-process MMIO area를 `mmap`할 수 있습니다.

AFU userspace access
AFU char device openOCXL_IOCTL_ATTACHPer-process MMIO mmap필요 시 IRQ allocate + event fdAFU와 상호작용

context attach 후 MMIO mapping과 interrupt를 함께 사용합니다.

mmap
----

A process can mmap the per-process MMIO area for interactions with the
AFU.