Skip to content

Commit f16e7f6

Browse files
jpirkodavem330
authored andcommitted
mlxsw: spectrum_acl: Ask device for rule stats only if counter was created
Set a flag in case rule counter was created. Only query the device for stats of a rule, which has the valid counter assigned. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4885547 commit f16e7f6

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

‎drivers/net/ethernet/mellanox/mlxsw/spectrum.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,8 @@ struct mlxsw_sp_acl_rule_info {
641641
struct mlxsw_afa_block *act_block;
642642
u8 action_created:1,
643643
ingress_bind_blocker:1,
644-
egress_bind_blocker:1;
644+
egress_bind_blocker:1,
645+
counter_valid:1;
645646
unsigned int counter_index;
646647
};
647648

‎drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,14 @@ int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
642642
struct mlxsw_sp_acl_rule_info *rulei,
643643
struct netlink_ext_ack *extack)
644644
{
645-
return mlxsw_afa_block_append_counter(rulei->act_block,
646-
&rulei->counter_index, extack);
645+
int err;
646+
647+
err = mlxsw_afa_block_append_counter(rulei->act_block,
648+
&rulei->counter_index, extack);
649+
if (err)
650+
return err;
651+
rulei->counter_valid = true;
652+
return 0;
647653
}
648654

649655
int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp,
@@ -857,16 +863,18 @@ int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
857863

858864
{
859865
struct mlxsw_sp_acl_rule_info *rulei;
860-
u64 current_packets;
861-
u64 current_bytes;
866+
u64 current_packets = 0;
867+
u64 current_bytes = 0;
862868
int err;
863869

864870
rulei = mlxsw_sp_acl_rule_rulei(rule);
865-
err = mlxsw_sp_flow_counter_get(mlxsw_sp, rulei->counter_index,
866-
&current_packets, &current_bytes);
867-
if (err)
868-
return err;
869-
871+
if (rulei->counter_valid) {
872+
err = mlxsw_sp_flow_counter_get(mlxsw_sp, rulei->counter_index,
873+
&current_packets,
874+
&current_bytes);
875+
if (err)
876+
return err;
877+
}
870878
*packets = current_packets - rule->last_packets;
871879
*bytes = current_bytes - rule->last_bytes;
872880
*last_use = rule->last_used;

0 commit comments

Comments
 (0)