ixgbe: use mii_bus to handle MII related ioctls
authorSteve Douthit <stephend@silicom-usa.com>
Thu, 6 Dec 2018 15:50:43 +0000 (15:50 +0000)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Thu, 20 Dec 2018 20:22:39 +0000 (12:22 -0800)
Use the mii_bus callbacks to address the entire clause 22/45 address
space.  Enables userspace to poke switch registers instead of a single
PHY address.

The ixgbe firmware may be polling PHYs in a way that is not protected by
the mii_bus lock.  This isn't new behavior, but as Andrew Lunn pointed
out there are more addresses available for conflicts.

Signed-off-by: Stephen Douthit <stephend@silicom-usa.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

index 7a3798ff236605a32565589ec93a28a81104ebe2..daff8183534b96b1aa3dbaaf482d5d7c5101c1f9 100644 (file)
@@ -8791,6 +8791,15 @@ ixgbe_mdio_read(struct net_device *netdev, int prtad, int devad, u16 addr)
        u16 value;
        int rc;
 
+       if (adapter->mii_bus) {
+               int regnum = addr;
+
+               if (devad != MDIO_DEVAD_NONE)
+                       regnum |= (devad << 16) | MII_ADDR_C45;
+
+               return mdiobus_read(adapter->mii_bus, prtad, regnum);
+       }
+
        if (prtad != hw->phy.mdio.prtad)
                return -EINVAL;
        rc = hw->phy.ops.read_reg(hw, addr, devad, &value);
@@ -8805,6 +8814,15 @@ static int ixgbe_mdio_write(struct net_device *netdev, int prtad, int devad,
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
        struct ixgbe_hw *hw = &adapter->hw;
 
+       if (adapter->mii_bus) {
+               int regnum = addr;
+
+               if (devad != MDIO_DEVAD_NONE)
+                       regnum |= (devad << 16) | MII_ADDR_C45;
+
+               return mdiobus_write(adapter->mii_bus, prtad, regnum, value);
+       }
+
        if (prtad != hw->phy.mdio.prtad)
                return -EINVAL;
        return hw->phy.ops.write_reg(hw, addr, devad, value);