* [PATCH net-next] net: systemport: allow changing MAC address
@ 2014-12-08 23:59 Florian Fainelli
2014-12-09 23:26 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2014-12-08 23:59 UTC (permalink / raw)
To: netdev; +Cc: davem, Florian Fainelli
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>
---
drivers/net/ethernet/broadcom/bcmsysport.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index c1d255972dae..a91a8c263391 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -1409,6 +1409,27 @@ static void topctrl_flush(struct bcm_sysport_priv *priv)
topctrl_writel(priv, 0, TX_FLUSH_CNTL);
}
+static int bcm_sysport_change_mac(struct net_device *dev, void *p)
+{
+ struct bcm_sysport_priv *priv = netdev_priv(dev);
+ struct sockaddr *addr = p;
+
+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EINVAL;
+
+ memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+
+ /* interface is disabled, changes to MAC will be reflected on next
+ * open call
+ */
+ if (!netif_running(dev))
+ return 0;
+
+ umac_set_hw_addr(priv, dev->dev_addr);
+
+ return 0;
+}
+
static void bcm_sysport_netif_start(struct net_device *dev)
{
struct bcm_sysport_priv *priv = netdev_priv(dev);
@@ -1628,6 +1649,7 @@ static const struct net_device_ops bcm_sysport_netdev_ops = {
.ndo_stop = bcm_sysport_stop,
.ndo_set_features = bcm_sysport_set_features,
.ndo_set_rx_mode = bcm_sysport_set_rx_mode,
+ .ndo_set_mac_address = bcm_sysport_change_mac,
};
#define REV_FMT "v%2x.%02x"
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next] net: systemport: allow changing MAC address
2014-12-08 23:59 [PATCH net-next] net: systemport: allow changing MAC address Florian Fainelli
@ 2014-12-09 23:26 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-12-09 23:26 UTC (permalink / raw)
To: f.fainelli; +Cc: netdev
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Mon, 8 Dec 2014 15:59:18 -0800
> 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>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-09 23:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-08 23:59 [PATCH net-next] net: systemport: allow changing MAC address Florian Fainelli
2014-12-09 23:26 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox