From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0394C7618A for ; Tue, 14 Mar 2023 17:50:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229934AbjCNRuT (ORCPT ); Tue, 14 Mar 2023 13:50:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230159AbjCNRuA (ORCPT ); Tue, 14 Mar 2023 13:50:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3A13AB893 for ; Tue, 14 Mar 2023 10:49:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5F72CB81ACB for ; Tue, 14 Mar 2023 17:49:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CA65C4339B; Tue, 14 Mar 2023 17:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678816196; bh=kb3uOPzGjYwhDUgntULYKlyfqkzEutZa9UVxynrndpc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jgw6JSN7WQsTzdyQCp3lvYnjAviR/oWTLTyucIDDbu8fPddgBKftJdcRAY+dmC8iX tp9pOGV3ASYZv0whQvQOqOyOdI2i9goRT5UtBzJfXtJd2IqUrBFkjzch8dqfKReZNS sHTo3a0q5u3YLGBkzYG5XKxVJIEY80fRpFbXamKOHJN9GmShELqgwJ9jLWZL17mGNq TUByY0B43Z1wJX3ipSukqXLE5arYgbRC9E/d8bOsUYMAtbDcR4U0yHOVrwlx3A2FBv 58NSbP9OB61vHDBOnlMBxz/fYaupFnKqVGCCyHMxz+1aCfjyA9FkOdnfgzfvs2Zb+C 8cvhvDT2az/lg== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Oz Shlomo , Paul Blakey Subject: [net 11/14] net/sched: TC, fix raw counter initialization Date: Tue, 14 Mar 2023 10:49:37 -0700 Message-Id: <20230314174940.62221-12-saeed@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314174940.62221-1-saeed@kernel.org> References: <20230314174940.62221-1-saeed@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Oz Shlomo 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 Reviewed-by: Paul Blakey Signed-off-by: Saeed Mahameed --- 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