Received: by 10.192.165.148 with SMTP id m20csp2586518imm; Thu, 26 Apr 2018 13:39:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/ld0nQ0RXg8TR05oiJkDPztSUFPDTNEBB3Ag3SmqDo3zNKaHZ5dVSyMDG3g36k4qLGfa9G X-Received: by 10.99.177.5 with SMTP id r5mr27847885pgf.186.1524775158031; Thu, 26 Apr 2018 13:39:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524775157; cv=none; d=google.com; s=arc-20160816; b=G2L7JBrbPw2DaiKSVFM8ACAEcberT/hF9L7wJdMcNBb50l7BDCNTJ0SSna8pzifj9p 2Oj9Vs3+QJ15A5oByoJRh3Kf/MqRc1uQNhe3alcYPyiyyzodjte6s5lk8CVAgOdyDtSk EF+bPDvfi8DXFCi2bCWIh/ER+KRovwp0imKLPN/1Owv0eHCP8wa6/FAJT6CghIGGV9Gl KgwlRnCgdWlFft8y2YCBmH8TszNA0JVPMU62jOI37hNWgSny/6TtoKUnRIkQ6NsKsDgz 3ZPArFPUNO621y356wV/J/KXmnOabYRVMh7IRZWNfqbiMddm1c4uiR/nMyWF8f2/F89l vbIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=wMaGQWtsNaPRfVCs44eEC1R/x0MtyTANQeOeUoJIUj4=; b=VE42elFH4J+7Be3Tg0c/ubMHVK6RW3I3OTbpL2oZIYqqIVJH+1lAt7iP0bHb5VYOwo sO30z9ETOoLkBYXteokojaSzsBMY0NXZ+O1supooV2w0BlLiHI5+XhvyZm7j9rqAEkjg OxSbNCE4TNmeT8Eg5b/aeOOvHv+DgeFEyn0YQKkf76GYqzKtT1cQEduLupeQfi9yXq5l eyylq4UFpmBsZvfAE4Jp87FKJvfLdNr1mrfoHHYJMlHKJhojpjnKgqLIyuNfZbSQVCWp sDFUH9/l6qYiCeD8Ie8uIB3aH+zYDl7V3oQDZKe15gbpXsyaiVIHz3PzL3fR4Ea07ByU dLfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Mhi+NcfW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c12-v6si6416685plr.467.2018.04.26.13.39.03; Thu, 26 Apr 2018 13:39:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Mhi+NcfW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756579AbeDZUhs (ORCPT + 99 others); Thu, 26 Apr 2018 16:37:48 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:47434 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753393AbeDZUhq (ORCPT ); Thu, 26 Apr 2018 16:37:46 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w3QKaVBT075221; Thu, 26 Apr 2018 20:37:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2017-10-26; bh=wMaGQWtsNaPRfVCs44eEC1R/x0MtyTANQeOeUoJIUj4=; b=Mhi+NcfWGibFfxJD/kq18u3xSN4zvrhziwTWPN7jYd8tOKj1sfvxy8EWAxKKU1L0ROri Oqg+HFKueYx5EE8GblxX3cpbYjYsuFj3Wi2lZJ2ffACIOxvg/oZV3TFphr7bUbUqUYTy PrRWN2Eh96Lj8sgAGRHufWhItOtfbKe8JVJNSE1o26IsXEh8ZTS1sxgnXw8uLW2OqJJs uKOtMPm6XzIi7O8gNeNowZHwCcMiGIh+xfUwJ5BvZcGCxnADC/rrI8uCsRbKUg7ctXDR mNZxT7/PNhvGl4pxY4yGnQMJ30fa6QpkLujX2nmhsNZBMfnpiVQ0hs+mfpDlnjgppX9i DQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2hfvrc4y52-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Apr 2018 20:37:40 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w3QKbd06017478 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Apr 2018 20:37:39 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w3QKbdgE012365; Thu, 26 Apr 2018 20:37:39 GMT Received: from qhuang-ol7-linux.us.oracle.com (/10.132.93.115) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 26 Apr 2018 13:37:39 -0700 From: Qing Huang To: linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org Cc: leon@kernel.org, matanb@mellanox.com, saeedm@mellanox.com, Qing Huang Subject: [PATCH] net/mlx5: report persistent netdev stats across ifdown/ifup commands Date: Thu, 26 Apr 2018 13:37:37 -0700 Message-Id: <1524775057-8012-1-git-send-email-qing.huang@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8875 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=948 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804260191 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Current stats collecting scheme in mlx5 driver is to periodically fetch aggregated stats from all the active mlx5 software channels associated with the device. However when a mlx5 interface is brought down(ifdown), all the channels will be deactivated and closed. A new set of channels will be created when next ifup command or a similar command is called. Unfortunately the new channels will have all stats reset to 0. So you lose the accumulated stats information. This behavior is different from other netdev drivers including the mlx4 driver. In order to fix it, we now save prior mlx5 software stats into netdev stats fields, so all the accumulated stats will survive multiple runs of ifdown/ifup commands and be shown correctly. Orabug: 27548610 Signed-off-by: Qing Huang --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 30 +++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index f1fe490..5d50e69 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -2621,6 +2621,23 @@ static void mlx5e_netdev_set_tcs(struct net_device *netdev) netdev_set_tc_queue(netdev, tc, nch, 0); } +static void mlx5e_netdev_save_stats(struct mlx5e_priv *priv) +{ + struct net_device *netdev = priv->netdev; + + netdev->stats.rx_packets += priv->stats.sw.rx_packets; + netdev->stats.rx_bytes += priv->stats.sw.rx_bytes; + netdev->stats.tx_packets += priv->stats.sw.tx_packets; + netdev->stats.tx_bytes += priv->stats.sw.tx_bytes; + netdev->stats.tx_dropped += priv->stats.sw.tx_queue_dropped; + + priv->stats.sw.rx_packets = 0; + priv->stats.sw.rx_bytes = 0; + priv->stats.sw.tx_packets = 0; + priv->stats.sw.tx_bytes = 0; + priv->stats.sw.tx_queue_dropped = 0; +} + static void mlx5e_build_channels_tx_maps(struct mlx5e_priv *priv) { struct mlx5e_channel *c; @@ -2691,6 +2708,7 @@ void mlx5e_switch_priv_channels(struct mlx5e_priv *priv, netif_set_real_num_tx_queues(netdev, new_num_txqs); mlx5e_deactivate_priv_channels(priv); + mlx5e_netdev_save_stats(priv); mlx5e_close_channels(&priv->channels); priv->channels = *new_chs; @@ -2770,6 +2788,7 @@ int mlx5e_close_locked(struct net_device *netdev) netif_carrier_off(priv->netdev); mlx5e_deactivate_priv_channels(priv); + mlx5e_netdev_save_stats(priv); mlx5e_close_channels(&priv->channels); return 0; @@ -3215,11 +3234,12 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type, stats->tx_packets = PPORT_802_3_GET(pstats, a_frames_transmitted_ok); stats->tx_bytes = PPORT_802_3_GET(pstats, a_octets_transmitted_ok); } else { - stats->rx_packets = sstats->rx_packets; - stats->rx_bytes = sstats->rx_bytes; - stats->tx_packets = sstats->tx_packets; - stats->tx_bytes = sstats->tx_bytes; - stats->tx_dropped = sstats->tx_queue_dropped; + stats->rx_packets = sstats->rx_packets + dev->stats.rx_packets; + stats->rx_bytes = sstats->rx_bytes + dev->stats.rx_bytes; + stats->tx_packets = sstats->tx_packets + dev->stats.tx_packets; + stats->tx_bytes = sstats->tx_bytes + dev->stats.tx_bytes; + stats->tx_dropped = sstats->tx_queue_dropped + + dev->stats.tx_dropped; } stats->rx_dropped = priv->stats.qcnt.rx_out_of_buffer; -- 1.8.3.1