16a48faeeSMaor Gottlieb // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
26a48faeeSMaor Gottlieb /* Copyright (c) 2019 Mellanox Technologies */
36a48faeeSMaor Gottlieb 
4e3a0f40bSYevgeny Kliteynik #include <linux/mlx5/vport.h>
56a48faeeSMaor Gottlieb #include "mlx5_core.h"
66a48faeeSMaor Gottlieb #include "fs_core.h"
76a48faeeSMaor Gottlieb #include "fs_cmd.h"
86a48faeeSMaor Gottlieb #include "mlx5dr.h"
96a48faeeSMaor Gottlieb #include "fs_dr.h"
100a8c20e2SYevgeny Kliteynik #include "dr_types.h"
116a48faeeSMaor Gottlieb 
dr_is_fw_term_table(struct mlx5_flow_table * ft)120a8c20e2SYevgeny Kliteynik static bool dr_is_fw_term_table(struct mlx5_flow_table *ft)
136a48faeeSMaor Gottlieb {
140a8c20e2SYevgeny Kliteynik 	if (ft->flags & MLX5_FLOW_TABLE_TERMINATION)
156a48faeeSMaor Gottlieb 		return true;
166a48faeeSMaor Gottlieb 
176a48faeeSMaor Gottlieb 	return false;
186a48faeeSMaor Gottlieb }
196a48faeeSMaor Gottlieb 
mlx5_cmd_dr_update_root_ft(struct mlx5_flow_root_namespace * ns,struct mlx5_flow_table * ft,u32 underlay_qpn,bool disconnect)206a48faeeSMaor Gottlieb static int mlx5_cmd_dr_update_root_ft(struct mlx5_flow_root_namespace *ns,
216a48faeeSMaor Gottlieb 				      struct mlx5_flow_table *ft,
226a48faeeSMaor Gottlieb 				      u32 underlay_qpn,
236a48faeeSMaor Gottlieb 				      bool disconnect)
246a48faeeSMaor Gottlieb {
256a48faeeSMaor Gottlieb 	return mlx5_fs_cmd_get_fw_cmds()->update_root_ft(ns, ft, underlay_qpn,
266a48faeeSMaor Gottlieb 							 disconnect);
276a48faeeSMaor Gottlieb }
286a48faeeSMaor Gottlieb 
set_miss_action(struct mlx5_flow_root_namespace * ns,struct mlx5_flow_table * ft,struct mlx5_flow_table * next_ft)296a48faeeSMaor Gottlieb static int set_miss_action(struct mlx5_flow_root_namespace *ns,
306a48faeeSMaor Gottlieb 			   struct mlx5_flow_table *ft,
316a48faeeSMaor Gottlieb 			   struct mlx5_flow_table *next_ft)
326a48faeeSMaor Gottlieb {
336a48faeeSMaor Gottlieb 	struct mlx5dr_action *old_miss_action;
346a48faeeSMaor Gottlieb 	struct mlx5dr_action *action = NULL;
356a48faeeSMaor Gottlieb 	struct mlx5dr_table *next_tbl;
366a48faeeSMaor Gottlieb 	int err;
376a48faeeSMaor Gottlieb 
386a48faeeSMaor Gottlieb 	next_tbl = next_ft ? next_ft->fs_dr_table.dr_table : NULL;
396a48faeeSMaor Gottlieb 	if (next_tbl) {
406a48faeeSMaor Gottlieb 		action = mlx5dr_action_create_dest_table(next_tbl);
416a48faeeSMaor Gottlieb 		if (!action)
426a48faeeSMaor Gottlieb 			return -EINVAL;
436a48faeeSMaor Gottlieb 	}
446a48faeeSMaor Gottlieb 	old_miss_action = ft->fs_dr_table.miss_action;
456a48faeeSMaor Gottlieb 	err = mlx5dr_table_set_miss_action(ft->fs_dr_table.dr_table, action);
466a48faeeSMaor Gottlieb 	if (err && action) {
476a48faeeSMaor Gottlieb 		err = mlx5dr_action_destroy(action);
4880b2bd73SLeon Romanovsky 		if (err)
4980b2bd73SLeon Romanovsky 			mlx5_core_err(ns->dev,
5080b2bd73SLeon Romanovsky 				      "Failed to destroy action (%d)\n", err);
516a48faeeSMaor Gottlieb 		action = NULL;
526a48faeeSMaor Gottlieb 	}
536a48faeeSMaor Gottlieb 	ft->fs_dr_table.miss_action = action;
546a48faeeSMaor Gottlieb 	if (old_miss_action) {
556a48faeeSMaor Gottlieb 		err = mlx5dr_action_destroy(old_miss_action);
566a48faeeSMaor Gottlieb 		if (err)
576a48faeeSMaor Gottlieb 			mlx5_core_err(ns->dev, "Failed to destroy action (%d)\n",
586a48faeeSMaor Gottlieb 				      err);
596a48faeeSMaor Gottlieb 	}
606a48faeeSMaor Gottlieb 
616a48faeeSMaor Gottlieb 	return err;
626a48faeeSMaor Gottlieb }
636a48faeeSMaor Gottlieb 
mlx5_cmd_dr_create_flow_table(struct mlx5_flow_root_namespace * ns,struct mlx5_flow_table * ft,struct mlx5_flow_table_attr * ft_attr,struct mlx5_flow_table * next_ft)646a48faeeSMaor Gottlieb static int mlx5_cmd_dr_create_flow_table(struct mlx5_flow_root_namespace *ns,
656a48faeeSMaor Gottlieb 					 struct mlx5_flow_table *ft,
66b0bb369eSMark Bloch 					 struct mlx5_flow_table_attr *ft_attr,
676a48faeeSMaor Gottlieb 					 struct mlx5_flow_table *next_ft)
686a48faeeSMaor Gottlieb {
696a48faeeSMaor Gottlieb 	struct mlx5dr_table *tbl;
7013a7e459SErez Shitrit 	u32 flags;
716a48faeeSMaor Gottlieb 	int err;
726a48faeeSMaor Gottlieb 
730a8c20e2SYevgeny Kliteynik 	if (dr_is_fw_term_table(ft))
746a48faeeSMaor Gottlieb 		return mlx5_fs_cmd_get_fw_cmds()->create_flow_table(ns, ft,
75b0bb369eSMark Bloch 								    ft_attr,
766a48faeeSMaor Gottlieb 								    next_ft);
7713a7e459SErez Shitrit 	flags = ft->flags;
7813a7e459SErez Shitrit 	/* turn off encap/decap if not supported for sw-str by fw */
7913a7e459SErez Shitrit 	if (!MLX5_CAP_FLOWTABLE(ns->dev, sw_owner_reformat_supported))
8013a7e459SErez Shitrit 		flags = ft->flags & ~(MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT |
8113a7e459SErez Shitrit 				      MLX5_FLOW_TABLE_TUNNEL_EN_DECAP);
826a48faeeSMaor Gottlieb 
83b0bb369eSMark Bloch 	tbl = mlx5dr_table_create(ns->fs_dr_domain.dr_domain, ft->level, flags,
84b0bb369eSMark Bloch 				  ft_attr->uid);
856a48faeeSMaor Gottlieb 	if (!tbl) {
866a48faeeSMaor Gottlieb 		mlx5_core_err(ns->dev, "Failed creating dr flow_table\n");
876a48faeeSMaor Gottlieb 		return -EINVAL;
886a48faeeSMaor Gottlieb 	}
896a48faeeSMaor Gottlieb 
906a48faeeSMaor Gottlieb 	ft->fs_dr_table.dr_table = tbl;
916a48faeeSMaor Gottlieb 	ft->id = mlx5dr_table_get_id(tbl);
926a48faeeSMaor Gottlieb 
936a48faeeSMaor Gottlieb 	if (next_ft) {
946a48faeeSMaor Gottlieb 		err = set_miss_action(ns, ft, next_ft);
956a48faeeSMaor Gottlieb 		if (err) {
966a48faeeSMaor Gottlieb 			mlx5dr_table_destroy(tbl);
976a48faeeSMaor Gottlieb 			ft->fs_dr_table.dr_table = NULL;
986a48faeeSMaor Gottlieb 			return err;
996a48faeeSMaor Gottlieb 		}
1006a48faeeSMaor Gottlieb 	}
1016a48faeeSMaor Gottlieb 
1029e117998SPaul Blakey 	ft->max_fte = INT_MAX;
10304745afbSPaul Blakey 
1046a48faeeSMaor Gottlieb 	return 0;
1056a48faeeSMaor Gottlieb }
1066a48faeeSMaor Gottlieb 
mlx5_cmd_dr_destroy_flow_table(struct mlx5_flow_root_namespace * ns,struct mlx5_flow_table * ft)1076a48faeeSMaor Gottlieb static int mlx5_cmd_dr_destroy_flow_table(struct mlx5_flow_root_namespace *ns,
1086a48faeeSMaor Gottlieb 					  struct mlx5_flow_table *ft)
1096a48faeeSMaor Gottlieb {
1106a48faeeSMaor Gottlieb 	struct mlx5dr_action *action = ft->fs_dr_table.miss_action;
1116a48faeeSMaor Gottlieb 	int err;
1126a48faeeSMaor Gottlieb 
1130a8c20e2SYevgeny Kliteynik 	if (dr_is_fw_term_table(ft))
1146a48faeeSMaor Gottlieb 		return mlx5_fs_cmd_get_fw_cmds()->destroy_flow_table(ns, ft);
1156a48faeeSMaor Gottlieb 
1166a48faeeSMaor Gottlieb 	err = mlx5dr_table_destroy(ft->fs_dr_table.dr_table);
1176a48faeeSMaor Gottlieb 	if (err) {
1186a48faeeSMaor Gottlieb 		mlx5_core_err(ns->dev, "Failed to destroy flow_table (%d)\n",
1196a48faeeSMaor Gottlieb 			      err);
1206a48faeeSMaor Gottlieb 		return err;
1216a48faeeSMaor Gottlieb 	}
1226a48faeeSMaor Gottlieb 	if (action) {
1236a48faeeSMaor Gottlieb 		err = mlx5dr_action_destroy(action);
1246a48faeeSMaor Gottlieb 		if (err) {
1256a48faeeSMaor Gottlieb 			mlx5_core_err(ns->dev, "Failed to destroy action(%d)\n",
1266a48faeeSMaor Gottlieb 				      err);
1276a48faeeSMaor Gottlieb 			return err;
1286a48faeeSMaor Gottlieb 		}
1296a48faeeSMaor Gottlieb 	}
1306a48faeeSMaor Gottlieb 
1316a48faeeSMaor Gottlieb 	return err;
1326a48faeeSMaor Gottlieb }
1336a48faeeSMaor Gottlieb 
mlx5_cmd_dr_modify_flow_table(struct mlx5_flow_root_namespace * ns,struct mlx5_flow_table * ft,struct mlx5_flow_table * next_ft)1346a48faeeSMaor Gottlieb static int mlx5_cmd_dr_modify_flow_table(struct mlx5_flow_root_namespace *ns,
1356a48faeeSMaor Gottlieb 					 struct mlx5_flow_table *ft,
1366a48faeeSMaor Gottlieb 					 struct mlx5_flow_table *next_ft)
1376a48faeeSMaor Gottlieb {
1380a8c20e2SYevgeny Kliteynik 	if (dr_is_fw_term_table(ft))
139a01a43faSYevgeny Kliteynik 		return mlx5_fs_cmd_get_fw_cmds()->modify_flow_table(ns, ft, next_ft);
140a01a43faSYevgeny Kliteynik 
1416a48faeeSMaor Gottlieb 	return set_miss_action(ns, ft, next_ft);
1426a48faeeSMaor Gottlieb }
1436a48faeeSMaor Gottlieb 
mlx5_cmd_dr_create_flow_group(struct mlx5_flow_root_namespace * ns,struct mlx5_flow_table * ft,u32 * in,struct mlx5_flow_group * fg)1446a48faeeSMaor Gottlieb static int mlx5_cmd_dr_create_flow_group(struct mlx5_flow_root_namespace *ns,
1456a48faeeSMaor Gottlieb 					 struct mlx5_flow_table *ft,
1466a48faeeSMaor Gottlieb 					 u32 *in,
1476a48faeeSMaor Gottlieb 					 struct mlx5_flow_group *fg)
1486a48faeeSMaor Gottlieb {
1496a48faeeSMaor Gottlieb 	struct mlx5dr_matcher *matcher;
150f6409299SHamdan Igbaria 	u32 priority = MLX5_GET(create_flow_group_in, in,
1516a48faeeSMaor Gottlieb 				start_flow_index);
1526a48faeeSMaor Gottlieb 	u8 match_criteria_enable = MLX5_GET(create_flow_group_in,
1536a48faeeSMaor Gottlieb 					    in,
1546a48faeeSMaor Gottlieb 					    match_criteria_enable);
1556a48faeeSMaor Gottlieb 	struct mlx5dr_match_parameters mask;
1566a48faeeSMaor Gottlieb 
1570a8c20e2SYevgeny Kliteynik 	if (dr_is_fw_term_table(ft))
1586a48faeeSMaor Gottlieb 		return mlx5_fs_cmd_get_fw_cmds()->create_flow_group(ns, ft, in,
1596a48faeeSMaor Gottlieb 								    fg);
1606a48faeeSMaor Gottlieb 
1616a48faeeSMaor Gottlieb 	mask.match_buf = MLX5_ADDR_OF(create_flow_group_in,
1626a48faeeSMaor Gottlieb 				      in, match_criteria);
1636a48faeeSMaor Gottlieb 	mask.match_sz = sizeof(fg->mask.match_criteria);
1646a48faeeSMaor Gottlieb 
1656a48faeeSMaor Gottlieb 	matcher = mlx5dr_matcher_create(ft->fs_dr_table.dr_table,
1666a48faeeSMaor Gottlieb 					priority,
1676a48faeeSMaor Gottlieb 					match_criteria_enable,
1686a48faeeSMaor Gottlieb 					&mask);
1696a48faeeSMaor Gottlieb 	if (!matcher) {
1706a48faeeSMaor Gottlieb 		mlx5_core_err(ns->dev, "Failed creating matcher\n");
1716a48faeeSMaor Gottlieb 		return -EINVAL;
1726a48faeeSMaor Gottlieb 	}
1736a48faeeSMaor Gottlieb 
1746a48faeeSMaor Gottlieb 	fg->fs_dr_matcher.dr_matcher = matcher;
1756a48faeeSMaor Gottlieb 	return 0;
1766a48faeeSMaor Gottlieb }
1776a48faeeSMaor Gottlieb 
mlx5_cmd_dr_destroy_flow_group(struct mlx5_flow_root_namespace * ns,struct mlx5_flow_table * ft,struct mlx5_flow_group * fg)1786a48faeeSMaor Gottlieb static int mlx5_cmd_dr_destroy_flow_group(struct mlx5_flow_root_namespace *ns,
1796a48faeeSMaor Gottlieb 					  struct mlx5_flow_table *ft,
1806a48faeeSMaor Gottlieb 					  struct mlx5_flow_group *fg)
1816a48faeeSMaor Gottlieb {
1820a8c20e2SYevgeny Kliteynik 	if (dr_is_fw_term_table(ft))
1836a48faeeSMaor Gottlieb 		return mlx5_fs_cmd_get_fw_cmds()->destroy_flow_group(ns, ft, fg);
1846a48faeeSMaor Gottlieb 
1856a48faeeSMaor Gottlieb 	return mlx5dr_matcher_destroy(fg->fs_dr_matcher.dr_matcher);
1866a48faeeSMaor Gottlieb }
1876a48faeeSMaor Gottlieb 
create_vport_action(struct mlx5dr_domain * domain,struct mlx5_flow_rule * dst)1886a48faeeSMaor Gottlieb static struct mlx5dr_action *create_vport_action(struct mlx5dr_domain *domain,
1896a48faeeSMaor Gottlieb 						 struct mlx5_flow_rule *dst)
1906a48faeeSMaor Gottlieb {
1916a48faeeSMaor Gottlieb 	struct mlx5_flow_destination *dest_attr = &dst->dest_attr;
1926a48faeeSMaor Gottlieb 
1936a48faeeSMaor Gottlieb 	return mlx5dr_action_create_dest_vport(domain, dest_attr->vport.num,
1946a48faeeSMaor Gottlieb 					       dest_attr->vport.flags &
1956a48faeeSMaor Gottlieb 					       MLX5_FLOW_DEST_VPORT_VHCA_ID,
1966a48faeeSMaor Gottlieb 					       dest_attr->vport.vhca_id);
1976a48faeeSMaor Gottlieb }
1986a48faeeSMaor Gottlieb 
create_uplink_action(struct mlx5dr_domain * domain,struct mlx5_flow_rule * dst)199e3a0f40bSYevgeny Kliteynik static struct mlx5dr_action *create_uplink_action(struct mlx5dr_domain *domain,
200e3a0f40bSYevgeny Kliteynik 						  struct mlx5_flow_rule *dst)
201e3a0f40bSYevgeny Kliteynik {
202e3a0f40bSYevgeny Kliteynik 	struct mlx5_flow_destination *dest_attr = &dst->dest_attr;
203e3a0f40bSYevgeny Kliteynik 
204e3a0f40bSYevgeny Kliteynik 	return mlx5dr_action_create_dest_vport(domain, MLX5_VPORT_UPLINK, 1,
205e3a0f40bSYevgeny Kliteynik 					       dest_attr->vport.vhca_id);
206e3a0f40bSYevgeny Kliteynik }
207e3a0f40bSYevgeny Kliteynik 
create_ft_action(struct mlx5dr_domain * domain,struct mlx5_flow_rule * dst)208aec292eeSAlex Vesker static struct mlx5dr_action *create_ft_action(struct mlx5dr_domain *domain,
2096a48faeeSMaor Gottlieb 					      struct mlx5_flow_rule *dst)
2106a48faeeSMaor Gottlieb {
2116a48faeeSMaor Gottlieb 	struct mlx5_flow_table *dest_ft = dst->dest_attr.ft;
2126a48faeeSMaor Gottlieb 
2130a8c20e2SYevgeny Kliteynik 	if (mlx5dr_is_fw_table(dest_ft))
214aec292eeSAlex Vesker 		return mlx5dr_action_create_dest_flow_fw_table(domain, dest_ft);
2156a48faeeSMaor Gottlieb 	return mlx5dr_action_create_dest_table(dest_ft->fs_dr_table.dr_table);
2166a48faeeSMaor Gottlieb }
2176a48faeeSMaor Gottlieb 
create_range_action(struct mlx5dr_domain * domain,struct mlx5_flow_rule * dst)218be6d5daeSYevgeny Kliteynik static struct mlx5dr_action *create_range_action(struct mlx5dr_domain *domain,
219be6d5daeSYevgeny Kliteynik 						 struct mlx5_flow_rule *dst)
220be6d5daeSYevgeny Kliteynik {
221be6d5daeSYevgeny Kliteynik 	return mlx5dr_action_create_dest_match_range(domain,
222be6d5daeSYevgeny Kliteynik 						     dst->dest_attr.range.field,
223be6d5daeSYevgeny Kliteynik 						     dst->dest_attr.range.hit_ft,
224be6d5daeSYevgeny Kliteynik 						     dst->dest_attr.range.miss_ft,
225be6d5daeSYevgeny Kliteynik 						     dst->dest_attr.range.min,
226be6d5daeSYevgeny Kliteynik 						     dst->dest_attr.range.max);
227be6d5daeSYevgeny Kliteynik }
228be6d5daeSYevgeny Kliteynik 
create_action_push_vlan(struct mlx5dr_domain * domain,struct mlx5_fs_vlan * vlan)2296a48faeeSMaor Gottlieb static struct mlx5dr_action *create_action_push_vlan(struct mlx5dr_domain *domain,
2306a48faeeSMaor Gottlieb 						     struct mlx5_fs_vlan *vlan)
2316a48faeeSMaor Gottlieb {
2326a48faeeSMaor Gottlieb 	u16 n_ethtype = vlan->ethtype;
2336a48faeeSMaor Gottlieb 	u8  prio = vlan->prio;
2346a48faeeSMaor Gottlieb 	u16 vid = vlan->vid;
2356a48faeeSMaor Gottlieb 	u32 vlan_hdr;
2366a48faeeSMaor Gottlieb 
2376a48faeeSMaor Gottlieb 	vlan_hdr = (u32)n_ethtype << 16 | (u32)(prio) << 12 |  (u32)vid;
2386a48faeeSMaor Gottlieb 	return mlx5dr_action_create_push_vlan(domain, htonl(vlan_hdr));
2396a48faeeSMaor Gottlieb }
2406a48faeeSMaor Gottlieb 
contain_vport_reformat_action(struct mlx5_flow_rule * dst)2417ee3f6d2SAlex Vesker static bool contain_vport_reformat_action(struct mlx5_flow_rule *dst)
2427ee3f6d2SAlex Vesker {
243e3a0f40bSYevgeny Kliteynik 	return (dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_VPORT ||
244e3a0f40bSYevgeny Kliteynik 		dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_UPLINK) &&
2457ee3f6d2SAlex Vesker 		dst->dest_attr.vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID;
2467ee3f6d2SAlex Vesker }
2477ee3f6d2SAlex Vesker 
2480aec12d9SYevgeny Kliteynik /* We want to support a rule with 32 destinations, which means we need to
2490aec12d9SYevgeny Kliteynik  * account for 32 destinations plus usually a counter plus one more action
2500aec12d9SYevgeny Kliteynik  * for a multi-destination flow table.
2510aec12d9SYevgeny Kliteynik  */
2520aec12d9SYevgeny Kliteynik #define MLX5_FLOW_CONTEXT_ACTION_MAX  34
mlx5_cmd_dr_create_fte(struct mlx5_flow_root_namespace * ns,struct mlx5_flow_table * ft,struct mlx5_flow_group * group,struct fs_fte * fte)2536a48faeeSMaor Gottlieb static int mlx5_cmd_dr_create_fte(struct mlx5_flow_root_namespace *ns,
2546a48faeeSMaor Gottlieb 				  struct mlx5_flow_table *ft,
2556a48faeeSMaor Gottlieb 				  struct mlx5_flow_group *group,
2566a48faeeSMaor Gottlieb 				  struct fs_fte *fte)
2576a48faeeSMaor Gottlieb {
2586a48faeeSMaor Gottlieb 	struct mlx5dr_domain *domain = ns->fs_dr_domain.dr_domain;
2597ee3f6d2SAlex Vesker 	struct mlx5dr_action_dest *term_actions;
2606a48faeeSMaor Gottlieb 	struct mlx5dr_match_parameters params;
2616a48faeeSMaor Gottlieb 	struct mlx5_core_dev *dev = ns->dev;
2626a48faeeSMaor Gottlieb 	struct mlx5dr_action **fs_dr_actions;
2636a48faeeSMaor Gottlieb 	struct mlx5dr_action *tmp_action;
2646a48faeeSMaor Gottlieb 	struct mlx5dr_action **actions;
2656a48faeeSMaor Gottlieb 	bool delay_encap_set = false;
2666a48faeeSMaor Gottlieb 	struct mlx5dr_rule *rule;
2676a48faeeSMaor Gottlieb 	struct mlx5_flow_rule *dst;
2686a48faeeSMaor Gottlieb 	int fs_dr_num_actions = 0;
2697ee3f6d2SAlex Vesker 	int num_term_actions = 0;
2706a48faeeSMaor Gottlieb 	int num_actions = 0;
2716a48faeeSMaor Gottlieb 	size_t match_sz;
2726a48faeeSMaor Gottlieb 	int err = 0;
2736a48faeeSMaor Gottlieb 	int i;
2746a48faeeSMaor Gottlieb 
2750a8c20e2SYevgeny Kliteynik 	if (dr_is_fw_term_table(ft))
2766a48faeeSMaor Gottlieb 		return mlx5_fs_cmd_get_fw_cmds()->create_fte(ns, ft, group, fte);
2776a48faeeSMaor Gottlieb 
2786a48faeeSMaor Gottlieb 	actions = kcalloc(MLX5_FLOW_CONTEXT_ACTION_MAX, sizeof(*actions),
2796a48faeeSMaor Gottlieb 			  GFP_KERNEL);
2807ee3f6d2SAlex Vesker 	if (!actions) {
2817ee3f6d2SAlex Vesker 		err = -ENOMEM;
2827ee3f6d2SAlex Vesker 		goto out_err;
2837ee3f6d2SAlex Vesker 	}
2846a48faeeSMaor Gottlieb 
2856a48faeeSMaor Gottlieb 	fs_dr_actions = kcalloc(MLX5_FLOW_CONTEXT_ACTION_MAX,
2866a48faeeSMaor Gottlieb 				sizeof(*fs_dr_actions), GFP_KERNEL);
2876a48faeeSMaor Gottlieb 	if (!fs_dr_actions) {
2887ee3f6d2SAlex Vesker 		err = -ENOMEM;
2897ee3f6d2SAlex Vesker 		goto free_actions_alloc;
2907ee3f6d2SAlex Vesker 	}
2917ee3f6d2SAlex Vesker 
2927ee3f6d2SAlex Vesker 	term_actions = kcalloc(MLX5_FLOW_CONTEXT_ACTION_MAX,
2937ee3f6d2SAlex Vesker 			       sizeof(*term_actions), GFP_KERNEL);
2947ee3f6d2SAlex Vesker 	if (!term_actions) {
2957ee3f6d2SAlex Vesker 		err = -ENOMEM;
2967ee3f6d2SAlex Vesker 		goto free_fs_dr_actions_alloc;
2976a48faeeSMaor Gottlieb 	}
2986a48faeeSMaor Gottlieb 
2996a48faeeSMaor Gottlieb 	match_sz = sizeof(fte->val);
3006a48faeeSMaor Gottlieb 
3017ee3f6d2SAlex Vesker 	/* Drop reformat action bit if destination vport set with reformat */
3027ee3f6d2SAlex Vesker 	if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
3037ee3f6d2SAlex Vesker 		list_for_each_entry(dst, &fte->node.children, node.list) {
3047ee3f6d2SAlex Vesker 			if (!contain_vport_reformat_action(dst))
3057ee3f6d2SAlex Vesker 				continue;
3067ee3f6d2SAlex Vesker 
3077ee3f6d2SAlex Vesker 			fte->action.action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
3087ee3f6d2SAlex Vesker 			break;
3097ee3f6d2SAlex Vesker 		}
3107ee3f6d2SAlex Vesker 	}
3117ee3f6d2SAlex Vesker 
3126a48faeeSMaor Gottlieb 	/* The order of the actions are must to be keep, only the following
3136a48faeeSMaor Gottlieb 	 * order is supported by SW steering:
314b2064909SAlex Vesker 	 * TX: modify header -> push vlan -> encap
3156a48faeeSMaor Gottlieb 	 * RX: decap -> pop vlan -> modify header
3166a48faeeSMaor Gottlieb 	 */
3176a48faeeSMaor Gottlieb 	if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_DECAP) {
3186a48faeeSMaor Gottlieb 		enum mlx5dr_action_reformat_type decap_type =
3196a48faeeSMaor Gottlieb 			DR_ACTION_REFORMAT_TYP_TNL_L2_TO_L2;
3206a48faeeSMaor Gottlieb 
3216a48faeeSMaor Gottlieb 		tmp_action = mlx5dr_action_create_packet_reformat(domain,
3223f3f05abSYevgeny Kliteynik 								  decap_type,
3233f3f05abSYevgeny Kliteynik 								  0, 0, 0,
3246a48faeeSMaor Gottlieb 								  NULL);
3256a48faeeSMaor Gottlieb 		if (!tmp_action) {
3266a48faeeSMaor Gottlieb 			err = -ENOMEM;
3276a48faeeSMaor Gottlieb 			goto free_actions;
3286a48faeeSMaor Gottlieb 		}
3296a48faeeSMaor Gottlieb 		fs_dr_actions[fs_dr_num_actions++] = tmp_action;
3306a48faeeSMaor Gottlieb 		actions[num_actions++] = tmp_action;
3316a48faeeSMaor Gottlieb 	}
3326a48faeeSMaor Gottlieb 
3336a48faeeSMaor Gottlieb 	if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT) {
33487cd0649SYevgeny Kliteynik 		bool is_decap;
33587cd0649SYevgeny Kliteynik 
33687cd0649SYevgeny Kliteynik 		if (fte->action.pkt_reformat->owner == MLX5_FLOW_RESOURCE_OWNER_FW) {
33787cd0649SYevgeny Kliteynik 			err = -EINVAL;
33887cd0649SYevgeny Kliteynik 			mlx5dr_err(domain, "FW-owned reformat can't be used in SW rule\n");
33987cd0649SYevgeny Kliteynik 			goto free_actions;
34087cd0649SYevgeny Kliteynik 		}
34187cd0649SYevgeny Kliteynik 
34287cd0649SYevgeny Kliteynik 		is_decap = fte->action.pkt_reformat->reformat_type ==
3436a48faeeSMaor Gottlieb 			   MLX5_REFORMAT_TYPE_L3_TUNNEL_TO_L2;
3446a48faeeSMaor Gottlieb 
3456a48faeeSMaor Gottlieb 		if (is_decap)
3466a48faeeSMaor Gottlieb 			actions[num_actions++] =
3476a48faeeSMaor Gottlieb 				fte->action.pkt_reformat->action.dr_action;
3486a48faeeSMaor Gottlieb 		else
3496a48faeeSMaor Gottlieb 			delay_encap_set = true;
3506a48faeeSMaor Gottlieb 	}
3516a48faeeSMaor Gottlieb 
3526a48faeeSMaor Gottlieb 	if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_VLAN_POP) {
3536a48faeeSMaor Gottlieb 		tmp_action =
3546a48faeeSMaor Gottlieb 			mlx5dr_action_create_pop_vlan();
3556a48faeeSMaor Gottlieb 		if (!tmp_action) {
3566a48faeeSMaor Gottlieb 			err = -ENOMEM;
3576a48faeeSMaor Gottlieb 			goto free_actions;
3586a48faeeSMaor Gottlieb 		}
3596a48faeeSMaor Gottlieb 		fs_dr_actions[fs_dr_num_actions++] = tmp_action;
3606a48faeeSMaor Gottlieb 		actions[num_actions++] = tmp_action;
3616a48faeeSMaor Gottlieb 	}
3626a48faeeSMaor Gottlieb 
3636a48faeeSMaor Gottlieb 	if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_VLAN_POP_2) {
3646a48faeeSMaor Gottlieb 		tmp_action =
3656a48faeeSMaor Gottlieb 			mlx5dr_action_create_pop_vlan();
3666a48faeeSMaor Gottlieb 		if (!tmp_action) {
3676a48faeeSMaor Gottlieb 			err = -ENOMEM;
3686a48faeeSMaor Gottlieb 			goto free_actions;
3696a48faeeSMaor Gottlieb 		}
3706a48faeeSMaor Gottlieb 		fs_dr_actions[fs_dr_num_actions++] = tmp_action;
3716a48faeeSMaor Gottlieb 		actions[num_actions++] = tmp_action;
3726a48faeeSMaor Gottlieb 	}
3736a48faeeSMaor Gottlieb 
3746a48faeeSMaor Gottlieb 	if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
3756a48faeeSMaor Gottlieb 		actions[num_actions++] =
3766a48faeeSMaor Gottlieb 			fte->action.modify_hdr->action.dr_action;
3776a48faeeSMaor Gottlieb 
378b2064909SAlex Vesker 	if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH) {
379b2064909SAlex Vesker 		tmp_action = create_action_push_vlan(domain, &fte->action.vlan[0]);
380b2064909SAlex Vesker 		if (!tmp_action) {
381b2064909SAlex Vesker 			err = -ENOMEM;
382b2064909SAlex Vesker 			goto free_actions;
383b2064909SAlex Vesker 		}
384b2064909SAlex Vesker 		fs_dr_actions[fs_dr_num_actions++] = tmp_action;
385b2064909SAlex Vesker 		actions[num_actions++] = tmp_action;
386b2064909SAlex Vesker 	}
387b2064909SAlex Vesker 
388b2064909SAlex Vesker 	if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH_2) {
389b2064909SAlex Vesker 		tmp_action = create_action_push_vlan(domain, &fte->action.vlan[1]);
390b2064909SAlex Vesker 		if (!tmp_action) {
391b2064909SAlex Vesker 			err = -ENOMEM;
392b2064909SAlex Vesker 			goto free_actions;
393b2064909SAlex Vesker 		}
394b2064909SAlex Vesker 		fs_dr_actions[fs_dr_num_actions++] = tmp_action;
395b2064909SAlex Vesker 		actions[num_actions++] = tmp_action;
396b2064909SAlex Vesker 	}
397b2064909SAlex Vesker 
3986a48faeeSMaor Gottlieb 	if (delay_encap_set)
3996a48faeeSMaor Gottlieb 		actions[num_actions++] =
4006a48faeeSMaor Gottlieb 			fte->action.pkt_reformat->action.dr_action;
4016a48faeeSMaor Gottlieb 
4026a48faeeSMaor Gottlieb 	/* The order of the actions below is not important */
4036a48faeeSMaor Gottlieb 
4046a48faeeSMaor Gottlieb 	if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_DROP) {
4056a48faeeSMaor Gottlieb 		tmp_action = mlx5dr_action_create_drop();
4066a48faeeSMaor Gottlieb 		if (!tmp_action) {
4076a48faeeSMaor Gottlieb 			err = -ENOMEM;
4086a48faeeSMaor Gottlieb 			goto free_actions;
4096a48faeeSMaor Gottlieb 		}
4106a48faeeSMaor Gottlieb 		fs_dr_actions[fs_dr_num_actions++] = tmp_action;
4117ee3f6d2SAlex Vesker 		term_actions[num_term_actions++].dest = tmp_action;
4126a48faeeSMaor Gottlieb 	}
4136a48faeeSMaor Gottlieb 
4146a48faeeSMaor Gottlieb 	if (fte->flow_context.flow_tag) {
4156a48faeeSMaor Gottlieb 		tmp_action =
4166a48faeeSMaor Gottlieb 			mlx5dr_action_create_tag(fte->flow_context.flow_tag);
4176a48faeeSMaor Gottlieb 		if (!tmp_action) {
4186a48faeeSMaor Gottlieb 			err = -ENOMEM;
4196a48faeeSMaor Gottlieb 			goto free_actions;
4206a48faeeSMaor Gottlieb 		}
4216a48faeeSMaor Gottlieb 		fs_dr_actions[fs_dr_num_actions++] = tmp_action;
4226a48faeeSMaor Gottlieb 		actions[num_actions++] = tmp_action;
4236a48faeeSMaor Gottlieb 	}
4246a48faeeSMaor Gottlieb 
4256a48faeeSMaor Gottlieb 	if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
4266a48faeeSMaor Gottlieb 		list_for_each_entry(dst, &fte->node.children, node.list) {
4276a48faeeSMaor Gottlieb 			enum mlx5_flow_destination_type type = dst->dest_attr.type;
4281ab6dc35SYevgeny Kliteynik 			u32 id;
4296a48faeeSMaor Gottlieb 
4300aec12d9SYevgeny Kliteynik 			if (fs_dr_num_actions == MLX5_FLOW_CONTEXT_ACTION_MAX ||
4310aec12d9SYevgeny Kliteynik 			    num_term_actions == MLX5_FLOW_CONTEXT_ACTION_MAX) {
4320aec12d9SYevgeny Kliteynik 				err = -EOPNOTSUPP;
4336a48faeeSMaor Gottlieb 				goto free_actions;
4346a48faeeSMaor Gottlieb 			}
4356a48faeeSMaor Gottlieb 
436b850a821SErez Shitrit 			if (type == MLX5_FLOW_DESTINATION_TYPE_COUNTER)
437b850a821SErez Shitrit 				continue;
4386a48faeeSMaor Gottlieb 
439b850a821SErez Shitrit 			switch (type) {
4406a48faeeSMaor Gottlieb 			case MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE:
441aec292eeSAlex Vesker 				tmp_action = create_ft_action(domain, dst);
4426a48faeeSMaor Gottlieb 				if (!tmp_action) {
4436a48faeeSMaor Gottlieb 					err = -ENOMEM;
4446a48faeeSMaor Gottlieb 					goto free_actions;
4456a48faeeSMaor Gottlieb 				}
4466a48faeeSMaor Gottlieb 				fs_dr_actions[fs_dr_num_actions++] = tmp_action;
4477ee3f6d2SAlex Vesker 				term_actions[num_term_actions++].dest = tmp_action;
4486a48faeeSMaor Gottlieb 				break;
449e3a0f40bSYevgeny Kliteynik 			case MLX5_FLOW_DESTINATION_TYPE_UPLINK:
4506a48faeeSMaor Gottlieb 			case MLX5_FLOW_DESTINATION_TYPE_VPORT:
451e3a0f40bSYevgeny Kliteynik 				tmp_action = type == MLX5_FLOW_DESTINATION_TYPE_VPORT ?
452e3a0f40bSYevgeny Kliteynik 					     create_vport_action(domain, dst) :
453e3a0f40bSYevgeny Kliteynik 					     create_uplink_action(domain, dst);
4546a48faeeSMaor Gottlieb 				if (!tmp_action) {
4556a48faeeSMaor Gottlieb 					err = -ENOMEM;
4566a48faeeSMaor Gottlieb 					goto free_actions;
4576a48faeeSMaor Gottlieb 				}
4586a48faeeSMaor Gottlieb 				fs_dr_actions[fs_dr_num_actions++] = tmp_action;
4597ee3f6d2SAlex Vesker 				term_actions[num_term_actions].dest = tmp_action;
4607ee3f6d2SAlex Vesker 
4617ee3f6d2SAlex Vesker 				if (dst->dest_attr.vport.flags &
4627ee3f6d2SAlex Vesker 				    MLX5_FLOW_DEST_VPORT_REFORMAT_ID)
4637ee3f6d2SAlex Vesker 					term_actions[num_term_actions].reformat =
4647ee3f6d2SAlex Vesker 						dst->dest_attr.vport.pkt_reformat->action.dr_action;
4657ee3f6d2SAlex Vesker 
4667ee3f6d2SAlex Vesker 				num_term_actions++;
4676a48faeeSMaor Gottlieb 				break;
468de346f40SAlex Vesker 			case MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE_NUM:
4691ab6dc35SYevgeny Kliteynik 				id = dst->dest_attr.ft_num;
470de346f40SAlex Vesker 				tmp_action = mlx5dr_action_create_dest_table_num(domain,
4711ab6dc35SYevgeny Kliteynik 										 id);
4721ab6dc35SYevgeny Kliteynik 				if (!tmp_action) {
4731ab6dc35SYevgeny Kliteynik 					err = -ENOMEM;
4741ab6dc35SYevgeny Kliteynik 					goto free_actions;
4751ab6dc35SYevgeny Kliteynik 				}
4761ab6dc35SYevgeny Kliteynik 				fs_dr_actions[fs_dr_num_actions++] = tmp_action;
4771ab6dc35SYevgeny Kliteynik 				term_actions[num_term_actions++].dest = tmp_action;
4781ab6dc35SYevgeny Kliteynik 				break;
4791ab6dc35SYevgeny Kliteynik 			case MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER:
4801ab6dc35SYevgeny Kliteynik 				id = dst->dest_attr.sampler_id;
4811ab6dc35SYevgeny Kliteynik 				tmp_action = mlx5dr_action_create_flow_sampler(domain,
4821ab6dc35SYevgeny Kliteynik 									       id);
483de346f40SAlex Vesker 				if (!tmp_action) {
484de346f40SAlex Vesker 					err = -ENOMEM;
485de346f40SAlex Vesker 					goto free_actions;
486de346f40SAlex Vesker 				}
487de346f40SAlex Vesker 				fs_dr_actions[fs_dr_num_actions++] = tmp_action;
488de346f40SAlex Vesker 				term_actions[num_term_actions++].dest = tmp_action;
489de346f40SAlex Vesker 				break;
490be6d5daeSYevgeny Kliteynik 			case MLX5_FLOW_DESTINATION_TYPE_RANGE:
491be6d5daeSYevgeny Kliteynik 				tmp_action = create_range_action(domain, dst);
492be6d5daeSYevgeny Kliteynik 				if (!tmp_action) {
493be6d5daeSYevgeny Kliteynik 					err = -ENOMEM;
494be6d5daeSYevgeny Kliteynik 					goto free_actions;
495be6d5daeSYevgeny Kliteynik 				}
496be6d5daeSYevgeny Kliteynik 				fs_dr_actions[fs_dr_num_actions++] = tmp_action;
497be6d5daeSYevgeny Kliteynik 				term_actions[num_term_actions++].dest = tmp_action;
498be6d5daeSYevgeny Kliteynik 				break;
4996a48faeeSMaor Gottlieb 			default:
5006a48faeeSMaor Gottlieb 				err = -EOPNOTSUPP;
5016a48faeeSMaor Gottlieb 				goto free_actions;
5026a48faeeSMaor Gottlieb 			}
5036a48faeeSMaor Gottlieb 		}
5046a48faeeSMaor Gottlieb 	}
5056a48faeeSMaor Gottlieb 
506b850a821SErez Shitrit 	if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_COUNT) {
507b850a821SErez Shitrit 		list_for_each_entry(dst, &fte->node.children, node.list) {
508b850a821SErez Shitrit 			u32 id;
509b850a821SErez Shitrit 
510b850a821SErez Shitrit 			if (dst->dest_attr.type !=
511b850a821SErez Shitrit 			    MLX5_FLOW_DESTINATION_TYPE_COUNTER)
512b850a821SErez Shitrit 				continue;
513b850a821SErez Shitrit 
5140aec12d9SYevgeny Kliteynik 			if (num_actions == MLX5_FLOW_CONTEXT_ACTION_MAX ||
5150aec12d9SYevgeny Kliteynik 			    fs_dr_num_actions == MLX5_FLOW_CONTEXT_ACTION_MAX) {
5160aec12d9SYevgeny Kliteynik 				err = -EOPNOTSUPP;
517b850a821SErez Shitrit 				goto free_actions;
518b850a821SErez Shitrit 			}
519b850a821SErez Shitrit 
520b850a821SErez Shitrit 			id = dst->dest_attr.counter_id;
521b850a821SErez Shitrit 			tmp_action =
522b850a821SErez Shitrit 				mlx5dr_action_create_flow_counter(id);
523b850a821SErez Shitrit 			if (!tmp_action) {
524b850a821SErez Shitrit 				err = -ENOMEM;
525b850a821SErez Shitrit 				goto free_actions;
526b850a821SErez Shitrit 			}
527b850a821SErez Shitrit 
528b850a821SErez Shitrit 			fs_dr_actions[fs_dr_num_actions++] = tmp_action;
529b850a821SErez Shitrit 			actions[num_actions++] = tmp_action;
530b850a821SErez Shitrit 		}
531b850a821SErez Shitrit 	}
532b850a821SErez Shitrit 
5338920d92bSYevgeny Kliteynik 	if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_EXECUTE_ASO) {
5348920d92bSYevgeny Kliteynik 		if (fte->action.exe_aso.type != MLX5_EXE_ASO_FLOW_METER) {
5358920d92bSYevgeny Kliteynik 			err = -EOPNOTSUPP;
5368920d92bSYevgeny Kliteynik 			goto free_actions;
5378920d92bSYevgeny Kliteynik 		}
5388920d92bSYevgeny Kliteynik 
5398920d92bSYevgeny Kliteynik 		tmp_action =
5408920d92bSYevgeny Kliteynik 			mlx5dr_action_create_aso(domain,
5418920d92bSYevgeny Kliteynik 						 fte->action.exe_aso.object_id,
5428920d92bSYevgeny Kliteynik 						 fte->action.exe_aso.return_reg_id,
5438920d92bSYevgeny Kliteynik 						 fte->action.exe_aso.type,
5448920d92bSYevgeny Kliteynik 						 fte->action.exe_aso.flow_meter.init_color,
5458920d92bSYevgeny Kliteynik 						 fte->action.exe_aso.flow_meter.meter_idx);
5468920d92bSYevgeny Kliteynik 		if (!tmp_action) {
5478920d92bSYevgeny Kliteynik 			err = -ENOMEM;
5488920d92bSYevgeny Kliteynik 			goto free_actions;
5498920d92bSYevgeny Kliteynik 		}
5508920d92bSYevgeny Kliteynik 		fs_dr_actions[fs_dr_num_actions++] = tmp_action;
5518920d92bSYevgeny Kliteynik 		actions[num_actions++] = tmp_action;
5528920d92bSYevgeny Kliteynik 	}
5538920d92bSYevgeny Kliteynik 
5546a48faeeSMaor Gottlieb 	params.match_sz = match_sz;
5556a48faeeSMaor Gottlieb 	params.match_buf = (u64 *)fte->val;
5567ee3f6d2SAlex Vesker 	if (num_term_actions == 1) {
5570aec12d9SYevgeny Kliteynik 		if (term_actions->reformat) {
5580aec12d9SYevgeny Kliteynik 			if (num_actions == MLX5_FLOW_CONTEXT_ACTION_MAX) {
5590aec12d9SYevgeny Kliteynik 				err = -EOPNOTSUPP;
5600aec12d9SYevgeny Kliteynik 				goto free_actions;
5610aec12d9SYevgeny Kliteynik 			}
5627ee3f6d2SAlex Vesker 			actions[num_actions++] = term_actions->reformat;
5630aec12d9SYevgeny Kliteynik 		}
5646a48faeeSMaor Gottlieb 
5650aec12d9SYevgeny Kliteynik 		if (num_actions == MLX5_FLOW_CONTEXT_ACTION_MAX) {
5660aec12d9SYevgeny Kliteynik 			err = -EOPNOTSUPP;
5670aec12d9SYevgeny Kliteynik 			goto free_actions;
5680aec12d9SYevgeny Kliteynik 		}
5697ee3f6d2SAlex Vesker 		actions[num_actions++] = term_actions->dest;
5707ee3f6d2SAlex Vesker 	} else if (num_term_actions > 1) {
57163b85f49SYevgeny Kliteynik 		bool ignore_flow_level =
57263b85f49SYevgeny Kliteynik 			!!(fte->action.flags & FLOW_ACT_IGNORE_FLOW_LEVEL);
5732c5fc6cdSMaor Dickman 		u32 flow_source = fte->flow_context.flow_source;
57463b85f49SYevgeny Kliteynik 
5750aec12d9SYevgeny Kliteynik 		if (num_actions == MLX5_FLOW_CONTEXT_ACTION_MAX ||
5760aec12d9SYevgeny Kliteynik 		    fs_dr_num_actions == MLX5_FLOW_CONTEXT_ACTION_MAX) {
5770aec12d9SYevgeny Kliteynik 			err = -EOPNOTSUPP;
5780aec12d9SYevgeny Kliteynik 			goto free_actions;
5790aec12d9SYevgeny Kliteynik 		}
5807ee3f6d2SAlex Vesker 		tmp_action = mlx5dr_action_create_mult_dest_tbl(domain,
5817ee3f6d2SAlex Vesker 								term_actions,
58263b85f49SYevgeny Kliteynik 								num_term_actions,
5832c5fc6cdSMaor Dickman 								ignore_flow_level,
5842c5fc6cdSMaor Dickman 								flow_source);
5857ee3f6d2SAlex Vesker 		if (!tmp_action) {
5867ee3f6d2SAlex Vesker 			err = -EOPNOTSUPP;
5877ee3f6d2SAlex Vesker 			goto free_actions;
5887ee3f6d2SAlex Vesker 		}
5897ee3f6d2SAlex Vesker 		fs_dr_actions[fs_dr_num_actions++] = tmp_action;
5907ee3f6d2SAlex Vesker 		actions[num_actions++] = tmp_action;
5917ee3f6d2SAlex Vesker 	}
5926a48faeeSMaor Gottlieb 
5936a48faeeSMaor Gottlieb 	rule = mlx5dr_rule_create(group->fs_dr_matcher.dr_matcher,
5946a48faeeSMaor Gottlieb 				  &params,
5956a48faeeSMaor Gottlieb 				  num_actions,
59601723919SHamdan Igbaria 				  actions,
59701723919SHamdan Igbaria 				  fte->flow_context.flow_source);
5986a48faeeSMaor Gottlieb 	if (!rule) {
5996a48faeeSMaor Gottlieb 		err = -EINVAL;
6006a48faeeSMaor Gottlieb 		goto free_actions;
6016a48faeeSMaor Gottlieb 	}
6026a48faeeSMaor Gottlieb 
6037ee3f6d2SAlex Vesker 	kfree(term_actions);
6046a48faeeSMaor Gottlieb 	kfree(actions);
6057ee3f6d2SAlex Vesker 
6066a48faeeSMaor Gottlieb 	fte->fs_dr_rule.dr_rule = rule;
6076a48faeeSMaor Gottlieb 	fte->fs_dr_rule.num_actions = fs_dr_num_actions;
6086a48faeeSMaor Gottlieb 	fte->fs_dr_rule.dr_actions = fs_dr_actions;
6096a48faeeSMaor Gottlieb 
6106a48faeeSMaor Gottlieb 	return 0;
6116a48faeeSMaor Gottlieb 
6126a48faeeSMaor Gottlieb free_actions:
6137ee3f6d2SAlex Vesker 	/* Free in reverse order to handle action dependencies */
6147ee3f6d2SAlex Vesker 	for (i = fs_dr_num_actions - 1; i >= 0; i--)
6156a48faeeSMaor Gottlieb 		if (!IS_ERR_OR_NULL(fs_dr_actions[i]))
6166a48faeeSMaor Gottlieb 			mlx5dr_action_destroy(fs_dr_actions[i]);
6176a48faeeSMaor Gottlieb 
6187ee3f6d2SAlex Vesker 	kfree(term_actions);
6197ee3f6d2SAlex Vesker free_fs_dr_actions_alloc:
6206a48faeeSMaor Gottlieb 	kfree(fs_dr_actions);
6217ee3f6d2SAlex Vesker free_actions_alloc:
6227ee3f6d2SAlex Vesker 	kfree(actions);
6237ee3f6d2SAlex Vesker out_err:
6247ee3f6d2SAlex Vesker 	mlx5_core_err(dev, "Failed to create dr rule err(%d)\n", err);
6256a48faeeSMaor Gottlieb 	return err;
6266a48faeeSMaor Gottlieb }
6276a48faeeSMaor Gottlieb 
mlx5_cmd_dr_packet_reformat_alloc(struct mlx5_flow_root_namespace * ns,struct mlx5_pkt_reformat_params * params,enum mlx5_flow_namespace_type namespace,struct mlx5_pkt_reformat * pkt_reformat)6286a48faeeSMaor Gottlieb static int mlx5_cmd_dr_packet_reformat_alloc(struct mlx5_flow_root_namespace *ns,
6293f3f05abSYevgeny Kliteynik 					     struct mlx5_pkt_reformat_params *params,
6306a48faeeSMaor Gottlieb 					     enum mlx5_flow_namespace_type namespace,
6316a48faeeSMaor Gottlieb 					     struct mlx5_pkt_reformat *pkt_reformat)
6326a48faeeSMaor Gottlieb {
6336a48faeeSMaor Gottlieb 	struct mlx5dr_domain *dr_domain = ns->fs_dr_domain.dr_domain;
6346a48faeeSMaor Gottlieb 	struct mlx5dr_action *action;
6356a48faeeSMaor Gottlieb 	int dr_reformat;
6366a48faeeSMaor Gottlieb 
6373f3f05abSYevgeny Kliteynik 	switch (params->type) {
6386a48faeeSMaor Gottlieb 	case MLX5_REFORMAT_TYPE_L2_TO_VXLAN:
6396a48faeeSMaor Gottlieb 	case MLX5_REFORMAT_TYPE_L2_TO_NVGRE:
6406a48faeeSMaor Gottlieb 	case MLX5_REFORMAT_TYPE_L2_TO_L2_TUNNEL:
6416a48faeeSMaor Gottlieb 		dr_reformat = DR_ACTION_REFORMAT_TYP_L2_TO_TNL_L2;
6426a48faeeSMaor Gottlieb 		break;
6436a48faeeSMaor Gottlieb 	case MLX5_REFORMAT_TYPE_L3_TUNNEL_TO_L2:
6446a48faeeSMaor Gottlieb 		dr_reformat = DR_ACTION_REFORMAT_TYP_TNL_L3_TO_L2;
6456a48faeeSMaor Gottlieb 		break;
6466a48faeeSMaor Gottlieb 	case MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL:
6476a48faeeSMaor Gottlieb 		dr_reformat = DR_ACTION_REFORMAT_TYP_L2_TO_TNL_L3;
6486a48faeeSMaor Gottlieb 		break;
6497ea9b398SYevgeny Kliteynik 	case MLX5_REFORMAT_TYPE_INSERT_HDR:
6507ea9b398SYevgeny Kliteynik 		dr_reformat = DR_ACTION_REFORMAT_TYP_INSERT_HDR;
6517ea9b398SYevgeny Kliteynik 		break;
6520139145fSYevgeny Kliteynik 	case MLX5_REFORMAT_TYPE_REMOVE_HDR:
6530139145fSYevgeny Kliteynik 		dr_reformat = DR_ACTION_REFORMAT_TYP_REMOVE_HDR;
6540139145fSYevgeny Kliteynik 		break;
6556a48faeeSMaor Gottlieb 	default:
6566a48faeeSMaor Gottlieb 		mlx5_core_err(ns->dev, "Packet-reformat not supported(%d)\n",
6573f3f05abSYevgeny Kliteynik 			      params->type);
6586a48faeeSMaor Gottlieb 		return -EOPNOTSUPP;
6596a48faeeSMaor Gottlieb 	}
6606a48faeeSMaor Gottlieb 
6616a48faeeSMaor Gottlieb 	action = mlx5dr_action_create_packet_reformat(dr_domain,
6626a48faeeSMaor Gottlieb 						      dr_reformat,
6633f3f05abSYevgeny Kliteynik 						      params->param_0,
6643f3f05abSYevgeny Kliteynik 						      params->param_1,
6653f3f05abSYevgeny Kliteynik 						      params->size,
6663f3f05abSYevgeny Kliteynik 						      params->data);
6676a48faeeSMaor Gottlieb 	if (!action) {
6686a48faeeSMaor Gottlieb 		mlx5_core_err(ns->dev, "Failed allocating packet-reformat action\n");
6696a48faeeSMaor Gottlieb 		return -EINVAL;
6706a48faeeSMaor Gottlieb 	}
6716a48faeeSMaor Gottlieb 
67287cd0649SYevgeny Kliteynik 	pkt_reformat->owner = MLX5_FLOW_RESOURCE_OWNER_SW;
6736a48faeeSMaor Gottlieb 	pkt_reformat->action.dr_action = action;
6746a48faeeSMaor Gottlieb 
6756a48faeeSMaor Gottlieb 	return 0;
6766a48faeeSMaor Gottlieb }
6776a48faeeSMaor Gottlieb 
mlx5_cmd_dr_packet_reformat_dealloc(struct mlx5_flow_root_namespace * ns,struct mlx5_pkt_reformat * pkt_reformat)6786a48faeeSMaor Gottlieb static void mlx5_cmd_dr_packet_reformat_dealloc(struct mlx5_flow_root_namespace *ns,
6796a48faeeSMaor Gottlieb 						struct mlx5_pkt_reformat *pkt_reformat)
6806a48faeeSMaor Gottlieb {
6816a48faeeSMaor Gottlieb 	mlx5dr_action_destroy(pkt_reformat->action.dr_action);
6826a48faeeSMaor Gottlieb }
6836a48faeeSMaor Gottlieb 
mlx5_cmd_dr_modify_header_alloc(struct mlx5_flow_root_namespace * ns,u8 namespace,u8 num_actions,void * modify_actions,struct mlx5_modify_hdr * modify_hdr)6846a48faeeSMaor Gottlieb static int mlx5_cmd_dr_modify_header_alloc(struct mlx5_flow_root_namespace *ns,
6856a48faeeSMaor Gottlieb 					   u8 namespace, u8 num_actions,
6866a48faeeSMaor Gottlieb 					   void *modify_actions,
6876a48faeeSMaor Gottlieb 					   struct mlx5_modify_hdr *modify_hdr)
6886a48faeeSMaor Gottlieb {
6896a48faeeSMaor Gottlieb 	struct mlx5dr_domain *dr_domain = ns->fs_dr_domain.dr_domain;
6906a48faeeSMaor Gottlieb 	struct mlx5dr_action *action;
6916a48faeeSMaor Gottlieb 	size_t actions_sz;
6926a48faeeSMaor Gottlieb 
693d65dbedfSHuy Nguyen 	actions_sz = MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto) *
6946a48faeeSMaor Gottlieb 		num_actions;
6956a48faeeSMaor Gottlieb 	action = mlx5dr_action_create_modify_header(dr_domain, 0,
6966a48faeeSMaor Gottlieb 						    actions_sz,
6976a48faeeSMaor Gottlieb 						    modify_actions);
6986a48faeeSMaor Gottlieb 	if (!action) {
6996a48faeeSMaor Gottlieb 		mlx5_core_err(ns->dev, "Failed allocating modify-header action\n");
7006a48faeeSMaor Gottlieb 		return -EINVAL;
7016a48faeeSMaor Gottlieb 	}
7026a48faeeSMaor Gottlieb 
70387cd0649SYevgeny Kliteynik 	modify_hdr->owner = MLX5_FLOW_RESOURCE_OWNER_SW;
7046a48faeeSMaor Gottlieb 	modify_hdr->action.dr_action = action;
7056a48faeeSMaor Gottlieb 
7066a48faeeSMaor Gottlieb 	return 0;
7076a48faeeSMaor Gottlieb }
7086a48faeeSMaor Gottlieb 
mlx5_cmd_dr_modify_header_dealloc(struct mlx5_flow_root_namespace * ns,struct mlx5_modify_hdr * modify_hdr)7096a48faeeSMaor Gottlieb static void mlx5_cmd_dr_modify_header_dealloc(struct mlx5_flow_root_namespace *ns,
7106a48faeeSMaor Gottlieb 					      struct mlx5_modify_hdr *modify_hdr)
7116a48faeeSMaor Gottlieb {
7126a48faeeSMaor Gottlieb 	mlx5dr_action_destroy(modify_hdr->action.dr_action);
7136a48faeeSMaor Gottlieb }
7146a48faeeSMaor Gottlieb 
715e7e2519eSMaor Gottlieb static int
mlx5_cmd_dr_destroy_match_definer(struct mlx5_flow_root_namespace * ns,int definer_id)716e7e2519eSMaor Gottlieb mlx5_cmd_dr_destroy_match_definer(struct mlx5_flow_root_namespace *ns,
717e7e2519eSMaor Gottlieb 				  int definer_id)
718e7e2519eSMaor Gottlieb {
719e7e2519eSMaor Gottlieb 	return -EOPNOTSUPP;
720e7e2519eSMaor Gottlieb }
721e7e2519eSMaor Gottlieb 
mlx5_cmd_dr_create_match_definer(struct mlx5_flow_root_namespace * ns,u16 format_id,u32 * match_mask)722e7e2519eSMaor Gottlieb static int mlx5_cmd_dr_create_match_definer(struct mlx5_flow_root_namespace *ns,
723e7e2519eSMaor Gottlieb 					    u16 format_id, u32 *match_mask)
724e7e2519eSMaor Gottlieb {
725e7e2519eSMaor Gottlieb 	return -EOPNOTSUPP;
726e7e2519eSMaor Gottlieb }
727e7e2519eSMaor Gottlieb 
mlx5_cmd_dr_delete_fte(struct mlx5_flow_root_namespace * ns,struct mlx5_flow_table * ft,struct fs_fte * fte)7286a48faeeSMaor Gottlieb static int mlx5_cmd_dr_delete_fte(struct mlx5_flow_root_namespace *ns,
7296a48faeeSMaor Gottlieb 				  struct mlx5_flow_table *ft,
7306a48faeeSMaor Gottlieb 				  struct fs_fte *fte)
7316a48faeeSMaor Gottlieb {
7326a48faeeSMaor Gottlieb 	struct mlx5_fs_dr_rule *rule = &fte->fs_dr_rule;
7336a48faeeSMaor Gottlieb 	int err;
7346a48faeeSMaor Gottlieb 	int i;
7356a48faeeSMaor Gottlieb 
7360a8c20e2SYevgeny Kliteynik 	if (dr_is_fw_term_table(ft))
7376a48faeeSMaor Gottlieb 		return mlx5_fs_cmd_get_fw_cmds()->delete_fte(ns, ft, fte);
7386a48faeeSMaor Gottlieb 
7396a48faeeSMaor Gottlieb 	err = mlx5dr_rule_destroy(rule->dr_rule);
7406a48faeeSMaor Gottlieb 	if (err)
7416a48faeeSMaor Gottlieb 		return err;
7426a48faeeSMaor Gottlieb 
7437ee3f6d2SAlex Vesker 	/* Free in reverse order to handle action dependencies */
7447ee3f6d2SAlex Vesker 	for (i = rule->num_actions - 1; i >= 0; i--)
7456a48faeeSMaor Gottlieb 		if (!IS_ERR_OR_NULL(rule->dr_actions[i]))
7466a48faeeSMaor Gottlieb 			mlx5dr_action_destroy(rule->dr_actions[i]);
7476a48faeeSMaor Gottlieb 
7486a48faeeSMaor Gottlieb 	kfree(rule->dr_actions);
7496a48faeeSMaor Gottlieb 	return 0;
7506a48faeeSMaor Gottlieb }
7516a48faeeSMaor Gottlieb 
mlx5_cmd_dr_update_fte(struct mlx5_flow_root_namespace * ns,struct mlx5_flow_table * ft,struct mlx5_flow_group * group,int modify_mask,struct fs_fte * fte)752a2ebfbb7SYevgeny Kliteynik static int mlx5_cmd_dr_update_fte(struct mlx5_flow_root_namespace *ns,
753a2ebfbb7SYevgeny Kliteynik 				  struct mlx5_flow_table *ft,
754a2ebfbb7SYevgeny Kliteynik 				  struct mlx5_flow_group *group,
755a2ebfbb7SYevgeny Kliteynik 				  int modify_mask,
756a2ebfbb7SYevgeny Kliteynik 				  struct fs_fte *fte)
757a2ebfbb7SYevgeny Kliteynik {
758a2ebfbb7SYevgeny Kliteynik 	struct fs_fte fte_tmp = {};
759a2ebfbb7SYevgeny Kliteynik 	int ret;
760a2ebfbb7SYevgeny Kliteynik 
7610a8c20e2SYevgeny Kliteynik 	if (dr_is_fw_term_table(ft))
762a2ebfbb7SYevgeny Kliteynik 		return mlx5_fs_cmd_get_fw_cmds()->update_fte(ns, ft, group, modify_mask, fte);
763a2ebfbb7SYevgeny Kliteynik 
764a2ebfbb7SYevgeny Kliteynik 	/* Backup current dr rule details */
765a2ebfbb7SYevgeny Kliteynik 	fte_tmp.fs_dr_rule = fte->fs_dr_rule;
766a2ebfbb7SYevgeny Kliteynik 	memset(&fte->fs_dr_rule, 0, sizeof(struct mlx5_fs_dr_rule));
767a2ebfbb7SYevgeny Kliteynik 
768a2ebfbb7SYevgeny Kliteynik 	/* First add the new updated rule, then delete the old rule */
769a2ebfbb7SYevgeny Kliteynik 	ret = mlx5_cmd_dr_create_fte(ns, ft, group, fte);
770a2ebfbb7SYevgeny Kliteynik 	if (ret)
771a2ebfbb7SYevgeny Kliteynik 		goto restore_fte;
772a2ebfbb7SYevgeny Kliteynik 
773a2ebfbb7SYevgeny Kliteynik 	ret = mlx5_cmd_dr_delete_fte(ns, ft, &fte_tmp);
774a2ebfbb7SYevgeny Kliteynik 	WARN_ONCE(ret, "dr update fte duplicate rule deletion failed\n");
775a2ebfbb7SYevgeny Kliteynik 	return ret;
776a2ebfbb7SYevgeny Kliteynik 
777a2ebfbb7SYevgeny Kliteynik restore_fte:
778a2ebfbb7SYevgeny Kliteynik 	fte->fs_dr_rule = fte_tmp.fs_dr_rule;
779a2ebfbb7SYevgeny Kliteynik 	return ret;
780a2ebfbb7SYevgeny Kliteynik }
781a2ebfbb7SYevgeny Kliteynik 
mlx5_cmd_dr_set_peer(struct mlx5_flow_root_namespace * ns,struct mlx5_flow_root_namespace * peer_ns,u16 peer_vhca_id)7826a48faeeSMaor Gottlieb static int mlx5_cmd_dr_set_peer(struct mlx5_flow_root_namespace *ns,
7836d5b7321SShay Drory 				struct mlx5_flow_root_namespace *peer_ns,
784*62752c0bSShay Drory 				u16 peer_vhca_id)
7856a48faeeSMaor Gottlieb {
7866a48faeeSMaor Gottlieb 	struct mlx5dr_domain *peer_domain = NULL;
7876a48faeeSMaor Gottlieb 
7886a48faeeSMaor Gottlieb 	if (peer_ns)
7896a48faeeSMaor Gottlieb 		peer_domain = peer_ns->fs_dr_domain.dr_domain;
7906a48faeeSMaor Gottlieb 	mlx5dr_domain_set_peer(ns->fs_dr_domain.dr_domain,
791*62752c0bSShay Drory 			       peer_domain, peer_vhca_id);
7926a48faeeSMaor Gottlieb 	return 0;
7936a48faeeSMaor Gottlieb }
7946a48faeeSMaor Gottlieb 
mlx5_cmd_dr_create_ns(struct mlx5_flow_root_namespace * ns)7956a48faeeSMaor Gottlieb static int mlx5_cmd_dr_create_ns(struct mlx5_flow_root_namespace *ns)
7966a48faeeSMaor Gottlieb {
7976a48faeeSMaor Gottlieb 	ns->fs_dr_domain.dr_domain =
7986a48faeeSMaor Gottlieb 		mlx5dr_domain_create(ns->dev,
7996a48faeeSMaor Gottlieb 				     MLX5DR_DOMAIN_TYPE_FDB);
8006a48faeeSMaor Gottlieb 	if (!ns->fs_dr_domain.dr_domain) {
8016a48faeeSMaor Gottlieb 		mlx5_core_err(ns->dev, "Failed to create dr flow namespace\n");
8026a48faeeSMaor Gottlieb 		return -EOPNOTSUPP;
8036a48faeeSMaor Gottlieb 	}
8046a48faeeSMaor Gottlieb 	return 0;
8056a48faeeSMaor Gottlieb }
8066a48faeeSMaor Gottlieb 
mlx5_cmd_dr_destroy_ns(struct mlx5_flow_root_namespace * ns)8076a48faeeSMaor Gottlieb static int mlx5_cmd_dr_destroy_ns(struct mlx5_flow_root_namespace *ns)
8086a48faeeSMaor Gottlieb {
8096a48faeeSMaor Gottlieb 	return mlx5dr_domain_destroy(ns->fs_dr_domain.dr_domain);
8106a48faeeSMaor Gottlieb }
8116a48faeeSMaor Gottlieb 
mlx5_cmd_dr_get_capabilities(struct mlx5_flow_root_namespace * ns,enum fs_flow_table_type ft_type)8128348b71cSDima Chumak static u32 mlx5_cmd_dr_get_capabilities(struct mlx5_flow_root_namespace *ns,
8138348b71cSDima Chumak 					enum fs_flow_table_type ft_type)
8148348b71cSDima Chumak {
815be6d5daeSYevgeny Kliteynik 	u32 steering_caps = 0;
816be6d5daeSYevgeny Kliteynik 
8178348b71cSDima Chumak 	if (ft_type != FS_FT_FDB ||
8186862c787SYevgeny Kliteynik 	    MLX5_CAP_GEN(ns->dev, steering_format_version) == MLX5_STEERING_FORMAT_CONNECTX_5)
8198348b71cSDima Chumak 		return 0;
8208348b71cSDima Chumak 
821be6d5daeSYevgeny Kliteynik 	steering_caps |= MLX5_FLOW_STEERING_CAP_VLAN_PUSH_ON_RX;
822be6d5daeSYevgeny Kliteynik 	steering_caps |= MLX5_FLOW_STEERING_CAP_VLAN_POP_ON_TX;
823be6d5daeSYevgeny Kliteynik 
824be6d5daeSYevgeny Kliteynik 	if (mlx5dr_supp_match_ranges(ns->dev))
825be6d5daeSYevgeny Kliteynik 		steering_caps |= MLX5_FLOW_STEERING_CAP_MATCH_RANGES;
826be6d5daeSYevgeny Kliteynik 
827be6d5daeSYevgeny Kliteynik 	return steering_caps;
8288348b71cSDima Chumak }
8298348b71cSDima Chumak 
mlx5_fs_dr_action_get_pkt_reformat_id(struct mlx5_pkt_reformat * pkt_reformat)83087cd0649SYevgeny Kliteynik int mlx5_fs_dr_action_get_pkt_reformat_id(struct mlx5_pkt_reformat *pkt_reformat)
83187cd0649SYevgeny Kliteynik {
83287cd0649SYevgeny Kliteynik 	switch (pkt_reformat->reformat_type) {
83387cd0649SYevgeny Kliteynik 	case MLX5_REFORMAT_TYPE_L2_TO_VXLAN:
83487cd0649SYevgeny Kliteynik 	case MLX5_REFORMAT_TYPE_L2_TO_NVGRE:
83587cd0649SYevgeny Kliteynik 	case MLX5_REFORMAT_TYPE_L2_TO_L2_TUNNEL:
83687cd0649SYevgeny Kliteynik 	case MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL:
83787cd0649SYevgeny Kliteynik 	case MLX5_REFORMAT_TYPE_INSERT_HDR:
83887cd0649SYevgeny Kliteynik 		return mlx5dr_action_get_pkt_reformat_id(pkt_reformat->action.dr_action);
83987cd0649SYevgeny Kliteynik 	}
84087cd0649SYevgeny Kliteynik 	return -EOPNOTSUPP;
84187cd0649SYevgeny Kliteynik }
84287cd0649SYevgeny Kliteynik 
mlx5_fs_dr_is_supported(struct mlx5_core_dev * dev)8436a48faeeSMaor Gottlieb bool mlx5_fs_dr_is_supported(struct mlx5_core_dev *dev)
8446a48faeeSMaor Gottlieb {
8456a48faeeSMaor Gottlieb 	return mlx5dr_is_supported(dev);
8466a48faeeSMaor Gottlieb }
8476a48faeeSMaor Gottlieb 
8486a48faeeSMaor Gottlieb static const struct mlx5_flow_cmds mlx5_flow_cmds_dr = {
8496a48faeeSMaor Gottlieb 	.create_flow_table = mlx5_cmd_dr_create_flow_table,
8506a48faeeSMaor Gottlieb 	.destroy_flow_table = mlx5_cmd_dr_destroy_flow_table,
8516a48faeeSMaor Gottlieb 	.modify_flow_table = mlx5_cmd_dr_modify_flow_table,
8526a48faeeSMaor Gottlieb 	.create_flow_group = mlx5_cmd_dr_create_flow_group,
8536a48faeeSMaor Gottlieb 	.destroy_flow_group = mlx5_cmd_dr_destroy_flow_group,
8546a48faeeSMaor Gottlieb 	.create_fte = mlx5_cmd_dr_create_fte,
8556a48faeeSMaor Gottlieb 	.update_fte = mlx5_cmd_dr_update_fte,
8566a48faeeSMaor Gottlieb 	.delete_fte = mlx5_cmd_dr_delete_fte,
8576a48faeeSMaor Gottlieb 	.update_root_ft = mlx5_cmd_dr_update_root_ft,
8586a48faeeSMaor Gottlieb 	.packet_reformat_alloc = mlx5_cmd_dr_packet_reformat_alloc,
8596a48faeeSMaor Gottlieb 	.packet_reformat_dealloc = mlx5_cmd_dr_packet_reformat_dealloc,
8606a48faeeSMaor Gottlieb 	.modify_header_alloc = mlx5_cmd_dr_modify_header_alloc,
8616a48faeeSMaor Gottlieb 	.modify_header_dealloc = mlx5_cmd_dr_modify_header_dealloc,
862e7e2519eSMaor Gottlieb 	.create_match_definer = mlx5_cmd_dr_create_match_definer,
863e7e2519eSMaor Gottlieb 	.destroy_match_definer = mlx5_cmd_dr_destroy_match_definer,
8646a48faeeSMaor Gottlieb 	.set_peer = mlx5_cmd_dr_set_peer,
8656a48faeeSMaor Gottlieb 	.create_ns = mlx5_cmd_dr_create_ns,
8666a48faeeSMaor Gottlieb 	.destroy_ns = mlx5_cmd_dr_destroy_ns,
8678348b71cSDima Chumak 	.get_capabilities = mlx5_cmd_dr_get_capabilities,
8686a48faeeSMaor Gottlieb };
8696a48faeeSMaor Gottlieb 
mlx5_fs_cmd_get_dr_cmds(void)8706a48faeeSMaor Gottlieb const struct mlx5_flow_cmds *mlx5_fs_cmd_get_dr_cmds(void)
8716a48faeeSMaor Gottlieb {
8726a48faeeSMaor Gottlieb 		return &mlx5_flow_cmds_dr;
8736a48faeeSMaor Gottlieb }
874