{"id":819404,"url":"http://patchwork.ozlabs.org/api/patches/819404/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170928044132.30940-10-saeedm@mellanox.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170928044132.30940-10-saeedm@mellanox.com>","list_archive_url":null,"date":"2017-09-28T04:41:30","name":"[net,09/11] net/mlx5e: Fix calculated checksum offloads counters","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"f821a34e62fe6766e122f1d33dbcd188b9983fa0","submitter":{"id":65299,"url":"http://patchwork.ozlabs.org/api/people/65299/?format=json","name":"Saeed Mahameed","email":"saeedm@mellanox.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170928044132.30940-10-saeedm@mellanox.com/mbox/","series":[{"id":5488,"url":"http://patchwork.ozlabs.org/api/series/5488/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=5488","date":"2017-09-28T04:41:23","name":"Mellanox, mlx5 fixes 2017-09-28","version":1,"mbox":"http://patchwork.ozlabs.org/series/5488/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/819404/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/819404/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3y2hr13kvBz9t3x\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 28 Sep 2017 14:42:25 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752022AbdI1EmW (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 28 Sep 2017 00:42:22 -0400","from mail-il-dmz.mellanox.com ([193.47.165.129]:54410 \"EHLO\n\tmellanox.co.il\" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org\n\twith ESMTP id S1751730AbdI1EmG (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Thu, 28 Sep 2017 00:42:06 -0400","from Internal Mail-Server by MTLPINE1 (envelope-from\n\tsaeedm@mellanox.com)\n\twith ESMTPS (AES256-SHA encrypted); 28 Sep 2017 06:42:02 +0200","from sws.mtl.labs.mlnx (reg-l-vrt-045-015.mtl.labs.mlnx\n\t[10.135.45.15])\n\tby labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v8S4g1jD011096;\n\tThu, 28 Sep 2017 07:42:01 +0300"],"From":"Saeed Mahameed <saeedm@mellanox.com>","To":"\"David S. Miller\" <davem@davemloft.net>","Cc":"netdev@vger.kernel.org, Gal Pressman <galp@mellanox.com>,\n\tSaeed Mahameed <saeedm@mellanox.com>","Subject":"[net 09/11] net/mlx5e: Fix calculated checksum offloads counters","Date":"Thu, 28 Sep 2017 07:41:30 +0300","Message-Id":"<20170928044132.30940-10-saeedm@mellanox.com>","X-Mailer":"git-send-email 2.13.0","In-Reply-To":"<20170928044132.30940-1-saeedm@mellanox.com>","References":"<20170928044132.30940-1-saeedm@mellanox.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"From: Gal Pressman <galp@mellanox.com>\n\nInstead of calculating the offloads counters, count them explicitly.\nThe calculations done for these counters would result in bugs in some\ncases, for example:\nWhen running TCP traffic over a VXLAN tunnel with TSO enabled the following\ncounters would increase:\n       tx_csum_partial: 1,333,284\n       tx_csum_partial_inner: 29,286\n       tx4_csum_partial_inner: 384\n       tx7_csum_partial_inner: 8\n       tx9_csum_partial_inner: 34\n       tx10_csum_partial_inner: 26,807\n       tx11_csum_partial_inner: 287\n       tx12_csum_partial_inner: 27\n       tx16_csum_partial_inner: 6\n       tx25_csum_partial_inner: 1,733\n\nSeems like tx_csum_partial increased out of nowhere.\nThe issue is in the following calculation in mlx5e_update_sw_counters:\ns->tx_csum_partial = s->tx_packets - tx_offload_none - s->tx_csum_partial_inner;\n\nWhile tx_packets increases by the number of GSO segments for each SKB,\ntx_csum_partial_inner will only increase by one, resulting in wrong\ntx_csum_partial counter.\n\nFixes: bfe6d8d1d433 (\"net/mlx5e: Reorganize ethtool statistics\")\nSigned-off-by: Gal Pressman <galp@mellanox.com>\nSigned-off-by: Saeed Mahameed <saeedm@mellanox.com>\n---\n drivers/net/ethernet/mellanox/mlx5/core/en_main.c  | 9 +++------\n drivers/net/ethernet/mellanox/mlx5/core/en_rx.c    | 3 +++\n drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | 6 ++++++\n drivers/net/ethernet/mellanox/mlx5/core/en_tx.c    | 1 +\n 4 files changed, 13 insertions(+), 6 deletions(-)","diff":"diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c\nindex 84b013dc62e9..cc11bbbd0309 100644\n--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c\n+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c\n@@ -184,7 +184,6 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)\n \tstruct mlx5e_sw_stats temp, *s = &temp;\n \tstruct mlx5e_rq_stats *rq_stats;\n \tstruct mlx5e_sq_stats *sq_stats;\n-\tu64 tx_offload_none = 0;\n \tint i, j;\n \n \tmemset(s, 0, sizeof(*s));\n@@ -199,6 +198,7 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)\n \t\ts->rx_lro_bytes\t+= rq_stats->lro_bytes;\n \t\ts->rx_csum_none\t+= rq_stats->csum_none;\n \t\ts->rx_csum_complete += rq_stats->csum_complete;\n+\t\ts->rx_csum_unnecessary += rq_stats->csum_unnecessary;\n \t\ts->rx_csum_unnecessary_inner += rq_stats->csum_unnecessary_inner;\n \t\ts->rx_xdp_drop += rq_stats->xdp_drop;\n \t\ts->rx_xdp_tx += rq_stats->xdp_tx;\n@@ -229,14 +229,11 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)\n \t\t\ts->tx_queue_dropped\t+= sq_stats->dropped;\n \t\t\ts->tx_xmit_more\t\t+= sq_stats->xmit_more;\n \t\t\ts->tx_csum_partial_inner += sq_stats->csum_partial_inner;\n-\t\t\ttx_offload_none\t\t+= sq_stats->csum_none;\n+\t\t\ts->tx_csum_none\t\t+= sq_stats->csum_none;\n+\t\t\ts->tx_csum_partial\t+= sq_stats->csum_partial;\n \t\t}\n \t}\n \n-\t/* Update calculated offload counters */\n-\ts->tx_csum_partial = s->tx_packets - tx_offload_none - s->tx_csum_partial_inner;\n-\ts->rx_csum_unnecessary = s->rx_packets - s->rx_csum_none - s->rx_csum_complete;\n-\n \ts->link_down_events_phy = MLX5_GET(ppcnt_reg,\n \t\t\t\tpriv->stats.pport.phy_counters,\n \t\t\t\tcounter_set.phys_layer_cntrs.link_down_events);\ndiff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c\nindex f1dd638384d3..15a1687483cc 100644\n--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c\n+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c\n@@ -627,6 +627,7 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,\n \n \tif (lro) {\n \t\tskb->ip_summed = CHECKSUM_UNNECESSARY;\n+\t\trq->stats.csum_unnecessary++;\n \t\treturn;\n \t}\n \n@@ -644,7 +645,9 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,\n \t\t\tskb->csum_level = 1;\n \t\t\tskb->encapsulation = 1;\n \t\t\trq->stats.csum_unnecessary_inner++;\n+\t\t\treturn;\n \t\t}\n+\t\trq->stats.csum_unnecessary++;\n \t\treturn;\n \t}\n csum_none:\ndiff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h\nindex 6d199ffb1c0b..f8637213afc0 100644\n--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h\n+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h\n@@ -68,6 +68,7 @@ struct mlx5e_sw_stats {\n \tu64 rx_xdp_drop;\n \tu64 rx_xdp_tx;\n \tu64 rx_xdp_tx_full;\n+\tu64 tx_csum_none;\n \tu64 tx_csum_partial;\n \tu64 tx_csum_partial_inner;\n \tu64 tx_queue_stopped;\n@@ -108,6 +109,7 @@ static const struct counter_desc sw_stats_desc[] = {\n \t{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_drop) },\n \t{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_tx) },\n \t{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_tx_full) },\n+\t{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_none) },\n \t{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_partial) },\n \t{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_partial_inner) },\n \t{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_stopped) },\n@@ -339,6 +341,7 @@ struct mlx5e_rq_stats {\n \tu64 packets;\n \tu64 bytes;\n \tu64 csum_complete;\n+\tu64 csum_unnecessary;\n \tu64 csum_unnecessary_inner;\n \tu64 csum_none;\n \tu64 lro_packets;\n@@ -363,6 +366,7 @@ static const struct counter_desc rq_stats_desc[] = {\n \t{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, packets) },\n \t{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, bytes) },\n \t{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete) },\n+\t{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary) },\n \t{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary_inner) },\n \t{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_none) },\n \t{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, xdp_drop) },\n@@ -392,6 +396,7 @@ struct mlx5e_sq_stats {\n \tu64 tso_bytes;\n \tu64 tso_inner_packets;\n \tu64 tso_inner_bytes;\n+\tu64 csum_partial;\n \tu64 csum_partial_inner;\n \tu64 nop;\n \t/* less likely accessed in data path */\n@@ -408,6 +413,7 @@ static const struct counter_desc sq_stats_desc[] = {\n \t{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_bytes) },\n \t{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_inner_packets) },\n \t{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_inner_bytes) },\n+\t{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_partial) },\n \t{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_partial_inner) },\n \t{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, nop) },\n \t{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_none) },\ndiff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c\nindex fee43e40fa16..1d6925d4369a 100644\n--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c\n+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c\n@@ -193,6 +193,7 @@ mlx5e_txwqe_build_eseg_csum(struct mlx5e_txqsq *sq, struct sk_buff *skb, struct\n \t\t\tsq->stats.csum_partial_inner++;\n \t\t} else {\n \t\t\teseg->cs_flags |= MLX5_ETH_WQE_L4_CSUM;\n+\t\t\tsq->stats.csum_partial++;\n \t\t}\n \t} else\n \t\tsq->stats.csum_none++;\n","prefixes":["net","09/11"]}