1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2 /* Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved */
4 #ifndef _MLXSW_CORE_ACL_FLEX_ACTIONS_H
5 #define _MLXSW_CORE_ACL_FLEX_ACTIONS_H
7 #include <linux/types.h>
8 #include <linux/netdevice.h>
9 #include <net/flow_offload.h>
12 struct mlxsw_afa_block;
14 struct mlxsw_afa_ops {
15 int (*kvdl_set_add)(void *priv, u32 *p_kvdl_index,
16 char *enc_actions, bool is_first);
17 void (*kvdl_set_del)(void *priv, u32 kvdl_index, bool is_first);
18 int (*kvdl_set_activity_get)(void *priv, u32 kvdl_index,
20 int (*kvdl_fwd_entry_add)(void *priv, u32 *p_kvdl_index, u8 local_port);
21 void (*kvdl_fwd_entry_del)(void *priv, u32 kvdl_index);
22 int (*counter_index_get)(void *priv, unsigned int *p_counter_index);
23 void (*counter_index_put)(void *priv, unsigned int counter_index);
24 int (*mirror_add)(void *priv, u8 local_in_port,
25 const struct net_device *out_dev,
26 bool ingress, int *p_span_id);
27 void (*mirror_del)(void *priv, u8 local_in_port, int span_id,
32 struct mlxsw_afa *mlxsw_afa_create(unsigned int max_acts_per_set,
33 const struct mlxsw_afa_ops *ops,
35 void mlxsw_afa_destroy(struct mlxsw_afa *mlxsw_afa);
36 struct mlxsw_afa_block *mlxsw_afa_block_create(struct mlxsw_afa *mlxsw_afa);
37 void mlxsw_afa_block_destroy(struct mlxsw_afa_block *block);
38 int mlxsw_afa_block_commit(struct mlxsw_afa_block *block);
39 char *mlxsw_afa_block_first_set(struct mlxsw_afa_block *block);
40 char *mlxsw_afa_block_cur_set(struct mlxsw_afa_block *block);
41 u32 mlxsw_afa_block_first_kvdl_index(struct mlxsw_afa_block *block);
42 int mlxsw_afa_block_activity_get(struct mlxsw_afa_block *block, bool *activity);
43 int mlxsw_afa_block_continue(struct mlxsw_afa_block *block);
44 int mlxsw_afa_block_jump(struct mlxsw_afa_block *block, u16 group_id);
45 int mlxsw_afa_block_terminate(struct mlxsw_afa_block *block);
46 const struct flow_action_cookie *
47 mlxsw_afa_cookie_lookup(struct mlxsw_afa *mlxsw_afa, u32 cookie_index);
48 int mlxsw_afa_block_append_drop(struct mlxsw_afa_block *block, bool ingress,
49 const struct flow_action_cookie *fa_cookie,
50 struct netlink_ext_ack *extack);
51 int mlxsw_afa_block_append_trap(struct mlxsw_afa_block *block, u16 trap_id);
52 int mlxsw_afa_block_append_trap_and_forward(struct mlxsw_afa_block *block,
54 int mlxsw_afa_block_append_mirror(struct mlxsw_afa_block *block,
56 const struct net_device *out_dev,
58 struct netlink_ext_ack *extack);
59 int mlxsw_afa_block_append_fwd(struct mlxsw_afa_block *block,
60 u8 local_port, bool in_port,
61 struct netlink_ext_ack *extack);
62 int mlxsw_afa_block_append_vlan_modify(struct mlxsw_afa_block *block,
63 u16 vid, u8 pcp, u8 et,
64 struct netlink_ext_ack *extack);
65 int mlxsw_afa_block_append_qos_switch_prio(struct mlxsw_afa_block *block,
67 struct netlink_ext_ack *extack);
68 int mlxsw_afa_block_append_qos_dsfield(struct mlxsw_afa_block *block,
70 struct netlink_ext_ack *extack);
71 int mlxsw_afa_block_append_qos_dscp(struct mlxsw_afa_block *block,
72 u8 dscp, struct netlink_ext_ack *extack);
73 int mlxsw_afa_block_append_qos_ecn(struct mlxsw_afa_block *block,
74 u8 ecn, struct netlink_ext_ack *extack);
75 int mlxsw_afa_block_append_allocated_counter(struct mlxsw_afa_block *block,
77 int mlxsw_afa_block_append_counter(struct mlxsw_afa_block *block,
79 struct netlink_ext_ack *extack);
80 int mlxsw_afa_block_append_fid_set(struct mlxsw_afa_block *block, u16 fid,
81 struct netlink_ext_ack *extack);
82 int mlxsw_afa_block_append_mcrouter(struct mlxsw_afa_block *block,
83 u16 expected_irif, u16 min_mtu,
84 bool rmid_valid, u32 kvdl_index);