Skip to contentSkip to conversation

arc_emac: write initial MAC address from devicetree to hw

PATCH Applied Max Schwarz 4 participants 4 messages Apr 18, 2014 – May 1, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arc_emac: write initial MAC address from devicetree to hw

The MAC address retrieved from dt was not actually written to the hardware. This meant proper communication was only possible after changing the MAC address.

Fix that by always writing the mac address during probing.

---

I recently noticed this problem on the Radxa Rock board. I'm not sure how this has ever worked on other platforms, though. I can only receive broadcast packets without configuring the address.

Running ifconfig eth0 hw ether XYZ or applying the patch fixes the problem for me.

CCing Heiko Stübner because he has seen the problem as well.

 drivers/net/ethernet/arc/emac_main.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/net/ethernet/arc/emac_main.c +14 -7
index eeecc29..9f45782 100644
@@ -574,6 +574,18 @@ static int arc_emac_tx(struct sk_buff *skb, struct net_device *ndev)
 	return NETDEV_TX_OK;
 }
 
+static void arc_emac_set_address_internal(struct net_device *ndev)
+{
+	struct arc_emac_priv *priv = netdev_priv(ndev);
+	unsigned int addr_low, addr_hi;
+
+	addr_low = le32_to_cpu(*(__le32 *) &ndev->dev_addr[0]);
+	addr_hi = le16_to_cpu(*(__le16 *) &ndev->dev_addr[4]);
+
+	arc_reg_set(priv, R_ADDRL, addr_low);
+	arc_reg_set(priv, R_ADDRH, addr_hi);
+}
+
 /**
  * arc_emac_set_address - Set the MAC address for this device.
  * @ndev:	Pointer to net_device structure.
@@ -587,9 +599,7 @@ static int arc_emac_tx(struct sk_buff *skb, struct net_device *ndev)
  */
 static int arc_emac_set_address(struct net_device *ndev, void *p)
 {
-	struct arc_emac_priv *priv = netdev_priv(ndev);
 	struct sockaddr *addr = p;
-	unsigned int addr_low, addr_hi;
 
 	if (netif_running(ndev))
 		return -EBUSY;
@@ -599,11 +609,7 @@ static int arc_emac_set_address(struct net_device *ndev, void *p)
 
 	memcpy(ndev->dev_addr, addr->sa_data, ndev->addr_len);
 
-	addr_low = le32_to_cpu(*(__le32 *) &ndev->dev_addr[0]);
-	addr_hi = le16_to_cpu(*(__le16 *) &ndev->dev_addr[4]);
-
-	arc_reg_set(priv, R_ADDRL, addr_low);
-	arc_reg_set(priv, R_ADDRH, addr_hi);
+	arc_emac_set_address_internal(ndev);
 
 	return 0;
 }
@@ -713,6 +719,7 @@ static int arc_emac_probe(struct platform_device *pdev)
 	else
 		eth_hw_addr_random(ndev);
 
+	arc_emac_set_address_internal(ndev);
 	dev_info(&pdev->dev, "MAC address is now %pM\n", ndev->dev_addr);
 
 	/* Do 1 allocation instead of 2 separate ones for Rx and Tx BD rings */
Signature · 1 line
1.8.3.2
Acked-by Tested-by on v1 1/1
#1 lore raw

Am Freitag, 18. April 2014, 02:17:32 schrieb Max Schwarz:

Quoted 7 lines

The MAC address retrieved from dt was not actually written to the hardware. This meant proper communication was only possible after changing the MAC address.

Fix that by always writing the mac address during probing.

On the same hardware (rk3188 radxa rock)

Quoted 69 lines

---

I recently noticed this problem on the Radxa Rock board. I'm not sure how this has ever worked on other platforms, though. I can only receive broadcast packets without configuring the address.

Running ifconfig eth0 hw ether XYZ or applying the patch fixes the problem for me.

CCing Heiko Stübner because he has seen the problem as well.

 drivers/net/ethernet/arc/emac_main.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/drivers/net/ethernet/arc/emac_main.c index eeecc29..9f45782 100644

drivers/net/ethernet/arc/emac_main.c +12 -0
@@ -574,6 +574,18 @@ static int arc_emac_tx(struct sk_buff *skb, struct
 net_device *ndev) return NETDEV_TX_OK;
 }
 
+static void arc_emac_set_address_internal(struct net_device *ndev)
+{
+	struct arc_emac_priv *priv = netdev_priv(ndev);
+	unsigned int addr_low, addr_hi;
+
+	addr_low = le32_to_cpu(*(__le32 *) &ndev->dev_addr[0]);
+	addr_hi = le16_to_cpu(*(__le16 *) &ndev->dev_addr[4]);
+
+	arc_reg_set(priv, R_ADDRL, addr_low);
+	arc_reg_set(priv, R_ADDRH, addr_hi);
+}
+
 /**
  * arc_emac_set_address - Set the MAC address for this device.
  * @ndev:	Pointer to net_device structure.
@@ -587,9 +599,7 @@ static int arc_emac_tx(struct sk_buff *skb, struct

net_device *ndev) */
static int arc_emac_set_address(struct net_device *ndev, void *p) {

drivers/net/ethernet/arc/emac_main.c +1 -7
-	struct arc_emac_priv *priv = netdev_priv(ndev);
 	struct sockaddr *addr = p;
-	unsigned int addr_low, addr_hi;
 
 	if (netif_running(ndev))
 		return -EBUSY;
@@ -599,11 +609,7 @@ static int arc_emac_set_address(struct net_device
 *ndev, void *p)
 
 	memcpy(ndev->dev_addr, addr->sa_data, ndev->addr_len);
 
-	addr_low = le32_to_cpu(*(__le32 *) &ndev->dev_addr[0]);
-	addr_hi = le16_to_cpu(*(__le16 *) &ndev->dev_addr[4]);
-
-	arc_reg_set(priv, R_ADDRL, addr_low);
-	arc_reg_set(priv, R_ADDRH, addr_hi);
+	arc_emac_set_address_internal(ndev);
 
 	return 0;

}

drivers/net/ethernet/arc/emac_main.c +1 -0
@@ -713,6 +719,7 @@ static int arc_emac_probe(struct platform_device *pdev)
 	else
 		eth_hw_addr_random(ndev);
 
+	arc_emac_set_address_internal(ndev);
 	dev_info(&pdev->dev, "MAC address is now %pM\n", ndev->dev_addr);
 
 	/* Do 1 allocation instead of 2 separate ones for Rx and Tx BD rings */
#3 lore raw
In reply to Max Schwarz
Quoted 6 lines · Max Schwarz

I recently noticed this problem on the Radxa Rock board. I'm not sure how this has ever worked on other platforms, though. I can only receive broadcast packets without configuring the address.

Running ifconfig eth0 hw ether XYZ or applying the patch fixes the problem for me.

Our rcS script would always do a ifconfig hw, hence we didn't run into this. We have used this driver in one of our FPGA boards for several years.

-Vineet