From patchwork Wed Jul 3 12:59:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Polchlopek X-Patchwork-Id: 1956233 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=nyDNGjle; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WDgF209N1z1xpN for ; Wed, 3 Jul 2024 23:12:54 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id C67E060EF5; Wed, 3 Jul 2024 13:12:50 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id OTCs0vvsW1iT; Wed, 3 Jul 2024 13:12:49 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 4074A60EE5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1720012369; bh=9KaU66tJnkFHxVYwNGGmcY/Uj7m/HarV11Qk7CWCZRo=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=nyDNGjlemL7PkZnnI/7Xs+q2MBWJ8jLGL2afht4AJm9aOMdmi/+g0r9guawGK4o7x w8XPJqhLYPG+dy/t+Ohm61OtFVboI879DZfKu/rHRTlYsGoqprRIu0WVDZ/C/xXx62 Oascr/Fc/qe/qkOcKDKZnO97dtSPLA52j+r0vzX4ymwfCnKRlIwyTxihlWLXShqy0V yTxG//K1EviZ4bJQZrrbswsMj4FX2C8T0Fb445K2Sv+k6rDMOlXIbQv2ov4M49I/dD Hou4Xn6J+caJD9SSCPx7qq+KKBN04Z7bXXx45B/G2PwlLKazNrU31U28GChfBstzau HssU1JVftbFGg== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 4074A60EE5; Wed, 3 Jul 2024 13:12:49 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 9FED01BF31B for ; Wed, 3 Jul 2024 13:12:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 8C8F24056B for ; Wed, 3 Jul 2024 13:12:43 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Vb3X-mJeWc9e for ; Wed, 3 Jul 2024 13:12:42 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=192.198.163.11; helo=mgamail.intel.com; envelope-from=mateusz.polchlopek@intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 7642A40498 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 7642A40498 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by smtp2.osuosl.org (Postfix) with ESMTPS id 7642A40498 for ; Wed, 3 Jul 2024 13:12:42 +0000 (UTC) X-CSE-ConnectionGUID: vdlCWXtSSTOBoQYn4IWvuQ== X-CSE-MsgGUID: M8vnpLM1RtynXsW0H9Q83g== X-IronPort-AV: E=McAfee;i="6700,10204,11121"; a="27857147" X-IronPort-AV: E=Sophos;i="6.09,182,1716274800"; d="scan'208";a="27857147" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2024 06:12:35 -0700 X-CSE-ConnectionGUID: h4paI16NSVaZ9zbM8ZjjRA== X-CSE-MsgGUID: cWdv3/j9TByEALayr0azhQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,182,1716274800"; d="scan'208";a="46321589" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmviesa010.fm.intel.com with ESMTP; 03 Jul 2024 06:12:32 -0700 Received: from fedora.igk.intel.com (Metan_eth.igk.intel.com [10.123.220.124]) by irvmail002.ir.intel.com (Postfix) with ESMTP id A0B812877D; Wed, 3 Jul 2024 14:12:30 +0100 (IST) From: Mateusz Polchlopek To: intel-wired-lan@lists.osuosl.org Date: Wed, 3 Jul 2024 08:59:20 -0400 Message-Id: <20240703125922.5625-5-mateusz.polchlopek@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20240703125922.5625-1-mateusz.polchlopek@intel.com> References: <20240703125922.5625-1-mateusz.polchlopek@intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1720012362; x=1751548362; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6YUvj8x7CBc4d6PYcb7HYz/bfW3oASOIRH1WMVTGBOA=; b=VdKqt2wWhBf5fc9rHHoXld9HUk+7nI0XNDwsXh8uEHB/Gu6SqcY1Y6w/ DhQatD3hWqnrPBaCo61q6opKASYKsHk2P5qGRpm8sOQQnMGJKOI0qi4dj tN0KKsATz6wi9eAG3Vrwix4DWRfB1+Nb1mLm0hbu8gk8Wv3PsC8IhD8Ou fpSxCQqbOiLB/3Hxf1ztuCcSBAHNJ4rQRKHNssa8AjhOBOWGUSrzFyyFY vNo9OQie9Qe7VGsr4E1B9IZmNIDthkp0yx6PSO1QvfoIF/72Czg0DYalk gMcsEJ33N8VMH9RKYB5E1IWzCbA3sZuDFi5pS0cIMqKMUOrJqNgKcwYPB Q==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=VdKqt2wW Subject: [Intel-wired-lan] [PATCH iwl-next v1 4/6] ice: print ethtool stats as part of Tx hang devlink health reporter X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: willemb@google.com, Wojciech Drewek , dwaipayanray1@gmail.com, Mateusz Polchlopek , linux-kernel@vger.kernel.org, Igor Bagnucki , joe@perches.com, edumazet@google.com, netdev@vger.kernel.org, apw@canonical.com, lukas.bulwahn@gmail.com, akpm@linux-foundation.org, Przemek Kitszel Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Przemek Kitszel Print the ethtool stats as part of Tx hang devlink health dump. Move the declarations of ethtool functions that devlink health uses out to a new file: ice_ethtool_common.h To utilize our existing ethtool code in this context, convert it to non-static. Signed-off-by: Przemek Kitszel Reviewed-by: Igor Bagnucki Reviewed-by: Wojciech Drewek Signed-off-by: Mateusz Polchlopek Reviewed-by: Simon Horman --- .../intel/ice/devlink/devlink_health.c | 32 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_ethtool.c | 10 +++--- drivers/net/ethernet/intel/ice/ice_ethtool.h | 2 ++ .../ethernet/intel/ice/ice_ethtool_common.h | 19 +++++++++++ 4 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_ethtool_common.h diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_health.c b/drivers/net/ethernet/intel/ice/devlink/devlink_health.c index 311719e69ea5..d6956bba1da2 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink_health.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink_health.c @@ -3,6 +3,7 @@ #include "devlink_health.h" #include "ice.h" +#include "ice_ethtool_common.h" #define ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, obj, name) \ devlink_fmsg_put(fmsg, #name, (obj)->name) @@ -32,6 +33,36 @@ static void ice_devlink_health_report(struct devlink_health_reporter *reporter, } } +static void ice_dump_ethtool_stats_to_fmsg(struct devlink_fmsg *fmsg, + struct net_device *netdev) +{ + const u32 string_set = ETH_SS_STATS; + u64 *stats; + u8 *names; + int scnt; + + scnt = ice_get_sset_count(netdev, string_set); + devlink_fmsg_put(fmsg, "stats-cnt", (u32)scnt); + if (scnt <= 0) + return; + + names = kcalloc(scnt, ETH_GSTRING_LEN, GFP_KERNEL); + stats = kcalloc(scnt, sizeof(*stats), GFP_KERNEL); + if (!names || !stats) + goto out; + + ice_get_strings(netdev, string_set, names); + ice_get_ethtool_stats(netdev, NULL, stats); + + devlink_fmsg_obj_nest_start(fmsg); + for (int i = 0; i < scnt; ++i) + devlink_fmsg_put(fmsg, &names[i * ETH_GSTRING_LEN], stats[i]); + devlink_fmsg_obj_nest_end(fmsg); +out: + kfree(names); + kfree(stats); +} + /** * ice_fmsg_put_ptr - put hex value of pointer into fmsg * @@ -77,6 +108,7 @@ static int ice_tx_hang_reporter_dump(struct devlink_health_reporter *reporter, devlink_fmsg_binary_pair_put(fmsg, "desc", event->tx_ring->desc, size_mul(event->tx_ring->count, sizeof(struct ice_tx_desc))); + ice_dump_ethtool_stats_to_fmsg(fmsg, event->tx_ring->vsi->netdev); devlink_fmsg_obj_nest_end(fmsg); return 0; diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c index d1940fc6f2f5..91f16396e20d 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c @@ -1522,7 +1522,7 @@ __ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data, } } -static void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data) +void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data) { struct ice_netdev_priv *np = netdev_priv(netdev); @@ -1900,7 +1900,7 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags) return ret; } -static int ice_get_sset_count(struct net_device *netdev, int sset) +int ice_get_sset_count(struct net_device *netdev, int sset) { switch (sset) { case ETH_SS_STATS: @@ -2003,9 +2003,9 @@ __ice_get_ethtool_stats(struct net_device *netdev, } } -static void -ice_get_ethtool_stats(struct net_device *netdev, - struct ethtool_stats __always_unused *stats, u64 *data) +void ice_get_ethtool_stats(struct net_device *netdev, + struct ethtool_stats __always_unused *stats, + u64 *data) { struct ice_netdev_priv *np = netdev_priv(netdev); diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.h b/drivers/net/ethernet/intel/ice/ice_ethtool.h index 9acccae38625..fd021d2813f8 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.h +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.h @@ -4,6 +4,8 @@ #ifndef _ICE_ETHTOOL_H_ #define _ICE_ETHTOOL_H_ +#include "ice_ethtool_common.h" + struct ice_phy_type_to_ethtool { u64 aq_link_speed; u8 link_mode; diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool_common.h b/drivers/net/ethernet/intel/ice/ice_ethtool_common.h new file mode 100644 index 000000000000..0c772056f006 --- /dev/null +++ b/drivers/net/ethernet/intel/ice/ice_ethtool_common.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2024, Intel Corporation. */ + +#ifndef _ICE_ETHTOOL_COMMON_H_ +#define _ICE_ETHTOOL_COMMON_H_ + +/** + * DOC: ice_ethtool_common.h + * + * This header is for ethtool related code that is reused in other places. + */ + +void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data); +int ice_get_sset_count(struct net_device *netdev, int sset); +void ice_get_ethtool_stats(struct net_device *netdev, + struct ethtool_stats __always_unused *stats, + u64 *data); + +#endif /* _ICE_ETHTOOL_COMMON_H_ */