2 * Texas Instruments 3-Port Ethernet Switch Address Lookup Engine APIs
4 * Copyright (C) 2012 Texas Instruments
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.
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.
15 #ifndef __TI_CPSW_ALE_H__
16 #define __TI_CPSW_ALE_H__
18 struct cpsw_ale_params
{
20 void __iomem
*ale_regs
;
21 unsigned long ale_ageout
; /* in secs */
22 unsigned long ale_entries
;
23 unsigned long ale_ports
;
27 struct cpsw_ale_params params
;
28 struct timer_list timer
;
33 enum cpsw_ale_control
{
49 ALE_PORT_DROP_UNTAGGED
,
50 ALE_PORT_DROP_UNKNOWN_VLAN
,
52 ALE_PORT_NO_SA_UPDATE
,
53 ALE_PORT_UNKNOWN_VLAN_MEMBER
,
54 ALE_PORT_UNKNOWN_MCAST_FLOOD
,
55 ALE_PORT_UNKNOWN_REG_MCAST_FLOOD
,
56 ALE_PORT_UNTAGGED_EGRESS
,
62 enum cpsw_ale_port_state
{
63 ALE_PORT_STATE_DISABLE
= 0x00,
64 ALE_PORT_STATE_BLOCK
= 0x01,
65 ALE_PORT_STATE_LEARN
= 0x02,
66 ALE_PORT_STATE_FORWARD
= 0x03,
69 /* ALE unicast entry flags - passed into cpsw_ale_add_ucast() */
70 #define ALE_SECURE BIT(0)
71 #define ALE_BLOCKED BIT(1)
72 #define ALE_SUPER BIT(2)
73 #define ALE_VLAN BIT(3)
75 #define ALE_PORT_HOST BIT(0)
76 #define ALE_PORT_1 BIT(1)
77 #define ALE_PORT_2 BIT(2)
79 #define ALE_MCAST_FWD 0
80 #define ALE_MCAST_BLOCK_LEARN_FWD 1
81 #define ALE_MCAST_FWD_LEARN 2
82 #define ALE_MCAST_FWD_2 3
84 #define ALE_ENTRY_BITS 68
85 #define ALE_ENTRY_WORDS DIV_ROUND_UP(ALE_ENTRY_BITS, 32)
87 struct cpsw_ale
*cpsw_ale_create(struct cpsw_ale_params
*params
);
88 int cpsw_ale_destroy(struct cpsw_ale
*ale
);
90 void cpsw_ale_start(struct cpsw_ale
*ale
);
91 void cpsw_ale_stop(struct cpsw_ale
*ale
);
93 int cpsw_ale_flush_multicast(struct cpsw_ale
*ale
, int port_mask
, int vid
);
94 int cpsw_ale_add_ucast(struct cpsw_ale
*ale
, u8
*addr
, int port
,
96 int cpsw_ale_del_ucast(struct cpsw_ale
*ale
, u8
*addr
, int port
,
98 int cpsw_ale_add_mcast(struct cpsw_ale
*ale
, u8
*addr
, int port_mask
,
99 int flags
, u16 vid
, int mcast_state
);
100 int cpsw_ale_del_mcast(struct cpsw_ale
*ale
, u8
*addr
, int port_mask
,
102 int cpsw_ale_add_vlan(struct cpsw_ale
*ale
, u16 vid
, int port
, int untag
,
103 int reg_mcast
, int unreg_mcast
);
104 int cpsw_ale_del_vlan(struct cpsw_ale
*ale
, u16 vid
, int port
);
105 void cpsw_ale_set_allmulti(struct cpsw_ale
*ale
, int allmulti
);
107 int cpsw_ale_control_get(struct cpsw_ale
*ale
, int port
, int control
);
108 int cpsw_ale_control_set(struct cpsw_ale
*ale
, int port
,
109 int control
, int value
);
110 void cpsw_ale_dump(struct cpsw_ale
*ale
, u32
*data
);