drivers: net: cpsw: add support to dump ALE table via ethtool register dump
[cascardo/linux.git] / drivers / net / ethernet / ti / cpsw_ale.c
index 7f89306..0579b22 100644 (file)
@@ -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;
 }
+
+void 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;
+       }
+}