mlxsw: acl: Introduce activity get operation for action block/set
authorJiri Pirko <jiri@mellanox.com>
Wed, 18 Jul 2018 08:14:36 +0000 (11:14 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Jul 2018 17:13:13 +0000 (02:13 +0900)
In Spectrum-2, activity cannot be find out by TCAM rule (PTCEv2 register),
but rather by associated action set. For that purpose, extend action ops
to allow query activity from PEFA register. Block activity is decided
according to activity of the first set.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_actions.c

index 72a6a8a2131e949cef88ebdc39b847167950bbdb..75ebf5e6b9e109f14275ac33fddf4676623b3d7f 100644 (file)
@@ -441,6 +441,15 @@ u32 mlxsw_afa_block_first_kvdl_index(struct mlxsw_afa_block *block)
 }
 EXPORT_SYMBOL(mlxsw_afa_block_first_kvdl_index);
 
+int mlxsw_afa_block_activity_get(struct mlxsw_afa_block *block, bool *activity)
+{
+       u32 kvdl_index = mlxsw_afa_block_first_kvdl_index(block);
+
+       return block->afa->ops->kvdl_set_activity_get(block->afa->ops_priv,
+                                                     kvdl_index, activity);
+}
+EXPORT_SYMBOL(mlxsw_afa_block_activity_get);
+
 int mlxsw_afa_block_continue(struct mlxsw_afa_block *block)
 {
        if (block->finished)
index c18249ac28f702987223b35381a9dbe9fe759e07..1c7db26e7942f686ecacca7d849659fcb8955ec2 100644 (file)
@@ -45,6 +45,8 @@ struct mlxsw_afa_ops {
        int (*kvdl_set_add)(void *priv, u32 *p_kvdl_index,
                            char *enc_actions, bool is_first);
        void (*kvdl_set_del)(void *priv, u32 kvdl_index, bool is_first);
+       int (*kvdl_set_activity_get)(void *priv, u32 kvdl_index,
+                                    bool *activity);
        int (*kvdl_fwd_entry_add)(void *priv, u32 *p_kvdl_index, u8 local_port);
        void (*kvdl_fwd_entry_del)(void *priv, u32 kvdl_index);
        int (*counter_index_get)(void *priv, unsigned int *p_counter_index);
@@ -66,6 +68,7 @@ void mlxsw_afa_block_destroy(struct mlxsw_afa_block *block);
 int mlxsw_afa_block_commit(struct mlxsw_afa_block *block);
 char *mlxsw_afa_block_first_set(struct mlxsw_afa_block *block);
 u32 mlxsw_afa_block_first_kvdl_index(struct mlxsw_afa_block *block);
+int mlxsw_afa_block_activity_get(struct mlxsw_afa_block *block, bool *activity);
 int mlxsw_afa_block_continue(struct mlxsw_afa_block *block);
 int mlxsw_afa_block_jump(struct mlxsw_afa_block *block, u16 group_id);
 int mlxsw_afa_block_terminate(struct mlxsw_afa_block *block);
index 9119a023bc1ec203ea868d80afc14a8e47a49181..bca0def756cda3bfd54423bd7f979e1ddf6194d1 100644 (file)
@@ -93,6 +93,27 @@ static void mlxsw_sp_act_kvdl_set_del(void *priv, u32 kvdl_index,
                           1, kvdl_index);
 }
 
+static int mlxsw_sp1_act_kvdl_set_activity_get(void *priv, u32 kvdl_index,
+                                              bool *activity)
+{
+       return -EOPNOTSUPP;
+}
+
+static int mlxsw_sp2_act_kvdl_set_activity_get(void *priv, u32 kvdl_index,
+                                              bool *activity)
+{
+       struct mlxsw_sp *mlxsw_sp = priv;
+       char pefa_pl[MLXSW_REG_PEFA_LEN];
+       int err;
+
+       mlxsw_reg_pefa_pack(pefa_pl, kvdl_index, true, NULL);
+       err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pefa), pefa_pl);
+       if (err)
+               return err;
+       mlxsw_reg_pefa_unpack(pefa_pl, activity);
+       return 0;
+}
+
 static int mlxsw_sp_act_kvdl_fwd_entry_add(void *priv, u32 *p_kvdl_index,
                                           u8 local_port)
 {
@@ -174,6 +195,7 @@ mlxsw_sp_act_mirror_del(void *priv, u8 local_in_port, int span_id, bool ingress)
 const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops = {
        .kvdl_set_add           = mlxsw_sp1_act_kvdl_set_add,
        .kvdl_set_del           = mlxsw_sp_act_kvdl_set_del,
+       .kvdl_set_activity_get  = mlxsw_sp1_act_kvdl_set_activity_get,
        .kvdl_fwd_entry_add     = mlxsw_sp_act_kvdl_fwd_entry_add,
        .kvdl_fwd_entry_del     = mlxsw_sp_act_kvdl_fwd_entry_del,
        .counter_index_get      = mlxsw_sp_act_counter_index_get,
@@ -185,6 +207,7 @@ const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops = {
 const struct mlxsw_afa_ops mlxsw_sp2_act_afa_ops = {
        .kvdl_set_add           = mlxsw_sp2_act_kvdl_set_add,
        .kvdl_set_del           = mlxsw_sp_act_kvdl_set_del,
+       .kvdl_set_activity_get  = mlxsw_sp2_act_kvdl_set_activity_get,
        .kvdl_fwd_entry_add     = mlxsw_sp_act_kvdl_fwd_entry_add,
        .kvdl_fwd_entry_del     = mlxsw_sp_act_kvdl_fwd_entry_del,
        .counter_index_get      = mlxsw_sp_act_counter_index_get,