From patchwork Fri Jul 12 09:32:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Polchlopek X-Patchwork-Id: 1959743 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=r9pvLeu2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (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 4WL6CH33VZz1xqj for ; Fri, 12 Jul 2024 19:45:15 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 34EFD41461; Fri, 12 Jul 2024 09:45:07 +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 dqz6tUm_jaBD; Fri, 12 Jul 2024 09:45:06 +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 smtp2.osuosl.org 595B341467 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1720777506; bh=MWaeV7ZFlHeNVKEFUxwFinzc/0yWkpqwK6w72e9pDJg=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=r9pvLeu2oS+pL/5De9dqnjwkCh0MxKMlN+cV31Hq6IXMwGXyzrISxCiaBrXuXj1Oh LEAlqVIfHVrEaN5plOcs5xXuU3lftzO+AgAa1gmCvKSMpXN7k35PBLlqP3lQW7gA/V hJjLv1vUflaUXfl4OHO1qIuzYrlZ7+ve1mH0UyGM4rtdYRZpbhkE2kE9AeYOG6rqK0 5aHa3u776dyfU0I6qcLwrFSDMi1yhQqW6WJMzOa9aQaj+yMlf+zBZJd9SHQDj4t7ME e1fUoFLqLHvUvzKJCOEUkNCwcKB2rTPPb0kNrcWolIqS7JWaM52j0MT+5075Dv3nh9 gQtmEuN9cGbRw== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id 595B341467; Fri, 12 Jul 2024 09:45:06 +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 173BC1BF5A9 for ; Fri, 12 Jul 2024 09:44:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 72C3B412E8 for ; Fri, 12 Jul 2024 09:44:58 +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 6UBxWZXAr_oq for ; Fri, 12 Jul 2024 09:44:56 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=192.198.163.17; helo=mgamail.intel.com; envelope-from=mateusz.polchlopek@intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org B1F2F41433 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org B1F2F41433 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by smtp2.osuosl.org (Postfix) with ESMTPS id B1F2F41433 for ; Fri, 12 Jul 2024 09:44:56 +0000 (UTC) X-CSE-ConnectionGUID: MfUGcqyNSe2vVbauEm7wqQ== X-CSE-MsgGUID: C9ssapZUSQKXGBfmlkLVQA== X-IronPort-AV: E=McAfee;i="6700,10204,11130"; a="18076985" X-IronPort-AV: E=Sophos;i="6.09,202,1716274800"; d="scan'208";a="18076985" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2024 02:44:56 -0700 X-CSE-ConnectionGUID: SkVpG3jGQG+ZVlZBMcwM1w== X-CSE-MsgGUID: oLY91aF5SAa51ao3YC9fWQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,202,1716274800"; d="scan'208";a="49524314" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa007.jf.intel.com with ESMTP; 12 Jul 2024 02:44:52 -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 1D6ED2F1F; Fri, 12 Jul 2024 10:44:50 +0100 (IST) From: Mateusz Polchlopek To: intel-wired-lan@lists.osuosl.org Date: Fri, 12 Jul 2024 05:32:49 -0400 Message-Id: <20240712093251.18683-5-mateusz.polchlopek@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20240712093251.18683-1-mateusz.polchlopek@intel.com> References: <20240712093251.18683-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=1720777497; x=1752313497; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AzEg1UCC/dP12DnBBLeMU5IhLxJ7HG62/flm+CPRQxw=; b=HjD2ZD5nerIhQifaGhkuynnk7GonI2ZNLbS4H/gPoRJvALNsV7zs6e6j rzBncMYwpSAQ3mMP80BjFhGkLxbvK7uBVGJemLZ1MAcbwrglO4fDiEhBN K61M1jYM24CUwRGb6AdwvzCzj5hkhhRWSmueSUIcsOQRw+YBnIXqkA9rY WjnpINhEQb8QfvSGVOe+4CIxHiD9TNdAVwCu1wTkmqxFB1j1OLUH0jtEu 4tLfDmPRJNbaZLCv391uT8+6NtT3BMibSi/NkCAnY3oplK1foIIVkjmMs vgkeiVS5WVrwZ1K6902jn4jMVGXrgH0VPtXx7mJc+xZUNYDIpntvh/uPK A==; 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=HjD2ZD5n Subject: [Intel-wired-lan] [PATCH iwl-next v2 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, Simon Horman , 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 Reviewed-by: Simon Horman Signed-off-by: Mateusz Polchlopek --- .../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 41f203cbdf6a..2fbf6f08d0f6 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 * @@ -76,6 +107,7 @@ static int ice_tx_hang_reporter_dump(struct devlink_health_reporter *reporter, ice_fmsg_put_ptr(fmsg, "dma-ptr", (void *)(long)event->tx_ring->dma); devlink_fmsg_binary_pair_put(fmsg, "desc", event->tx_ring->desc, (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 39d2652c3ee1..bc431e692b28 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c @@ -1519,7 +1519,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); @@ -1897,7 +1897,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: @@ -2000,9 +2000,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_ */