NVMe controller device driver
Purpose
Supports the Non-Volatile Memory Express (NVMe) controller.
Syntax
<#include /usr/include/sys/nvme.h>
<#include /usr/include/sys/devinfo.h>
Description
The /dev/nvmen special file provides interfaces to the NVMe controller device driver.
Device-dependent subroutines
The NVMe controller device driver supports the open
, close
, and
ioctl
subroutines only. The read
and write
subroutines are not supported by the NVMe controller special file.
ioctl Subroutine
Along with the IOCINFO operation, the NVMe controller device driver defines operations for NVMe controller devices.
ioctl
subroutine as follows:- The IOCINFO operation returns a
devinfo
structure. Thedevinfo
structure is defined in the /usr/include/sys/devinfo.h header file. The device type in this structure is DD_BUS, and the subtype is DS_NVME. Theflags
field is not used and it is set to 0. - The
devinfo
structure includes unique data such as version information and the data transfer size that is allowed in the maximum initiator mode. The transfer size is specified in bytes.
NVMe controller ioctl operations
ioctl
operations are supported for NVMe controller devices:- NVME_PASSTHRU
-
Provides options to send a passthru command to an NVMe controller device. The arg parameter for the
NVME_PASSTHRU
operation is the address of anNVME_PASSTHRU
structure that is defined in the /usr/include/sys/nvme.h header file.Note: You can send an admin command only to the adapter device, and an NVM command only to the storage (hdisk
) device. Otherwise, the commands can result in undefined behavior such as data corruption. The opcodes of all the NVMe commands are unique only within a command set and the opcode value can be used for different operations in different command sets.When an NVMe passthru command is issued to the NVMe controller device, a specific
path_id
can be specified. If you want to use specificpath_id
for the passthru command, you need to configure both the NVME_PASS_PASSTHRU flag in theflags
field and thepath_id
to be used in thepath_id
field.You can write the
dword_10
todword_15
data in the endian format that is used by the host such that (leftmost) bit 31 is the most significant bit and (rightmost) bit 0 is the least significant bit according to the NVMe specification. For example, to read 0xAC blocks and to set FUA,dword_10
in thepassthru
structure is set to 0x400000AB.You must byte reverse any fields in the data that is transferred by using the passthru command. For example, to read the name space size (NSZE) from data that is returned by Identify Namespace, bytes 0 - 7 in the data buffer must be byte reversed.
The passthru command is unsuccessful if the
ioctl
subroutine returns -1. A return value of -1 indicates that the driver failed to send the command to the controller or the controller did not respond before the timeout occurred. If theerrno
flag is set to theEINVAL
value, the resp.status parameter contains a code that indicates the invalid field.The passthru command is successful if the
ioctl
subroutine returns 0 and if the resp.status parameter contains 0. The passthru command runs in parallel with commands that are initiated by another user by running read or write operation. - NVME_CNTL
- Provides the options to submit a control request to the NVMe controller device driver. The
arg parameter of the NVME_CNTL operation is the address of an
nvme_cntl
structure that is defined in the /usr/include/sys/nvme.h header file. The types of control operations that are supported for the NVMe controller device driver are documented in thenvme_cntl
structure.