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(vctrl: lan966x->vcap_ctrl, ndev: port->dev,
15 from_cid, to_cid, cookie: goto_id,
16 enable: 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(vctrl: lan966x->vcap_ctrl, ndev: port->dev, from_cid: 0, to_cid: 0,
43 cookie: goto_id, enable: 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}
51

source code of linux/drivers/net/ethernet/microchip/lan966x/lan966x_goto.c