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分段。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM