Skip to content

Commit

Permalink
lan78xx: Add support to dump lan78xx registers
Browse files Browse the repository at this point in the history
In order to dump lan78xx family registers using ethtool, add
support at lan78xx driver level.

Signed-off-by: Raghuram Chary J <raghuramchary.jallipalli@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Raghuram Chary J authored and David S. Miller committed Apr 20, 2018
1 parent 0a8b275 commit 4962186
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions drivers/net/usb/lan78xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,30 @@ struct lan78xx_statstage64 {
u64 eee_tx_lpi_time;
};

static u32 lan78xx_regs[] = {
ID_REV,
INT_STS,
HW_CFG,
PMT_CTL,
E2P_CMD,
E2P_DATA,
USB_STATUS,
VLAN_TYPE,
MAC_CR,
MAC_RX,
MAC_TX,
FLOW,
ERR_STS,
MII_ACC,
MII_DATA,
EEE_TX_LPI_REQ_DLY,
EEE_TW_TX_SYS,
EEE_TX_LPI_REM_DLY,
WUCSR
};

#define PHY_REG_SIZE (32 * sizeof(u32))

struct lan78xx_net;

struct lan78xx_priv {
Expand Down Expand Up @@ -1607,6 +1631,34 @@ static int lan78xx_set_pause(struct net_device *net,
return ret;
}

static int lan78xx_get_regs_len(struct net_device *netdev)
{
if (!netdev->phydev)
return (sizeof(lan78xx_regs));
else
return (sizeof(lan78xx_regs) + PHY_REG_SIZE);
}

static void
lan78xx_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
void *buf)
{
u32 *data = buf;
int i, j;
struct lan78xx_net *dev = netdev_priv(netdev);

/* Read Device/MAC registers */
for (i = 0; i < (sizeof(lan78xx_regs) / sizeof(u32)); i++)
lan78xx_read_reg(dev, lan78xx_regs[i], &data[i]);

if (!netdev->phydev)
return;

/* Read PHY registers */
for (j = 0; j < 32; i++, j++)
data[i] = phy_read(netdev->phydev, j);
}

static const struct ethtool_ops lan78xx_ethtool_ops = {
.get_link = lan78xx_get_link,
.nway_reset = phy_ethtool_nway_reset,
Expand All @@ -1627,6 +1679,8 @@ static const struct ethtool_ops lan78xx_ethtool_ops = {
.set_pauseparam = lan78xx_set_pause,
.get_link_ksettings = lan78xx_get_link_ksettings,
.set_link_ksettings = lan78xx_set_link_ksettings,
.get_regs_len = lan78xx_get_regs_len,
.get_regs = lan78xx_get_regs,
};

static int lan78xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
Expand Down

0 comments on commit 4962186

Please sign in to comment.