Skip to content

Commit 316d5f7

Browse files
roidayanSaeed Mahameed
authored andcommitted
net/mlx5e: Always query offloaded tc peer rule counter
Under multipath when encap rules are duplicated to HW in the driver, it's possible for one flow to be currently un-offloaded (e.g. lack of next-hop route or neigh entry) while the other flow is offloaded. As such, we move to query the counters of both flows at all times. Signed-off-by: Roi Dayan <[email protected]> Reviewed-by: Or Gerlitz <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent b4a2332 commit 316d5f7

File tree

1 file changed

+15
-11
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+15
-11
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3078,23 +3078,25 @@ int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv,
30783078
struct mlx5_eswitch *peer_esw;
30793079
struct mlx5e_tc_flow *flow;
30803080
struct mlx5_fc *counter;
3081-
u64 bytes;
3082-
u64 packets;
3083-
u64 lastuse;
3081+
u64 lastuse = 0;
3082+
u64 packets = 0;
3083+
u64 bytes = 0;
30843084

30853085
flow = rhashtable_lookup_fast(tc_ht, &f->cookie, tc_ht_params);
30863086
if (!flow || !same_flow_direction(flow, flags))
30873087
return -EINVAL;
30883088

3089-
if (!(flow->flags & MLX5E_TC_FLOW_OFFLOADED))
3090-
return 0;
3091-
3092-
counter = mlx5e_tc_get_counter(flow);
3093-
if (!counter)
3094-
return 0;
3089+
if (flow->flags & MLX5E_TC_FLOW_OFFLOADED) {
3090+
counter = mlx5e_tc_get_counter(flow);
3091+
if (!counter)
3092+
return 0;
30953093

3096-
mlx5_fc_query_cached(counter, &bytes, &packets, &lastuse);
3094+
mlx5_fc_query_cached(counter, &bytes, &packets, &lastuse);
3095+
}
30973096

3097+
/* Under multipath it's possible for one rule to be currently
3098+
* un-offloaded while the other rule is offloaded.
3099+
*/
30983100
peer_esw = mlx5_devcom_get_peer_data(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
30993101
if (!peer_esw)
31003102
goto out;
@@ -3106,15 +3108,17 @@ int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv,
31063108
u64 lastuse2;
31073109

31083110
counter = mlx5e_tc_get_counter(flow->peer_flow);
3111+
if (!counter)
3112+
goto no_peer_counter;
31093113
mlx5_fc_query_cached(counter, &bytes2, &packets2, &lastuse2);
31103114

31113115
bytes += bytes2;
31123116
packets += packets2;
31133117
lastuse = max_t(u64, lastuse, lastuse2);
31143118
}
31153119

3120+
no_peer_counter:
31163121
mlx5_devcom_release_peer_data(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
3117-
31183122
out:
31193123
flow_stats_update(&f->stats, bytes, packets, lastuse);
31203124

0 commit comments

Comments
 (0)