From patchwork Thu Oct 19 14:41:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10017297 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DF7D9600CC for ; Thu, 19 Oct 2017 14:42:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3BA328D90 for ; Thu, 19 Oct 2017 14:42:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8AB128D94; Thu, 19 Oct 2017 14:42:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66AD128D90 for ; Thu, 19 Oct 2017 14:42:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752671AbdJSOmy (ORCPT ); Thu, 19 Oct 2017 10:42:54 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:54888 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752656AbdJSOmv (ORCPT ); Thu, 19 Oct 2017 10:42:51 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Oct 2017 16:42:42 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v9JEggYb032340; Thu, 19 Oct 2017 17:42:42 +0300 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id v9JEggQZ027421; Thu, 19 Oct 2017 17:42:42 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id v9JEggkI027420; Thu, 19 Oct 2017 17:42:42 +0300 From: Yishai Hadas To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, yishaih@mellanox.com, raeds@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-next 12/16] net/mlx5: Expand mlx5_fc_query_cached to return absolute counters values Date: Thu, 19 Oct 2017 17:41:54 +0300 Message-Id: <1508424118-27205-13-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1508424118-27205-1-git-send-email-yishaih@mellanox.com> References: <1508424118-27205-1-git-send-email-yishaih@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Raed Salem Currently mlx5_fc_query_cached returns counters values since last call, expands it to work with query flags, passing MLX5_FLOW_QUERY_CACHED_ABS flag will makes function to return counters absolute values. This absolute mode will be used in downstream patches in this series. Signed-off-by: Raed Salem Reviewed-by: Yishai Hadas --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 6 ++++-- drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c | 14 ++++++++++---- include/linux/mlx5/fs.h | 8 +++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 1aa2028..37b3049 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -465,7 +465,8 @@ 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); - mlx5_fc_query_cached(counter, &bytes, &packets, &lastuse); + mlx5_fc_query_cached(counter, &bytes, &packets, &lastuse, + MLX5_FLOW_QUERY_CACHED_DIFF); if (time_after((unsigned long)lastuse, nhe->reported_lastuse)) { neigh_used = true; break; @@ -2133,7 +2134,8 @@ int mlx5e_stats_flower(struct mlx5e_priv *priv, if (!counter) return 0; - mlx5_fc_query_cached(counter, &bytes, &packets, &lastuse); + mlx5_fc_query_cached(counter, &bytes, &packets, &lastuse, + MLX5_FLOW_QUERY_CACHED_DIFF); tcf_exts_stats_update(f->exts, bytes, packets, lastuse); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c index f679eb0..2a5b2f4 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c @@ -315,16 +315,22 @@ void mlx5_cleanup_fc_stats(struct mlx5_core_dev *dev) } void mlx5_fc_query_cached(struct mlx5_fc *counter, - u64 *bytes, u64 *packets, u64 *lastuse) + u64 *bytes, u64 *packets, u64 *lastuse, + enum mlx5_flow_query_cached_flags query_flags) { struct mlx5_fc_cache c; c = counter->cache; - *bytes = c.bytes - counter->lastbytes; - *packets = c.packets - counter->lastpackets; - *lastuse = c.lastuse; + if (query_flags == MLX5_FLOW_QUERY_CACHED_ABS) { + *bytes = c.bytes; + *packets = c.packets; + } else { + *bytes = c.bytes - counter->lastbytes; + *packets = c.packets - counter->lastpackets; + } + *lastuse = c.lastuse; counter->lastbytes = c.bytes; counter->lastpackets = c.packets; } diff --git a/include/linux/mlx5/fs.h b/include/linux/mlx5/fs.h index a4a715e..8e0331c 100644 --- a/include/linux/mlx5/fs.h +++ b/include/linux/mlx5/fs.h @@ -164,8 +164,14 @@ 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); + +enum mlx5_flow_query_cached_flags { + MLX5_FLOW_QUERY_CACHED_DIFF = 0, + MLX5_FLOW_QUERY_CACHED_ABS = 1, +}; void mlx5_fc_query_cached(struct mlx5_fc *counter, - u64 *bytes, u64 *packets, u64 *lastuse); + u64 *bytes, u64 *packets, u64 *lastuse, + enum mlx5_flow_query_cached_flags query_flags); int mlx5_cmd_fc_query(struct mlx5_core_dev *dev, u32 id, u64 *packets, u64 *bytes);