|
| 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_deinit (ra8_etha_port_t port) |
| | Tear down an ETHA port (drop into RESET, mask all IRQs).
|
| 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_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_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_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_attach_handler (ra8_etha_port_t port, ra8_etha_event_fn_t cb, void *ctx) |
| | Attach a per-port event handler.
|
| 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_enter_stop (ra8_etha_port_t port) |
| | Drop an ETHA port into low-power stop (DISABLE mode).
|
| 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_reset (ra8_etha_port_t port) |
| | Software-reset the port: drop to RESET, then re-enter CONFIG.
|
| 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_queue_arb (ra8_etha_port_t port, ra8_etha_tc_t tc, uint8_t arb) |
| | Configure the per-traffic-class TX queue arbitration weight.
|
| 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_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_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_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_ipv_remap (ra8_etha_port_t port, const uint8_t *map) |
| | Programme the IPV (PCP-to-internal-priority) remap table.
|
Per-port ETHA lifecycle / IRQ / mode / queue API – HUM Ch 32 (p 1627-1702).
- Tag
- [Ring 3 / HAL] {World: NS}
Lifecycle (init / deinit / reset), status snapshot, error-IRQ block management, event dispatch, low-power stop, explicit mode-change, and per-traffic-class TX-queue arbitration / depth / preemption / max frame-size / IPV-remap prototypes. Split out of the umbrella ra8_etha.h to keep that header under the per-file line budget; this is a pure move of the original declarations. The data types these functions take live in ra8_etha_types.h, and the register enums in ra8_etha_regs.h.
- Copyright
- Copyright (c) 2026 Brighton Sikarskie SPDX-License-Identifier: MIT
- Since
- 0.1.0
Definition in file ra8_etha_ops.h.
Clear bits in EAEIS0 / EAEIS1 / EAEIS2 via EAEIDx.
- Parameters
-
| [in] | port | Port identifier. |
| [in] | block | Which error-interrupt block (0/1/2). |
| [in] | mask | Bit mask to write to EAEIDx. |
- Returns
- ra8_err_t Error code.
- Return values
-
- Precondition
- Port previously brought up via ra8_etha_init.
-
Caller has read the corresponding EAEISx via::ra8_etha_get_status.
- Postcondition
- Bits in mask are cleared in EAEISx.
-
EAEISx read-back excludes the cleared bits.
- Note
- IRQ-safe; the underlying write is atomic on Cortex-M85.
- See also
- ra8_etha_get_status
- Since
- 0.1.0
Definition at line 255 of file ra8_etha.c.
References r_etha_regs_t::EAEID0, r_etha_regs_t::EAEID1, r_etha_regs_t::EAEID2, r_etha_regs_t::EAEIS0, r_etha_regs_t::EAEIS1, r_etha_regs_t::EAEIS2, internal_irq_block_ok(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_etha_irq_class_0, k_ra8_etha_irq_class_1, k_ra8_etha_irq_class_2, k_ra8_etha_irq_class_count, k_ra8_ok, ra8_etha(), ra8_log_error, and s_tag.
Atomically disable specific error IRQ bits in one of the three blocks.
- Parameters
-
| [in] | port | Port identifier. |
| [in] | block | Which IRQ block. |
| [in] | mask | Bits to OR into the corresponding EAEIDx. |
- Returns
- ra8_err_t Error code.
- Return values
-
- Precondition
- Port previously brought up via ra8_etha_init.
-
IRQ at the NVIC is masked or this caller can tolerate a missed event.
- Postcondition
- Bits in mask are cleared in EAEIEx.
-
Other bits in EAEIEx are unchanged.
- Note
- Hardware uses a separate "clear" register so this is atomic.
- See also
- ra8_etha_enable_irq
- Since
- 0.1.0
Definition at line 316 of file ra8_etha.c.
References r_etha_regs_t::EAEIE0, r_etha_regs_t::EAEIE1, r_etha_regs_t::EAEIE2, internal_irq_block_ok(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_etha_irq_class_0, k_ra8_etha_irq_class_1, k_ra8_etha_irq_class_2, k_ra8_etha_irq_class_count, k_ra8_ok, ra8_etha(), ra8_log_error, and s_tag.
Snapshot all three EAEISx, clear them, then fire the per-port handler.
Reads the three Ethernet-A error/event status registers EAEIS0/1/2 (HUM Ch 32 "ETHA error / event status registers EAEISn", p ~1408) for the given port, atomically writes back the captured bits to acknowledge them, then invokes the handler installed via ra8_etha_attach_handler() with the snapshot mask. Out-of-range ports and missing handlers are silently ignored.
- Parameters
-
| [in] | port | Port identifier. Out-of-range silently ignored. |
- Precondition
- Port previously brought up via ra8_etha_init for the call to do work.
-
Caller has masked the ETHA IRQ at the NVIC if reentrancy is undesirable.
- Postcondition
- All three EAEISx are cleared (matching what was passed to the handler).
-
Per-port callback (if any) has been invoked exactly once.
- Note
- IRQ-context safe; performs no allocation, no locks.
- See also
- ra8_etha_attach_handler
- Since
- 0.1.0
Definition at line 355 of file ra8_etha.c.
References r_etha_regs_t::EAEID0, r_etha_regs_t::EAEID1, r_etha_regs_t::EAEID2, r_etha_regs_t::EAEIS0, r_etha_regs_t::EAEIS1, r_etha_regs_t::EAEIS2, internal_port_ok(), ra8_etha(), and s_etha_slots.
Atomically enable specific error IRQ bits in one of the three blocks.
- Parameters
-
| [in] | port | Port identifier. |
| [in] | block | Which IRQ block. |
| [in] | mask | Bits to OR into the corresponding EAEIEx. |
- Returns
- ra8_err_t Error code.
- Return values
-
- Precondition
- Port previously brought up via ra8_etha_init.
-
IRQ at the NVIC is disabled while this is called if reentrancy is undesirable.
- Postcondition
- Bits in mask are set in EAEIEx.
-
Other bits in EAEIEx are unchanged.
- Note
- Hardware uses a separate "set" register so this is atomic.
- See also
- ra8_etha_disable_irq
- Since
- 0.1.0
Definition at line 289 of file ra8_etha.c.
References r_etha_regs_t::EAEIE0, r_etha_regs_t::EAEIE1, r_etha_regs_t::EAEIE2, internal_irq_block_ok(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_etha_irq_class_0, k_ra8_etha_irq_class_1, k_ra8_etha_irq_class_2, k_ra8_etha_irq_class_count, k_ra8_ok, ra8_etha(), ra8_log_error, and s_tag.
Read the current and high-water-mark queue level for one class.
- Parameters
-
| [in] | port | Port identifier. |
| [in] | tc | Traffic class (0..7). |
| [out] | cur_level | Current pending-descriptor count (DNQ). |
| [out] | peak | Peak pending-descriptor count since last clear (DMLQ). |
- Returns
- ra8_err_t Error code.
- Return values
-
- Precondition
- Port previously brought up via ra8_etha_init.
-
cur_level and peak are writable pointers.
- Postcondition
- *cur_level = EATDQM[tc].DNQ.
-
*peak = EATDQMLM[tc].DMLQ.
- Note
- Read-only; does not clear the high-water mark.
- See also
- ra8_etha_set_queue_depth
- Since
- 0.1.0
Definition at line 534 of file ra8_etha.c.
References r_etha_regs_t::EATDQM, r_etha_regs_t::EATDQMLM, internal_port_ok(), internal_tc_ok(), k_ra8_err_invalid_arg, k_ra8_etha_mask_dnq, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_etha(), ra8_log_error, and s_tag.
Read a port's status snapshot (mode + 3x error IRQ status + TAS).
- Parameters
-
| [in] | port | Port identifier. |
| [out] | out | Destination for the status snapshot. |
- Returns
- ra8_err_t Error code.
- Return values
-
- Precondition
- Port has been brought up via ra8_etha_init.
-
out is a writable pointer.
- Postcondition
- out fields reflect the live registers at the call site.
-
No register state is mutated.
- Note
- Reads are non-destructive; status bits are cleared via ra8_etha_clear_status.
- See also
- ra8_etha_clear_status
- Since
- 0.1.0
Definition at line 228 of file ra8_etha.c.
References r_etha_regs_t::EAEIS0, ra8_etha_status_t::eaeis0, r_etha_regs_t::EAEIS1, ra8_etha_status_t::eaeis1, r_etha_regs_t::EAEIS2, ra8_etha_status_t::eaeis2, r_etha_regs_t::EAMS, r_etha_regs_t::EATASCTM, internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_etha_mask_ops, k_ra8_ok, ra8_etha_status_t::ops, RA8_CHECK_NULL_PTR, ra8_etha(), ra8_log_error, s_tag, and ra8_etha_status_t::tas_cycle.
Referenced by tsn_log_status().
Initialise an ETHA port (MSTP gate + reset registers + initial mode).
- Parameters
-
| [in] | port | Port identifier (k_ra8_etha_port_0 or _1). |
| [in] | cfg | Per-port configuration. Must not be nullptr. |
- Returns
- ra8_err_t Error code.
- Return values
-
- Precondition
- Caller is single-threaded with respect to this port.
-
Ethernet subsystem MSTP gate may already be enabled by ra8_eth.
- Postcondition
- EAMC is loaded with cfg->initial_mode.
-
EAEIE0/1/2 are loaded with cfg->eaeie0/1/2_mask.
- Note
- Per-port; safe to call concurrently for distinct ports.
- See also
- ra8_etha_deinit
- Since
- 0.1.0
Definition at line 167 of file ra8_etha.c.
References r_etha_regs_t::EAEID0, r_etha_regs_t::EAEID1, r_etha_regs_t::EAEID2, r_etha_regs_t::EAEIE0, ra8_etha_config_t::eaeie0_mask, r_etha_regs_t::EAEIE1, ra8_etha_config_t::eaeie1_mask, r_etha_regs_t::EAEIE2, ra8_etha_config_t::eaeie2_mask, r_etha_regs_t::EAMC, ra8_etha_config_t::initial_mode, internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_etha_local_all_bits_set, k_ra8_etha_mask_opc, k_ra8_mstp_eswm, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_etha(), ra8_log_error, ra8_log_info, ra8_mstp_enable(), RA8_RETURN_ON_ERROR, s_etha_slots, and s_tag.
Referenced by internal_eth_loopback_run_once(), priv_ra8_board_eth_etha_to_config(), and tsn_arm().
Programme the IPV (PCP-to-internal-priority) remap table.
- Parameters
-
| [in] | port | Port identifier. |
| [in] | map | 8-entry array, each value 0..7. ipv_map[i] is the internal priority for incoming PCP=i. |
- Returns
- ra8_err_t Error code.
- Return values
-
- Precondition
- Port is in CONFIG mode.
-
map points to 8 valid entries.
- Postcondition
- EAIRC packs eight 3-bit fields, IPVR0..IPVR7, from map[].
-
Out-of-range values are rejected without partial writes.
- Note
- Used to map 802.1p PCP -> RA8D2 internal traffic class.
- See also
- ra8_etha_set_queue_arb
- Since
- 0.1.0
Definition at line 583 of file ra8_etha.c.
References r_etha_regs_t::EAIRC, internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_etha_mask_ipv, k_ra8_etha_tc_count, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_etha(), ra8_log_error, and s_tag.
Issue an explicit EAMC mode-change command.
- Parameters
-
| [in] | port | Port identifier. |
| [in] | mode | Target mode (one of::ra8_etha_opc_t). |
- Returns
- ra8_err_t Error code.
- Return values
-
- Precondition
- Port previously brought up via ra8_etha_init.
-
mode is a legal transition from the current state per HUM Ch 32.2.
- Postcondition
- EAMC = mode.
-
Caller must poll get_status until OPS == ops-of-mode for ack.
- Note
- State machine: RESET -> CONFIG -> OPERATION; OPERATION -> DISABLE.
- State Machine
-
- See also
- ra8_etha_get_status
- Since
- 0.1.0
Definition at line 494 of file ra8_etha.c.
References r_etha_regs_t::EAMC, internal_etha_wait_for_mode(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_etha_mask_opc, ra8_etha(), ra8_log_error, and s_tag.
Referenced by internal_bring_up_rmac(), internal_eth_etha_to_operation(), internal_eth_loopback_run_once(), internal_program_mpic(), and priv_ra8_board_eth_etha_to_config().