aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMugunthan V N <mugunthanvnm@ti.com>2014-07-22 13:55:07 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-22 22:58:25 -0400
commit52c4f0ec662bbf02f1b0bcb311a48af2c8e5ee89 (patch)
tree64293c54add14d887ffcd6fa1313238f0085d2b5
parent63502b8d01631bd41778a64c9f6b72ea409bf97b (diff)
drivers: net: cpsw: add support to dump ALE table via ethtool register dump
Add support to view addresses added by the driver and learnt by the hardware from ALE table via ethtool register dump interface. Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/ti/cpsw.c24
-rw-r--r--drivers/net/ethernet/ti/cpsw_ale.c12
-rw-r--r--drivers/net/ethernet/ti/cpsw_ale.h4
3 files changed, 37 insertions, 3 deletions
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index ae6379af5b4d..60f925df15e2 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1675,14 +1675,34 @@ static const struct net_device_ops cpsw_netdev_ops = {
1675 .ndo_vlan_rx_kill_vid = cpsw_ndo_vlan_rx_kill_vid, 1675 .ndo_vlan_rx_kill_vid = cpsw_ndo_vlan_rx_kill_vid,
1676}; 1676};
1677 1677
1678static int cpsw_get_regs_len(struct net_device *ndev)
1679{
1680 struct cpsw_priv *priv = netdev_priv(ndev);
1681
1682 return priv->data.ale_entries * ALE_ENTRY_WORDS * sizeof(u32);
1683}
1684
1685static void cpsw_get_regs(struct net_device *ndev,
1686 struct ethtool_regs *regs, void *p)
1687{
1688 struct cpsw_priv *priv = netdev_priv(ndev);
1689 u32 *reg = p;
1690
1691 /* update CPSW IP version */
1692 regs->version = priv->version;
1693
1694 cpsw_ale_dump(priv->ale, reg);
1695}
1696
1678static void cpsw_get_drvinfo(struct net_device *ndev, 1697static void cpsw_get_drvinfo(struct net_device *ndev,
1679 struct ethtool_drvinfo *info) 1698 struct ethtool_drvinfo *info)
1680{ 1699{
1681 struct cpsw_priv *priv = netdev_priv(ndev); 1700 struct cpsw_priv *priv = netdev_priv(ndev);
1682 1701
1683 strlcpy(info->driver, "TI CPSW Driver v1.0", sizeof(info->driver)); 1702 strlcpy(info->driver, "cpsw", sizeof(info->driver));
1684 strlcpy(info->version, "1.0", sizeof(info->version)); 1703 strlcpy(info->version, "1.0", sizeof(info->version));
1685 strlcpy(info->bus_info, priv->pdev->name, sizeof(info->bus_info)); 1704 strlcpy(info->bus_info, priv->pdev->name, sizeof(info->bus_info));
1705 info->regdump_len = cpsw_get_regs_len(ndev);
1686} 1706}
1687 1707
1688static u32 cpsw_get_msglevel(struct net_device *ndev) 1708static u32 cpsw_get_msglevel(struct net_device *ndev)
@@ -1790,6 +1810,8 @@ static const struct ethtool_ops cpsw_ethtool_ops = {
1790 .get_ethtool_stats = cpsw_get_ethtool_stats, 1810 .get_ethtool_stats = cpsw_get_ethtool_stats,
1791 .get_wol = cpsw_get_wol, 1811 .get_wol = cpsw_get_wol,
1792 .set_wol = cpsw_set_wol, 1812 .set_wol = cpsw_set_wol,
1813 .get_regs_len = cpsw_get_regs_len,
1814 .get_regs = cpsw_get_regs,
1793}; 1815};
1794 1816
1795static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv, 1817static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv,
diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 7f893069c418..0579b2243bb6 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -25,8 +25,6 @@
25#include "cpsw_ale.h" 25#include "cpsw_ale.h"
26 26
27#define BITMASK(bits) (BIT(bits) - 1) 27#define BITMASK(bits) (BIT(bits) - 1)
28#define ALE_ENTRY_BITS 68
29#define ALE_ENTRY_WORDS DIV_ROUND_UP(ALE_ENTRY_BITS, 32)
30 28
31#define ALE_VERSION_MAJOR(rev) ((rev >> 8) & 0xff) 29#define ALE_VERSION_MAJOR(rev) ((rev >> 8) & 0xff)
32#define ALE_VERSION_MINOR(rev) (rev & 0xff) 30#define ALE_VERSION_MINOR(rev) (rev & 0xff)
@@ -763,3 +761,13 @@ int cpsw_ale_destroy(struct cpsw_ale *ale)
763 kfree(ale); 761 kfree(ale);
764 return 0; 762 return 0;
765} 763}
764
765void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data)
766{
767 int i;
768
769 for (i = 0; i < ale->params.ale_entries; i++) {
770 cpsw_ale_read(ale, i, data);
771 data += ALE_ENTRY_WORDS;
772 }
773}
diff --git a/drivers/net/ethernet/ti/cpsw_ale.h b/drivers/net/ethernet/ti/cpsw_ale.h
index de409c33b250..31cf43cab42e 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.h
+++ b/drivers/net/ethernet/ti/cpsw_ale.h
@@ -80,6 +80,9 @@ enum cpsw_ale_port_state {
80#define ALE_MCAST_FWD_LEARN 2 80#define ALE_MCAST_FWD_LEARN 2
81#define ALE_MCAST_FWD_2 3 81#define ALE_MCAST_FWD_2 3
82 82
83#define ALE_ENTRY_BITS 68
84#define ALE_ENTRY_WORDS DIV_ROUND_UP(ALE_ENTRY_BITS, 32)
85
83struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params); 86struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params);
84int cpsw_ale_destroy(struct cpsw_ale *ale); 87int cpsw_ale_destroy(struct cpsw_ale *ale);
85 88
@@ -104,5 +107,6 @@ int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port);
104int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control); 107int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control);
105int cpsw_ale_control_set(struct cpsw_ale *ale, int port, 108int cpsw_ale_control_set(struct cpsw_ale *ale, int port,
106 int control, int value); 109 int control, int value);
110void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data);
107 111
108#endif 112#endif