Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4825011ybl; Wed, 22 Jan 2020 05:27:15 -0800 (PST) X-Google-Smtp-Source: APXvYqwjgy0XODALjrpX2mdn+QgYGuLfyVtsNcR2E4xEwyZp1TTw1ZzrRBue1AR3K7VWMROmpb// X-Received: by 2002:aca:b808:: with SMTP id i8mr6546804oif.66.1579699635703; Wed, 22 Jan 2020 05:27:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579699635; cv=none; d=google.com; s=arc-20160816; b=TYvqeGwwmq+ftqv5FUWkKd+KUOdFo6uOK2O5JC+OhxfCzjs7Q5C3+nDAtnewdgYH/d KXvJmB64hgAjaPMnExyB6yi2m73ca6FjtZlJhnsbCoQN0eASt0tXA+he6ZuLVkbl/pt5 AfiWIz7YV9pl+GCzG3jJZeZi9Cq93+wb35+7sCqAfN8nnnYWsFvBG/gpgC1q2ERIM241 T3ea5wofYgnvM7lpZ1ATqY/2Wscp+DUTomvxbf1ZFfwvo4UStoC4k312dGw4+PRUEUNs PZ85jspz1j9DnThm2sEPKdtKoLpCzostDqWg+C9MUZUks0Ece+U5dWzdk4OrXIhLz/GG nMdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4y7DUFsm1tkerRtpoi9i+BDteR53x32+hB4ZNVN+GNU=; b=QOmjiv37lqun1rTfqLzeVrOgPixY8fts9WeHZLxqmXl/SmlfkIpfkNHo4HtZH1Aspu EZ1z8UnC4hESW3AzOPD6OiNjiQsw31AMVlu/WOkrOdoulR+6XSzIKvQLwv/7cQd7CS7P zLrctus66DiZ+0rSJkVvCtyEOuEZBWs4d2+IsfOoB5ui85UqGjWdLeerr29BwaEiVddI yews7y9W4wI4GAt51hX0CpOpvZhtK8h9xxxY92vbPJFeA4ERshWUWXA7axBuvQVPqVBx C0k6fNHIf6K67BWHJv9oXmfCszsm2H3RWexYEnDZiTkTjpSRKtEXnwjnHTnOQJFtjv/x 52UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=afGH3CTA; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f21si23482274otp.56.2020.01.22.05.27.03; Wed, 22 Jan 2020 05:27:15 -0800 (PST) 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=@kernel.org header.s=default header.b=afGH3CTA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730572AbgAVNYx (ORCPT + 99 others); Wed, 22 Jan 2020 08:24:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:44166 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730589AbgAVNYv (ORCPT ); Wed, 22 Jan 2020 08:24:51 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0D6D424697; Wed, 22 Jan 2020 13:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699490; bh=1YzfcHjs92uvAFnhEsI/u9hRXryDJjS0n+AS3ZKt7l4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=afGH3CTAh4hIVJUmOnkCLubYuv9uOU3kl4pTQ5gh6XYhiaCTizAKAEzuwJKm4oRm6 CbHiDREuGTtXtvK2w3A8NgtZLyLY+meTgLMITMQRyGeUfSw5bHose5sXkW+VdZaVgc Dg4mtRycxo6vxCWQ1KWazedNQmjaCaGWqz5BG0Lg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Petr Machata , Jiri Pirko , Ido Schimmel , "David S. Miller" Subject: [PATCH 5.4 162/222] mlxsw: spectrum: Wipe xstats.backlog of down ports Date: Wed, 22 Jan 2020 10:29:08 +0100 Message-Id: <20200122092845.313521947@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Petr Machata commit ca7609ff3680c51d6c29897f3117aa2ad904f92a upstream. Per-port counter cache used by Qdiscs is updated periodically, unless the port is down. The fact that the cache is not updated for down ports is no problem for most counters, which are relative in nature. However, backlog is absolute in nature, and if there is a non-zero value in the cache around the time that the port goes down, that value just stays there. This value then leaks to offloaded Qdiscs that report non-zero backlog even if there (obviously) is no traffic. The HW does not keep backlog of a downed port, so do likewise: as the port goes down, wipe the backlog value from xstats. Fixes: 075ab8adaf4e ("mlxsw: spectrum: Collect tclass related stats periodically") Signed-off-by: Petr Machata Acked-by: Jiri Pirko Signed-off-by: Ido Schimmel Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -1161,6 +1161,9 @@ static void update_stats_cache(struct wo periodic_hw_stats.update_dw.work); if (!netif_carrier_ok(mlxsw_sp_port->dev)) + /* Note: mlxsw_sp_port_down_wipe_counters() clears the cache as + * necessary when port goes down. + */ goto out; mlxsw_sp_port_get_hw_stats(mlxsw_sp_port->dev, @@ -4170,6 +4173,15 @@ static int mlxsw_sp_port_unsplit(struct return 0; } +static void +mlxsw_sp_port_down_wipe_counters(struct mlxsw_sp_port *mlxsw_sp_port) +{ + int i; + + for (i = 0; i < TC_MAX_QUEUE; i++) + mlxsw_sp_port->periodic_hw_stats.xstats.backlog[i] = 0; +} + static void mlxsw_sp_pude_event_func(const struct mlxsw_reg_info *reg, char *pude_pl, void *priv) { @@ -4191,6 +4203,7 @@ static void mlxsw_sp_pude_event_func(con } else { netdev_info(mlxsw_sp_port->dev, "link down\n"); netif_carrier_off(mlxsw_sp_port->dev); + mlxsw_sp_port_down_wipe_counters(mlxsw_sp_port); } }