Skip to content

Commit b596229

Browse files
HoratiuVulturdavem330
authored andcommitted
net: mscc: ocelot: Add support for tcam
Add ACL support using the TCAM. Using ACL it is possible to create rules in hardware to filter/redirect frames. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6345266 commit b596229

File tree

10 files changed

+1508
-3
lines changed

10 files changed

+1508
-3
lines changed

arch/mips/boot/dts/mscc/ocelot.dtsi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,12 @@
132132
<0x1270000 0x100>,
133133
<0x1280000 0x100>,
134134
<0x1800000 0x80000>,
135-
<0x1880000 0x10000>;
135+
<0x1880000 0x10000>,
136+
<0x1060000 0x10000>;
136137
reg-names = "sys", "rew", "qs", "port0", "port1",
137138
"port2", "port3", "port4", "port5", "port6",
138139
"port7", "port8", "port9", "port10", "qsys",
139-
"ana";
140+
"ana", "s2";
140141
interrupts = <21 22>;
141142
interrupt-names = "xtr", "inj";
142143

drivers/net/ethernet/mscc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: (GPL-2.0 OR MIT)
22
obj-$(CONFIG_MSCC_OCELOT_SWITCH) += mscc_ocelot_common.o
33
mscc_ocelot_common-y := ocelot.o ocelot_io.o
4-
mscc_ocelot_common-y += ocelot_regs.o ocelot_tc.o ocelot_police.o
4+
mscc_ocelot_common-y += ocelot_regs.o ocelot_tc.o ocelot_police.o ocelot_ace.o
55
obj-$(CONFIG_MSCC_OCELOT_SWITCH_OCELOT) += ocelot_board.o

drivers/net/ethernet/mscc/ocelot.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <net/switchdev.h>
2323

2424
#include "ocelot.h"
25+
#include "ocelot_ace.h"
2526

2627
#define TABLE_UPDATE_SLEEP_US 10
2728
#define TABLE_UPDATE_TIMEOUT_US 100000
@@ -130,6 +131,13 @@ static void ocelot_mact_init(struct ocelot *ocelot)
130131
ocelot_write(ocelot, MACACCESS_CMD_INIT, ANA_TABLES_MACACCESS);
131132
}
132133

134+
static void ocelot_vcap_enable(struct ocelot *ocelot, struct ocelot_port *port)
135+
{
136+
ocelot_write_gix(ocelot, ANA_PORT_VCAP_S2_CFG_S2_ENA |
137+
ANA_PORT_VCAP_S2_CFG_S2_IP6_CFG(0xa),
138+
ANA_PORT_VCAP_S2_CFG, port->chip_port);
139+
}
140+
133141
static inline u32 ocelot_vlant_read_vlanaccess(struct ocelot *ocelot)
134142
{
135143
return ocelot_read(ocelot, ANA_TABLES_VLANACCESS);
@@ -1662,6 +1670,9 @@ int ocelot_probe_port(struct ocelot *ocelot, u8 port,
16621670
/* Basic L2 initialization */
16631671
ocelot_vlan_port_apply(ocelot, ocelot_port);
16641672

1673+
/* Enable vcap lookups */
1674+
ocelot_vcap_enable(ocelot, ocelot_port);
1675+
16651676
return 0;
16661677

16671678
err_register_netdev:
@@ -1696,6 +1707,7 @@ int ocelot_init(struct ocelot *ocelot)
16961707

16971708
ocelot_mact_init(ocelot);
16981709
ocelot_vlan_init(ocelot);
1710+
ocelot_ace_init(ocelot);
16991711

17001712
for (port = 0; port < ocelot->num_phys_ports; port++) {
17011713
/* Clear all counters (5 groups) */
@@ -1808,6 +1820,7 @@ void ocelot_deinit(struct ocelot *ocelot)
18081820
{
18091821
destroy_workqueue(ocelot->stats_queue);
18101822
mutex_destroy(&ocelot->stats_lock);
1823+
ocelot_ace_deinit();
18111824
}
18121825
EXPORT_SYMBOL(ocelot_deinit);
18131826

drivers/net/ethernet/mscc/ocelot.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ enum ocelot_target {
6969
QSYS,
7070
REW,
7171
SYS,
72+
S2,
7273
HSIO,
7374
TARGET_MAX,
7475
};
@@ -335,6 +336,13 @@ enum ocelot_reg {
335336
SYS_CM_DATA_RD,
336337
SYS_CM_OP,
337338
SYS_CM_DATA,
339+
S2_CORE_UPDATE_CTRL = S2 << TARGET_OFFSET,
340+
S2_CORE_MV_CFG,
341+
S2_CACHE_ENTRY_DAT,
342+
S2_CACHE_MASK_DAT,
343+
S2_CACHE_ACTION_DAT,
344+
S2_CACHE_CNT_DAT,
345+
S2_CACHE_TG_DAT,
338346
};
339347

340348
enum ocelot_regfield {

0 commit comments

Comments
 (0)