Skip to content

Commit d529074

Browse files
committed
drivers: ethernet: stm32hal: Fixes source address control
The default configuration for all STM32 microcontrollers in HAL is to replace the ehternet MAC address with the address configured in replace address zero. In "modules/hal", Grep for: macDefaultConf.SourceAddrControl = ETH_SOURCEADDRESS_REPLACE_ADDR0; But this is a bad thing for bridging. Since Zephyr ethernet LL code always writes the source address, this patch has no impact on normal operation. And has the benefit of maintaining the source MAC address of bridged packets. Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com>
1 parent 665f600 commit d529074

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

drivers/ethernet/eth_stm32_hal_v1.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ void eth_stm32_set_mac_config(const struct device *dev, struct phy_link_state *s
235235

236236
heth->Init.Speed = PHY_LINK_IS_SPEED_100M(state->speed) ? ETH_SPEED_100M : ETH_SPEED_10M;
237237

238+
/* The default configuration is ETH_SOURCEADDRESS_REPLACE_ADDR0,
239+
* which is bad for bridging. */
240+
mac_config.SourceAddrControl = ETH_SOURCEADDRESS_DISABLE;
241+
238242
hal_ret = HAL_ETH_ConfigMAC(heth, NULL);
239243
if (hal_ret != HAL_OK) {
240244
LOG_ERR("HAL_ETH_ConfigMAC: failed: %d", hal_ret);

drivers/ethernet/eth_stm32_hal_v2.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,10 @@ void eth_stm32_set_mac_config(const struct device *dev, struct phy_link_state *s
653653
? ETH_SPEED_100M
654654
: ETH_SPEED_10M;
655655

656+
/* The default configuration is ETH_SOURCEADDRESS_REPLACE_ADDR0,
657+
* which is bad for bridging. */
658+
mac_config.SourceAddrControl = ETH_SOURCEADDRESS_DISABLE;
659+
656660
hal_ret = HAL_ETH_SetMACConfig(heth, &mac_config);
657661
if (hal_ret != HAL_OK) {
658662
LOG_ERR("HAL_ETH_SetMACConfig failed: %d", hal_ret);

0 commit comments

Comments
 (0)