ixgbe: register a mdiobus
Subsystems (2)
PATCH 1/2 ixgbe: register a mdiobus
From: Steve Douthit <[email protected]>
Most dsa devices expect a 'struct mii_bus' pointer to talk to switches via the MII interface.
Signed-off-by Stephen Douthit <[email protected]>
--- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 2 + drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 + drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c | 192 ++++++++++++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h | 2 + 4 files changed, 202 insertions(+)
drivers/net/ethernet/intel/ixgbe/ixgbe.h +2 -0
@@ -12,6 +12,7 @@#include <linux/aer.h> #include <linux/if_vlan.h> #include <linux/jiffies.h> +#include <linux/phy.h> #include <linux/timecounter.h> #include <linux/net_tstamp.h>
@@ -561,6 +562,7 @@ struct ixgbe_adapter {struct net_device *netdev;struct bpf_prog *xdp_prog;struct pci_dev *pdev; +struct mii_bus *mii_bus;unsigned long state;
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +6 -0
@@ -39,6 +39,7 @@#include "ixgbe.h" #include "ixgbe_common.h" #include "ixgbe_dcb_82599.h" +#include "ixgbe_phy.h" #include "ixgbe_sriov.h" #include "ixgbe_model.h" #include "ixgbe_txrx_common.h"
@@ -11120,6 +11121,9 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)IXGBE_LINK_SPEED_10GB_FULL |IXGBE_LINK_SPEED_1GB_FULL , true); +if (ixgbe_mii_bus_init (hw)) +e_err (probe,"failed to create mii_bus\n" ); +return 0 ; err_register:
@@ -11170,6 +11174,8 @@ static void ixgbe_remove(struct pci_dev *pdev)set_bit (__IXGBE_REMOVING, &adapter->state);cancel_work_sync (&adapter->service_task); +if (adapter->mii_bus) +mdiobus_unregister (adapter->mii_bus);#ifdef CONFIG_IXGBE_DCA if (adapter->flags &IXGBE_FLAG_DCA_ENABLED ) {
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c +192 -0
198 lines not on this page · raw message
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h +2 -0
@@ -120,6 +120,8 @@/* SFP+ SFF-8472 Compliance code */ #define IXGBE_SFF_SFF_8472_UNSUP 0x00 +s32 ixgbe_mii_bus_init (struct ixgbe_hw *hw); +s32 ixgbe_identify_phy_generic (struct ixgbe_hw *hw);s32 ixgbe_reset_phy_generic (struct ixgbe_hw *hw); s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
PATCH 2/2 ixgbe: use mii_bus to handle MII related ioctls
From: Steve Douthit <[email protected]>
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 <[email protected]>
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +14 -15
@@ -8786,27 +8786,26 @@ static int ixgbe_mdio_read(struct net_device *netdev, int prtad, int devad, u16 addr) { struct ixgbe_adapter *adapter = netdev_priv(netdev); -struct ixgbe_hw *hw = &adapter->hw; -u16 value; -int rc; +struct mii_bus *mii_bus = adapter->mii_bus; +int regnum = addr; -if (prtad != hw->phy.mdio.prtad) -return -EINVAL ; - rc = hw->phy.ops.read_reg (hw, addr, devad, &value); -if (!rc) - rc = value; -return rc; +if (devad !=MDIO_DEVAD_NONE ) + regnum |= (devad <<16 ) |MII_ADDR_C45 ; + +return mdiobus_read (mii_bus, prtad, regnum); }static int ixgbe_mdio_write (struct net_device *netdev,int prtad,int devad,u16 addr,u16 value) {struct ixgbe_adapter *adapter =netdev_priv (netdev); -struct ixgbe_hw *hw = &adapter->hw; +struct mii_bus *mii_bus = adapter->mii_bus; +int regnum = addr; -if (prtad != hw->phy.mdio.prtad) -return -EINVAL ; -return hw->phy.ops.write_reg (hw, addr, devad, value); +if (devad !=MDIO_DEVAD_NONE ) + regnum |= (devad <<16 ) |MII_ADDR_C45 ; + +return mdiobus_write (mii_bus, prtad, regnum, value); }static int ixgbe_ioctl (struct net_device *netdev,struct ifreq *req,int cmd)
@@ -8819,7 +8818,7 @@ static int ixgbe_ioctl(struct net_device *netdev, struct ifreq *req, int cmd)case SIOCGHWTSTAMP :return ixgbe_ptp_get_ts_config (adapter, req);case SIOCGMIIPHY : -if (!adapter->hw.phy.ops.read_reg) +if (!adapter->mii_bus)return -EOPNOTSUPP ;/* fall through */ default :
@@ -10796,7 +10795,7 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)/* ixgbe_identify_phy_generic will set prtad and mmds properly */ hw->phy.mdio.prtad =MDIO_PRTAD_NONE ; hw->phy.mdio.mmds =0 ; - hw->phy.mdio.mode_support =MDIO_SUPPORTS_C45 |MDIO_EMULATE_C22 ; + hw->phy.mdio.mode_support =MDIO_SUPPORTS_C45 |MDIO_SUPPORTS_C22 ; hw->phy.mdio.dev = netdev; hw->phy.mdio.mdio_read = ixgbe_mdio_read; hw->phy.mdio.mdio_write = ixgbe_mdio_write;