Skip to content

Commit

Permalink
net: mscc: ocelot: Add support for tcam
Browse files Browse the repository at this point in the history
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 <horatiu.vultur@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Horatiu Vultur authored and David S. Miller committed Jun 2, 2019
1 parent 6345266 commit b596229
Show file tree
Hide file tree
Showing 10 changed files with 1,508 additions and 3 deletions.
5 changes: 3 additions & 2 deletions arch/mips/boot/dts/mscc/ocelot.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,12 @@
<0x1270000 0x100>,
<0x1280000 0x100>,
<0x1800000 0x80000>,
<0x1880000 0x10000>;
<0x1880000 0x10000>,
<0x1060000 0x10000>;
reg-names = "sys", "rew", "qs", "port0", "port1",
"port2", "port3", "port4", "port5", "port6",
"port7", "port8", "port9", "port10", "qsys",
"ana";
"ana", "s2";
interrupts = <21 22>;
interrupt-names = "xtr", "inj";

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mscc/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: (GPL-2.0 OR MIT)
obj-$(CONFIG_MSCC_OCELOT_SWITCH) += mscc_ocelot_common.o
mscc_ocelot_common-y := ocelot.o ocelot_io.o
mscc_ocelot_common-y += ocelot_regs.o ocelot_tc.o ocelot_police.o
mscc_ocelot_common-y += ocelot_regs.o ocelot_tc.o ocelot_police.o ocelot_ace.o
obj-$(CONFIG_MSCC_OCELOT_SWITCH_OCELOT) += ocelot_board.o
13 changes: 13 additions & 0 deletions drivers/net/ethernet/mscc/ocelot.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <net/switchdev.h>

#include "ocelot.h"
#include "ocelot_ace.h"

#define TABLE_UPDATE_SLEEP_US 10
#define TABLE_UPDATE_TIMEOUT_US 100000
Expand Down Expand Up @@ -130,6 +131,13 @@ static void ocelot_mact_init(struct ocelot *ocelot)
ocelot_write(ocelot, MACACCESS_CMD_INIT, ANA_TABLES_MACACCESS);
}

static void ocelot_vcap_enable(struct ocelot *ocelot, struct ocelot_port *port)
{
ocelot_write_gix(ocelot, ANA_PORT_VCAP_S2_CFG_S2_ENA |
ANA_PORT_VCAP_S2_CFG_S2_IP6_CFG(0xa),
ANA_PORT_VCAP_S2_CFG, port->chip_port);
}

static inline u32 ocelot_vlant_read_vlanaccess(struct ocelot *ocelot)
{
return ocelot_read(ocelot, ANA_TABLES_VLANACCESS);
Expand Down Expand Up @@ -1662,6 +1670,9 @@ int ocelot_probe_port(struct ocelot *ocelot, u8 port,
/* Basic L2 initialization */
ocelot_vlan_port_apply(ocelot, ocelot_port);

/* Enable vcap lookups */
ocelot_vcap_enable(ocelot, ocelot_port);

return 0;

err_register_netdev:
Expand Down Expand Up @@ -1696,6 +1707,7 @@ int ocelot_init(struct ocelot *ocelot)

ocelot_mact_init(ocelot);
ocelot_vlan_init(ocelot);
ocelot_ace_init(ocelot);

for (port = 0; port < ocelot->num_phys_ports; port++) {
/* Clear all counters (5 groups) */
Expand Down Expand Up @@ -1808,6 +1820,7 @@ void ocelot_deinit(struct ocelot *ocelot)
{
destroy_workqueue(ocelot->stats_queue);
mutex_destroy(&ocelot->stats_lock);
ocelot_ace_deinit();
}
EXPORT_SYMBOL(ocelot_deinit);

Expand Down
8 changes: 8 additions & 0 deletions drivers/net/ethernet/mscc/ocelot.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ enum ocelot_target {
QSYS,
REW,
SYS,
S2,
HSIO,
TARGET_MAX,
};
Expand Down Expand Up @@ -335,6 +336,13 @@ enum ocelot_reg {
SYS_CM_DATA_RD,
SYS_CM_OP,
SYS_CM_DATA,
S2_CORE_UPDATE_CTRL = S2 << TARGET_OFFSET,
S2_CORE_MV_CFG,
S2_CACHE_ENTRY_DAT,
S2_CACHE_MASK_DAT,
S2_CACHE_ACTION_DAT,
S2_CACHE_CNT_DAT,
S2_CACHE_TG_DAT,
};

enum ocelot_regfield {
Expand Down
Loading

0 comments on commit b596229

Please sign in to comment.