Skip to content

Commit fb3b596

Browse files
ffainellidavem330
authored andcommitted
net: systemport: allow changing MAC address
Hook a ndo_set_mac_address callback, update the internal Ethernet MAC in the netdevice structure, and finally write that address down to the UniMAC registers. If the interface is down, and most likely clock gated, we do not update the registers but just the local copy, such that next ndo_open() call will effectively write down the address. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6271037 commit fb3b596

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/net/ethernet/broadcom/bcmsysport.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,27 @@ static void topctrl_flush(struct bcm_sysport_priv *priv)
14091409
topctrl_writel(priv, 0, TX_FLUSH_CNTL);
14101410
}
14111411

1412+
static int bcm_sysport_change_mac(struct net_device *dev, void *p)
1413+
{
1414+
struct bcm_sysport_priv *priv = netdev_priv(dev);
1415+
struct sockaddr *addr = p;
1416+
1417+
if (!is_valid_ether_addr(addr->sa_data))
1418+
return -EINVAL;
1419+
1420+
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
1421+
1422+
/* interface is disabled, changes to MAC will be reflected on next
1423+
* open call
1424+
*/
1425+
if (!netif_running(dev))
1426+
return 0;
1427+
1428+
umac_set_hw_addr(priv, dev->dev_addr);
1429+
1430+
return 0;
1431+
}
1432+
14121433
static void bcm_sysport_netif_start(struct net_device *dev)
14131434
{
14141435
struct bcm_sysport_priv *priv = netdev_priv(dev);
@@ -1628,6 +1649,7 @@ static const struct net_device_ops bcm_sysport_netdev_ops = {
16281649
.ndo_stop = bcm_sysport_stop,
16291650
.ndo_set_features = bcm_sysport_set_features,
16301651
.ndo_set_rx_mode = bcm_sysport_set_rx_mode,
1652+
.ndo_set_mac_address = bcm_sysport_change_mac,
16311653
};
16321654

16331655
#define REV_FMT "v%2x.%02x"

0 commit comments

Comments
 (0)