Bin Meng | 000230c | 2021-06-22 21:16:22 +0800 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | .. Copyright (C) 2017 NXP Semiconductors |
| 3 | .. Copyright (C) 2017 Bin Meng <bmeng.cn@gmail.com> |
Zhikang Zhang | 145b88f | 2017-08-03 02:30:57 -0700 | [diff] [blame] | 4 | |
Bin Meng | 000230c | 2021-06-22 21:16:22 +0800 | [diff] [blame] | 5 | NVMe Support |
Zhikang Zhang | 145b88f | 2017-08-03 02:30:57 -0700 | [diff] [blame] | 6 | ============ |
| 7 | |
Bin Meng | 000230c | 2021-06-22 21:16:22 +0800 | [diff] [blame] | 8 | What is NVMe |
| 9 | ------------ |
| 10 | |
Zhikang Zhang | 145b88f | 2017-08-03 02:30:57 -0700 | [diff] [blame] | 11 | NVM Express (NVMe) is a register level interface that allows host software to |
| 12 | communicate with a non-volatile memory subsystem. This interface is optimized |
| 13 | for enterprise and client solid state drives, typically attached to the PCI |
| 14 | express interface. It is a scalable host controller interface designed to |
| 15 | address the needs of enterprise and client systems that utilize PCI express |
| 16 | based solid state drives (SSD). The interface provides optimized command |
| 17 | submission and completion paths. It includes support for parallel operation by |
| 18 | supporting up to 64K I/O queues with up to 64K commands per I/O queue. |
| 19 | |
| 20 | The device is comprised of some number of controllers, where each controller |
| 21 | is comprised of some number of namespaces, where each namespace is comprised |
| 22 | of some number of logical blocks. A namespace is a quantity of non-volatile |
| 23 | memory that is formatted into logical blocks. An NVMe namespace is equivalent |
| 24 | to a SCSI LUN. Each namespace is operated as an independent "device". |
| 25 | |
| 26 | How it works |
| 27 | ------------ |
| 28 | There is an NVMe uclass driver (driver name "nvme"), an NVMe host controller |
| 29 | driver (driver name "nvme") and an NVMe namespace block driver (driver name |
Simon Glass | 736612e | 2023-01-17 10:48:19 -0700 | [diff] [blame] | 30 | "nvme_blk"). The host controller driver is supposed to probe the hardware and |
Zhikang Zhang | 145b88f | 2017-08-03 02:30:57 -0700 | [diff] [blame] | 31 | do necessary initialization to put the controller into a ready state at which |
| 32 | it is able to scan all available namespaces attached to it. Scanning namespace |
| 33 | is triggered by the NVMe uclass driver and the actual work is done in the NVMe |
| 34 | namespace block driver. |
| 35 | |
| 36 | Status |
| 37 | ------ |
| 38 | It only support basic block read/write functions in the NVMe driver. |
| 39 | |
| 40 | Config options |
| 41 | -------------- |
| 42 | CONFIG_NVME Enable NVMe device support |
Mark Kettenis | f8463d6 | 2022-01-22 20:38:11 +0100 | [diff] [blame] | 43 | CONFIG_NVME_PCI Enable PCIe NVMe device support |
Zhikang Zhang | 4945565 | 2017-08-03 02:30:59 -0700 | [diff] [blame] | 44 | CONFIG_CMD_NVME Enable basic NVMe commands |
| 45 | |
| 46 | Usage in U-Boot |
| 47 | --------------- |
| 48 | To use an NVMe hard disk from U-Boot shell, a 'nvme scan' command needs to |
| 49 | be executed for all NVMe hard disks attached to the NVMe controller to be |
| 50 | identified. |
| 51 | |
| 52 | To list all of the NVMe hard disks, try: |
| 53 | |
Bin Meng | 000230c | 2021-06-22 21:16:22 +0800 | [diff] [blame] | 54 | .. code-block:: none |
| 55 | |
Bin Meng | 326c5fd | 2017-08-22 08:15:17 -0700 | [diff] [blame] | 56 | => nvme info |
Zhikang Zhang | 4945565 | 2017-08-03 02:30:59 -0700 | [diff] [blame] | 57 | Device 0: Vendor: 0x8086 Rev: 8DV10131 Prod: CVFT535600LS400BGN |
| 58 | Type: Hard Disk |
| 59 | Capacity: 381554.0 MB = 372.6 GB (781422768 x 512) |
| 60 | |
| 61 | and print out detailed information for controller and namespaces via: |
| 62 | |
Bin Meng | 000230c | 2021-06-22 21:16:22 +0800 | [diff] [blame] | 63 | .. code-block:: none |
| 64 | |
Bin Meng | 326c5fd | 2017-08-22 08:15:17 -0700 | [diff] [blame] | 65 | => nvme detail |
Zhikang Zhang | 4945565 | 2017-08-03 02:30:59 -0700 | [diff] [blame] | 66 | |
| 67 | Raw block read/write to can be done via the 'nvme read/write' commands: |
| 68 | |
Bin Meng | 000230c | 2021-06-22 21:16:22 +0800 | [diff] [blame] | 69 | .. code-block:: none |
| 70 | |
Zhikang Zhang | 4945565 | 2017-08-03 02:30:59 -0700 | [diff] [blame] | 71 | => nvme read a0000000 0 11000 |
| 72 | |
| 73 | => tftp 80000000 /tftpboot/kernel.itb |
| 74 | => nvme write 80000000 0 11000 |
| 75 | |
| 76 | Of course, file system command can be used on the NVMe hard disk as well: |
| 77 | |
Bin Meng | 000230c | 2021-06-22 21:16:22 +0800 | [diff] [blame] | 78 | .. code-block:: none |
| 79 | |
Zhikang Zhang | 4945565 | 2017-08-03 02:30:59 -0700 | [diff] [blame] | 80 | => fatls nvme 0:1 |
| 81 | 32376967 kernel.itb |
| 82 | 22929408 100m |
| 83 | |
| 84 | 2 file(s), 0 dir(s) |
| 85 | |
| 86 | => fatload nvme 0:1 a0000000 /kernel.itb |
| 87 | => bootm a0000000 |
Bin Meng | 139f8c1 | 2017-08-03 02:31:03 -0700 | [diff] [blame] | 88 | |
| 89 | Testing NVMe with QEMU x86 |
| 90 | -------------------------- |
| 91 | QEMU supports NVMe emulation and we can test NVMe driver with QEMU x86 running |
| 92 | U-Boot. Please see README.x86 for how to build u-boot.rom image for QEMU x86. |
| 93 | |
| 94 | Example command line to call QEMU x86 below with emulated NVMe device: |
Bin Meng | 000230c | 2021-06-22 21:16:22 +0800 | [diff] [blame] | 95 | |
| 96 | .. code-block:: bash |
| 97 | |
| 98 | $ ./qemu-system-i386 -drive file=nvme.img,if=none,id=drv0 -device nvme,drive=drv0,serial=QEMUNVME0001 -bios u-boot.rom |