0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __TI_CPSW_ALE_H__
0009 #define __TI_CPSW_ALE_H__
0010
0011 struct cpsw_ale_params {
0012 struct device *dev;
0013 void __iomem *ale_regs;
0014 unsigned long ale_ageout;
0015 unsigned long ale_entries;
0016 unsigned long ale_ports;
0017
0018
0019
0020
0021
0022 bool nu_switch_ale;
0023
0024
0025
0026 u32 major_ver_mask;
0027 const char *dev_id;
0028 unsigned long bus_freq;
0029 };
0030
0031 struct ale_entry_fld;
0032
0033 struct cpsw_ale {
0034 struct cpsw_ale_params params;
0035 struct timer_list timer;
0036 unsigned long ageout;
0037 u32 version;
0038 u32 features;
0039
0040 u32 port_mask_bits;
0041 u32 port_num_bits;
0042 u32 vlan_field_bits;
0043 unsigned long *p0_untag_vid_mask;
0044 const struct ale_entry_fld *vlan_entry_tbl;
0045 };
0046
0047 enum cpsw_ale_control {
0048
0049 ALE_ENABLE,
0050 ALE_CLEAR,
0051 ALE_AGEOUT,
0052 ALE_P0_UNI_FLOOD,
0053 ALE_VLAN_NOLEARN,
0054 ALE_NO_PORT_VLAN,
0055 ALE_OUI_DENY,
0056 ALE_BYPASS,
0057 ALE_RATE_LIMIT_TX,
0058 ALE_VLAN_AWARE,
0059 ALE_AUTH_ENABLE,
0060 ALE_RATE_LIMIT,
0061
0062 ALE_PORT_STATE,
0063 ALE_PORT_DROP_UNTAGGED,
0064 ALE_PORT_DROP_UNKNOWN_VLAN,
0065 ALE_PORT_NOLEARN,
0066 ALE_PORT_NO_SA_UPDATE,
0067 ALE_PORT_UNKNOWN_VLAN_MEMBER,
0068 ALE_PORT_UNKNOWN_MCAST_FLOOD,
0069 ALE_PORT_UNKNOWN_REG_MCAST_FLOOD,
0070 ALE_PORT_UNTAGGED_EGRESS,
0071 ALE_PORT_MACONLY,
0072 ALE_PORT_MACONLY_CAF,
0073 ALE_PORT_BCAST_LIMIT,
0074 ALE_PORT_MCAST_LIMIT,
0075 ALE_DEFAULT_THREAD_ID,
0076 ALE_DEFAULT_THREAD_ENABLE,
0077 ALE_NUM_CONTROLS,
0078 };
0079
0080 enum cpsw_ale_port_state {
0081 ALE_PORT_STATE_DISABLE = 0x00,
0082 ALE_PORT_STATE_BLOCK = 0x01,
0083 ALE_PORT_STATE_LEARN = 0x02,
0084 ALE_PORT_STATE_FORWARD = 0x03,
0085 };
0086
0087
0088 #define ALE_SECURE BIT(0)
0089 #define ALE_BLOCKED BIT(1)
0090 #define ALE_SUPER BIT(2)
0091 #define ALE_VLAN BIT(3)
0092
0093 #define ALE_PORT_HOST BIT(0)
0094 #define ALE_PORT_1 BIT(1)
0095 #define ALE_PORT_2 BIT(2)
0096
0097 #define ALE_MCAST_FWD 0
0098 #define ALE_MCAST_BLOCK_LEARN_FWD 1
0099 #define ALE_MCAST_FWD_LEARN 2
0100 #define ALE_MCAST_FWD_2 3
0101
0102 #define ALE_ENTRY_BITS 68
0103 #define ALE_ENTRY_WORDS DIV_ROUND_UP(ALE_ENTRY_BITS, 32)
0104
0105 struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params);
0106
0107 void cpsw_ale_start(struct cpsw_ale *ale);
0108 void cpsw_ale_stop(struct cpsw_ale *ale);
0109
0110 int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid);
0111 int cpsw_ale_add_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
0112 int flags, u16 vid);
0113 int cpsw_ale_del_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
0114 int flags, u16 vid);
0115 int cpsw_ale_add_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
0116 int flags, u16 vid, int mcast_state);
0117 int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
0118 int flags, u16 vid);
0119 int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag,
0120 int reg_mcast, int unreg_mcast);
0121 int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port);
0122 void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti, int port);
0123 int cpsw_ale_rx_ratelimit_bc(struct cpsw_ale *ale, int port, unsigned int ratelimit_pps);
0124 int cpsw_ale_rx_ratelimit_mc(struct cpsw_ale *ale, int port, unsigned int ratelimit_pps);
0125
0126 int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control);
0127 int cpsw_ale_control_set(struct cpsw_ale *ale, int port,
0128 int control, int value);
0129 void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data);
0130 u32 cpsw_ale_get_num_entries(struct cpsw_ale *ale);
0131
0132 static inline int cpsw_ale_get_vlan_p0_untag(struct cpsw_ale *ale, u16 vid)
0133 {
0134 return test_bit(vid, ale->p0_untag_vid_mask);
0135 }
0136
0137 int cpsw_ale_vlan_add_modify(struct cpsw_ale *ale, u16 vid, int port_mask,
0138 int untag_mask, int reg_mcast, int unreg_mcast);
0139 int cpsw_ale_vlan_del_modify(struct cpsw_ale *ale, u16 vid, int port_mask);
0140 void cpsw_ale_set_unreg_mcast(struct cpsw_ale *ale, int unreg_mcast_mask,
0141 bool add);
0142
0143 #endif