lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180627000612.27263-9-paul.burton@mips.com>
Date:   Tue, 26 Jun 2018 17:06:09 -0700
From:   Paul Burton <paul.burton@...s.com>
To:     netdev@...r.kernel.org
Cc:     "David S . Miller" <davem@...emloft.net>,
        Andrew Lunn <andrew@...n.ch>, paul.burton@...s.com
Subject: [PATCH v7 08/11] net: pch_gbe: Clean up resets

Currently pch_gbe_reset() performs a number of tasks:

  1) Calls pch_gbe_reset_hw(), which:

     1a) Reads the MAC address from the hardware, even though we already
         did that in pch_gbe_open() & it should not have changed.

     1b) Writes to the RESET register to reset the MAC.

     1c) Writes the MODE register to configure GMII/RGMII mode,
         potentially before the MAC reset has finished.

     1d) Polls for the completion of the MAC reset.

     1e) Configures the device MAC address.

  2) Calls pch_gbe_set_multi() to configure multicast addresses &
     hardware MAC filtering.

  3) Calls pch_gbe_mac_init_rx_addrs(), which:

     3a) Configures the device MAC address again, duplicating step 1e.

     3b) Masks & clears all other MAC registers, wiping out the
         configuration performed by step 2.

This is needlessly repetitive & split across 3 functions for no good
reason. This patch cleans this up significantly by:

  a) Inlining pch_gbe_mac_reset_hw() into pch_gbe_reset(), moving the
     MODE register write to after the MAC reset has completed & removing
     the initial read of the MAC address.

  b) Removing pch_gbe_mac_init_rx_addrs() entirely, leaving the
     address configuration performed by pch_gbe_set_multi() intact.

With this done we know that pch_gbe_reset() will leave us with the
multicast MAC addresses & filtering configured correctly, so we can
remove the call to pch_gbe_set_multi() in pch_gbe_watchdog().

Signed-off-by: Paul Burton <paul.burton@...s.com>
Cc: Andrew Lunn <andrew@...n.ch>
Cc: David S. Miller <davem@...emloft.net>
Cc: netdev@...r.kernel.org
---

Changes in v7: New patch

 .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c  | 54 ++++---------------
 1 file changed, 11 insertions(+), 43 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 c9b064ac06a1..123c7818698d 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
@@ -357,22 +357,6 @@ static void pch_gbe_mac_mar_set(struct pch_gbe_hw *hw, u8 * addr, u32 index)
 	pch_gbe_wait_clr_bit(&hw->reg->ADDR_MASK, PCH_GBE_BUSY);
 }
 
-/**
- * pch_gbe_mac_reset_hw - Reset hardware
- * @hw:	Pointer to the HW structure
- */
-static void pch_gbe_mac_reset_hw(struct pch_gbe_hw *hw)
-{
-	/* Read the MAC address. and store to the private data */
-	pch_gbe_mac_read_mac_addr(hw);
-	iowrite32(PCH_GBE_ALL_RST, &hw->reg->RESET);
-	iowrite32(PCH_GBE_MODE_GMII_ETHER, &hw->reg->MODE);
-	pch_gbe_wait_clr_bit(&hw->reg->RESET, PCH_GBE_ALL_RST);
-	/* Setup the receive addresses */
-	pch_gbe_mac_mar_set(hw, hw->mac.addr, 0);
-	return;
-}
-
 static void pch_gbe_disable_mac_rx(struct pch_gbe_hw *hw)
 {
 	u32 rctl;
@@ -389,28 +373,6 @@ static void pch_gbe_enable_mac_rx(struct pch_gbe_hw *hw)
 	iowrite32((rctl | PCH_GBE_MRE_MAC_RX_EN), &hw->reg->MAC_RX_EN);
 }
 
-/**
- * pch_gbe_mac_init_rx_addrs - Initialize receive address's
- * @hw:	Pointer to the HW structure
- * @mar_count: Receive address registers
- */
-static void pch_gbe_mac_init_rx_addrs(struct pch_gbe_hw *hw, u16 mar_count)
-{
-	u32 i;
-
-	/* Setup the receive address */
-	pch_gbe_mac_mar_set(hw, hw->mac.addr, 0);
-
-	/* Zero out the other receive addresses */
-	for (i = 1; i < mar_count; i++) {
-		iowrite32(0, &hw->reg->mac_adr[i].high);
-		iowrite32(0, &hw->reg->mac_adr[i].low);
-	}
-	iowrite32(0xFFFE, &hw->reg->ADDR_MASK);
-	/* wait busy */
-	pch_gbe_wait_clr_bit(&hw->reg->ADDR_MASK, PCH_GBE_BUSY);
-}
-
 /**
  * pch_gbe_mac_force_mac_fc - Force the MAC's flow control settings
  * @hw:	            Pointer to the HW structure
@@ -734,11 +696,18 @@ void pch_gbe_reset(struct pch_gbe_adapter *adapter)
 	struct net_device *netdev = adapter->netdev;
 	struct pch_gbe_hw *hw = &adapter->hw;
 
-	pch_gbe_mac_reset_hw(hw);
-	/* reprogram multicast address register after reset */
+	/* Perform the reset & wait for it to complete */
+	iowrite32(PCH_GBE_ALL_RST, &hw->reg->RESET);
+	pch_gbe_wait_clr_bit(&hw->reg->RESET, PCH_GBE_ALL_RST);
+
+	/* Configure GMII/RGMII mode */
+	iowrite32(PCH_GBE_MODE_GMII_ETHER, &hw->reg->MODE);
+
+	/* Program the MAC address */
+	pch_gbe_mac_mar_set(hw, hw->mac.addr, 0);
+
+	/* Configure multicast addresses & filtering */
 	pch_gbe_set_multi(netdev);
-	/* Setup the receive address. */
-	pch_gbe_mac_init_rx_addrs(hw, PCH_GBE_MAR_ENTRIES);
 }
 
 /**
@@ -1944,7 +1913,6 @@ static void pch_gbe_watchdog(struct timer_list *t)
 		pch_gbe_set_mode(adapter, hw->mac.link_speed,
 				 hw->mac.link_duplex);
 
-		pch_gbe_set_multi(netdev);
 		pch_gbe_setup_tctl(adapter);
 		pch_gbe_configure_tx(adapter);
 		pch_gbe_setup_rctl(adapter);
-- 
2.18.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ