NVMe Command Decoder
Decode a 64-byte NVMe command capsule from hexadecimal bytes. Inspect command opcode, command identifier, namespace ID, metadata pointer, PRP or SGL data pointers, CDW10 through CDW15 and command-specific fields for common Admin and NVM commands.
16 DWORDs = 64 bytes.
Command DWORD 0 includes OPC, FUSE, PSDT and CID. Namespace ID is in CDW1.
Metadata pointer occupies CDW4–5, the data pointer occupies CDW6–9, and
command-specific fields normally occupy CDW10–15.
—
—
—
What Is an NVMe Command?
An NVMe command is a 64-byte command capsule submitted by host software to an NVMe Submission Queue. The controller reads the command, performs the requested operation and later posts a Completion Queue Entry.
Admin commands configure and manage the controller, while I/O command sets such as the NVM command set perform namespace data operations.
NVMe Command Size
Command size:
64 bytes
DWORDs:
64 / 4
= 16 DWORDs
CDW0 through CDW15NVMe Command DWORD 0
Command DWORD 0 contains the opcode and several fields that apply to all standard commands.
CDW0:
Bits 7:0 OPC
Bits 9:8 FUSE
Bits 15:14 PSDT
Bits 31:16 CIDOther reserved or command-format-specific bits should be interpreted according to the applicable NVMe specification version.
NVMe Opcode
The Opcode field identifies the operation within the selected command set. The same numeric opcode can have different meanings in different command sets, so queue and command-set context matters.
| Command Set | Opcode | Common Command |
|---|---|---|
| NVM | 0x00 | Flush |
| NVM | 0x01 | Write |
| NVM | 0x02 | Read |
| NVM | 0x08 | Write Zeroes |
| NVM | 0x09 | Dataset Management |
| Admin | 0x02 | Get Log Page |
| Admin | 0x06 | Identify |
| Admin | 0x09 | Set Features |
| Admin | 0x0A | Get Features |
Command Identifier
The Command Identifier, or CID, is selected by host software and copied into the associated completion. It allows the host to match a Completion Queue Entry with the submitted command.
CID =
CDW0 bits 31:16Namespace Identifier
CDW1 normally contains the Namespace Identifier. A namespace-specific NVM command such as Read or Write uses this field to select the target namespace.
CDW1:
NSID
Example:
0x00000001
= Namespace 1NVMe Metadata Pointer
CDW4 and CDW5 form the 64-bit Metadata Pointer field when the applicable command uses a separate metadata buffer.
MPTR =
CDW5 : CDW4PRP1 and PRP2
When the command uses Physical Region Page pointers, CDW6 through CDW9 hold two 64-bit data pointers.
PRP1 =
CDW7 : CDW6
PRP2 =
CDW9 : CDW8Depending on transfer length, PRP2 can reference either a second data page or a PRP List.
PSDT — PRP or SGL
The PRP or SGL Data Transfer field in CDW0 indicates how the data pointer area should be interpreted.
The decoder reports the raw PSDT value and can show the pointer region as PRPs or as a generic SGL descriptor view.
NVMe Read Command
The NVM Read command transfers logical blocks from a namespace into host memory. Its command-specific DWORDs include the starting logical block address, number of logical blocks and control information.
CDW10–11:
Starting LBA
CDW12 bits 15:0:
NLB
Actual logical blocks =
NLB + 1NVMe Write Command
Write uses a layout similar to Read, but data is transferred from host memory to the selected namespace.
OPC:
0x01
SLBA:
CDW11 : CDW10
Logical Block Count:
(CDW12 & 0xFFFF) + 1Why NLB Is Zero-Based
For common NVM Read and Write commands, the Number of Logical Blocks field is zero-based.
NLB field = 0
means 1 logical block
NLB field = 7
means 8 logical blocksThe decoder therefore reports both the raw field and the effective number of logical blocks.
Starting LBA
The Starting Logical Block Address is a 64-bit value formed from CDW10 and CDW11 for common NVM data commands.
SLBA =
(CDW11 << 32)
|
CDW10NVMe Flush
Flush requests that volatile write data associated with the namespace be made nonvolatile according to the controller's supported behavior.
Flush normally does not use an NLB or starting-LBA transfer range in the same way as Read and Write.
NVMe Write Zeroes
Write Zeroes requests that a range of logical blocks be logically written with zeroes without requiring a host data buffer containing the zero pattern.
The command includes Starting LBA and Number of Logical Blocks fields similar to other NVM range commands.
Dataset Management Command
Dataset Management allows software to communicate information about logical block ranges, such as deallocation hints. The command can reference one or more range descriptors in host memory.
The NR field is zero-based, so the effective number of ranges is normally the field value plus one.
NVMe Identify Command
Identify is an Admin command used to retrieve controller, namespace and other identification data structures. CDW10 contains the CNS selector and related fields.
Identify opcode:
0x06
CNS:
CDW10 bits 7:0Get Log Page Command
Get Log Page retrieves an NVMe log structure. CDW10 contains the Log Page Identifier along with transfer-length related fields, while later DWORDs can contain additional offset and selector information depending on the NVMe revision.
Admin Opcode:
0x02
LID:
CDW10 bits 7:0Get Features and Set Features
Feature commands use a Feature Identifier to select the controller or namespace feature being queried or changed.
FID =
CDW10 bits 7:0The meaning of CDW11 and later fields depends on the selected feature.
NVMe DWORD Endianness
NVMe multi-byte command fields are represented in little-endian byte order in memory. Therefore the first byte of a DWORD contains its least significant eight bits.
Bytes:
78 56 34 12
DWORD value:
0x12345678The decoder handles this byte ordering automatically.
Command vs Completion
The 64-byte command submitted to a Submission Queue is different from the Completion Queue Entry returned by the controller. A completion contains status, queue information, command ID and command-specific result data rather than the original 64-byte command layout.
NVMe Command Decoder FAQs
How many bytes is an NVMe command?
Where is the NVMe opcode stored?
Where is the Command Identifier stored?
Where is the Namespace ID?
How is the Starting LBA decoded?
Does NLB 0 mean zero blocks?
What are PRP1 and PRP2?
What does PSDT mean?
Can opcode 0x02 mean both Read and Get Log Page?
Can this decoder replace an NVMe protocol analyzer?
Decode NVMe Submission Queue Commands
Inspect raw NVMe command capsules from driver traces, kernel logs, firmware, FPGA simulations and storage protocol captures with command-level decoding of common Admin and NVM fields.