SGL协议阅读个人总结

  • SGL概念
    • A Scatter Gather List (SGL) is a data structure in memory address space used to describe a data buffer
    • A data buffer is either a source buffer or a destination buffer. (来回都有SGL, 例如read/write)
    • 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.
  • SGL由一个或者多个Segment组成。每个Segment所描述的Data空间大小应该大于或等于Data Transfer的大小。
  • SGL和SQ

PSDT field:

  1. 如果给0x0,则通过PRP传输。
  2. 如果set 0x1,通过SGL传输。且MPTR field指向一个8byte长度的物理内存地址,用来存放Metadata。这个域的对齐情况参考SGLS_bit17
  3. 如果set 0x2,也通过SGL传输。且MPTR field指向一个8byte长度的地址,用来存放描述metadata的Segment,此时MPRT域需要Qword对齐。这个Segment只包含一个Descriptor。

  • SGL Support情况:

bit0_1 of SGLS:0→ Not Support SGL

1→Support SGL and No Dword alignment

2→Support SGL and Require Dword Alignment

  • Generic SGL Descriptor Format

  • Type和SubType的支持情况:

SGL Descriptor Type:

SGL Data Block Descriptor (0x0), describes a data block.

SGL Bit Bucket Descriptor (0x1), is used to ignore parts of source data.

SGL Segment Descriptor (0x2), 用来描述 next SGL segment, 不能作为last SGL segment.

SGL Last Segment Descriptor (0x3) ,用来描述下一个Segment且是Last Segment的Descriptor。(在倒数第二个Segment的末尾,后面只剩一个Last Segment)

Keyed SGL Data Block descriptor (0x4) (16 MiB – 1), describes a keyed data block.相比其他的data block Descriptor多了一个key 字段,在descriptor的bytes14_11

Transport SGL Data Block descriptor (0x5)

Sub Type 0 表示Address

Sub Type 1 表示Offset(only for NVME over Fabric)

SubType0

SubType1

Type0

Address

Fabrics Offset

Type1

Address

Abort

Type2

Address

Fabrics Offset

Type3

Address

Fabrics Offset

Type4

Address

Abort

SGL SubType 描述Descriptor的额外信息,例如可能Address域是指Offset的值而不是实际的地址。SubType也可以用来描述NVME Transport所指定的一些信息。

  • SGL Segment和Descriptor
    • 每个Segment中只有最后一个Descriptor可以是SGL Segment Descriptor或者SGL Last Segment Descriptor
    • Last SGL Segment是一个既不包含Segment Descriptor,也不包含 Last Segment Descriptor的Segment
  • Command Abort:
    • 当一个SGL Segment中的Segment Descriptor 或者SGL Last Segment Descriptor的位置不在Segment的最后一个Descriptor
    • 当一个Last Segment中包含Segment Descriptor或者包含Last Segment Descriptor
    • an SGL descriptor has an unsupported format;
    • 当Id-ctrl中规定dword对齐需要时,在Address 或者offset 域前2bit非00b (似乎是非强制要求,下面说是may report 0x2)
  • SDT (SGL Descriptor Threshold) 和MSDBD(Maximum SGL Data Block Descriptors) in Identify Controller Data.

如果Bit Bucket Descriptor可能导致性能下降

  • Descriptor Type1 Bit Bucket descriptor
    • Address:Reserved
    • Length:指 amount of source data that is discarded。Length=0表示没有需要discard 的buffer,并且是valid Descriptor。
    • 如果Bit Bucket descriptor描述的是destination data buffer,(方向read Controller --> Host memory)则Length表示Controller discard的data长度(not transfer to destination data buffer) 。
    • 如果Bit Bucket Descriptor描述的是source data buffer,(write from host to controller), 则Length被当做clear To 0处理。
    • 如果Bit Bucket Descriptor 支持,那么所有作为destination data 的Bit Bucket的Length应该包含在数据传输的总长度中。如果是作为source data的话,Length不包含在data transfer Length中(也就是NLB)
  • Descriptor Type2 Segment Descriptor
    • Address:描述 address of the next SGL segment。或者offset (over fabric)
    • Length:描述下一个Segment的长度,in bytes,且不能为0, 且是16的倍数。(一个Descriptor是16bytes),且需要Dword对齐,如果SGLS指定
    • Address + Length 应该
  • Descriptor Type3 Last Segment Descriptor
    • Address:描述 address of the next and Last SGL segment。
    • Length:与Type2描述一致。
    • Address + Length 应该
  • Descriptor Type4: Keyed SGL Data Block descriptor
    • Address:同上
    • Length:同上
    • Key: Specifies a 32-bit key that is associated with the data block.
  • Descriptor Type5: Keyed SGL Data Block descriptor
    • Address: Reserved
    • Length:同上
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值