mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] net: bcmgenet: Fix MAC address setting
@ 2022-12-02 10:52 Sascha Hauer
  0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2022-12-02 10:52 UTC (permalink / raw)
  To: Barebox List; +Cc: Ahmad Fatoum

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@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




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-02 10:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-02 10:52 [PATCH] net: bcmgenet: Fix MAC address setting Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox