pub struct FlitDW0 {
pub tlp_type: FlitTlpType,
pub tc: u8,
pub ohc: u8,
pub ts: u8,
pub attr: u8,
pub length: u16,
}Expand description
Parsed representation of a flit-mode DW0 (first 4 bytes of a flit TLP).
Flit-mode DW0 layout:
Byte 0: Type[7:0] — flat 8-bit type code
Byte 1: TC[2:0] | OHC[4:0] — traffic class + OHC presence bitmap
Byte 2: TS[2:0] | Attr[2:0] | Length[9:8]
Byte 3: Length[7:0]Use FlitDW0::from_dw0 to parse from a byte slice.
Fields§
§tlp_type: FlitTlpTypeDecoded TLP type.
tc: u8Traffic Class (bits [2:0] of byte 1).
ohc: u8OHC presence bitmap (bits [4:0] of byte 1).
Each set bit indicates one Optional Header Content word appended
after the base header. Use FlitDW0::ohc_count for the DW count.
ts: u8Transaction Steering (bits [7:5] of byte 2).
attr: u8Attributes (bits [4:2] of byte 2).
length: u16Payload length in DW. A value of 0 encodes 1024 DW.
Implementations§
Source§impl FlitDW0
impl FlitDW0
Sourcepub fn from_dw0(b: &[u8]) -> Result<Self, TlpError>
pub fn from_dw0(b: &[u8]) -> Result<Self, TlpError>
Parse the flit-mode DW0 from the first 4 bytes of a byte slice.
Returns Err(TlpError::InvalidLength) if b.len() < 4.
Returns Err(TlpError::InvalidType) if the type code is unknown.
Sourcepub fn ohc_count(&self) -> u8
pub fn ohc_count(&self) -> u8
Number of OHC extension words present — popcount of FlitDW0::ohc.
Sourcepub fn total_bytes(&self) -> usize
pub fn total_bytes(&self) -> usize
Total TLP size in bytes:
(base_header_dw + ohc_count) × 4 + payload_bytes
Per PCIe spec a length value of 0 encodes 1024 DW (4096 bytes),
but only for types that actually carry a data payload (see FlitTlpType::has_data_payload).
Types that never carry payload (read requests, NOP, LocalTlpPrefix, MsgToRc)
always contribute zero payload bytes.
Source§impl FlitDW0
impl FlitDW0
Sourcepub fn validate_mandatory_ohc(&self) -> Result<(), TlpError>
pub fn validate_mandatory_ohc(&self) -> Result<(), TlpError>
Validate mandatory OHC rules for this TLP type.
Some flit-mode TLP types require an OHC word to be present:
IoWriterequires OHC-A2 (bit 0 of the OHC bitmap must be set)CfgWrite0requires OHC-A3 (bit 0 of the OHC bitmap must be set)
Returns Err(TlpError::MissingMandatoryOhc) if the rule is violated.