Part 1
요약·해설
NVMe driver의 세 계층, namespace naming, Devicetree overlay, Kconfig와 4-byte buffer alignment 의무를 설명합니다.
Controller
Namespace
Disk API
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
1E8CCD612D7C0E39A280986290ECAE40D33AFA776ACED1903405D70B7752AFC6
.. _disk_nvme:
NVMe
####
NVMe is a standardized logical device interface on PCIe bus exposing storage devices.
NVMe controllers and disks are supported. Disks can be accessed via the :ref:`Disk Access API <disk_access_api>` they expose
and thus be used through the :ref:`File System API <file_system_api>`.
Driver design
*************
The driver is sliced up in 3 main parts:
- NVMe controller: :zephyr_file:`drivers/disk/nvme/nvme_controller.c`
- NVMe commands: :zephyr_file:`drivers/disk/nvme/nvme_cmd.c`
- NVMe namespace: :zephyr_file:`drivers/disk/nvme/nvme_namespace.c`
Where the NVMe controller is the root of the device driver. This is the one that will get device driver instances.
Note that this is only what DTS describes: the NVMe controller, and none of its namespaces (disks).
The NVMe command is the generic logic used to communicate with the controller and the namespaces it exposes.
Finally the NVMe namespace is the dedicated part to deal with an actual namespace which, in turn, enables applications
accessing each ones through the Disk Access API :zephyr_file:`drivers/disk/nvme/nvme_disk.c`.
If a controller exposes more than 1 namespace (disk), it will be possible to raise the amount of built-in namespace support
by tweaking the configuration option CONFIG_NVME_MAX_NAMESPACES (see below).
Each exposed disk, via it's related disk_info structure, will be distinguished by its name which is inherited from
it's related namespace. As such, the disk name follows NVMe naming which is nvme<k>n<n> where k is the controller number
and n the namespame number. Most of the time, if only one NVMe disk is plugged into the system, one will see 'nvme0n0' as
an exposed disk.
NVMe configuration
******************
DTS
===
Any board exposing an NVMe disk should provide a DTS overlay to enable its use within Zephyr
.. code-block:: devicetree
#include <zephyr/dt-bindings/pcie/pcie.h>
/ {
pcie0 {
nvme0: nvme0 {
compatible = "nvme-controller";
vendor-id = <VENDOR_ID>;
device-id = <DEVICE_ID>;
status = "okay";
};
};
};
Where VENDOR_ID and DEVICE_ID are the ones from the exposed NVMe controller.
Options
=======
* :kconfig:option:`CONFIG_NVME`
Note that NVME requires the target to support PCIe multi-vector MSI-X in order to function.
* :kconfig:option:`CONFIG_NVME_MAX_NAMESPACES`
Important note for users
************************
NVMe specifications mandate the data buffer to be placed in a dword (4 bytes) aligned address.
While this is not a problem for advanced OS managing virtual memory and dynamic allocations
below the user processes, this can become an issue in Zephyr as soon as buffer addresses
map directly to physical memory.
At this stage then, it is up to the user to make sure the buffer address being provided to
:c:func:`disk_access_read` and :c:func:`disk_access_write` are dword aligned.
Part 3
한국어 전문 번역
NVMe는 PCIe bus에서 storage device를 노출하는 표준 logical-device interface입니다. Zephyr는 NVMe controller와 disk를 지원하며, namespace가 제공하는 Disk Access API를 통해 File System API에서도 사용할 수 있습니다.
Driver design
Driver는 세 부분으로 나뉩니다.
drivers/disk/nvme/nvme_controller.c: PCIe에 enumerated되는 root controller와 driver instance.drivers/disk/nvme/nvme_cmd.c: controller와 namespace에 command를 전송하는 공통 logic.drivers/disk/nvme/nvme_namespace.c: 실제 namespace를 관리하고nvme_disk.c를 통해 Disk Access API를 노출.
DTS에는 NVMe controller만 기술되고 namespace(disk)는 기술되지 않습니다. Controller가 runtime에 namespace를 찾아 각각 disk_info로 등록합니다. 한 controller가 여러 namespace를 제공하면 CONFIG_NVME_MAX_NAMESPACES를 늘려 built-in 지원 수를 조정합니다.
각 disk name은 NVMe namespace naming을 따라 nvme<k>n<n>입니다. k는 controller 번호, n은 namespace 번호이며 NVMe disk 하나만 있으면 보통 nvme0n0이 보입니다.
NVMe configuration
DTS
NVMe disk를 노출하는 board는 Zephyr에서 controller를 enable하는 DTS overlay를 제공해야 합니다.
#include <zephyr/dt-bindings/pcie/pcie.h>
/ {
pcie0 {
nvme0: nvme0 {
compatible = "nvme-controller";
vendor-id = <VENDOR_ID>;
device-id = <DEVICE_ID>;
status = "okay";
};
};
};
VENDOR_ID와 DEVICE_ID는 실제 PCIe NVMe controller의 값으로 바꿉니다.
Options
CONFIG_NVME: NVMe driver를 활성화합니다. Target은 PCIe multi-vector MSI-X를 지원해야 합니다.CONFIG_NVME_MAX_NAMESPACES: 동시에 노출할 namespace 최대 수를 정합니다.
Important note for users
NVMe specification은 data buffer address가 dword, 즉 4-byte alignment를 만족하도록 요구합니다. Virtual memory와 allocator가 alignment를 관리하는 큰 OS와 달리 Zephyr에서는 user buffer address가 physical memory에 직접 대응할 수 있습니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.