netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
	netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
	Oz Shlomo <ozsh@nvidia.com>, Paul Blakey <paulb@nvidia.com>
Subject: [net 11/14] net/sched: TC, fix raw counter initialization
Date: Tue, 14 Mar 2023 10:49:37 -0700	[thread overview]
Message-ID: <20230314174940.62221-12-saeed@kernel.org> (raw)
In-Reply-To: <20230314174940.62221-1-saeed@kernel.org>

From: Oz Shlomo <ozsh@nvidia.com>

Freed counters may be reused by fs core.
As such, raw counters may not be initialized to zero.

Cache the counter values when the action stats object is initialized to
have a proper base value for calculating the difference from the previous
query.

Fixes: 2b68d659a704 ("net/mlx5e: TC, support per action stats")
Signed-off-by: Oz Shlomo <ozsh@nvidia.com>
Reviewed-by: Paul Blakey <paulb@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.c
index 626cb7470fa5..07c1895a2b23 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.c
@@ -64,6 +64,7 @@ mlx5e_tc_act_stats_add(struct mlx5e_tc_act_stats_handle *handle,
 {
 	struct mlx5e_tc_act_stats *act_stats, *old_act_stats;
 	struct rhashtable *ht = &handle->ht;
+	u64 lastused;
 	int err = 0;
 
 	act_stats = kvzalloc(sizeof(*act_stats), GFP_KERNEL);
@@ -73,6 +74,10 @@ mlx5e_tc_act_stats_add(struct mlx5e_tc_act_stats_handle *handle,
 	act_stats->tc_act_cookie = act_cookie;
 	act_stats->counter = counter;
 
+	mlx5_fc_query_cached_raw(counter,
+				 &act_stats->lastbytes,
+				 &act_stats->lastpackets, &lastused);
+
 	rcu_read_lock();
 	old_act_stats = rhashtable_lookup_get_insert_fast(ht,
 							  &act_stats->hash,
-- 
2.39.2


  parent reply	other threads:[~2023-03-14 17:50 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14 17:49 [pull request][net 00/14] mlx5 fixes 2023-03-14 Saeed Mahameed
2023-03-14 17:49 ` [net 01/14] net/mlx5e: Fix macsec ASO context alignment Saeed Mahameed
2023-03-14 17:49 ` [net 02/14] net/mlx5e: Don't cache tunnel offloads capability Saeed Mahameed
2023-03-15 13:14   ` Piotr Raczynski
2023-03-14 17:49 ` [net 03/14] net/mlx5: Fix setting ec_function bit in MANAGE_PAGES Saeed Mahameed
2023-03-15 13:10   ` Piotr Raczynski
2023-03-15 20:51     ` Saeed Mahameed
2023-03-15 21:04       ` Jakub Kicinski
2023-03-15 21:09         ` Saeed Mahameed
2023-03-15 21:33           ` Jakub Kicinski
2023-03-15 22:53             ` Saeed Mahameed
2023-03-14 17:49 ` [net 04/14] net/mlx5: Disable eswitch before waiting for VF pages Saeed Mahameed
2023-03-15 12:51   ` Piotr Raczynski
2023-03-14 17:49 ` [net 05/14] net/mlx5: E-switch, Fix wrong usage of source port rewrite in split rules Saeed Mahameed
2023-03-14 17:49 ` [net 06/14] net/mlx5: E-switch, Fix missing set of split_count when forward to ovs internal port Saeed Mahameed
2023-03-14 17:49 ` [net 07/14] net/mlx5e: Fix cleanup null-ptr deref on encap lock Saeed Mahameed
2023-03-14 17:49 ` [net 08/14] net/mlx5e: kTLS, Fix missing error unwind on unsupported cipher type Saeed Mahameed
2023-03-14 17:49 ` [net 09/14] net/mlx5: Set BREAK_FW_WAIT flag first when removing driver Saeed Mahameed
2023-03-14 17:49 ` [net 10/14] net/mlx5e: Lower maximum allowed MTU in XSK to match XDP prerequisites Saeed Mahameed
2023-03-14 17:49 ` Saeed Mahameed [this message]
2023-03-14 17:49 ` [net 12/14] net/mlx5e: TC, fix missing error code Saeed Mahameed
2023-03-14 17:49 ` [net 13/14] net/mlx5e: TC, fix cloned flow attribute Saeed Mahameed
2023-03-14 17:49 ` [net 14/14] net/mlx5e: TC, Remove error message log print Saeed Mahameed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230314174940.62221-12-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ozsh@nvidia.com \
    --cc=pabeni@redhat.com \
    --cc=paulb@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).