Trait EthernetAdapterDatapathClient

Source
pub trait EthernetAdapterDatapathClient {
    // Required methods
    fn transmit_frame_done(
        &self,
        err: Result<(), ErrorCode>,
        frame_buffer: &'static mut [u8],
        len: u16,
        transmission_identifier: usize,
        timestamp: Option<u64>,
    );
    fn received_frame(&self, frame: &[u8], timestamp: Option<u64>);
}
Expand description

Ethernet adapter datapath client HIL

Required Methods§

Source

fn transmit_frame_done( &self, err: Result<(), ErrorCode>, frame_buffer: &'static mut [u8], len: u16, transmission_identifier: usize, timestamp: Option<u64>, )

An Ethernet frame was transmitted, or an error occurred during transmission.

Arguments:

  1. err: Ok(()) if no error occurred, Err(e) otherwise.

    Possible error codes:

    • ErrorCode::FAIL: an internal error occurred. The frame may or may not have been sent, and the Ethernet MAC may or may not be able to send further frames.

    • ErrorCode::BUSY: the Ethernet MAC is current busy processing another operation and could not enqueue this frame. A client may try again later.

    • ErrorCode::OFF: the Ethernet MAC is not enabled or initialized and cannot send this frame.

    • ErrorCode::NODEVICE: the Ethernet MAC does not have an active link and cannot send this frame.

  2. frame_buffer: the buffer initially supplied to transmit. Ethernet MACs will retain the sent frame data (from the start of this buffer, up to len) in the buffer for inspection by the client.

  3. len: the length of the raw frame that was transmitted, including the Ethernet header and excluding the FCS trailer. This value must be identical to the one supplied in EthernetAdapterDatapath::transmit_frame.

    This value imposes a maximum frame size of u16::MAX bytes. While Ethernet II frames do not contain an explicit length parameter (instead using the 16-bit length parameter reserved in IEEE 802.3 as an Ethertype parameter), the largest MTUs for Ethernet frames (including various Jumbo-frame options) are all below 65535 bytes and hence fit into a 16-bit integer value.

  4. transmission_identifier: an opaque identifier of this transmission operation. This value will be identical to the one supplied in the call to EthernetAdapterDatapath::transmit_frame.

  5. timestamp: optional timestamp of the transmission time of this frame, if frame timestamping is enabled (such as for IEEE 1588 PTP). The value of this field is opaque, users of this interface must refer to the EthernetAdapterDatapath MAC implementation to interpret this value and convert it to a proper timestamp.

    Because the transmit timestamp of a packet is ultimately tied to a particular packet, this value is transported alongside the datapath and not in another, independent callback.

Source

fn received_frame(&self, frame: &[u8], timestamp: Option<u64>)

An Ethernet frame was received.

Arguments:

  1. frame: a buffer containing the frame data, including the Ethernet header and excluding the FCS trailer.

  2. timestamp: optional timestamp of the reception time of this frame, if frame timestamping is enabled (such as for IEEE 1588 PTP). The value of this field is opaque, users of this interface must refer to the EthernetAdapterDatapath MAC implementation to interpret this value and convert it to a proper timestamp.

    Because the receive timestamp of a packet is ultimately tied to a particular packet, this value is transported alongside the datapath and not in another, independent callback.

Implementors§