drivers: eth: Replace driver specific RANDOM_MAC Kconfig with devicetree
Utilize the devicetree property "zephyr,random-mac-address" to determine if a driver should use a random mac address and remove the associated Kconfig options that enabled this feature. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
ce0d50c2b0
commit
1de61b4c42
12 changed files with 14 additions and 72 deletions
|
@ -16,10 +16,6 @@ config NET_L2_ETHERNET
|
||||||
config ETH_SAM_GMAC
|
config ETH_SAM_GMAC
|
||||||
default y if NET_L2_ETHERNET
|
default y if NET_L2_ETHERNET
|
||||||
|
|
||||||
choice ETH_SAM_GMAC_MAC_SELECT
|
|
||||||
default ETH_SAM_GMAC_RANDOM_MAC
|
|
||||||
endchoice
|
|
||||||
|
|
||||||
endif # NETWORKING
|
endif # NETWORKING
|
||||||
|
|
||||||
endif # BOARD_ATSAME54_XPRO
|
endif # BOARD_ATSAME54_XPRO
|
||||||
|
|
|
@ -85,4 +85,5 @@
|
||||||
|
|
||||||
&gmac {
|
&gmac {
|
||||||
status = "okay";
|
status = "okay";
|
||||||
|
zephyr,random-mac-address;
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,10 +28,6 @@ config NET_L2_ETHERNET
|
||||||
config ETH_SAM_GMAC
|
config ETH_SAM_GMAC
|
||||||
default y if NET_L2_ETHERNET
|
default y if NET_L2_ETHERNET
|
||||||
|
|
||||||
choice ETH_SAM_GMAC_MAC_SELECT
|
|
||||||
default ETH_SAM_GMAC_RANDOM_MAC
|
|
||||||
endchoice
|
|
||||||
|
|
||||||
endif # NETWORKING
|
endif # NETWORKING
|
||||||
|
|
||||||
endif # BOARD_SAM4E_XPRO
|
endif # BOARD_SAM4E_XPRO
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
|
|
||||||
&gmac {
|
&gmac {
|
||||||
status = "okay";
|
status = "okay";
|
||||||
|
zephyr,random-mac-address;
|
||||||
};
|
};
|
||||||
|
|
||||||
&wdt {
|
&wdt {
|
||||||
|
|
|
@ -39,11 +39,6 @@ choice ETH_GECKO_MAC_SELECT
|
||||||
help
|
help
|
||||||
Choose how to configure MAC address.
|
Choose how to configure MAC address.
|
||||||
|
|
||||||
config ETH_GECKO_RANDOM_MAC
|
|
||||||
bool "Random MAC address"
|
|
||||||
help
|
|
||||||
Generate a random MAC address dynamically.
|
|
||||||
|
|
||||||
config ETH_GECKO_MAC_MANUAL
|
config ETH_GECKO_MAC_MANUAL
|
||||||
bool "Manual"
|
bool "Manual"
|
||||||
help
|
help
|
||||||
|
|
|
@ -16,10 +16,4 @@ config ETH_LITEETH_0_IRQ_PRI
|
||||||
help
|
help
|
||||||
IRQ priority
|
IRQ priority
|
||||||
|
|
||||||
config ETH_LITEETH_0_RANDOM_MAC
|
|
||||||
bool "Random MAC address"
|
|
||||||
depends on ENTROPY_GENERATOR
|
|
||||||
help
|
|
||||||
Generate a random MAC address dynamically.
|
|
||||||
|
|
||||||
endif # ETH_LITEETH_0
|
endif # ETH_LITEETH_0
|
||||||
|
|
|
@ -66,15 +66,6 @@ config ETH_MCUX_0_UNIQUE_MAC
|
||||||
help
|
help
|
||||||
Generate MAC address from MCU's unique identification register.
|
Generate MAC address from MCU's unique identification register.
|
||||||
|
|
||||||
config ETH_MCUX_0_RANDOM_MAC
|
|
||||||
bool "Random MAC address"
|
|
||||||
help
|
|
||||||
Generate a random MAC address dynamically on each reboot.
|
|
||||||
Note that using this choice and rebooting a board may leave
|
|
||||||
stale MAC address in peers' ARP caches and lead to issues and
|
|
||||||
delays in communication. (Use "ip neigh flush all" on Linux
|
|
||||||
peers to clear ARP cache.)
|
|
||||||
|
|
||||||
config ETH_MCUX_0_MANUAL_MAC
|
config ETH_MCUX_0_MANUAL_MAC
|
||||||
bool "Manual MAC address"
|
bool "Manual MAC address"
|
||||||
help
|
help
|
||||||
|
@ -102,15 +93,6 @@ config ETH_MCUX_1_UNIQUE_MAC
|
||||||
help
|
help
|
||||||
Generate MAC address from MCU's unique identification register.
|
Generate MAC address from MCU's unique identification register.
|
||||||
|
|
||||||
config ETH_MCUX_1_RANDOM_MAC
|
|
||||||
bool "Random MAC address"
|
|
||||||
help
|
|
||||||
Generate a random MAC address dynamically on each reboot.
|
|
||||||
Note that using this choice and rebooting a board may leave
|
|
||||||
stale MAC address in peers' ARP caches and lead to issues and
|
|
||||||
delays in communication. (Use "ip neigh flush all" on Linux
|
|
||||||
peers to clear ARP cache.)
|
|
||||||
|
|
||||||
config ETH_MCUX_1_MANUAL_MAC
|
config ETH_MCUX_1_MANUAL_MAC
|
||||||
bool "Manual MAC address"
|
bool "Manual MAC address"
|
||||||
help
|
help
|
||||||
|
|
|
@ -91,11 +91,6 @@ config ETH_SAM_GMAC_MAC_I2C_EEPROM
|
||||||
help
|
help
|
||||||
Read MAC address from an I2C EEPROM.
|
Read MAC address from an I2C EEPROM.
|
||||||
|
|
||||||
config ETH_SAM_GMAC_RANDOM_MAC
|
|
||||||
bool "Random MAC address"
|
|
||||||
help
|
|
||||||
Generate a random MAC address dynamically.
|
|
||||||
|
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
if ETH_SAM_GMAC_MAC_I2C_EEPROM
|
if ETH_SAM_GMAC_MAC_I2C_EEPROM
|
||||||
|
|
|
@ -488,17 +488,10 @@ static int eth_init(struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_ETH_GECKO_RANDOM_MAC)
|
|
||||||
static void generate_random_mac(u8_t mac_addr[6])
|
|
||||||
{
|
|
||||||
gen_random_mac(mac_addr, SILABS_OUI_B0, SILABS_OUI_B1, SILABS_OUI_B2);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void generate_mac(u8_t mac_addr[6])
|
static void generate_mac(u8_t mac_addr[6])
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_ETH_GECKO_RANDOM_MAC)
|
#if DT_INST_PROP(0, zephyr_random_mac_address)
|
||||||
generate_random_mac(mac_addr);
|
gen_random_mac(mac_addr, SILABS_OUI_B0, SILABS_OUI_B1, SILABS_OUI_B2);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,12 +177,6 @@ static void eth_irq_handler(struct device *port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ETH_LITEETH_0_RANDOM_MAC
|
|
||||||
static void generate_mac(u8_t *mac_addr)
|
|
||||||
gen_random_mac(mac_addr, 0x10, 0xe2, 0xd5);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_ETH_LITEETH_0
|
#ifdef CONFIG_ETH_LITEETH_0
|
||||||
|
|
||||||
static struct eth_liteeth_dev_data eth_data = {
|
static struct eth_liteeth_dev_data eth_data = {
|
||||||
|
@ -211,9 +205,9 @@ static void eth_iface_init(struct net_if *iface)
|
||||||
/* initialize ethernet L2 */
|
/* initialize ethernet L2 */
|
||||||
ethernet_init(iface);
|
ethernet_init(iface);
|
||||||
|
|
||||||
#ifdef CONFIG_ETH_LITEETH_0_RANDOM_MAC
|
#if DT_INST_PROP(0, zephyr_random_mac_address)
|
||||||
/* generate random MAC address */
|
/* generate random MAC address */
|
||||||
generate_mac(context->mac_addr);
|
gen_random_mac(context->mac_addr, 0x10, 0xe2, 0xd5);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* set MAC address */
|
/* set MAC address */
|
||||||
|
|
|
@ -878,8 +878,8 @@ static void eth_callback(ENET_Type *base, enet_handle_t *handle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_ETH_MCUX_0_RANDOM_MAC) || \
|
#if DT_INST_PROP(0, zephyr_random_mac_address) || \
|
||||||
defined(CONFIG_ETH_MCUX_1_RANDOM_MAC)
|
DT_INST_PROP(1, zephyr_random_mac_address)
|
||||||
static void generate_random_mac(u8_t *mac_addr)
|
static void generate_random_mac(u8_t *mac_addr)
|
||||||
{
|
{
|
||||||
gen_random_mac(mac_addr, FREESCALE_OUI_B0,
|
gen_random_mac(mac_addr, FREESCALE_OUI_B0,
|
||||||
|
@ -1207,7 +1207,7 @@ static struct eth_context eth_0_context = {
|
||||||
#if defined(CONFIG_ETH_MCUX_0_UNIQUE_MAC)
|
#if defined(CONFIG_ETH_MCUX_0_UNIQUE_MAC)
|
||||||
.generate_mac = generate_eth0_unique_mac,
|
.generate_mac = generate_eth0_unique_mac,
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_ETH_MCUX_0_RANDOM_MAC)
|
#if DT_INST_PROP(0, zephyr_random_mac_address)
|
||||||
.generate_mac = generate_random_mac,
|
.generate_mac = generate_random_mac,
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_ETH_MCUX_0_MANUAL_MAC)
|
#if defined(CONFIG_ETH_MCUX_0_MANUAL_MAC)
|
||||||
|
@ -1274,7 +1274,7 @@ static struct eth_context eth_1_context = {
|
||||||
#if defined(CONFIG_ETH_MCUX_1_UNIQUE_MAC)
|
#if defined(CONFIG_ETH_MCUX_1_UNIQUE_MAC)
|
||||||
.generate_mac = generate_eth1_unique_mac,
|
.generate_mac = generate_eth1_unique_mac,
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_ETH_MCUX_1_RANDOM_MAC)
|
#if DT_INST_PROP(1, zephyr_random_mac_address)
|
||||||
.generate_mac = generate_random_mac,
|
.generate_mac = generate_random_mac,
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_ETH_MCUX_1_MANUAL_MAC)
|
#if defined(CONFIG_ETH_MCUX_1_MANUAL_MAC)
|
||||||
|
|
|
@ -41,6 +41,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
||||||
#include "phy_sam_gmac.h"
|
#include "phy_sam_gmac.h"
|
||||||
#include "eth_sam_gmac_priv.h"
|
#include "eth_sam_gmac_priv.h"
|
||||||
|
|
||||||
|
#include "eth.h"
|
||||||
|
|
||||||
#ifdef CONFIG_SOC_FAMILY_SAM0
|
#ifdef CONFIG_SOC_FAMILY_SAM0
|
||||||
#include "eth_sam0_gmac.h"
|
#include "eth_sam0_gmac.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -1797,19 +1799,12 @@ static void get_mac_addr_from_i2c_eeprom(u8_t mac_addr[6])
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_ETH_SAM_GMAC_RANDOM_MAC)
|
|
||||||
static void generate_random_mac(u8_t mac_addr[6])
|
|
||||||
{
|
|
||||||
gen_random_mac(mac_addr, ATMEL_OUI_B0, ATMEL_OUI_B1, ATMEL_OUI_B2);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void generate_mac(u8_t mac_addr[6])
|
static void generate_mac(u8_t mac_addr[6])
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_ETH_SAM_GMAC_MAC_I2C_EEPROM)
|
#if defined(CONFIG_ETH_SAM_GMAC_MAC_I2C_EEPROM)
|
||||||
get_mac_addr_from_i2c_eeprom(mac_addr);
|
get_mac_addr_from_i2c_eeprom(mac_addr);
|
||||||
#elif defined(CONFIG_ETH_SAM_GMAC_RANDOM_MAC)
|
#elif DT_INST_PROP(0, zephyr_random_mac_address)
|
||||||
generate_random_mac(mac_addr);
|
gen_random_mac(mac_addr, ATMEL_OUI_B0, ATMEL_OUI_B1, ATMEL_OUI_B2);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue