diff mbox series

[v7,02/11] net: pch_gbe: Mask spare MAC addresses all at once

Message ID 20180627000612.27263-3-paul.burton@mips.com
State Changes Requested, archived
Delegated to: David Miller
Headers show
Series net: pch_gbe: Fixes, conversion to phylib, enable for MIPS | expand

Commit Message

Paul Burton June 27, 2018, 12:06 a.m. UTC
pch_gbe_set_multi() loops through each unused MAC address register,
masking them one by one & waiting for a bit to clear indicating that the
change has taken effect before zeroing out the MAC register.

This is needlessly inefficient. We can instead set all the desired mask
bits with a single write to the ADDR_MASK register & wait only once for
the busy bit to clear indicating that the addresses are masked (ie.
ignored) as required.

It's pointless zeroing the MAC registers since they're masked anyway so
their contents are irrelevant, so we can avoid looping over them here
entirely.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---

Changes in v7: New patch

 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 8908ef654d94..9651fa02d4bb 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -2140,15 +2140,13 @@  static void pch_gbe_set_multi(struct net_device *netdev)
 		pch_gbe_mac_mar_set(hw, ha->addr, i++);
 
 	/* If there are spare MAC registers, mask & clear them */
-	for (; i < PCH_GBE_MAR_ENTRIES; i++) {
-		/* Clear MAC address mask */
+	if (i < PCH_GBE_MAR_ENTRIES) {
 		adrmask = ioread32(&hw->reg->ADDR_MASK);
-		iowrite32(adrmask | BIT(i), &hw->reg->ADDR_MASK);
+		adrmask |= GENMASK(PCH_GBE_MAR_ENTRIES - 1, i);
+		iowrite32(adrmask, &hw->reg->ADDR_MASK);
+
 		/* wait busy */
 		pch_gbe_wait_clr_bit(&hw->reg->ADDR_MASK, PCH_GBE_BUSY);
-		/* Clear MAC address */
-		iowrite32(0, &hw->reg->mac_adr[i].high);
-		iowrite32(0, &hw->reg->mac_adr[i].low);
 	}
 
 	netdev_dbg(netdev,