提交 45b62742 编写于 作者: J Jiri Pirko 提交者: David S. Miller

mlxsw: spectrum: Offload multichain TC rules

Reflect chain index coming down from TC core and create a ruleset per
chain. Note that only chain 0, being the implicit chain, is bound to the
device for processing. The rest of chains have to be "jumped-to" by
actions.
Signed-off-by: NJiri Pirko <jiri@mellanox.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 ae99e188
...@@ -1733,9 +1733,6 @@ mlxsw_sp_setup_tc_cls_flower(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -1733,9 +1733,6 @@ mlxsw_sp_setup_tc_cls_flower(struct mlxsw_sp_port *mlxsw_sp_port,
else else
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (f->common.chain_index)
return -EOPNOTSUPP;
switch (f->command) { switch (f->command) {
case TC_CLSFLOWER_REPLACE: case TC_CLSFLOWER_REPLACE:
return mlxsw_sp_flower_replace(mlxsw_sp_port, ingress, f); return mlxsw_sp_flower_replace(mlxsw_sp_port, ingress, f);
......
...@@ -440,8 +440,8 @@ struct mlxsw_sp_acl_ruleset; ...@@ -440,8 +440,8 @@ struct mlxsw_sp_acl_ruleset;
/* spectrum_acl.c */ /* spectrum_acl.c */
struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl); struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);
struct mlxsw_sp_acl_ruleset * struct mlxsw_sp_acl_ruleset *
mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, struct net_device *dev,
struct net_device *dev, bool ingress, bool ingress, u32 chain_index,
enum mlxsw_sp_acl_profile profile); enum mlxsw_sp_acl_profile profile);
void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp, void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_ruleset *ruleset); struct mlxsw_sp_acl_ruleset *ruleset);
......
...@@ -74,6 +74,7 @@ struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl) ...@@ -74,6 +74,7 @@ struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl)
struct mlxsw_sp_acl_ruleset_ht_key { struct mlxsw_sp_acl_ruleset_ht_key {
struct net_device *dev; /* dev this ruleset is bound to */ struct net_device *dev; /* dev this ruleset is bound to */
bool ingress; bool ingress;
u32 chain_index;
const struct mlxsw_sp_acl_profile_ops *ops; const struct mlxsw_sp_acl_profile_ops *ops;
}; };
...@@ -163,7 +164,8 @@ static void mlxsw_sp_acl_ruleset_destroy(struct mlxsw_sp *mlxsw_sp, ...@@ -163,7 +164,8 @@ static void mlxsw_sp_acl_ruleset_destroy(struct mlxsw_sp *mlxsw_sp,
static int mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp, static int mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_ruleset *ruleset, struct mlxsw_sp_acl_ruleset *ruleset,
struct net_device *dev, bool ingress) struct net_device *dev, bool ingress,
u32 chain_index)
{ {
const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops;
struct mlxsw_sp_acl *acl = mlxsw_sp->acl; struct mlxsw_sp_acl *acl = mlxsw_sp->acl;
...@@ -171,13 +173,20 @@ static int mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp, ...@@ -171,13 +173,20 @@ static int mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp,
ruleset->ht_key.dev = dev; ruleset->ht_key.dev = dev;
ruleset->ht_key.ingress = ingress; ruleset->ht_key.ingress = ingress;
ruleset->ht_key.chain_index = chain_index;
err = rhashtable_insert_fast(&acl->ruleset_ht, &ruleset->ht_node, err = rhashtable_insert_fast(&acl->ruleset_ht, &ruleset->ht_node,
mlxsw_sp_acl_ruleset_ht_params); mlxsw_sp_acl_ruleset_ht_params);
if (err) if (err)
return err; return err;
err = ops->ruleset_bind(mlxsw_sp, ruleset->priv, dev, ingress); if (!ruleset->ht_key.chain_index) {
if (err) /* We only need ruleset with chain index 0, the implicit one,
goto err_ops_ruleset_bind; * to be directly bound to device. The rest of the rulesets
* are bound by "Goto action set".
*/
err = ops->ruleset_bind(mlxsw_sp, ruleset->priv, dev, ingress);
if (err)
goto err_ops_ruleset_bind;
}
return 0; return 0;
err_ops_ruleset_bind: err_ops_ruleset_bind:
...@@ -192,7 +201,8 @@ static void mlxsw_sp_acl_ruleset_unbind(struct mlxsw_sp *mlxsw_sp, ...@@ -192,7 +201,8 @@ static void mlxsw_sp_acl_ruleset_unbind(struct mlxsw_sp *mlxsw_sp,
const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops;
struct mlxsw_sp_acl *acl = mlxsw_sp->acl; struct mlxsw_sp_acl *acl = mlxsw_sp->acl;
ops->ruleset_unbind(mlxsw_sp, ruleset->priv); if (!ruleset->ht_key.chain_index)
ops->ruleset_unbind(mlxsw_sp, ruleset->priv);
rhashtable_remove_fast(&acl->ruleset_ht, &ruleset->ht_node, rhashtable_remove_fast(&acl->ruleset_ht, &ruleset->ht_node,
mlxsw_sp_acl_ruleset_ht_params); mlxsw_sp_acl_ruleset_ht_params);
} }
...@@ -212,8 +222,8 @@ static void mlxsw_sp_acl_ruleset_ref_dec(struct mlxsw_sp *mlxsw_sp, ...@@ -212,8 +222,8 @@ static void mlxsw_sp_acl_ruleset_ref_dec(struct mlxsw_sp *mlxsw_sp,
} }
struct mlxsw_sp_acl_ruleset * struct mlxsw_sp_acl_ruleset *
mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, struct net_device *dev,
struct net_device *dev, bool ingress, bool ingress, u32 chain_index,
enum mlxsw_sp_acl_profile profile) enum mlxsw_sp_acl_profile profile)
{ {
const struct mlxsw_sp_acl_profile_ops *ops; const struct mlxsw_sp_acl_profile_ops *ops;
...@@ -229,6 +239,7 @@ mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, ...@@ -229,6 +239,7 @@ mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp,
memset(&ht_key, 0, sizeof(ht_key)); memset(&ht_key, 0, sizeof(ht_key));
ht_key.dev = dev; ht_key.dev = dev;
ht_key.ingress = ingress; ht_key.ingress = ingress;
ht_key.chain_index = chain_index;
ht_key.ops = ops; ht_key.ops = ops;
ruleset = rhashtable_lookup_fast(&acl->ruleset_ht, &ht_key, ruleset = rhashtable_lookup_fast(&acl->ruleset_ht, &ht_key,
mlxsw_sp_acl_ruleset_ht_params); mlxsw_sp_acl_ruleset_ht_params);
...@@ -239,7 +250,8 @@ mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, ...@@ -239,7 +250,8 @@ mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp,
ruleset = mlxsw_sp_acl_ruleset_create(mlxsw_sp, ops); ruleset = mlxsw_sp_acl_ruleset_create(mlxsw_sp, ops);
if (IS_ERR(ruleset)) if (IS_ERR(ruleset))
return ruleset; return ruleset;
err = mlxsw_sp_acl_ruleset_bind(mlxsw_sp, ruleset, dev, ingress); err = mlxsw_sp_acl_ruleset_bind(mlxsw_sp, ruleset, dev,
ingress, chain_index);
if (err) if (err)
goto err_ruleset_bind; goto err_ruleset_bind;
return ruleset; return ruleset;
......
...@@ -378,6 +378,7 @@ int mlxsw_sp_flower_replace(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, ...@@ -378,6 +378,7 @@ int mlxsw_sp_flower_replace(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress,
int err; int err;
ruleset = mlxsw_sp_acl_ruleset_get(mlxsw_sp, dev, ingress, ruleset = mlxsw_sp_acl_ruleset_get(mlxsw_sp, dev, ingress,
f->common.chain_index,
MLXSW_SP_ACL_PROFILE_FLOWER); MLXSW_SP_ACL_PROFILE_FLOWER);
if (IS_ERR(ruleset)) if (IS_ERR(ruleset))
return PTR_ERR(ruleset); return PTR_ERR(ruleset);
...@@ -421,7 +422,7 @@ void mlxsw_sp_flower_destroy(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, ...@@ -421,7 +422,7 @@ void mlxsw_sp_flower_destroy(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress,
struct mlxsw_sp_acl_rule *rule; struct mlxsw_sp_acl_rule *rule;
ruleset = mlxsw_sp_acl_ruleset_get(mlxsw_sp, mlxsw_sp_port->dev, ruleset = mlxsw_sp_acl_ruleset_get(mlxsw_sp, mlxsw_sp_port->dev,
ingress, ingress, f->common.chain_index,
MLXSW_SP_ACL_PROFILE_FLOWER); MLXSW_SP_ACL_PROFILE_FLOWER);
if (IS_ERR(ruleset)) if (IS_ERR(ruleset))
return; return;
...@@ -447,7 +448,7 @@ int mlxsw_sp_flower_stats(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, ...@@ -447,7 +448,7 @@ int mlxsw_sp_flower_stats(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress,
int err; int err;
ruleset = mlxsw_sp_acl_ruleset_get(mlxsw_sp, mlxsw_sp_port->dev, ruleset = mlxsw_sp_acl_ruleset_get(mlxsw_sp, mlxsw_sp_port->dev,
ingress, ingress, f->common.chain_index,
MLXSW_SP_ACL_PROFILE_FLOWER); MLXSW_SP_ACL_PROFILE_FLOWER);
if (WARN_ON(IS_ERR(ruleset))) if (WARN_ON(IS_ERR(ruleset)))
return -EINVAL; return -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册