持久内存 - ✅ 8.7 Directives(指令机制)进阶解析(第 357 页) (第368页)
我们继续深入分析 NVM Express® Base Specification Revision 2.0b 第 357 页 的内容,重点理解 Directives 指令机制(第 8.7 节) 的使用规则与结构,特别是:
✅ 8.7 Directives(指令机制)进阶解析(第 357 页)
🔐 指令支持性与使能状态
如果某种 Directive 类型未被支持 或者 被支持但未使能,那么:
所有带该 Directive Type 的
Directive Send和Directive Receive命令都必须被控制器 以 Invalid Field in Command 状态码中止处理。
📌 使用建议与规则
- 主机在使用某种 Directive 前,应执行:
- 使用
Identify Directive指令确认控制器是否支持该 Directive; -
若支持,主机应使用
Enable Directive操作将该指令启用。 -
具体的指令是否支持,以及使能状态,都通过 Identify Directive 中的 Return Parameters 获取。
✅ I/O 命令中使用 Directives(I/O Command Directives)
📤 使用机制:
某些 I/O 命令(如 Write)可 附带 Directive 类型(DTYPE)与参数(DSPEC),用于指定指令行为。
- DTYPE(4位):表示指令类型;
- DSPEC(16位):表示类型相关参数。
🧾 使用限制:
- 只能使用 DTYPE ≤ 0Fh,高位固定为 0(因为 I/O 命令字段只有低 4 位);
- DTYPE = 00h 时,表示“不使用任何 Directive”;
- DSPEC 字段解释依赖于具体 DTYPE 类型。
🧠 具体字段说明(Figure 417)
| DTYPE 值 | Directive Specific (DSPEC) 含义 |
|---|---|
| 00h | 不使用 Directives,DSPEC 忽略 |
| 01h | 表示 Stream Identifier(流ID) |
| 02h–0Fh | 保留,不得使用 |
✳️ 如果 DSPEC = 0h,行为等效于 DTYPE = 00h(即不使用 directive)——用于“默认处理”。
❗ 错误处理机制
| 情况 | 控制器行为 |
|---|---|
| 没有使能任何 I/O Directive,且 DTYPE ≠ 00h | 忽略 DTYPE/DSPEC |
| DTYPE 不受支持或未使能 | 命令被中止,状态码为 Invalid Field in Command |
✅ Identify Directive(DTYPE = 00h)
Identify Directive 是 所有控制器支持 Directive 功能的前提条件,其作用为:
- 返回控制器支持的 Directive 类型;
- 对 Directive 类型进行启用/禁用操作。
📤 支持的操作(Figure 418)
| 命令类型 | 操作名称 | 操作值(OpCode) | 定义位置 |
|---|---|---|---|
| Directive Receive | Return Parameters | 01h | §8.7.2.1.1 |
| Directive Send | Enable Directive | 01h | §8.7.2.2.1 |
| 任意其他操作值 | 保留(Reserved) | - | - |
🧠 总结知识点
| 分类 | 内容 |
|---|---|
| Directive 指令支持性 | 必须通过 Identify Directive 查询并显式启用 |
| DTYPE 字段作用 | 用于标识 I/O 命令中使用的 Directive 类型 |
| DSPEC 字段作用 | 具体 directive 类型的扩展参数(如 Stream ID) |
| 错误处理 | 未使能的 directive 被使用时,返回 Invalid Field in Command |
| Identify Directive | 是开启 Directive 功能的核心:查询支持、启用 directive |
🔜 下一节预告
接下来第 8.7.2.1 节将详细说明:
Directive Receive + Return Parameters的 请求结构 与 响应数据结构;- 也就是主机如何查询控制器“支持哪些 Directive 类型”。
是否继续分析 8.7.2.1?我可以为你逐条拆解字段和作用。