ethernet: manual netdev->dev_addr conversions (part 3)
Subsystems (9)
Jakub Kicinski
maintainercover ethernet: manual netdev->dev_addr conversions (part 3)
Manual conversions of Ethernet drivers writing directly to netdev->dev_addr (part 3 out of 3).
Jakub Kicinski (6):
ethernet: netsec: use eth_hw_addr_set()
ethernet: stmmac: use eth_hw_addr_set()
ethernet: tehuti: use eth_hw_addr_set()
ethernet: tlan: use eth_hw_addr_set()
ethernet: via-rhine: use eth_hw_addr_set()
ethernet: via-velocity: use eth_hw_addr_set()
drivers/net/ethernet/socionext/netsec.c | 16 +++++++++------- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 8 ++++++-- drivers/net/ethernet/tehuti/tehuti.c | 6 ++++-- drivers/net/ethernet/ti/tlan.c | 10 ++++++---- drivers/net/ethernet/via/via-rhine.c | 4 +++- drivers/net/ethernet/via/via-velocity.c | 4 +++- 6 files changed, 31 insertions(+), 17 deletions(-)
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 1/6 ethernet: netsec: use eth_hw_addr_set()
Commit 406f42fa0d3c ("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintain netdev->dev_addr in this tree we need to make all the writes to it got through appropriate helpers.
Read the address into an array on the stack, then call eth_hw_addr_set().
---
CC: [email protected]
CC: [email protected]
--- drivers/net/ethernet/socionext/netsec.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/net/ethernet/socionext/netsec.c +9 -7
@@ -2037,13 +2037,15 @@ static int netsec_probe(struct platform_device *pdev)if (ret && priv->eeprom_base) {void __iomem *macp = priv->eeprom_base +NETSEC_EEPROM_MAC_ADDRESS ; - - ndev->dev_addr[0 ] =readb (macp +3 ); - ndev->dev_addr[1 ] =readb (macp +2 ); - ndev->dev_addr[2 ] =readb (macp +1 ); - ndev->dev_addr[3 ] =readb (macp +0 ); - ndev->dev_addr[4 ] =readb (macp +7 ); - ndev->dev_addr[5 ] =readb (macp +6 ); +u8 addr[ETH_ALEN ]; + + addr[0 ] =readb (macp +3 ); + addr[1 ] =readb (macp +2 ); + addr[2 ] =readb (macp +1 ); + addr[3 ] =readb (macp +0 ); + addr[4 ] =readb (macp +7 ); + addr[5 ] =readb (macp +6 ); +eth_hw_addr_set (ndev, addr); }if (!is_valid_ether_addr (ndev->dev_addr)) {
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 2/6 ethernet: stmmac: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 406f42fa0d3c ("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintain netdev->dev_addr in this tree we need to make all the writes to it got through appropriate helpers.
Read the address into an array on the stack, then call eth_hw_addr_set().
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +6 -2
@@ -2818,9 +2818,13 @@ static int stmmac_get_hw_features(struct stmmac_priv *priv)*/ static void stmmac_check_ether_addr (struct stmmac_priv *priv) { +u8 addr[ETH_ALEN ]; +if (!is_valid_ether_addr (priv->dev->dev_addr)) { -stmmac_get_umac_addr (priv, priv->hw, priv->dev->dev_addr,0 ); -if (!is_valid_ether_addr (priv->dev->dev_addr)) +stmmac_get_umac_addr (priv, priv->hw, addr,0 ); +if (is_valid_ether_addr (addr)) +eth_hw_addr_set (priv->dev, addr); +else eth_hw_addr_random (priv->dev);dev_info (priv->device,"device MAC address %pM\n" , priv->dev->dev_addr);
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 3/6 ethernet: tehuti: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 406f42fa0d3c ("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintain netdev->dev_addr in this tree we need to make all the writes to it got through appropriate helpers.
Break the address up into an array on the stack, then call eth_hw_addr_set().
---
CC: [email protected]
--- drivers/net/ethernet/tehuti/tehuti.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/tehuti/tehuti.c +4 -2
@@ -840,6 +840,7 @@ static int bdx_set_mac(struct net_device *ndev, void *p)static int bdx_read_mac (struct bdx_priv *priv) {u16 macAddress[3 ], i; +u8 addr[ETH_ALEN ];ENTER ; macAddress[2 ] =READ_REG (priv, regUNC_MAC0_A);
@@ -849,9 +850,10 @@ static int bdx_read_mac(struct bdx_priv *priv) macAddress[0 ] =READ_REG (priv, regUNC_MAC2_A); macAddress[0 ] =READ_REG (priv, regUNC_MAC2_A);for (i =0 ; i <3 ; i++) { - priv->ndev->dev_addr[i *2 +1 ] = macAddress[i]; - priv->ndev->dev_addr[i *2 ] = macAddress[i] >>8 ; + addr[i *2 +1 ] = macAddress[i]; + addr[i *2 ] = macAddress[i] >>8 ; } +eth_hw_addr_set (priv->ndev, addr);RET (0 ); }
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 4/6 ethernet: tlan: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 406f42fa0d3c ("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintain netdev->dev_addr in this tree we need to make all the writes to it got through appropriate helpers.
Read the address into an array on the stack, do the swapping, then call eth_hw_addr_set().
---
CC: [email protected]
--- drivers/net/ethernet/ti/tlan.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/ethernet/ti/tlan.c +6 -4
@@ -817,6 +817,7 @@ static int tlan_init(struct net_device *dev)int err;int i;struct tlan_priv *priv; +u8 addr[ETH_ALEN ]; priv =netdev_priv (dev);
@@ -842,7 +843,7 @@ static int tlan_init(struct net_device *dev)for (i =0 ; i <ETH_ALEN ; i++) err |=tlan_ee_read_byte (dev, (u8 ) priv->adapter->addr_ofs + i, - (u8 *) &dev->dev_addr[i]); + addr + i);if (err) {pr_err ("%s: Error reading MAC from eeprom: %d\n" , dev->name, err);
@@ -850,11 +851,12 @@ static int tlan_init(struct net_device *dev)/* Olicom OC-2325/OC-2326 have the address byte-swapped */ if (priv->adapter->addr_ofs ==0xf8 ) {for (i =0 ; i <ETH_ALEN ; i +=2 ) { -char tmp = dev->dev_addr[i]; - dev->dev_addr[i] = dev->dev_addr[i +1 ]; - dev->dev_addr[i +1 ] = tmp; +char tmp = addr[i]; + addr[i] = addr[i +1 ]; + addr[i +1 ] = tmp; } } +eth_hw_addr_set (dev, addr);netif_carrier_off (dev);
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 6/6 ethernet: via-velocity: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 406f42fa0d3c ("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintain netdev->dev_addr in this tree we need to make all the writes to it got through appropriate helpers.
Read the address into an array on the stack, then call eth_hw_addr_set().
---
CC: [email protected]
--- drivers/net/ethernet/via/via-velocity.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/via/via-velocity.c +3 -1
@@ -2767,6 +2767,7 @@ static int velocity_probe(struct device *dev, int irq,struct velocity_info *vptr;struct mac_regs __iomem *regs;int ret = -ENOMEM ; +u8 addr[ETH_ALEN ];/* FIXME: this driver, like almost all other ethernet drivers, * can support more than MAX_UNITS.
@@ -2820,7 +2821,8 @@ static int velocity_probe(struct device *dev, int irq,mac_wol_reset (regs);for (i =0 ; i <6 ; i++) - netdev->dev_addr[i] =readb (®s->PAR[i]); + addr[i] =readb (®s->PAR[i]); +eth_hw_addr_set (netdev, addr);velocity_get_options (&vptr->options, velocity_nics);
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 5/6 ethernet: via-rhine: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 406f42fa0d3c ("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintain netdev->dev_addr in this tree we need to make all the writes to it got through appropriate helpers.
Read the address into an array on the stack, then call eth_hw_addr_set().
---
CC: [email protected]
--- drivers/net/ethernet/via/via-rhine.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/via/via-rhine.c +3 -1
@@ -899,6 +899,7 @@ static int rhine_init_one_common(struct device *hwdev, u32 quirks,struct net_device *dev;struct rhine_private *rp;int i, rc, phy_id; +u8 addr[ETH_ALEN ];const char *name;/* this should always be supported */
@@ -933,7 +934,8 @@ static int rhine_init_one_common(struct device *hwdev, u32 quirks,rhine_hw_init (dev, pioaddr);for (i =0 ; i <6 ; i++) - dev->dev_addr[i] =ioread8 (ioaddr + StationAddr + i); + addr[i] =ioread8 (ioaddr + StationAddr + i); +eth_hw_addr_set (dev, addr);if (!is_valid_ether_addr (dev->dev_addr)) {/* Report it and use a random ethernet address instead */
Signature · 1 line
2.31.1
Re: [PATCH net-next 1/6] ethernet: netsec: use eth_hw_addr_set()
In reply to Jakub KicinskiHi Jakub,
Quoted 45 lines · Jakub Kicinski
Commit
406f42fa0d3c("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintainnetdev->dev_addrin this tree we need to make all the writes to it got through appropriate helpers.Read the address into an array on the stack, then call
eth_hw_addr_set().Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]--- drivers/net/ethernet/socionext/netsec.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)drivers/net/ethernet/socionext/netsec.c +9
-8@@ -2037,13 +2037,15 @@ static int netsec_probe(struct platform_device *pdev)if (ret && priv->eeprom_base) {void __iomem *macp = priv->eeprom_base +NETSEC_EEPROM_MAC_ADDRESS ; - - ndev->dev_addr[0 ] =readb (macp +3 ); - ndev->dev_addr[1 ] =readb (macp +2 ); - ndev->dev_addr[2 ] =readb (macp +1 ); - ndev->dev_addr[3 ] =readb (macp +0 ); - ndev->dev_addr[4 ] =readb (macp +7 ); - ndev->dev_addr[5 ] =readb (macp +6 ); +u8 addr[ETH_ALEN ]; + + addr[0 ] =readb (macp +3 ); + addr[1 ] =readb (macp +2 ); + addr[2 ] =readb (macp +1 ); + addr[3 ] =readb (macp +0 ); + addr[4 ] =readb (macp +7 ); + addr[5 ] =readb (macp +6 ); +eth_hw_addr_set (ndev, addr); }if (!is_valid_ether_addr (ndev->dev_addr)) { --
Quoted 2 lines
2.31.1
Thanks!
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 11 lines · On Tue, 19 Oct 2021 08:00:05 -0700 you wrote:
Manual conversions of Ethernet drivers writing directly to
netdev->dev_addr(part 3 out of 3).Jakub Kicinski (6):
ethernet: netsec: useeth_hw_addr_set()
ethernet: stmmac: useeth_hw_addr_set()
ethernet: tehuti: useeth_hw_addr_set()
ethernet: tlan: useeth_hw_addr_set()
ethernet: via-rhine: useeth_hw_addr_set()
ethernet: via-velocity: useeth_hw_addr_set()
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,1/6] ethernet: netsec: use eth_hw_addr_set()
https://git.kernel.org/netdev/net-next/c/414c6a3c84d7 - [net-next,2/6] ethernet: stmmac: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/7f9b8fe5445c - [net-next,3/6] ethernet: tehuti: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/3d9c64ca52d5 - [net-next,4/6] ethernet: tlan: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/41a19eb084f0 - [net-next,5/6] ethernet: via-rhine: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/83f262babdde - [net-next,6/6] ethernet: via-velocity: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/0b271c48d9c5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html