mlxsw: spectrum_acl: Allow to get group_id value for a ruleset
authorJiri Pirko <jiri@mellanox.com>
Wed, 23 Aug 2017 08:08:20 +0000 (10:08 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 24 Aug 2017 03:44:32 +0000 (20:44 -0700)
For goto_chain action we need to know group_id of a ruleset to jump to.
Provide infrastructure in order to get it.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c

index de3aef971e2d04404d68b87b9929e0cb3021f578..1866f692d3cd2cbdc3c02674f5b1085f488bf2b8 100644 (file)
@@ -417,6 +417,7 @@ struct mlxsw_sp_acl_profile_ops {
        int (*ruleset_bind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv,
                            struct net_device *dev, bool ingress);
        void (*ruleset_unbind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv);
+       u16 (*ruleset_group_id)(void *ruleset_priv);
        size_t rule_priv_size;
        int (*rule_add)(struct mlxsw_sp *mlxsw_sp,
                        void *ruleset_priv, void *rule_priv,
@@ -445,6 +446,7 @@ mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, struct net_device *dev,
                         enum mlxsw_sp_acl_profile profile);
 void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp,
                              struct mlxsw_sp_acl_ruleset *ruleset);
+u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset);
 
 struct mlxsw_sp_acl_rule_info *
 mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl);
index 8ab331bdff023602e22d08d404890ecb96a96470..ef86f044295ad090b7b3f0f3a7cad7f9b60ad364 100644 (file)
@@ -267,6 +267,13 @@ void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp,
        mlxsw_sp_acl_ruleset_ref_dec(mlxsw_sp, ruleset);
 }
 
+u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset)
+{
+       const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops;
+
+       return ops->ruleset_group_id(ruleset->priv);
+}
+
 static int
 mlxsw_sp_acl_rulei_counter_alloc(struct mlxsw_sp *mlxsw_sp,
                                 struct mlxsw_sp_acl_rule_info *rulei)
index bc5173f1b5c1be0d2274125f377ab48de20c7059..50b40de1fb911d9cbf3ebb22f81fc416db7e21e7 100644 (file)
@@ -295,6 +295,12 @@ mlxsw_sp_acl_tcam_group_unbind(struct mlxsw_sp *mlxsw_sp,
        mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ppbt), ppbt_pl);
 }
 
+static u16
+mlxsw_sp_acl_tcam_group_id(struct mlxsw_sp_acl_tcam_group *group)
+{
+       return group->id;
+}
+
 static unsigned int
 mlxsw_sp_acl_tcam_region_prio(struct mlxsw_sp_acl_tcam_region *region)
 {
@@ -1063,6 +1069,14 @@ mlxsw_sp_acl_tcam_flower_ruleset_unbind(struct mlxsw_sp *mlxsw_sp,
        mlxsw_sp_acl_tcam_group_unbind(mlxsw_sp, &ruleset->group);
 }
 
+static u16
+mlxsw_sp_acl_tcam_flower_ruleset_group_id(void *ruleset_priv)
+{
+       struct mlxsw_sp_acl_tcam_flower_ruleset *ruleset = ruleset_priv;
+
+       return mlxsw_sp_acl_tcam_group_id(&ruleset->group);
+}
+
 static int
 mlxsw_sp_acl_tcam_flower_rule_add(struct mlxsw_sp *mlxsw_sp,
                                  void *ruleset_priv, void *rule_priv,
@@ -1099,6 +1113,7 @@ static const struct mlxsw_sp_acl_profile_ops mlxsw_sp_acl_tcam_flower_ops = {
        .ruleset_del            = mlxsw_sp_acl_tcam_flower_ruleset_del,
        .ruleset_bind           = mlxsw_sp_acl_tcam_flower_ruleset_bind,
        .ruleset_unbind         = mlxsw_sp_acl_tcam_flower_ruleset_unbind,
+       .ruleset_group_id       = mlxsw_sp_acl_tcam_flower_ruleset_group_id,
        .rule_priv_size         = sizeof(struct mlxsw_sp_acl_tcam_flower_rule),
        .rule_add               = mlxsw_sp_acl_tcam_flower_rule_add,
        .rule_del               = mlxsw_sp_acl_tcam_flower_rule_del,