Mugunthan V N | db82173 | 2012-03-18 20:17:53 +0000 | [diff] [blame] | 1 | /* |
Karicheri, Muralidharan | ca47130 | 2017-01-06 15:37:44 -0500 | [diff] [blame] | 2 | * Texas Instruments N-Port Ethernet Switch Address Lookup Engine APIs |
Mugunthan V N | db82173 | 2012-03-18 20:17:53 +0000 | [diff] [blame] | 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 | |
| 18 | struct 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; |
Karicheri, Muralidharan | ca47130 | 2017-01-06 15:37:44 -0500 | [diff] [blame] | 24 | /* NU Switch has specific handling as number of bits in ALE entries |
| 25 | * are different than other versions of ALE. Also there are specific |
| 26 | * registers for unknown vlan specific fields. So use nu_switch_ale |
| 27 | * to identify this hardware. |
| 28 | */ |
| 29 | bool nu_switch_ale; |
| 30 | /* mask bit used in NU Switch ALE is 3 bits instead of 8 bits. So |
| 31 | * pass it from caller. |
| 32 | */ |
| 33 | u32 major_ver_mask; |
Mugunthan V N | db82173 | 2012-03-18 20:17:53 +0000 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | struct cpsw_ale { |
| 37 | struct cpsw_ale_params params; |
| 38 | struct timer_list timer; |
| 39 | unsigned long ageout; |
Lennart Sorensen | 1e5c4bc | 2014-10-31 13:38:52 -0400 | [diff] [blame] | 40 | int allmulti; |
Karicheri, Muralidharan | ca47130 | 2017-01-06 15:37:44 -0500 | [diff] [blame] | 41 | u32 version; |
Karicheri, Muralidharan | b361da8 | 2017-01-06 15:37:46 -0500 | [diff] [blame] | 42 | /* These bits are different on NetCP NU Switch ALE */ |
| 43 | u32 port_mask_bits; |
| 44 | u32 port_num_bits; |
| 45 | u32 vlan_field_bits; |
Mugunthan V N | db82173 | 2012-03-18 20:17:53 +0000 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | enum cpsw_ale_control { |
| 49 | /* global */ |
| 50 | ALE_ENABLE, |
| 51 | ALE_CLEAR, |
| 52 | ALE_AGEOUT, |
Mugunthan V N | 0cd8f9c | 2014-01-23 00:03:12 +0530 | [diff] [blame] | 53 | ALE_P0_UNI_FLOOD, |
Mugunthan V N | db82173 | 2012-03-18 20:17:53 +0000 | [diff] [blame] | 54 | ALE_VLAN_NOLEARN, |
| 55 | ALE_NO_PORT_VLAN, |
| 56 | ALE_OUI_DENY, |
| 57 | ALE_BYPASS, |
| 58 | ALE_RATE_LIMIT_TX, |
| 59 | ALE_VLAN_AWARE, |
| 60 | ALE_AUTH_ENABLE, |
| 61 | ALE_RATE_LIMIT, |
| 62 | /* port controls */ |
| 63 | ALE_PORT_STATE, |
| 64 | ALE_PORT_DROP_UNTAGGED, |
| 65 | ALE_PORT_DROP_UNKNOWN_VLAN, |
| 66 | ALE_PORT_NOLEARN, |
Mugunthan V N | 0cd8f9c | 2014-01-23 00:03:12 +0530 | [diff] [blame] | 67 | ALE_PORT_NO_SA_UPDATE, |
Mugunthan V N | db82173 | 2012-03-18 20:17:53 +0000 | [diff] [blame] | 68 | ALE_PORT_UNKNOWN_VLAN_MEMBER, |
| 69 | ALE_PORT_UNKNOWN_MCAST_FLOOD, |
| 70 | ALE_PORT_UNKNOWN_REG_MCAST_FLOOD, |
| 71 | ALE_PORT_UNTAGGED_EGRESS, |
| 72 | ALE_PORT_BCAST_LIMIT, |
| 73 | ALE_PORT_MCAST_LIMIT, |
| 74 | ALE_NUM_CONTROLS, |
| 75 | }; |
| 76 | |
| 77 | enum cpsw_ale_port_state { |
| 78 | ALE_PORT_STATE_DISABLE = 0x00, |
| 79 | ALE_PORT_STATE_BLOCK = 0x01, |
| 80 | ALE_PORT_STATE_LEARN = 0x02, |
| 81 | ALE_PORT_STATE_FORWARD = 0x03, |
| 82 | }; |
| 83 | |
| 84 | /* ALE unicast entry flags - passed into cpsw_ale_add_ucast() */ |
Mugunthan V N | e11b220 | 2013-02-05 08:26:47 +0000 | [diff] [blame] | 85 | #define ALE_SECURE BIT(0) |
| 86 | #define ALE_BLOCKED BIT(1) |
| 87 | #define ALE_SUPER BIT(2) |
| 88 | #define ALE_VLAN BIT(3) |
Mugunthan V N | db82173 | 2012-03-18 20:17:53 +0000 | [diff] [blame] | 89 | |
Mugunthan V N | 3b72c2f | 2013-02-05 08:26:48 +0000 | [diff] [blame] | 90 | #define ALE_PORT_HOST BIT(0) |
| 91 | #define ALE_PORT_1 BIT(1) |
| 92 | #define ALE_PORT_2 BIT(2) |
| 93 | |
Mugunthan V N | db82173 | 2012-03-18 20:17:53 +0000 | [diff] [blame] | 94 | #define ALE_MCAST_FWD 0 |
| 95 | #define ALE_MCAST_BLOCK_LEARN_FWD 1 |
| 96 | #define ALE_MCAST_FWD_LEARN 2 |
| 97 | #define ALE_MCAST_FWD_2 3 |
| 98 | |
Mugunthan V N | 52c4f0e | 2014-07-22 23:25:07 +0530 | [diff] [blame] | 99 | #define ALE_ENTRY_BITS 68 |
| 100 | #define ALE_ENTRY_WORDS DIV_ROUND_UP(ALE_ENTRY_BITS, 32) |
| 101 | |
Mugunthan V N | db82173 | 2012-03-18 20:17:53 +0000 | [diff] [blame] | 102 | struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params); |
Mugunthan V N | db82173 | 2012-03-18 20:17:53 +0000 | [diff] [blame] | 103 | |
| 104 | void cpsw_ale_start(struct cpsw_ale *ale); |
| 105 | void cpsw_ale_stop(struct cpsw_ale *ale); |
| 106 | |
Mugunthan V N | 2590605 | 2015-01-13 17:35:49 +0530 | [diff] [blame] | 107 | int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid); |
Mugunthan V N | e11b220 | 2013-02-05 08:26:47 +0000 | [diff] [blame] | 108 | int cpsw_ale_add_ucast(struct cpsw_ale *ale, u8 *addr, int port, |
| 109 | int flags, u16 vid); |
| 110 | int cpsw_ale_del_ucast(struct cpsw_ale *ale, u8 *addr, int port, |
| 111 | int flags, u16 vid); |
Mugunthan V N | db82173 | 2012-03-18 20:17:53 +0000 | [diff] [blame] | 112 | int cpsw_ale_add_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask, |
Mugunthan V N | e11b220 | 2013-02-05 08:26:47 +0000 | [diff] [blame] | 113 | int flags, u16 vid, int mcast_state); |
| 114 | int cpsw_ale_del_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask, |
| 115 | int flags, u16 vid); |
| 116 | int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag, |
| 117 | int reg_mcast, int unreg_mcast); |
| 118 | int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port); |
Lennart Sorensen | 1e5c4bc | 2014-10-31 13:38:52 -0400 | [diff] [blame] | 119 | void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti); |
Mugunthan V N | db82173 | 2012-03-18 20:17:53 +0000 | [diff] [blame] | 120 | |
| 121 | int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control); |
| 122 | int cpsw_ale_control_set(struct cpsw_ale *ale, int port, |
| 123 | int control, int value); |
Mugunthan V N | 52c4f0e | 2014-07-22 23:25:07 +0530 | [diff] [blame] | 124 | void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data); |
Mugunthan V N | db82173 | 2012-03-18 20:17:53 +0000 | [diff] [blame] | 125 | |
| 126 | #endif |