Commit a2c7023f authored by Xiaofei Shen's avatar Xiaofei Shen Committed by David S. Miller

net: dsa: read mac address from DT for slave device

Before creating a slave netdevice, get the mac address from DTS and
apply in case it is valid.
Signed-off-by: default avatarXiaofei Shen <xiaofeis@codeaurora.org>
Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f5d54767
......@@ -140,6 +140,7 @@ struct dsa_port {
unsigned int index;
const char *name;
const struct dsa_port *cpu_dp;
const char *mac;
struct device_node *dn;
unsigned int ageing_time;
u8 stp_state;
......
......@@ -266,6 +266,7 @@ static int dsa_port_setup(struct dsa_port *dp)
return 0;
memset(&dp->devlink_port, 0, sizeof(dp->devlink_port));
dp->mac = of_get_mac_address(dp->dn);
switch (dp->type) {
case DSA_PORT_TYPE_CPU:
......
......@@ -1393,6 +1393,9 @@ int dsa_slave_create(struct dsa_port *port)
NETIF_F_HW_VLAN_CTAG_FILTER;
slave_dev->hw_features |= NETIF_F_HW_TC;
slave_dev->ethtool_ops = &dsa_slave_ethtool_ops;
if (port->mac && is_valid_ether_addr(port->mac))
ether_addr_copy(slave_dev->dev_addr, port->mac);
else
eth_hw_addr_inherit(slave_dev, master);
slave_dev->priv_flags |= IFF_NO_QUEUE;
slave_dev->netdev_ops = &dsa_slave_netdev_ops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment