Skip to main content

TxDescriptor

Struct TxDescriptor 

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

TX DMA descriptor — enhanced 8-word layout (32 bytes).

The ESP32 GMAC requires the enhanced descriptor format when DMABUSMODE.ATDS = 1 (which is what the IDF / ph-esp32-mac driver runs with). Reserved fields below are written by the DMA but unused by the CPU; they exist purely so the descriptor stride is 32 bytes and the DMA does not stomp adjacent descriptors when chained.

Implementations§

Source§

impl TxDescriptor

Source

pub const SIZE: usize = 32

Descriptor size in bytes (enhanced 8-word layout).

Source

pub const fn new() -> Self

Create a new zeroed TX descriptor.

Source

pub fn setup_chained(&self, buffer: *const u8, next_desc: *const TxDescriptor)

Initialize descriptor for chained mode.

Sets the buffer pointer, next-descriptor pointer, and the SECOND_ADDR_CHAINED flag. The descriptor is left CPU-owned.

Source

pub fn is_owned(&self) -> bool

Check if DMA owns this descriptor.

Source

pub fn set_owned(&self)

Give ownership to DMA.

Source

pub fn clear_owned(&self)

Take ownership from DMA.

Source

pub fn prepare(&self, len: usize, first: bool, last: bool)

Prepare descriptor for transmission with segment flags.

Sets the buffer length and first/last segment flags. Does not set the OWN bit — call set_owned afterwards to submit to DMA.

CIC (Checksum Insertion Control) is always set to 0b11 (bits 23:22), which instructs the MAC to insert the IPv4 header checksum and the TCP/UDP/ICMP payload checksum including the pseudo-header. For non-IPv4 frames the MAC ignores the CIC field, so setting it unconditionally is safe.

Source

pub fn prepare_and_submit(&self, len: usize, first: bool, last: bool)

Prepare and submit to DMA in one operation.

Source

pub fn has_error(&self) -> bool

Check if transmission had errors (error summary bit).

Source

pub fn error_flags(&self) -> u32

Get all error flags from TDES0.

Source

pub fn buffer_addr(&self) -> u32

Get buffer address (TDES2).

Source

pub fn next_desc_addr(&self) -> u32

Get next descriptor address (TDES3, chained mode).

Source

pub fn reset(&self)

Reset descriptor to initial state, preserving the chain pointer.

Source

pub fn raw_tdes0(&self) -> u32

Raw TDES0 value (for debugging / tests).

Source

pub fn raw_tdes1(&self) -> u32

Raw TDES1 value (for debugging / tests).

Trait Implementations§

Source§

impl Default for TxDescriptor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Send for TxDescriptor

Source§

impl Sync for TxDescriptor

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.