From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-15 22:17:02
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().
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: ionut@badula.org
---
drivers/net/ethernet/adaptec/starfire.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
@@ -641,6 +641,7 @@ static int starfire_init_one(struct pci_dev *pdev,structnetdev_private*np;inti,irq,chip_idx=ent->driver_data;structnet_device*dev;+u8addr[ETH_ALEN];longioaddr;void__iomem*base;intdrv_flags,io_size;
@@ -696,7 +697,8 @@ static int starfire_init_one(struct pci_dev *pdev,/* Serial EEPROM reads are hidden by the hardware. */for(i=0;i<6;i++)-dev->dev_addr[i]=readb(base+EEPROMCtrl+20-i);+addr[i]=readb(base+EEPROMCtrl+20-i);+eth_hw_addr_set(dev,addr);#if ! defined(final_version) /* Dump the EEPROM contents during development. */if(debug>4)
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-15 22:17:02
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.
macaddr[] is a module param, and int, so copy the address into
an array of u8 on the stack, then call eth_hw_addr_set().
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: andreas@gaisler.com
---
drivers/net/ethernet/aeroflex/greth.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-15 22:17:03
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.
Break the address apart into an array on the stack, then call
eth_hw_addr_set().
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: jes@trained-monkey.org
CC: linux-acenic@sunsite.dk
---
drivers/net/ethernet/alteon/acenic.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-15 22:17:05
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().
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: pcnet32@frontier.com
---
drivers/net/ethernet/amd/amd8111e.c | 4 +++-
drivers/net/ethernet/amd/pcnet32.c | 13 +++++++++----
2 files changed, 12 insertions(+), 5 deletions(-)
@@ -1743,6 +1743,7 @@ static int amd8111e_probe_one(struct pci_dev *pdev,unsignedlongreg_addr,reg_len;structamd8111e_priv*lp;structnet_device*dev;+u8addr[ETH_ALEN];err=pci_enable_device(pdev);if(err){
@@ -1809,7 +1810,8 @@ static int amd8111e_probe_one(struct pci_dev *pdev,/* Initializing MAC address */for(i=0;i<ETH_ALEN;i++)-dev->dev_addr[i]=readb(lp->mmio+PADR+i);+addr[i]=readb(lp->mmio+PADR+i);+eth_hw_addr_set(dev,addr);/* Setting user defined parametrs */lp->ext_phy_option=speed_duplex[card_idx];
@@ -1595,6 +1595,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)structnet_device*dev;conststructpcnet32_access*a=NULL;u8promaddr[ETH_ALEN];+u8addr[ETH_ALEN];intret=-ENODEV;/* reset the chip */
@@ -1760,9 +1761,10 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)unsignedintval;val=a->read_csr(ioaddr,i+12)&0x0ffff;/* There may be endianness issues here. */-dev->dev_addr[2*i]=val&0x0ff;-dev->dev_addr[2*i+1]=(val>>8)&0x0ff;+addr[2*i]=val&0x0ff;+addr[2*i+1]=(val>>8)&0x0ff;}+eth_hw_addr_set(dev,addr);/* read PROM address and compare with CSR address */for(i=0;i<ETH_ALEN;i++)
@@ -1780,8 +1782,11 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)}/* if the ethernet address is not valid, force to 00:00:00:00:00:00 */-if(!is_valid_ether_addr(dev->dev_addr))-eth_zero_addr(dev->dev_addr);+if(!is_valid_ether_addr(dev->dev_addr)){+staticconstu8zero_addr[ETH_ALEN]={};++eth_hw_addr_set(dev,zero_addr);+}if(pcnet32_debug&NETIF_MSG_PROBE){pr_cont(" %pM",dev->dev_addr);
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-15 22:17:05
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.
Use an array on the stack, then call eth_hw_addr_set().
eth_hw_addr_set() is after error checking, this should
be fine, error propagates all the way to failing probe.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: irusskikh@marvell.com
---
drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
@@ -316,12 +317,13 @@ int aq_nic_ndev_register(struct aq_nic_s *self)#endifmutex_lock(&self->fwreq_mutex);-err=self->aq_fw_ops->get_mac_permanent(self->aq_hw,-self->ndev->dev_addr);+err=self->aq_fw_ops->get_mac_permanent(self->aq_hw,addr);mutex_unlock(&self->fwreq_mutex);if(err)gotoerr_exit;+eth_hw_addr_set(self->ndev,addr);+if(!is_valid_ether_addr(self->ndev->dev_addr)||!aq_nic_is_valid_ether_addr(self->ndev->dev_addr)){netdev_warn(self->ndev,"MAC is invalid, will use random.");
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-15 22:17:06
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().
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: aelior@marvell.com
CC: skalluru@marvell.com
CC: GR-everest-linux-l2@marvell.com
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
@@ -11823,9 +11823,10 @@ static void bnx2x_get_mac_hwinfo(struct bnx2x *bp)u32val,val2;intfunc=BP_ABS_FUNC(bp);intport=BP_PORT(bp);+u8addr[ETH_ALEN]={};/* Zero primary MAC configuration */-eth_zero_addr(bp->dev->dev_addr);+eth_hw_addr_set(bp->dev,addr);if(BP_NOMCP(bp)){BNX2X_ERROR("warning: random MAC workaround active\n");
@@ -11843,7 +11846,8 @@ static void bnx2x_get_mac_hwinfo(struct bnx2x *bp)/* in SF read MACs from port configuration */val2=SHMEM_RD(bp,dev_info.port_hw_config[port].mac_upper);val=SHMEM_RD(bp,dev_info.port_hw_config[port].mac_lower);-bnx2x_set_mac_buf(bp->dev->dev_addr,val,val2);+bnx2x_set_mac_buf(addr,val,val2);+eth_hw_addr_set(bp->dev,addr);if(CNIC_SUPPORT(bp))bnx2x_get_cnic_mac_hwinfo(bp);
@@ -12291,7 +12295,9 @@ static int bnx2x_init_bp(struct bnx2x *bp)if(rc)returnrc;}else{-eth_zero_addr(bp->dev->dev_addr);+staticconstu8zero_addr[ETH_ALEN]={};++eth_hw_addr_set(bp->dev,zero_addr);}bnx2x_set_modes_bitmap(bp);
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-15 22:17:07
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().
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: opendmb@gmail.com
CC: f.fainelli@gmail.com
CC: bcm-kernel-feedback-list@broadcom.com
---
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-15 22:17:08
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.
Use a zero'ed array on the stack, then call eth_hw_addr_set().
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: benve@cisco.com
CC: _govind@gmx.com
---
drivers/net/ethernet/cisco/enic/enic_main.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
@@ -1098,6 +1098,7 @@ static int enic_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)staticintenic_set_vf_port(structnet_device*netdev,intvf,structnlattr*port[]){+staticconstu8zero_addr[ETH_ALEN]={};structenic*enic=netdev_priv(netdev);structenic_port_profileprev_pp;structenic_port_profile*pp;
@@ -1162,7 +1163,7 @@ static int enic_set_vf_port(struct net_device *netdev, int vf,}else{memset(pp,0,sizeof(*pp));if(vf==PORT_SELF_VF)-eth_zero_addr(netdev->dev_addr);+eth_hw_addr_set(netdev,zero_addr);}}else{/* Set flag to indicate that the port assoc/disassoc
@@ -1174,7 +1175,7 @@ static int enic_set_vf_port(struct net_device *netdev, int vf,if(pp->request==PORT_REQUEST_DISASSOCIATE){eth_zero_addr(pp->mac_addr);if(vf==PORT_SELF_VF)-eth_zero_addr(netdev->dev_addr);+eth_hw_addr_set(netdev,zero_addr);}}
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-15 22:17:09
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.
Copy the address into an array on the stack, then call
eth_hw_addr_set().
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: reksio@newterm.pl
---
drivers/net/ethernet/ec_bhf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-15 22:17:10
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.
Pass a netdev into the helper instead of just the address,
read the address into an array on the stack, then call
eth_hw_addr_set().
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: claudiu.manoil@nxp.com
---
drivers/net/ethernet/freescale/enetc/enetc_hw.h | 6 +++++-
drivers/net/ethernet/freescale/enetc/enetc_pf.c | 2 +-
drivers/net/ethernet/freescale/enetc/enetc_vf.c | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
@@ -783,7 +783,7 @@ static void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev,}/* pick up primary MAC address from SI */-enetc_get_primary_mac_addr(&si->hw,ndev->dev_addr);+enetc_load_primary_mac_addr(&si->hw,ndev);}staticintenetc_mdio_probe(structenetc_pf*pf,structdevice_node*np)
@@ -135,7 +135,7 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev,ndev->hw_features|=NETIF_F_RXHASH;/* pick up primary MAC address from SI */-enetc_get_primary_mac_addr(&si->hw,ndev->dev_addr);+enetc_load_primary_mac_addr(&si->hw,ndev);}staticintenetc_vf_probe(structpci_dev*pdev,
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-15 22:17:11
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(). ixgb_get_ee_mac_addr() is used with
a non-nevdev->dev_addr pointer so we can't deal with the problem
inside it.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: jesse.brandeburg@intel.com
CC: anthony.l.nguyen@intel.com
---
drivers/net/ethernet/intel/ixgb/ixgb_main.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-10-15 22:17:51
We'll want to make netdev->dev_addr const, remove the local
helper which is missing a const qualifier on the argument
and use ether_addr_to_u64().
Similar story to mlx4.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: cforno12@linux.ibm.com
CC: mpe@ellerman.id.au
CC: benh@kernel.crashing.org
CC: paulus@samba.org
CC: linuxppc-dev@lists.ozlabs.org
---
drivers/net/ethernet/ibm/ibmveth.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
We'll want to make netdev->dev_addr const, remove the local
helper which is missing a const qualifier on the argument
and use ether_addr_to_u64().
LGTM. ibmveth_encode_mac_addr() is clearly code duplication of
ether_addr_to_u64() minus the const qualifier.
Reviewed-by: Tyrel Datwyler <tyreld@linux.ibm.com>
quoted hunk
Similar story to mlx4.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: cforno12@linux.ibm.com
CC: mpe@ellerman.id.au
CC: benh@kernel.crashing.org
CC: paulus@samba.org
CC: linuxppc-dev@lists.ozlabs.org
---
drivers/net/ethernet/ibm/ibmveth.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
Hello:
This series was applied to netdev/net-next.git (master)
by David S. Miller [off-list ref]:
On Fri, 15 Oct 2021 15:16:40 -0700 you wrote:
Manual conversions of drivers writing directly
to netdev->dev_addr (part 1 out of 3).
Jakub Kicinski (12):
ethernet: adaptec: use eth_hw_addr_set()
ethernet: aeroflex: use eth_hw_addr_set()
ethernet: alteon: use eth_hw_addr_set()
ethernet: amd: use eth_hw_addr_set()
ethernet: aquantia: use eth_hw_addr_set()
ethernet: bnx2x: use eth_hw_addr_set()
ethernet: bcmgenet: use eth_hw_addr_set()
ethernet: enic: use eth_hw_addr_set()
ethernet: ec_bhf: use eth_hw_addr_set()
ethernet: enetc: use eth_hw_addr_set()
ethernet: ibmveth: use ether_addr_to_u64()
ethernet: ixgb: use eth_hw_addr_set()
[...]
Acked-By: Jes Sorensen <redacted>
Sorry for top posting, mobile email clients suck.
Jes
Sent from MailDroid
-----Original Message-----
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>, jes@trained-monkey.org, linux-acenic@sunsite.dk
Sent: Sat, 16 Oct 2021 0:17
Subject: [PATCH net-next 03/12] ethernet: alteon: 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.
Break the address apart into an array on the stack, then call
eth_hw_addr_set().
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: jes@trained-monkey.org
CC: linux-acenic@sunsite.dk
---
drivers/net/ethernet/alteon/acenic.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
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().
Signed-off-by: Jakub Kicinski <kuba@kernel.org>