1
2
3
4
5
6
7
8 #ifndef __TI_CPSW_ALE_H__
9 #define __TI_CPSW_ALE_H__
10
11 struct cpsw_ale_params {
12 struct device *dev;
13 void __iomem *ale_regs;
14 unsigned long ale_ageout;
15 unsigned long ale_entries;
16 unsigned long ale_ports;
17
18
19
20
21
22 bool nu_switch_ale;
23
24
25
26 u32 major_ver_mask;
27 };
28
29 struct cpsw_ale {
30 struct cpsw_ale_params params;
31 struct timer_list timer;
32 unsigned long ageout;
33 u32 version;
34
35 u32 port_mask_bits;
36 u32 port_num_bits;
37 u32 vlan_field_bits;
38 };
39
40 enum cpsw_ale_control {
41
42 ALE_ENABLE,
43 ALE_CLEAR,
44 ALE_AGEOUT,
45 ALE_P0_UNI_FLOOD,
46 ALE_VLAN_NOLEARN,
47 ALE_NO_PORT_VLAN,
48 ALE_OUI_DENY,
49 ALE_BYPASS,
50 ALE_RATE_LIMIT_TX,
51 ALE_VLAN_AWARE,
52 ALE_AUTH_ENABLE,
53 ALE_RATE_LIMIT,
54
55 ALE_PORT_STATE,
56 ALE_PORT_DROP_UNTAGGED,
57 ALE_PORT_DROP_UNKNOWN_VLAN,
58 ALE_PORT_NOLEARN,
59 ALE_PORT_NO_SA_UPDATE,
60 ALE_PORT_UNKNOWN_VLAN_MEMBER,
61 ALE_PORT_UNKNOWN_MCAST_FLOOD,
62 ALE_PORT_UNKNOWN_REG_MCAST_FLOOD,
63 ALE_PORT_UNTAGGED_EGRESS,
64 ALE_PORT_BCAST_LIMIT,
65 ALE_PORT_MCAST_LIMIT,
66 ALE_NUM_CONTROLS,
67 };
68
69 enum cpsw_ale_port_state {
70 ALE_PORT_STATE_DISABLE = 0x00,
71 ALE_PORT_STATE_BLOCK = 0x01,
72 ALE_PORT_STATE_LEARN = 0x02,
73 ALE_PORT_STATE_FORWARD = 0x03,
74 };
75
76
77 #define ALE_SECURE BIT(0)
78 #define ALE_BLOCKED BIT(1)
79 #define ALE_SUPER BIT(2)
80 #define ALE_VLAN BIT(3)
81
82 #define ALE_PORT_HOST BIT(0)
83 #define ALE_PORT_1 BIT(1)
84 #define ALE_PORT_2 BIT(2)
85
86 #define ALE_MCAST_FWD 0
87 #define ALE_MCAST_BLOCK_LEARN_FWD 1
88 #define ALE_MCAST_FWD_LEARN 2
89 #define ALE_MCAST_FWD_2 3
90
91 #define ALE_ENTRY_BITS 68
92 #define ALE_ENTRY_WORDS DIV_ROUND_UP(ALE_ENTRY_BITS, 32)
93
94 struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params);
95
96 void cpsw_ale_start(struct cpsw_ale *ale);
97 void cpsw_ale_stop(struct cpsw_ale *ale);
98
99 int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid);
100 int cpsw_ale_add_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
101 int flags, u16 vid);
102 int cpsw_ale_del_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
103 int flags, u16 vid);
104 int cpsw_ale_add_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
105 int flags, u16 vid, int mcast_state);
106 int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
107 int flags, u16 vid);
108 int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag,
109 int reg_mcast, int unreg_mcast);
110 int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port);
111 void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti, int port);
112
113 int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control);
114 int cpsw_ale_control_set(struct cpsw_ale *ale, int port,
115 int control, int value);
116 void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data);
117
118 #endif