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,
31 struct mlx5dr_match_parameters {
33 u64 *match_buf; /* Device spec format */
36 struct mlx5dr_action_dest {
37 struct mlx5dr_action *dest;
38 struct mlx5dr_action *reformat;
41 struct mlx5dr_domain *
42 mlx5dr_domain_create(struct mlx5_core_dev *mdev, enum mlx5dr_domain_type type);
44 int mlx5dr_domain_destroy(struct mlx5dr_domain *domain);
46 int mlx5dr_domain_sync(struct mlx5dr_domain *domain, u32 flags);
48 void mlx5dr_domain_set_peer(struct mlx5dr_domain *dmn,
49 struct mlx5dr_domain *peer_dmn);
52 mlx5dr_table_create(struct mlx5dr_domain *domain, u32 level, u32 flags);
54 int mlx5dr_table_destroy(struct mlx5dr_table *table);
56 u32 mlx5dr_table_get_id(struct mlx5dr_table *table);
58 struct mlx5dr_matcher *
59 mlx5dr_matcher_create(struct mlx5dr_table *table,
61 u8 match_criteria_enable,
62 struct mlx5dr_match_parameters *mask);
64 int mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher);
67 mlx5dr_rule_create(struct mlx5dr_matcher *matcher,
68 struct mlx5dr_match_parameters *value,
70 struct mlx5dr_action *actions[],
73 int mlx5dr_rule_destroy(struct mlx5dr_rule *rule);
75 int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
76 struct mlx5dr_action *action);
78 struct mlx5dr_action *
79 mlx5dr_action_create_dest_table_num(struct mlx5dr_domain *dmn, u32 table_num);
81 struct mlx5dr_action *
82 mlx5dr_action_create_dest_table(struct mlx5dr_table *table);
84 struct mlx5dr_action *
85 mlx5dr_action_create_dest_flow_fw_table(struct mlx5dr_domain *domain,
86 struct mlx5_flow_table *ft);
88 struct mlx5dr_action *
89 mlx5dr_action_create_dest_vport(struct mlx5dr_domain *domain,
90 u32 vport, u8 vhca_id_valid,
93 struct mlx5dr_action *
94 mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn,
95 struct mlx5dr_action_dest *dests,
98 struct mlx5dr_action *mlx5dr_action_create_drop(void);
100 struct mlx5dr_action *mlx5dr_action_create_tag(u32 tag_value);
102 struct mlx5dr_action *
103 mlx5dr_action_create_flow_counter(u32 counter_id);
105 struct mlx5dr_action *
106 mlx5dr_action_create_packet_reformat(struct mlx5dr_domain *dmn,
107 enum mlx5dr_action_reformat_type reformat_type,
111 struct mlx5dr_action *
112 mlx5dr_action_create_modify_header(struct mlx5dr_domain *domain,
117 struct mlx5dr_action *mlx5dr_action_create_pop_vlan(void);
119 struct mlx5dr_action *
120 mlx5dr_action_create_push_vlan(struct mlx5dr_domain *domain, __be32 vlan_hdr);
122 int mlx5dr_action_destroy(struct mlx5dr_action *action);
125 mlx5dr_is_supported(struct mlx5_core_dev *dev)
127 return MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner) ||
128 (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner_v2) &&
129 (MLX5_CAP_GEN(dev, steering_format_version) <=
130 MLX5_STEERING_FORMAT_CONNECTX_6DX));
133 /* buddy functions & structure */
135 struct mlx5dr_icm_mr;
137 struct mlx5dr_icm_buddy_mem {
138 unsigned long **bitmap;
139 unsigned int *num_free;
141 struct list_head list_node;
142 struct mlx5dr_icm_mr *icm_mr;
143 struct mlx5dr_icm_pool *pool;
145 /* This is the list of used chunks. HW may be accessing this memory */
146 struct list_head used_list;
149 /* Hardware may be accessing this memory but at some future,
150 * undetermined time, it might cease to do so.
151 * sync_ste command sets them free.
153 struct list_head hot_list;
156 int mlx5dr_buddy_init(struct mlx5dr_icm_buddy_mem *buddy,
157 unsigned int max_order);
158 void mlx5dr_buddy_cleanup(struct mlx5dr_icm_buddy_mem *buddy);
159 int mlx5dr_buddy_alloc_mem(struct mlx5dr_icm_buddy_mem *buddy,
161 unsigned int *segment);
162 void mlx5dr_buddy_free_mem(struct mlx5dr_icm_buddy_mem *buddy,
163 unsigned int seg, unsigned int order);
165 #endif /* _MLX5DR_H_ */