int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_block *block, struct tc_cls_flower_offload *f) { struct mlxsw_sp_acl_ruleset *ruleset; struct mlxsw_sp_acl_rule *rule; u64 packets; u64 lastuse; u64 bytes; int err; ruleset = mlxsw_sp_acl_ruleset_get(mlxsw_sp, block, f->common.chain_index, MLXSW_SP_ACL_PROFILE_FLOWER, NULL); if (WARN_ON(IS_ERR(ruleset))) return -EINVAL; rule = mlxsw_sp_acl_rule_lookup(mlxsw_sp, ruleset, f->cookie); if (!rule) return -EINVAL; err = mlxsw_sp_acl_rule_get_stats(mlxsw_sp, rule, &packets, &bytes, &lastuse); if (err) goto err_rule_get_stats; tcf_exts_stats_update(f->exts, bytes, packets, lastuse); mlxsw_sp_acl_ruleset_put(mlxsw_sp, ruleset); return 0; err_rule_get_stats: mlxsw_sp_acl_ruleset_put(mlxsw_sp, ruleset); return err; }
void mlxsw_sp_flower_destroy(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_block *block, struct tc_cls_flower_offload *f) { struct mlxsw_sp_acl_ruleset *ruleset; struct mlxsw_sp_acl_rule *rule; ruleset = mlxsw_sp_acl_ruleset_get(mlxsw_sp, block, f->common.chain_index, MLXSW_SP_ACL_PROFILE_FLOWER, NULL); if (IS_ERR(ruleset)) return; rule = mlxsw_sp_acl_rule_lookup(mlxsw_sp, ruleset, f->cookie); if (rule) { mlxsw_sp_acl_rule_del(mlxsw_sp, rule); mlxsw_sp_acl_rule_destroy(mlxsw_sp, rule); } mlxsw_sp_acl_ruleset_put(mlxsw_sp, ruleset); }
static void mlxsw_sp2_mr_tcam_route_destroy(struct mlxsw_sp *mlxsw_sp, void *priv, void *route_priv, struct mlxsw_sp_mr_route_key *key) { struct mlxsw_sp2_mr_tcam *mr_tcam = priv; struct mlxsw_sp_acl_ruleset *ruleset; struct mlxsw_sp_acl_rule *rule; ruleset = mlxsw_sp2_mr_tcam_proto_ruleset(mr_tcam, key->proto); if (WARN_ON(!ruleset)) return; rule = mlxsw_sp_acl_rule_lookup(mlxsw_sp, ruleset, (unsigned long) route_priv); if (WARN_ON(!rule)) return; mlxsw_sp_acl_rule_del(mlxsw_sp, rule); mlxsw_sp_acl_rule_destroy(mlxsw_sp, rule); }
static int mlxsw_sp2_mr_tcam_route_update(struct mlxsw_sp *mlxsw_sp, void *route_priv, struct mlxsw_sp_mr_route_key *key, struct mlxsw_afa_block *afa_block) { struct mlxsw_sp2_mr_route *mr_route = route_priv; struct mlxsw_sp2_mr_tcam *mr_tcam = mr_route->mr_tcam; struct mlxsw_sp_acl_ruleset *ruleset; struct mlxsw_sp_acl_rule *rule; ruleset = mlxsw_sp2_mr_tcam_proto_ruleset(mr_tcam, key->proto); if (WARN_ON(!ruleset)) return -EINVAL; rule = mlxsw_sp_acl_rule_lookup(mlxsw_sp, ruleset, (unsigned long) route_priv); if (WARN_ON(!rule)) return -EINVAL; return mlxsw_sp_acl_rule_action_replace(mlxsw_sp, rule, afa_block); }