From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Burton Subject: [PATCH v7 02/11] net: pch_gbe: Mask spare MAC addresses all at once Date: Tue, 26 Jun 2018 17:06:03 -0700 Message-ID: <20180627000612.27263-3-paul.burton@mips.com> References: <20180627000612.27263-1-paul.burton@mips.com> Mime-Version: 1.0 Content-Type: text/plain Cc: "David S . Miller" , Andrew Lunn , paul.burton@mips.com To: netdev@vger.kernel.org Return-path: Received: from mail-eopbgr700099.outbound.protection.outlook.com ([40.107.70.99]:11034 "EHLO NAM04-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754676AbeF0AGf (ORCPT ); Tue, 26 Jun 2018 20:06:35 -0400 In-Reply-To: <20180627000612.27263-1-paul.burton@mips.com> Sender: netdev-owner@vger.kernel.org List-ID: 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 Cc: Andrew Lunn Cc: David S. Miller 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 --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, -- 2.18.0