start of change

NVMe storage (hdisk) device driver

Purpose

Supports Peripheral Component Interconnect Express (PCIe) and Fibre Channel (FC) attached Non-Volatile Memory Express (NVMe) storage devices.

Syntax

<#include /usr/include/sys/nvme.h>
<#include /usr/include/sys/devinfo.h>

Description

The /dev/hdiskn special file provides interfaces to the NVMe storage device driver.

Device-dependent subroutines

The NVMe storage device driver supports the open, close, read, write, and ioctl subroutines.

ioctl subroutine

Along with the IOCINFO operation, the NVMe storage device driver defines operations for NVMe storage devices.

The IOCINFO operation is defined for all device drivers that use the ioctl subroutine, as follows:

The IOCINFO operation returns a devinfo structure. The devinfo structure is defined in the /usr/include/sys/devinfo.h header file. The device type in this structure is DD_SCDISK, and the subtype is DS_PV. The flags field is used to indicate the values DF_SSD and DF_NVME. When the DF_4B_ALINGED flag is preset, the flag indicates that all host data buffer addresses must be aligned to a 4 byte address.

NVMe storage ioctl operations

The following ioctl operations are supported for NVMe storage devices:
NVME_PASSTHRU
Provides options to send a passthru command to an NVMe storage device. The arg parameter for the NVME_PASSTHRU operation is the address of an NVME_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 storage device, a specific path_id can be specified. If you want to use specific path_id for the passthru command, you need to configure both the NVME_PASS_PASSTHRU flag in the flags field and the path_id to be used in the path_id field.

You can write the dword_10 to dword_15 data in 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 the passthru structure is set to 0x400000AB.

You must byte reverse any two 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 the errno flag is set to the EINVAL 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.