ethernet: manual netdev->dev_addr conversions (part 1)
Subsystems (14)
Jakub Kicinski
maintainercover ethernet: manual netdev->dev_addr conversions (part 1)
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()
drivers/net/ethernet/adaptec/starfire.c | 4 +++- drivers/net/ethernet/aeroflex/greth.c | 6 +++--- drivers/net/ethernet/alteon/acenic.c | 14 ++++++++------ drivers/net/ethernet/amd/amd8111e.c | 4 +++- drivers/net/ethernet/amd/pcnet32.c | 13 +++++++++---- drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 6 ++++-- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 16 +++++++++++----- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 8 ++++++-- drivers/net/ethernet/cisco/enic/enic_main.c | 5 +++-- drivers/net/ethernet/ec_bhf.c | 4 +++- 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 +- drivers/net/ethernet/ibm/ibmveth.c | 17 +++-------------- drivers/net/ethernet/intel/ixgb/ixgb_main.c | 8 ++++++-- 15 files changed, 69 insertions(+), 46 deletions(-)
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 1/12 ethernet: adaptec: 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]
--- drivers/net/ethernet/adaptec/starfire.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/adaptec/starfire.c +3 -1
@@ -641,6 +641,7 @@ static int starfire_init_one(struct pci_dev *pdev,struct netdev_private *np;int i, irq, chip_idx = ent->driver_data;struct net_device *dev; +u8 addr[ETH_ALEN ];long ioaddr;void __iomem *base;int drv_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 )
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 2/12 ethernet: aeroflex: 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.
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().
---
CC: [email protected]
--- drivers/net/ethernet/aeroflex/greth.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/aeroflex/greth.c +3 -3
@@ -1346,6 +1346,7 @@ static int greth_of_probe(struct platform_device *ofdev)int i;int err;int tmp; +u8 addr[ETH_ALEN ];unsigned long timeout; dev =alloc_etherdev (sizeof (struct greth_private ));
@@ -1449,8 +1450,6 @@ static int greth_of_probe(struct platform_device *ofdev)break ; }if (i ==6 ) { -u8 addr[ETH_ALEN ]; - err =of_get_mac_address (ofdev->dev.of_node, addr);if (!err) {for (i =0 ; i <6 ; i++)
@@ -1464,7 +1463,8 @@ static int greth_of_probe(struct platform_device *ofdev) }for (i =0 ; i <6 ; i++) - dev->dev_addr[i] = macaddr[i]; + addr[i] = macaddr[i]; +eth_hw_addr_set (dev, addr); macaddr[5 ]++;
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 3/12 ethernet: alteon: 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 apart into an array on the stack, then call eth_hw_addr_set().
---
CC: [email protected]
CC: [email protected]
--- drivers/net/ethernet/alteon/acenic.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/alteon/acenic.c +8 -6
@@ -869,6 +869,7 @@ static int ace_init(struct net_device *dev)int board_idx, ecode =0 ;short i;unsigned char cache_size; +u8 addr[ETH_ALEN ]; ap =netdev_priv (dev); regs = ap->regs;
@@ -988,12 +989,13 @@ static int ace_init(struct net_device *dev)writel (mac1, ®s->MacAddrHi);writel (mac2, ®s->MacAddrLo); - dev->dev_addr[0 ] = (mac1 >>8 ) &0xff ; - dev->dev_addr[1 ] = mac1 &0xff ; - dev->dev_addr[2 ] = (mac2 >>24 ) &0xff ; - dev->dev_addr[3 ] = (mac2 >>16 ) &0xff ; - dev->dev_addr[4 ] = (mac2 >>8 ) &0xff ; - dev->dev_addr[5 ] = mac2 &0xff ; + addr[0 ] = (mac1 >>8 ) &0xff ; + addr[1 ] = mac1 &0xff ; + addr[2 ] = (mac2 >>24 ) &0xff ; + addr[3 ] = (mac2 >>16 ) &0xff ; + addr[4 ] = (mac2 >>8 ) &0xff ; + addr[5 ] = mac2 &0xff ; +eth_hw_addr_set (dev, addr);printk ("MAC: %pM\n" , dev->dev_addr);
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 4/12 ethernet: amd: 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/amd/amd8111e.c | 4 +++- drivers/net/ethernet/amd/pcnet32.c | 13 +++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-)
drivers/net/ethernet/amd/amd8111e.c +3 -1
@@ -1743,6 +1743,7 @@ static int amd8111e_probe_one(struct pci_dev *pdev,unsigned long reg_addr, reg_len;struct amd8111e_priv *lp;struct net_device *dev; +u8 addr[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];
drivers/net/ethernet/amd/pcnet32.c +9 -4
@@ -1595,6 +1595,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)struct net_device *dev;const struct pcnet32_access *a =NULL ;u8 promaddr[ETH_ALEN ]; +u8 addr[ETH_ALEN ];int ret = -ENODEV ;/* reset the chip */
@@ -1760,9 +1761,10 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)unsigned int val; 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)) { +static const u8 zero_addr[ETH_ALEN ] = {}; + +eth_hw_addr_set (dev, zero_addr); + }if (pcnet32_debug &NETIF_MSG_PROBE ) {pr_cont (" %pM" , dev->dev_addr);
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 5/12 ethernet: aquantia: 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.
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.
---
CC: [email protected]
--- drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +4 -2
@@ -300,6 +300,7 @@ static bool aq_nic_is_valid_ether_addr(const u8 *addr)int aq_nic_ndev_register (struct aq_nic_s *self) { +u8 addr[ETH_ALEN ];int err =0 ;if (!self->ndev) {
@@ -316,12 +317,13 @@ int aq_nic_ndev_register(struct aq_nic_s *self)#endif mutex_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) goto err_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." );
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 6/12 ethernet: bnx2x: 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]
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +11 -5
@@ -11823,9 +11823,10 @@ static void bnx2x_get_mac_hwinfo(struct bnx2x *bp)u32 val, val2;int func =BP_ABS_FUNC (bp);int port =BP_PORT (bp); +u8 addr[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" );
@@ -11834,8 +11835,10 @@ static void bnx2x_get_mac_hwinfo(struct bnx2x *bp) val2 =MF_CFG_RD (bp, func_mf_config[func].mac_upper); val =MF_CFG_RD (bp, func_mf_config[func].mac_lower);if ((val2 !=FUNC_MF_CFG_UPPERMAC_DEFAULT ) && - (val !=FUNC_MF_CFG_LOWERMAC_DEFAULT )) -bnx2x_set_mac_buf (bp->dev->dev_addr, val, val2); + (val !=FUNC_MF_CFG_LOWERMAC_DEFAULT )) { +bnx2x_set_mac_buf (addr, val, val2); +eth_hw_addr_set (bp->dev, addr); + }if (CNIC_SUPPORT (bp))bnx2x_get_cnic_mac_hwinfo (bp);
@@ -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)return rc; }else { -eth_zero_addr (bp->dev->dev_addr); +static const u8 zero_addr[ETH_ALEN ] = {}; + +eth_hw_addr_set (bp->dev, zero_addr); }bnx2x_set_modes_bitmap (bp);
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 7/12 ethernet: bcmgenet: 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]
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +6 -2
@@ -4085,8 +4085,12 @@ static int bcmgenet_probe(struct platform_device *pdev)eth_hw_addr_set (dev, pd->mac_address); else if (device_get_ethdev_address(&pdev->dev, dev)) - if (has_acpi_companion(&pdev->dev)) - bcmgenet_get_hw_addr(priv, dev->dev_addr); + if (has_acpi_companion(&pdev->dev)) { +u8 addr[ETH_ALEN ]; + +bcmgenet_get_hw_addr (priv, addr); +eth_hw_addr_set (dev, addr); + }if (!is_valid_ether_addr (dev->dev_addr)) {dev_warn (&pdev->dev,"using random Ethernet MAC\n" );
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 8/12 ethernet: enic: 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.
Use a zero'ed array on the stack, then call eth_hw_addr_set().
---
CC: [email protected]
CC: [email protected]
--- drivers/net/ethernet/cisco/enic/enic_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/cisco/enic/enic_main.c +3 -2
@@ -1098,6 +1098,7 @@ static int enic_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)static int enic_set_vf_port (struct net_device *netdev,int vf,struct nlattr *port[]) { +static const u8 zero_addr[ETH_ALEN ] = {};struct enic *enic =netdev_priv (netdev);struct enic_port_profile prev_pp;struct enic_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); } }
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 9/12 ethernet: ec_bhf: 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.
Copy the address into an array on the stack, then call eth_hw_addr_set().
---
CC: [email protected]
--- drivers/net/ethernet/ec_bhf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/ec_bhf.c +3 -1
@@ -479,6 +479,7 @@ static int ec_bhf_probe(struct pci_dev *dev, const struct pci_device_id *id)struct net_device *net_dev;struct ec_bhf_priv *priv;void __iomem *dma_io; +u8 addr[ETH_ALEN ];void __iomem *io;int err =0 ;
@@ -539,7 +540,8 @@ static int ec_bhf_probe(struct pci_dev *dev, const struct pci_device_id *id)if (err <0 ) goto err_free_net_dev; -memcpy_fromio (net_dev->dev_addr, priv->mii_io +MII_MAC_ADDR ,6 ); +memcpy_fromio (addr, priv->mii_io +MII_MAC_ADDR ,ETH_ALEN ); +eth_hw_addr_set (net_dev, addr); err =register_netdev (net_dev);if (err <0 )
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 11/12 ethernet: ibmveth: use ether_addr_to_u64()
In reply to Jakub KicinskiWe'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.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/net/ethernet/ibm/ibmveth.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/net/ethernet/ibm/ibmveth.c +3 -14
@@ -483,17 +483,6 @@ static int ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,return rc; } -static u64 ibmveth_encode_mac_addr (u8 *mac) -{ -int i; -u64 encoded =0 ; - -for (i =0 ; i <ETH_ALEN ; i++) - encoded = (encoded <<8 ) | mac[i]; - -return encoded; -} -static int ibmveth_open (struct net_device *netdev) {struct ibmveth_adapter *adapter =netdev_priv (netdev);
@@ -553,7 +542,7 @@ static int ibmveth_open(struct net_device *netdev) adapter->rx_queue.num_slots = rxq_entries; adapter->rx_queue.toggle =1 ; - mac_address =ibmveth_encode_mac_addr (netdev->dev_addr); + mac_address =ether_addr_to_u64 (netdev->dev_addr); rxq_desc.fields.flags_len =IBMVETH_BUF_VALID | adapter->rx_queue.queue_len;
@@ -1476,7 +1465,7 @@ static void ibmveth_set_multicast_list(struct net_device *netdev)netdev_for_each_mc_addr (ha, netdev) {/* add the multicast address to the filter table */ u64 mcast_addr; - mcast_addr =ibmveth_encode_mac_addr (ha->addr); + mcast_addr =ether_addr_to_u64 (ha->addr); lpar_rc =h_multicast_ctrl (adapter->vdev->unit_address, IbmVethMcastAddFilter, mcast_addr);
@@ -1606,7 +1595,7 @@ static int ibmveth_set_mac_addr(struct net_device *dev, void *p)if (!is_valid_ether_addr (addr->sa_data))return -EADDRNOTAVAIL ; - mac_address =ibmveth_encode_mac_addr (addr->sa_data); + mac_address =ether_addr_to_u64 (addr->sa_data); rc =h_change_logical_lan_mac (adapter->vdev->unit_address, mac_address);if (rc) {netdev_err (adapter->netdev,"h_change_logical_lan_mac failed with rc=%d\n" , rc);
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 10/12 ethernet: enetc: 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.
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().
---
CC: [email protected]
--- 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(-)
drivers/net/ethernet/freescale/enetc/enetc_hw.h +5 -1
@@ -635,10 +635,14 @@ struct enetc_cmd_rfse {#define ENETC_RFSE_EN BIT(15)#define ENETC_RFSE_MODE_BD 2 -static inline void enetc_get_primary_mac_addr (struct enetc_hw *hw,u8 *addr) +static inline void enetc_load_primary_mac_addr (struct enetc_hw *hw, +struct net_device *ndev) { +u8 addr[ETH_ALEN ]__aligned(4) ; + *(u32 *)addr =__raw_readl (hw->reg +ENETC_SIPMAR0 ); *(u16 *)(addr +4 ) =__raw_readw (hw->reg +ENETC_SIPMAR1 ); +eth_hw_addr_set (ndev, addr); }#define ENETC_SI_INT_IDX 0
drivers/net/ethernet/freescale/enetc/enetc_pf.c +1 -1
@@ -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); }static int enetc_mdio_probe (struct enetc_pf *pf,struct device_node *np)
drivers/net/ethernet/freescale/enetc/enetc_vf.c +1 -1
@@ -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); } static int enetc_vf_probe(struct pci_dev *pdev,
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 12/12 ethernet: ixgb: 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(). ixgb_get_ee_mac_addr() is used with a non-nevdev->dev_addr pointer so we can't deal with the problem inside it.
---
CC: [email protected]
CC: [email protected]
--- drivers/net/ethernet/intel/ixgb/ixgb_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgb/ixgb_main.c +6 -2
@@ -362,6 +362,7 @@ ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)struct ixgb_adapter *adapter;static int cards_found =0 ;int pci_using_dac; +u8 addr[ETH_ALEN ];int i;int err;
@@ -461,7 +462,8 @@ ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_eeprom; } -ixgb_get_ee_mac_addr (&adapter->hw, netdev->dev_addr); +ixgb_get_ee_mac_addr (&adapter->hw, addr); +eth_hw_addr_set (netdev, addr);if (!is_valid_ether_addr (netdev->dev_addr)) {netif_err (adapter, probe, adapter->netdev,"Invalid MAC Address\n" );
@@ -2227,6 +2229,7 @@ static pci_ers_result_t ixgb_io_slot_reset(struct pci_dev *pdev) {struct net_device *netdev =pci_get_drvdata (pdev);struct ixgb_adapter *adapter =netdev_priv (netdev); +u8 addr[ETH_ALEN ];if (pci_enable_device (pdev)) { netif_err(adapter, probe, adapter->netdev,
@@ -2250,7 +2253,8 @@ static pci_ers_result_t ixgb_io_slot_reset(struct pci_dev *pdev) "After reset, the EEPROM checksum is not valid\n");return PCI_ERS_RESULT_DISCONNECT ; } -ixgb_get_ee_mac_addr (&adapter->hw, netdev->dev_addr); +ixgb_get_ee_mac_addr (&adapter->hw, addr); +eth_hw_addr_set (netdev, addr);memcpy (netdev->perm_addr, netdev->dev_addr, netdev->addr_len);if (!is_valid_ether_addr (netdev->perm_addr)) {
Signature · 1 line
2.31.1
Re: [PATCH net-next 11/12] ethernet: ibmveth: use ether_addr_to_u64()
In reply to Jakub KicinskiQuoted 3 lines · Jakub Kicinski
We'll want to make
netdev->dev_addrconst, remove the local helper which is missing a const qualifier on the argument and useether_addr_to_u64().
LGTM. ibmveth_encode_mac_addr() is clearly code duplication of ether_addr_to_u64() minus the const qualifier.
Quoted 64 lines
Similar story to mlx4.
Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]--- drivers/net/ethernet/ibm/ibmveth.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)drivers/net/ethernet/ibm/ibmveth.c +3
-14@@ -483,17 +483,6 @@ static int ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,return rc; } -static u64 ibmveth_encode_mac_addr (u8 *mac) -{ -int i; -u64 encoded =0 ; - -for (i =0 ; i <ETH_ALEN ; i++) - encoded = (encoded <<8 ) | mac[i]; - -return encoded; -} -static int ibmveth_open (struct net_device *netdev) {struct ibmveth_adapter *adapter =netdev_priv (netdev);@@ -553,7 +542,7 @@ static int ibmveth_open(struct net_device *netdev) adapter->rx_queue.num_slots = rxq_entries; adapter->rx_queue.toggle =1 ; - mac_address =ibmveth_encode_mac_addr (netdev->dev_addr); + mac_address =ether_addr_to_u64 (netdev->dev_addr); rxq_desc.fields.flags_len =IBMVETH_BUF_VALID | adapter->rx_queue.queue_len;@@ -1476,7 +1465,7 @@ static void ibmveth_set_multicast_list(struct net_device *netdev)netdev_for_each_mc_addr (ha, netdev) {/* add the multicast address to the filter table */ u64 mcast_addr; - mcast_addr =ibmveth_encode_mac_addr (ha->addr); + mcast_addr =ether_addr_to_u64 (ha->addr); lpar_rc =h_multicast_ctrl (adapter->vdev->unit_address, IbmVethMcastAddFilter, mcast_addr);@@ -1606,7 +1595,7 @@ static int ibmveth_set_mac_addr(struct net_device *dev, void *p)if (!is_valid_ether_addr (addr->sa_data))return -EADDRNOTAVAIL ; - mac_address =ibmveth_encode_mac_addr (addr->sa_data); + mac_address =ether_addr_to_u64 (addr->sa_data); rc =h_change_logical_lan_mac (adapter->vdev->unit_address, mac_address);if (rc) {netdev_err (adapter->netdev,"h_change_logical_lan_mac failed with rc=%d\n" , rc);
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 17 lines · On Fri, 15 Oct 2021 15:16:40 -0700 you wrote:
Manual conversions of drivers writing directly
tonetdev->dev_addr(part 1 out of 3).Jakub Kicinski (12):
ethernet: adaptec: useeth_hw_addr_set()
ethernet: aeroflex: useeth_hw_addr_set()
ethernet: alteon: useeth_hw_addr_set()
ethernet: amd: useeth_hw_addr_set()
ethernet: aquantia: useeth_hw_addr_set()
ethernet: bnx2x: useeth_hw_addr_set()
ethernet: bcmgenet: useeth_hw_addr_set()
ethernet: enic: useeth_hw_addr_set()
ethernet:ec_bhf: useeth_hw_addr_set()
ethernet: enetc: useeth_hw_addr_set()
ethernet: ibmveth: useether_addr_to_u64()
ethernet: ixgb: useeth_hw_addr_set()
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,01/12] ethernet: adaptec: use eth_hw_addr_set()
https://git.kernel.org/netdev/net-next/c/8ec53ed9af1f - [net-next,02/12] ethernet: aeroflex: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/0d4c7517159f - [net-next,03/12] ethernet: alteon: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/ffaeca68fb5f - [net-next,04/12] ethernet: amd: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/f98c50509a20 - [net-next,05/12] ethernet: aquantia: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/698c33d8b489 - [net-next,06/12] ethernet: bnx2x: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/a85c8f9ad2f6 - [net-next,07/12] ethernet: bcmgenet: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/0c9e0c7931c6 - [net-next,08/12] ethernet: enic: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/41edfff572d9 - [net-next,09/12] ethernet: ec_bhf: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/10e6ded81235 - [net-next,10/12] ethernet: enetc: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/d9ca87233b68 - [net-next,11/12] ethernet: ibmveth: use ether_addr_to_u64() https://git.kernel.org/netdev/net-next/c/5c8b348534ac - [net-next,12/12] ethernet: ixgb: use eth_hw_addr_set() https://git.kernel.org/netdev/net-next/c/ec356edef78c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Re: [PATCH net-next 03/12] ethernet: alteon: use eth_hw_addr_set()
In reply to Jakub KicinskiSorry for top posting, mobile email clients suck.
Jes
Sent from MailDroid
-----Original Message-----
From: Jakub Kicinski <[email protected]>
To: [email protected]
Cc: [email protected], Jakub Kicinski <[email protected]>, [email protected], [email protected]
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().
---
CC: [email protected]
CC: [email protected]
--- drivers/net/ethernet/alteon/acenic.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/alteon/acenic.c +8 -6
@@ -869,6 +869,7 @@ static int ace_init(struct net_device *dev)int board_idx, ecode =0 ;short i;unsigned char cache_size; +u8 addr[ETH_ALEN ]; ap =netdev_priv (dev); regs = ap->regs;
@@ -988,12 +989,13 @@ static int ace_init(struct net_device *dev)writel (mac1, ®s->MacAddrHi);writel (mac2, ®s->MacAddrLo); - dev->dev_addr[0 ] = (mac1 >>8 ) &0xff ; - dev->dev_addr[1 ] = mac1 &0xff ; - dev->dev_addr[2 ] = (mac2 >>24 ) &0xff ; - dev->dev_addr[3 ] = (mac2 >>16 ) &0xff ; - dev->dev_addr[4 ] = (mac2 >>8 ) &0xff ; - dev->dev_addr[5 ] = mac2 &0xff ; + addr[0 ] = (mac1 >>8 ) &0xff ; + addr[1 ] = mac1 &0xff ; + addr[2 ] = (mac2 >>24 ) &0xff ; + addr[3 ] = (mac2 >>16 ) &0xff ; + addr[4 ] = (mac2 >>8 ) &0xff ; + addr[5 ] = mac2 &0xff ; +eth_hw_addr_set (dev, addr);printk ("MAC: %pM\n" , dev->dev_addr);
Signature · 1 line
2.31.1
Re: [PATCH net-next 07/12] ethernet: bcmgenet: use eth_hw_addr_set()
In reply to Jakub KicinskiQuoted 9 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]>
Signature · 1 line
Florian