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