Commit 5c2aa8ae authored by Mark Bloch's avatar Mark Bloch Committed by Saeed Mahameed

net/mlx5: Accept flow rules without match

Allow passing NULL spec when creating a flow rule. Such rules will act
as "catch all" flow rules.
Signed-off-by: default avatarMark Bloch <markb@mellanox.com>
Reviewed-by: default avatarMaor Gottlieb <maorg@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 4110fc59
...@@ -175,28 +175,20 @@ static int arfs_add_default_rule(struct mlx5e_priv *priv, ...@@ -175,28 +175,20 @@ static int arfs_add_default_rule(struct mlx5e_priv *priv,
struct mlx5e_tir *tir = priv->indir_tir; struct mlx5e_tir *tir = priv->indir_tir;
struct mlx5_flow_destination dest = {}; struct mlx5_flow_destination dest = {};
MLX5_DECLARE_FLOW_ACT(flow_act); MLX5_DECLARE_FLOW_ACT(flow_act);
struct mlx5_flow_spec *spec;
enum mlx5e_traffic_types tt; enum mlx5e_traffic_types tt;
int err = 0; int err = 0;
spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
if (!spec) {
err = -ENOMEM;
goto out;
}
dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR; dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR;
tt = arfs_get_tt(type); tt = arfs_get_tt(type);
if (tt == -EINVAL) { if (tt == -EINVAL) {
netdev_err(priv->netdev, "%s: bad arfs_type: %d\n", netdev_err(priv->netdev, "%s: bad arfs_type: %d\n",
__func__, type); __func__, type);
err = -EINVAL; return -EINVAL;
goto out;
} }
dest.tir_num = tir[tt].tirn; dest.tir_num = tir[tt].tirn;
arfs_t->default_rule = mlx5_add_flow_rules(arfs_t->ft.t, spec, arfs_t->default_rule = mlx5_add_flow_rules(arfs_t->ft.t, NULL,
&flow_act, &flow_act,
&dest, 1); &dest, 1);
if (IS_ERR(arfs_t->default_rule)) { if (IS_ERR(arfs_t->default_rule)) {
...@@ -205,8 +197,7 @@ static int arfs_add_default_rule(struct mlx5e_priv *priv, ...@@ -205,8 +197,7 @@ static int arfs_add_default_rule(struct mlx5e_priv *priv,
netdev_err(priv->netdev, "%s: add rule failed, arfs type=%d\n", netdev_err(priv->netdev, "%s: add rule failed, arfs type=%d\n",
__func__, type); __func__, type);
} }
out:
kvfree(spec);
return err; return err;
} }
......
...@@ -1334,7 +1334,6 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw, ...@@ -1334,7 +1334,6 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw,
goto out; goto out;
} }
memset(spec, 0, sizeof(*spec));
flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP; flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP;
/* Attach drop flow counter */ /* Attach drop flow counter */
...@@ -1346,7 +1345,7 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw, ...@@ -1346,7 +1345,7 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw,
dest_num++; dest_num++;
} }
vport->ingress.legacy.drop_rule = vport->ingress.legacy.drop_rule =
mlx5_add_flow_rules(vport->ingress.acl, spec, mlx5_add_flow_rules(vport->ingress.acl, NULL,
&flow_act, dst, dest_num); &flow_act, dst, dest_num);
if (IS_ERR(vport->ingress.legacy.drop_rule)) { if (IS_ERR(vport->ingress.legacy.drop_rule)) {
err = PTR_ERR(vport->ingress.legacy.drop_rule); err = PTR_ERR(vport->ingress.legacy.drop_rule);
...@@ -1409,7 +1408,6 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw, ...@@ -1409,7 +1408,6 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw,
struct mlx5_flow_destination drop_ctr_dst = {0}; struct mlx5_flow_destination drop_ctr_dst = {0};
struct mlx5_flow_destination *dst = NULL; struct mlx5_flow_destination *dst = NULL;
struct mlx5_flow_act flow_act = {0}; struct mlx5_flow_act flow_act = {0};
struct mlx5_flow_spec *spec;
int dest_num = 0; int dest_num = 0;
int err = 0; int err = 0;
...@@ -1438,11 +1436,6 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw, ...@@ -1438,11 +1436,6 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw,
if (err) if (err)
return err; return err;
/* Drop others rule (star rule) */
spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
if (!spec)
goto out;
flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP; flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP;
/* Attach egress drop flow counter */ /* Attach egress drop flow counter */
...@@ -1454,7 +1447,7 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw, ...@@ -1454,7 +1447,7 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw,
dest_num++; dest_num++;
} }
vport->egress.legacy.drop_rule = vport->egress.legacy.drop_rule =
mlx5_add_flow_rules(vport->egress.acl, spec, mlx5_add_flow_rules(vport->egress.acl, NULL,
&flow_act, dst, dest_num); &flow_act, dst, dest_num);
if (IS_ERR(vport->egress.legacy.drop_rule)) { if (IS_ERR(vport->egress.legacy.drop_rule)) {
err = PTR_ERR(vport->egress.legacy.drop_rule); err = PTR_ERR(vport->egress.legacy.drop_rule);
...@@ -1463,8 +1456,7 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw, ...@@ -1463,8 +1456,7 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw,
vport->vport, err); vport->vport, err);
vport->egress.legacy.drop_rule = NULL; vport->egress.legacy.drop_rule = NULL;
} }
out:
kvfree(spec);
return err; return err;
} }
...@@ -2481,12 +2473,11 @@ static int _mlx5_eswitch_set_vepa_locked(struct mlx5_eswitch *esw, ...@@ -2481,12 +2473,11 @@ static int _mlx5_eswitch_set_vepa_locked(struct mlx5_eswitch *esw,
} }
/* Star rule to forward all traffic to uplink vport */ /* Star rule to forward all traffic to uplink vport */
memset(spec, 0, sizeof(*spec));
memset(&dest, 0, sizeof(dest)); memset(&dest, 0, sizeof(dest));
dest.type = MLX5_FLOW_DESTINATION_TYPE_VPORT; dest.type = MLX5_FLOW_DESTINATION_TYPE_VPORT;
dest.vport.num = MLX5_VPORT_UPLINK; dest.vport.num = MLX5_VPORT_UPLINK;
flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
flow_rule = mlx5_add_flow_rules(esw->fdb_table.legacy.vepa_fdb, spec, flow_rule = mlx5_add_flow_rules(esw->fdb_table.legacy.vepa_fdb, NULL,
&flow_act, &dest, 1); &flow_act, &dest, 1);
if (IS_ERR(flow_rule)) { if (IS_ERR(flow_rule)) {
err = PTR_ERR(flow_rule); err = PTR_ERR(flow_rule);
......
...@@ -1881,7 +1881,6 @@ static int esw_vport_add_ingress_acl_modify_metadata(struct mlx5_eswitch *esw, ...@@ -1881,7 +1881,6 @@ static int esw_vport_add_ingress_acl_modify_metadata(struct mlx5_eswitch *esw,
struct mlx5_vport *vport) struct mlx5_vport *vport)
{ {
u8 action[MLX5_UN_SZ_BYTES(set_action_in_add_action_in_auto)] = {}; u8 action[MLX5_UN_SZ_BYTES(set_action_in_add_action_in_auto)] = {};
static const struct mlx5_flow_spec spec = {};
struct mlx5_flow_act flow_act = {}; struct mlx5_flow_act flow_act = {};
int err = 0; int err = 0;
u32 key; u32 key;
...@@ -1913,7 +1912,7 @@ static int esw_vport_add_ingress_acl_modify_metadata(struct mlx5_eswitch *esw, ...@@ -1913,7 +1912,7 @@ static int esw_vport_add_ingress_acl_modify_metadata(struct mlx5_eswitch *esw,
flow_act.modify_hdr = vport->ingress.offloads.modify_metadata; flow_act.modify_hdr = vport->ingress.offloads.modify_metadata;
vport->ingress.offloads.modify_metadata_rule = vport->ingress.offloads.modify_metadata_rule =
mlx5_add_flow_rules(vport->ingress.acl, mlx5_add_flow_rules(vport->ingress.acl,
&spec, &flow_act, NULL, 0); NULL, &flow_act, NULL, 0);
if (IS_ERR(vport->ingress.offloads.modify_metadata_rule)) { if (IS_ERR(vport->ingress.offloads.modify_metadata_rule)) {
err = PTR_ERR(vport->ingress.offloads.modify_metadata_rule); err = PTR_ERR(vport->ingress.offloads.modify_metadata_rule);
esw_warn(esw->dev, esw_warn(esw->dev,
......
...@@ -410,7 +410,6 @@ mlx5_esw_chains_add_miss_rule(struct fdb_chain *fdb_chain, ...@@ -410,7 +410,6 @@ mlx5_esw_chains_add_miss_rule(struct fdb_chain *fdb_chain,
struct mlx5_flow_table *fdb, struct mlx5_flow_table *fdb,
struct mlx5_flow_table *next_fdb) struct mlx5_flow_table *next_fdb)
{ {
static const struct mlx5_flow_spec spec = {};
struct mlx5_eswitch *esw = fdb_chain->esw; struct mlx5_eswitch *esw = fdb_chain->esw;
struct mlx5_flow_destination dest = {}; struct mlx5_flow_destination dest = {};
struct mlx5_flow_act act = {}; struct mlx5_flow_act act = {};
...@@ -425,7 +424,7 @@ mlx5_esw_chains_add_miss_rule(struct fdb_chain *fdb_chain, ...@@ -425,7 +424,7 @@ mlx5_esw_chains_add_miss_rule(struct fdb_chain *fdb_chain,
act.action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; act.action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
} }
return mlx5_add_flow_rules(fdb, &spec, &act, &dest, 1); return mlx5_add_flow_rules(fdb, NULL, &act, &dest, 1);
} }
static int static int
......
...@@ -49,7 +49,6 @@ mlx5_eswitch_termtbl_create(struct mlx5_core_dev *dev, ...@@ -49,7 +49,6 @@ mlx5_eswitch_termtbl_create(struct mlx5_core_dev *dev,
struct mlx5_termtbl_handle *tt, struct mlx5_termtbl_handle *tt,
struct mlx5_flow_act *flow_act) struct mlx5_flow_act *flow_act)
{ {
static const struct mlx5_flow_spec spec = {};
struct mlx5_flow_table_attr ft_attr = {}; struct mlx5_flow_table_attr ft_attr = {};
struct mlx5_flow_namespace *root_ns; struct mlx5_flow_namespace *root_ns;
int err; int err;
...@@ -73,7 +72,7 @@ mlx5_eswitch_termtbl_create(struct mlx5_core_dev *dev, ...@@ -73,7 +72,7 @@ mlx5_eswitch_termtbl_create(struct mlx5_core_dev *dev,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
tt->rule = mlx5_add_flow_rules(tt->termtbl, &spec, flow_act, tt->rule = mlx5_add_flow_rules(tt->termtbl, NULL, flow_act,
&tt->dest, 1); &tt->dest, 1);
if (IS_ERR(tt->rule)) { if (IS_ERR(tt->rule)) {
......
...@@ -1892,12 +1892,16 @@ mlx5_add_flow_rules(struct mlx5_flow_table *ft, ...@@ -1892,12 +1892,16 @@ mlx5_add_flow_rules(struct mlx5_flow_table *ft,
int num_dest) int num_dest)
{ {
struct mlx5_flow_root_namespace *root = find_root(&ft->node); struct mlx5_flow_root_namespace *root = find_root(&ft->node);
static const struct mlx5_flow_spec zero_spec = {};
struct mlx5_flow_destination gen_dest = {}; struct mlx5_flow_destination gen_dest = {};
struct mlx5_flow_table *next_ft = NULL; struct mlx5_flow_table *next_ft = NULL;
struct mlx5_flow_handle *handle = NULL; struct mlx5_flow_handle *handle = NULL;
u32 sw_action = flow_act->action; u32 sw_action = flow_act->action;
struct fs_prio *prio; struct fs_prio *prio;
if (!spec)
spec = &zero_spec;
fs_get_obj(prio, ft->node.parent); fs_get_obj(prio, ft->node.parent);
if (flow_act->action == MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO) { if (flow_act->action == MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO) {
if (!fwd_next_prio_supported(ft)) if (!fwd_next_prio_supported(ft))
......
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