drivers: ethernet: eth_stm32_hal: fix API_V2 multicast

After API_V2 auto-negotiation support was added by #86621
setup_mac_filter() was called before HAL_ETH_Init(), which resulted in
received multicast packets being discarded.

This moves the call to setup_mac_filter() to eth_iface_init(), after
HAL_ETH_Init() for both API_V1 and API_V2.

I've verified the problem and tested the fix on a Nucleo-H563ZI with a
simple application that just starts up and makes an mDNS query (which
depends on working multicast).

Signed-off-by: Kevin ORourke <kevin.orourke@ferroamp.se>
This commit is contained in:
Kevin ORourke 2025-04-09 13:39:53 +02:00 committed by Benjamin Cabé
commit f68eefa6f7

View file

@ -967,11 +967,9 @@ static int eth_initialize(const struct device *dev)
&dma_tx_buffer[0][0], ETH_TXBUFNB); &dma_tx_buffer[0][0], ETH_TXBUFNB);
HAL_ETH_DMARxDescListInit(heth, dma_rx_desc_tab, HAL_ETH_DMARxDescListInit(heth, dma_rx_desc_tab,
&dma_rx_buffer[0][0], ETH_RXBUFNB); &dma_rx_buffer[0][0], ETH_RXBUFNB);
#endif /* !CONFIG_ETH_STM32_HAL_API_V1 */ #endif /* !CONFIG_ETH_STM32_HAL_API_V1 */
setup_mac_filter(heth);
LOG_DBG("MAC %02x:%02x:%02x:%02x:%02x:%02x", LOG_DBG("MAC %02x:%02x:%02x:%02x:%02x:%02x",
dev_data->mac_addr[0], dev_data->mac_addr[1], dev_data->mac_addr[0], dev_data->mac_addr[1],
dev_data->mac_addr[2], dev_data->mac_addr[3], dev_data->mac_addr[2], dev_data->mac_addr[3],
@ -1194,6 +1192,7 @@ static void eth_iface_init(struct net_if *iface)
const struct device *dev; const struct device *dev;
struct eth_stm32_hal_dev_data *dev_data; struct eth_stm32_hal_dev_data *dev_data;
bool is_first_init = false; bool is_first_init = false;
ETH_HandleTypeDef *heth;
__ASSERT_NO_MSG(iface != NULL); __ASSERT_NO_MSG(iface != NULL);
@ -1203,6 +1202,9 @@ static void eth_iface_init(struct net_if *iface)
dev_data = dev->data; dev_data = dev->data;
__ASSERT_NO_MSG(dev_data != NULL); __ASSERT_NO_MSG(dev_data != NULL);
heth = &dev_data->heth;
__ASSERT_NO_MSG(heth != NULL);
if (dev_data->iface == NULL) { if (dev_data->iface == NULL) {
dev_data->iface = iface; dev_data->iface = iface;
is_first_init = true; is_first_init = true;
@ -1227,6 +1229,8 @@ static void eth_iface_init(struct net_if *iface)
eth_init_api_v2(dev); eth_init_api_v2(dev);
#endif #endif
setup_mac_filter(heth);
net_if_carrier_off(iface); net_if_carrier_off(iface);
net_lldp_set_lldpdu(iface); net_lldp_set_lldpdu(iface);