Skip to content

Commit 61caac2

Browse files
HoratiuVulturPaolo Abeni
authored andcommitted
net: lan966x: add tc matchall goto action
Extend matchall with action goto. This is needed to enable the lookup in the VCAP. It is needed to connect chain 0 to a chain that is recognized by the HW. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 3643abd commit 61caac2

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

drivers/net/ethernet/microchip/lan966x/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ lan966x-switch-objs := lan966x_main.o lan966x_phylink.o lan966x_port.o \
1313
lan966x_tbf.o lan966x_cbs.o lan966x_ets.o \
1414
lan966x_tc_matchall.o lan966x_police.o lan966x_mirror.o \
1515
lan966x_xdp.o lan966x_vcap_impl.o lan966x_vcap_ag_api.o \
16-
lan966x_tc_flower.o
16+
lan966x_tc_flower.o lan966x_goto.o
1717

1818
# Provide include files
1919
ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// SPDX-License-Identifier: GPL-2.0+
2+
3+
#include "lan966x_main.h"
4+
#include "vcap_api_client.h"
5+
6+
int lan966x_goto_port_add(struct lan966x_port *port,
7+
struct flow_action_entry *act,
8+
unsigned long goto_id,
9+
struct netlink_ext_ack *extack)
10+
{
11+
struct lan966x *lan966x = port->lan966x;
12+
int err;
13+
14+
err = vcap_enable_lookups(lan966x->vcap_ctrl, port->dev,
15+
act->chain_index, goto_id,
16+
true);
17+
if (err == -EFAULT) {
18+
NL_SET_ERR_MSG_MOD(extack, "Unsupported goto chain");
19+
return -EOPNOTSUPP;
20+
}
21+
22+
if (err == -EADDRINUSE) {
23+
NL_SET_ERR_MSG_MOD(extack, "VCAP already enabled");
24+
return -EOPNOTSUPP;
25+
}
26+
27+
if (err) {
28+
NL_SET_ERR_MSG_MOD(extack, "Could not enable VCAP lookups");
29+
return err;
30+
}
31+
32+
port->tc.goto_id = goto_id;
33+
34+
return 0;
35+
}
36+
37+
int lan966x_goto_port_del(struct lan966x_port *port,
38+
unsigned long goto_id,
39+
struct netlink_ext_ack *extack)
40+
{
41+
struct lan966x *lan966x = port->lan966x;
42+
int err;
43+
44+
err = vcap_enable_lookups(lan966x->vcap_ctrl, port->dev, 0,
45+
goto_id, false);
46+
if (err) {
47+
NL_SET_ERR_MSG_MOD(extack, "Could not disable VCAP lookups");
48+
return err;
49+
}
50+
51+
port->tc.goto_id = 0;
52+
53+
return 0;
54+
}

drivers/net/ethernet/microchip/lan966x/lan966x_main.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ struct lan966x_port_tc {
320320
unsigned long police_id;
321321
unsigned long ingress_mirror_id;
322322
unsigned long egress_mirror_id;
323+
unsigned long goto_id;
323324
struct flow_stats police_stat;
324325
struct flow_stats mirror_stat;
325326
};
@@ -591,6 +592,14 @@ void lan966x_vcap_deinit(struct lan966x *lan966x);
591592
int lan966x_tc_flower(struct lan966x_port *port,
592593
struct flow_cls_offload *f);
593594

595+
int lan966x_goto_port_add(struct lan966x_port *port,
596+
struct flow_action_entry *act,
597+
unsigned long goto_id,
598+
struct netlink_ext_ack *extack);
599+
int lan966x_goto_port_del(struct lan966x_port *port,
600+
unsigned long goto_id,
601+
struct netlink_ext_ack *extack);
602+
594603
static inline void __iomem *lan_addr(void __iomem *base[],
595604
int id, int tinst, int tcnt,
596605
int gbase, int ginst,

drivers/net/ethernet/microchip/lan966x/lan966x_tc_matchall.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ static int lan966x_tc_matchall_add(struct lan966x_port *port,
2323
case FLOW_ACTION_MIRRED:
2424
return lan966x_mirror_port_add(port, act, f->cookie,
2525
ingress, f->common.extack);
26+
case FLOW_ACTION_GOTO:
27+
return lan966x_goto_port_add(port, act, f->cookie,
28+
f->common.extack);
2629
default:
2730
NL_SET_ERR_MSG_MOD(f->common.extack,
2831
"Unsupported action");
@@ -43,6 +46,9 @@ static int lan966x_tc_matchall_del(struct lan966x_port *port,
4346
f->cookie == port->tc.egress_mirror_id) {
4447
return lan966x_mirror_port_del(port, ingress,
4548
f->common.extack);
49+
} else if (f->cookie == port->tc.goto_id) {
50+
return lan966x_goto_port_del(port, f->cookie,
51+
f->common.extack);
4652
} else {
4753
NL_SET_ERR_MSG_MOD(f->common.extack,
4854
"Unsupported action");

0 commit comments

Comments
 (0)