72static const char*
s_tag =
"ETHA";
89typedef enum : uint32_t {
102typedef enum : uint32_t {
240 const uint32_t eaeis0 = reg->
EAEIS0;
242 const uint32_t eaeis1 = reg->
EAEIS1;
244 const uint32_t eaeis2 = reg->
EAEIS2;
246 const uint32_t tasctm = reg->
EATASCTM;
363 const uint32_t s0 = reg->
EAEIS0;
365 const uint32_t s1 = reg->
EAEIS1;
367 const uint32_t s2 = reg->
EAEIS2;
386 fn(ctx, port, s0, s1, s2);
475 for (uint32_t ms = 0U; ms < (uint32_t)k_ms_budget; ++ms) {
476 for (uint32_t i = 0U; i < (uint32_t)k_inner; ++i) {
479#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
480 if (ra8_fake_mmio_wait_eval(®->
EAMS, i, (eams == target))) {
484 if (eams == target) {
515 const uint32_t shift = (uint32_t)((uint8_t)tc * 4U);
563 if (cut_thru != 0U) {
598 uint32_t packed = 0U;
601 const uint32_t shift = (uint32_t)i * 4U;
616 const uint32_t v = ((uint32_t)vim & 0x1U) |
705 const uint32_t bit = 1U << (uint8_t)tc;
733 const uint32_t bit = 1U << (uint8_t)tc;
735 *enabled = (uint8_t)((reg->
EACOEM & bit) != 0U ? 1U : 0U);
737 *gate_open = (uint8_t)((reg->
EACGSM & bit) != 0U ? 1U : 0U);
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_ISR_SAFE
The function is callable from interrupt context.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_hw_timeout
Hardware timed out waiting for a flag or handshake.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
ra8_err_t ra8_etha_read_stats(ra8_etha_port_t port, ra8_etha_stats_t *out)
Read the per-port MIB error counters.
static ra8_err_t internal_etha_wait_for_mode(ra8_etha_port_t port, volatile r_etha_regs_t *reg, ra8_etha_opc_t mode)
Busy-wait until EAMS.OPS catches up to the requested EAMC.OPC.
ra8_err_t ra8_etha_set_ipv_remap(ra8_etha_port_t port, const uint8_t *map)
Programme the IPV (PCP-to-internal-priority) remap table.
ra8_err_t ra8_etha_clear_stats(ra8_etha_port_t port)
Clear the per-port MIB error counters in hardware.
ra8_err_t ra8_etha_deinit(ra8_etha_port_t port)
Tear down an ETHA port (drop into RESET, mask all IRQs).
ra8_err_t ra8_etha_set_mode(ra8_etha_port_t port, ra8_etha_opc_t mode)
Issue an explicit EAMC mode-change command.
ra8_err_t ra8_etha_set_vlan_mode(ra8_etha_port_t port, ra8_etha_vim_t vim, ra8_etha_vem_t vem)
Configure VLAN tag insertion / extraction for the port.
volatile uint32_t g_ra8_etha_diag_last_eams[2]
Last EAMS.OPS value observed during the CONFIG-mode poll.
ra8_err_t ra8_etha_disable_irq(ra8_etha_port_t port, ra8_etha_irq_class_t block, uint32_t mask)
Atomically disable specific error IRQ bits in one of the three blocks.
ra8_err_t ra8_etha_enter_stop(ra8_etha_port_t port)
Drop an ETHA port into low-power stop (DISABLE mode).
ra8_err_t ra8_etha_clear_status(ra8_etha_port_t port, ra8_etha_irq_class_t block, uint32_t mask)
Clear bits in EAEIS0 / EAEIS1 / EAEIS2 via EAEIDx.
ra8_etha_slot_t s_etha_slots[k_ra8_etha_port_count]
Per-port handler table; index = ra8_etha_port_t.
ra8_err_t ra8_etha_set_queue_depth(ra8_etha_port_t port, ra8_etha_tc_t tc, uint16_t depth)
Set the TX descriptor queue depth for one traffic class.
ra8_err_t ra8_etha_enable_irq(ra8_etha_port_t port, ra8_etha_irq_class_t block, uint32_t mask)
Atomically enable specific error IRQ bits in one of the three blocks.
ra8_err_t ra8_etha_set_rx_tag_filter(ra8_etha_port_t port, uint32_t mask)
Configure the RX tag filter (multicast group + VLAN-tag filter).
void ra8_etha_dispatch(ra8_etha_port_t port)
Snapshot all three EAEISx, clear them, then fire the per-port handler.
ra8_err_t ra8_etha_attach_handler(ra8_etha_port_t port, ra8_etha_event_fn_t cb, void *ctx)
Attach a per-port event handler.
ra8_err_t ra8_etha_get_status(ra8_etha_port_t port, ra8_etha_status_t *out)
Read a port's status snapshot (mode + 3x error IRQ status + TAS).
ra8_err_t ra8_etha_configure_cut_through(ra8_etha_port_t port, uint16_t qd, uint8_t dqd)
Configure the cut-through TX queue (low-latency forwarding).
ra8_err_t ra8_etha_set_preemption(ra8_etha_port_t port, uint8_t preempt, uint8_t cut_thru, ra8_etha_afs_t afs)
Configure 802.3br TX preemption: which classes are pre-emptable.
ra8_err_t ra8_etha_reset(ra8_etha_port_t port)
Software-reset the port: drop to RESET, then re-enter CONFIG.
static bool internal_irq_block_ok(ra8_etha_irq_class_t block)
Range-check an error-IRQ block index.
ra8_err_t ra8_etha_configure_cbs(ra8_etha_port_t port, ra8_etha_tc_t tc, uint8_t enable, const ra8_etha_cbs_param_t *param)
Configure the credit-based shaper (CBS) for one traffic class.
ra8_err_t ra8_etha_exit_stop(ra8_etha_port_t port)
Bring an ETHA port back from low-power stop (OPERATION mode).
ra8_err_t ra8_etha_get_cbs_state(ra8_etha_port_t port, ra8_etha_tc_t tc, uint8_t *enabled, uint8_t *gate_open, ra8_etha_cbs_param_t *oper_param)
Read the operational CBS gate-state vector + per-class oper params.
static bool internal_tc_ok(ra8_etha_tc_t tc)
Range-check a traffic-class argument.
ra8_etha_local_mask_t
Local mask helpers used inside this driver.
@ k_ra8_etha_local_9bit_mask
9-bit field mask.
@ k_ra8_etha_local_byte_mask
8-bit field mask.
@ k_ra8_etha_local_all_bits_set
W1C-all helper.
ra8_err_t ra8_etha_set_max_frame_size(ra8_etha_port_t port, ra8_etha_tc_t tc, uint16_t max_bytes)
Set the maximum frame size for one traffic class (jumbo OK).
ra8_err_t ra8_etha_set_queue_arb(ra8_etha_port_t port, ra8_etha_tc_t tc, uint8_t arb)
Configure the per-traffic-class TX queue arbitration weight.
etha_field_t
EAVCC field constants.
@ k_etha_vem_mask
3-bit VLAN egress mode field.
ra8_err_t ra8_etha_init(ra8_etha_port_t port, const ra8_etha_config_t *cfg)
Initialise an ETHA port (MSTP gate + reset registers + initial mode).
ra8_err_t ra8_etha_get_queue_level(ra8_etha_port_t port, ra8_etha_tc_t tc, uint16_t *cur_level, uint16_t *peak)
Read the current and high-water-mark queue level for one class.
ra8_err_t ra8_etha_set_vlan_tag(ra8_etha_port_t port, const ra8_etha_vlan_tag_t *c_tag, const ra8_etha_vlan_tag_t *s_tag_in)
Programme the C-VLAN and S-VLAN tag values used on TX insertion.
Per-port Ethernet Agent (ETHA) driver – HUM Ch 32 (p 1627-1702).
Cross-TU shared surface for the ra8_etha driver split.
static bool internal_port_ok(ra8_etha_port_t port)
Range-check a port argument.
Ethernet Agent (ETHA) per-port register layout for the RA8D2.
ra8_etha_port_t
ETHA port index (m = 0, 1).
@ k_ra8_etha_port_count
Number of ETHA ports.
ra8_etha_afs_t
EATPEC.AFS[1:0] additional fragment size policy for 802.3br.
ra8_etha_tc_t
Traffic-class index (q = 0..7) used by every per-class array.
@ k_ra8_etha_tc_count
Number of traffic classes per port.
ra8_etha_opc_t
ETHA EAMC.OPC[1:0] operating mode commands.
@ k_ra8_etha_opc_operation
Enter OPERATION mode.
@ k_ra8_etha_opc_config
Enter CONFIG mode.
@ k_ra8_etha_opc_reset
Enter RESET mode.
@ k_ra8_etha_opc_disable
Enter DISABLE mode.
ra8_etha_ops_t
ETHA EAMS.OPS[1:0] operating-mode status flag values.
ra8_etha_irq_class_t
Identifier for one of the three error-interrupt blocks.
@ k_ra8_etha_irq_class_1
Block 1: CBS overflow + TAS gate-states.
@ k_ra8_etha_irq_class_2
Block 2: descriptor queue overflow + security.
@ k_ra8_etha_irq_class_0
Block 0: ECC + frame errors + TAS gate-events.
@ k_ra8_etha_irq_class_count
RA8 etha IRQ class count.
static volatile r_etha_regs_t * ra8_etha(ra8_etha_port_t port)
Compile-time offset and size insurance for r_etha_regs_t.
ra8_etha_vim_t
EAVCC.VIM VLAN insertion mode for TX.
@ k_ra8_etha_eavtc_stv_pos
EAVTC.STV[27:16] S-VLAN VID.
@ k_ra8_etha_eavtc_std_pos
EAVTC.STD[31] S-VLAN DEI.
@ k_ra8_etha_eavtc_ctp_pos
EAVTC.CTP[14:12] C-VLAN PCP.
@ k_ra8_etha_eavtc_ctd_pos
EAVTC.CTD[15] C-VLAN DEI.
@ k_ra8_etha_eavtc_stp_pos
EAVTC.STP[30:28] S-VLAN PCP.
@ k_ra8_etha_eavtc_ctv_pos
EAVTC.CTV[11:0] C-VLAN VID.
@ k_ra8_etha_eatpec_afs_pos
EATPEC.AFS[17:16].
@ k_ra8_etha_eavcc_vem_pos
EAVCC.VEM[18:16].
@ k_ra8_etha_mask_civ
EACAIVCq.CIV[19:0].
@ k_ra8_etha_mask_cul
EACAULCq.CUL[30:0].
@ k_ra8_etha_mask_vlan_dei
EAVTC DEI 1-bit field.
@ k_ra8_etha_mask_ctqd
EACTQC.CTQD[15:0].
@ k_ra8_etha_mask_ctdqd
EACTDQDC.CTDQD[3:0].
@ k_ra8_etha_mask_vlan_vid
EAVTC VID 12-bit field.
@ k_ra8_etha_mask_vlan_pcp
EAVTC PCP 3-bit field.
@ k_ra8_etha_mask_opc
EAMC.OPC[1:0].
@ k_ra8_etha_mask_dqd
EATDQDCq.DQD[10:0].
@ k_ra8_etha_mask_mfs
EATMFSCq.MFS[15:0].
@ k_ra8_etha_mask_ops
EAMS.OPS[1:0].
@ k_ra8_etha_mask_ipv
EAIRC.IPVRq[2:0].
@ k_ra8_etha_mask_dnq
EATDQMq.DNQ[10:0].
@ k_ra8_etha_mask_tdqa
EATDQAC.TDQAq[3:0].
ra8_etha_vem_t
EAVCC.VEM[2:0] VLAN extraction mode.
void(* ra8_etha_event_fn_t)(void *ctx, ra8_etha_port_t port, uint32_t eaeis0, uint32_t eaeis1, uint32_t eaeis2)
ETHA per-port event callback.
Ethernet controller base addresses for the Renesas RA8D2.
Bounded wait-flag primitives for RA8D2 HAL drivers.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info(tag, message)
RA8 log info.
#define ra8_log_error(tag, message)
RA8 log error.
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_enable(ra8_mstp_t id)
Reference-counted "ungate this peripheral" request.
Module Stop Control (MSTP) register layout for the Renesas RA8D2.
@ k_ra8_mstp_eswm
MSTPC30 ESWM.
Full ETHA per-port register window (HUM Ch 32, FSP R_ETHA0_Type).
volatile uint32_t EARTFC
+0x0138 RX tag filter configuration.
volatile uint32_t EAMC
+0x0000 Mode command.
volatile uint32_t EACTQC
+0x0100 Cut-through queue config.
volatile uint32_t EACAULC[8]
+0x0240..0x025F CBS admin upper lim.
volatile uint32_t EACC
+0x0204 CBS configuration.
volatile uint32_t EAFSECN
+0x0408 Frame size error counter.
volatile uint32_t EACGSM
+0x02C0 CBS gate state monitor.
volatile uint32_t EATDQAC
+0x001C TX desc queue arbitration.
volatile uint32_t EAIRC
+0x0010 IPV remap (8x 3-bit fields).
volatile uint32_t EATDQM[8]
+0x0080..0x009F Per-class queue mon.
volatile uint32_t EAUSMFSECN
+0x0400 Switch min frame size err cnt.
volatile uint32_t EADQSECN
+0x0410 Queue security error counter.
volatile uint32_t EAEID1
+0x0518 Error interrupt disable 1.
volatile uint32_t EAEIE0
+0x0504 Error interrupt enable 0.
volatile uint32_t EACTDQDC
+0x0104 Cut-through queue depth.
volatile uint32_t EATDQMLM[8]
+0x00A0..0x00BF Per-class peak level.
volatile uint32_t EADQOECN
+0x040C Queue overflow error counter.
volatile uint32_t EAEIE2
+0x0524 Error interrupt enable 2.
volatile uint32_t EAVTC
+0x0134 VLAN tag (C+S) configuration.
volatile uint32_t EAVCC
+0x0130 VLAN control configuration.
volatile uint32_t EATASCTM
+0x03B4 TAS cycle time monitor.
volatile uint32_t EATPEC
+0x0020 TX preemption config (802.3br).
volatile uint32_t EACAEC
+0x0200 CBS admin enable.
volatile uint32_t EAEIS0
+0x0500 Error interrupt status 0.
volatile uint32_t EATDQDC[8]
+0x0060..0x007F Per-class queue depth.
volatile uint32_t EATFECN
+0x0404 Tag filter error counter.
volatile uint32_t EAEID0
+0x0508 Error interrupt disable 0.
volatile uint32_t EACOULM[8]
+0x02A0..0x02BF CBS oper upper limit.
volatile uint32_t EATMFSC[8]
+0x0040..0x005F Per-class max frame.
volatile uint32_t EACOIVM[8]
+0x0280..0x029F CBS oper increment mon.
volatile uint32_t EAEIS2
+0x0520 Error interrupt status 2.
volatile uint32_t EACAIVC[8]
+0x0220..0x023F CBS admin increment.
volatile uint32_t EACOEM
+0x0260 CBS oper enable monitor.
volatile uint32_t EAMS
+0x0004 Mode status.
volatile uint32_t EAEID2
+0x0528 Error interrupt disable 2.
volatile uint32_t EAEIS1
+0x0510 Error interrupt status 1.
volatile uint32_t EAEIE1
+0x0514 Error interrupt enable 1.
Credit-based shaper parameters per traffic class.
uint32_t increment
CIV credit-add per byte (20 bits).
uint32_t upper_lim
CUL upper credit limit (31 bits).
Per-port ETHA configuration knobs.
uint32_t eaeie2_mask
Bits to OR into EAEIE2 on init.
uint32_t eaeie0_mask
Bits to OR into EAEIE0 on init.
uint32_t eaeie1_mask
Bits to OR into EAEIE1 on init.
ra8_etha_opc_t initial_mode
Mode to enter after init.
Per-port runtime traffic counters maintained by ra8_etha.
Per-port MIB counter snapshot.
uint16_t frame_size_err
EAFSECN.FSEN[15:0].
uint16_t tag_filter_err
EATFECN.TFEN[15:0].
uint16_t switch_min_frame_err
EAUSMFSECN.USMFSEN[15:0].
uint16_t queue_security_err
EADQSECN.DQSEN[15:0].
uint16_t queue_overflow_err
EADQOECN.DQOEN[15:0].
Snapshot of an ETHA port's runtime state.
uint32_t tas_cycle
EATASCTM TAS cycle-time monitor.
uint32_t eaeis0
Raw EAEIS0 (ECC + frame errors).
uint32_t eaeis1
Raw EAEIS1 (CBS + TAS gate).
ra8_etha_ops_t ops
Current operating-mode flag.
uint32_t eaeis2
Raw EAEIS2 (queue overflow).
802.1Q VLAN tag descriptor (used by::ra8_etha_set_vlan_tag).
uint8_t pcp
Priority code point (3 bits).
uint16_t vid
VLAN identifier (12 bits).
uint8_t dei
Drop eligible indicator (1 bit).