|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Ethernet Message Forwarding Engine driver implementation. More...
#include "ra8_eth_mfwd.h"#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_ether_regs.h"#include "ra8_log.h"#include "ra8_mstp.h"#include "ra8_mstp_regs.h"Go to the source code of this file.
Enumerations | |
| enum | ra8_eth_mfwd_internal_t : uint32_t { k_ra8_mfwd_off_fwpbfc0_base = 0x4A00UL , k_ra8_mfwd_off_fwpbfcsdc0_base = 0x4A04UL , k_ra8_mfwd_fwpbfcsdc_stride = 0x10UL , k_ra8_mfwd_pbdv_mask = 0x7FUL , k_ra8_mfwd_pbcsd_mask = 0x7FUL , k_ra8_mfwd_port_count = 3UL , k_ra8_mfwd_max_port = 1UL , k_ra8_mfwd_max_queue = 31UL } |
| MFWD register offsets used by the routing programming path. More... | |
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. | |
| static volatile uint32_t * | internal_mfwd_fwpbfcsdc (uint8_t port) |
| Return a typed pointer to FWPBFCSDC0[port] inside MFWD. | |
| 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. | |
Variables | |
| static const char * | s_tag = "ETHMFW" |
| static ra8_eth_mfwd_event_fn_t | s_mfwd_fn |
| static void * | s_mfwd_ctx |
Ethernet Message Forwarding Engine driver implementation.
driver for the RA8D2 MFWD block. The MFWD shares the Ethernet Switch MSTP gate (ESWM) so the lifecycle calls below piggyback on k_ra8_mstp_eswm rather than a per-block bit. Every register access carries a HUM Ch 30 citation.
Definition in file ra8_eth_mfwd.c.
| enum ra8_eth_mfwd_internal_t : uint32_t |
MFWD register offsets used by the routing programming path.
Per CMSIS R7KA8D2KF_core0.h: FWPBFCSDC00 sits at offset 0x4A04 in the MFWD register window (port 0), with each subsequent port advancing 0x10 bytes (so port 1 -> 0x4A14, port 2 -> 0x4A24). PBCSD (Port Based Forwarding CSD) is the low 7 bits.
Definition at line 124 of file ra8_eth_mfwd.c.
|
inlinestatic |
Return a typed pointer to FWPBFCSDC0[port] inside MFWD.
Helper that computes the register address from the MFWD base + per-port offset so the caller's body stays readable. Per project policy hardware register access is via inline accessors, never preprocessor macros.
| [in] | port | Port index (already bounds-checked by the caller). |
Definition at line 155 of file ra8_eth_mfwd.c.
References k_ra8_mfwd_base_addr, k_ra8_mfwd_fwpbfcsdc_stride, k_ra8_mfwd_off_fwpbfcsdc0_base, and RA8_INTERNAL.
Referenced by ra8_eth_mfwd_route_queue().
|
nodiscard |
Attach the shared event handler.
Definition at line 81 of file ra8_eth_mfwd.c.
References k_ra8_ok, s_mfwd_ctx, and s_mfwd_fn.
|
nodiscard |
Clear bits in MFWD_STS via MFWD_ICLR.
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().
|
nodiscard |
Tear down the MFWD block.
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.
| void ra8_eth_mfwd_dispatch | ( | void | ) |
Dispatch an MFWD event.
See implementation.
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.
|
nodiscard |
Put MFWD into MSTP-gated stop.
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().
|
nodiscard |
Exit MSTP-gated stop.
Definition at line 110 of file ra8_eth_mfwd.c.
References k_ra8_mstp_eswm, and ra8_mstp_enable().
|
nodiscard |
Read the MFWD_STS status register.
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().
|
nodiscard |
Initialise the MFWD block (MSTP enable + reset regs).
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().
|
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.
| [in] | port | GMAC port index (0..1 on RA8D2). |
| [in] | queue_index | GWCA queue index that receives the frames (<= 31). |
| k_ra8_ok | Routing programmed. |
| k_ra8_err_invalid_arg | port > 1 or queue_index > 31. |
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().
|
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.
| [in] | port_masks | Array of three masks: index 0 = port 0, index 1 = port 1, index 2 = host port. Caller-owned; only the values are read. |
| k_ra8_ok | Masks programmed. |
| k_ra8_err_null_ptr | port_masks is null. |
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().
|
static |
Definition at line 33 of file ra8_eth_mfwd.c.
Referenced by ra8_eth_mfwd_attach_handler(), ra8_eth_mfwd_deinit(), and ra8_eth_mfwd_dispatch().
|
static |
Definition at line 32 of file ra8_eth_mfwd.c.
Referenced by ra8_eth_mfwd_attach_handler(), ra8_eth_mfwd_deinit(), and ra8_eth_mfwd_dispatch().
|
static |
Definition at line 30 of file ra8_eth_mfwd.c.