All of lore.kernel.org
 help / color / mirror / Atom feed
* [net-next PATCH 1/1] drivers: net: cpsw: add support to dump ALE table via ethtool register dump
@ 2014-07-22 16:15 Mugunthan V N
  2014-07-22 16:35 ` Mugunthan V N
  2014-07-23  2:58 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Mugunthan V N @ 2014-07-22 16:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, Mugunthan V N

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>
---
Below is the sample output of ale table dump via ethtool interface.

root@am437x-evm:~# ./ethtool -d eth0
cpsw hw version 1.15 (0)
0   : type: vlan , vid = 1 untag_force = 0x3, reg_mcast = 0x3, unreg_mcast = 0x0, member_list = 0x3
1   : type: mcast, vid = 1, addr = ff:ff:ff:ff:ff:ff, mcast_state = f, no super, port_mask = 0x3
2   : type: ucast, vid = 1, addr = 20:cd:39:2b:c7:be, ucast_type = persistant, port_num = 0x0
3   : type: vlan , vid = 0 untag_force = 0x7, reg_mcast = 0x0, unreg_mcast = 0x0, member_list = 0x7
4   : type: mcast, vid = 1, addr = 01:00:5e:00:00:01, mcast_state = f, no super, port_mask = 0x3
6   : type: ucast, vid = 1, addr = 00:00:0c:07:ac:08, ucast_type = touched   , port_num = 0x1
12  : type: ucast, vid = 1, addr = 5c:f9:dd:76:28:8d, ucast_type = touched   , port_num = 0x1
14  : type: ucast, vid = 1, addr = d4:ae:52:c2:c4:5b, ucast_type = untouched , port_num = 0x1
15  : type: ucast, vid = 0, addr = 20:cd:39:2b:c7:be, ucast_type = touched   , port_num = 0x0
16  : type: ucast, vid = 1, addr = c0:8c:60:bb:a5:49, ucast_type = touched   , port_num = 0x1
17  : type: ucast, vid = 1, addr = 00:0f:8f:13:b2:8f, ucast_type = touched   , port_num = 0x1
19  : type: ucast, vid = 1, addr = bc:30:5b:d3:13:80, ucast_type = touched   , port_num = 0x1
26  : type: ucast, vid = 1, addr = 00:1a:a0:ae:c2:ee, ucast_type = untouched , port_num = 0x1
27  : type: ucast, vid = 1, addr = b8:ac:6f:8f:50:a3, ucast_type = touched   , port_num = 0x1
28  : type: ucast, vid = 1, addr = 00:08:a1:97:79:57, ucast_type = untouched , port_num = 0x1
32  : type: ucast, vid = 1, addr = f0:f7:55:7c:0e:49, ucast_type = touched   , port_num = 0x1
37  : type: ucast, vid = 1, addr = b8:ca:3a:b6:b0:20, ucast_type = untouched , port_num = 0x1
39  : type: ucast, vid = 1, addr = b8:ac:6f:8b:82:2c, ucast_type = untouched , port_num = 0x1
40  : type: ucast, vid = 1, addr = b8:ac:6f:90:7a:ab, ucast_type = untouched , port_num = 0x1
41  : type: ucast, vid = 1, addr = d4:be:d9:99:c8:3d, ucast_type = untouched , port_num = 0x1
42  : type: ucast, vid = 1, addr = 5c:26:0a:6e:d1:27, ucast_type = touched   , port_num = 0x1
49  : type: ucast, vid = 1, addr = d4:be:d9:9a:68:1d, ucast_type = touched   , port_num = 0x1
53  : type: ucast, vid = 1, addr = 00:1d:09:33:e4:ce, ucast_type = untouched , port_num = 0x1
54  : type: ucast, vid = 1, addr = 00:26:b9:8c:4e:90, ucast_type = untouched , port_num = 0x1
---
 drivers/net/ethernet/ti/cpsw.c     | 24 +++++++++++++++++++++++-
 drivers/net/ethernet/ti/cpsw_ale.c | 12 ++++++++++--
 drivers/net/ethernet/ti/cpsw_ale.h |  4 ++++
 3 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 62d49e9..c9e86b1 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1751,14 +1751,34 @@ static const struct net_device_ops cpsw_netdev_ops = {
 	.ndo_vlan_rx_kill_vid	= cpsw_ndo_vlan_rx_kill_vid,
 };
 
+static int cpsw_get_regs_len(struct net_device *ndev)
+{
+	struct cpsw_priv *priv = netdev_priv(ndev);
+
+	return priv->data.ale_entries * ALE_ENTRY_WORDS * sizeof(u32);
+}
+
+static void cpsw_get_regs(struct net_device *ndev,
+			  struct ethtool_regs *regs, void *p)
+{
+	struct cpsw_priv *priv = netdev_priv(ndev);
+	u32 *reg = p;
+
+	/* update CPSW IP version */
+	regs->version = priv->version;
+
+	cpsw_ale_dump(priv->ale, reg);
+}
+
 static void cpsw_get_drvinfo(struct net_device *ndev,
 			     struct ethtool_drvinfo *info)
 {
 	struct cpsw_priv *priv = netdev_priv(ndev);
 
-	strlcpy(info->driver, "TI CPSW Driver v1.0", sizeof(info->driver));
+	strlcpy(info->driver, "cpsw", sizeof(info->driver));
 	strlcpy(info->version, "1.0", sizeof(info->version));
 	strlcpy(info->bus_info, priv->pdev->name, sizeof(info->bus_info));
+	info->regdump_len = cpsw_get_regs_len(ndev);
 }
 
 static u32 cpsw_get_msglevel(struct net_device *ndev)
@@ -1866,6 +1886,8 @@ static const struct ethtool_ops cpsw_ethtool_ops = {
 	.get_ethtool_stats	= cpsw_get_ethtool_stats,
 	.get_wol	= cpsw_get_wol,
 	.set_wol	= cpsw_set_wol,
+	.get_regs_len	= cpsw_get_regs_len,
+	.get_regs	= cpsw_get_regs,
 };
 
 static 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 7f89306..8e48297 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -25,8 +25,6 @@
 #include "cpsw_ale.h"
 
 #define BITMASK(bits)		(BIT(bits) - 1)
-#define ALE_ENTRY_BITS		68
-#define ALE_ENTRY_WORDS	DIV_ROUND_UP(ALE_ENTRY_BITS, 32)
 
 #define ALE_VERSION_MAJOR(rev)	((rev >> 8) & 0xff)
 #define ALE_VERSION_MINOR(rev)	(rev & 0xff)
@@ -763,3 +761,13 @@ int cpsw_ale_destroy(struct cpsw_ale *ale)
 	kfree(ale);
 	return 0;
 }
+
+int cpsw_ale_dump(struct cpsw_ale *ale, u32 *data)
+{
+	int i;
+
+	for (i = 0; i < ale->params.ale_entries; i++) {
+		cpsw_ale_read(ale, i, data);
+		data += ALE_ENTRY_WORDS;
+	}
+}
diff --git a/drivers/net/ethernet/ti/cpsw_ale.h b/drivers/net/ethernet/ti/cpsw_ale.h
index de409c3..898cf46 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 {
 #define ALE_MCAST_FWD_LEARN		2
 #define ALE_MCAST_FWD_2			3
 
+#define ALE_ENTRY_BITS		68
+#define ALE_ENTRY_WORDS	DIV_ROUND_UP(ALE_ENTRY_BITS, 32)
+
 struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params);
 int cpsw_ale_destroy(struct cpsw_ale *ale);
 
@@ -104,5 +107,6 @@ int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port);
 int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control);
 int cpsw_ale_control_set(struct cpsw_ale *ale, int port,
 			 int control, int value);
+int cpsw_ale_dump(struct cpsw_ale *ale, u32 *data);
 
 #endif
-- 
2.0.0.390.gcb682f8

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [net-next PATCH 1/1] drivers: net: cpsw: add support to dump ALE table via ethtool register dump
  2014-07-22 16:15 [net-next PATCH 1/1] drivers: net: cpsw: add support to dump ALE table via ethtool register dump Mugunthan V N
@ 2014-07-22 16:35 ` Mugunthan V N
  2014-07-23  2:58 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Mugunthan V N @ 2014-07-22 16:35 UTC (permalink / raw)
  To: netdev; +Cc: davem

On Tuesday 22 July 2014 09:45 PM, Mugunthan V N wrote:
> 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>

One build warning is there in this patch, will post v2 shortly

drivers/net/ethernet/ti/cpsw_ale.c: In function ‘cpsw_ale_dump’:
drivers/net/ethernet/ti/cpsw_ale.c:773:1: warning: control reaches end
of non-void function [-Wreturn-type]

Regards
Mugunthan V N

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [net-next PATCH 1/1] drivers: net: cpsw: add support to dump ALE table via ethtool register dump
  2014-07-22 16:15 [net-next PATCH 1/1] drivers: net: cpsw: add support to dump ALE table via ethtool register dump Mugunthan V N
  2014-07-22 16:35 ` Mugunthan V N
@ 2014-07-23  2:58 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-07-23  2:58 UTC (permalink / raw)
  To: mugunthanvnm; +Cc: netdev

From: Mugunthan V N <mugunthanvnm@ti.com>
Date: Tue, 22 Jul 2014 21:45:56 +0530

> 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>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-23  2:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-22 16:15 [net-next PATCH 1/1] drivers: net: cpsw: add support to dump ALE table via ethtool register dump Mugunthan V N
2014-07-22 16:35 ` Mugunthan V N
2014-07-23  2:58 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.