mlxsw: spectrum_dpipe: Fix incorrect entry index
authorArkadi Sharshevsky <arkadis@mellanox.com>
Thu, 18 May 2017 07:18:52 +0000 (09:18 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 18 May 2017 15:03:59 +0000 (11:03 -0400)
In case of disabled counters the entry index will be incorrect. Fix this
by moving the entry index set before the counter status check.

Fixes: 2ba5999f009d ("mlxsw: spectrum: Add Support for erif table entries access")
Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c

index ea56f6ade6b429585f35a2f72dae20f8d51d4a0f..5f0a7bc692a4b8e3efae2f8a3c8a55f5c448346d 100644 (file)
@@ -199,10 +199,11 @@ static int mlxsw_sp_erif_entry_get(struct mlxsw_sp *mlxsw_sp,
 
        entry->counter_valid = false;
        entry->counter = 0;
+       entry->index = mlxsw_sp_rif_index(rif);
+
        if (!counters_enabled)
                return 0;
 
-       entry->index = mlxsw_sp_rif_index(rif);
        err = mlxsw_sp_rif_counter_value_get(mlxsw_sp, rif,
                                             MLXSW_SP_RIF_COUNTER_EGRESS,
                                             &cnt);