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