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

Ethernet Message Forwarding Engine (MFWD) driver. More...

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

Go to the source code of this file.

Typedefs

typedef void(* ra8_eth_mfwd_event_fn_t) (void *ctx, uint32_t status_mask)
 MFWD event callback.

Functions

ra8_err_t ra8_eth_mfwd_init (void)
 Initialise the MFWD block (MSTP enable + reset regs).
ra8_err_t ra8_eth_mfwd_deinit (void)
 Tear down the MFWD block.
ra8_err_t ra8_eth_mfwd_get_status (uint32_t *out_mask)
 Read the MFWD_STS status register.
ra8_err_t ra8_eth_mfwd_clear_status (uint32_t mask)
 Clear bits in MFWD_STS via MFWD_ICLR.
ra8_err_t ra8_eth_mfwd_attach_handler (ra8_eth_mfwd_event_fn_t fn, void *ctx)
 Attach the shared event handler.
void ra8_eth_mfwd_dispatch (void)
 Dispatch an MFWD event.
ra8_err_t ra8_eth_mfwd_enter_stop (void)
 Put MFWD into MSTP-gated stop.
ra8_err_t ra8_eth_mfwd_exit_stop (void)
 Exit MSTP-gated stop.
ra8_err_t ra8_eth_mfwd_set_forwarding_masks (const uint8_t port_masks[3])
 Program the per-port forwarding-destination masks (FWPBFC0).
ra8_err_t ra8_eth_mfwd_route_queue (uint8_t port, uint8_t queue_index)
 Route inbound frames from a GMAC port into a GWCA RX queue.

Detailed Description

Ethernet Message Forwarding Engine (MFWD) driver.

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

driver for the RA8D2 MFWD block. The MFWD sits between the GMAC ports and the CPU Agent (GWCA), making per-frame forwarding decisions (port-to-port, port-to-host, multicast). This driver covers lifecycle + status + IRQ + power transition; the per-frame forwarding-table programming surface lands with the first routing-aware consumer.

Definition in file ra8_eth_mfwd.h.

Typedef Documentation

◆ ra8_eth_mfwd_event_fn_t

typedef void(* ra8_eth_mfwd_event_fn_t) (void *ctx, uint32_t status_mask)

MFWD event callback.

Definition at line 35 of file ra8_eth_mfwd.h.

Function Documentation

◆ ra8_eth_mfwd_attach_handler()

ra8_err_t ra8_eth_mfwd_attach_handler ( ra8_eth_mfwd_event_fn_t fn,
void * ctx )
nodiscard

Attach the shared event handler.

Since
0.1.0

Definition at line 81 of file ra8_eth_mfwd.c.

References k_ra8_ok, s_mfwd_ctx, and s_mfwd_fn.

◆ ra8_eth_mfwd_clear_status()

ra8_err_t ra8_eth_mfwd_clear_status ( uint32_t mask)
nodiscard

Clear bits in MFWD_STS via MFWD_ICLR.

Since
0.1.0

Definition at line 72 of file ra8_eth_mfwd.c.

References k_ra8_ok, r_mfwd_regs_t::MFWD_ICLR, r_mfwd_regs_t::MFWD_STS, and ra8_mfwd().

◆ ra8_eth_mfwd_deinit()

ra8_err_t ra8_eth_mfwd_deinit ( void )
nodiscard

Tear down the MFWD block.

Since
0.1.0

Definition at line 53 of file ra8_eth_mfwd.c.

References k_ra8_mstp_eswm, r_mfwd_regs_t::MFWD_CTRL, r_mfwd_regs_t::MFWD_IE, ra8_mfwd(), ra8_mstp_disable(), s_mfwd_ctx, and s_mfwd_fn.

◆ ra8_eth_mfwd_dispatch()

void ra8_eth_mfwd_dispatch ( void )

Dispatch an MFWD event.

Since
0.1.0

See implementation.

Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.

Definition at line 89 of file ra8_eth_mfwd.c.

References r_mfwd_regs_t::MFWD_ICLR, r_mfwd_regs_t::MFWD_STS, ra8_mfwd(), s_mfwd_ctx, and s_mfwd_fn.

◆ ra8_eth_mfwd_enter_stop()

ra8_err_t ra8_eth_mfwd_enter_stop ( void )
nodiscard

Put MFWD into MSTP-gated stop.

Since
0.1.0

Definition at line 103 of file ra8_eth_mfwd.c.

References k_ra8_mstp_eswm, r_mfwd_regs_t::MFWD_CTRL, ra8_mfwd(), and ra8_mstp_disable().

◆ ra8_eth_mfwd_exit_stop()

ra8_err_t ra8_eth_mfwd_exit_stop ( void )
nodiscard

Exit MSTP-gated stop.

Since
0.1.0

Definition at line 110 of file ra8_eth_mfwd.c.

References k_ra8_mstp_eswm, and ra8_mstp_enable().

◆ ra8_eth_mfwd_get_status()

ra8_err_t ra8_eth_mfwd_get_status ( uint32_t * out_mask)
nodiscard

Read the MFWD_STS status register.

Since
0.1.0

Definition at line 64 of file ra8_eth_mfwd.c.

References k_ra8_ok, r_mfwd_regs_t::MFWD_STS, RA8_CHECK_NULL_PTR, ra8_mfwd(), and s_tag.

Referenced by l3_program_forwarding().

◆ ra8_eth_mfwd_init()

ra8_err_t ra8_eth_mfwd_init ( void )
nodiscard

Initialise the MFWD block (MSTP enable + reset regs).

Since
0.1.0

Definition at line 35 of file ra8_eth_mfwd.c.

References k_ra8_mstp_eswm, k_ra8_ok, r_mfwd_regs_t::MFWD_CTRL, r_mfwd_regs_t::MFWD_ICLR, r_mfwd_regs_t::MFWD_IE, r_mfwd_regs_t::MFWD_STS, ra8_log_info, ra8_mfwd(), ra8_mstp_enable(), RA8_RETURN_ON_ERROR, and s_tag.

Referenced by l3_arm().

◆ ra8_eth_mfwd_route_queue()

ra8_err_t ra8_eth_mfwd_route_queue ( uint8_t port,
uint8_t queue_index )
nodiscard

Route inbound frames from a GMAC port into a GWCA RX queue.

Programs MFWD.FWPBFCSDC0[port].PBCSD = queue_index so the forwarding engine knows where to deliver port-to-host frames. Without this call the GWCA RX queue stays empty even when frames arrive on the wire. Per FSP r_layer3_switch_StartDescriptorQueue this MUST be programmed after the GWCA queue is in OPERATION and before the MAC is allowed to receive.

Parameters
[in]portGMAC port index (0..1 on RA8D2).
[in]queue_indexGWCA queue index that receives the frames (<= 31).
Returns
ra8_err_t Error code.
Return values
k_ra8_okRouting programmed.
k_ra8_err_invalid_argport > 1 or queue_index > 31.
Precondition
ra8_eth_mfwd_init succeeded earlier (or ra8_eth_init brought up the shared ESWM gate).
GWCA queue indicated by queue_index has been configured.
Postcondition
FWPBFCSDC0[port].PBCSD == queue_index on success.
Other bits of FWPBFCSDC0[port] preserved.
Note
Not thread-safe.
Since
0.1.0

Definition at line 177 of file ra8_eth_mfwd.c.

References internal_mfwd_fwpbfcsdc(), k_ra8_err_invalid_arg, k_ra8_mfwd_max_port, k_ra8_mfwd_max_queue, k_ra8_mfwd_pbcsd_mask, k_ra8_ok, ra8_log_error, and s_tag.

Referenced by internal_open_gwca_path(), and l3_program_forwarding().

◆ ra8_eth_mfwd_set_forwarding_masks()

ra8_err_t ra8_eth_mfwd_set_forwarding_masks ( const uint8_t port_masks[3])
nodiscard

Program the per-port forwarding-destination masks (FWPBFC0).

Sets MFWD.FWPBFC0[i].PBDV = mask for each port i in 0..2 (the two GMAC ports + the host/GWCA port). PBDV is a 7-bit bitmask of destination ports a frame received on this port is allowed to reach. Per FSP r_layer3_switch_open this must be programmed BEFORE the GWCA mode transitions (alongside FWPC10/11/12.DDE).

The simplest permissive setting is 0x7F (all destinations allowed) on every port – that lets wire-to-host RX flow through the switch without any L3 filtering.

Parameters
[in]port_masksArray of three masks: index 0 = port 0, index 1 = port 1, index 2 = host port. Caller-owned; only the values are read.
Returns
ra8_err_t Error code.
Return values
k_ra8_okMasks programmed.
k_ra8_err_null_ptrport_masks is null.
Precondition
ra8_eth_mfwd_init or board MSTP setup has run.
Each mask is 7 bits or fewer (extra bits are ignored).
Postcondition
FWPBFC0/1/2.PBDV reflect the supplied masks.
No other bits of FWPBFC0/1/2 are disturbed.
Note
Not thread-safe.
Since
0.1.0

Definition at line 163 of file ra8_eth_mfwd.c.

References k_ra8_mfwd_base_addr, k_ra8_mfwd_fwpbfcsdc_stride, k_ra8_mfwd_off_fwpbfc0_base, k_ra8_mfwd_pbdv_mask, k_ra8_mfwd_port_count, k_ra8_ok, RA8_CHECK_NULL_PTR, and s_tag.

Referenced by internal_open_gwca_path(), and l3_program_forwarding().