1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2019, Mellanox Technologies */
13 enum mlx5dr_domain_type {
14 MLX5DR_DOMAIN_TYPE_NIC_RX,
15 MLX5DR_DOMAIN_TYPE_NIC_TX,
16 MLX5DR_DOMAIN_TYPE_FDB,
19 enum mlx5dr_domain_sync_flags {
20 MLX5DR_DOMAIN_SYNC_FLAGS_SW = 1 << 0,
21 MLX5DR_DOMAIN_SYNC_FLAGS_HW = 1 << 1,
24 enum mlx5dr_action_reformat_type {
25 DR_ACTION_REFORMAT_TYP_TNL_L2_TO_L2,
26 DR_ACTION_REFORMAT_TYP_L2_TO_TNL_L2,
27 DR_ACTION_REFORMAT_TYP_TNL_L3_TO_L2,
28 DR_ACTION_REFORMAT_TYP_L2_TO_TNL_L3,
29 DR_ACTION_REFORMAT_TYP_INSERT_HDR,
30 DR_ACTION_REFORMAT_TYP_REMOVE_HDR,
33 struct mlx5dr_match_parameters {
35 u64 *match_buf; /* Device spec format */
38 struct mlx5dr_action_dest {
39 struct mlx5dr_action *dest;
40 struct mlx5dr_action *reformat;
43 struct mlx5dr_domain *
44 mlx5dr_domain_create(struct mlx5_core_dev *mdev, enum mlx5dr_domain_type type);
46 int mlx5dr_domain_destroy(struct mlx5dr_domain *domain);
48 int mlx5dr_domain_sync(struct mlx5dr_domain *domain, u32 flags);
50 void mlx5dr_domain_set_peer(struct mlx5dr_domain *dmn,
51 struct mlx5dr_domain *peer_dmn);
54 mlx5dr_table_create(struct mlx5dr_domain *domain, u32 level, u32 flags,
58 mlx5dr_table_get_from_fs_ft(struct mlx5_flow_table *ft);
60 int mlx5dr_table_destroy(struct mlx5dr_table *table);
62 u32 mlx5dr_table_get_id(struct mlx5dr_table *table);
64 struct mlx5dr_matcher *
65 mlx5dr_matcher_create(struct mlx5dr_table *table,
67 u8 match_criteria_enable,
68 struct mlx5dr_match_parameters *mask);
70 int mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher);
73 mlx5dr_rule_create(struct mlx5dr_matcher *matcher,
74 struct mlx5dr_match_parameters *value,
76 struct mlx5dr_action *actions[],
79 int mlx5dr_rule_destroy(struct mlx5dr_rule *rule);
81 int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
82 struct mlx5dr_action *action);
84 struct mlx5dr_action *
85 mlx5dr_action_create_dest_table_num(struct mlx5dr_domain *dmn, u32 table_num);
87 struct mlx5dr_action *
88 mlx5dr_action_create_dest_table(struct mlx5dr_table *table);
90 struct mlx5dr_action *
91 mlx5dr_action_create_dest_flow_fw_table(struct mlx5dr_domain *domain,
92 struct mlx5_flow_table *ft);
94 struct mlx5dr_action *
95 mlx5dr_action_create_dest_vport(struct mlx5dr_domain *domain,
96 u16 vport, u8 vhca_id_valid,
99 struct mlx5dr_action *
100 mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn,
101 struct mlx5dr_action_dest *dests,
103 bool ignore_flow_level,
106 struct mlx5dr_action *mlx5dr_action_create_drop(void);
108 struct mlx5dr_action *mlx5dr_action_create_tag(u32 tag_value);
110 struct mlx5dr_action *
111 mlx5dr_action_create_flow_sampler(struct mlx5dr_domain *dmn, u32 sampler_id);
113 struct mlx5dr_action *
114 mlx5dr_action_create_flow_counter(u32 counter_id);
116 struct mlx5dr_action *
117 mlx5dr_action_create_packet_reformat(struct mlx5dr_domain *dmn,
118 enum mlx5dr_action_reformat_type reformat_type,
124 struct mlx5dr_action *
125 mlx5dr_action_create_modify_header(struct mlx5dr_domain *domain,
130 struct mlx5dr_action *mlx5dr_action_create_pop_vlan(void);
132 struct mlx5dr_action *
133 mlx5dr_action_create_push_vlan(struct mlx5dr_domain *domain, __be32 vlan_hdr);
135 struct mlx5dr_action *
136 mlx5dr_action_create_aso(struct mlx5dr_domain *dmn,
143 int mlx5dr_action_destroy(struct mlx5dr_action *action);
146 mlx5dr_is_supported(struct mlx5_core_dev *dev)
148 return MLX5_CAP_GEN(dev, roce) &&
149 (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner) ||
150 (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner_v2) &&
151 (MLX5_CAP_GEN(dev, steering_format_version) <=
152 MLX5_STEERING_FORMAT_CONNECTX_7)));
155 /* buddy functions & structure */
157 struct mlx5dr_icm_mr;
159 struct mlx5dr_icm_buddy_mem {
160 unsigned long **bitmap;
161 unsigned int *num_free;
163 struct list_head list_node;
164 struct mlx5dr_icm_mr *icm_mr;
165 struct mlx5dr_icm_pool *pool;
167 /* This is the list of used chunks. HW may be accessing this memory */
168 struct list_head used_list;
171 /* Hardware may be accessing this memory but at some future,
172 * undetermined time, it might cease to do so.
173 * sync_ste command sets them free.
175 struct list_head hot_list;
177 /* Memory optimisation */
178 struct mlx5dr_ste *ste_arr;
179 struct list_head *miss_list;
183 int mlx5dr_buddy_init(struct mlx5dr_icm_buddy_mem *buddy,
184 unsigned int max_order);
185 void mlx5dr_buddy_cleanup(struct mlx5dr_icm_buddy_mem *buddy);
186 int mlx5dr_buddy_alloc_mem(struct mlx5dr_icm_buddy_mem *buddy,
188 unsigned int *segment);
189 void mlx5dr_buddy_free_mem(struct mlx5dr_icm_buddy_mem *buddy,
190 unsigned int seg, unsigned int order);
192 #endif /* _MLX5DR_H_ */