Commit af76c501 authored by Matan Barak's avatar Matan Barak Committed by Saeed Mahameed

net/mlx5: Add shim layer between fs and cmd

The shim layer allows each namespace to define possibly different
functionality for add/delete/update commands. The shim layer
introduced here, will be used to support flow steering with the FPGA.
Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
Signed-off-by: default avatarAviad Yehezkel <aviadye@mellanox.com>
Signed-off-by: default avatarBoris Pismenny <borisp@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent a9db0ecf
...@@ -39,7 +39,79 @@ ...@@ -39,7 +39,79 @@
#include "mlx5_core.h" #include "mlx5_core.h"
#include "eswitch.h" #include "eswitch.h"
int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev, static int mlx5_cmd_stub_update_root_ft(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft,
u32 underlay_qpn,
bool disconnect)
{
return 0;
}
static int mlx5_cmd_stub_create_flow_table(struct mlx5_core_dev *dev,
u16 vport,
enum fs_flow_table_op_mod op_mod,
enum fs_flow_table_type type,
unsigned int level,
unsigned int log_size,
struct mlx5_flow_table *next_ft,
unsigned int *table_id, u32 flags)
{
return 0;
}
static int mlx5_cmd_stub_destroy_flow_table(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft)
{
return 0;
}
static int mlx5_cmd_stub_modify_flow_table(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft,
struct mlx5_flow_table *next_ft)
{
return 0;
}
static int mlx5_cmd_stub_create_flow_group(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft,
u32 *in,
unsigned int *group_id)
{
return 0;
}
static int mlx5_cmd_stub_destroy_flow_group(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft,
unsigned int group_id)
{
return 0;
}
static int mlx5_cmd_stub_create_fte(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft,
struct mlx5_flow_group *group,
struct fs_fte *fte)
{
return 0;
}
static int mlx5_cmd_stub_update_fte(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft,
unsigned int group_id,
int modify_mask,
struct fs_fte *fte)
{
return -EOPNOTSUPP;
}
static int mlx5_cmd_stub_delete_fte(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft,
unsigned int index)
{
return 0;
}
static int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, u32 underlay_qpn, struct mlx5_flow_table *ft, u32 underlay_qpn,
bool disconnect) bool disconnect)
{ {
...@@ -71,12 +143,14 @@ int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev, ...@@ -71,12 +143,14 @@ int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev,
return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
} }
int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev, static int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev,
u16 vport, u16 vport,
enum fs_flow_table_op_mod op_mod, enum fs_flow_table_op_mod op_mod,
enum fs_flow_table_type type, unsigned int level, enum fs_flow_table_type type,
unsigned int log_size, struct mlx5_flow_table unsigned int level,
*next_ft, unsigned int *table_id, u32 flags) unsigned int log_size,
struct mlx5_flow_table *next_ft,
unsigned int *table_id, u32 flags)
{ {
int en_encap_decap = !!(flags & MLX5_FLOW_TABLE_TUNNEL_EN); int en_encap_decap = !!(flags & MLX5_FLOW_TABLE_TUNNEL_EN);
u32 out[MLX5_ST_SZ_DW(create_flow_table_out)] = {0}; u32 out[MLX5_ST_SZ_DW(create_flow_table_out)] = {0};
...@@ -125,7 +199,7 @@ int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev, ...@@ -125,7 +199,7 @@ int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev,
return err; return err;
} }
int mlx5_cmd_destroy_flow_table(struct mlx5_core_dev *dev, static int mlx5_cmd_destroy_flow_table(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft) struct mlx5_flow_table *ft)
{ {
u32 in[MLX5_ST_SZ_DW(destroy_flow_table_in)] = {0}; u32 in[MLX5_ST_SZ_DW(destroy_flow_table_in)] = {0};
...@@ -143,7 +217,7 @@ int mlx5_cmd_destroy_flow_table(struct mlx5_core_dev *dev, ...@@ -143,7 +217,7 @@ int mlx5_cmd_destroy_flow_table(struct mlx5_core_dev *dev,
return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
} }
int mlx5_cmd_modify_flow_table(struct mlx5_core_dev *dev, static int mlx5_cmd_modify_flow_table(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, struct mlx5_flow_table *ft,
struct mlx5_flow_table *next_ft) struct mlx5_flow_table *next_ft)
{ {
...@@ -188,7 +262,7 @@ int mlx5_cmd_modify_flow_table(struct mlx5_core_dev *dev, ...@@ -188,7 +262,7 @@ int mlx5_cmd_modify_flow_table(struct mlx5_core_dev *dev,
return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
} }
int mlx5_cmd_create_flow_group(struct mlx5_core_dev *dev, static int mlx5_cmd_create_flow_group(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, struct mlx5_flow_table *ft,
u32 *in, u32 *in,
unsigned int *group_id) unsigned int *group_id)
...@@ -213,7 +287,7 @@ int mlx5_cmd_create_flow_group(struct mlx5_core_dev *dev, ...@@ -213,7 +287,7 @@ int mlx5_cmd_create_flow_group(struct mlx5_core_dev *dev,
return err; return err;
} }
int mlx5_cmd_destroy_flow_group(struct mlx5_core_dev *dev, static int mlx5_cmd_destroy_flow_group(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, struct mlx5_flow_table *ft,
unsigned int group_id) unsigned int group_id)
{ {
...@@ -332,17 +406,19 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev, ...@@ -332,17 +406,19 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
return err; return err;
} }
int mlx5_cmd_create_fte(struct mlx5_core_dev *dev, static int mlx5_cmd_create_fte(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, struct mlx5_flow_table *ft,
unsigned group_id, struct mlx5_flow_group *group,
struct fs_fte *fte) struct fs_fte *fte)
{ {
unsigned int group_id = group->id;
return mlx5_cmd_set_fte(dev, 0, 0, ft, group_id, fte); return mlx5_cmd_set_fte(dev, 0, 0, ft, group_id, fte);
} }
int mlx5_cmd_update_fte(struct mlx5_core_dev *dev, static int mlx5_cmd_update_fte(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, struct mlx5_flow_table *ft,
unsigned group_id, unsigned int group_id,
int modify_mask, int modify_mask,
struct fs_fte *fte) struct fs_fte *fte)
{ {
...@@ -357,7 +433,7 @@ int mlx5_cmd_update_fte(struct mlx5_core_dev *dev, ...@@ -357,7 +433,7 @@ int mlx5_cmd_update_fte(struct mlx5_core_dev *dev,
return mlx5_cmd_set_fte(dev, opmod, modify_mask, ft, group_id, fte); return mlx5_cmd_set_fte(dev, opmod, modify_mask, ft, group_id, fte);
} }
int mlx5_cmd_delete_fte(struct mlx5_core_dev *dev, static int mlx5_cmd_delete_fte(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, struct mlx5_flow_table *ft,
unsigned int index) unsigned int index)
{ {
...@@ -610,3 +686,52 @@ void mlx5_modify_header_dealloc(struct mlx5_core_dev *dev, u32 modify_header_id) ...@@ -610,3 +686,52 @@ void mlx5_modify_header_dealloc(struct mlx5_core_dev *dev, u32 modify_header_id)
mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
} }
static const struct mlx5_flow_cmds mlx5_flow_cmds = {
.create_flow_table = mlx5_cmd_create_flow_table,
.destroy_flow_table = mlx5_cmd_destroy_flow_table,
.modify_flow_table = mlx5_cmd_modify_flow_table,
.create_flow_group = mlx5_cmd_create_flow_group,
.destroy_flow_group = mlx5_cmd_destroy_flow_group,
.create_fte = mlx5_cmd_create_fte,
.update_fte = mlx5_cmd_update_fte,
.delete_fte = mlx5_cmd_delete_fte,
.update_root_ft = mlx5_cmd_update_root_ft,
};
static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = {
.create_flow_table = mlx5_cmd_stub_create_flow_table,
.destroy_flow_table = mlx5_cmd_stub_destroy_flow_table,
.modify_flow_table = mlx5_cmd_stub_modify_flow_table,
.create_flow_group = mlx5_cmd_stub_create_flow_group,
.destroy_flow_group = mlx5_cmd_stub_destroy_flow_group,
.create_fte = mlx5_cmd_stub_create_fte,
.update_fte = mlx5_cmd_stub_update_fte,
.delete_fte = mlx5_cmd_stub_delete_fte,
.update_root_ft = mlx5_cmd_stub_update_root_ft,
};
static const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void)
{
return &mlx5_flow_cmds;
}
static const struct mlx5_flow_cmds *mlx5_fs_cmd_get_stub_cmds(void)
{
return &mlx5_flow_cmd_stubs;
}
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_default(enum fs_flow_table_type type)
{
switch (type) {
case FS_FT_NIC_RX:
case FS_FT_ESW_EGRESS_ACL:
case FS_FT_ESW_INGRESS_ACL:
case FS_FT_FDB:
case FS_FT_SNIFFER_RX:
case FS_FT_SNIFFER_TX:
return mlx5_fs_cmd_get_fw_cmds();
default:
return mlx5_fs_cmd_get_stub_cmds();
}
}
...@@ -33,46 +33,52 @@ ...@@ -33,46 +33,52 @@
#ifndef _MLX5_FS_CMD_ #ifndef _MLX5_FS_CMD_
#define _MLX5_FS_CMD_ #define _MLX5_FS_CMD_
int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev, #include "fs_core.h"
struct mlx5_flow_cmds {
int (*create_flow_table)(struct mlx5_core_dev *dev,
u16 vport, u16 vport,
enum fs_flow_table_op_mod op_mod, enum fs_flow_table_op_mod op_mod,
enum fs_flow_table_type type, unsigned int level, enum fs_flow_table_type type,
unsigned int log_size, struct mlx5_flow_table unsigned int level, unsigned int log_size,
*next_ft, unsigned int *table_id, u32 flags); struct mlx5_flow_table *next_ft,
unsigned int *table_id, u32 flags);
int mlx5_cmd_destroy_flow_table(struct mlx5_core_dev *dev, int (*destroy_flow_table)(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft); struct mlx5_flow_table *ft);
int mlx5_cmd_modify_flow_table(struct mlx5_core_dev *dev, int (*modify_flow_table)(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, struct mlx5_flow_table *ft,
struct mlx5_flow_table *next_ft); struct mlx5_flow_table *next_ft);
int mlx5_cmd_create_flow_group(struct mlx5_core_dev *dev, int (*create_flow_group)(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, struct mlx5_flow_table *ft,
u32 *in, unsigned int *group_id); u32 *in,
unsigned int *group_id);
int mlx5_cmd_destroy_flow_group(struct mlx5_core_dev *dev, int (*destroy_flow_group)(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, struct mlx5_flow_table *ft,
unsigned int group_id); unsigned int group_id);
int mlx5_cmd_create_fte(struct mlx5_core_dev *dev, int (*create_fte)(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, struct mlx5_flow_table *ft,
unsigned group_id, struct mlx5_flow_group *fg,
struct fs_fte *fte); struct fs_fte *fte);
int mlx5_cmd_update_fte(struct mlx5_core_dev *dev, int (*update_fte)(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, struct mlx5_flow_table *ft,
unsigned group_id, unsigned int group_id,
int modify_mask, int modify_mask,
struct fs_fte *fte); struct fs_fte *fte);
int mlx5_cmd_delete_fte(struct mlx5_core_dev *dev, int (*delete_fte)(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, struct mlx5_flow_table *ft,
unsigned int index); unsigned int index);
int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev, int (*update_root_ft)(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, u32 underlay_qpn, struct mlx5_flow_table *ft,
u32 underlay_qpn,
bool disconnect); bool disconnect);
};
int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id); int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id);
int mlx5_cmd_fc_free(struct mlx5_core_dev *dev, u32 id); int mlx5_cmd_fc_free(struct mlx5_core_dev *dev, u32 id);
...@@ -90,4 +96,6 @@ void mlx5_cmd_fc_bulk_get(struct mlx5_core_dev *dev, ...@@ -90,4 +96,6 @@ void mlx5_cmd_fc_bulk_get(struct mlx5_core_dev *dev,
struct mlx5_cmd_fc_bulk *b, u32 id, struct mlx5_cmd_fc_bulk *b, u32 id,
u64 *packets, u64 *bytes); u64 *packets, u64 *bytes);
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_default(enum fs_flow_table_type type);
#endif #endif
...@@ -425,15 +425,17 @@ static void del_sw_prio(struct fs_node *node) ...@@ -425,15 +425,17 @@ static void del_sw_prio(struct fs_node *node)
static void del_hw_flow_table(struct fs_node *node) static void del_hw_flow_table(struct fs_node *node)
{ {
struct mlx5_flow_root_namespace *root;
struct mlx5_flow_table *ft; struct mlx5_flow_table *ft;
struct mlx5_core_dev *dev; struct mlx5_core_dev *dev;
int err; int err;
fs_get_obj(ft, node); fs_get_obj(ft, node);
dev = get_dev(&ft->node); dev = get_dev(&ft->node);
root = find_root(&ft->node);
if (node->active) { if (node->active) {
err = mlx5_cmd_destroy_flow_table(dev, ft); err = root->cmds->destroy_flow_table(dev, ft);
if (err) if (err)
mlx5_core_warn(dev, "flow steering can't destroy ft\n"); mlx5_core_warn(dev, "flow steering can't destroy ft\n");
} }
...@@ -454,6 +456,7 @@ static void del_sw_flow_table(struct fs_node *node) ...@@ -454,6 +456,7 @@ static void del_sw_flow_table(struct fs_node *node)
static void del_sw_hw_rule(struct fs_node *node) static void del_sw_hw_rule(struct fs_node *node)
{ {
struct mlx5_flow_root_namespace *root;
struct mlx5_flow_rule *rule; struct mlx5_flow_rule *rule;
struct mlx5_flow_table *ft; struct mlx5_flow_table *ft;
struct mlx5_flow_group *fg; struct mlx5_flow_group *fg;
...@@ -488,8 +491,9 @@ static void del_sw_hw_rule(struct fs_node *node) ...@@ -488,8 +491,9 @@ static void del_sw_hw_rule(struct fs_node *node)
update_fte = true; update_fte = true;
} }
out: out:
root = find_root(&ft->node);
if (update_fte && fte->dests_size) { if (update_fte && fte->dests_size) {
err = mlx5_cmd_update_fte(dev, ft, fg->id, modify_mask, fte); err = root->cmds->update_fte(dev, ft, fg->id, modify_mask, fte);
if (err) if (err)
mlx5_core_warn(dev, mlx5_core_warn(dev,
"%s can't del rule fg id=%d fte_index=%d\n", "%s can't del rule fg id=%d fte_index=%d\n",
...@@ -500,6 +504,7 @@ static void del_sw_hw_rule(struct fs_node *node) ...@@ -500,6 +504,7 @@ static void del_sw_hw_rule(struct fs_node *node)
static void del_hw_fte(struct fs_node *node) static void del_hw_fte(struct fs_node *node)
{ {
struct mlx5_flow_root_namespace *root;
struct mlx5_flow_table *ft; struct mlx5_flow_table *ft;
struct mlx5_flow_group *fg; struct mlx5_flow_group *fg;
struct mlx5_core_dev *dev; struct mlx5_core_dev *dev;
...@@ -512,9 +517,9 @@ static void del_hw_fte(struct fs_node *node) ...@@ -512,9 +517,9 @@ static void del_hw_fte(struct fs_node *node)
trace_mlx5_fs_del_fte(fte); trace_mlx5_fs_del_fte(fte);
dev = get_dev(&ft->node); dev = get_dev(&ft->node);
root = find_root(&ft->node);
if (node->active) { if (node->active) {
err = mlx5_cmd_delete_fte(dev, ft, err = root->cmds->delete_fte(dev, ft, fte->index);
fte->index);
if (err) if (err)
mlx5_core_warn(dev, mlx5_core_warn(dev,
"flow steering can't delete fte in index %d of flow group id %d\n", "flow steering can't delete fte in index %d of flow group id %d\n",
...@@ -542,6 +547,7 @@ static void del_sw_fte(struct fs_node *node) ...@@ -542,6 +547,7 @@ static void del_sw_fte(struct fs_node *node)
static void del_hw_flow_group(struct fs_node *node) static void del_hw_flow_group(struct fs_node *node)
{ {
struct mlx5_flow_root_namespace *root;
struct mlx5_flow_group *fg; struct mlx5_flow_group *fg;
struct mlx5_flow_table *ft; struct mlx5_flow_table *ft;
struct mlx5_core_dev *dev; struct mlx5_core_dev *dev;
...@@ -551,7 +557,8 @@ static void del_hw_flow_group(struct fs_node *node) ...@@ -551,7 +557,8 @@ static void del_hw_flow_group(struct fs_node *node)
dev = get_dev(&ft->node); dev = get_dev(&ft->node);
trace_mlx5_fs_del_fg(fg); trace_mlx5_fs_del_fg(fg);
if (fg->node.active && mlx5_cmd_destroy_flow_group(dev, ft, fg->id)) root = find_root(&ft->node);
if (fg->node.active && root->cmds->destroy_flow_group(dev, ft, fg->id))
mlx5_core_warn(dev, "flow steering can't destroy fg %d of ft %d\n", mlx5_core_warn(dev, "flow steering can't destroy fg %d of ft %d\n",
fg->id, ft->id); fg->id, ft->id);
} }
...@@ -797,15 +804,14 @@ static int connect_fts_in_prio(struct mlx5_core_dev *dev, ...@@ -797,15 +804,14 @@ static int connect_fts_in_prio(struct mlx5_core_dev *dev,
struct fs_prio *prio, struct fs_prio *prio,
struct mlx5_flow_table *ft) struct mlx5_flow_table *ft)
{ {
struct mlx5_flow_root_namespace *root = find_root(&prio->node);
struct mlx5_flow_table *iter; struct mlx5_flow_table *iter;
int i = 0; int i = 0;
int err; int err;
fs_for_each_ft(iter, prio) { fs_for_each_ft(iter, prio) {
i++; i++;
err = mlx5_cmd_modify_flow_table(dev, err = root->cmds->modify_flow_table(dev, iter, ft);
iter,
ft);
if (err) { if (err) {
mlx5_core_warn(dev, "Failed to modify flow table %d\n", mlx5_core_warn(dev, "Failed to modify flow table %d\n",
iter->id); iter->id);
...@@ -853,12 +859,12 @@ static int update_root_ft_create(struct mlx5_flow_table *ft, struct fs_prio ...@@ -853,12 +859,12 @@ static int update_root_ft_create(struct mlx5_flow_table *ft, struct fs_prio
if (list_empty(&root->underlay_qpns)) { if (list_empty(&root->underlay_qpns)) {
/* Don't set any QPN (zero) in case QPN list is empty */ /* Don't set any QPN (zero) in case QPN list is empty */
qpn = 0; qpn = 0;
err = mlx5_cmd_update_root_ft(root->dev, ft, qpn, false); err = root->cmds->update_root_ft(root->dev, ft, qpn, false);
} else { } else {
list_for_each_entry(uqp, &root->underlay_qpns, list) { list_for_each_entry(uqp, &root->underlay_qpns, list) {
qpn = uqp->qpn; qpn = uqp->qpn;
err = mlx5_cmd_update_root_ft(root->dev, ft, qpn, err = root->cmds->update_root_ft(root->dev, ft,
false); qpn, false);
if (err) if (err)
break; break;
} }
...@@ -877,6 +883,7 @@ static int update_root_ft_create(struct mlx5_flow_table *ft, struct fs_prio ...@@ -877,6 +883,7 @@ static int update_root_ft_create(struct mlx5_flow_table *ft, struct fs_prio
static int _mlx5_modify_rule_destination(struct mlx5_flow_rule *rule, static int _mlx5_modify_rule_destination(struct mlx5_flow_rule *rule,
struct mlx5_flow_destination *dest) struct mlx5_flow_destination *dest)
{ {
struct mlx5_flow_root_namespace *root;
struct mlx5_flow_table *ft; struct mlx5_flow_table *ft;
struct mlx5_flow_group *fg; struct mlx5_flow_group *fg;
struct fs_fte *fte; struct fs_fte *fte;
...@@ -891,10 +898,9 @@ static int _mlx5_modify_rule_destination(struct mlx5_flow_rule *rule, ...@@ -891,10 +898,9 @@ static int _mlx5_modify_rule_destination(struct mlx5_flow_rule *rule,
fs_get_obj(ft, fg->node.parent); fs_get_obj(ft, fg->node.parent);
memcpy(&rule->dest_attr, dest, sizeof(*dest)); memcpy(&rule->dest_attr, dest, sizeof(*dest));
err = mlx5_cmd_update_fte(get_dev(&ft->node), root = find_root(&ft->node);
ft, fg->id, err = root->cmds->update_fte(get_dev(&ft->node), ft, fg->id,
modify_mask, modify_mask, fte);
fte);
up_write_ref_node(&fte->node); up_write_ref_node(&fte->node);
return err; return err;
...@@ -1035,9 +1041,9 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa ...@@ -1035,9 +1041,9 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa
tree_init_node(&ft->node, del_hw_flow_table, del_sw_flow_table); tree_init_node(&ft->node, del_hw_flow_table, del_sw_flow_table);
log_table_sz = ft->max_fte ? ilog2(ft->max_fte) : 0; log_table_sz = ft->max_fte ? ilog2(ft->max_fte) : 0;
next_ft = find_next_chained_ft(fs_prio); next_ft = find_next_chained_ft(fs_prio);
err = mlx5_cmd_create_flow_table(root->dev, ft->vport, ft->op_mod, ft->type, err = root->cmds->create_flow_table(root->dev, ft->vport, ft->op_mod,
ft->level, log_table_sz, next_ft, &ft->id, ft->type, ft->level, log_table_sz,
ft->flags); next_ft, &ft->id, ft->flags);
if (err) if (err)
goto free_ft; goto free_ft;
...@@ -1053,7 +1059,7 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa ...@@ -1053,7 +1059,7 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa
mutex_unlock(&root->chain_lock); mutex_unlock(&root->chain_lock);
return ft; return ft;
destroy_ft: destroy_ft:
mlx5_cmd_destroy_flow_table(root->dev, ft); root->cmds->destroy_flow_table(root->dev, ft);
free_ft: free_ft:
kfree(ft); kfree(ft);
unlock_root: unlock_root:
...@@ -1125,6 +1131,7 @@ EXPORT_SYMBOL(mlx5_create_auto_grouped_flow_table); ...@@ -1125,6 +1131,7 @@ EXPORT_SYMBOL(mlx5_create_auto_grouped_flow_table);
struct mlx5_flow_group *mlx5_create_flow_group(struct mlx5_flow_table *ft, struct mlx5_flow_group *mlx5_create_flow_group(struct mlx5_flow_table *ft,
u32 *fg_in) u32 *fg_in)
{ {
struct mlx5_flow_root_namespace *root = find_root(&ft->node);
void *match_criteria = MLX5_ADDR_OF(create_flow_group_in, void *match_criteria = MLX5_ADDR_OF(create_flow_group_in,
fg_in, match_criteria); fg_in, match_criteria);
u8 match_criteria_enable = MLX5_GET(create_flow_group_in, u8 match_criteria_enable = MLX5_GET(create_flow_group_in,
...@@ -1152,7 +1159,7 @@ struct mlx5_flow_group *mlx5_create_flow_group(struct mlx5_flow_table *ft, ...@@ -1152,7 +1159,7 @@ struct mlx5_flow_group *mlx5_create_flow_group(struct mlx5_flow_table *ft,
if (IS_ERR(fg)) if (IS_ERR(fg))
return fg; return fg;
err = mlx5_cmd_create_flow_group(dev, ft, fg_in, &fg->id); err = root->cmds->create_flow_group(dev, ft, fg_in, &fg->id);
if (err) { if (err) {
tree_put_node(&fg->node); tree_put_node(&fg->node);
return ERR_PTR(err); return ERR_PTR(err);
...@@ -1275,6 +1282,7 @@ add_rule_fte(struct fs_fte *fte, ...@@ -1275,6 +1282,7 @@ add_rule_fte(struct fs_fte *fte,
int dest_num, int dest_num,
bool update_action) bool update_action)
{ {
struct mlx5_flow_root_namespace *root;
struct mlx5_flow_handle *handle; struct mlx5_flow_handle *handle;
struct mlx5_flow_table *ft; struct mlx5_flow_table *ft;
int modify_mask = 0; int modify_mask = 0;
...@@ -1290,12 +1298,13 @@ add_rule_fte(struct fs_fte *fte, ...@@ -1290,12 +1298,13 @@ add_rule_fte(struct fs_fte *fte,
modify_mask |= BIT(MLX5_SET_FTE_MODIFY_ENABLE_MASK_ACTION); modify_mask |= BIT(MLX5_SET_FTE_MODIFY_ENABLE_MASK_ACTION);
fs_get_obj(ft, fg->node.parent); fs_get_obj(ft, fg->node.parent);
root = find_root(&fg->node);
if (!(fte->status & FS_FTE_STATUS_EXISTING)) if (!(fte->status & FS_FTE_STATUS_EXISTING))
err = mlx5_cmd_create_fte(get_dev(&ft->node), err = root->cmds->create_fte(get_dev(&ft->node),
ft, fg->id, fte); ft, fg, fte);
else else
err = mlx5_cmd_update_fte(get_dev(&ft->node), err = root->cmds->update_fte(get_dev(&ft->node), ft, fg->id,
ft, fg->id, modify_mask, fte); modify_mask, fte);
if (err) if (err)
goto free_handle; goto free_handle;
...@@ -1360,6 +1369,7 @@ static struct mlx5_flow_group *alloc_auto_flow_group(struct mlx5_flow_table *ft ...@@ -1360,6 +1369,7 @@ static struct mlx5_flow_group *alloc_auto_flow_group(struct mlx5_flow_table *ft
static int create_auto_flow_group(struct mlx5_flow_table *ft, static int create_auto_flow_group(struct mlx5_flow_table *ft,
struct mlx5_flow_group *fg) struct mlx5_flow_group *fg)
{ {
struct mlx5_flow_root_namespace *root = find_root(&ft->node);
struct mlx5_core_dev *dev = get_dev(&ft->node); struct mlx5_core_dev *dev = get_dev(&ft->node);
int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in); int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
void *match_criteria_addr; void *match_criteria_addr;
...@@ -1380,7 +1390,7 @@ static int create_auto_flow_group(struct mlx5_flow_table *ft, ...@@ -1380,7 +1390,7 @@ static int create_auto_flow_group(struct mlx5_flow_table *ft,
memcpy(match_criteria_addr, fg->mask.match_criteria, memcpy(match_criteria_addr, fg->mask.match_criteria,
sizeof(fg->mask.match_criteria)); sizeof(fg->mask.match_criteria));
err = mlx5_cmd_create_flow_group(dev, ft, in, &fg->id); err = root->cmds->create_flow_group(dev, ft, in, &fg->id);
if (!err) { if (!err) {
fg->node.active = true; fg->node.active = true;
trace_mlx5_fs_add_fg(fg); trace_mlx5_fs_add_fg(fg);
...@@ -1912,7 +1922,6 @@ static int update_root_ft_destroy(struct mlx5_flow_table *ft) ...@@ -1912,7 +1922,6 @@ static int update_root_ft_destroy(struct mlx5_flow_table *ft)
return 0; return 0;
new_root_ft = find_next_ft(ft); new_root_ft = find_next_ft(ft);
if (!new_root_ft) { if (!new_root_ft) {
root->root_ft = NULL; root->root_ft = NULL;
return 0; return 0;
...@@ -1921,13 +1930,14 @@ static int update_root_ft_destroy(struct mlx5_flow_table *ft) ...@@ -1921,13 +1930,14 @@ static int update_root_ft_destroy(struct mlx5_flow_table *ft)
if (list_empty(&root->underlay_qpns)) { if (list_empty(&root->underlay_qpns)) {
/* Don't set any QPN (zero) in case QPN list is empty */ /* Don't set any QPN (zero) in case QPN list is empty */
qpn = 0; qpn = 0;
err = mlx5_cmd_update_root_ft(root->dev, new_root_ft, qpn, err = root->cmds->update_root_ft(root->dev, new_root_ft,
false); qpn, false);
} else { } else {
list_for_each_entry(uqp, &root->underlay_qpns, list) { list_for_each_entry(uqp, &root->underlay_qpns, list) {
qpn = uqp->qpn; qpn = uqp->qpn;
err = mlx5_cmd_update_root_ft(root->dev, new_root_ft, err = root->cmds->update_root_ft(root->dev,
qpn, false); new_root_ft, qpn,
false);
if (err) if (err)
break; break;
} }
...@@ -2229,10 +2239,11 @@ static int init_root_tree(struct mlx5_flow_steering *steering, ...@@ -2229,10 +2239,11 @@ static int init_root_tree(struct mlx5_flow_steering *steering,
return 0; return 0;
} }
static struct mlx5_flow_root_namespace *create_root_ns(struct mlx5_flow_steering *steering, static struct mlx5_flow_root_namespace
enum fs_flow_table_type *create_root_ns(struct mlx5_flow_steering *steering,
table_type) enum fs_flow_table_type table_type)
{ {
const struct mlx5_flow_cmds *cmds = mlx5_fs_cmd_get_default(table_type);
struct mlx5_flow_root_namespace *root_ns; struct mlx5_flow_root_namespace *root_ns;
struct mlx5_flow_namespace *ns; struct mlx5_flow_namespace *ns;
...@@ -2243,6 +2254,7 @@ static struct mlx5_flow_root_namespace *create_root_ns(struct mlx5_flow_steering ...@@ -2243,6 +2254,7 @@ static struct mlx5_flow_root_namespace *create_root_ns(struct mlx5_flow_steering
root_ns->dev = steering->dev; root_ns->dev = steering->dev;
root_ns->table_type = table_type; root_ns->table_type = table_type;
root_ns->cmds = cmds;
INIT_LIST_HEAD(&root_ns->underlay_qpns); INIT_LIST_HEAD(&root_ns->underlay_qpns);
...@@ -2634,7 +2646,8 @@ int mlx5_fs_add_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn) ...@@ -2634,7 +2646,8 @@ int mlx5_fs_add_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn)
goto update_ft_fail; goto update_ft_fail;
} }
err = mlx5_cmd_update_root_ft(dev, root->root_ft, underlay_qpn, false); err = root->cmds->update_root_ft(dev, root->root_ft, underlay_qpn,
false);
if (err) { if (err) {
mlx5_core_warn(dev, "Failed adding underlay QPN (%u) to root FT err(%d)\n", mlx5_core_warn(dev, "Failed adding underlay QPN (%u) to root FT err(%d)\n",
underlay_qpn, err); underlay_qpn, err);
...@@ -2677,7 +2690,8 @@ int mlx5_fs_remove_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn) ...@@ -2677,7 +2690,8 @@ int mlx5_fs_remove_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn)
goto out; goto out;
} }
err = mlx5_cmd_update_root_ft(dev, root->root_ft, underlay_qpn, true); err = root->cmds->update_root_ft(dev, root->root_ft, underlay_qpn,
true);
if (err) if (err)
mlx5_core_warn(dev, "Failed removing underlay QPN (%u) from root FT err(%d)\n", mlx5_core_warn(dev, "Failed removing underlay QPN (%u) from root FT err(%d)\n",
underlay_qpn, err); underlay_qpn, err);
......
...@@ -224,6 +224,7 @@ struct mlx5_flow_root_namespace { ...@@ -224,6 +224,7 @@ struct mlx5_flow_root_namespace {
/* Should be held when chaining flow tables */ /* Should be held when chaining flow tables */
struct mutex chain_lock; struct mutex chain_lock;
struct list_head underlay_qpns; struct list_head underlay_qpns;
const struct mlx5_flow_cmds *cmds;
}; };
int mlx5_init_fc_stats(struct mlx5_core_dev *dev); int mlx5_init_fc_stats(struct mlx5_core_dev *dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment