Skip to content

Conversation

juickar
Copy link

@juickar juickar commented Oct 7, 2025

Fix the init call order for V2 API to be able to configure PTP as PTP initialization happens before iface initialization.

Fixes #96197

This solution is the equivalent to the one used in the main branch at this commit: ca6e25a, but it can't be directly applied in the v4.2 branch, as the Ethernet driver is not split between v1 and v2 yet in this version.

@erwango erwango added this to the v4.2.1 milestone Oct 7, 2025
* properly initialized. In auto-negotiation mode, it reads the speed
* and duplex settings to configure the driver accordingly.
*/
eth_init_api_v2(dev);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you test the return value?
By the way, would it make sense to move thee API_V1 also into a eth_init_api_v1() helper function?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a check and moved the v1 init in its own function

Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note there's an extra space char in your Signed-off-by tag (between your name and e-mail address) Compliance Checks CI test complains about.

@juickar juickar force-pushed the v4.2-branch branch 2 times, most recently from 60c59d4 to 558de73 Compare October 7, 2025 12:01
Comment on lines 874 to 876
/* HAL Init time out. This could be linked to */
/* a recoverable error. Log the issue and continue */
/* driver initialisation */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, I think it would be nice to fix the inline comment style:

		/* HAL Init time out. This could be linked to
		 * a recoverable error. Log the issue and continue
		 * driver initialization.
		 */

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(feel free to discard my comment if you prefer)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also fixed it in the v2 function

Fix the init call order for V2 API to be able to configure PTP
as PTP initialization happens before iface initialization.

Signed-off-by: Julien Racki <julien.racki-ext@st.com>
Move the Ethernet API v1 Initialization in eth_init_api_v1()
helper function to match the V2 implementation.

Signed-off-by: Julien Racki <julien.racki-ext@st.com>
Copy link

sonarqubecloud bot commented Oct 7, 2025

@erwango erwango requested a review from maass-hamburg October 7, 2025 13:55
Copy link
Member

@maass-hamburg maass-hamburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little nit, but fine for a fix, that will only be applied to a past version and not to main.

Comment on lines 1001 to +1004
#if defined(CONFIG_ETH_STM32_HAL_API_V1)
HAL_StatusTypeDef hal_ret = HAL_OK;

if (!ETH_STM32_AUTO_NEGOTIATION_ENABLE) {
struct phy_link_state state;

phy_get_link_state(eth_stm32_phy_dev, &state);

heth->Init.DuplexMode = PHY_LINK_IS_FULL_DUPLEX(state.speed) ? ETH_MODE_FULLDUPLEX
: ETH_MODE_HALFDUPLEX;
heth->Init.Speed =
PHY_LINK_IS_SPEED_100M(state.speed) ? ETH_SPEED_100M : ETH_SPEED_10M;
}
ret = eth_init_api_v1(dev);
#elif defined(CONFIG_ETH_STM32_HAL_API_V2)
ret = eth_init_api_v2(dev);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could share a common function name

@erwango
Copy link
Member

erwango commented Oct 7, 2025

@dkalowsk, @danieldegrasse FYI, this one is a bit specific as no backport possible.

@danieldegrasse danieldegrasse merged commit 6da1cbc into zephyrproject-rtos:v4.2-branch Oct 7, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants