深入理解nvme 协议中的SGL

网友投稿 718 2022-10-11

深入理解nvme 协议中的SGL

深入理解nvme 协议中的SGL能够提供DMA的效率,进而更好地利用硬件的特性。为此,需要了解它的相关寄存器、数据结构和使用过程。

重要的寄存器

Offset 14h: CC – Controller Configuration

Memory Page Size (MPS): This field indicates the host memory page size. The memory page size is (2 ^ (12 + MPS)). Thus, the minimum host memory page size is 4 KiB and the maximum host memory page size is 128 MiB。

重要的数据结构

nvme 中的metadata

关于PRP

每个PRP 的结构如下,就是一个64bit 的地址(包含偏移)

描述了PRP entry 及其和下一个PRP entry page 之间的链接方式:

A physical region page list (PRP List) is a set of PRP entries in a single page of contiguous memory. A PRP List describes additional PRP entries that could not be described within the command itself. Any PRP entries described within the command are not duplicated in a PRP List. If the amount of data to transfer requires multiple PRP List memory pages, then the last PRP entry before the end of the memory page shall be a pointer to the next PRP List, indicating the next segment of the PRP List. Figure 109 shows the layout of a PRP List where each PRP entry identifies memory pages that are physically contiguous. Figure 109 shows the layout of a PRP List where each PRP entry identifies a different memory page (i.e., the memory pages are not physically contiguous).

SGL 重要数据结构

entry 摆放方式

entry 分类

下表列出了主要的几种sgl descriptor的类型:

其实每个主类型里还有子类型,这里就不具体列举了。

entry 的结构

每个entry 都是16 bytes, 下面介绍几种最主要的entry.

SGL Data Block Descripotr

(通过它,可以把LBA上相邻的数据,通过DMA合并一起读写)

SGL bit bucket Descpritor

通过它,可以调过NVME 设备上业务不需要访问的数据区域,告诉DMA这里需要新启一个DMA传输。

SGL Segment Descripotr

SGL Last Segment Descriptor:

用来链接最后一个SGL descriptor,告诉DMA 这是最后一个传输了。

示例

下面一个示意图,用到了上面列出的四种描述符,是一个SGL用法非常好的例子:

Command Format – Admin and NVM Command Set 定义了每个NVME submit queue entry 格式

指定执行什么NVME命令操作

Command Dword 0 : 指定命令类型、 使用PRP 还是SGL 来传输数据

指定在哪个name space 上执行

Namespace Identifier (NSID):

元数据指针:Metadata Pointer (MPTR):

Metadata Pointer (MPTR): This field is valid only if the command has metadata that is not interleaved with the logical block data, as specified in the Format NVM command. This is a reserved field in NVMe over Fabrics implementations.

如果CDW0.PSDT 为0, 这个字段表示使用PRP 来描述是PRP (Physical Region pointer);否则,表示数据走SCL机制;

(Metadata Pointer 到底做什么用?和后面的 Date buffer 字段相比,功能上有和联系和区别?)

数据指针:Data Pointer (DPTR):

如果使用PRP: 表示PRP Entry2如果数据不跨memory page, 保留无用; 如果数据跨越memory page, 就表示第二个physical region memroy page; 如果使用SGL:表示SGL1: 指向第一个SGL segment

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Kubernetes Operator基础入门
下一篇:Hadoop+HBase+ZooKeeper分布式集群环境搭建步骤
相关文章

 发表评论

暂时没有评论,来抢沙发吧~