4.4 Scatter Gather List (SGL)

4.4 Scatter Gather List (SGL)
A Scatter Gather List (SGL) is a data structure in memory address space used to describe a data buffer. The controller indicates the SGL types that it supports in the Identify Controller data structure. A data buffer is either a source buffer or a destination buffer. An SGL contains one or more SGL segments. The total length of the Data Block and Bit Bucket descriptors in an SGL shall be equal to or exceed the amount of data required by the number of logical blocks transferred.
An SGL segment is a Qword aligned data structure in a contiguous region of physical memory describing all, part of, or none of a data buffer and the next SGL segment, if any. An SGL segment consists of an array of one or more SGL descriptors. Only the last descriptor in an SGL segment may be an SGL Segment descriptor or an SGL Last Segment descriptor.

A last SGL segment is an SGL segment that does not contain an SGL Segment descriptor, or an SGL Last Segment descriptor.
A controller may support byte or Dword alignment and granularity of Data Blocks. If a controller supports only Dword alignment and granularity as indicated in the SGL Support field of the Identify Controller data structure, then the values in the Address and Length fields of all Data Block descriptors shall have their lower two bits cleared to 00b. This requirement applies to Data Block descriptors that indicate data and/or metadata memory regions.
A Keyed SGL Data Block descriptor is a Data Block descriptor that includes a key that is used as part of the host memory access. The maximum length that may be specified in a Keyed SGL Data Block descriptor is (16 MB – 1).
The SGL Identifier Descriptor Sub Type field may indicate additional information about a descriptor. As an example, the Sub Type may indicate that the Address field is an offset rather than an absolute address. The Sub Type may also indicate NVMe Transport specific information.
The controller shall abort a command if:
   an SGL segment contains an SGL Segment descriptor or an SGL Last Segment descriptor in other than the last descriptor in the segment;
   a last SGL segment contains an SGL Segment descriptor, or an SGL Last Segment descriptor;
   an SGL descriptor has an unsupported format; or
   an SGL Data Block descriptor contains Address or Length fields with either of the two lower bits set to 1b and the controller supports only Dword alignment and granularity as indicated in the SGL Support field of the Identify Controller data structure.
Figure 16 defines the SGL segment.

 

 

 An SGL segment contains one or more SGL descriptors. Figure 17 defines the generic SGL descriptor format.

 

 

 The SGL Descriptor Type field defined in Figure 18 specifies the SGL descriptor type. If the SGL Descriptor Type field is set to a reserved or unsupported value, then the SGL descriptor shall be processed as having an error. If the SGL Descriptor Sub Type field is set to an unsupported value, then the descriptor shall be processed as having an SGL Descriptor Type error.

An SGL descriptor set to all zeros is an SGL Data Block descriptor with the Address field set to 00000000_00000000h and the Length field set to 00000000h may be used as a NULL descriptor.

 

 

 4.4 Scatter Gather List (SGL)

Scatter Gather List (SGL) 是内存地址空间中的一种数据结构,其用于描述数据缓冲区。控制器在标识控制器数据结构(Identify Controller data structure)中表明其支持的SGL类型。描述的数据缓冲区可以是源缓冲区,也可以是目标缓冲区。一个SGL包含一个或多个SGL段。SGL中的数据块(Data Block)和位桶(Bit Bucket)描述符的总长度应等于或超过传输的逻辑块数量所需的数据量。
SGL段是物理内存连续区域中的一个Qword对齐的数据结构,其描述了一个数据缓冲区的全部、部分或空集以及下一个SGL段(如果有的话)。一个SGL段由一个或多个SGL描述符组成。只有SGL段中的最后一个描
述符可以是SGL段描述符或SGL末段描述符。最后一个SGL段是不包含SGL段描述符或SGL末段描述符的SGL段。控制器应当支持数据块(Data Blocks)的byte或Dword对齐和粒度(granularity)。如果控制器在标识控制器数据结构(Identify Controller data structure)中的SGL Support字段表明只支持Dword对齐和粒度,则所有数据块描述符的Address and Length字段中的值都应将其低两位清空为00b。此要求适用于指示数据和/或元数据内存区域的数据块描述符。键控SGL数据块(Keyed SGL Data Block)描述符是一个数据块描述符,其中包含一个键,该键用作主机内存访问的一部分。可在键控SGL数据块描述符中指定的最大长度为(16MB - 1)。SGL标识符描述符子类型(SGL Identifier Descriptor Sub Type)字段可以指示关于描述符的附加信息。例如,子类型可能表明Address字段是偏移量,而不是绝对地址。子类型还可以指示NVMe传输特定的信息。如果发生以下情况,控制器应中止命令:

  •SGL段除了段中的最后一个描述符外,还包含SGL段描述符或SGL最后一个段描述符;

  •最后一个SGL段包含一个SGL段描述符,或一个SGL末段描述符;

  •SGL描述符具有不受支持的格式;

  •SGL数据块描述符包含地址或长度字段,其中两个较低的位任一设置为1b,控制器只支持标识控制器数据结构中的SGL Support字段中所示的Dword对齐和粒度。

Figure16defines the SGL segment.

 

 

 一个SGL段包含一个或多个SGL描述符。 图17定义了通用SGL描述符格式。

 

 

 

图18中定义的SGL描述符类型字段指定SGL描述符类型。 如果SGL描述符类型字段设置为保留值或不支持的值,则应将SGL描述符处理为有错误。 如果SGL描述符子类型字段设置为不支持的值,则该描述符应被视为具有SGL描述符类型错误。
设置为全零的SGL描述符是地址字段设置为00000000_00000000h且长度字段设置为00000000h的SGL数据块描述符可以用作NULL描述符。

 

 

 Figure 19 defines the SGL Descriptor Sub Type Values. For each Sub Type Value defined, the Descriptor Types that it applies to are indicated.

 

 

 The SGL Data Block descriptor, defined in Figure 20, describes a data block.

 

 

 The SGL Bit Bucket descriptor, defined in Figure 21, is used to ignore parts of source data.

 

 

 The SGL Segment descriptor, defined in Figure 22, describes the next SGL segment, which is not the last SGL segment.

 

 

 The SGL Last Segment descriptor, defined in Figure 23, describes the next and last SGL segment. A last SGL segment that contains an SGL Segment descriptor or an SGL Last Segment descriptor is processed as an error.

 

 

 The Keyed SGL Data Block descriptor, defined in Figure 24, describes a keyed data block.

 

 

 4.4.1 SGL Example

Figure 25 shows an example of a data read request using SGLs. In the example, the logical block size is 512B. The total length of the logical blocks accessed is 13KB, of which only 11KB is transferred to the host. The Number of Logical Blocks (NLB) field in the command shall specify 26, indicating the total length of the logical blocks accessed on the controller is 13KB. There are three SGL segments describing the locations in memory where the logical block data is transferred.
The three SGL segments contain a total of three Data Block descriptors with lengths of 3 KB, 4 KB and 4 KB respectively. Segment 1 of the Destination SGL contains a Bit Bucket descriptor with a length of 2 KB that specifies to not transfer (i.e., ignore) 2 KB of logical block data from the NVM. Segment 1 of the destination SGL also contains a Last Segment descriptor specifying that the segment pointed to by the descriptor is the last SGL segment.

 

 

 

图25显示了使用SGL的数据读取请求的示例。 在该示例中,逻辑块大小为512B。 所访问的逻辑块的总长度为13KB,其中只有11KB传输到主机。 命令中的逻辑块数(NLB)字段应指定26,指示在控制器上访问的逻辑块的总长度为13KB。 有三个SGL段描述了逻辑块数据在内存中的传输位置。
这三个SGL段总共包含三个数据块描述符,其长度分别为3 KB,4 KB和4 KB。 目标SGL的段1包含一个长度为2 KB的位桶描述符,该描述符指定不传输(即忽略)来自NVM的2 KB逻辑块数据。 目标SGL的分段1还包含一个Last Segment描述符,该描述符指定描述符所指向的分段是最后一个SGL分段。

posted @ 2020-04-09 20:04  话说吴语  阅读(2896)  评论(0编辑  收藏  举报