blob: 31cf43cab42ee7ba70b6948593bc93cf28c5a6e7 [file] [log] [blame]
Mugunthan V Ndb821732012-03-18 20:17:53 +00001/*
2 * Texas Instruments 3-Port Ethernet Switch Address Lookup Engine APIs
3 *
4 * Copyright (C) 2012 Texas Instruments
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15#ifndef __TI_CPSW_ALE_H__
16#define __TI_CPSW_ALE_H__
17
18struct cpsw_ale_params {
19 struct device *dev;
20 void __iomem *ale_regs;
21 unsigned long ale_ageout; /* in secs */
22 unsigned long ale_entries;
23 unsigned long ale_ports;
24};
25
26struct cpsw_ale {
27 struct cpsw_ale_params params;
28 struct timer_list timer;
29 unsigned long ageout;
30};
31
32enum cpsw_ale_control {
33 /* global */
34 ALE_ENABLE,
35 ALE_CLEAR,
36 ALE_AGEOUT,
Mugunthan V N0cd8f9c2014-01-23 00:03:12 +053037 ALE_P0_UNI_FLOOD,
Mugunthan V Ndb821732012-03-18 20:17:53 +000038 ALE_VLAN_NOLEARN,
39 ALE_NO_PORT_VLAN,
40 ALE_OUI_DENY,
41 ALE_BYPASS,
42 ALE_RATE_LIMIT_TX,
43 ALE_VLAN_AWARE,
44 ALE_AUTH_ENABLE,
45 ALE_RATE_LIMIT,
46 /* port controls */
47 ALE_PORT_STATE,
48 ALE_PORT_DROP_UNTAGGED,
49 ALE_PORT_DROP_UNKNOWN_VLAN,
50 ALE_PORT_NOLEARN,
Mugunthan V N0cd8f9c2014-01-23 00:03:12 +053051 ALE_PORT_NO_SA_UPDATE,
Mugunthan V Ndb821732012-03-18 20:17:53 +000052 ALE_PORT_UNKNOWN_VLAN_MEMBER,
53 ALE_PORT_UNKNOWN_MCAST_FLOOD,
54 ALE_PORT_UNKNOWN_REG_MCAST_FLOOD,
55 ALE_PORT_UNTAGGED_EGRESS,
56 ALE_PORT_BCAST_LIMIT,
57 ALE_PORT_MCAST_LIMIT,
58 ALE_NUM_CONTROLS,
59};
60
61enum cpsw_ale_port_state {
62 ALE_PORT_STATE_DISABLE = 0x00,
63 ALE_PORT_STATE_BLOCK = 0x01,
64 ALE_PORT_STATE_LEARN = 0x02,
65 ALE_PORT_STATE_FORWARD = 0x03,
66};
67
68/* ALE unicast entry flags - passed into cpsw_ale_add_ucast() */
Mugunthan V Ne11b2202013-02-05 08:26:47 +000069#define ALE_SECURE BIT(0)
70#define ALE_BLOCKED BIT(1)
71#define ALE_SUPER BIT(2)
72#define ALE_VLAN BIT(3)
Mugunthan V Ndb821732012-03-18 20:17:53 +000073
Mugunthan V N3b72c2f2013-02-05 08:26:48 +000074#define ALE_PORT_HOST BIT(0)
75#define ALE_PORT_1 BIT(1)
76#define ALE_PORT_2 BIT(2)
77
Mugunthan V Ndb821732012-03-18 20:17:53 +000078#define ALE_MCAST_FWD 0
79#define ALE_MCAST_BLOCK_LEARN_FWD 1
80#define ALE_MCAST_FWD_LEARN 2
81#define ALE_MCAST_FWD_2 3
82
Mugunthan V N52c4f0e2014-07-22 23:25:07 +053083#define ALE_ENTRY_BITS 68
84#define ALE_ENTRY_WORDS DIV_ROUND_UP(ALE_ENTRY_BITS, 32)
85
Mugunthan V Ndb821732012-03-18 20:17:53 +000086struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params);
87int cpsw_ale_destroy(struct cpsw_ale *ale);
88
89void cpsw_ale_start(struct cpsw_ale *ale);
90void cpsw_ale_stop(struct cpsw_ale *ale);
91
92int cpsw_ale_set_ageout(struct cpsw_ale *ale, int ageout);
93int cpsw_ale_flush(struct cpsw_ale *ale, int port_mask);
Mugunthan V N5c50a852012-10-29 08:45:11 +000094int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask);
Mugunthan V Ne11b2202013-02-05 08:26:47 +000095int cpsw_ale_add_ucast(struct cpsw_ale *ale, u8 *addr, int port,
96 int flags, u16 vid);
97int cpsw_ale_del_ucast(struct cpsw_ale *ale, u8 *addr, int port,
98 int flags, u16 vid);
Mugunthan V Ndb821732012-03-18 20:17:53 +000099int cpsw_ale_add_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
Mugunthan V Ne11b2202013-02-05 08:26:47 +0000100 int flags, u16 vid, int mcast_state);
101int cpsw_ale_del_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
102 int flags, u16 vid);
103int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag,
104 int reg_mcast, int unreg_mcast);
105int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port);
Mugunthan V Ndb821732012-03-18 20:17:53 +0000106
107int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control);
108int cpsw_ale_control_set(struct cpsw_ale *ale, int port,
109 int control, int value);
Mugunthan V N52c4f0e2014-07-22 23:25:07 +0530110void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data);
Mugunthan V Ndb821732012-03-18 20:17:53 +0000111
112#endif