mirror of
https://github.com/Ysurac/openmptcprouter.git
synced 2025-02-15 04:42:02 +00:00
106 lines
4.6 KiB
Diff
106 lines
4.6 KiB
Diff
From 0ccf47265e4cb7fd13d339ee20a84bdbdbd466ef Mon Sep 17 00:00:00 2001
|
|
From: Ariel Levkovich <lariel@mellanox.com>
|
|
Date: Sat, 6 Jul 2019 18:06:15 +0300
|
|
Subject: [PATCH 804/826] net/mlx5e: Prevent encap flow counter update async to
|
|
user query
|
|
|
|
[ Upstream commit 90bb769291161cf25a818d69cf608c181654473e ]
|
|
|
|
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: f6dfb4c3f216 ("net/mlx5e: Update neighbour 'used' state using HW flow rules counters")
|
|
Signed-off-by: Ariel Levkovich <lariel@mellanox.com>
|
|
Reviewed-by: Roi Dayan <roid@mellanox.com>
|
|
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
|
|
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
|
---
|
|
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 4 ++--
|
|
drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c | 5 +++++
|
|
include/linux/mlx5/fs.h | 1 +
|
|
3 files changed, 8 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
|
|
index 9f7f8425f676..c8928ce69185 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
|
|
@@ -992,13 +992,13 @@ void mlx5e_tc_encap_flows_del(struct mlx5e_priv *priv,
|
|
void mlx5e_tc_update_neigh_used_value(struct mlx5e_neigh_hash_entry *nhe)
|
|
{
|
|
struct mlx5e_neigh *m_neigh = &nhe->m_neigh;
|
|
- u64 bytes, packets, lastuse = 0;
|
|
struct mlx5e_tc_flow *flow;
|
|
struct mlx5e_encap_entry *e;
|
|
struct mlx5_fc *counter;
|
|
struct neigh_table *tbl;
|
|
bool neigh_used = false;
|
|
struct neighbour *n;
|
|
+ u64 lastuse;
|
|
|
|
if (m_neigh->family == AF_INET)
|
|
tbl = &arp_tbl;
|
|
@@ -1015,7 +1015,7 @@ void mlx5e_tc_update_neigh_used_value(struct mlx5e_neigh_hash_entry *nhe)
|
|
list_for_each_entry(flow, &e->flows, encap) {
|
|
if (flow->flags & MLX5E_TC_FLOW_OFFLOADED) {
|
|
counter = mlx5_flow_rule_counter(flow->rule[0]);
|
|
- mlx5_fc_query_cached(counter, &bytes, &packets, &lastuse);
|
|
+ lastuse = mlx5_fc_query_lastuse(counter);
|
|
if (time_after((unsigned long)lastuse, nhe->reported_lastuse)) {
|
|
neigh_used = true;
|
|
break;
|
|
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
|
|
index 58af6be13dfa..808ddd732e04 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
|
|
@@ -321,6 +321,11 @@ int mlx5_fc_query(struct mlx5_core_dev *dev, struct mlx5_fc *counter,
|
|
}
|
|
EXPORT_SYMBOL(mlx5_fc_query);
|
|
|
|
+u64 mlx5_fc_query_lastuse(struct mlx5_fc *counter)
|
|
+{
|
|
+ return counter->cache.lastuse;
|
|
+}
|
|
+
|
|
void mlx5_fc_query_cached(struct mlx5_fc *counter,
|
|
u64 *bytes, u64 *packets, u64 *lastuse)
|
|
{
|
|
diff --git a/include/linux/mlx5/fs.h b/include/linux/mlx5/fs.h
|
|
index 804516e4f483..3386399feadc 100644
|
|
--- a/include/linux/mlx5/fs.h
|
|
+++ b/include/linux/mlx5/fs.h
|
|
@@ -188,6 +188,7 @@ int mlx5_modify_rule_destination(struct mlx5_flow_handle *handler,
|
|
struct mlx5_fc *mlx5_flow_rule_counter(struct mlx5_flow_handle *handler);
|
|
struct mlx5_fc *mlx5_fc_create(struct mlx5_core_dev *dev, bool aging);
|
|
void mlx5_fc_destroy(struct mlx5_core_dev *dev, struct mlx5_fc *counter);
|
|
+u64 mlx5_fc_query_lastuse(struct mlx5_fc *counter);
|
|
void mlx5_fc_query_cached(struct mlx5_fc *counter,
|
|
u64 *bytes, u64 *packets, u64 *lastuse);
|
|
int mlx5_fc_query(struct mlx5_core_dev *dev, struct mlx5_fc *counter,
|
|
--
|
|
2.22.0
|
|
|