From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steve Douthit Subject: [PATCH net-next v2 2/2] ixgbe: use mii_bus to handle MII related ioctls Date: Mon, 3 Dec 2018 16:33:01 +0000 Message-ID: <20181203163227.5107-3-stephend@silicom-usa.com> References: <20181203163227.5107-1-stephend@silicom-usa.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "David S. Miller" , "intel-wired-lan@lists.osuosl.org" , "netdev@vger.kernel.org" , Andrew Lunn , Florian Fainelli , Steve Douthit To: Jeff Kirsher Return-path: Received: from mail-eopbgr50097.outbound.protection.outlook.com ([40.107.5.97]:8117 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726615AbeLCQdI (ORCPT ); Mon, 3 Dec 2018 11:33:08 -0500 In-Reply-To: <20181203163227.5107-1-stephend@silicom-usa.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: 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. Signed-off-by: Stephen Douthit --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/et= hernet/intel/ixgbe/ixgbe_main.c index 82af3b24d222..fb066c491abe 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -8790,6 +8790,15 @@ ixgbe_mdio_read(struct net_device *netdev, int prtad= , int devad, u16 addr) u16 value; int rc; =20 + if (adapter->mii_bus) { + int regnum =3D addr; + + if (devad !=3D MDIO_DEVAD_NONE) + regnum |=3D (devad << 16) | MII_ADDR_C45; + + return mdiobus_read(adapter->mii_bus, prtad, regnum); + } + if (prtad !=3D hw->phy.mdio.prtad) return -EINVAL; rc =3D hw->phy.ops.read_reg(hw, addr, devad, &value); @@ -8804,6 +8813,15 @@ static int ixgbe_mdio_write(struct net_device *netde= v, int prtad, int devad, struct ixgbe_adapter *adapter =3D netdev_priv(netdev); struct ixgbe_hw *hw =3D &adapter->hw; =20 + if (adapter->mii_bus) { + int regnum =3D addr; + + if (devad !=3D MDIO_DEVAD_NONE) + regnum |=3D (devad << 16) | MII_ADDR_C45; + + return mdiobus_write(adapter->mii_bus, prtad, regnum, value); + } + if (prtad !=3D hw->phy.mdio.prtad) return -EINVAL; return hw->phy.ops.write_reg(hw, addr, devad, value); --=20 2.17.2 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steve Douthit Date: Mon, 3 Dec 2018 16:33:01 +0000 Subject: [Intel-wired-lan] [PATCH net-next v2 2/2] ixgbe: use mii_bus to handle MII related ioctls In-Reply-To: <20181203163227.5107-1-stephend@silicom-usa.com> References: <20181203163227.5107-1-stephend@silicom-usa.com> Message-ID: <20181203163227.5107-3-stephend@silicom-usa.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: intel-wired-lan@osuosl.org List-ID: 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. Signed-off-by: Stephen Douthit --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 82af3b24d222..fb066c491abe 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -8790,6 +8790,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); @@ -8804,6 +8813,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); -- 2.17.2