![]() |
RA Flexible Software Package Documentation
Release v6.6.0
|
|
Functions | |
| fsp_err_t | R_RMAC_Open (ether_ctrl_t *const p_ctrl, ether_cfg_t const *const p_cfg) |
| After RMAC, Switch and PHY-LSI are reset in software, an auto negotiation of PHY-LSI is begun. Afterwards, the link signal change interrupt is permitted. Implements ether_api_t::open. More... | |
| fsp_err_t | R_RMAC_Close (ether_ctrl_t *const p_ctrl) |
| Disables interrupts. Removes power and releases hardware lock. Implements ether_api_t::close. More... | |
| fsp_err_t | R_RMAC_BufferRelease (ether_ctrl_t *const p_ctrl) |
| Move to the next buffer in the receive buffer list. Implements ether_api_t::bufferRelease. More... | |
| fsp_err_t | R_RMAC_RxBufferUpdate (ether_ctrl_t *const p_ctrl, void *const p_buffer) |
| Change the buffer pointer of the current rx buffer descriptor. Implements ether_api_t::rxBufferUpdate. More... | |
| fsp_err_t | R_RMAC_LinkProcess (ether_ctrl_t *const p_ctrl) |
| The Link up processing, the Link down processing, and the magic packet detection processing are executed. Implements ether_api_t::linkProcess. More... | |
| fsp_err_t | R_RMAC_WakeOnLANEnable (ether_ctrl_t *const p_ctrl) |
| The setting of RMAC is changed from normal sending and receiving mode to magic packet detection mode. Implements ether_api_t::wakeOnLANEnable. More... | |
| fsp_err_t | R_RMAC_Read (ether_ctrl_t *const p_ctrl, void *const p_buffer, uint32_t *const length_bytes) |
| Receive Ethernet frame. Receives data to the location specified by the pointer to the receive buffer. In zero copy mode, the address of the receive buffer is returned. In non zero copy mode, the received data in the internal buffer is copied to the pointer passed by the argument. Implements ether_api_t::read. More... | |
| fsp_err_t | R_RMAC_Write (ether_ctrl_t *const p_ctrl, void *const p_buffer, uint32_t const frame_length) |
| Transmit Ethernet frame. Transmits data from the location specified by the pointer to the transmit buffer, with the data size equal to the specified frame length. In the non zero copy mode, transmits data after being copied to the internal buffer. Implements ether_api_t::write. More... | |
| fsp_err_t | R_RMAC_TxStatusGet (ether_ctrl_t *const p_ctrl, void *const p_buffer_address) |
| fsp_err_t | R_RMAC_CallbackSet (ether_ctrl_t *const p_api_ctrl, void(*p_callback)(ether_callback_args_t *), void *const p_context, ether_callback_args_t *const p_callback_memory) |
| fsp_err_t | R_RMAC_SetWriteConfig (ether_ctrl_t *const p_ctrl, rmac_write_cfg_t *const p_write_cfg) |
| Set configuration for tx frame. This API must call before ether_api_t::write. More... | |
| fsp_err_t | R_RMAC_GetTxTimestamp (ether_ctrl_t *const p_ctrl, rmac_timestamp_t *const p_timestamp) |
| Get timestamp of transmitted frame. This API must call after ether_api_t::write. More... | |
| fsp_err_t | R_RMAC_GetRxTimestamp (ether_ctrl_t *const p_ctrl, rmac_timestamp_t *const p_timestamp) |
| Get timestamp of received frame. This API must call before ether_api_t::read. More... | |
Driver for the Ethernet peripheral on RA MCUs. This module implements the Ethernet Interface.
This module transmits and receives Ethernet (IEEE 802.3) frames. This module provides single MAC layer interface.
The following figure shows which IPs are used by the r_rmac module.
The RMAC module supports the following features:
| Device Group | Devices |
|---|---|
| RA8 | RA8D2, RA8M2, RA8P1, RA8T2 |
| Configuration | Options | Default | Description |
|---|---|---|---|
| Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
| Read Buffer Size Checking |
| Disabled | If selected code for buffer size checking is included in the build. |
| Configuration | Options | Default | Description |
|---|---|---|---|
| General | |||
| Name | Name must be a valid C symbol | g_ether0 | Module name. |
| Channel | Must be an integer greater than or equal to 0. | 0 | Write the ether channel number. |
| Zero-copy Mode |
| Disable | Enable or disable zero-copy mode. |
| Flow control functionality |
| Disable | Enable or disable flow control. |
| MAC address | Must be a valid MAC address | 00:11:22:33:44:55 | MAC address of this channel. |
| Filters | |||
| Multicast Mode |
| Enable | Enable or disable multicast frame reception. |
| Promiscuous Mode |
| Disable | Enable this option to receive packets addressed to other NICs. |
| Broadcast filter | Must be a valid non-negative integer with maximum configurable value of 65535. | 0 | Limit of the number of broadcast frames received continuously |
| Buffers | |||
| Padding size | Disable | Disable | The padding size that is automatically inserted into the received packets |
| Padding offset | Must be less than 64 bytes. | 0 | The offset into a receive buffer to insert padding bytes. |
| TX queue length | Value must be an integer | 3 | Number of buffers per TX queue. |
| RX queue length | Value must be an integer | 3 | Number of buffers per RX queue. |
| TX queue num | Value must be an integer | 2 | TX queue num |
| RX queue num | Value must be an integer | 2 | RX queue num |
| Number of TX buffer | Value must be an integer | 12 | Number of transmit buffers |
| Number of RX buffer | Value must be an integer | 12 | Number of receive buffers |
| Buffer size | Must be at least 1514 which is the maximum Ethernet frame size. | 1514 | Size of Ethernet buffer |
| Allocate RX buffer |
| Enable | Allocates the RX buffer when generating the configuration structure |
| Number of node num | Value must be an integer | 24 | Number of receive buffers |
| Interrupts | |||
| Magic packet interrupt priority | MCU Specific Options | Select the magic packet detection interrupt priority. | |
| Callback | Name must be a valid C symbol | NULL | Callback provided when an ISR occurs |
| Timestamp | |||
| TS queue length | Value must be an integer | 8 | Timestamp queue length. |
| Forwarding | |||
| Transmission descriptor format |
| Transmission direct descriptor | The transmission direct descriptor could be used, for example, for non-routable protocol forwarding (network control) or for CPU-CPU communication and the transmission ethernet descriptor could be used for all normal ethernet transmissions. |
| Port based forwarding for reception |
| Disabled | Port based forwarding function forwards all frames from a port to other ones when receiving. |
| Link | |||
| Link monitored ports | MCU Specific Options | Select ports to be monitored for link up detection. | |
| Link Detection |
| Default port (same as Channel) | Condition for detecting link up status of monitored ports. |
The first R_RMAC_Open function call sets GWDI interrupts. The user could provide callback function which would be invoked when GWDI interrupt handler has been completed. The callback arguments will contain information about a channel number, the event code and a pointer to the user defined context.
The user could provide callback function which would be invoked when either a magic packet or a link signal change is detected. When the callback function is called, a variable in which the channel number for which the detection occurred and a constant shown in Table 2.4 are stored is passed as an argument. If the value of this argument is to be used outside the callback function, its value should be copied into, for example, a global variable.
The ESWM peripheral uses ICLK, PCLKA, ESWCLK and ESWPHYCLK as clocks. These clocks must be set to frequencies within the ranges shown in the following table.
| PHY speed [Mbps] | ICLK [MHz] | PCLKA [MHz] | ESWCLK [MHz] | ESWPHYCLK [MHz] |
|---|---|---|---|---|
| 10/100 | 50 to 250 | up to 125 | 50 to 250 | Not required |
| 1000 | 150 to 250 | up to 125 | 150 to 250 | 500 |
To use the RMAC module, input/output signals of the peripheral function have to be allocated to pins with the multi-function pin controller (MPC). Please perform the pin setting before calling the R_RMAC_Open function.
The RMAC module supports the Ethernet II/IEEE 802.3 frame format.
The preamble and SFD signal the start of an Ethernet frame. The FCS contains the CRC of the Ethernet frame and is calculated on the transmitting side. When data is received the CRC value of the frame is calculated in hardware, and the Ethernet frame is discarded if the values do not match. When the hardware determines that the data is normal, the valid range of receive data is: (transmission destination address) + (transmission source address) + (length/type) + (data).
The transmission destination address is specified as 01:80:C2:00:00:01 (a multicast address reserved for PAUSE frames). At the start of the payload the length/type is specified as 0x8808 and the operation code as 0x0001. The pause duration in the payload is specified by the value of the automatic PAUSE (AP) bits in the automatic PAUSE frame setting register (APR), or the manual PAUSE time setting (MP) bits in the manual PAUSE frame setting register (MPR).
In a Magic Packet, the value FF:FF:FF:FF:FF:FF followed by the transmission destination address repeated 16 times is inserted somewhere in the Ethernet frame data.
Transparent Bridge is a Layer 2 bridging method that forwards, learns, and filters frames based on MAC addresses.
The r_rmac driver allows a single r_rmac instance to manage multiple ports, enabling multi-port transmission and reception operations similar to Transparent Bridge.
For an implementation example, refer to Transparent Bridge Example
Configure the following settings in the rmac stack.
| Property | Value | Description |
|---|---|---|
| Forwarding -> Transmission descriptor format Transmission ethernet descriptor | Transmission ethernet descriptor | Configures transmission to follow forwarding rules. |
| Forwarding -> Port-based forwarding for reception Enabled | Enabled | Enables reception on multiple ports. |
| Link -> Link monitored ports | All ports used for the transparent bridge | Specifies the ports to monitor for link detection. |
| Link -> Link Detection Any monitored port | Any monitored port | Selects the port used for link monitoring. |
Use the ConfigureTable API to initialize the forwarding table as shown in the table below.
The array port_cfg_list[] must be configured according to the number of ports.
| Member | Value | Description |
|---|---|---|
| unsecure_entry_maximum_num | At least 1 | The number of forwarding rule entries. |
| port_cfg_list[].mac_table_enable | true | Enables MAC address-based forwarding for each port. |
| port_cfg_list[].mac_address_search | LAYER3_SWITCH_MAC_ADDRESS_SEARCH_DESTINATION | Uses the destination MAC address in forwarding rules. |
| port_cfg_list[].mac_hardware_learning_enable | true | Enables automatic learning of MAC addresses from received frames. |
To allow the CPU to receive frames from a specific MAC address, add a forwarding rule with the following configuration using the AddTableEntry API.
| Member | Value | Description |
|---|---|---|
| target_frame.entry_type | LAYER3_SWITCH_TABLE_ENTRY_TYPE_MAC | Performs forwarding based on a MAC address. |
| target_frame.p_destination_mac_address | MAC address set in rmac | Destination MAC address used to forward frames to the CPU. |
| entry_cfg.entry_enable | true | Must be enabled to register the entry. |
| entry_cfg.destination_ports | (1 << BSP_FEATURE_ESWM_GWCA_PORT) | Specifies the CPU as the forwarding destination. |
| entry_cfg.source_ports | All ports used for the transparent bridge. | Specifies the ports from which received frames are forwarded. |
| entry_cfg.destination_queue_index | rmac .p_rx_queue_list[running_queue_index].index | Synchronizes with the receive queue managed by the r_rmac driver.(*1) |
(*1)Because the receive queue used by the rmac driver changes dynamically, the forwarding rule settings must be updated accordingly.
Forwarding rules can be updated by calling the AddTableEntry API again in a callback of r_rmac or a higher-level module when an RX event occurs.
This is a basic example of minimal use of the ETHER in an application.
This is a example of getting transmission and reception timestamps.
This is a example of Transparent Bridge.
| fsp_err_t R_RMAC_Open | ( | ether_ctrl_t *const | p_ctrl, |
| ether_cfg_t const *const | p_cfg | ||
| ) |
After RMAC, Switch and PHY-LSI are reset in software, an auto negotiation of PHY-LSI is begun. Afterwards, the link signal change interrupt is permitted. Implements ether_api_t::open.
Initializes the ether module and applies configurations. Implements ether_api_t::open.
| FSP_SUCCESS | Channel opened successfully. |
| FSP_ERR_ASSERTION | Pointer to ETHER control block or configuration structure is NULL. |
| FSP_ERR_ALREADY_OPEN | Control block has already been opened or channel is being used by another instance. Call close() then open() to reconfigure. |
| FSP_ERR_ETHER_ERROR_PHY_COMMUNICATION | Initialization of PHY-LSI failed. |
| FSP_ERR_INVALID_CHANNEL | Invalid channel number is given. |
| FSP_ERR_INVALID_POINTER | Pointer to extend config structure or MAC address is NULL. |
| FSP_ERR_INVALID_ARGUMENT | Interrupt is not enabled. |
| FSP_ERR_ETHER_PHY_ERROR_LINK | Initialization of PHY-LSI failed. |
| fsp_err_t R_RMAC_Close | ( | ether_ctrl_t *const | p_ctrl | ) |
Disables interrupts. Removes power and releases hardware lock. Implements ether_api_t::close.
| FSP_SUCCESS | Channel successfully closed. |
| FSP_ERR_ASSERTION | Pointer to ETHER control block is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened |
| fsp_err_t R_RMAC_BufferRelease | ( | ether_ctrl_t *const | p_ctrl | ) |
Move to the next buffer in the receive buffer list. Implements ether_api_t::bufferRelease.
| FSP_SUCCESS | Processing completed successfully. |
| FSP_ERR_ASSERTION | Pointer to ETHER control block or internal buffers is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened |
| FSP_ERR_ETHER_ERROR_LINK | Auto-negotiation is not completed, and reception is not enabled. |
| FSP_ERR_BUFFER_EMPTY | There is no available internal RX buffer. |
| fsp_err_t R_RMAC_RxBufferUpdate | ( | ether_ctrl_t *const | p_ctrl, |
| void *const | p_buffer | ||
| ) |
Change the buffer pointer of the current rx buffer descriptor. Implements ether_api_t::rxBufferUpdate.
| FSP_SUCCESS | Processing completed successfully. |
| FSP_ERR_ASSERTION | A pointer argument is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |
| FSP_ERR_INVALID_POINTER | The pointer of buffer is NULL or not aligned on a 32-bit boundary. |
| FSP_ERR_INVALID_MODE | Driver is configured to non zero copy mode. |
| FSP_ERR_BUFFER_EMPTY | There is no available internal RX buffer. |
| fsp_err_t R_RMAC_LinkProcess | ( | ether_ctrl_t *const | p_ctrl | ) |
The Link up processing, the Link down processing, and the magic packet detection processing are executed. Implements ether_api_t::linkProcess.
| FSP_SUCCESS | Link is up. |
| FSP_ERR_ASSERTION | Pointer to ETHER control block is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |
| FSP_ERR_ETHER_ERROR_LINK | Link is down. |
| FSP_ERR_ETHER_ERROR_PHY_COMMUNICATION | When reopening the PHY interface initialization of the PHY-LSI failed. |
| FSP_ERR_ALREADY_OPEN | When reopening the PHY interface it was already opened. |
| FSP_ERR_INVALID_CHANNEL | When reopening the PHY interface an invalid channel was passed. |
| FSP_ERR_INVALID_POINTER | When reopening the PHY interface the MAC address pointer was NULL. |
| FSP_ERR_INVALID_ARGUMENT | When reopening the PHY interface the interrupt was not enabled. |
| FSP_ERR_ETHER_PHY_ERROR_LINK | Initialization of the PHY-LSI failed. |
| fsp_err_t R_RMAC_WakeOnLANEnable | ( | ether_ctrl_t *const | p_ctrl | ) |
The setting of RMAC is changed from normal sending and receiving mode to magic packet detection mode. Implements ether_api_t::wakeOnLANEnable.
| FSP_SUCCESS | Processing completed successfully. |
| FSP_ERR_ASSERTION | Pointer to ETHER control block is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |
| FSP_ERR_ETHER_ERROR_LINK | Auto-negotiation is not completed, and reception is not enabled. |
| FSP_ERR_ETHER_PHY_ERROR_LINK | Initialization of PHY-LSI failed. |
| fsp_err_t R_RMAC_Read | ( | ether_ctrl_t *const | p_ctrl, |
| void *const | p_buffer, | ||
| uint32_t *const | length_bytes | ||
| ) |
Receive Ethernet frame. Receives data to the location specified by the pointer to the receive buffer. In zero copy mode, the address of the receive buffer is returned. In non zero copy mode, the received data in the internal buffer is copied to the pointer passed by the argument. Implements ether_api_t::read.
| FSP_SUCCESS | Processing completed successfully. |
| FSP_ERR_ASSERTION | Pointer to ETHER control block is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |
| FSP_ERR_ETHER_ERROR_NO_DATA | There is no data in receive buffer. |
| FSP_ERR_ETHER_ERROR_LINK | Auto-negotiation is not completed, and reception is not enabled. |
| FSP_ERR_ETHER_ERROR_FILTERING | Multicast Frame filter is enable, and Multicast Address Frame is received. |
| FSP_ERR_INVALID_POINTER | Value of the pointer is NULL. |
| FSP_ERR_BUFFER_EMPTY | There is no available internal RX buffer. |
| FSP_ERR_INVALID_SIZE | The buffer size is smaller than ether_cfg_t::ether_buffer_size. |
| fsp_err_t R_RMAC_Write | ( | ether_ctrl_t *const | p_ctrl, |
| void *const | p_buffer, | ||
| uint32_t const | frame_length | ||
| ) |
Transmit Ethernet frame. Transmits data from the location specified by the pointer to the transmit buffer, with the data size equal to the specified frame length. In the non zero copy mode, transmits data after being copied to the internal buffer. Implements ether_api_t::write.
| FSP_SUCCESS | Processing completed successfully. |
| FSP_ERR_ASSERTION | Pointer to ETHER control block is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |
| FSP_ERR_ETHER_ERROR_LINK | Auto-negotiation is not completed, and reception is not enabled. |
| FSP_ERR_ETHER_ERROR_TRANSMIT_BUFFER_FULL | Transmit buffer is not empty. |
| FSP_ERR_INVALID_POINTER | Value of the pointer is NULL. |
| FSP_ERR_INVALID_ARGUMENT | Value of the send frame size is out of range. |
| FSP_ERR_BUFFER_EMPTY | There is no available internal TX buffer. |
| fsp_err_t R_RMAC_TxStatusGet | ( | ether_ctrl_t *const | p_ctrl, |
| void *const | p_buffer_address | ||
| ) |
Provides status of Ethernet driver in the user provided pointer. Implements ether_api_t::txStatusGet.
| FSP_SUCCESS | Transmit buffer address is stored in provided p_buffer_address. |
| FSP_ERR_ASSERTION | Pointer to ETHER control block is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |
| FSP_ERR_INVALID_POINTER | p_status is NULL. |
| FSP_ERR_NOT_FOUND | Transmit buffer address has been overwritten in transmit descriptor. |
| fsp_err_t R_RMAC_CallbackSet | ( | ether_ctrl_t *const | p_api_ctrl, |
| void(*)(ether_callback_args_t *) | p_callback, | ||
| void *const | p_context, | ||
| ether_callback_args_t *const | p_callback_memory | ||
| ) |
Updates the user callback with the option to provide memory for the callback argument structure. Implements ether_api_t::callbackSet.
| FSP_SUCCESS | Callback updated successfully. |
| FSP_ERR_ASSERTION | A required pointer is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |
| FSP_ERR_NO_CALLBACK_MEMORY | p_callback is non-secure and p_callback_memory is either secure or NULL. |
| fsp_err_t R_RMAC_SetWriteConfig | ( | ether_ctrl_t *const | p_ctrl, |
| rmac_write_cfg_t *const | p_write_cfg | ||
| ) |
Set configuration for tx frame. This API must call before ether_api_t::write.
| FSP_SUCCESS | Processing completed successfully. |
| FSP_ERR_ASSERTION | A pointer argument is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |
| fsp_err_t R_RMAC_GetTxTimestamp | ( | ether_ctrl_t *const | p_ctrl, |
| rmac_timestamp_t *const | p_timestamp | ||
| ) |
Get timestamp of transmitted frame. This API must call after ether_api_t::write.
| FSP_SUCCESS | Processing completed successfully. |
| FSP_ERR_ASSERTION | A pointer argument is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |
| fsp_err_t R_RMAC_GetRxTimestamp | ( | ether_ctrl_t *const | p_ctrl, |
| rmac_timestamp_t *const | p_timestamp | ||
| ) |
Get timestamp of received frame. This API must call before ether_api_t::read.
| FSP_SUCCESS | Processing completed successfully. |
| FSP_ERR_ASSERTION | A pointer argument is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |