0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

備忘録:ioctl()でNVMe SSDを制御する

Posted at

必要なヘッダ

linux/nvme_ioctl.h
fcntl.h
sys/ioctl.h
unistd.h
string.h

NVMeコマンド

struct nvme_admin_cmdあるいはstruct nvme_passthru_cmdによって構成される。

以下の構造体で定義されるnvme_admin_cmdをioctl()の引数に渡すことでNVMeコマンドを制御できる。

'''struct nvme_admin_cmd {
__u8 opcode; // ← これが cmd.opcode
__u8 flags;
__u16 rsvd1;
__u32 nsid;
__u64 cdw2;
__u64 cdw3;
__u64 metadata;
__u64 addr; // データバッファのポインタ
__u32 data_len;
__u32 metadata_len;
__u64 cdw10;
__u64 cdw11;
__u64 cdw12;
__u64 cdw13;
__u64 cdw14;
__u64 cdw15;
__u32 timeout_ms;
__u32 result;
};'''

opcode(NVMe specifications, Admin command setに記載 )

opcode 定数名 意味
0x00 NVME_ADMIN_DELETE_IO_SQ I/O Submission Queue を削除
0x01 NVME_ADMIN_CREATE_IO_SQ I/O Submission Queue を作成
0x02 NVME_ADMIN_GET_LOG_PAGE ログページ(SMARTなど)を取得
0x06 NVME_ADMIN_IDENTIFY デバイス情報・名前空間情報などの取得
0x09 NVME_ADMIN_SET_FEATURES 各種機能の設定(例:書き込みキャッシュなど)
0x0A NVME_ADMIN_GET_FEATURES 各種機能の取得
0x0C NVME_ADMIN_ASYNC_EVENT 非同期イベントの設定
0x10 NVME_ADMIN_FIRMWARE_ACTIVATE ファームウェアのアクティベート
0x11 NVME_ADMIN_FIRMWARE_IMAGE_DOWNLOAD ファームウェアのダウンロード

Identify cmd

NVMe specifications, Identify commandに記載

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?