Skip to content

Commit 4962186

Browse files
Raghuram Chary Jdavem330
authored andcommitted
lan78xx: Add support to dump lan78xx registers
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>
1 parent 0a8b275 commit 4962186

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

drivers/net/usb/lan78xx.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,30 @@ struct lan78xx_statstage64 {
280280
u64 eee_tx_lpi_time;
281281
};
282282

283+
static u32 lan78xx_regs[] = {
284+
ID_REV,
285+
INT_STS,
286+
HW_CFG,
287+
PMT_CTL,
288+
E2P_CMD,
289+
E2P_DATA,
290+
USB_STATUS,
291+
VLAN_TYPE,
292+
MAC_CR,
293+
MAC_RX,
294+
MAC_TX,
295+
FLOW,
296+
ERR_STS,
297+
MII_ACC,
298+
MII_DATA,
299+
EEE_TX_LPI_REQ_DLY,
300+
EEE_TW_TX_SYS,
301+
EEE_TX_LPI_REM_DLY,
302+
WUCSR
303+
};
304+
305+
#define PHY_REG_SIZE (32 * sizeof(u32))
306+
283307
struct lan78xx_net;
284308

285309
struct lan78xx_priv {
@@ -1607,6 +1631,34 @@ static int lan78xx_set_pause(struct net_device *net,
16071631
return ret;
16081632
}
16091633

1634+
static int lan78xx_get_regs_len(struct net_device *netdev)
1635+
{
1636+
if (!netdev->phydev)
1637+
return (sizeof(lan78xx_regs));
1638+
else
1639+
return (sizeof(lan78xx_regs) + PHY_REG_SIZE);
1640+
}
1641+
1642+
static void
1643+
lan78xx_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
1644+
void *buf)
1645+
{
1646+
u32 *data = buf;
1647+
int i, j;
1648+
struct lan78xx_net *dev = netdev_priv(netdev);
1649+
1650+
/* Read Device/MAC registers */
1651+
for (i = 0; i < (sizeof(lan78xx_regs) / sizeof(u32)); i++)
1652+
lan78xx_read_reg(dev, lan78xx_regs[i], &data[i]);
1653+
1654+
if (!netdev->phydev)
1655+
return;
1656+
1657+
/* Read PHY registers */
1658+
for (j = 0; j < 32; i++, j++)
1659+
data[i] = phy_read(netdev->phydev, j);
1660+
}
1661+
16101662
static const struct ethtool_ops lan78xx_ethtool_ops = {
16111663
.get_link = lan78xx_get_link,
16121664
.nway_reset = phy_ethtool_nway_reset,
@@ -1627,6 +1679,8 @@ static const struct ethtool_ops lan78xx_ethtool_ops = {
16271679
.set_pauseparam = lan78xx_set_pause,
16281680
.get_link_ksettings = lan78xx_get_link_ksettings,
16291681
.set_link_ksettings = lan78xx_set_link_ksettings,
1682+
.get_regs_len = lan78xx_get_regs_len,
1683+
.get_regs = lan78xx_get_regs,
16301684
};
16311685

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

0 commit comments

Comments
 (0)