generic ar8216: allow to read/reset MIB counters via swconfig
[openwrt/staging/mkresin.git] / target / linux / generic / files / drivers / net / phy / ar8216.h
index 8948c52054160908022bb92b3913fba659ab960e..0b4a899074911094728c9bec96c9c9c80ecd65aa 100644 (file)
 #define   AR8216_ATU_CTRL_AGE_TIME     BITS(0, 16)
 #define   AR8216_ATU_CTRL_AGE_TIME_S   0
 
+#define AR8216_REG_MIB_FUNC            0x0080
+#define   AR8216_MIB_TIMER             BITS(0, 16)
+#define   AR8216_MIB_AT_HALF_EN                BIT(16)
+#define   AR8216_MIB_BUSY              BIT(17)
+#define   AR8216_MIB_FUNC              BITS(24, 3)
+#define   AR8216_MIB_FUNC_S            24
+#define   AR8216_MIB_FUNC_NO_OP                0x0
+#define   AR8216_MIB_FUNC_FLUSH                0x1
+#define   AR8216_MIB_FUNC_CAPTURE      0x3
+#define   AR8236_MIB_EN                        BIT(30)
+
 #define AR8216_PORT_OFFSET(_i)         (0x0100 * (_i + 1))
 #define AR8216_REG_PORT_STATUS(_i)     (AR8216_PORT_OFFSET(_i) + 0x0000)
 #define   AR8216_PORT_STATUS_SPEED     BITS(0,2)
 #define AR8216_REG_PORT_RATE(_i)       (AR8216_PORT_OFFSET(_i) + 0x000c)
 #define AR8216_REG_PORT_PRIO(_i)       (AR8216_PORT_OFFSET(_i) + 0x0010)
 
+#define AR8216_REG_PORT_STATS_BASE(_i) (0x20000 + (_i) * 0x100)
+
+#define AR8216_STATS_RXBROAD           0x00
+#define AR8216_STATS_RXPAUSE           0x04
+#define AR8216_STATS_RXMULTI           0x08
+#define AR8216_STATS_RXFCSERR          0x0c
+#define AR8216_STATS_RXALIGNERR                0x10
+#define AR8216_STATS_RXRUNT            0x14
+#define AR8216_STATS_RXFRAGMENT                0x18
+#define AR8216_STATS_RX64BYTE          0x1c
+#define AR8216_STATS_RX128BYTE         0x20
+#define AR8216_STATS_RX256BYTE         0x24
+#define AR8216_STATS_RX512BYTE         0x28
+#define AR8216_STATS_RX1024BYTE                0x2c
+#define AR8216_STATS_RX1518BYTE                0x30
+#define AR8216_STATS_RXMAXBYTE         0x34
+#define AR8216_STATS_RXTOOLONG         0x38
+#define AR8216_STATS_RXGOODBYTE                0x3c
+#define AR8216_STATS_RXBADBYTE         0x44
+#define AR8216_STATS_RXOVERFLOW                0x4c
+#define AR8216_STATS_FILTERED          0x50
+#define AR8216_STATS_TXBROAD           0x54
+#define AR8216_STATS_TXPAUSE           0x58
+#define AR8216_STATS_TXMULTI           0x5c
+#define AR8216_STATS_TXUNDERRUN                0x60
+#define AR8216_STATS_TX64BYTE          0x64
+#define AR8216_STATS_TX128BYTE         0x68
+#define AR8216_STATS_TX256BYTE         0x6c
+#define AR8216_STATS_TX512BYTE         0x70
+#define AR8216_STATS_TX1024BYTE                0x74
+#define AR8216_STATS_TX1518BYTE                0x78
+#define AR8216_STATS_TXMAXBYTE         0x7c
+#define AR8216_STATS_TXOVERSIZE                0x80
+#define AR8216_STATS_TXBYTE            0x84
+#define AR8216_STATS_TXCOLLISION       0x8c
+#define AR8216_STATS_TXABORTCOL                0x90
+#define AR8216_STATS_TXMULTICOL                0x94
+#define AR8216_STATS_TXSINGLECOL       0x98
+#define AR8216_STATS_TXEXCDEFER                0x9c
+#define AR8216_STATS_TXDEFER           0xa0
+#define AR8216_STATS_TXLATECOL         0xa4
 
 #define AR8236_REG_PORT_VLAN(_i)       (AR8216_PORT_OFFSET((_i)) + 0x0008)
 #define   AR8236_PORT_VLAN_DEFAULT_ID  BITS(16, 12)
 #define AR8327_REG_INT_STATUS1                 0x024
 #define AR8327_REG_INT_MASK0                   0x028
 #define AR8327_REG_INT_MASK1                   0x02c
+
+#define AR8327_REG_MODULE_EN                   0x030
+#define   AR8327_MODULE_EN_MIB                 BIT(0)
+
+#define AR8327_REG_MIB_FUNC                    0x034
+#define   AR8327_MIB_CPU_KEEP                  BIT(20)
+
 #define AR8327_REG_SERVICE_TAG                 0x048
 #define AR8327_REG_LED_CTRL0                   0x050
 #define AR8327_REG_LED_CTRL1                   0x054
 
 #define AR8327_REG_PORT_PRIO(_i)               (0x664 + (_i) * 0xc)
 
+#define AR8327_REG_PORT_STATS_BASE(_i)         (0x1000 + (_i) * 0x100)
+
 /* port speed */
 enum {
         AR8216_PORT_SPEED_10M = 0,