Skip to main content

FlitDW0

Struct FlitDW0 

Source
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: FlitTlpType

Decoded TLP type.

§tc: u8

Traffic Class (bits [2:0] of byte 1).

§ohc: u8

OHC 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: u8

Transaction Steering (bits [7:5] of byte 2).

§attr: u8

Attributes (bits [4:2] of byte 2).

§length: u16

Payload length in DW. A value of 0 encodes 1024 DW.

Implementations§

Source§

impl FlitDW0

Source

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.

Source

pub fn ohc_count(&self) -> u8

Number of OHC extension words present — popcount of FlitDW0::ohc.

Source

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

Source

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:

  • IoWrite requires OHC-A2 (bit 0 of the OHC bitmap must be set)
  • CfgWrite0 requires OHC-A3 (bit 0 of the OHC bitmap must be set)

Returns Err(TlpError::MissingMandatoryOhc) if the rule is violated.

Trait Implementations§

Source§

impl Clone for FlitDW0

Source§

fn clone(&self) -> FlitDW0

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FlitDW0

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for FlitDW0

Source§

fn eq(&self, other: &FlitDW0) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for FlitDW0

Source§

impl StructuralPartialEq for FlitDW0

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.