From patchwork Fri Jan 15 13:46:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 1427011 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DHMvc3D9Rz9sjB; Sat, 16 Jan 2021 00:48:11 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1l0PSP-0005SC-9V; Fri, 15 Jan 2021 13:48:05 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l0PSN-0005Rz-V4 for kernel-team@lists.ubuntu.com; Fri, 15 Jan 2021 13:48:03 +0000 Received: from mail-qk1-f199.google.com ([209.85.222.199]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l0PQg-0005EF-DU for kernel-team@lists.ubuntu.com; Fri, 15 Jan 2021 13:46:30 +0000 Received: by mail-qk1-f199.google.com with SMTP id y187so7992445qke.20 for ; Fri, 15 Jan 2021 05:46:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6lJJRLsZIfBSr8mLQwifNlREhXYgL4iXDYU0+imQijE=; b=Xpgh14HsIzoVFNQU9LUMdDbGtJrhuWNL/M2dTRbe2Eew6nYC0NgXlNZILJlcRKICNc BFjlRU0/jYhzfm0bu+AleIHFWP4uCHoGhqZ4yf1AcL5M9Lti3CmgYERhJfugYAHEMxTr LK8xyqWq3oHSfUEcWEkvhi0cvmWPHT0sx9XiIuHSvu9jAzSEFCZuVQjOPy4UdXW7elqz q1eyULf1slyVpPm+61PbFvljT2gwkOB6Hk8f/CWN6a5lMwjxJEPUCLMZbFNObaVdhnmZ neJ9+ZMGBrY/UMcOfo+4XJ0ZDBCpkkPjeVyBNkRCvrld3kyLCejgQGhrWoBzTIjEsZkY MtLQ== X-Gm-Message-State: AOAM5331d0OPieax7IGmsAihXBhJDqh2txdF6OKQoOYHl64NFBjkTIye VUqlp01qaYCis8L67LhgLW6QjppYl7rqVZTp+FjCylkB44/8FuY78OHfWF6PegwQhfAZBVqO76m S+/aU/vvkhBbKhj2Atpw8xIuKErn6npUS63dyDinjLw== X-Received: by 2002:a37:66ce:: with SMTP id a197mr12255942qkc.312.1610718377326; Fri, 15 Jan 2021 05:46:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIw5WgopYI/WnX7AoBr4L3b9isZGFCKE3TgvDsJ4voxaITSX3m5doFDdZxi6ajyiy8z7JLtg== X-Received: by 2002:a37:66ce:: with SMTP id a197mr12255914qkc.312.1610718377031; Fri, 15 Jan 2021 05:46:17 -0800 (PST) Received: from localhost.localdomain ([193.27.12.132]) by smtp.gmail.com with ESMTPSA id 9sm5096506qke.123.2021.01.15.05.46.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 05:46:16 -0800 (PST) From: William Breathitt Gray To: kernel-team@lists.ubuntu.com Subject: [SRU][F][PATCH 1/1] net/mlx5e: Fix multicast counter not up-to-date in "ip -s" Date: Fri, 15 Jan 2021 08:46:09 -0500 Message-Id: <20210115134610.21268-2-william.gray@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210115134610.21268-1-william.gray@canonical.com> References: <20210115134610.21268-1-william.gray@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Ron Diskin BugLink: https://bugs.launchpad.net/bugs/1901842 Currently the FW does not generate events for counters other than error counters. Unlike ".get_ethtool_stats", ".ndo_get_stats64" (which ip -s uses) might run in atomic context, while the FW interface is non atomic. Thus, 'ip' is not allowed to issue FW commands, so it will only display cached counters in the driver. Add a SW counter (mcast_packets) in the driver to count rx multicast packets. The counter also counts broadcast packets, as we consider it a special case of multicast. Use the counter value when calling "ip -s"/"ifconfig". Fixes: f62b8bb8f2d3 ("net/mlx5: Extend mlx5_core to support ConnectX-4 Ethernet functionality") Signed-off-by: Ron Diskin Reviewed-by: Tariq Toukan Reviewed-by: Moshe Shemesh Signed-off-by: Saeed Mahameed (backported from commit 47c97e6b10a1e3680cad539929da092bfa535446) [ vilhelmgray: context adjustments ] Signed-off-by: William Breathitt Gray --- drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h | 5 +++++ drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 8 +------- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 4 ++++ drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | 2 ++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h index f07b1399744e..b6418823c63a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h @@ -27,6 +27,11 @@ #define INL_HDR_START_SZ (sizeof(((struct mlx5_wqe_eth_seg *)NULL)->inline_hdr.start)) +static inline bool mlx5e_skb_is_multicast(struct sk_buff *skb) +{ + return skb->pkt_type == PACKET_MULTICAST || skb->pkt_type == PACKET_BROADCAST; +} + static inline bool mlx5e_wqc_has_room_for(struct mlx5_wq_cyc *wq, u16 cc, u16 pc, u16 n) { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 8b8581f71e79..24fc71116f48 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3629,6 +3629,7 @@ void mlx5e_fold_sw_stats64(struct mlx5e_priv *priv, struct rtnl_link_stats64 *s) s->rx_packets += rq_stats->packets + xskrq_stats->packets; s->rx_bytes += rq_stats->bytes + xskrq_stats->bytes; + s->multicast += rq_stats->mcast_packets + xskrq_stats->mcast_packets; for (j = 0; j < priv->max_opened_tc; j++) { struct mlx5e_sq_stats *sq_stats = &channel_stats->sq[j]; @@ -3644,7 +3645,6 @@ void mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) { struct mlx5e_priv *priv = netdev_priv(dev); - struct mlx5e_vport_stats *vstats = &priv->stats.vport; struct mlx5e_pport_stats *pstats = &priv->stats.pport; /* In switchdev mode, monitor counters doesn't monitor @@ -3679,12 +3679,6 @@ mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) stats->rx_errors = stats->rx_length_errors + stats->rx_crc_errors + stats->rx_frame_errors; stats->tx_errors = stats->tx_aborted_errors + stats->tx_carrier_errors; - - /* vport multicast also counts packets that are dropped due to steering - * or rx out of buffer - */ - stats->multicast = - VPORT_COUNTER_GET(vstats, received_eth_multicast.packets); } static void mlx5e_set_rx_mode(struct net_device *dev) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index 066bada4ccd1..386f49949a23 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -49,6 +49,7 @@ #include "en/xdp.h" #include "en/xsk/rx.h" #include "en/health.h" +#include "en/txrx.h" static inline bool mlx5e_rx_hw_stamp(struct hwtstamp_config *config) { @@ -1022,6 +1023,9 @@ static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe, mlx5e_enable_ecn(rq, skb); skb->protocol = eth_type_trans(skb, netdev); + + if (unlikely(mlx5e_skb_is_multicast(skb))) + stats->mcast_packets++; } static inline void mlx5e_complete_rx_cqe(struct mlx5e_rq *rq, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h index 869f3502f631..f19329039f5a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h @@ -68,6 +68,7 @@ struct mlx5e_sw_stats { u64 tx_nop; u64 rx_lro_packets; u64 rx_lro_bytes; + u64 rx_mcast_packets; u64 rx_ecn_mark; u64 rx_removed_vlan_packets; u64 rx_csum_unnecessary; @@ -235,6 +236,7 @@ struct mlx5e_rq_stats { u64 csum_none; u64 lro_packets; u64 lro_bytes; + u64 mcast_packets; u64 ecn_mark; u64 removed_vlan_packets; u64 xdp_drop;