Skip to content

Commit

Permalink
net: dsa: read mac address from DT for slave device
Browse files Browse the repository at this point in the history
Before creating a slave netdevice, get the mac address from DTS and
apply in case it is valid.

Signed-off-by: Xiaofei Shen <[email protected]>
Signed-off-by: Vinod Koul <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Xiaofei Shen authored and davem330 committed Apr 1, 2019
1 parent f5d5476 commit a2c7023
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/net/dsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions net/dsa/dsa2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,10 @@ 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;
eth_hw_addr_inherit(slave_dev, master);
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;
slave_dev->min_mtu = 0;
Expand Down

0 comments on commit a2c7023

Please sign in to comment.