Ethernet
Supported ICs[ RTL8721F ]
Overview
Ethernet is a wired networking technology that complies with the IEEE 802.3 standard. The Ameba series chips integrate an IEEE 802.3 compliant MAC (Media Access Control) controller and connect to an external PHY (Physical Layer) chip via the RMII (Reduced Media Independent Interface), enabling access to the physical network.
Ethernet Architecture
Features
The current Ethernet module supports the following key features:
Interface Standards & Speed
Supports RMII interface standard.
Supports 10/100 Mbps speeds with Full-Duplex/Half-Duplex modes.
Supports hardware Auto-negotiation for speed and duplex modes.
Protocols & Flow Control
Full-Duplex: Supports IEEE 802.3x Flow Control.
Half-Duplex: Supports CSMA/CD (Carrier Sense Multiple Access with Collision Detection) protocol.
Operating Modes & Clocking
Supports configuring the RMII interface in MAC Mode or PHY Mode.
Supports outputting a 25/50MHz reference clock source, saving the need for an external PHY crystal.
Management & Advanced Features
Supports configuring and managing PHY devices via the SMI (MDC/MDIO) interface.
Supports SMI Master (STA) mode to control external PHYs.
Supports EEE (Energy Efficient Ethernet) standard.
Quick Start
Communication Interfaces
Communication between the Ameba MAC and the external world relies on two core interfaces: RMII for data transmission and SMI (MDC/MDIO) for configuration management.
RMII and SMI Interfaces
RMII Data Interface Signals
The Ameba chip connects to the external PHY chip via the RMII interface. The standard signal definitions and directions are described below.
Signal Name |
Abbr. |
Direction |
Description |
|---|---|---|---|
TX Data 0 |
TXD0 |
MAC ➔ PHY |
Transmit Data Bit 0. Lower bit of data transmitted from MAC to PHY. |
TX Data 1 |
TXD1 |
MAC ➔ PHY |
Transmit Data Bit 1. Higher bit of data transmitted from MAC to PHY. |
TX Enable |
TX_EN |
MAC ➔ PHY |
Transmit Enable. When high, indicates that valid data is present on TXD. |
RX Data 0 |
RXD0 |
PHY ➔ MAC |
Receive Data Bit 0. Lower bit of data transmitted from PHY to MAC. |
RX Data 1 |
RXD1 |
PHY ➔ MAC |
Receive Data Bit 1. Higher bit of data transmitted from PHY to MAC. |
RX Error* |
RX_ERR |
PHY ➔ MAC |
Receive Error. High when the PHY detects an error (e.g., coding error) in the current frame. |
CRS_DV |
CRS_DV |
PHY ➔ MAC |
Carrier Sense/Data Valid. Indicates the PHY is receiving data and the medium is not idle. |
Ref Clock |
REF_CLK |
Bi-dir |
50MHz Reference Clock. This is the core synchronization clock for RMII operation. |
Note
The IEEE 802.3u standard defines RX_ERR (Receive Error). When the PHY detects an error in a received packet, it asserts this signal to notify the MAC. However, in practice, to save pins (GPIO), the MAC controllers of many embedded SoCs do not use the hardware RX_ERR pin in RMII mode. Data integrity relies entirely on the Ethernet frame’s built-in CRC/FCS checksum mechanism.
RMII reduces the data bus from 4 bits to 2 bits, requiring fewer pins. The trade-off is a higher clock frequency: 50MHz instead of 25MHz, to maintain 100Mbps throughput.
RMII signals use REF_CLK for synchronization, so both MAC and PHY must reference the same clock source. In practice, the following REF_CLK architectures exist:
MAC supplies REF_CLK to PHY: MAC’s REF_CLK is Output; PHY’s REF_CLK is Input.
PHY supplies REF_CLK to MAC: MAC’s REF_CLK is Input; PHY’s REF_CLK is Output.
External Source supplies REF_CLK to both: Both MAC and PHY REF_CLK are set to Input.
See the figure below:
REF_CLK Direction
The specific direction setting depends on the clock source scheme. See PHY Clock Source Selection for details.
SMI Management Interface Signals
The SMI (Serial Management Interface), commonly known as the MDIO Interface, is a simple two-wire serial interface used for exchanging management data between the Ethernet MAC sublayer and the Physical Layer (PHY), with a maximum speed of 2.5MHz.
The MDIO interface uses a Master-Slave architecture containing two types of entities:
STA (Station Management Entity)
Typically integrated into the MAC controller.
Acts as the bus Master, initiating all management frames (Read/Write) and driving the clock signal (MDC).
MMD (MDIO Manageable Device) / PHY
Integrated into the Ethernet PHY chip.
Acts as the bus Slave, responding to read/write requests from the STA.
The MDIO interface consists of two signal lines:
Signal Name |
Abbr. |
Direction |
Description |
|---|---|---|---|
MDC |
MDC |
MAC ➔ PHY |
Management Data Clock. Provides the clock reference for MDIO data transfer (typically < 2.5MHz). |
MDIO |
MDIO |
Bi-dir |
Management Data Input/Output. Used to transfer configuration commands and status data. Requires an external pull-up resistor (typically 1.5kΩ). |
Tip
Aperiodic Clock: MDC does not need to be a continuous periodic signal. The STA can stop the clock between frame transmissions (holding high or low), and the PHY must support this static operation.
Frequency Independent: As long as the maximum frequency limit (2.5 MHz) is not exceeded, the interface can operate at any lower rate, allowing for software bit-banging of MDIO timing.
Operating Modes
The connection method between the Ethernet MAC controller and external devices depends on its operating mode.
MAC Mode
This is the default operating mode where the CPU’s integrated MAC connects to an external PHY chip, as shown in MAC connecting to external PHY chip. In this mode, Ameba’s RMII interface follows standard MAC definitions to drive TX signals and manage the external PHY via MDC/MDIO.
MAC connecting to external PHY chip
PHY Mode
When two MAC-equipped chips (e.g., SoC-to-SoC or SoC-to-switch) sit on the same PCB, using two PHY chips for interconnection increases BOM cost, power consumption, and PCB area.
Traditional Connection: Requires additional components, as shown below.
Traditional Connection
PHY Mode (MAC-to-MAC Direct Connection): The Ameba MAC controller can be configured in
PHY Mode. The connection diagram is shown in MAC to MAC Direct Connection. This mode saves PHY chips and transformers, significantly optimizing hardware architecture.
MAC to MAC Direct Connection
A typical schematic for this connection is shown below:
MAC to MAC Schematic Reference
Warning
PHY Mode Precautions
Disable Auto-negotiation: Without a PHY chip, auto-negotiation cannot be used. Speed and Duplex must be forced manually.
Cross Connection: Ensure TX/RX lines are crossed (TX connects to peer RX).
Common Clock Source: A common clock source strategy is strongly recommended. Either one SoC outputs 50MHz to the other, or both share a single external crystal source to avoid FIFO overflow or CRC errors due to clock frequency deviation (PPM).
Pin Configuration
The ameba_intfcfg.c file predefines 4 groups of Ethernet pin configurations (ETHERNET_PAD). Group 0 is used by default.
Pin Function |
Group 0 (Default) |
Group 1 |
Group 2 |
Group 3 |
|---|---|---|---|---|
RMII Signals |
(Fixed Set) |
(Fixed Set) |
(Fixed Set) |
(Fixed Set) |
REF_CLK |
PB_9 |
PB_18 |
PB_30 |
PB_18 |
TXD0 |
PB_8 |
PB_13 |
PB_29 |
PC_4 |
TXD1 |
PB_7 |
PB_16 |
PB_28 |
PC_3 |
TXEN |
PB_6 |
PB_15 |
PB_27 |
PC_2 |
RXD0 |
PB_11 |
PB_21 |
PC_0 |
PC_7 |
RXD1 |
PB_10 |
PB_19 |
PB_31 |
PC_6 |
RXERR |
PB_4 |
PB_17 |
PB_25 |
PB_17 |
CRS |
PB_5 |
PB_14 |
PB_26 |
PC_5 |
Mgmt & Clock |
||||
MDC |
PB_12 |
PB_22 |
PC_1 |
PA_25 |
MDIO |
PB_3 |
PB_23 |
PB_24 |
PA_26 |
EXTCLK |
PA_12 |
PB_24 |
PA_12 |
PB_19 |
EXTCLK is used to provide a clock to an external PHY chip. See PHY Clock Source Selection.
Note
All pin assignments under the RMII interface are fixed. Users need to check the pinmux table and modify the
ETHERNET_Pin_Grpvariable (0x0 - 0x3) inameba_intfcfg.cto select an available pin group based on the chip package.MDC, MDIO, and EXTCLK can be flexibly configured to other pins. Modify based on the pinmux table.
PHY Clock Source Selection
Ameba Supplies Clock to PHY
Configure a pin as EXT_CLK_OUT (the EXTCLK pin in Pin Configuration) via pin multiplexing. Ameba outputs a 25 MHz or 50 MHz clock to the PHY, so the PHY does not need a separate XTAL. In Menuconfig, select 50M from Ameba or 25M from Ameba accordingly.
PHY Uses Independent XTAL
If the PHY’s system clock is provided by its own independent XTAL, EXT_CLK_OUT does not need to be configured. In Menuconfig, select PHY xtal.
Configuration Process
The Ameba SDK integrates the LwIP component, implementing the MAC layer driver (ameba_ethernet.c) and the PHY RTL8201FR driver (ameba_phy8201fr.c). When using a standard EVB, users can configure and use Ethernet as follows:
Menuconfig: Enable related components via
menuconfigbefore compiling.Go to
CONFIG ETHERNETand enable Ethernet.In
PHY SOURCE CLK, select the clock source based on the board hardware (see PHY Clock Source Selection).
PHY xtal: PHY clock is sourced from its own independent crystal. Select , save and exit.50M from Ameba/25M from Ameba: PHY clock is sourced from Ameba, output via theEXT_CLK_OUTpin (see Pin Configuration) at 50 MHz or 25 MHz. Go toPHY SOURCE CLK, select or , save and exit.
Pin and PHY Adaptation
If using a standard EVB, the SDK adapts to PHY RTL8201FR by default. Check the schematic and modify the
ETHERNET_Pin_Grpindex inameba_intfcfg.cto select theETHERNET_PAD[4][11]member used by the board.If using a custom board or other PHY chips:
Modify the
ETHERNET_Pin_Grpindex inameba_intfcfg.cbased on the actual pin combination.Add the PHY driver for the specific chip used. Refer to PHY Interface Adaptation.
Note
The default REF_CLK direction is MAC → PHY (Ameba outputs REF_CLK). If your board uses PHY → MAC direction, configure it accordingly in the initialization structure.
PHY Interface Adaptation
Software Architecture
Before adapting a PHY driver, it is essential to understand the Ethernet architectural layering. The Ameba Ethernet module integrates the Lightweight TCP/IP stack (LwIP) and MAC driver. The correspondence to OSI and TCP/IP models is shown below:
Ethernet Software Architecture
Layer functions:
Layer |
Component |
Description |
Core Files |
Note |
|---|---|---|---|---|
L5-7: App |
User App |
Implements user logic and high-level protocols (HTTP, MQTT). |
(User Defined) |
Socket/Netconn API |
L4: Transport |
TCP & UDP |
End-to-end communication; TCP for reliability, UDP for low latency. |
|
LwIP Core |
L3: Network |
IP & ARP |
Routing, logical addressing (IPv4/v6), address resolution. |
|
LwIP Core |
L2: Data Link |
LLC / Adapter |
Converts LwIP |
|
Porting Layer |
MAC Driver |
Manipulates MAC registers, manages DMA descriptors and interrupts. |
|
Platform Specific |
|
L1: Physical |
PHY Driver |
Configures external PHY transceiver, manages Auto-negotiation. |
|
Platform Specific |
HW Interface |
Physical bus between MAC and PHY. |
N/A |
RMII / MII |
Note
The L2 MAC driver and RMII operations are implemented in the SDK. RTL8201FR driver (L1) is provided.
Adaptation Steps
The Ameba SDK provides a flexible PHY abstraction layer, allowing users to adapt different Ethernet PHY chips by implementing the eth_phy_ops interface table and defining device instances.
Implement PHY Operations
Implement the key functions in struct eth_phy_ops based on the PHY datasheet.
Note
Standard PHY registers are defined in
ameba_phy.h.Custom registers can be defined in a user file (e.g.,
ameba_phy_custom.c).
Taking RTL8201FR as an example:
OPS Member |
Function |
Description |
Reason |
|---|---|---|---|
|
|
Init & ID Check Read PHY ID and match with |
Prevents matching wrong hardware; ensures PHY is powered and MDIO is working. |
|
|
Soft Reset Write BMCR reset bit and wait for stabilization. |
Ensures PHY is in a known state. |
|
|
Ref Clock Config Switch to Page 7 to set RMII clock direction (Input/Output). |
RMII requires a synchronized 50MHz clock. Wrong direction prevents link establishment. |
|
|
Link Config Configure Auto-Neg advertisement or force Speed/Duplex. |
Required to set 10M/100M or duplex modes. |
Define Bus Interface and PHY Instance
Define the MDIO bus read/write interface and create the eth_phy_dev instance, specifying the PHY address.
// 1. Define MDIO bus operations
// Use low-level read/write functions provided by SDK
const struct eth_mdio_ops eth_mdio_bus_default = {
.mdio_read = Ethernet_ReadPhyReg,
.mdio_write = Ethernet_WritePhyReg,
};
// 2. Define PHY device instance
struct eth_phy_dev eth_phy_dev_custom = {
.bus = ð_mdio_bus_default, // Bind bus interface
.addr = 0x01, // [Important] PHY Address must match schematic
.ops = &custom_phy_ops, // Bind operations implemented above
};
Register and Initialize
In the Ethernet initialization phase, call Ethernet_StructInit() passing the PHY instance.
void User_Ethernet_Init(void)
{
ETH_InitTypeDef eth_initstruct;
// Initialize using custom PHY device instance
// This mounts eth_phy_dev_custom to the MAC driver
Ethernet_StructInit(ð_initstruct, ð_phy_dev_custom);
// Call other Ethernet functions...
}
Functional Details
Auto-negotiation
Auto-negotiation allows devices on both ends of a link to automatically select common operating parameters:
Duplex Mode
Speed
Flow Control
Note
IEEE 802.3u makes auto-negotiation optional for 100Mbps Ethernet.
Detection Mechanism
Auto-negotiation uses pulses on the physical link:
NLP (Normal Link Pulse): Used for 10BASE-T link beat. Single 100ns pulse every 16ms ± 8ms.
FLP (Fast Link Pulse): Used for 100BASE-TX/1000BASE-T. Extends NLP into a “Burst”.
Structure: Burst every 16ms.
Encoding: 33 pulse positions (17 clock + 16 data).
Link Codeword: 16-bit word advertising speed/duplex capabilities.
Link Pulses and Codewords
Parallel Detection
Used when one side enables Auto-Neg and the other forces a fixed mode.
Principle: The Auto-Neg side detects FLP, NLP, and Idle streams.
NLP Detected: Determine peer is 10M.
4B/5B Idle Stream Detected: Determine peer is 100M.
Warning
Duplex Mismatch: Parallel detection cannot detect duplex mode. By standard, the Auto-Neg side must fallback to Half-Duplex.
Negotiation Scenarios
Link establishment depends on configuration:
Local Config |
Peer Config |
Result |
Explanation |
|---|---|---|---|
Auto-Neg |
Auto-Neg |
✅ Success |
Exchange capabilities, lock to highest common mode (e.g., 100M Full). |
Auto-Neg |
Fixed 10M/100M (Half) |
✅ Success |
Parallel detection sets local to Half-Duplex. Matches peer. |
Auto-Neg |
Fixed 10M/100M (Full) |
⚠️ Duplex Mismatch |
Link Up, but packet loss. Local falls back to Half-Duplex via parallel detection; peer is Full-Duplex. Causes collisions and CRC errors. |
Auto-Neg (Full Only) |
Auto-Neg (Half Only) |
❌ Fail |
No common capabilities. |
Fixed Mode A |
Fixed Mode B |
❌ Fail |
Mismatched speed or duplex prevents sync. |
If Auto-Neg is disabled, ensure parameters match exactly on both sides.
Note
Auto-Neg should be disabled for:
PHY Mode: Connecting to an external MAC requires fixed speed/duplex.
VLAN
VLANs (Virtual LANs) break the limitations of a flat broadcast domain:
Broadcast Storms: Limits broadcast packets to the VLAN.
Security: Provides logical isolation.
VLAN Application
VLAN Tagging adds a 4-byte tag to the frame to identify membership.
Frame Format
IEEE 802.1Q inserts a tag between the Source MAC and EtherType.
VLAN Frame Format
Fields:
Field |
Length |
Value |
Function |
Notes |
|---|---|---|---|---|
TPID |
2 Bytes |
Fixed |
Identifies the frame as an 802.1Q tagged frame. |
Devices that do not support 802.1Q typically drop frames with TPID |
PRI |
3 Bits |
0–7 (higher = higher priority) |
QoS priority. High-priority packets are forwarded first when congestion occurs. |
To set priority without a specific VLAN, set VID to |
CFI/DEI |
1 Bit |
|
Originally distinguished Ethernet / FDDI / Token Ring frames (CFI). Redefined as DEI (Drop Eligible Indicator) in IEEE 802.1Q-2011 to indicate drop priority. |
Ethernet always uses |
VID |
12 Bits |
0–4095
(1–4094 valid)
|
Identifies the VLAN the frame belongs to. |
Special values: |
QinQ (Double Tagging) uses an outer STAG (Service Tag) and inner CTAG (Customer Tag).
VLAN Frame Processing
Switch logic:
Ingress (Receive):
Untagged frame from Access Link -> Add PVID Tag -> Internal Switching.
Egress (Send):
Send to Access Link -> Strip Tag -> Send Untagged Frame.
Send to Trunk Link -> Keep Tag -> Send Tagged Frame.
VLAN Configuration
Ameba MAC supports hardware VLAN tag offload for egress insertion/removal and ingress stripping.
Note
Hardware limits:
Supports Double Tagging (STAG + CTAG). Triple Tag is not supported.
Egress: Single insertion/removal/remark per packet.
Ingress: Strips inner CTAG only; stripped tag info is stored in the RX descriptor.
Egress (TX) Configuration
Configure the target tag layer and the egress action:
Parameter |
Value |
Description |
|---|---|---|
|
|
Selects the tag layer for Insert/Remove/Remark. |
|
0x0001–0xFFFF |
STAG Protocol ID. Valid only when |
|
0–4094 |
Target VID used by hardware when the action is INSERT or REMARK_VID. |
|
See options below. |
Egress action. Determines how the MAC processes the VLAN tag before transmission. |
DefTxAction options:
Mode |
Function |
Typical Scenario |
|---|---|---|
Intact |
No modification (supports double-tag passthrough). |
Soft-Tagging: OS network stack handles tagging, hardware does not intervene; or Trunk Passthrough. |
Insert |
Insert a new tag into the packet. (Note: total tag count after insertion must not exceed the hardware limit, typically 2 layers.) |
Provider QinQ: add S-Tag outside user packet; or Port Default VLAN (PVID): hardware forces the default PVID. |
Remove |
Remove the specified tag from the packet. |
Access Port: strip tag to restore standard Ethernet frame; or QinQ Termination: strip outer S-Tag for the user side. |
Remark |
Preserve tag structure, replace VID only. |
VLAN Translation: hardware replaces VID directly for cross-domain communication. |
Configuration recommendations:
Standard internet access: use
INTACT; let the OS network stack handle tagging.Embedded gateway/router: if CPU load is high, use
REMOVE(LAN port) andINSERT(WAN port) to leverage hardware offload.
Ingress (RX) Configuration
RxStrip: Hardware stripping control.1: Enable stripping. Driver reads VLAN ID from the RX descriptor.0: Disable stripping. Received packet retains the full VLAN tag header.
Energy Efficient Ethernet (EEE)
EEE (Energy Efficient Ethernet, IEEE 802.3az) is a power management technology whose core mechanism is Low Power Idle (LPI). It allows network devices to enter a low-power state during idle intervals when the link is up but no data is being transmitted.
System Architecture
EEE requires coordination between the MAC layer (containing the LPI Client) and the PHY.
EEE Architecture
LPI Client (Policy Initiator)
Located in the MAC layer. Responsible for initiating LPI requests based on traffic load. The specific trigger implementation is vendor-defined.
PHY (Physical Layer)
Encodes RMII signals (e.g., 4B/5B or 8B/10B) and exchanges LPI state with the link partner over the physical medium.
Entering/Exiting LPI
The standard RMII interface removes the TX_ER pin present in MII, so LPI cannot be signaled using the standard IEEE 802.3az pin combination directly. Instead, LPI entry and exit are encoded via combinations of control signals (TX_EN / CRS_DV) and data bus (TXD[1:0] / RXD[1:0]). The timing is shown in LPI Signaling.
LPI Signaling
TX Path (MAC to PHY): MAC decides when the PHY enters or exits low-power mode.
Enter LPI: MAC drives
TX_EN=0,TXD=01. PHY detects this state and shuts down the analog TX circuit.Hold LPI: MAC maintains
TX_EN=0,TXD=01.Exit LPI: When MAC needs to transmit or a timer expires, MAC changes
TXD[1:0]from01to00(TX_ENstill 0). This signals a Wake Request. After the required wake-up time Twq, MAC assertsTX_ENand begins transmission.
RX Path (PHY to MAC): PHY monitors the remote link state and notifies MAC to enter or exit low-power mode.
Enter LPI: PHY detects an LPI signal from the remote end, pulls
CRS_DVlow, and drivesRXD[1:0]to01. MAC detectsCRS_DV=0,RXD=01and enters RX low-power mode.Hold LPI: PHY maintains
RXD[1:0]at01until the line state changes.Exit LPI: PHY detects an IDLE stream on the line and changes
RXD[1:0]from01back to00. MAC recovers the RX clock and decode logic, ready to receive the next frame.
When the RMII interface asserts the LPI signal, the PHY transitions through the following states:
LPI States
Sleep: Local PHY sends SLEEP codeword to notify the link partner.
Quiet:
General: PHY stops transmitting after sending SLEEP.
1000BASE-T: Both sides must exchange SLEEP before jointly entering Quiet.
Refresh: Periodic Refresh signals are sent during Quiet to maintain link parameters (e.g., equalizer coefficients, clock synchronization).
Wake: PHY sends Wake signal to notify the link partner to resume normal operation.
LPI Decision Makers
TX Path
Enter LPI: The MAC determines when to initiate an LPI request on the TX path (i.e., output
01encoding):HW Auto:
TX queue empty: Triggered immediately when the last packet is sent and no new packet arrives.
TX rate below threshold: Even if the queue is not empty, MAC may enter LPI and buffer packets to reduce frequent wake-up overhead.
Pause frame received: When a Flow Control Pause frame is received, MAC pauses transmission and may enter LPI to save power.
SW Force: Software forces MAC into LPI mode via register configuration, typically for debugging or special power management.
Exit LPI:
HW Auto wake: New packet enters TX queue, or high-priority queue has data — hardware immediately triggers the wake sequence.
SW Force wake: Software proactively exits LPI in anticipation of a data burst, to avoid hardware wake-up latency.
RX Path
RX LPI state is primarily controlled by the PHY; MAC operates passively. MAC manages internal RX circuit power by monitoring RMII signal changes.
Enter LPI: When MAC detects
CRS_DV=0&RXD=01, the internal RX clock domain logic stops, packet parsing halts, and MAC enters low-power state.Exit LPI: PHY detects IDLE or data on the line and drives
RXD[1:0]from01back to00.
Configuration Process
Prerequisites: Enable Auto-Neg, Full Duplex, PHY supports EEE.
Sleep/Wake Policy:
Sleep policy determines when the MAC initiates an LPI request. Select based on the application scenario:
Option |
Description |
Scenario |
|---|---|---|
|
Immediate (Default): Enter sleep as soon as the TX queue is empty. |
Most IoT scenarios. Lowest power, but frequent PHY state switching if traffic is bursty. |
|
Traffic Threshold: Enter sleep only when TX rate is below the configured threshold. |
Latency-sensitive scenarios. Avoids frequent sleep when packet inter-arrival time is short. |
|
Pause Frame: Enter sleep only while a Flow Control Pause frame has halted transmission. |
High-throughput scenarios. Sleep triggered by flow control. |
Wake policy determines when the MAC exits the low-power state:
Option |
Description |
Recommended Use |
|---|---|---|
|
Wake on Any Data (Default): Wake immediately when data is written to the TX buffer. |
Default. Safest and most general setting. |
|
Wake on High Priority Only: Normal data queues; only high-priority packets trigger wake-up. |
QoS scenarios with VLAN priority queuing. |
Traffic Threshold:
This configuration is valid only when the sleep policy is set to ETH_EEE_SLEEP_LOW_TRAFFIC.
It sets the TX traffic threshold to trigger EEE sleep via the TxTrafficThresh parameter (unit: Bytes). The device enters sleep mode when the transmitted traffic within the observation window falls below this threshold.
The calculation formula is as follows:
TxTrafficThresh = Round[(T_tx_rate × Rate) / 8]
T_tx_rate: The traffic observation time window (e.g., 10us).Rate: The current link speed (e.g., 100Mbps).
Example:
When T_tx_rate = 10us and the link speed is 100Mbps, the calculated threshold is 0x7D (125 Bytes). The default value is 0x3E.
Note
A larger threshold makes sleep easier to trigger; a smaller threshold makes sleep harder to trigger.
Test Modes
Loopback modes for debugging:
Binary |
Macro |
Mode |
Description |
|---|---|---|---|
|
|
Normal |
Normal operation. |
|
|
External (R2T) |
RX to TX. Forwards received RX packets directly to TX. Tests external physical connection. |
|
|
Internal (T2R) |
TX to RX. CPU sent data loops back to RX inside MAC. Does not pass to PHY. Tests driver/MAC logic. |
Loopback Test Modes
T2R Mode: Data is looped back directly within the MAC, bypassing the PHY. It is used to verify the internal logic of the MAC controller.
R2T Mode: Data transmitted to the PHY is looped back to the MAC internally at the PHY level (on the MII/RMII interface side). It is used to verify the physical connection between the MAC and the PHY (e.g., PCB traces, soldering).
Ethernet Descriptors
Descriptors are shared memory structures between software (driver) and hardware (DMA), enabling zero-copy transfers and CPU offload.
Descriptor Ring
Note
Memory Attribute: Descriptors should be in Non-cacheable SRAM (or DDR with MPU config) to avoid Cache Coherency issues.
Alignment: RX buffers must be 4-byte aligned.
Descriptor Format
Descriptor Format
OWN (Ownership Bit)
OWN = 1 (DMA): CPU has prepared data (TX) or buffer (RX). CPU must not touch.
OWN = 0 (CPU): DMA has completed operation. CPU can reclaim.
EOR (End of Ring)
EOR = 1: End of ring. DMA wraps around to base address.
Descriptor Configuration
Buffer Size: Calculated for Max Ethernet Frame + VLAN + CRC = 1522 Bytes. Aligned to cache line (32B) → 1536 Bytes.
Descriptor Count:
ETH_RxDescNum/ETH_TxDescNum. More descriptors handle burst traffic better but use more RAM.
Performance Data
Test conditions:
Storage: Code in PSRAM; descriptors in Non-Cache SRAM.
TCP: Receive window (TCP Window) = 23360 Bytes (16 × 1460 MSS).
UDP: TX delay = 0.
Buffer: Single packet buffer size = 1536 Bytes.
The table below shows UDP/TCP throughput at 100Mbps and 10Mbps in Full-Duplex and Half-Duplex modes:
Link Mode |
UDP TX |
UDP RX |
TCP TX |
TCP RX |
|---|---|---|---|---|
100Mbps Full-Duplex |
95.4 |
93.5 |
94.8 |
78.0 |
100Mbps Half-Duplex |
95.4 |
92.0 |
90.0 |
78.0 |
10Mbps Full-Duplex |
9.60 |
9.57 |
9.50 |
9.49 |
10Mbps Half-Duplex |
9.54 |
9.57 |
8.80 |
8.90 |
Note: Reference data only.