Struct TlpPacket

Source
pub struct TlpPacket { /* private fields */ }
Expand description

TLP Packet structure is high level abstraction for entire TLP packet Contains Header and Data

§Examples

use rtlp_lib::TlpPacket;
use rtlp_lib::TlpFmt;
use rtlp_lib::TlpType;
use rtlp_lib::new_msg_req;
use rtlp_lib::new_conf_req;
use rtlp_lib::new_mem_req;
use rtlp_lib::new_cmpl_req;

// Bytes for full TLP Packet
//               <------- DW1 -------->  <------- DW2 -------->  <------- DW3 -------->  <------- DW4 -------->
let bytes = vec![0x00, 0x00, 0x20, 0x01, 0x04, 0x00, 0x00, 0x01, 0x20, 0x01, 0xFF, 0x00, 0xC2, 0x81, 0xFF, 0x10];
let packet = TlpPacket::new(bytes);

let header = packet.get_header();
// TLP Type tells us what is this packet
let tlp_type = header.get_tlp_type().unwrap();
let tlp_format = packet.get_tlp_format();
let requester_id;
match (tlp_type) {
     TlpType::MemReadReq |
     TlpType::MemReadLockReq |
     TlpType::MemWriteReq |
     TlpType::IOReadReq |
     TlpType::IOWriteReq |
     TlpType::FetchAddAtomicOpReq |
     TlpType::SwapAtomicOpReq |
     TlpType::CompareSwapAtomicOpReq => requester_id = new_mem_req(packet.get_data(), &tlp_format).req_id(),
     TlpType::ConfType0ReadReq |
     TlpType::ConfType0WriteReq |
     TlpType::ConfType1ReadReq |
     TlpType::ConfType1WriteReq => requester_id = new_conf_req(packet.get_data(), &tlp_format).req_id(),
     TlpType::MsgReq |
     TlpType::MsgReqData => requester_id = new_msg_req(packet.get_data(), &tlp_format).req_id(),
     TlpType::Cpl |
     TlpType::CplData |
     TlpType::CplLocked |
     TlpType::CplDataLocked => requester_id = new_cmpl_req(packet.get_data(), &tlp_format).req_id(),
     TlpType::LocalTlpPrefix |
     TlpType::EndToEndTlpPrefix => println!("I need to implement TLP Type: {:?}", tlp_type),
}

Implementations§

Source§

impl TlpPacket

Source

pub fn new(bytes: Vec<u8>) -> TlpPacket

Source

pub fn get_header(&self) -> &TlpPacketHeader

Source

pub fn get_data(&self) -> Vec<u8>

Source

pub fn get_tlp_type(&self) -> TlpType

Source

pub fn get_tlp_format(&self) -> TlpFmt

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> 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, 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.