Loading...
1// SPDX-License-Identifier: GPL-2.0+
2
3#include "lan966x_main.h"
4#include "vcap_api_client.h"
5
6int lan966x_goto_port_add(struct lan966x_port *port,
7 int from_cid, int to_cid,
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 from_cid, to_cid, 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 return 0;
33}
34
35int lan966x_goto_port_del(struct lan966x_port *port,
36 unsigned long goto_id,
37 struct netlink_ext_ack *extack)
38{
39 struct lan966x *lan966x = port->lan966x;
40 int err;
41
42 err = vcap_enable_lookups(lan966x->vcap_ctrl, port->dev, 0, 0,
43 goto_id, false);
44 if (err) {
45 NL_SET_ERR_MSG_MOD(extack, "Could not disable VCAP lookups");
46 return err;
47 }
48
49 return 0;
50}
1// SPDX-License-Identifier: GPL-2.0+
2
3#include "lan966x_main.h"
4#include "vcap_api_client.h"
5
6int 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
37int 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}