From 3a313a3e11adc1d44a8c7108ffb158f1ab1304d5 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 24 Jan 2015 19:42:06 +0000 Subject: ar8216: add swconfig attribute to display ARL table on AR8327/AR8337 Add global read-only swconfig attribute "arl_table" to display the address resolution table. So far the chip-specific part is implemented for AR8327/AR8337 only as I don't have the datasheets for the other AR8XXX chips. Successfully tested on TL-WDR4300 (AR8327rev2) and TL-WDR4900 (AR8327rev4). Signed-off-by: Heiner Kallweit SVN-Revision: 44104 --- .../linux/generic/files/drivers/net/phy/ar8216.h | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'target/linux/generic/files/drivers/net/phy/ar8216.h') diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.h b/target/linux/generic/files/drivers/net/phy/ar8216.h index 77df506256..7163cf430f 100644 --- a/target/linux/generic/files/drivers/net/phy/ar8216.h +++ b/target/linux/generic/files/drivers/net/phy/ar8216.h @@ -337,6 +337,18 @@ enum { AR8XXX_VER_AR8337 = 0x13, }; +#define AR8XXX_NUM_ARL_RECORDS 100 + +enum arl_op { + AR8XXX_ARL_INITIALIZE, + AR8XXX_ARL_GET_NEXT +}; + +struct arl_entry { + u8 port; + u8 mac[6]; +}; + struct ar8xxx_priv; struct ar8xxx_mib_desc { @@ -372,6 +384,8 @@ struct ar8xxx_chip { void (*vtu_load_vlan)(struct ar8xxx_priv *priv, u32 vid, u32 port_mask); void (*phy_fixup)(struct ar8xxx_priv *priv, int phy); void (*set_mirror_regs)(struct ar8xxx_priv *priv); + void (*get_arl_entry)(struct ar8xxx_priv *priv, struct arl_entry *a, + u32 *status, enum arl_op op); int (*sw_hw_apply)(struct switch_dev *dev); const struct ar8xxx_mib_desc *mib_decs; @@ -396,6 +410,8 @@ struct ar8xxx_priv { bool initialized; bool port4_phy; char buf[2048]; + struct arl_entry arl_table[AR8XXX_NUM_ARL_RECORDS]; + char arl_buf[AR8XXX_NUM_ARL_RECORDS * 32 + 256]; bool link_up[AR8X16_MAX_PORTS]; bool init; @@ -422,6 +438,10 @@ struct ar8xxx_priv { int monitor_port; }; +u32 +mii_read32(struct ar8xxx_priv *priv, int phy_id, int regnum); +void +mii_write32(struct ar8xxx_priv *priv, int phy_id, int regnum, u32 val); u32 ar8xxx_read(struct ar8xxx_priv *priv, int reg); void @@ -500,6 +520,10 @@ ar8xxx_sw_get_port_mib(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val); int +ar8xxx_sw_get_arl_table(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val); +int ar8216_wait_bit(struct ar8xxx_priv *priv, int reg, u32 mask, u32 val); static inline struct ar8xxx_priv * @@ -555,6 +579,19 @@ ar8xxx_reg_clear(struct ar8xxx_priv *priv, int reg, u32 val) ar8xxx_rmw(priv, reg, val, 0); } +static inline void +split_addr(u32 regaddr, u16 *r1, u16 *r2, u16 *page) +{ + regaddr >>= 1; + *r1 = regaddr & 0x1e; + + regaddr >>= 5; + *r2 = regaddr & 0x7; + + regaddr >>= 3; + *page = regaddr & 0x1ff; +} + static inline void wait_for_page_switch(void) { -- cgit v1.2.3