本文基本是对 CXL 协议 2.0 的翻译,仍未有特别独特的见解,口语化解释不太多,尽量在有例子的基础上进行讲解,希望对相关人员理解有帮助。以后慢慢更新其中的理解吧。
这一部分你需要了解cache MESI 协议相关的知识。
状态转换,要都理解了:
CXL.cache 协议将 Device 和 Host 之间的交互定义为每个具有至少一个关联响应消息的请求的数量,有时是数据传输。 该接口由每个方向的三个通道组成:请求、响应和数据。 通道以其方向命名,D2H 表示Device to Host 和 H2D for Host to Device,以及它们携带的交易、请求、响应和数据如图 20 所示。独立的通道允许不同的消息使用专用线并实现每条线的解耦和更高有效吞吐量。
D2H Request 将新的请求从 Device 传送到 Host。请求通常目标内存。每个请求将收到零个、一个或两个响应,最多一个64 字节的数据缓存行。该通道可能会毫无问题地受到数据积压。 D2H Response 携带从 Device 到 Host 的所有响应。设备对 snoops 的响应指示该行留在设备缓存中的状态,并可能指示数据是被返回到主机提供的数据缓冲区。他们可能仍被阻止暂时由于链路层信用,但不应要求完成任何其他事务以释放信用。 D2H 数据携带来自设备到主机的所有数据和 byte-enables 。数据传输可能来自隐式(由于snoop)或显式回写(作为缓存容量驱逐的结果)。在所有情况下,将传输一个完整的 64 字节的缓存行数据。 D2H 数据传输必须取得进展否则可能会发生死锁。它们可能因链路层信用而被暂时阻止,但不得要求完成任何其他事务以释放信用。
H2D Request 携带从 Host 到 Device 的请求,这些是 snoops 保持一致性。 可能会返回数据以供 snoops。 请求携带任何返回数据应写入的数据缓冲区的位置。 H2D 请求可能由于缺乏设备资源而数据积压; 但是,必须释放资源无需 D2H 请求即可取得进展。 H2D Response 携带序列消息和拉取写入数据。 每个响应都携带来自原始设备请求的标识符,以指示应将响应路由到何处。 为了写入数据拉取响应,消息携带应写入数据的位置。 H2D只能暂时阻止链路层信用的响应。 H2D 数据提供设备读取请求的数据。 在所有情况下,一个完整的 64 字节缓存行数据将被转移。 H2D 数据传输由于链路层信用只能暂时阻塞。
此命令包含的几个字段,我们可以把它理解为一个网络包,然后包中包含的字段代表不同的含义。
These are full cacheline read requests from the device for lines to get the most current data, but not change the existing state in any cache, including in the Host. The Host does not need to track the cacheline in the device that issued the RdCurr. RdCurr gets adata but no GO. The device receives the line in the Invalid state which means it getsone use of the line and cannot cache it.
设备发出的完整高速缓存行读请求,以获取主机最新的数据,但不会更改其中任何缓存行的现有状态。 主机不需要跟踪发出 RdCurr 的设备中的缓存行。 RdCurr 只得到一个数据并没有 GO 信息。 设备接收到数据,本地缓存行处于无效状态,这意味着它只使用数据一次,并不缓存它。
These are full cacheline reads requests from the device for lines to be cached in any writeable state. Typically, RdOwn request receives the line in Exclusive (GO-E) or Modified (GO-M) state. Lines in Modified state must not be dropped, and have to be written back to the Host.
这是设备发出的完整缓存行读请求,这些缓存行在设备中处于任何可写状态。 通常,RdOwn 接收到的数据会处在独占(GO-E) 或修改(GO-M)状态。 处于 Modified 状态的行不能被删除,必须写回主机。
Under error conditions, a RdOwn request may receive the line in Invalid (GO-I) or Error (GO-Err) state. Both will return synthe sized data of all1s. The device is responsible forhandling the error appropriately.
在错误情况下,RdOwn 请求可能会收到处于无效 (GO-I) 或 错误 (GO-Err) 状态中的缓存行。 两者都将返回 all 1s 的合成数据。 设备适当地负责处理错误。
Cache Writes 三种方式:
1. Ownership
2.Silient Write
3. Cache Evictioin
These are full cacheline read requests from the device for lines to cached in Shared state. Typically, RdShared request receives the line in Shared (GO-S) state.
这些是来自设备的完整缓存行读请求,用于缓存在 Shared 状态中的缓存行。 通常,RdShared 请求接收处于share (GO-S) 状态的缓存行。
在错误情况下,RdShared 请求可能会收到处于 Invalid (GO-I) 或错误 (GO-Err) 状态的缓存行。 两者都将返回 all1s 的合成数据。 该设备是负责适当地处理错误。
These are full cacheline read requests from the device for lines to cached in any state. Typically, RdAny request receives the line in Shared (GO-S), Exclusive (GO-E) or Modified (GO-M) state. Lines in Modified state must not be dropped, and have to be written back to the Host.
这些是来自设备的完整缓存线读取请求,用于在任何状态下缓存的行。通常,RdAny 请求以 Shared (GO-S)、Exclusive (GO-E) 或修改(GO-M)状态。 处于 Modified 状态的行不能被删除,并且必须写回主机。
在错误情况下,RdAny 请求可能会收到处于 Invalid (GO-I) 或 Error 状态的缓存行。 两者都将返回 all1s 的合成数据。 该设备负责适当地处理错误。
These are requests to get exclusive ownership of the cacheline address indicated in the address field. The typical response is Exclusive (GO-E).
这些是获取缓存行地址独占所有权的请求,地址在地址字段表示出来。 典型的响应是独占 (GO-E)。
在错误情况下,RdOwnNoData 请求可能会收到在错误(GO-Err)状态的缓存行。 设备负责适当地处理错误。
This command requests exclusive ownership of the cacheline address indicated in the address field and atomically writes the cacheline back to the Host. The device guarantees the entire line will be modified, so no data needs to be transferred to the device. The typical response is GO-I-WritePull, which is sent once the request is granted ownership. The device must not retain a copy of the line.
该命令请求 独占缓存行地址并以原子方式将缓存行写回主机。 设备保证整行都会被修改,因此不需要将数据传输到设备。 典型的响应是 GO-I-WritePull,它在请求授予所有权的时候被发送。 设备不得保留缓存行的副本。
If an error occurs, then GO-Err-WritePull is sent instead. The device sends the data to the Host, which drops it. The device is responsible for handling the error as appropriate.
如果发生错误,则改为发送 GO-Err-WritePull。 设备将数据发送到主机,它会丢弃它。 设备负责将错误处理为合适的。
The command behaves like the ItoMWr in that it atomically requests ownership of a cacheline and then writes a full cacheline back to the fabric. However, it differs from ItoMWr in where the data is written. Only if the command hits in a cache will the data be written there; on a miss the data will be written to directly to memory. The typical response is GO-I-WritePull once the request is granted ownership. The device must not retain a copy of the line.
该命令的行为类似于 ItoMWr,因为它以原子方式请求一个缓存行,然后将完整的缓存行写回 fabric。 然而,它不同于ItoMWr ,数据写入的地方不一样。 只有当命令命中缓存时,数据才会写在那里; 如果未命中,数据将直接写入内存。 就是一旦请求被授予所有权,典型的响应就是 GO-I-WritePull。 该设备不得保留该行的副本。
如果发生错误,则改为发送 GO-Err-WritePull。 设备将数据发送到主机,它会丢弃它。 设备负责将错误处理为合适的。
This is a request to the Host to invalidate the cacheline specified in the address field. The typical response is GO-I that will be sent from the Host upon completion in memory.
这是对主机的请求,以使地址字段中指定的高速缓存行无效。典型的响应是 GO-I,它将在内存中完成后从主机发送。
However, the Host may keep tracking the cacheline in Shared state if the Core has issued a Monitor to an address belonging in the cacheline. Thus, the Device must not rely on CLFlush/GO-I as an only and sufficient condition to flip a cacheline from Host to Device bias mode. Instead, the Device must initiate RdOwnNoData and receive an H2D Response of GO-E before it updates its Bias Table and may subsequently access the cacheline without notifying the Host.
但是,如果 Core 向属于高速缓存行的地址发出监视命令,主机可能继续跟踪处于共享状态的缓存行。 因此,设备不得依赖 CLFlush/GO-I 作为将缓存行从主机翻转到的唯一且充分的条件器件偏置模式。 相反,设备必须在更新其偏向表并随后可能访问缓存行而不通知主机之前启动 RdOwnNoData 并接收 H2D GO-E 。
Under error conditions, a ClFlush request may receive the line in the Error (GO-Err) state. The device is responsible for handling the error appropriately
在错误情况下,ClFlush 请求可能会收到 Error (GO-Err) 状态的行。 设备负责适当地处理错误。
This is a request to the Host to evict a full 64 byte Exclusive cacheline from the device. Typically, CleanEvict receives GO-WritePull or GO-WritePullDrop. Receiving any means the device must relinquish snoop ownership of the line. For GO-WritePull the device will send the data as normal. For GO-WritePullDrop the device simply drops the data.
这是对主机的请求,从设备中逐出完整的 64 字节独占高速缓存行。通常,CleanEvict 接收 GO-WritePull 或 GO-WritePullDrop。 接受任何手段设备必须放弃对缓存行的 snoop 所有权。 对于 GO-WritePull,设备将正常发送数据。 对于 GO-WritePullDrop,设备只是丢弃数据。
Once the device has issued this command and the address is subsequently snooped, but before the device has received the GO-WritePull or GO-WritePullDrop, the device must set the Bogus field in all D2H Data messages to indicate the data is now stale.
一旦设备发出了这个命令并且地址随后被窥探,但在设备收到 GO-WritePull 或 GO-WritePullDrop 之前,设备必须在所有 D2H 数据消息中设置 Bogus 字段以指示数据现在已过时。
CleanEvict requests also guarantee to the Host that the device no longer contains any cached copies of this line. Only one CleanEvict from the device may be pending on CXL.cache for any given cacheline address.
CleanEvict 请求还向主机保证设备不再包含任何此行的缓存副本。 设备中对于给定的缓存行地址只有一个 CleanEvict 可能处于待处理状态。
CleanEvict is only expected for host-attached memory range of addresses. For deviceattached memory range, the equivalent operation can be completed internally within the device without sending a transaction to the Host.
CleanEvict 仅适用于主机连接的内存地址范围。 对于设备内存范围内,等效操作可以在内部完成设备,不向主机发送事务。
This is a request to the Host to evict a full 64 byte Modified cacheline from the device. Typically, DirtyEvict receives GO-WritePull from the Host at which point the device must relinquish snoop ownership of the line and send the data as normal.
这是对主机的请求,以从设备中逐出完整的 64 字节修改的缓存行。通常,DirtyEvict 从主机接收 GO-WritePull,此时设备必须放弃缓存行的窥探所有权并正常发送数据。
Once the device has issued this command and the address is subsequently snooped, but before the device has received the GO-WritePull, the device must set the Bogus field in all D2H Data messages to indicate the data is now stale.
一旦设备发出了这个命令并且地址随后被窥探,但在设备收到 GO-WritePull 之前,设备必须设置 所有 D2H 数据消息中的Bogus字段以指示数据现在已过时。
DirtyEvict requests also guarantee to the Host that the device no longer contains any cached copies of this line. Only one DirtyEvict from the device may be pending on CXL.cache for any given cacheline address.
DirtyEvict 请求还向主机保证设备不再包含任何此行的缓存副本。 对于任何缓存行地址只有一个来自设备的 DirtyEvict 可能被挂起。
In error conditions, a GO-Err-WritePull will be received. The device will send the data as normal, and the Host will drop it. The device is responsible for handling the error as appropriate.
在错误情况下,将收到 GO-Err-WritePull。 设备将正常发送数据,主机会丢弃它。 设备负责适当的错误处理。
DirtyEvict is only expected for host-attached memory range of addresses. For deviceattached memory range, the equivalent operation can be completed internally within the device without sending a transaction to the Host.
DirtyEvict 仅适用于主机连接的内存地址范围。 对于设备内存范围内,等效操作可以在内部完成设备而不向主机发送事务。
This is a request for the device to update the Host that a clean line is dropped in the device. The sole purpose of this request is to update any snoop filters in the Host and no data will be exchanged.
这是设备更新主机的请求,即设备抛弃一个干净的缓存行。 此请求的唯一目的是更新主机中的任何 snoop 过滤器, 并且不会交换任何数据。
CleanEvictNoData is only expected for host-attached memory range of addresses. For device-attached memory range, the equivalent operation can be completed internally within the device without sending a transaction to the Host.
CleanEvictNoData 仅适用于主机连接的内存地址范围。 为了设备内存范围,等效操作可以在内部完成在设备内,无需向主机发送事务。
This is a weakly ordered write invalidate line request of 0-63 bytes for write combining type stores. Any combination of byte enables may be set.
这是用于写组合类型存储的 0-63 字节的弱排序写无效行请求。 可以设置任何字节使能组合。
Typically, WOWrInv receives a FastGO-WritePull followed by an ExtCmp. Upon receiving the FastGO-WritePull the device sends the data to the Host. For host-attached memory, the Host sends the ExtCmp once the write is complete in memory.
通常,WOWrInv 收到一个 FastGO-WritePull 后跟一个 ExtCmp。 收到 FastGO-WritePull 后设备将数据发送到主机。 对于主机附加内存,一旦在内存中完成写入,主机就会发送 ExtCmp。
In error conditions, a GO-Err-Writepull will be received. The device will send the data as normal, and the Host will drop it. The device is responsible for handling the error as appropriate. An ExtCmp will still be sent by the Host after the GO-Err in all cases.
在错误情况下,将收到一个 GO-Err-Writepull。 设备将发送数据为正常,主机会丢弃它。 设备负责将错误处理为合适的。 在所有情况下,主机仍将在 GO-Err 之后发送 ExtCmp。
和 WOWINV 一样,除了它是写64字节
This is a write invalidate line request of 0-64 bytes. Typically, WrInv receives a WritePull followed by a GO. Upon getting the WritePull the device sends the data to the Host. The Host sends GO once the write complete in memory (both, host-attached or deviceattached).
这是一个 0-64 字节的写无效行请求。 通常,WrInv 接收一个 GO后面的WritePull。 获得 WritePull 后,设备将数据发送到主机。 这一旦内存中的写入完成(主机连接或设备连接),主机就会发送 GO。
In error conditions, a GO-Err is received. The device is responsible for handling the error as appropriate.
错误状态下, GO-Err 将被接收。
This is an indication sent by the device to inform the Host that its caches are flushed, and it no longer contains any cachelines in the Shared, Exclusive or Modified state. The Host can use this information to clear its snoop filters and block snoops to the device and return a GO. Once the device receives the GO, it is guaranteed to not receive any snoops from the Host until the device sends the next cacheable D2H Request.
这是设备发送的一个指示,通知主机其缓存已刷新,并且它不再包含任何处于 Shared、Exclusive 或 Modified 状态的缓存行。 主机可以使用此信息清除其窥探过滤器并阻止对设备的窥探并返回一个 GO。 一旦设备收到GO,就保证不会收到任何主机发出的 snoops,直到设备发送下一个可缓存的 D2H 请求。
此响应告诉设备将写入数据发送到主机,但不更改缓存行的状态。 这用于在 GO-I 能够发送之前需要数据的 WrInv 。 这是因为 GO-I 是 I/O 完成写入的通知。
The Global Observation (GO) message conveys that read requests are coherent and that write requests are coherent and consistent. It is an indication that the transaction has been observed by the system device and the MESI state that is encoded in the RspType field indicates what state the data associated with the transaction should be put in for the requester’s caches. Details in Table 14.
全局观察 (GO) 消息传达读请求是一致的,并且写请求是连贯一致的。 这表示一个事务被系统设备观察,并且 MESI 状态被编码在RspType 字段,指示与事务关联的数据应该是什么状态放入请求者的缓存中。 表 14 中的详细信息。
If the Host returns Modified state to the device, then the device is responsible for the dirty data and cannot drop the line without writing it back to the Host.
如果主机返回 M 状态给设备,则设备负责脏数据,并且在不将其写回主机的情况下无法删除该行。
If the Host returns Invalid or Error state to the device, then the device must use the data at most once and not cache the data. Error responses to reads and cacheable write requests (for example, RdOwn or ItoMWr) will always be the result of an abort condition, so modified data can be safely dropped in the device.
如果主机向设备返回无效或错误状态,则设备必须使用数据最多一次,不缓存数据。 对读取和可缓存的错误响应写请求(例如,RdOwn 或 ItoMWr)将始终是中止的结果条件,因此设备中修改后的数据可以安全地丢弃。
This is a combined GO + WritePull message. No cache state is transferred to the device. The GO+WritePull message is used for posted write types.
这是一个组合的 GO + WritePull 消息。 没有缓存状态传输到设备。GO+WritePull 消息用于 posted 的写入类型。
This response indicates that the data that was previously locally ordered (FastGO) has been observed throughout the system. Most importantly, accesses to memory will return the most up to date data.
这个响应表明之前本地排序的数据(FastGO)有在整个系统中已经被观察。 最重要的是,对内存的访问将返回最新的数据。
This message has the same semantics as Go_WritePull, except that the device should not send data to the Host. This response can be sent in place of GO_WritePull when the Host determines that the data is not required. This response will never be sent for partial writes since the byte enables will always need to be transferred.
此消息与 Go_WritePull 具有相同的语义,除了设备应该不向主机发送数据。 当主机确定不需要该数据时,这个响应可以代替 GO_WritePull。 此响应将永远不会被部分写发送,因为 byte enables 始终需要被传输。
Similar to GO, but only indicates that the request is locally observed. There will be a later ExtCmp message when the transaction is fully observable in memory. Devices that do not implement the Fast_GO feature may ignore this message and wait for the ExtCMP.
类似于 GO,但只表示请求是本地观察的。 当事务在内存中完全可观察时,会有一个稍后的 ExtCmp 消息。 设备不实现 Fast_GO 功能可能会忽略此消息并等待 ExtCMP。
Similar to GO_WritePull, but only indicates that the request is locally observed. There will be a later ExtCmp message when the transaction is fully observable in memory. Devices that do not implement the Fast_GO feature may ignore the GO message and wait for the ExtCMP. Data must always be sent for the WritePull though. No cache state is transferred to the device.
与 GO_WritePull 类似,但只表示请求是本地观察的。 当事务在内存中完全可观察时,将是稍后的 ExtCmp 消息。未实现 Fast_GO 功能的设备可能会忽略 GO 消息并等待 ExtCMP。 但是,必须始终为 WritePull 发送数据。 无缓存状态传输到设备。
Similar to GO_WritePull, but indicates that there was an error with the transaction that should be handled properly in the device. Data must be sent to the Host for the WritePull, and the Host will drop the data. No cache state is transferred to the device (assumed Error). An ExtCmp is still sent if it is expected by the originating request.
与 GO_WritePull 类似,但表示事务发生错误应在设备中妥善处理。由于 WritePull,数据必须发送到主机,Host 会丢弃数据。 没有缓存状态传输到设备(假设错误)。 如果原始请求期望 ExtCmp,它仍然会被发送。
These are snoop requests from the Host for lines that are intended to be cached in either Shared or Exclusive state at the requester (the Exclusive state can be cached at the requester only if all devices respond with RspI). This type of snoop is typically triggered by data read requests. A device that receives this snoop must either invalidate or downgrade all cachelines to Shared state. If the device holds dirty data it must return it to the Host.
缓存状态降级为共享状态,但必须返回任何修改的数据
这些是来自主机的对要缓存的行的 snoop 请求, 这些缓存行打算在请求者是 Shared 或 Exclusive 状态(Exclusive 状态可以缓存在仅当所有设备都以 RspI 响应时的请求者)。 这种类型的 snoop 通常是由数据读取请求触发。 接收此侦听的设备必须要么使所有缓存行无效或降级为共享状态。 如果设备持有脏数据必须归还给Host。
These are snoop requests from the Host for lines that are intended to be granted ownership and Exclusive state at the requester. This type of snoop is typically triggered by write requests. A device that receives this snoop must invalidate all cachelines. If the device holds dirty data it must return it to the Host.
缓存行降级为无效,必须返回任何修改的数据
这些是来自主机的对打算授予所有权的缓存行的 snoop 请求,缓存行在请求者中是独占状态。 这种类型的窥探通常被写请求触发。 接收此监听的设备必须使所有高速缓存行无效。 如果设备持有脏数据,它必须将其返回给主机。
This snoop gets the current version of the line, but doesn’t require change of any cache state in the hierarchy. It is only sent on behalf of the RdCurr request. If the device holds data in Modified state it must return it to the Host. The cache state can remain unchanged in both the device and Host, and the Host should not update its caches.
缓存状态不变,必须返回任何修改的数据
这个 snoop 获取缓存行的当前版本,但不需要更改任何缓存层次结构中的状态。 它仅为了 RdCurr 请求发送。 如果设备保存处于修改状态的数据,它必须将其返回给主机。 缓存状态可以保持设备和主机都没有变化,主机不应该更新它的缓存。
In general, this is the response that a device provides to a snoop when the line was not found in any caches. If the device returns RspIHitI for a snoop, the Host can assume the line has been cleared from that device.
通常,当任何 cache 都没有找到这一缓存行时,设备就会提供给 snoop 这个回应。 如果设备返回 RspIHitI,主机可以假设缓存行已从该设备清除。
In general, this is the response that a device provides to a snoop when the line was hit in the cache and no state change occurred. If the device returns an RspVHitV for a snoop, the Host can assume a copy of the line is present in one or more places in that device.
通常,当缓存行命中以及没有状态改变,设备就会提供 snoop 这个回应。 如果设备为一个 snoop 返回一个 RspVHitV ,主机可以假设该行的副本存在于设备的一个或多个位置。
In general, this is the response that a device provides to a snoop when the line was hit in a clean state in at least one cache and is now invalid. If the device returns an RspIHitSE for a snoop, the Host can assume the line has been cleared from that device.
通常,当缓存行至少在一个 Cache 中处于 clean 状态被命中,现在是无效状态,设备就会提供给 snoop 这个回应。 如果设备返回一个RspIHitSE ,主机可以假设缓存行已从该设备清除。
In general, this is the response that a device provides to a snoop when the line was hit in a clean state in at least one cache and is now downgraded to shared state. If the device returns an RspSHitSE for a snoop, the Host should assume the line is still in the device.
通常,当缓存行至少在一个 Cache 中处于 clean 状态被命中,现在已降级为共享状态,设备就会提供给 snoop 这个回应。 如果设备返回一个 RspSHitSE,主机应假定该线路仍在设备中。
This response indicates to the Host that the line being snooped is now in S state in the device, after having hit the line in Modified state. The device may choose to downgrade the line to Invalid. This response also indicates to the Host snoop tracking logic that 64 bytes of data will be transferred on the D2H CXL.cache Data Channel to the Host data buffer indicated in the original snoop’s destination (UQID).
该响应向主机表明,在命中 M 状态的缓存行之后,正在侦听的缓存行在设备中正处于 S 状态。设备可以选择降级缓存行到无效。 此响应还向主机侦听跟踪逻辑表明 64字节数据将在 D2H CXL.cache 数据通道上传输到主机数据原始窥探目标 (UQID) 中指示的缓冲区。
This response indicates to the Host that the line being snooped is now in I state in the device, after having hit the line in Modified state. The Host may now assume the device contains no more cached copies of this line. This response also indicates to the Host snoop tracking logic that 64 bytes of data will be transferred on the D2H CXL.cache Data Channel to the Host data buffer indicated in the original snoop’s destination (UQID).
这个响应向主机表明, 在命中 M 状态的缓存行之后,被监听的缓存行现在在设备中是 I 状态。 主机可以假设设备不再包含此行的缓存副本。 这个回应也向主机侦听跟踪逻辑指示将传输 64 字节的数据D2H CXL.cache 数据通道到原始数据中指示的主机数据缓冲区snoop 的目的地 (UQID)。
This response indicates that the device is returning the current data to the Host and leaving the state unchanged. The Host must only forward the data to the requestor since there is no state information.
此响应表明设备正在向主机返回当前数据,并且保持状态不变。 主机只能将数据转发给请求者,因为没有状态信息。
Device Request :