Queue Pair
Namespace
A namespace is a quantity of non-volatile memory that may be formatted into logical blocks
如果把闪存空间划分成若干个独立的逻辑空间,每个空间逻辑块地址(LBA)范围是 0 到 N-1 (N 是逻辑空间大小),这样划分出来的每一个逻辑空间我们就叫做 NS
NS 由 Host 创建和管理,每个创建好的 NS,从 Host 操作系统角度看来,就是一个独立的磁盘,用户可在每个 NS 做分区等操作
SQ,CQ and DB
A Submission Queue (SQ) is a circular buffer with a fixed slot size that the host software uses to submit commands for execution by the controller
A Completion Queue (CQ) is a circular buffer with a fixed slot size used to post status for completed commands
SQ and CQ
- SQ 用以 Host 发命令,CQ 用以 SSD 回命令完成状态
- SQ and CQ are allocated in memory
- 两种类型的 SQ/CQ:Admin 和 I/O,前者发送 Admin 命令,后者发送 I/O 命令;
- 系统中只能有一对 Admin SQ/CQ,但可以有很多对 I/O SQ/CQ,最多65535个;
- I/O SQ 与 CQ 可以是一对一的关系,也可以是多对一的关系;
- I/O SQ 是可以赋予不同优先级的;
- Queue Size: I/O SQ/CQ 2-64Ki; Admin SQ/CQ 2-4Ki
- I/O SQ/CQ 的广度和深度都可以灵活配置;
- 每条命令大小是 64 字节,每条命令完成状态是 16 字节
- Host 更新SQ tail, CQ head; SSD controller更新CQ tail, SQ head
- Host create CQ before SQ, delete SQ before CQ
DB
- DB 在 SSD Controller 端,是寄存器
- Host 只能写 DB,不能读 DB
- Host 通过 SSD 往 CQ 中写入的命令完成状态获取 Head 或者 Tail
Queue
Empty queue
Full queue
PRP and SGL
PRP
- SGL segment
- SGL descriptor
- SGL segment
- SGL descriptor
- SGL descriptor
- …
- …
Command Processing
第一步:Host 写命令到 SQ;
第二步:Host 写 DB,通知 SSD 取指;
第三步:SSD 从 SQ 中取指;
第四步:SSD 执行指令;
第五步:指令执行完成,SSD 往 CQ 中写指令执行结果;
第六步:SSD 发送中断告知Host 去检查CQ中的返回结果;
第七步:Host 处理 CQ,查看指令完成状态;
第八步:Host更新 CQ Head DB
Completion Queue Entry
An entry in the Completion Queue is at least 16 bytes in size .
The Completion Queue Tail pointer is only used internally by the controller and is not visible to the host.
Command Format
Format of Command specific fields (Dword10-Dword15) varies for different command
BusXpert Trace
Read from host to controller -> Memory Read TLP(Non-Posted: need Completion TLP)
Write data to host -> Memory Write TLP( Posted: don’t need Completion TLP)