ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_rmac.h File Reference

Per-port Ethernet MAC (RMAC) driver – HUM Ch 33. More...

#include <stdint.h>
#include "ra8_err.h"
#include "ra8_rmac_regs.h"
Include dependency graph for ra8_rmac.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ra8_rmac_config_t
 Per-port RMAC configuration knobs. More...
 Resolved PHY link status snapshot. More...
struct  ra8_rmac_status_t
 Snapshot of an RMAC port's runtime state. More...
struct  ra8_rmac_stats_t
 Snapshot of every RMAC statistic counter. More...

Typedefs

typedef void(* ra8_rmac_event_fn_t) (void *ctx, ra8_rmac_port_t port, uint32_t err_msk, uint32_t mon0_msk, uint32_t mon1_msk, uint32_t mon2_msk)
 Per-port RMAC IRQ callback.

Enumerations

enum  ra8_rmac_mdc_clk_t : uint32_t {
  k_ra8_rmac_mdc_default_hz = 1000000UL ,
  k_ra8_rmac_mdc_min_hz = 100000UL ,
  k_ra8_rmac_mdc_psmcs_max = 127UL
}
 MPIC PHY-station-management clock-rate constants. More...
enum  ra8_rmac_phy_speed_t : uint8_t {
  k_ra8_rmac_phy_speed_unknown = 0U ,
  k_ra8_rmac_phy_speed_10_hd = 1U ,
  k_ra8_rmac_phy_speed_10_fd = 2U ,
  k_ra8_rmac_phy_speed_100_hd = 3U ,
  k_ra8_rmac_phy_speed_100_fd = 4U ,
  k_ra8_rmac_phy_speed_count = 5U
}
 Resolved PHY link speed/duplex. More...
enum  ra8_rmac_phy_advert_t : uint16_t {
  k_ra8_rmac_phy_advert_10_hd = 0x0020U ,
  k_ra8_rmac_phy_advert_10_fd = 0x0040U ,
  k_ra8_rmac_phy_advert_100_hd = 0x0080U ,
  k_ra8_rmac_phy_advert_100_fd = 0x0100U ,
  k_ra8_rmac_phy_advert_pause = 0x0400U
}
 802.3 Clause 22 ANAR (auto-negotiation advertisement) bits. More...

Functions

ra8_err_t ra8_rmac_init (ra8_rmac_port_t port, const ra8_rmac_config_t *cfg)
 Initialise an RMAC port (MSTP gate + reset regs + filter mode).
ra8_err_t ra8_rmac_deinit (ra8_rmac_port_t port)
 Tear down an RMAC port.
ra8_err_t ra8_rmac_enter_stop (ra8_rmac_port_t port)
 Enter low-power "stop" by disabling RX address filtering.
ra8_err_t ra8_rmac_exit_stop (ra8_rmac_port_t port)
 Exit low-power "stop" by reasserting the saved RX filter.
ra8_err_t ra8_rmac_set_mac_address (ra8_rmac_port_t port, const uint8_t mac[k_ra8_rmac_mac_byte_count])
 Program the reception MAC address (MRMAC0 / MRMAC1).
ra8_err_t ra8_rmac_set_rx_filter (ra8_rmac_port_t port, ra8_rmac_mrafc_t filter)
 Program the RX address filter mask (MRAFC).
ra8_err_t ra8_rmac_set_ptp_filter (ra8_rmac_port_t port, uint8_t index, uint8_t byte_offset, uint8_t value, bool tef0, bool tef1)
 Program a PTP-frame filter table entry (MPFCt, t = 0..15).
ra8_err_t ra8_rmac_set_frame_size (ra8_rmac_port_t port, bool is_pframe, uint16_t min_size, uint16_t max_size)
 Configure jumbo-frame minimum / maximum sizes.
ra8_err_t ra8_rmac_set_vlan_framing (ra8_rmac_port_t port, bool disable_pad, bool use_mcrc)
 Configure VLAN double-tagging behaviour via MTFFC.
ra8_err_t ra8_rmac_set_pause_frame (ra8_rmac_port_t port, ra8_rmac_pause_mode_t mode, uint16_t pause_time, uint8_t retry_time, uint8_t retry_level)
 Program a TX pause / PFC frame template.
ra8_err_t ra8_rmac_set_pfc_group (ra8_rmac_port_t port, ra8_rmac_pfc_group_t group, uint8_t pcp_mask)
 Configure a PFC (802.1Qbb) priority group bitmap.
ra8_err_t ra8_rmac_set_lpi (ra8_rmac_port_t port, bool enable)
 Enable / disable Energy Efficient Ethernet LPI request.
ra8_err_t ra8_rmac_set_magic_packet (ra8_rmac_port_t port, bool enable)
 Enable / disable magic-packet wake-on-LAN detection.
ra8_err_t ra8_rmac_set_loopback (ra8_rmac_port_t port, bool enable)
 Enable / disable internal MAC loopback.
ra8_err_t ra8_rmac_set_link (ra8_rmac_port_t port, ra8_rmac_pis_t iface, ra8_rmac_lsc_t speed, ra8_rmac_duplex_t duplex)
 Configure the link layer (interface, speed, duplex) atomically.
ra8_err_t ra8_rmac_mdio_c22_read (ra8_rmac_port_t port, uint8_t phy_addr, uint8_t reg_addr, uint16_t *out_value)
 Trigger an MDIO Clause-22 register read on the off-chip PHY.
ra8_err_t ra8_rmac_mdio_c22_write (ra8_rmac_port_t port, uint8_t phy_addr, uint8_t reg_addr, uint16_t value)
 Trigger an MDIO Clause-22 register write on the off-chip PHY.
ra8_err_t ra8_rmac_mdio_c45_read (ra8_rmac_port_t port, uint8_t phy_addr, uint8_t dev_addr, uint16_t reg_addr, uint16_t *out_value)
 Trigger an MDIO Clause-45 register read.
ra8_err_t ra8_rmac_mdio_c45_write (ra8_rmac_port_t port, uint8_t phy_addr, uint8_t dev_addr, uint16_t reg_addr, uint16_t value)
 Trigger an MDIO Clause-45 register write.
ra8_err_t ra8_rmac_get_status (ra8_rmac_port_t port, ra8_rmac_status_t *out)
 Read a port's status snapshot (MEIS + MMIS0..2 + MPIM + MAC).
ra8_err_t ra8_rmac_clear_status (ra8_rmac_port_t port, uint32_t err_mask, uint32_t mon0_mask, uint32_t mon1_mask, uint32_t mon2_mask)
 Clear bits in MEIS / MMIS0 / MMIS1 / MMIS2.
ra8_err_t ra8_rmac_read_stats (ra8_rmac_port_t port, ra8_rmac_stats_t *out)
 Read the full statistic counter snapshot (HUM Ch 33.4).
ra8_err_t ra8_rmac_attach_handler (ra8_rmac_port_t port, ra8_rmac_event_fn_t cb, void *ctx)
 Attach a per-port IRQ handler for RMAC events.
void ra8_rmac_dispatch (ra8_rmac_port_t port)
 Dispatch a pending RMAC IRQ.
ra8_err_t ra8_rmac_phy_reset (ra8_rmac_port_t port, uint8_t phy_addr)
 Software-reset an off-chip PHY via Clause-22 MDIO.
ra8_err_t ra8_rmac_phy_set_advertise (ra8_rmac_port_t port, uint8_t phy_addr, uint16_t capabilities)
 Program the off-chip PHY's auto-negotiation advertisement.
ra8_err_t ra8_rmac_phy_auto_neg_start (ra8_rmac_port_t port, uint8_t phy_addr)
 Kick off (or restart) auto-negotiation on the off-chip PHY.
ra8_err_t ra8_rmac_phy_auto_neg_wait (ra8_rmac_port_t port, uint8_t phy_addr, uint32_t timeout_ms, ra8_rmac_phy_link_t *out_link)
 Block (with a bounded poll) until the PHY reports AN_COMPLETE.
ra8_err_t ra8_rmac_phy_link_status (ra8_rmac_port_t port, uint8_t phy_addr, ra8_rmac_phy_link_t *out_link)
 Quick poll of BMSR.LINK_STATUS (no auto-neg block).

Detailed Description

Per-port Ethernet MAC (RMAC) driver – HUM Ch 33.

Tag
[Ring 3 / HAL] {World: NS}

Full HAL coverage of the RA8D2 RMAC block (HUM Ch 33, p 1703-1786). RMAC is the on-chip MAC layer that talks to an off-chip PHY over MII / RMII / GMII / RGMII / XGMII / XFI. It sits between the per-port Ethernet Agent (ETHA, see ra8_etha.h) above and the off-chip PHY below:

*   ESWM (Ch 29, switch fabric) -- top
*      |
*   ETHA (Ch 32, per-port agent)
*      |
*   RMAC (Ch 33, per-port MAC)   <-- this driver
*      |
*   off-chip PHY                  -- bottom
* 

The driver exposes every register field documented in HUM Ch 33.4 except those owned by ra8_eth_gptp (PTP timestamping). The split is:

  • This driver: lifecycle, MAC address program, RX address filter table (perfect-match + multicast hash), VLAN tagging (via MTFFC framing), PFC priority groups (MTPFC3t), Energy Efficient Ethernet / LPI (MEEEC + MMIS2 LPI bits), magic- packet WoL (MRGC.MPDE + MMIS2.MPDIS), loopback (MLBC), link verification (MLVC), XGMII / 10G control (MXGMIIC, MPCH), PHY MDIO Clause-22 + Clause-45 (MPSM driven by MMIS1 events), all link speeds (MPIC.LSC), all duplex modes (MPIC.PIPP), statistics counters (MMPFTCT..MTXBCPL), and full IRQ management (MEIS/MEIE/MEID, MMIS0/1/2 + enables/disables).
  • ra8_eth_gptp: PTP timestamping itself; this driver only programs the MPFCt PTP filter slots and sets up the RMAC MTRC capture-config bits so the GPTP block sees the frame.
State Machine

Definition in file ra8_rmac.h.

Typedef Documentation

◆ ra8_rmac_event_fn_t

typedef void(* ra8_rmac_event_fn_t) (void *ctx, ra8_rmac_port_t port, uint32_t err_msk, uint32_t mon0_msk, uint32_t mon1_msk, uint32_t mon2_msk)

Per-port RMAC IRQ callback.

Parameters
[in]ctxCaller-supplied opaque cookie.
[in]portPort that raised the event.
[in]err_mskSnapshot of MEIS at dispatch time.
[in]mon0_mskSnapshot of MMIS0 at dispatch time.
[in]mon1_mskSnapshot of MMIS1 at dispatch time.
[in]mon2_mskSnapshot of MMIS2 at dispatch time.

Definition at line 290 of file ra8_rmac.h.

Enumeration Type Documentation

◆ ra8_rmac_mdc_clk_t

enum ra8_rmac_mdc_clk_t : uint32_t

MPIC PHY-station-management clock-rate constants.

The MPIC register packs three MDC-related fields:

  • PSMCS[22:16] : clock divider; MDC = ESWCLK / (2 * (PSMCS + 1)).
  • PSMHT[26:24] : MDIO hold-time adjust (FSP default 0).
  • PSMCT[30:28] : MDIO capture-time adjust (FSP default 0).

Exposed publicly so the board-level bring-up code can pick a conservative mdc_hz target without having to know the PSMCS field width. IEEE 802.3 Clause 22 caps MDC at 2.5 MHz; the GPY111 / PEF7071 family is happy at 1 MHz which is what the default constant below provides.

Cross-checked against FSP r_rmac_phy_calculate_mpic and CMSIS R7KA8D2KF_core0.h R_RMAC0_MPIC_PSMCS_Pos / PSMHT_Pos / PSMCT_Pos.

Enumerator
k_ra8_rmac_mdc_default_hz 

1 MHz MDC – well below the 2.5 MHz ceiling.

k_ra8_rmac_mdc_min_hz 

Lower-bound sanity (PSMCS is 7 bits wide).

k_ra8_rmac_mdc_psmcs_max 

MPIC.PSMCS[22:16] is 7 bits wide.

Definition at line 105 of file ra8_rmac.h.

◆ ra8_rmac_phy_advert_t

enum ra8_rmac_phy_advert_t : uint16_t

802.3 Clause 22 ANAR (auto-negotiation advertisement) bits.

These match the IEEE 802.3 Clause 28.2.4 ANAR register bit layout for 10/100M abilities. Pass any bitwise OR to ra8_rmac_phy_set_advertise. The selector field (bits 0-4) is set to 00001 (IEEE 802.3) by the helper; callers do not need to include it.

Enumerator
k_ra8_rmac_phy_advert_10_hd 

IEEE 802.3 ANAR.10BASE-T.

k_ra8_rmac_phy_advert_10_fd 

IEEE 802.3 ANAR.10BASE-T FD.

k_ra8_rmac_phy_advert_100_hd 

IEEE 802.3 ANAR.100BASE-TX.

k_ra8_rmac_phy_advert_100_fd 

IEEE 802.3 ANAR.100BASE-TX FD.

k_ra8_rmac_phy_advert_pause 

IEEE 802.3 ANAR.PAUSE.

Definition at line 196 of file ra8_rmac.h.

◆ ra8_rmac_phy_speed_t

enum ra8_rmac_phy_speed_t : uint8_t

Resolved PHY link speed/duplex.

Returned by ra8_rmac_phy_auto_neg_wait once the off-chip PHY's IEEE 802.3 Clause 22 BMSR.AN_COMPLETE bit asserts. Encodes the highest-priority capability common to both link partners (the PHY itself decodes the LPA register and presents the resolved value).

Enumerator
k_ra8_rmac_phy_speed_unknown 

No link / not yet resolved.

k_ra8_rmac_phy_speed_10_hd 

10BASE-T half duplex.

k_ra8_rmac_phy_speed_10_fd 

10BASE-T full duplex.

k_ra8_rmac_phy_speed_100_hd 

100BASE-TX half duplex.

k_ra8_rmac_phy_speed_100_fd 

100BASE-TX full duplex.

k_ra8_rmac_phy_speed_count 

Sentinel.

Definition at line 160 of file ra8_rmac.h.

Function Documentation

◆ ra8_rmac_attach_handler()

ra8_err_t ra8_rmac_attach_handler ( ra8_rmac_port_t port,
ra8_rmac_event_fn_t cb,
void * ctx )
nodiscard

Attach a per-port IRQ handler for RMAC events.

Parameters
[in]portPort identifier.
[in]cbCallback (nullptr to detach).
[in]ctxOpaque cookie passed back to cb.
Returns
ra8_err_t Error code.
Precondition
Port previously brought up via ra8_rmac_init.
Caller is single-threaded with respect to attach/dispatch.
Postcondition
Subsequent calls to ra8_rmac_dispatch invoke cb.
See also
ra8_rmac_dispatch
Since
0.1.0

Definition at line 934 of file ra8_rmac.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, ra8_log_error, s_slots, and s_tag.

◆ ra8_rmac_clear_status()

ra8_err_t ra8_rmac_clear_status ( ra8_rmac_port_t port,
uint32_t err_mask,
uint32_t mon0_mask,
uint32_t mon1_mask,
uint32_t mon2_mask )
nodiscard

Clear bits in MEIS / MMIS0 / MMIS1 / MMIS2.

Parameters
[in]portPort identifier.
[in]err_maskBits to clear in MEIS via MEID.
[in]mon0_maskBits to clear in MMIS0 via MMID0.
[in]mon1_maskBits to clear in MMIS1 via MMID1.
[in]mon2_maskBits to clear in MMIS2 via MMID2.
Returns
ra8_err_t Error code.
Precondition
Port previously brought up via ra8_rmac_init.
Caller has read the status registers via ra8_rmac_get_status.
Postcondition
Bits in masks are cleared in their respective status registers.
Re-reads of the status registers exclude the cleared bits.
Note
IRQ-safe; the underlying writes are atomic on Cortex-M85.
Since
0.1.0

Definition at line 118 of file ra8_rmac_mgmt.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, r_rmac_regs_t::MEID, r_rmac_regs_t::MEIS, r_rmac_regs_t::MMID0, r_rmac_regs_t::MMID1, r_rmac_regs_t::MMID2, r_rmac_regs_t::MMIS0, r_rmac_regs_t::MMIS1, r_rmac_regs_t::MMIS2, ra8_log_error, ra8_rmac(), and s_tag.

◆ ra8_rmac_deinit()

ra8_err_t ra8_rmac_deinit ( ra8_rmac_port_t port)
nodiscard

Tear down an RMAC port.

Parameters
[in]portPort identifier.
Returns
ra8_err_t Error code.
Return values
k_ra8_okPort stopped, regs cleared.
k_ra8_err_invalid_argport out of range.
Precondition
Port previously brought up via ra8_rmac_init.
No outstanding TX/RX traffic on this port.
Postcondition
MRAFC, MRGC, MTFFC, MLBC, MEEEC cleared.
MEIE, MMIE0, MMIE1, MMIE2 cleared.
Note
Does NOT drop the shared ESWM MSTP gate; ra8_eth_deinit owns the final reference.
See also
ra8_rmac_init
Since
0.1.0

Definition at line 515 of file ra8_rmac.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, r_rmac_regs_t::MEEEC, r_rmac_regs_t::MEIE, r_rmac_regs_t::MLBC, r_rmac_regs_t::MMIE0, r_rmac_regs_t::MMIE1, r_rmac_regs_t::MMIE2, r_rmac_regs_t::MRAFC, r_rmac_regs_t::MRGC, r_rmac_regs_t::MTFFC, ra8_log_error, ra8_rmac(), s_slots, and s_tag.

Referenced by ra8_eth_close().

◆ ra8_rmac_dispatch()

void ra8_rmac_dispatch ( ra8_rmac_port_t port)

Dispatch a pending RMAC IRQ.

Parameters
[in]portPort identifier.

Reads MEIS / MMIS0..2 atomically, clears every observed bit through the matching MEID / MMID register, then invokes the attached callback with the snapshot. Designed to be called from the NVIC ISR registered for the RMAC error / monitor interrupt vectors.

Precondition
Port previously brought up via ra8_rmac_init.
Called from ISR context or a host-test driver.
Postcondition
All four status registers are cleared.
Callback (if any) has run with the snapshot.
Note
Not thread-safe; pair with NVIC masking. See HUM Ch 41 "Reduced Media Access Controller (RMAC)" pp 1893-2018.
See also
ra8_rmac_attach_handler
Since
0.1.0

Definition at line 946 of file ra8_rmac.c.

References internal_port_ok(), r_rmac_regs_t::MEID, r_rmac_regs_t::MEIS, r_rmac_regs_t::MMID0, r_rmac_regs_t::MMID1, r_rmac_regs_t::MMID2, r_rmac_regs_t::MMIS0, r_rmac_regs_t::MMIS1, r_rmac_regs_t::MMIS2, ra8_rmac(), and s_slots.

◆ ra8_rmac_enter_stop()

ra8_err_t ra8_rmac_enter_stop ( ra8_rmac_port_t port)
nodiscard

Enter low-power "stop" by disabling RX address filtering.

Parameters
[in]portPort identifier.
Returns
ra8_err_t Error code.
Precondition
Port has been brought up via ra8_rmac_init.
No PHY MDIO transaction outstanding.
Postcondition
MRAFC = 0 (no frame class accepted).
Existing IRQ enables preserved so wake events still fire.
Note
Pair with ra8_rmac_exit_stop. Magic-packet WoL stays armed if MRGC.MPDE was set before this call.
Since
0.1.0

Definition at line 551 of file ra8_rmac.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, r_rmac_regs_t::MRAFC, ra8_log_error, ra8_rmac(), and s_tag.

◆ ra8_rmac_exit_stop()

ra8_err_t ra8_rmac_exit_stop ( ra8_rmac_port_t port)
nodiscard

Exit low-power "stop" by reasserting the saved RX filter.

Parameters
[in]portPort identifier.
Returns
ra8_err_t Error code.
Precondition
Caller previously invoked ra8_rmac_enter_stop on this port.
Port still has its MSTP gate held by ra8_eth.
Postcondition
MRAFC restored to the value cached by ra8_rmac_init / set_filter.
Counters reset to zero so the new accounting window starts clean.
See also
ra8_rmac_enter_stop
Since
0.1.0

Definition at line 562 of file ra8_rmac.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, r_rmac_regs_t::MRAFC, ra8_log_error, ra8_rmac(), s_slots, and s_tag.

◆ ra8_rmac_get_status()

ra8_err_t ra8_rmac_get_status ( ra8_rmac_port_t port,
ra8_rmac_status_t * out )
nodiscard

Read a port's status snapshot (MEIS + MMIS0..2 + MPIM + MAC).

Parameters
[in]portPort identifier.
[out]outDestination for the status snapshot.
Returns
ra8_err_t Error code.
Precondition
Port has been brought up via ra8_rmac_init.
out is a writable pointer.
Postcondition
out->err_status reflects MEIS at the call site.
out->mon_status[i] reflect MMIS{i} for i in 0..2.
Note
Reads are non-destructive; status bits are cleared via ra8_rmac_clear_status.
See also
ra8_rmac_clear_status
Since
0.1.0

Definition at line 92 of file ra8_rmac_mgmt.c.

References ra8_rmac_status_t::err_status, internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, r_rmac_regs_t::MEIS, r_rmac_regs_t::MMIS0, r_rmac_regs_t::MMIS1, r_rmac_regs_t::MMIS2, ra8_rmac_status_t::mon_status, r_rmac_regs_t::MPIM, r_rmac_regs_t::MRMAC0, ra8_rmac_status_t::mrmac0, r_rmac_regs_t::MRMAC1, ra8_rmac_status_t::mrmac1, ra8_rmac_status_t::phy_monitor, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac(), and s_tag.

◆ ra8_rmac_init()

ra8_err_t ra8_rmac_init ( ra8_rmac_port_t port,
const ra8_rmac_config_t * cfg )
nodiscard

Initialise an RMAC port (MSTP gate + reset regs + filter mode).

Parameters
[in]portPort identifier (k_ra8_rmac_port_0 or _1).
[in]cfgPer-port configuration. Must not be nullptr.
Returns
ra8_err_t Error code.
Return values
k_ra8_okPort brought up.
k_ra8_err_null_ptrcfg is nullptr.
k_ra8_err_invalid_argport out of range or cfg field invalid.
Precondition
Caller is single-threaded with respect to this port.
Ethernet subsystem MSTP gate may already be enabled by ra8_eth.
Postcondition
MRAFC = cfg->rx_filter.
MEIE = cfg->err_irq_enable; MMIE0/1/2 set; status regs cleared.
MPIC.PIS / .LSC / .PIPP programmed from cfg.
Note
Per-port; safe to call concurrently for distinct ports.
See also
ra8_rmac_deinit
Since
0.1.0

Definition at line 481 of file ra8_rmac.c.

References internal_pis_ok(), internal_port_ok(), internal_program_irq_block(), internal_program_mac_config(), k_ra8_err_invalid_arg, k_ra8_mstp_eswm, k_ra8_ok, k_ra8_rmac_lsc_count, ra8_rmac_config_t::link_speed, ra8_rmac_config_t::phy_interface, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_log_info, ra8_mstp_enable(), RA8_RETURN_ON_ERROR, ra8_rmac(), ra8_rmac_config_t::rx_filter, s_slots, and s_tag.

Referenced by internal_eth_rmac_program().

◆ ra8_rmac_mdio_c22_read()

ra8_err_t ra8_rmac_mdio_c22_read ( ra8_rmac_port_t port,
uint8_t phy_addr,
uint8_t reg_addr,
uint16_t * out_value )
nodiscard

Trigger an MDIO Clause-22 register read on the off-chip PHY.

Parameters
[in]portPort identifier.
[in]phy_addr5-bit PHY address (0..31).
[in]reg_addr5-bit register address (0..31).
[out]out_value16-bit register value on success.
Returns
ra8_err_t Error code.
Return values
k_ra8_okRead complete, *out_value populated.
k_ra8_err_null_ptrout_value is nullptr.
k_ra8_err_hw_timeoutMMIS1.PRACS never set within the bounded poll.
Precondition
Port previously brought up via ra8_rmac_init.
MPIC.PSMCS programmed for the chosen MDC clock.
Postcondition
MPSM transaction issued; MMIS1.PRACS cleared.
PHY register snapshot in *out_value when k_ra8_ok is returned.
Since
0.1.0

Definition at line 811 of file ra8_rmac.c.

References internal_mdio_drain(), internal_mdio_wait(), internal_mpsm_issue(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mask_mpsm_data, k_ra8_rmac_mdio_op_c22_read, k_ra8_rmac_mmis1_pracs, k_ra8_rmac_shift_mpsm_prd, r_rmac_regs_t::MPSM, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac(), and s_tag.

Referenced by internal_eth_phy_set_rgmii_skew(), internal_eth_phy_soft_reset(), internal_phy_read_link(), internal_query_negotiated_speed(), internal_wait_for_autoneg(), ra8_rmac_phy_auto_neg_wait(), ra8_rmac_phy_link_status(), and ra8_rmac_phy_reset().

◆ ra8_rmac_mdio_c22_write()

ra8_err_t ra8_rmac_mdio_c22_write ( ra8_rmac_port_t port,
uint8_t phy_addr,
uint8_t reg_addr,
uint16_t value )
nodiscard

Trigger an MDIO Clause-22 register write on the off-chip PHY.

Parameters
[in]portPort identifier.
[in]phy_addr5-bit PHY address.
[in]reg_addr5-bit register address.
[in]value16-bit value to drive into the PHY register.
Returns
ra8_err_t Error code.
Precondition
Port previously brought up via ra8_rmac_init.
MPIC.PSMCS programmed for the chosen MDC clock.
Postcondition
MPSM transaction issued; MMIS1.PWACS cleared.
Since
0.1.0

Definition at line 842 of file ra8_rmac.c.

References internal_mdio_drain(), internal_mdio_wait(), internal_mpsm_issue(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mdio_op_c22_write, k_ra8_rmac_mmis1_pwacs, ra8_log_error, ra8_rmac(), and s_tag.

Referenced by internal_eth_phy_set_rgmii_skew(), internal_eth_phy_soft_reset(), internal_eth_phy_start_autoneg(), ra8_rmac_phy_auto_neg_start(), ra8_rmac_phy_reset(), and ra8_rmac_phy_set_advertise().

◆ ra8_rmac_mdio_c45_read()

ra8_err_t ra8_rmac_mdio_c45_read ( ra8_rmac_port_t port,
uint8_t phy_addr,
uint8_t dev_addr,
uint16_t reg_addr,
uint16_t * out_value )
nodiscard

Trigger an MDIO Clause-45 register read.

Parameters
[in]portPort identifier.
[in]phy_addr5-bit PHY address.
[in]dev_addr5-bit MMD device address.
[in]reg_addr16-bit MMD register address.
[out]out_value16-bit register value on success.
Returns
ra8_err_t Error code.
Return values
k_ra8_okRead complete.
k_ra8_err_null_ptrout_value is nullptr.
k_ra8_err_hw_timeoutMMIS1 completion bit never asserted.
Precondition
Port previously brought up via ra8_rmac_init.
MPIC.PSMHT configured for Clause-45 hold time.
Postcondition
Address frame followed by read frame both completed.
Since
0.1.0

Definition at line 859 of file ra8_rmac.c.

References internal_mdio_drain(), internal_mdio_wait(), internal_mpsm_issue(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mask_mpsm_data, k_ra8_rmac_mdio_op_c45_address, k_ra8_rmac_mdio_op_c45_read, k_ra8_rmac_mmis1_paacs, k_ra8_rmac_mmis1_pracs, k_ra8_rmac_shift_mpsm_prd, r_rmac_regs_t::MPSM, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac(), and s_tag.

◆ ra8_rmac_mdio_c45_write()

ra8_err_t ra8_rmac_mdio_c45_write ( ra8_rmac_port_t port,
uint8_t phy_addr,
uint8_t dev_addr,
uint16_t reg_addr,
uint16_t value )
nodiscard

Trigger an MDIO Clause-45 register write.

Parameters
[in]portPort identifier.
[in]phy_addr5-bit PHY address.
[in]dev_addr5-bit MMD device address.
[in]reg_addr16-bit MMD register address.
[in]value16-bit value to drive into the MMD register.
Returns
ra8_err_t Error code.
Precondition
Port previously brought up via ra8_rmac_init.
MPIC.PSMHT configured for Clause-45 hold time.
Postcondition
Address frame followed by write frame both completed.
Since
0.1.0

Definition at line 902 of file ra8_rmac.c.

References internal_mdio_drain(), internal_mdio_wait(), internal_mpsm_issue(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mdio_op_c45_address, k_ra8_rmac_mdio_op_c45_write, k_ra8_rmac_mmis1_paacs, k_ra8_rmac_mmis1_pwacs, ra8_log_error, ra8_rmac(), and s_tag.

◆ ra8_rmac_phy_auto_neg_start()

ra8_err_t ra8_rmac_phy_auto_neg_start ( ra8_rmac_port_t port,
uint8_t phy_addr )
nodiscard

Kick off (or restart) auto-negotiation on the off-chip PHY.

Sets IEEE 802.3 Clause 22 BMCR.AN_ENABLE (bit 12) and BMCR.AN_RESTART (bit 9) in a single MDIO write. Pair this call with ra8_rmac_phy_auto_neg_wait to block until the PHY reports AN_COMPLETE in BMSR.

Parameters
[in]portPort identifier.
[in]phy_addr5-bit PHY address.
Returns
ra8_err_t Error code.
Return values
k_ra8_okAN restart issued.
k_ra8_err_invalid_argport or phy_addr out of range.
k_ra8_err_hw_timeoutMDIO transaction never completed.
Precondition
Port previously brought up via ra8_rmac_init.
PHY ANAR programmed (see ra8_rmac_phy_set_advertise).
Postcondition
BMCR.AN_ENABLE = 1; BMCR.AN_RESTART = 1.
PHY transitions to AN_ABILITY_DETECT per IEEE 802.3 Clause 28.
Note
IEEE 802.3 Clause 22 sec 22.2.4.1 "BMCR" bit definitions.
See also
ra8_rmac_phy_auto_neg_wait
Since
0.1.0

Definition at line 380 of file ra8_rmac_mgmt.c.

References internal_phy_args_ok(), k_ra8_err_invalid_arg, k_ra8_rmac_phy_bmcr_an_enable, k_ra8_rmac_phy_bmcr_an_restart, k_ra8_rmac_phy_reg_bmcr, ra8_log_error, ra8_rmac_mdio_c22_write(), and s_tag.

Referenced by ra8_etha_open().

◆ ra8_rmac_phy_auto_neg_wait()

ra8_err_t ra8_rmac_phy_auto_neg_wait ( ra8_rmac_port_t port,
uint8_t phy_addr,
uint32_t timeout_ms,
ra8_rmac_phy_link_t * out_link )
nodiscard

Block (with a bounded poll) until the PHY reports AN_COMPLETE.

Reads IEEE 802.3 Clause 22 BMSR (register 1) in a loop; each iteration costs one MDIO transaction. Returns success when both BMSR.AN_COMPLETE (bit 5) and BMSR.LINK_STATUS (bit 2) are observed set in the same read. The resolved speed/duplex is decoded from the negotiated 10/100 capability bits in ANLPAR (register 5) once AN_COMPLETE asserts.

Parameters
[in]portPort identifier.
[in]phy_addr5-bit PHY address.
[in]timeout_msMaximum wait in milliseconds (0 -> internal cap).
[out]out_linkResolved link state on success.
Returns
ra8_err_t Error code.
Return values
k_ra8_okAN_COMPLETE + LINK_STATUS observed.
k_ra8_err_null_ptrout_link is nullptr.
k_ra8_err_invalid_argport or phy_addr out of range.
k_ra8_err_hw_timeoutAN_COMPLETE never asserted.
Precondition
Port previously brought up via ra8_rmac_init.
Auto-neg started via ra8_rmac_phy_auto_neg_start.
Postcondition
On k_ra8_ok, *out_link reflects negotiated speed/duplex/link.
On k_ra8_err_hw_timeout, *out_link->up = false.
Note
IEEE 802.3 Clause 22 sec 22.2.4.2 "BMSR" defines AN_COMPLETE and LINK_STATUS; Clause 28.2.4.4 "ANLPAR" defines the resolved-capability bit layout this helper decodes.
See also
ra8_rmac_phy_auto_neg_start
Since
0.1.0

Definition at line 394 of file ra8_rmac_mgmt.c.

References internal_decode_anlpar(), internal_phy_args_ok(), k_ra8_err_hw_timeout, k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_phy_anwait_iter_cap, k_ra8_rmac_phy_anwait_iters_per_ms, k_ra8_rmac_phy_bmsr_an_done, k_ra8_rmac_phy_bmsr_link_up, k_ra8_rmac_phy_reg_anlpar, k_ra8_rmac_phy_reg_bmsr, k_ra8_rmac_phy_speed_unknown, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac_mdio_c22_read(), s_tag, ra8_rmac_phy_link_t::speed, and ra8_rmac_phy_link_t::up.

Referenced by ra8_etha_open().

◆ ra8_rmac_phy_link_status()

ra8_err_t ra8_rmac_phy_link_status ( ra8_rmac_port_t port,
uint8_t phy_addr,
ra8_rmac_phy_link_t * out_link )
nodiscard

Quick poll of BMSR.LINK_STATUS (no auto-neg block).

Single MDIO read of IEEE 802.3 Clause 22 BMSR. Reports up/down via out_link->up. When up is true the speed field is decoded from ANLPAR if AN_COMPLETE is set, otherwise it is left as k_ra8_rmac_phy_speed_unknown.

Parameters
[in]portPort identifier.
[in]phy_addr5-bit PHY address.
[out]out_linkDestination for the snapshot.
Returns
ra8_err_t Error code.
Return values
k_ra8_okBMSR read OK.
k_ra8_err_null_ptrout_link is nullptr.
k_ra8_err_invalid_argport or phy_addr out of range.
k_ra8_err_hw_timeoutMDIO transaction never completed.
Precondition
Port previously brought up via ra8_rmac_init.
PHY visible on the MDIO bus.
Postcondition
out_link populated; no PHY register state changed.
Note
IEEE 802.3 Clause 22 sec 22.2.4.2 "BMSR.LINK_STATUS" is latching-low: a single read clears any latched-down event.
Since
0.1.0

Definition at line 444 of file ra8_rmac_mgmt.c.

References internal_decode_anlpar(), internal_phy_args_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_phy_bmsr_an_done, k_ra8_rmac_phy_bmsr_link_up, k_ra8_rmac_phy_reg_anlpar, k_ra8_rmac_phy_reg_bmsr, k_ra8_rmac_phy_speed_unknown, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac_mdio_c22_read(), s_tag, ra8_rmac_phy_link_t::speed, and ra8_rmac_phy_link_t::up.

◆ ra8_rmac_phy_reset()

ra8_err_t ra8_rmac_phy_reset ( ra8_rmac_port_t port,
uint8_t phy_addr )
nodiscard

Software-reset an off-chip PHY via Clause-22 MDIO.

Writes IEEE 802.3 Clause 22 BMCR.RESET (bit 15), then polls BMCR until the reset bit self-clears or a bounded poll budget is exhausted.

Parameters
[in]portPort identifier (k_ra8_rmac_port_0 / _1).
[in]phy_addr5-bit PHY address on the MDIO bus (0..31).
Returns
ra8_err_t Error code.
Return values
k_ra8_okPHY reset complete.
k_ra8_err_invalid_argport or phy_addr out of range.
k_ra8_err_hw_timeoutBMCR.RESET never self-cleared.
Precondition
Port previously brought up via ra8_rmac_init.
MPIC.PSMCS programmed for the chosen MDC clock.
Postcondition
BMCR.RESET observed cleared by the PHY.
All other BMCR bits reset to power-on defaults by the PHY.
Note
IEEE 802.3 Clause 22 sec 22.2.4.1.1 "BMCR.RESET" defines the self-clearing semantics this function relies on.
See also
ra8_rmac_phy_auto_neg_start
Since
0.1.0

Definition at line 332 of file ra8_rmac_mgmt.c.

References internal_phy_args_ok(), k_ra8_err_hw_timeout, k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_phy_bmcr_reset, k_ra8_rmac_phy_reg_bmcr, k_ra8_rmac_phy_reset_iter_cap, ra8_log_error, ra8_rmac_mdio_c22_read(), ra8_rmac_mdio_c22_write(), and s_tag.

Referenced by ra8_etha_open().

◆ ra8_rmac_phy_set_advertise()

ra8_err_t ra8_rmac_phy_set_advertise ( ra8_rmac_port_t port,
uint8_t phy_addr,
uint16_t capabilities )
nodiscard

Program the off-chip PHY's auto-negotiation advertisement.

Writes the IEEE 802.3 Clause 22 ANAR register (register 4) with the supplied capability mask plus the IEEE 802.3 selector field (00001 in bits [4:0]). After updating the advertisement, callers typically invoke ra8_rmac_phy_auto_neg_start to cause the PHY to restart auto-negotiation with the new capabilities.

Parameters
[in]portPort identifier.
[in]phy_addr5-bit PHY address (0..31).
[in]capabilitiesOR of ra8_rmac_phy_advert_t bits.
Returns
ra8_err_t Error code.
Return values
k_ra8_okANAR programmed.
k_ra8_err_invalid_argport or phy_addr out of range.
k_ra8_err_hw_timeoutMDIO transaction never completed.
Precondition
Port previously brought up via ra8_rmac_init.
PHY is in a state that accepts ANAR writes (post reset OK).
Postcondition
ANAR = capabilities | 0x0001 (selector field).
Auto-neg restart still required to advertise new value.
Note
IEEE 802.3 Clause 28.2.4 "AN advertisement register" defines the bit layout this helper writes.
See also
ra8_rmac_phy_auto_neg_start
Since
0.1.0

Definition at line 368 of file ra8_rmac_mgmt.c.

References internal_phy_args_ok(), k_ra8_err_invalid_arg, k_ra8_rmac_phy_anar_selector, k_ra8_rmac_phy_reg_anar, ra8_log_error, ra8_rmac_mdio_c22_write(), and s_tag.

Referenced by ra8_etha_open().

◆ ra8_rmac_read_stats()

ra8_err_t ra8_rmac_read_stats ( ra8_rmac_port_t port,
ra8_rmac_stats_t * out )
nodiscard

Read the full statistic counter snapshot (HUM Ch 33.4).

Parameters
[in]portPort identifier.
[out]outDestination for the counter snapshot.
Returns
ra8_err_t Error code.
Precondition
Port has been brought up via ra8_rmac_init.
out is a writable pointer.
Postcondition
Every member in out matches its register at read time.
Hardware counters keep accumulating; this is a read-only snap.
Note
Counters are read-only; clearing happens via deinit/init or a controlled reset of the ETHA mode.
Since
0.1.0

Definition at line 259 of file ra8_rmac_mgmt.c.

References internal_port_ok(), internal_snapshot_pause_pfc(), internal_snapshot_rx(), internal_snapshot_tx(), k_ra8_err_invalid_arg, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac(), and s_tag.

◆ ra8_rmac_set_frame_size()

ra8_err_t ra8_rmac_set_frame_size ( ra8_rmac_port_t port,
bool is_pframe,
uint16_t min_size,
uint16_t max_size )
nodiscard

Configure jumbo-frame minimum / maximum sizes.

Parameters
[in]portPort identifier.
[in]is_pframetrue for P-frames (MRFSCP), false for E-frames (MRFSCE).
[in]min_sizeMinimum accepted frame size (bytes).
[in]max_sizeMaximum accepted frame size (bytes, up to 16383).
Returns
ra8_err_t Error code.
Precondition
Port is in CONFIG mode.
min_size <= max_size.
Postcondition
MRFSCE / MRFSCP packed with min and max in the right halves.
Frames outside the window count toward MRGUEFC / MRBUEFC / MRGOEFC / MRBOEFC depending on size and FCS validity.
Since
0.1.0

Definition at line 652 of file ra8_rmac.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mask_mrfsc, k_ra8_rmac_shift_mrfsce_max, k_ra8_rmac_shift_mrfsce_min, r_rmac_regs_t::MRFSCE, r_rmac_regs_t::MRFSCP, ra8_log_error, ra8_rmac(), and s_tag.

◆ ra8_rmac_set_link()

ra8_err_t ra8_rmac_set_link ( ra8_rmac_port_t port,
ra8_rmac_pis_t iface,
ra8_rmac_lsc_t speed,
ra8_rmac_duplex_t duplex )
nodiscard

Configure the link layer (interface, speed, duplex) atomically.

Parameters
[in]portPort identifier.
[in]ifacePHY-side interface (GMII / MII / RMII / RGMII / XGMII).
[in]speedLink speed (10 / 100 / 1000 / 2500 / 10000 Mbit/s).
[in]duplexHalf / full duplex.
Returns
ra8_err_t Error code.
Precondition
Port is in CONFIG mode.
iface, speed, duplex are within their respective enums.
Postcondition
MPIC.PIS = iface; MPIC.LSC = speed; MPIC.PIPP = duplex.
Since
0.1.0

Definition at line 782 of file ra8_rmac.c.

References internal_make_mpic(), internal_pis_ok(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_lsc_count, k_ra8_rmac_mask_mpic_psmcs, k_ra8_rmac_shift_mpic_psmcs, r_rmac_regs_t::MPIC, ra8_log_error, ra8_rmac(), and s_tag.

Referenced by internal_program_mpic().

◆ ra8_rmac_set_loopback()

ra8_err_t ra8_rmac_set_loopback ( ra8_rmac_port_t port,
bool enable )
nodiscard

Enable / disable internal MAC loopback.

Parameters
[in]portPort identifier.
[in]enabletrue to short TX -> RX inside the MAC.
Returns
ra8_err_t Error code.
Precondition
Port is in CONFIG mode.
PHY pulled into electrical loopback or detached for cleanest test.
Postcondition
MLBC.LBME set / cleared.
Note
Some PHYs also offer line-side loopback configured via MDIO; this driver only manages the on-chip MAC-side path.
Since
0.1.0

Definition at line 767 of file ra8_rmac.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mlbc_lbme, r_rmac_regs_t::MLBC, ra8_log_error, ra8_rmac(), and s_tag.

◆ ra8_rmac_set_lpi()

ra8_err_t ra8_rmac_set_lpi ( ra8_rmac_port_t port,
bool enable )
nodiscard

Enable / disable Energy Efficient Ethernet LPI request.

Parameters
[in]portPort identifier.
[in]enabletrue to assert TX LPI; false to clear.
Returns
ra8_err_t Error code.
Precondition
Port previously brought up via ra8_rmac_init.
PHY supports IEEE 802.3az LPI (caller responsibility).
Postcondition
MEEEC.LPITR set / cleared accordingly.
Subsequent TX traffic enters / leaves LPI; MMIS2.LPIAIS / LPIDIS fires at the transition.
See also
ra8_rmac_get_status to observe MPIM.LPIA bit.
Since
0.1.0

Definition at line 734 of file ra8_rmac.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_meeec_lpitr, r_rmac_regs_t::MEEEC, ra8_log_error, ra8_rmac(), and s_tag.

◆ ra8_rmac_set_mac_address()

ra8_err_t ra8_rmac_set_mac_address ( ra8_rmac_port_t port,
const uint8_t mac[k_ra8_rmac_mac_byte_count] )
nodiscard

Program the reception MAC address (MRMAC0 / MRMAC1).

Parameters
[in]portPort identifier.
[in]mac6-byte network-byte-order MAC address (mac[0] = OUI hi).
Returns
ra8_err_t Error code.
Return values
k_ra8_okMAC address programmed.
k_ra8_err_null_ptrmac is nullptr.
k_ra8_err_invalid_argport out of range.
Precondition
Port is in CONFIG mode (MRMAC0/1 are CONFIG-only writes per Table 33.4).
mac points to a 6-byte readable buffer.
Postcondition
MRMAC0.MAU = mac[0..1] big-endian (MSB in bits [15:8]).
MRMAC1.MAL = mac[2..5] big-endian (mac[2] in bits [31:24]).
Note
Caller is responsible for switching to/from CONFIG mode via the ETHA EAMC.OPC field; see ra8_etha_init.
Since
0.1.0

Definition at line 573 of file ra8_rmac.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mac_byte_0, k_ra8_rmac_mac_byte_1, k_ra8_rmac_mac_byte_2, k_ra8_rmac_mac_byte_3, k_ra8_rmac_mac_byte_4, k_ra8_rmac_mac_byte_5, k_ra8_rmac_mac_byte_count, k_ra8_rmac_mask_byte, k_ra8_rmac_mask_mrmac0_mau, k_ra8_rmac_shift_byte0, k_ra8_rmac_shift_byte1, k_ra8_rmac_shift_byte2, k_ra8_rmac_shift_byte3, k_ra8_rmac_shift_high16, k_ra8_rmac_shift_high24, r_rmac_regs_t::MRMAC0, r_rmac_regs_t::MRMAC1, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac(), and s_tag.

Referenced by internal_bring_up_rmac().

◆ ra8_rmac_set_magic_packet()

ra8_err_t ra8_rmac_set_magic_packet ( ra8_rmac_port_t port,
bool enable )
nodiscard

Enable / disable magic-packet wake-on-LAN detection.

Parameters
[in]portPort identifier.
[in]enabletrue arms detection; false disarms.
Returns
ra8_err_t Error code.
Precondition
Port previously brought up via ra8_rmac_init.
RX path is otherwise quiesced (only WoL frames expected).
Postcondition
MRGC.MPDE set / cleared.
On magic-packet arrival, MMIS2.MPDIS asserts and the IRQ handler fires if MMIE2.MPDIE is set.
Since
0.1.0

Definition at line 749 of file ra8_rmac.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mrgc_mpde, r_rmac_regs_t::MRGC, ra8_log_error, ra8_rmac(), and s_tag.

◆ ra8_rmac_set_pause_frame()

ra8_err_t ra8_rmac_set_pause_frame ( ra8_rmac_port_t port,
ra8_rmac_pause_mode_t mode,
uint16_t pause_time,
uint8_t retry_time,
uint8_t retry_level )
nodiscard

Program a TX pause / PFC frame template.

Parameters
[in]portPort identifier.
[in]modePause-vs-PFC (MTPFC2.PFM).
[in]pause_time16-bit pause quanta (MTPFC.PT).
[in]retry_time8-bit retry threshold (MTPFC.PFRT).
[in]retry_level5-bit retry-level (MTPFC.PFRLV).
Returns
ra8_err_t Error code.
Precondition
Port is in CONFIG mode.
Postcondition
MTPFC packed with pause_time + retry_time + retry_level.
MTPFC2.PFM written from mode.
Since
0.1.0

Definition at line 692 of file ra8_rmac.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mask_mtpfc_pfrt, k_ra8_rmac_mask_mtpfc_pt, k_ra8_rmac_pause_mode_pfc, k_ra8_rmac_shift_mtpfc2_pfm, k_ra8_rmac_shift_mtpfc_pfrlv, k_ra8_rmac_shift_mtpfc_pfrt, k_ra8_rmac_shift_mtpfc_pt, k_rmac_pfrlv_mask, r_rmac_regs_t::MTPFC, r_rmac_regs_t::MTPFC2, ra8_log_error, ra8_rmac(), and s_tag.

◆ ra8_rmac_set_pfc_group()

ra8_err_t ra8_rmac_set_pfc_group ( ra8_rmac_port_t port,
ra8_rmac_pfc_group_t group,
uint8_t pcp_mask )
nodiscard

Configure a PFC (802.1Qbb) priority group bitmap.

Parameters
[in]portPort identifier.
[in]groupPriority group index (0..1).
[in]pcp_mask8-bit PCP-priority bitmap.
Returns
ra8_err_t Error code.
Precondition
Port is in CONFIG mode.
group < k_ra8_rmac_pfc_group_count.
Postcondition
MTPFC3[group] = pcp_mask & 0xFF.
Since
0.1.0

Definition at line 719 of file ra8_rmac.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mask_pfc_priority, k_ra8_rmac_pfc_group_count, r_rmac_regs_t::MTPFC3, ra8_log_error, ra8_rmac(), and s_tag.

◆ ra8_rmac_set_ptp_filter()

ra8_err_t ra8_rmac_set_ptp_filter ( ra8_rmac_port_t port,
uint8_t index,
uint8_t byte_offset,
uint8_t value,
bool tef0,
bool tef1 )
nodiscard

Program a PTP-frame filter table entry (MPFCt, t = 0..15).

Parameters
[in]portPort identifier.
[in]indexSlot index (0..15).
[in]byte_offsetOffset into the frame payload to test.
[in]valueReference byte value to compare.
[in]tef0true to flag GPTP TX-event-frame trigger 0.
[in]tef1true to flag GPTP TX-event-frame trigger 1.
Returns
ra8_err_t Error code.
Precondition
Port is in CONFIG mode.
index < k_ra8_rmac_ptp_filter_count.
Postcondition
MPFC[index] = encoded slot.
Subsequent matching frames raise the requested GPTP trigger.
Note
Pair with ra8_eth_gptp to consume the timestamp.
Since
0.1.0

Definition at line 621 of file ra8_rmac.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mask_byte, k_ra8_rmac_ptp_filter_count, k_ra8_rmac_shift_mpfc_te0, k_ra8_rmac_shift_mpfc_te1, k_ra8_rmac_shift_mpfc_val, r_rmac_regs_t::MPFC, ra8_log_error, ra8_rmac(), and s_tag.

◆ ra8_rmac_set_rx_filter()

ra8_err_t ra8_rmac_set_rx_filter ( ra8_rmac_port_t port,
ra8_rmac_mrafc_t filter )
nodiscard

Program the RX address filter mask (MRAFC).

Parameters
[in]portPort identifier.
[in]filterBitwise OR of ra8_rmac_mrafc_t values.
Returns
ra8_err_t Error code.
Precondition
Port has been brought up via ra8_rmac_init.
filter only sets bits documented in ra8_rmac_mrafc_t.
Postcondition
MRAFC = filter.
Driver caches filter for ra8_rmac_exit_stop restore.
Note
Filter writes are CONFIG/OPERATION-mode safe per HUM Table 33.4 ("MRAFC -- C, O").
Since
0.1.0

Definition at line 609 of file ra8_rmac.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, r_rmac_regs_t::MRAFC, ra8_log_error, ra8_rmac(), s_slots, and s_tag.

◆ ra8_rmac_set_vlan_framing()

ra8_err_t ra8_rmac_set_vlan_framing ( ra8_rmac_port_t port,
bool disable_pad,
bool use_mcrc )
nodiscard

Configure VLAN double-tagging behaviour via MTFFC.

Parameters
[in]portPort identifier.
[in]disable_padtrue to disable TX pad (DPAD).
[in]use_mcrctrue to use mCRC framing instead of standard CRC (FCM).
Returns
ra8_err_t Error code.
Precondition
Port is in CONFIG mode.
Postcondition
MTFFC = (DPAD?1) | (FCM<<1).
Note
802.1Q double-tagging itself is honoured by the chip when both outer and inner Ethertypes are recognised; this call only toggles the framing mode that the rest of the pipeline uses.
Since
0.1.0

Definition at line 674 of file ra8_rmac.c.

References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mtffc_dpad, k_ra8_rmac_mtffc_fcm, r_rmac_regs_t::MTFFC, ra8_log_error, ra8_rmac(), and s_tag.