Skip to content

Commit e63e9f5

Browse files
committedMar 8, 2025
drivers: ethernet: stm32: Add get_config() support
Implementation of get_config() api added Fixes: #84898 Signed-off-by: Ram Mahesh <rammaheshram1234@gmail.com>
1 parent 935c8e4 commit e63e9f5

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
 

‎drivers/ethernet/eth_stm32_hal.c

+42
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,47 @@ static enum ethernet_hw_caps eth_stm32_hal_get_capabilities(const struct device
13581358
;
13591359
}
13601360

1361+
static int eth_stm32_hal_get_config(const struct device *dev, enum ethernet_config_type type,
1362+
struct ethernet_config *config)
1363+
{
1364+
int ret = -ENOTSUP;
1365+
struct eth_stm32_hal_dev_data *dev_data;
1366+
ETH_HandleTypeDef *heth;
1367+
1368+
dev_data = dev->data;
1369+
heth = &dev_data->heth;
1370+
1371+
switch (type) {
1372+
case ETHERNET_CONFIG_TYPE_MAC_ADDRESS:
1373+
memcpy(config->mac_address.addr, dev_data->mac_addr,
1374+
sizeof(config->mac_address.addr));
1375+
ret = 0;
1376+
break;
1377+
case ETHERNET_CONFIG_TYPE_PROMISC_MODE:
1378+
#if defined(CONFIG_NET_PROMISCUOUS_MODE)
1379+
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_ethernet)
1380+
if (heth->Instance->MACPFR & ETH_MACPFR_PR) {
1381+
config->promisc_mode = true;
1382+
} else {
1383+
config->promisc_mode = false;
1384+
}
1385+
#else
1386+
if (heth->Instance->MACFFR & ETH_MACFFR_PM) {
1387+
config->promisc_mode = true;
1388+
} else {
1389+
config->promisc_mode = false;
1390+
}
1391+
#endif /* DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_ethernet) */
1392+
ret = 0;
1393+
#endif /* CONFIG_NET_PROMISCUOUS_MODE */
1394+
break;
1395+
default:
1396+
break;
1397+
}
1398+
1399+
return ret;
1400+
}
1401+
13611402
static int eth_stm32_hal_set_config(const struct device *dev,
13621403
enum ethernet_config_type type,
13631404
const struct ethernet_config *config)
@@ -1449,6 +1490,7 @@ static const struct ethernet_api eth_api = {
14491490
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_mdio)
14501491
.get_phy = eth_stm32_hal_get_phy,
14511492
#endif
1493+
.get_config = eth_stm32_hal_get_config,
14521494
#if defined(CONFIG_NET_DSA)
14531495
.send = dsa_tx,
14541496
#else

0 commit comments

Comments
 (0)