1/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2/* Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved */
3
4#ifndef _MLXSW_CORE_ACL_FLEX_ACTIONS_H
5#define _MLXSW_CORE_ACL_FLEX_ACTIONS_H
6
7#include <linux/types.h>
8#include <linux/netdevice.h>
9#include <net/flow_offload.h>
10
11struct mlxsw_afa;
12struct mlxsw_afa_block;
13
14struct 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,
19 bool *activity);
20 int (*kvdl_fwd_entry_add)(void *priv, u32 *p_kvdl_index, u16 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, u16 local_in_port,
25 const struct net_device *out_dev,
26 bool ingress, int *p_span_id);
27 void (*mirror_del)(void *priv, u16 local_in_port, int span_id,
28 bool ingress);
29 int (*policer_add)(void *priv, u64 rate_bytes_ps, u32 burst,
30 u16 *p_policer_index,
31 struct netlink_ext_ack *extack);
32 void (*policer_del)(void *priv, u16 policer_index);
33 int (*sampler_add)(void *priv, u16 local_port,
34 struct psample_group *psample_group, u32 rate,
35 u32 trunc_size, bool truncate, bool ingress,
36 int *p_span_id, struct netlink_ext_ack *extack);
37 void (*sampler_del)(void *priv, u16 local_port, int span_id,
38 bool ingress);
39 bool dummy_first_set;
40};
41
42struct mlxsw_afa *mlxsw_afa_create(unsigned int max_acts_per_set,
43 const struct mlxsw_afa_ops *ops,
44 void *ops_priv);
45void mlxsw_afa_destroy(struct mlxsw_afa *mlxsw_afa);
46struct mlxsw_afa_block *mlxsw_afa_block_create(struct mlxsw_afa *mlxsw_afa);
47void mlxsw_afa_block_destroy(struct mlxsw_afa_block *block);
48int mlxsw_afa_block_commit(struct mlxsw_afa_block *block);
49char *mlxsw_afa_block_first_set(struct mlxsw_afa_block *block);
50char *mlxsw_afa_block_cur_set(struct mlxsw_afa_block *block);
51u32 mlxsw_afa_block_first_kvdl_index(struct mlxsw_afa_block *block);
52int mlxsw_afa_block_activity_get(struct mlxsw_afa_block *block, bool *activity);
53int mlxsw_afa_block_continue(struct mlxsw_afa_block *block);
54int mlxsw_afa_block_jump(struct mlxsw_afa_block *block, u16 group_id);
55int mlxsw_afa_block_terminate(struct mlxsw_afa_block *block);
56const struct flow_action_cookie *
57mlxsw_afa_cookie_lookup(struct mlxsw_afa *mlxsw_afa, u32 cookie_index);
58int mlxsw_afa_block_append_drop(struct mlxsw_afa_block *block, bool ingress,
59 const struct flow_action_cookie *fa_cookie,
60 struct netlink_ext_ack *extack);
61int mlxsw_afa_block_append_trap(struct mlxsw_afa_block *block, u16 trap_id);
62int mlxsw_afa_block_append_trap_and_forward(struct mlxsw_afa_block *block,
63 u16 trap_id);
64int mlxsw_afa_block_append_mirror(struct mlxsw_afa_block *block,
65 u16 local_in_port,
66 const struct net_device *out_dev,
67 bool ingress,
68 struct netlink_ext_ack *extack);
69int mlxsw_afa_block_append_fwd(struct mlxsw_afa_block *block,
70 u16 local_port, bool in_port,
71 struct netlink_ext_ack *extack);
72int mlxsw_afa_block_append_vlan_modify(struct mlxsw_afa_block *block,
73 u16 vid, u8 pcp, u8 et,
74 struct netlink_ext_ack *extack);
75int mlxsw_afa_block_append_qos_switch_prio(struct mlxsw_afa_block *block,
76 u8 prio,
77 struct netlink_ext_ack *extack);
78int mlxsw_afa_block_append_qos_dsfield(struct mlxsw_afa_block *block,
79 u8 dsfield,
80 struct netlink_ext_ack *extack);
81int mlxsw_afa_block_append_qos_dscp(struct mlxsw_afa_block *block,
82 u8 dscp, struct netlink_ext_ack *extack);
83int mlxsw_afa_block_append_qos_ecn(struct mlxsw_afa_block *block,
84 u8 ecn, struct netlink_ext_ack *extack);
85int mlxsw_afa_block_append_allocated_counter(struct mlxsw_afa_block *block,
86 u32 counter_index);
87int mlxsw_afa_block_append_counter(struct mlxsw_afa_block *block,
88 u32 *p_counter_index,
89 struct netlink_ext_ack *extack);
90int mlxsw_afa_block_append_fid_set(struct mlxsw_afa_block *block, u16 fid,
91 struct netlink_ext_ack *extack);
92int mlxsw_afa_block_append_ignore(struct mlxsw_afa_block *block,
93 bool disable_learning, bool disable_security);
94int mlxsw_afa_block_append_mcrouter(struct mlxsw_afa_block *block,
95 u16 expected_irif, u16 min_mtu,
96 bool rmid_valid, u32 kvdl_index);
97int mlxsw_afa_block_append_ip(struct mlxsw_afa_block *block, bool is_dip,
98 bool is_lsb, u32 val_31_0, u32 val_63_32,
99 struct netlink_ext_ack *extack);
100int mlxsw_afa_block_append_l4port(struct mlxsw_afa_block *block, bool is_dport, u16 l4_port,
101 struct netlink_ext_ack *extack);
102int mlxsw_afa_block_append_police(struct mlxsw_afa_block *block,
103 u32 fa_index, u64 rate_bytes_ps, u32 burst,
104 u16 *p_policer_index,
105 struct netlink_ext_ack *extack);
106int mlxsw_afa_block_append_sampler(struct mlxsw_afa_block *block, u16 local_port,
107 struct psample_group *psample_group,
108 u32 rate, u32 trunc_size, bool truncate,
109 bool ingress,
110 struct netlink_ext_ack *extack);
111
112#endif
113

source code of linux/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h