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 11 struct mlxsw_afa; 12 struct mlxsw_afa_block; 13 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, 19 bool *activity); 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, 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, u8 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, u8 local_port, int span_id, 38 bool ingress); 39 bool dummy_first_set; 40 }; 41 42 struct mlxsw_afa *mlxsw_afa_create(unsigned int max_acts_per_set, 43 const struct mlxsw_afa_ops *ops, 44 void *ops_priv); 45 void mlxsw_afa_destroy(struct mlxsw_afa *mlxsw_afa); 46 struct mlxsw_afa_block *mlxsw_afa_block_create(struct mlxsw_afa *mlxsw_afa); 47 void mlxsw_afa_block_destroy(struct mlxsw_afa_block *block); 48 int mlxsw_afa_block_commit(struct mlxsw_afa_block *block); 49 char *mlxsw_afa_block_first_set(struct mlxsw_afa_block *block); 50 char *mlxsw_afa_block_cur_set(struct mlxsw_afa_block *block); 51 u32 mlxsw_afa_block_first_kvdl_index(struct mlxsw_afa_block *block); 52 int mlxsw_afa_block_activity_get(struct mlxsw_afa_block *block, bool *activity); 53 int mlxsw_afa_block_continue(struct mlxsw_afa_block *block); 54 int mlxsw_afa_block_jump(struct mlxsw_afa_block *block, u16 group_id); 55 int mlxsw_afa_block_terminate(struct mlxsw_afa_block *block); 56 const struct flow_action_cookie * 57 mlxsw_afa_cookie_lookup(struct mlxsw_afa *mlxsw_afa, u32 cookie_index); 58 int 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); 61 int mlxsw_afa_block_append_trap(struct mlxsw_afa_block *block, u16 trap_id); 62 int mlxsw_afa_block_append_trap_and_forward(struct mlxsw_afa_block *block, 63 u16 trap_id); 64 int mlxsw_afa_block_append_mirror(struct mlxsw_afa_block *block, 65 u8 local_in_port, 66 const struct net_device *out_dev, 67 bool ingress, 68 struct netlink_ext_ack *extack); 69 int mlxsw_afa_block_append_fwd(struct mlxsw_afa_block *block, 70 u8 local_port, bool in_port, 71 struct netlink_ext_ack *extack); 72 int mlxsw_afa_block_append_vlan_modify(struct mlxsw_afa_block *block, 73 u16 vid, u8 pcp, u8 et, 74 struct netlink_ext_ack *extack); 75 int mlxsw_afa_block_append_qos_switch_prio(struct mlxsw_afa_block *block, 76 u8 prio, 77 struct netlink_ext_ack *extack); 78 int mlxsw_afa_block_append_qos_dsfield(struct mlxsw_afa_block *block, 79 u8 dsfield, 80 struct netlink_ext_ack *extack); 81 int mlxsw_afa_block_append_qos_dscp(struct mlxsw_afa_block *block, 82 u8 dscp, struct netlink_ext_ack *extack); 83 int mlxsw_afa_block_append_qos_ecn(struct mlxsw_afa_block *block, 84 u8 ecn, struct netlink_ext_ack *extack); 85 int mlxsw_afa_block_append_allocated_counter(struct mlxsw_afa_block *block, 86 u32 counter_index); 87 int mlxsw_afa_block_append_counter(struct mlxsw_afa_block *block, 88 u32 *p_counter_index, 89 struct netlink_ext_ack *extack); 90 int mlxsw_afa_block_append_fid_set(struct mlxsw_afa_block *block, u16 fid, 91 struct netlink_ext_ack *extack); 92 int mlxsw_afa_block_append_mcrouter(struct mlxsw_afa_block *block, 93 u16 expected_irif, u16 min_mtu, 94 bool rmid_valid, u32 kvdl_index); 95 int mlxsw_afa_block_append_l4port(struct mlxsw_afa_block *block, bool is_dport, u16 l4_port, 96 struct netlink_ext_ack *extack); 97 int mlxsw_afa_block_append_police(struct mlxsw_afa_block *block, 98 u32 fa_index, u64 rate_bytes_ps, u32 burst, 99 u16 *p_policer_index, 100 struct netlink_ext_ack *extack); 101 int mlxsw_afa_block_append_sampler(struct mlxsw_afa_block *block, u8 local_port, 102 struct psample_group *psample_group, 103 u32 rate, u32 trunc_size, bool truncate, 104 bool ingress, 105 struct netlink_ext_ack *extack); 106 107 #endif 108