1*44704f69SBart Van Assche# 64 byte NVMe, Read command (a NVM command) that is suitable for: 2*44704f69SBart Van Assche# sg_raw --cmdfile=<this_file_name> --nvm --request=2048 <nvme_device> 3*44704f69SBart Van Assche# 4*44704f69SBart Van Assche# The address field (at byte offset 24, 8 bytes and little endian) gives 5*44704f69SBart Van Assche# special meaning to the highest address pointers: 6*44704f69SBart Van Assche# ffffffff fffffffe use address of data-in buffer 7*44704f69SBart Van Assche# ffffffff fffffffd use address of data-out buffer 8*44704f69SBart Van Assche# 9*44704f69SBart Van Assche# The data length field (at byte offset 36, 4 bytes and little endian) 10*44704f69SBart Van Assche# gives special meaning to the highest block counts: 11*44704f69SBart Van Assche# fffffffe use byte length of data-in buffer 12*44704f69SBart Van Assche# fffffffd use byte length of data-out buffer 13*44704f69SBart Van Assche# 14*44704f69SBart Van Assche# 512 byte logical block size is assumed. Read 4 blocks hence 2048 bytes. 15*44704f69SBart Van Assche# The first LBA read is 0x12345 and the namespace is 1. If successful 16*44704f69SBart Van Assche# the four blocks will be read into the data-in buffer. Submission queue 17*44704f69SBart Van Assche# 0 is used (the same queue that Admin commands use). The NVM opcode for 18*44704f69SBart Van Assche# the Read command is 0x2 and appears in the first command byte. 19*44704f69SBart Van Assche 20*44704f69SBart Van Assche02 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 21*44704f69SBart Van Assche00 00 00 00 00 00 00 00 fe ff ff ff ff ff ff ff 22*44704f69SBart Van Assche00 00 00 00 fe ff ff ff 45 23 01 00 00 00 00 00 23*44704f69SBart Van Assche03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24*44704f69SBart Van Assche 25*44704f69SBart Van Assche# Notice NVMe uses its quirky "0's based" number of blocks so 26*44704f69SBart Van Assche# 03 appears at byte offset 48 to mean "read 4 blocks". 27*44704f69SBart Van Assche# 28*44704f69SBart Van Assche# A typical invocation in Linux and FreeBSD would look like this: 29*44704f69SBart Van Assche# sg_raw --cmdfile=nvme_read_ctl.hex --nvm -r 2048 30*44704f69SBart Van Assche# --outfile=t.bin /dev/nvme0n1 31*44704f69SBart Van Assche# In FreeBSD the device name would be /dev/nvme0ns1 32*44704f69SBart Van Assche# 33*44704f69SBart Van Assche# Notice the '--nvm' option which is needed to distinguish a NVM 34*44704f69SBart Van Assche# command from an Admin command as Admin commands are the default 35*44704f69SBart Van Assche# in this utility. 36*44704f69SBart Van Assche# 37*44704f69SBart Van Assche# This utility (and most others in the package) aligns data-in and 38*44704f69SBart Van Assche# data-out buffers to the beginning of pages which are 4096 bytes 39*44704f69SBart Van Assche# long at a minimum. This is the way NVMe likes things as well. 40