|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Per-port Ethernet MAC (RMAC) driver – HUM Ch 33. More...
Go to the source code of this file.
Data Structures | |
| struct | ra8_rmac_config_t |
| Per-port RMAC configuration knobs. More... | |
| struct | ra8_rmac_phy_link_t |
| Resolved PHY link status snapshot. More... | |
| struct | ra8_rmac_status_t |
| Snapshot of an RMAC port's runtime state. More... | |
| struct | ra8_rmac_stats_t |
| Snapshot of every RMAC statistic counter. More... | |
Typedefs | |
| typedef void(* | ra8_rmac_event_fn_t) (void *ctx, ra8_rmac_port_t port, uint32_t err_msk, uint32_t mon0_msk, uint32_t mon1_msk, uint32_t mon2_msk) |
| Per-port RMAC IRQ callback. | |
Enumerations | |
| enum | ra8_rmac_mdc_clk_t : uint32_t { k_ra8_rmac_mdc_default_hz = 1000000UL , k_ra8_rmac_mdc_min_hz = 100000UL , k_ra8_rmac_mdc_psmcs_max = 127UL } |
| MPIC PHY-station-management clock-rate constants. More... | |
| enum | ra8_rmac_phy_speed_t : uint8_t { k_ra8_rmac_phy_speed_unknown = 0U , k_ra8_rmac_phy_speed_10_hd = 1U , k_ra8_rmac_phy_speed_10_fd = 2U , k_ra8_rmac_phy_speed_100_hd = 3U , k_ra8_rmac_phy_speed_100_fd = 4U , k_ra8_rmac_phy_speed_count = 5U } |
| Resolved PHY link speed/duplex. More... | |
| enum | ra8_rmac_phy_advert_t : uint16_t { k_ra8_rmac_phy_advert_10_hd = 0x0020U , k_ra8_rmac_phy_advert_10_fd = 0x0040U , k_ra8_rmac_phy_advert_100_hd = 0x0080U , k_ra8_rmac_phy_advert_100_fd = 0x0100U , k_ra8_rmac_phy_advert_pause = 0x0400U } |
| 802.3 Clause 22 ANAR (auto-negotiation advertisement) bits. More... | |
Functions | |
| ra8_err_t | ra8_rmac_init (ra8_rmac_port_t port, const ra8_rmac_config_t *cfg) |
| Initialise an RMAC port (MSTP gate + reset regs + filter mode). | |
| ra8_err_t | ra8_rmac_deinit (ra8_rmac_port_t port) |
| Tear down an RMAC port. | |
| ra8_err_t | ra8_rmac_enter_stop (ra8_rmac_port_t port) |
| Enter low-power "stop" by disabling RX address filtering. | |
| ra8_err_t | ra8_rmac_exit_stop (ra8_rmac_port_t port) |
| Exit low-power "stop" by reasserting the saved RX filter. | |
| ra8_err_t | ra8_rmac_set_mac_address (ra8_rmac_port_t port, const uint8_t mac[k_ra8_rmac_mac_byte_count]) |
| Program the reception MAC address (MRMAC0 / MRMAC1). | |
| ra8_err_t | ra8_rmac_set_rx_filter (ra8_rmac_port_t port, ra8_rmac_mrafc_t filter) |
| Program the RX address filter mask (MRAFC). | |
| ra8_err_t | ra8_rmac_set_ptp_filter (ra8_rmac_port_t port, uint8_t index, uint8_t byte_offset, uint8_t value, bool tef0, bool tef1) |
| Program a PTP-frame filter table entry (MPFCt, t = 0..15). | |
| ra8_err_t | ra8_rmac_set_frame_size (ra8_rmac_port_t port, bool is_pframe, uint16_t min_size, uint16_t max_size) |
| Configure jumbo-frame minimum / maximum sizes. | |
| ra8_err_t | ra8_rmac_set_vlan_framing (ra8_rmac_port_t port, bool disable_pad, bool use_mcrc) |
| Configure VLAN double-tagging behaviour via MTFFC. | |
| ra8_err_t | ra8_rmac_set_pause_frame (ra8_rmac_port_t port, ra8_rmac_pause_mode_t mode, uint16_t pause_time, uint8_t retry_time, uint8_t retry_level) |
| Program a TX pause / PFC frame template. | |
| ra8_err_t | ra8_rmac_set_pfc_group (ra8_rmac_port_t port, ra8_rmac_pfc_group_t group, uint8_t pcp_mask) |
| Configure a PFC (802.1Qbb) priority group bitmap. | |
| ra8_err_t | ra8_rmac_set_lpi (ra8_rmac_port_t port, bool enable) |
| Enable / disable Energy Efficient Ethernet LPI request. | |
| ra8_err_t | ra8_rmac_set_magic_packet (ra8_rmac_port_t port, bool enable) |
| Enable / disable magic-packet wake-on-LAN detection. | |
| ra8_err_t | ra8_rmac_set_loopback (ra8_rmac_port_t port, bool enable) |
| Enable / disable internal MAC loopback. | |
| ra8_err_t | ra8_rmac_set_link (ra8_rmac_port_t port, ra8_rmac_pis_t iface, ra8_rmac_lsc_t speed, ra8_rmac_duplex_t duplex) |
| Configure the link layer (interface, speed, duplex) atomically. | |
| ra8_err_t | ra8_rmac_mdio_c22_read (ra8_rmac_port_t port, uint8_t phy_addr, uint8_t reg_addr, uint16_t *out_value) |
| Trigger an MDIO Clause-22 register read on the off-chip PHY. | |
| ra8_err_t | ra8_rmac_mdio_c22_write (ra8_rmac_port_t port, uint8_t phy_addr, uint8_t reg_addr, uint16_t value) |
| Trigger an MDIO Clause-22 register write on the off-chip PHY. | |
| ra8_err_t | ra8_rmac_mdio_c45_read (ra8_rmac_port_t port, uint8_t phy_addr, uint8_t dev_addr, uint16_t reg_addr, uint16_t *out_value) |
| Trigger an MDIO Clause-45 register read. | |
| ra8_err_t | ra8_rmac_mdio_c45_write (ra8_rmac_port_t port, uint8_t phy_addr, uint8_t dev_addr, uint16_t reg_addr, uint16_t value) |
| Trigger an MDIO Clause-45 register write. | |
| ra8_err_t | ra8_rmac_get_status (ra8_rmac_port_t port, ra8_rmac_status_t *out) |
| Read a port's status snapshot (MEIS + MMIS0..2 + MPIM + MAC). | |
| ra8_err_t | ra8_rmac_clear_status (ra8_rmac_port_t port, uint32_t err_mask, uint32_t mon0_mask, uint32_t mon1_mask, uint32_t mon2_mask) |
| Clear bits in MEIS / MMIS0 / MMIS1 / MMIS2. | |
| ra8_err_t | ra8_rmac_read_stats (ra8_rmac_port_t port, ra8_rmac_stats_t *out) |
| Read the full statistic counter snapshot (HUM Ch 33.4). | |
| ra8_err_t | ra8_rmac_attach_handler (ra8_rmac_port_t port, ra8_rmac_event_fn_t cb, void *ctx) |
| Attach a per-port IRQ handler for RMAC events. | |
| void | ra8_rmac_dispatch (ra8_rmac_port_t port) |
| Dispatch a pending RMAC IRQ. | |
| ra8_err_t | ra8_rmac_phy_reset (ra8_rmac_port_t port, uint8_t phy_addr) |
| Software-reset an off-chip PHY via Clause-22 MDIO. | |
| ra8_err_t | ra8_rmac_phy_set_advertise (ra8_rmac_port_t port, uint8_t phy_addr, uint16_t capabilities) |
| Program the off-chip PHY's auto-negotiation advertisement. | |
| ra8_err_t | ra8_rmac_phy_auto_neg_start (ra8_rmac_port_t port, uint8_t phy_addr) |
| Kick off (or restart) auto-negotiation on the off-chip PHY. | |
| ra8_err_t | ra8_rmac_phy_auto_neg_wait (ra8_rmac_port_t port, uint8_t phy_addr, uint32_t timeout_ms, ra8_rmac_phy_link_t *out_link) |
| Block (with a bounded poll) until the PHY reports AN_COMPLETE. | |
| ra8_err_t | ra8_rmac_phy_link_status (ra8_rmac_port_t port, uint8_t phy_addr, ra8_rmac_phy_link_t *out_link) |
| Quick poll of BMSR.LINK_STATUS (no auto-neg block). | |
Per-port Ethernet MAC (RMAC) driver – HUM Ch 33.
Full HAL coverage of the RA8D2 RMAC block (HUM Ch 33, p 1703-1786). RMAC is the on-chip MAC layer that talks to an off-chip PHY over MII / RMII / GMII / RGMII / XGMII / XFI. It sits between the per-port Ethernet Agent (ETHA, see ra8_etha.h) above and the off-chip PHY below:
* ESWM (Ch 29, switch fabric) -- top * | * ETHA (Ch 32, per-port agent) * | * RMAC (Ch 33, per-port MAC) <-- this driver * | * off-chip PHY -- bottom *
The driver exposes every register field documented in HUM Ch 33.4 except those owned by ra8_eth_gptp (PTP timestamping). The split is:
Definition in file ra8_rmac.h.
| typedef void(* ra8_rmac_event_fn_t) (void *ctx, ra8_rmac_port_t port, uint32_t err_msk, uint32_t mon0_msk, uint32_t mon1_msk, uint32_t mon2_msk) |
Per-port RMAC IRQ callback.
| [in] | ctx | Caller-supplied opaque cookie. |
| [in] | port | Port that raised the event. |
| [in] | err_msk | Snapshot of MEIS at dispatch time. |
| [in] | mon0_msk | Snapshot of MMIS0 at dispatch time. |
| [in] | mon1_msk | Snapshot of MMIS1 at dispatch time. |
| [in] | mon2_msk | Snapshot of MMIS2 at dispatch time. |
Definition at line 290 of file ra8_rmac.h.
| enum ra8_rmac_mdc_clk_t : uint32_t |
MPIC PHY-station-management clock-rate constants.
The MPIC register packs three MDC-related fields:
Exposed publicly so the board-level bring-up code can pick a conservative mdc_hz target without having to know the PSMCS field width. IEEE 802.3 Clause 22 caps MDC at 2.5 MHz; the GPY111 / PEF7071 family is happy at 1 MHz which is what the default constant below provides.
Cross-checked against FSP r_rmac_phy_calculate_mpic and CMSIS R7KA8D2KF_core0.h R_RMAC0_MPIC_PSMCS_Pos / PSMHT_Pos / PSMCT_Pos.
Definition at line 105 of file ra8_rmac.h.
| enum ra8_rmac_phy_advert_t : uint16_t |
802.3 Clause 22 ANAR (auto-negotiation advertisement) bits.
These match the IEEE 802.3 Clause 28.2.4 ANAR register bit layout for 10/100M abilities. Pass any bitwise OR to ra8_rmac_phy_set_advertise. The selector field (bits 0-4) is set to 00001 (IEEE 802.3) by the helper; callers do not need to include it.
Definition at line 196 of file ra8_rmac.h.
| enum ra8_rmac_phy_speed_t : uint8_t |
Resolved PHY link speed/duplex.
Returned by ra8_rmac_phy_auto_neg_wait once the off-chip PHY's IEEE 802.3 Clause 22 BMSR.AN_COMPLETE bit asserts. Encodes the highest-priority capability common to both link partners (the PHY itself decodes the LPA register and presents the resolved value).
Definition at line 160 of file ra8_rmac.h.
|
nodiscard |
Attach a per-port IRQ handler for RMAC events.
| [in] | port | Port identifier. |
| [in] | cb | Callback (nullptr to detach). |
| [in] | ctx | Opaque cookie passed back to cb. |
Definition at line 934 of file ra8_rmac.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, ra8_log_error, s_slots, and s_tag.
|
nodiscard |
Clear bits in MEIS / MMIS0 / MMIS1 / MMIS2.
| [in] | port | Port identifier. |
| [in] | err_mask | Bits to clear in MEIS via MEID. |
| [in] | mon0_mask | Bits to clear in MMIS0 via MMID0. |
| [in] | mon1_mask | Bits to clear in MMIS1 via MMID1. |
| [in] | mon2_mask | Bits to clear in MMIS2 via MMID2. |
Definition at line 118 of file ra8_rmac_mgmt.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, r_rmac_regs_t::MEID, r_rmac_regs_t::MEIS, r_rmac_regs_t::MMID0, r_rmac_regs_t::MMID1, r_rmac_regs_t::MMID2, r_rmac_regs_t::MMIS0, r_rmac_regs_t::MMIS1, r_rmac_regs_t::MMIS2, ra8_log_error, ra8_rmac(), and s_tag.
|
nodiscard |
Tear down an RMAC port.
| [in] | port | Port identifier. |
| k_ra8_ok | Port stopped, regs cleared. |
| k_ra8_err_invalid_arg | port out of range. |
Definition at line 515 of file ra8_rmac.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, r_rmac_regs_t::MEEEC, r_rmac_regs_t::MEIE, r_rmac_regs_t::MLBC, r_rmac_regs_t::MMIE0, r_rmac_regs_t::MMIE1, r_rmac_regs_t::MMIE2, r_rmac_regs_t::MRAFC, r_rmac_regs_t::MRGC, r_rmac_regs_t::MTFFC, ra8_log_error, ra8_rmac(), s_slots, and s_tag.
Referenced by ra8_eth_close().
| void ra8_rmac_dispatch | ( | ra8_rmac_port_t | port | ) |
Dispatch a pending RMAC IRQ.
| [in] | port | Port identifier. |
Reads MEIS / MMIS0..2 atomically, clears every observed bit through the matching MEID / MMID register, then invokes the attached callback with the snapshot. Designed to be called from the NVIC ISR registered for the RMAC error / monitor interrupt vectors.
Definition at line 946 of file ra8_rmac.c.
References internal_port_ok(), r_rmac_regs_t::MEID, r_rmac_regs_t::MEIS, r_rmac_regs_t::MMID0, r_rmac_regs_t::MMID1, r_rmac_regs_t::MMID2, r_rmac_regs_t::MMIS0, r_rmac_regs_t::MMIS1, r_rmac_regs_t::MMIS2, ra8_rmac(), and s_slots.
|
nodiscard |
Enter low-power "stop" by disabling RX address filtering.
| [in] | port | Port identifier. |
Definition at line 551 of file ra8_rmac.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, r_rmac_regs_t::MRAFC, ra8_log_error, ra8_rmac(), and s_tag.
|
nodiscard |
Exit low-power "stop" by reasserting the saved RX filter.
| [in] | port | Port identifier. |
Definition at line 562 of file ra8_rmac.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, r_rmac_regs_t::MRAFC, ra8_log_error, ra8_rmac(), s_slots, and s_tag.
|
nodiscard |
Read a port's status snapshot (MEIS + MMIS0..2 + MPIM + MAC).
| [in] | port | Port identifier. |
| [out] | out | Destination for the status snapshot. |
Definition at line 92 of file ra8_rmac_mgmt.c.
References ra8_rmac_status_t::err_status, internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, r_rmac_regs_t::MEIS, r_rmac_regs_t::MMIS0, r_rmac_regs_t::MMIS1, r_rmac_regs_t::MMIS2, ra8_rmac_status_t::mon_status, r_rmac_regs_t::MPIM, r_rmac_regs_t::MRMAC0, ra8_rmac_status_t::mrmac0, r_rmac_regs_t::MRMAC1, ra8_rmac_status_t::mrmac1, ra8_rmac_status_t::phy_monitor, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac(), and s_tag.
|
nodiscard |
Initialise an RMAC port (MSTP gate + reset regs + filter mode).
| [in] | port | Port identifier (k_ra8_rmac_port_0 or _1). |
| [in] | cfg | Per-port configuration. Must not be nullptr. |
| k_ra8_ok | Port brought up. |
| k_ra8_err_null_ptr | cfg is nullptr. |
| k_ra8_err_invalid_arg | port out of range or cfg field invalid. |
Definition at line 481 of file ra8_rmac.c.
References internal_pis_ok(), internal_port_ok(), internal_program_irq_block(), internal_program_mac_config(), k_ra8_err_invalid_arg, k_ra8_mstp_eswm, k_ra8_ok, k_ra8_rmac_lsc_count, ra8_rmac_config_t::link_speed, ra8_rmac_config_t::phy_interface, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_log_info, ra8_mstp_enable(), RA8_RETURN_ON_ERROR, ra8_rmac(), ra8_rmac_config_t::rx_filter, s_slots, and s_tag.
Referenced by internal_eth_rmac_program().
|
nodiscard |
Trigger an MDIO Clause-22 register read on the off-chip PHY.
| [in] | port | Port identifier. |
| [in] | phy_addr | 5-bit PHY address (0..31). |
| [in] | reg_addr | 5-bit register address (0..31). |
| [out] | out_value | 16-bit register value on success. |
| k_ra8_ok | Read complete, *out_value populated. |
| k_ra8_err_null_ptr | out_value is nullptr. |
| k_ra8_err_hw_timeout | MMIS1.PRACS never set within the bounded poll. |
Definition at line 811 of file ra8_rmac.c.
References internal_mdio_drain(), internal_mdio_wait(), internal_mpsm_issue(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mask_mpsm_data, k_ra8_rmac_mdio_op_c22_read, k_ra8_rmac_mmis1_pracs, k_ra8_rmac_shift_mpsm_prd, r_rmac_regs_t::MPSM, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac(), and s_tag.
Referenced by internal_eth_phy_set_rgmii_skew(), internal_eth_phy_soft_reset(), internal_phy_read_link(), internal_query_negotiated_speed(), internal_wait_for_autoneg(), ra8_rmac_phy_auto_neg_wait(), ra8_rmac_phy_link_status(), and ra8_rmac_phy_reset().
|
nodiscard |
Trigger an MDIO Clause-22 register write on the off-chip PHY.
| [in] | port | Port identifier. |
| [in] | phy_addr | 5-bit PHY address. |
| [in] | reg_addr | 5-bit register address. |
| [in] | value | 16-bit value to drive into the PHY register. |
Definition at line 842 of file ra8_rmac.c.
References internal_mdio_drain(), internal_mdio_wait(), internal_mpsm_issue(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mdio_op_c22_write, k_ra8_rmac_mmis1_pwacs, ra8_log_error, ra8_rmac(), and s_tag.
Referenced by internal_eth_phy_set_rgmii_skew(), internal_eth_phy_soft_reset(), internal_eth_phy_start_autoneg(), ra8_rmac_phy_auto_neg_start(), ra8_rmac_phy_reset(), and ra8_rmac_phy_set_advertise().
|
nodiscard |
Trigger an MDIO Clause-45 register read.
| [in] | port | Port identifier. |
| [in] | phy_addr | 5-bit PHY address. |
| [in] | dev_addr | 5-bit MMD device address. |
| [in] | reg_addr | 16-bit MMD register address. |
| [out] | out_value | 16-bit register value on success. |
| k_ra8_ok | Read complete. |
| k_ra8_err_null_ptr | out_value is nullptr. |
| k_ra8_err_hw_timeout | MMIS1 completion bit never asserted. |
Definition at line 859 of file ra8_rmac.c.
References internal_mdio_drain(), internal_mdio_wait(), internal_mpsm_issue(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mask_mpsm_data, k_ra8_rmac_mdio_op_c45_address, k_ra8_rmac_mdio_op_c45_read, k_ra8_rmac_mmis1_paacs, k_ra8_rmac_mmis1_pracs, k_ra8_rmac_shift_mpsm_prd, r_rmac_regs_t::MPSM, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac(), and s_tag.
|
nodiscard |
Trigger an MDIO Clause-45 register write.
| [in] | port | Port identifier. |
| [in] | phy_addr | 5-bit PHY address. |
| [in] | dev_addr | 5-bit MMD device address. |
| [in] | reg_addr | 16-bit MMD register address. |
| [in] | value | 16-bit value to drive into the MMD register. |
Definition at line 902 of file ra8_rmac.c.
References internal_mdio_drain(), internal_mdio_wait(), internal_mpsm_issue(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mdio_op_c45_address, k_ra8_rmac_mdio_op_c45_write, k_ra8_rmac_mmis1_paacs, k_ra8_rmac_mmis1_pwacs, ra8_log_error, ra8_rmac(), and s_tag.
|
nodiscard |
Kick off (or restart) auto-negotiation on the off-chip PHY.
Sets IEEE 802.3 Clause 22 BMCR.AN_ENABLE (bit 12) and BMCR.AN_RESTART (bit 9) in a single MDIO write. Pair this call with ra8_rmac_phy_auto_neg_wait to block until the PHY reports AN_COMPLETE in BMSR.
| [in] | port | Port identifier. |
| [in] | phy_addr | 5-bit PHY address. |
| k_ra8_ok | AN restart issued. |
| k_ra8_err_invalid_arg | port or phy_addr out of range. |
| k_ra8_err_hw_timeout | MDIO transaction never completed. |
Definition at line 380 of file ra8_rmac_mgmt.c.
References internal_phy_args_ok(), k_ra8_err_invalid_arg, k_ra8_rmac_phy_bmcr_an_enable, k_ra8_rmac_phy_bmcr_an_restart, k_ra8_rmac_phy_reg_bmcr, ra8_log_error, ra8_rmac_mdio_c22_write(), and s_tag.
Referenced by ra8_etha_open().
|
nodiscard |
Block (with a bounded poll) until the PHY reports AN_COMPLETE.
Reads IEEE 802.3 Clause 22 BMSR (register 1) in a loop; each iteration costs one MDIO transaction. Returns success when both BMSR.AN_COMPLETE (bit 5) and BMSR.LINK_STATUS (bit 2) are observed set in the same read. The resolved speed/duplex is decoded from the negotiated 10/100 capability bits in ANLPAR (register 5) once AN_COMPLETE asserts.
| [in] | port | Port identifier. |
| [in] | phy_addr | 5-bit PHY address. |
| [in] | timeout_ms | Maximum wait in milliseconds (0 -> internal cap). |
| [out] | out_link | Resolved link state on success. |
| k_ra8_ok | AN_COMPLETE + LINK_STATUS observed. |
| k_ra8_err_null_ptr | out_link is nullptr. |
| k_ra8_err_invalid_arg | port or phy_addr out of range. |
| k_ra8_err_hw_timeout | AN_COMPLETE never asserted. |
Definition at line 394 of file ra8_rmac_mgmt.c.
References internal_decode_anlpar(), internal_phy_args_ok(), k_ra8_err_hw_timeout, k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_phy_anwait_iter_cap, k_ra8_rmac_phy_anwait_iters_per_ms, k_ra8_rmac_phy_bmsr_an_done, k_ra8_rmac_phy_bmsr_link_up, k_ra8_rmac_phy_reg_anlpar, k_ra8_rmac_phy_reg_bmsr, k_ra8_rmac_phy_speed_unknown, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac_mdio_c22_read(), s_tag, ra8_rmac_phy_link_t::speed, and ra8_rmac_phy_link_t::up.
Referenced by ra8_etha_open().
|
nodiscard |
Quick poll of BMSR.LINK_STATUS (no auto-neg block).
Single MDIO read of IEEE 802.3 Clause 22 BMSR. Reports up/down via out_link->up. When up is true the speed field is decoded from ANLPAR if AN_COMPLETE is set, otherwise it is left as k_ra8_rmac_phy_speed_unknown.
| [in] | port | Port identifier. |
| [in] | phy_addr | 5-bit PHY address. |
| [out] | out_link | Destination for the snapshot. |
| k_ra8_ok | BMSR read OK. |
| k_ra8_err_null_ptr | out_link is nullptr. |
| k_ra8_err_invalid_arg | port or phy_addr out of range. |
| k_ra8_err_hw_timeout | MDIO transaction never completed. |
Definition at line 444 of file ra8_rmac_mgmt.c.
References internal_decode_anlpar(), internal_phy_args_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_phy_bmsr_an_done, k_ra8_rmac_phy_bmsr_link_up, k_ra8_rmac_phy_reg_anlpar, k_ra8_rmac_phy_reg_bmsr, k_ra8_rmac_phy_speed_unknown, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac_mdio_c22_read(), s_tag, ra8_rmac_phy_link_t::speed, and ra8_rmac_phy_link_t::up.
|
nodiscard |
Software-reset an off-chip PHY via Clause-22 MDIO.
Writes IEEE 802.3 Clause 22 BMCR.RESET (bit 15), then polls BMCR until the reset bit self-clears or a bounded poll budget is exhausted.
| [in] | port | Port identifier (k_ra8_rmac_port_0 / _1). |
| [in] | phy_addr | 5-bit PHY address on the MDIO bus (0..31). |
| k_ra8_ok | PHY reset complete. |
| k_ra8_err_invalid_arg | port or phy_addr out of range. |
| k_ra8_err_hw_timeout | BMCR.RESET never self-cleared. |
Definition at line 332 of file ra8_rmac_mgmt.c.
References internal_phy_args_ok(), k_ra8_err_hw_timeout, k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_phy_bmcr_reset, k_ra8_rmac_phy_reg_bmcr, k_ra8_rmac_phy_reset_iter_cap, ra8_log_error, ra8_rmac_mdio_c22_read(), ra8_rmac_mdio_c22_write(), and s_tag.
Referenced by ra8_etha_open().
|
nodiscard |
Program the off-chip PHY's auto-negotiation advertisement.
Writes the IEEE 802.3 Clause 22 ANAR register (register 4) with the supplied capability mask plus the IEEE 802.3 selector field (00001 in bits [4:0]). After updating the advertisement, callers typically invoke ra8_rmac_phy_auto_neg_start to cause the PHY to restart auto-negotiation with the new capabilities.
| [in] | port | Port identifier. |
| [in] | phy_addr | 5-bit PHY address (0..31). |
| [in] | capabilities | OR of ra8_rmac_phy_advert_t bits. |
| k_ra8_ok | ANAR programmed. |
| k_ra8_err_invalid_arg | port or phy_addr out of range. |
| k_ra8_err_hw_timeout | MDIO transaction never completed. |
Definition at line 368 of file ra8_rmac_mgmt.c.
References internal_phy_args_ok(), k_ra8_err_invalid_arg, k_ra8_rmac_phy_anar_selector, k_ra8_rmac_phy_reg_anar, ra8_log_error, ra8_rmac_mdio_c22_write(), and s_tag.
Referenced by ra8_etha_open().
|
nodiscard |
Read the full statistic counter snapshot (HUM Ch 33.4).
| [in] | port | Port identifier. |
| [out] | out | Destination for the counter snapshot. |
Definition at line 259 of file ra8_rmac_mgmt.c.
References internal_port_ok(), internal_snapshot_pause_pfc(), internal_snapshot_rx(), internal_snapshot_tx(), k_ra8_err_invalid_arg, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac(), and s_tag.
|
nodiscard |
Configure jumbo-frame minimum / maximum sizes.
| [in] | port | Port identifier. |
| [in] | is_pframe | true for P-frames (MRFSCP), false for E-frames (MRFSCE). |
| [in] | min_size | Minimum accepted frame size (bytes). |
| [in] | max_size | Maximum accepted frame size (bytes, up to 16383). |
Definition at line 652 of file ra8_rmac.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mask_mrfsc, k_ra8_rmac_shift_mrfsce_max, k_ra8_rmac_shift_mrfsce_min, r_rmac_regs_t::MRFSCE, r_rmac_regs_t::MRFSCP, ra8_log_error, ra8_rmac(), and s_tag.
|
nodiscard |
Configure the link layer (interface, speed, duplex) atomically.
| [in] | port | Port identifier. |
| [in] | iface | PHY-side interface (GMII / MII / RMII / RGMII / XGMII). |
| [in] | speed | Link speed (10 / 100 / 1000 / 2500 / 10000 Mbit/s). |
| [in] | duplex | Half / full duplex. |
Definition at line 782 of file ra8_rmac.c.
References internal_make_mpic(), internal_pis_ok(), internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_lsc_count, k_ra8_rmac_mask_mpic_psmcs, k_ra8_rmac_shift_mpic_psmcs, r_rmac_regs_t::MPIC, ra8_log_error, ra8_rmac(), and s_tag.
Referenced by internal_program_mpic().
|
nodiscard |
Enable / disable internal MAC loopback.
| [in] | port | Port identifier. |
| [in] | enable | true to short TX -> RX inside the MAC. |
Definition at line 767 of file ra8_rmac.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mlbc_lbme, r_rmac_regs_t::MLBC, ra8_log_error, ra8_rmac(), and s_tag.
|
nodiscard |
Enable / disable Energy Efficient Ethernet LPI request.
| [in] | port | Port identifier. |
| [in] | enable | true to assert TX LPI; false to clear. |
Definition at line 734 of file ra8_rmac.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_meeec_lpitr, r_rmac_regs_t::MEEEC, ra8_log_error, ra8_rmac(), and s_tag.
|
nodiscard |
Program the reception MAC address (MRMAC0 / MRMAC1).
| [in] | port | Port identifier. |
| [in] | mac | 6-byte network-byte-order MAC address (mac[0] = OUI hi). |
| k_ra8_ok | MAC address programmed. |
| k_ra8_err_null_ptr | mac is nullptr. |
| k_ra8_err_invalid_arg | port out of range. |
Definition at line 573 of file ra8_rmac.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mac_byte_0, k_ra8_rmac_mac_byte_1, k_ra8_rmac_mac_byte_2, k_ra8_rmac_mac_byte_3, k_ra8_rmac_mac_byte_4, k_ra8_rmac_mac_byte_5, k_ra8_rmac_mac_byte_count, k_ra8_rmac_mask_byte, k_ra8_rmac_mask_mrmac0_mau, k_ra8_rmac_shift_byte0, k_ra8_rmac_shift_byte1, k_ra8_rmac_shift_byte2, k_ra8_rmac_shift_byte3, k_ra8_rmac_shift_high16, k_ra8_rmac_shift_high24, r_rmac_regs_t::MRMAC0, r_rmac_regs_t::MRMAC1, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_rmac(), and s_tag.
Referenced by internal_bring_up_rmac().
|
nodiscard |
Enable / disable magic-packet wake-on-LAN detection.
| [in] | port | Port identifier. |
| [in] | enable | true arms detection; false disarms. |
Definition at line 749 of file ra8_rmac.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mrgc_mpde, r_rmac_regs_t::MRGC, ra8_log_error, ra8_rmac(), and s_tag.
|
nodiscard |
Program a TX pause / PFC frame template.
| [in] | port | Port identifier. |
| [in] | mode | Pause-vs-PFC (MTPFC2.PFM). |
| [in] | pause_time | 16-bit pause quanta (MTPFC.PT). |
| [in] | retry_time | 8-bit retry threshold (MTPFC.PFRT). |
| [in] | retry_level | 5-bit retry-level (MTPFC.PFRLV). |
Definition at line 692 of file ra8_rmac.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mask_mtpfc_pfrt, k_ra8_rmac_mask_mtpfc_pt, k_ra8_rmac_pause_mode_pfc, k_ra8_rmac_shift_mtpfc2_pfm, k_ra8_rmac_shift_mtpfc_pfrlv, k_ra8_rmac_shift_mtpfc_pfrt, k_ra8_rmac_shift_mtpfc_pt, k_rmac_pfrlv_mask, r_rmac_regs_t::MTPFC, r_rmac_regs_t::MTPFC2, ra8_log_error, ra8_rmac(), and s_tag.
|
nodiscard |
Configure a PFC (802.1Qbb) priority group bitmap.
| [in] | port | Port identifier. |
| [in] | group | Priority group index (0..1). |
| [in] | pcp_mask | 8-bit PCP-priority bitmap. |
Definition at line 719 of file ra8_rmac.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mask_pfc_priority, k_ra8_rmac_pfc_group_count, r_rmac_regs_t::MTPFC3, ra8_log_error, ra8_rmac(), and s_tag.
|
nodiscard |
Program a PTP-frame filter table entry (MPFCt, t = 0..15).
| [in] | port | Port identifier. |
| [in] | index | Slot index (0..15). |
| [in] | byte_offset | Offset into the frame payload to test. |
| [in] | value | Reference byte value to compare. |
| [in] | tef0 | true to flag GPTP TX-event-frame trigger 0. |
| [in] | tef1 | true to flag GPTP TX-event-frame trigger 1. |
Definition at line 621 of file ra8_rmac.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mask_byte, k_ra8_rmac_ptp_filter_count, k_ra8_rmac_shift_mpfc_te0, k_ra8_rmac_shift_mpfc_te1, k_ra8_rmac_shift_mpfc_val, r_rmac_regs_t::MPFC, ra8_log_error, ra8_rmac(), and s_tag.
|
nodiscard |
Program the RX address filter mask (MRAFC).
| [in] | port | Port identifier. |
| [in] | filter | Bitwise OR of ra8_rmac_mrafc_t values. |
Definition at line 609 of file ra8_rmac.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, r_rmac_regs_t::MRAFC, ra8_log_error, ra8_rmac(), s_slots, and s_tag.
|
nodiscard |
Configure VLAN double-tagging behaviour via MTFFC.
| [in] | port | Port identifier. |
| [in] | disable_pad | true to disable TX pad (DPAD). |
| [in] | use_mcrc | true to use mCRC framing instead of standard CRC (FCM). |
Definition at line 674 of file ra8_rmac.c.
References internal_port_ok(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_rmac_mtffc_dpad, k_ra8_rmac_mtffc_fcm, r_rmac_regs_t::MTFFC, ra8_log_error, ra8_rmac(), and s_tag.