|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Per-port ETHA VLAN / shaper / stats / ring / PHY API – HUM Ch 32 (p 1627-1702). More...
#include <stdint.h>#include "ra8_err.h"#include "ra8_etha_regs.h"#include "ra8_etha_types.h"#include "ra8_rmac.h"Go to the source code of this file.
Functions | |
| 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. | |
| 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. | |
| 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). | |
| 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_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_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. | |
| ra8_err_t | ra8_etha_set_tas_schedule (ra8_etha_port_t port, const ra8_etha_tas_queue_t *queues, uint8_t initial_gate_states, uint32_t cycle_time_ns, uint64_t start_time) |
| Programme the time-aware shaper (TAS / 802.1Qbv) gate lists. | |
| ra8_err_t | ra8_etha_tas_ram_reset (ra8_etha_port_t port) |
| Reset the TAS RAM and wait for it to report ready. | |
| ra8_err_t | ra8_etha_read_tas_entry (ra8_etha_port_t port, uint8_t address, ra8_etha_tas_entry_t *out) |
| Read one TAS RAM entry back out of hardware. | |
| ra8_err_t | ra8_etha_enable_tas (ra8_etha_port_t port, uint8_t enable) |
| Enable or disable the TAS scheduler (main switch). | |
| ra8_err_t | ra8_etha_read_stats (ra8_etha_port_t port, ra8_etha_stats_t *out) |
| Read the per-port MIB error counters. | |
| 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_descriptor_ring_init (ra8_etha_port_t channel, uint16_t num_tx, uint16_t num_rx, uint16_t buffer_size) |
| Configure the per-port descriptor-ring sizing. | |
| ra8_err_t | ra8_etha_get_stats (ra8_etha_port_t channel, ra8_etha_port_stats_t *out_stats) |
| Snapshot the per-port software-maintained traffic counters. | |
| ra8_err_t | ra8_etha_account_traffic (ra8_etha_port_t channel, uint32_t tx_ok, uint32_t tx_err, uint32_t rx_ok, uint32_t rx_err, uint32_t rx_drop) |
| Increment the per-port TX OK / TX err / RX OK / RX err / drop counters. | |
| ra8_err_t | ra8_etha_open (ra8_etha_port_t channel, const ra8_etha_phy_open_t *phy, ra8_rmac_phy_link_t *out_link) |
| Bring an ETHA port + its off-chip PHY up to OPERATION mode. | |
Per-port ETHA VLAN / shaper / stats / ring / PHY API – HUM Ch 32 (p 1627-1702).
VLAN tag insertion / extraction, RX tag filter, cut-through queue, credit-based shaper (CBS / 802.1Qav), time-aware shaper (TAS / 802.1Qbv), per-port MIB counters, descriptor ring sizing, software traffic accounting, and the one-shot PHY bring-up helper. 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 tests-side Ethernet header parser that once lived here moved to tests/fixtures/inc/eth_frame_fixture.h under issue #238). The data types these functions take live in ra8_etha_types.h, the register enums in ra8_etha_regs.h, and the PHY link type in ra8_rmac.h.
Definition in file ra8_etha_shaper.h.
|
nodiscard |
Increment the per-port TX OK / TX err / RX OK / RX err / drop counters.
| [in] | channel | Port identifier. |
| [in] | tx_ok | Frames to add to tx_ok. |
| [in] | tx_err | Frames to add to tx_err. |
| [in] | rx_ok | Frames to add to rx_ok. |
| [in] | rx_err | Frames to add to rx_err. |
| [in] | rx_drop | Frames to add to rx_drop. |
| k_ra8_ok | Counters updated (or saturated). |
| k_ra8_err_invalid_arg | channel out of range. |
Definition at line 158 of file ra8_etha_stats.c.
References internal_port_ok(), internal_sat_add_u32(), k_ra8_err_invalid_arg, k_ra8_ok, ra8_log_error, ra8_etha_port_stats_t::rx_drop, ra8_etha_port_stats_t::rx_err, ra8_etha_port_stats_t::rx_ok, s_etha_slots, s_tag, ra8_etha_port_stats_t::tx_err, and ra8_etha_port_stats_t::tx_ok.
Referenced by internal_eth_loopback_run_once().
|
nodiscard |
Clear the per-port MIB error counters in hardware.
| [in] | port | Port identifier. |
| k_ra8_ok | All five counters zeroed. |
| k_ra8_err_invalid_arg | port out of range. |
Definition at line 767 of file ra8_etha.c.
References r_etha_regs_t::EADQOECN, r_etha_regs_t::EADQSECN, r_etha_regs_t::EAFSECN, r_etha_regs_t::EATFECN, r_etha_regs_t::EAUSMFSECN, internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, ra8_etha(), ra8_log_error, and s_tag.
|
nodiscard |
Configure the credit-based shaper (CBS) for one traffic class.
| [in] | port | Port identifier. |
| [in] | tc | Traffic class (0..7). |
| [in] | enable | Non-zero -> set EACAEC.CEtc and EACC.CCtc. |
| [in] | param | Pointer to CBS parameters (increment + upper-limit). |
| k_ra8_ok | CBS programmed. |
| k_ra8_err_null_ptr | param is nullptr (when enable != 0). |
| k_ra8_err_invalid_arg | port, tc, or values out of range. |
Definition at line 680 of file ra8_etha.c.
References r_etha_regs_t::EACAEC, r_etha_regs_t::EACAIVC, r_etha_regs_t::EACAULC, r_etha_regs_t::EACC, ra8_etha_cbs_param_t::increment, internal_port_ok(), internal_tc_ok(), k_ra8_err_invalid_arg, k_ra8_etha_mask_civ, k_ra8_etha_mask_cul, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_etha(), ra8_log_error, s_tag, and ra8_etha_cbs_param_t::upper_lim.
Referenced by tsn_program_cbs().
|
nodiscard |
Configure the cut-through TX queue (low-latency forwarding).
| [in] | port | Port identifier. |
| [in] | qd | 16-bit cut-through queue depth in bytes (CTQD). |
| [in] | dqd | 4-bit cut-through descriptor queue depth (CTDQD). |
| k_ra8_ok | EACTQC + EACTDQDC updated. |
| k_ra8_err_invalid_arg | port out of range. |
Definition at line 666 of file ra8_etha.c.
References r_etha_regs_t::EACTDQDC, r_etha_regs_t::EACTQC, internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_etha_mask_ctdqd, k_ra8_etha_mask_ctqd, k_ra8_ok, ra8_etha(), ra8_log_error, and s_tag.
|
nodiscard |
Configure the per-port descriptor-ring sizing.
| [in] | channel | Port identifier (0..1, mapped to ra8_etha_port_t). |
| [in] | num_tx | Number of TX descriptors (1..4096). |
| [in] | num_rx | Number of RX descriptors (1..4096). |
| [in] | buffer_size | Bytes per descriptor buffer (>= 64, <= 16383). |
| k_ra8_ok | Ring config captured. |
| k_ra8_err_invalid_arg | Any argument out of range. |
Definition at line 115 of file ra8_etha_stats.c.
References r_etha_regs_t::EATDQDC, internal_port_ok(), internal_ring_args_ok(), k_ra8_err_invalid_arg, k_ra8_etha_mask_dqd, k_ra8_etha_tc_count, k_ra8_ok, ra8_etha(), ra8_log_error, s_etha_slots, and s_tag.
Referenced by internal_eth_loopback_run_once().
|
nodiscard |
Enable or disable the TAS scheduler (main switch).
| [in] | port | Port identifier. |
| [in] | enable | Non-zero -> set EATASC.TASE; zero -> clear. |
| k_ra8_ok | EATASC.TASE updated. |
| k_ra8_err_invalid_arg | port out of range. |
Definition at line 389 of file ra8_etha_tas.c.
References r_etha_regs_t::EATASC, internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_etha_eatasc_tase_pos, k_ra8_ok, ra8_etha(), ra8_log_error, and s_tag.
Referenced by tsn_program_tas().
|
nodiscard |
Read the operational CBS gate-state vector + per-class oper params.
| [in] | port | Port identifier. |
| [in] | tc | Traffic class (0..7). |
| [out] | enabled | Non-zero if oper-enable mirror bit is set. |
| [out] | gate_open | Non-zero if EACGSM gate-state bit is asserted. |
| [out] | oper_param | Live oper-side increment + upper-limit values. |
| k_ra8_ok | Snapshot returned. |
| k_ra8_err_null_ptr | any out pointer is nullptr. |
| k_ra8_err_invalid_arg | port or tc out of range. |
Definition at line 718 of file ra8_etha.c.
References r_etha_regs_t::EACGSM, r_etha_regs_t::EACOEM, r_etha_regs_t::EACOIVM, r_etha_regs_t::EACOULM, ra8_etha_cbs_param_t::increment, internal_port_ok(), internal_tc_ok(), k_ra8_err_invalid_arg, k_ra8_etha_mask_civ, k_ra8_etha_mask_cul, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_etha(), ra8_log_error, s_tag, and ra8_etha_cbs_param_t::upper_lim.
Referenced by tsn_program_cbs().
|
nodiscard |
Snapshot the per-port software-maintained traffic counters.
| [in] | channel | Port identifier. |
| [out] | out_stats | Destination for the snapshot. |
| k_ra8_ok | Snapshot returned. |
| k_ra8_err_null_ptr | out_stats is nullptr. |
| k_ra8_err_invalid_arg | channel out of range. |
Definition at line 147 of file ra8_etha_stats.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_log_error, s_etha_slots, and s_tag.
Referenced by internal_eth_loopback_run_once().
|
nodiscard |
Bring an ETHA port + its off-chip PHY up to OPERATION mode.
One-shot helper that wraps the per-port bring-up sequence the threadx_netx_tcp_echo app needs. Steps:
| [in] | channel | Port identifier. |
| [in] | phy | PHY bring-up parameters (must not be nullptr). |
| [out] | out_link | Resolved link state on success. |
| k_ra8_ok | Port + PHY up; out_link populated. |
| k_ra8_err_null_ptr | phy or out_link is nullptr. |
| k_ra8_err_invalid_arg | channel out of range or phy fields bad. |
| k_ra8_err_hw_timeout | PHY reset / auto-neg never completed. |
Definition at line 215 of file ra8_etha_stats.c.
References ra8_etha_phy_open_t::advertise, internal_etha_to_operation(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, ra8_etha_phy_open_t::phy_addr, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac_phy_auto_neg_start(), ra8_rmac_phy_auto_neg_wait(), ra8_rmac_phy_reset(), ra8_rmac_phy_set_advertise(), s_tag, and ra8_etha_phy_open_t::timeout_ms.
|
nodiscard |
Read the per-port MIB error counters.
| [in] | port | Port identifier. |
| [out] | out | Snapshot of all five counter registers. |
| k_ra8_ok | Snapshot returned. |
| k_ra8_err_null_ptr | out is nullptr. |
| k_ra8_err_invalid_arg | port out of range. |
Definition at line 745 of file ra8_etha.c.
References r_etha_regs_t::EADQOECN, r_etha_regs_t::EADQSECN, r_etha_regs_t::EAFSECN, r_etha_regs_t::EATFECN, r_etha_regs_t::EAUSMFSECN, ra8_etha_stats_t::frame_size_err, internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_etha_mask_mfs, k_ra8_ok, ra8_etha_stats_t::queue_overflow_err, ra8_etha_stats_t::queue_security_err, RA8_CHECK_NULL_PTR, ra8_etha(), ra8_log_error, s_tag, ra8_etha_stats_t::switch_min_frame_err, and ra8_etha_stats_t::tag_filter_err.
|
nodiscard |
Read one TAS RAM entry back out of hardware.
The TAS entry read flow of HUM Figure 32.15 (Ch 32.4.2.13 "TAS Entry i Read Flow" p 1678): write the address to EATASGR.TASGAR, poll until EATASGRR.GR clears, then take TASGSR and TASGTR[27:0].
This is the read-back that lets a caller assert something real. Without it, the only available evidence that a schedule was programmed is that the programming calls returned k_ra8_ok – which they also did while the driver was writing gate states into the entry-address register.
| [in] | port | Port identifier. |
| [in] | address | TAS RAM entry address (0..k_ra8_etha_tas_addr_max). |
| [out] | out | Entry read back from that address. |
| k_ra8_ok | *out holds the entry at address. |
| k_ra8_err_null_ptr | out is nullptr. |
| k_ra8_err_invalid_arg | port out of range. |
| k_ra8_err_hw_timeout | EATASGRR.GR never cleared within budget. |
Definition at line 361 of file ra8_etha_tas.c.
References r_etha_regs_t::EATASGR, r_etha_regs_t::EATASGRR, ra8_etha_tas_entry_t::gate_open, ra8_etha_tas_entry_t::gate_time_ns, internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_etha_eatasgrr_gr_pos, k_ra8_etha_eatasgrr_tasgsr_pos, k_ra8_etha_mask_tas_gal, k_ra8_etha_mask_tas_gtl, k_ra8_etha_tas_learn_spins, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_etha(), ra8_hw_wait_flag_clear32(), ra8_log_error, and s_tag.
Referenced by tsn_tas_entry_matches().
|
nodiscard |
Configure the RX tag filter (multicast group + VLAN-tag filter).
| [in] | port | Port identifier. |
| [in] | mask | Bit mask written verbatim to EARTFC. Bit positions follow HUM Ch 32 EARTFC: NT, RT, CST, CSRT, CT, CRT, SCT, SCRT, UT. |
| k_ra8_ok | EARTFC = mask. |
| k_ra8_err_invalid_arg | port out of range. |
Definition at line 655 of file ra8_etha.c.
References r_etha_regs_t::EARTFC, internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_etha_local_9bit_mask, k_ra8_ok, ra8_etha(), ra8_log_error, and s_tag.
|
nodiscard |
Programme the time-aware shaper (TAS / 802.1Qbv) gate lists.
Implements the TAS setting flow of HUM Figure 32.11 (Ch 32.4.2.9 "TAS Setting Flow" p 1675-1676) exactly:
queues is indexed by descriptor queue because the TAS RAM is partitioned per queue rather than holding one interleaved list: the entry blocks are laid out in queue order from EATASC.TASCA upward, and an entry's single GS bit belongs to the queue whose block holds it.
| [in] | port | Port identifier. |
| [in] | queues | Per-queue gate lists; k_ra8_etha_tc_count elements. |
| [in] | initial_gate_states | EATASIGSC bitmap – bit q is queue q's gate state at schedule start (HUM Ch 32.3.5.2 p 1647). |
| [in] | cycle_time_ns | Total cycle time, written verbatim to EATASCTC. |
| [in] | start_time | Absolute cycle-start time on the gPTP time base; low word to EATASCSTC0, high word to EATASCSTC1. |
| k_ra8_ok | TAS programmed and committed. |
| k_ra8_err_null_ptr | queues is nullptr, or a queue declares a non-zero count with a nullptr entry list. |
| k_ra8_err_invalid_arg | port out of range, the total entry count exceeds k_ra8_etha_tas_entries_max, or a gate time does not fit TASGTL[27:0]. |
| k_ra8_err_busy | EATASC.TASCI is set; the port cannot accept a configuration change right now. |
| k_ra8_err_hw_timeout | EATASGLR.GL never cleared after a learn. |
Definition at line 313 of file ra8_etha_tas.c.
References r_etha_regs_t::EATASC, internal_port_ok(), internal_tas_learn_all(), internal_tas_program_timing(), internal_tas_validate(), k_ra8_err_busy, k_ra8_err_invalid_arg, k_ra8_etha_eatasc_tasca_pos, k_ra8_etha_eatasc_tascc_pos, k_ra8_etha_eatasc_tasci_pos, k_ra8_etha_eatasc_tase_pos, k_ra8_etha_mask_tas_gal, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_etha(), ra8_log_error, and s_tag.
Referenced by tsn_program_tas().
|
nodiscard |
Configure VLAN tag insertion / extraction for the port.
| [in] | port | Port identifier. |
| [in] | vim | Insertion mode (ra8_etha_vim_t). |
| [in] | vem | Extraction mode (ra8_etha_vem_t). |
| k_ra8_ok | EAVCC updated. |
| k_ra8_err_invalid_arg | port out of range. |
Definition at line 609 of file ra8_etha.c.
References r_etha_regs_t::EAVCC, internal_port_ok(), k_etha_vem_mask, k_ra8_err_invalid_arg, k_ra8_etha_eavcc_vem_pos, k_ra8_ok, ra8_etha(), ra8_log_error, and s_tag.
|
nodiscard |
Programme the C-VLAN and S-VLAN tag values used on TX insertion.
| [in] | port | Port identifier. |
| [in] | c_tag | C-VLAN tag (inner). Pointer to descriptor. |
| [in] | s_tag_in | S-VLAN tag (outer). Pointer to descriptor. |
| k_ra8_ok | EAVTC packed and written. |
| k_ra8_err_null_ptr | c_tag or s_tag is nullptr. |
| k_ra8_err_invalid_arg | port out of range or vid/pcp out of range. |
Definition at line 623 of file ra8_etha.c.
References ra8_etha_vlan_tag_t::dei, r_etha_regs_t::EAVTC, internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_etha_eavtc_ctd_pos, k_ra8_etha_eavtc_ctp_pos, k_ra8_etha_eavtc_ctv_pos, k_ra8_etha_eavtc_std_pos, k_ra8_etha_eavtc_stp_pos, k_ra8_etha_eavtc_stv_pos, k_ra8_etha_mask_vlan_dei, k_ra8_etha_mask_vlan_pcp, k_ra8_etha_mask_vlan_vid, k_ra8_ok, ra8_etha_vlan_tag_t::pcp, RA8_CHECK_NULL_PTR, ra8_etha(), ra8_log_error, s_tag, and ra8_etha_vlan_tag_t::vid.
|
nodiscard |
Reset the TAS RAM and wait for it to report ready.
The TAS RAM reset flow of HUM Figure 32.8 (Ch 32.4.2.6 "TAS RAM Reset Flow" p 1667): write 1 to EATASRIRM.TASRIOG, then poll until EATASRIRM.TASRR reads 1. Hardware clears TASRIOG itself when the initialisation completes. Entries learned before a reset do not survive it, so this runs once during bring-up, ahead of any schedule.
| [in] | port | Port identifier. |
| k_ra8_ok | TAS RAM initialised; EATASRIRM.TASRR reads 1. |
| k_ra8_err_invalid_arg | port out of range. |
| k_ra8_err_hw_timeout | TASRR never asserted within budget. |
Definition at line 244 of file ra8_etha_tas.c.
References r_etha_regs_t::EATASRIRM, internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_etha_eatasrirm_tasriog_pos, k_ra8_etha_eatasrirm_tasrr_pos, k_ra8_etha_tas_ram_spins, k_ra8_ok, ra8_etha(), ra8_hw_wait_flag_set32(), ra8_log_error, and s_tag.
Referenced by tsn_program_tas().