• Ariel Levkovich's avatar
    net/mlx5e: Prevent encap flow counter update async to user query · 90bb7692
    Ariel Levkovich authored
    This patch prevents a race between user invoked cached counters
    query and a neighbor last usage updater.
    
    The cached flow counter stats can be queried by calling
    "mlx5_fc_query_cached" which provides the number of bytes and
    packets that passed via this flow since the last time this counter
    was queried.
    It does so by reducting the last saved stats from the current, cached
    stats and then updating the last saved stats with the cached stats.
    It also provide the lastuse value for that flow.
    
    Since "mlx5e_tc_update_neigh_used_value" needs to retrieve the
    last usage time of encapsulation flows, it calls the flow counter
    query method periodically and async to user queries of the flow counter
    using cls_flower.
    This call is causing the driver to update the last reported bytes and
    packets from the cache and therefore, future user queries of the flow
    stats will return lower than expected number for bytes and packets
    since the last saved stats in the driver was updated async to the last
    saved stats in cls_flower.
    
    This causes wrong stats presentation of encapsulation flows to user.
    
    Since the neighbor usage updater only needs the lastuse stats from the
    cached counter, the fix is to use a dedicated lastuse query call that
    returns the lastuse value without synching between the cached stats and
    the last saved stats.
    
    Fixes: f6dfb4c3 ("net/mlx5e: Update neighbour 'used' state using HW flow rules counters")
    Signed-off-by: default avatarAriel Levkovich <lariel@mellanox.com>
    Reviewed-by: default avatarRoi Dayan <roid@mellanox.com>
    Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
    90bb7692
en_tc.c 100 KB