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]
Date:   Tue, 18 Dec 2018 07:36:27 +0100
From:   Heiner Kallweit <hkallweit1@...il.com>
To:     Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        David Miller <davem@...emloft.net>,
        Ray Jui <rjui@...adcom.com>,
        Scott Branden <sbranden@...adcom.com>,
        bcm-kernel-feedback-list@...adcom.com
Cc:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: [PATCH net-next 1/2] net: phy: set 1Gbps as default for driver
 features

Whether a PHY is 100MBps or 1Gbps-capable can be autodetected,
therefore it's not needed to define this manually in the driver.
genphy_config_init() will remove 1Gbps from phydev->supported if
not supported. Having said that PHY drivers for 100Mbps not
calling genphy_config_init() still have to set the features field.
As most PHY's are 1Gbps-capable let's use this as default.

Signed-off-by: Heiner Kallweit <hkallweit1@...il.com>
---
 drivers/net/phy/phy_device.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 54af2bde6..753451341 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -2138,6 +2138,7 @@ static int phy_probe(struct device *dev)
 	struct phy_device *phydev = to_phy_device(dev);
 	struct device_driver *drv = phydev->mdio.dev.driver;
 	struct phy_driver *phydrv = to_phy_driver(drv);
+	const long unsigned int *features;
 	int err = 0;
 
 	phydev->drv = phydrv;
@@ -2153,11 +2154,14 @@ static int phy_probe(struct device *dev)
 
 	mutex_lock(&phydev->lock);
 
+	/* Use 1Gbps as default if driver defines no features */
+	features = phydrv->features ?: phy_gbit_features;
+
 	/* Start out supporting everything. Eventually,
 	 * a controller will attach, and may modify one
 	 * or both of these values
 	 */
-	linkmode_copy(phydev->supported, phydrv->features);
+	linkmode_copy(phydev->supported, features);
 	of_set_phy_supported(phydev);
 	linkmode_copy(phydev->advertising, phydev->supported);
 
@@ -2177,17 +2181,16 @@ static int phy_probe(struct device *dev)
 	 * (e.g. hardware erratum) where the driver wants to set only one
 	 * of these bits.
 	 */
-	if (test_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydrv->features) ||
-	    test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydrv->features)) {
+	if (test_bit(ETHTOOL_LINK_MODE_Pause_BIT, features) ||
+	    test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, features)) {
 		linkmode_clear_bit(ETHTOOL_LINK_MODE_Pause_BIT,
 				   phydev->supported);
 		linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
 				   phydev->supported);
-		if (test_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydrv->features))
+		if (test_bit(ETHTOOL_LINK_MODE_Pause_BIT, features))
 			linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT,
 					 phydev->supported);
-		if (test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
-			     phydrv->features))
+		if (test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, features))
 			linkmode_set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
 					 phydev->supported);
 	} else {
-- 
2.20.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ