[PATCH] net: bcmgenet: Fix MAC address setting

Sascha Hauer s.hauer at pengutronix.de
Fri Dec 2 02:52:04 PST 2022


bcmgenet_set_hwaddr() only copies the MAC address only into internal
state, but not into hardware. Copying to hardware is done in
__bcmgenet_set_hwaddr() called during open time. Depending on
nv.dev.eth0.ethaddr being set the order in which both functions
are called changes.

Copy the state into hardware as well in bcmgenet_set_hwaddr(). This
fixes sending packets when nv.dev.eth0.ethaddr is not set.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/net/bcmgenet.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/net/bcmgenet.c b/drivers/net/bcmgenet.c
index 79514dfa69..8df5fd5dea 100644
--- a/drivers/net/bcmgenet.c
+++ b/drivers/net/bcmgenet.c
@@ -215,15 +215,6 @@ static void bcmgenet_umac_reset(struct bcmgenet_eth_priv *priv)
 	writel(1, (priv->mac_reg + RBUF_TBUF_SIZE_CTRL));
 }
 
-static int bcmgenet_set_hwaddr(struct eth_device *dev, const unsigned char *addr)
-{
-	struct bcmgenet_eth_priv *priv = dev->priv;
-
-	memcpy(priv->addr, addr, 6);
-
-	return 0;
-}
-
 static int __bcmgenet_set_hwaddr(struct bcmgenet_eth_priv *priv)
 {
 	const unsigned char *addr = priv->addr;
@@ -238,6 +229,17 @@ static int __bcmgenet_set_hwaddr(struct bcmgenet_eth_priv *priv)
 	return 0;
 }
 
+static int bcmgenet_set_hwaddr(struct eth_device *dev, const unsigned char *addr)
+{
+	struct bcmgenet_eth_priv *priv = dev->priv;
+
+	memcpy(priv->addr, addr, 6);
+
+	__bcmgenet_set_hwaddr(priv);
+
+	return 0;
+}
+
 static int bcmgenet_get_hwaddr(struct eth_device *edev, unsigned char *mac)
 {
 	return -1;
-- 
2.30.2




More information about the barebox mailing list