Re: [PATCH net 2/3] lan78xx: Add support to dump lan78xx registers

2018-04-10 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 55d7de9de6c3 Microchip's LAN7800 family USB 2/3 to 10/100/1000 
Ethernet device driver.

The bot has tested the following trees: v4.16.1, v4.15.16, v4.14.33, v4.9.93, 
v4.4.127.

v4.16.1: Build OK!
v4.15.16: Build OK!
v4.14.33: Build OK!
v4.9.93: Failed to apply! Possible dependencies:
6e76510e7e19 ("net: usb: lan78xx: use new api 
ethtool_{get|set}_link_ksettings")

v4.4.127: Failed to apply! Possible dependencies:
20ff55655a93 ("lan78xx: handle statistics counter rollover")
349e0c5e2237 ("lan78xx: add ethtool set & get pause functions")
6e76510e7e19 ("net: usb: lan78xx: use new api 
ethtool_{get|set}_link_ksettings")


--
Thanks,
Sasha

RE: [PATCH net 2/3] lan78xx: Add support to dump lan78xx registers

2018-04-09 Thread RaghuramChary.Jallipalli
> If there is no PHY attached, you probably should not include PHY_REG_SIZE
> here.
> 
Sure, will address it.

Thanks,
Raghu


Re: [PATCH net 2/3] lan78xx: Add support to dump lan78xx registers

2018-04-06 Thread Andrew Lunn
> +static int lan78xx_get_regs_len(struct net_device *netdev)
> +{
> + return (sizeof(lan78xx_regs) + PHY_REG_SIZE);

If there is no PHY attached, you probably should not include
PHY_REG_SIZE here.

 Andrew


[PATCH net 2/3] lan78xx: Add support to dump lan78xx registers

2018-04-06 Thread Raghuram Chary J
In order to dump lan78xx family registers using ethtool, add
support at lan78xx driver level.

Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 
Ethernet device driver")
Signed-off-by: Raghuram Chary J 
---
 drivers/net/usb/lan78xx.c | 51 +++
 1 file changed, 51 insertions(+)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 55a78eb96961..e3cc3b504c87 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -278,6 +278,30 @@ struct lan78xx_statstage64 {
u64 eee_tx_lpi_time;
 };
 
+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 {
@@ -1604,6 +1628,31 @@ static int lan78xx_set_pause(struct net_device *net,
return ret;
 }
 
+static int lan78xx_get_regs_len(struct net_device *netdev)
+{
+   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, j = 0; i < (sizeof(lan78xx_regs) / sizeof(u32)); i++, j++)
+   lan78xx_read_reg(dev, lan78xx_regs[i], [j]);
+
+   if (!netdev->phydev)
+   return;
+
+   /* Read PHY registers */
+   for (i = 0; i < 32; i++, j++)
+   data[j] = phy_read(netdev->phydev, i);
+}
+
 static const struct ethtool_ops lan78xx_ethtool_ops = {
.get_link   = lan78xx_get_link,
.nway_reset = phy_ethtool_nway_reset,
@@ -1624,6 +1673,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)
-- 
2.16.2