棋子 · 2 天前

PCIe Gen6 Transaction Layer 整理(一)

image.png

1. Transaction Layer 简介

1.1  事务定义与 TLP 生成

  • 生成事务层数据报文(TLP):接收设备核心层(Device Core)的数据请求(如数据读写、完成反馈、信息传递等),将其转换为标准的 PCIe 总线事务,并封装成事务层数据报文(TLP,Transaction Layer Packet)。TLP 主要包含头部(Header)、数据负载(Data Payload,可选)和端到端循环冗余校验(ECRC,End - to - End CRC),用于在设备间传输数据和指令。
  • 支持多种总线事务:继承并扩展了传统 PCI/PCI - X 总线事务,包括:

1I/O 读写(I/O Read/Write):针对 I/O 设备地址空间的读写。

  • 存储器读写(Memory Read/Write):对内存空间的读写操作。
  • 配置读写(Configuration Read/Write):用于访问设备的配置空间,初始化和配置设备。

1Message 事务:实现设备间带内通信(如中断、错误报告等),支持标准消息及厂商自定义消息。

图片

1.1.1 Memory Transactions

memory 传输包含如下类型:

• Read Request/Completion
• Write Request (and Completions for UIO)
• Deferrable Memory Write Request/Completion
• AtomicOp Request/Completion

memory 传输包含两种 2 地址格式,分别是 32-bit address 和 64-bit address。

1.1.2 I/O Transactions

为了兼容旧设备,PCIe 支持 IO 传输。

IO 传输包含如下类型:

• Read Request/Completion
• Write Request/Completion

IO 传输只会使用 32-bit address。

1.1.3 Configuration Transactions

Configuration Transactions 用于访问设备 function 的配置寄存器。

Configuration 传输包含如下类型:

• Read Request/Completion
• Write Request/Completion

1.1.4 Message Transactions

实现设备间带内通信(如中断、错误报告等),支持标准消息及厂商自定义消息。

协议描述了多种类型的 Message ,PCIe 还支持 Vendor-Defined Messages,但是不同 vendor 的 Vendor-Defined Messages 之间无法保证能够通信。

1.2  流量控制(Flow Control)

  • 采用基于信用(Credit)的流量控制机制,发送端根据接收端反馈的缓存 credit,动态控制 TLP 的发送,避免接收端缓存溢出,确保数据传输的高效与稳定。

1.3  虚通路管理(Virtual Channel Management)

  • 支持多个虚拟通道(VC,最多 8 个),每个 VC 可独立传输 TLP。当某个 VC 缓存满时,不影响其他 VC 的传输,实现不同类型流量(如高优先级的视频流与普通数据)的隔离与优先处理,提升服务质量(QoS)。例如,通过流量类别(TC,Traffic Class)字段为 TLP 分配优先级,将其放入对应 VC 传输。

1.4  数据完整性与错误处理

  • 端到端校验(ECRC):事务层计算并添加 ECRC 字段,接收端通过校验该字段,确保 TLP 在整个传输过程中未出现错误(如经过多个交换机或链路时)。
  • 错误指示:支持数据中毒(Error Poisoned)等机制,指示 TLP 的数据负载是否被污染,以便接收端进行相应处理,保障数据可靠性。

1.5 Packet Format Overview

图片

图 2-2 显示了 TLP 的高级序列化视图,由一个或多个可选的 TLP 前缀、一个 TLP 头、数据有效载荷(对于某些类型的包)和一个可选的 TLP 摘要组成。在发送 TLP 时,按字节编码顺序发送,例如 Byte0 先发送,ByteK+3 最后发送。其中,data payload 的最低地址字节是 J,在所有 data payload 中最先传输。

图片

根据 TLP 的类型,TLP header 会包含如上部分字段:

• Format of the packet
• Type of the packet
• Length for any associated data
• Transaction Descriptor, including:

◦ Transaction ID
◦ Attributes
◦ Traffic Class

• Address/routing information
• Byte Enables
• Message encoding
• Completion status

2. Transaction Layer Protocol - Packet 定义

所有 TLP 中 RSV 的字段必须填充 0,且 receiver 忽略 rsv 字段。Switch 在转发时不修改此字段。

Non-Flit Mode (NFM) 和 Flit Mode (FM) 的 header 格式是不相同的,因此对 Switch 来说,如果 TLP 进入端口(ingress port)和出口(egress port)处在不同的模式下(一个端口在 NFM,另外一个在 FM),此时 Switch 内部需要对 TLP 格式进行转换,满足 egress port 格式要求。

2.1 Common Packet Header

2.1.1 Common Packet Header Fields for Non-Flit Mode

图片

图片

所有 TLP prefixes 和 headers 都包含如下字段:

• Fmt[2:0] - Format of TLP (see § Table 2-2) - bits 7:5 of byte 0
• Type[4:0] - Type of TLP - bits 4:0 of byte 0

Type 字段指示 TLP Prefix type(s),而 Fmt 字段指示 TLP Prefixes 的数量。

图片

• TC[2:0] - Traffic Class- bits [6:4] of byte 1

图片

• R (byte 1 bit 1) - Reserved; formerly was the Lightweight Notification (LN) bit, but is now available for reassignment.
• TLP Hints (TH) - 1b indicates the presence of TLP Processing Hints (TPH) in the TLP header and optional TPH TLP Prefix (if present) - bit 0 of byte 1 (see § Section 2.2.7.1.1 )
• Attr[1:0] - Attributes (see § Section 2.2.6.3 ) - bits [5:4] of byte 2
• Attr[2] - Attribute (see § Section 2.2.6.3 ) - bit 2 of byte 1 (shown as A2 in figures)
• TD - 1b indicates presence of TLP Digest in the form of a single Double Word (DW) at the end of the TLP (see § Section 2.2.3 ) - bit 7 of byte 2

图片

• TD - 1b indicates presence of TLP Digest in the form of a single Double Word (DW) at the end of the TLP- bit 7 of byte 2,数值为 1 表示存在 ECRC
• Error Poisoned (EP) - indicates the TLP is poisoned (see § Section 2.7 ) - bit 6 of byte 2
• Length[9:0] - Length of data payload, or of data referenced, in DW  - bits 1:0 of byte 2 concatenated with bits 7:0 of byte 3

◦ TLP data must be 4-byte naturally aligned and in increments of 4-byte DW.
◦ Reserved for TLPs that do not contain or refer to data payloads, including Cpl, CplLk, and Messages (except as specified)

需要注意的是全 0 表示 1024 个 DW。

图片

图片

图片

END

作者:IC小鸽
文章来源:IC小鸽

推荐阅读

更多 IC 设计干货请关注IC 设计专栏。欢迎添加极术小姐姐微信(id:aijishu20)加入技术交流群,请备注研究方向。

推荐阅读
关注数
22996
内容数
1373
主要交流IC以及SoC设计流程相关的技术和知识
目录
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
安谋科技学堂公众号
关注安谋科技学堂
实时获取安谋科技及 Arm 教学资源
安谋科技招聘公众号
关注安谋科技招聘
实时获取安谋科技中国职位信息