From patchwork Wed Dec 11 22:32:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13904298 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DEB1204696 for ; Wed, 11 Dec 2024 22:32:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733956366; cv=none; b=PVf3/U9uYCT80JTby8l42LCD5HdxKKdUZM3pQ60L8xnnXKe5NhtybXIRdied6OhFYodLyNyGEQHLY2nPGk+Qr2fu/K8S1k0SWlWeZi0GlDeVqVoPhUffpvxlmahcOMx/VNs6yNST+MiH8WkSBsBkquvT8WVCQ26Bp1U02dn/cG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733956366; c=relaxed/simple; bh=NAS07V7tLD1XfiI4DKCY3VyAD0Y/heRVWRFjSiwpAnA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C1skGLY6EAYkAR0//AB1xvOPnZ0IKWFvfpYjBxTkh5LfKLm417e94AitriVlC9SDEqwMiKpzPDDeCxJyf7qzggI9THPf4TGjvcLJlRvQeHHw+QLOIVk0ozfa697NgO8Le0dWAZn4RZjEBuw9tnFOMUR28WBwS8LogssdfnjU02U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=A76p09v3; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="A76p09v3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733956364; x=1765492364; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NAS07V7tLD1XfiI4DKCY3VyAD0Y/heRVWRFjSiwpAnA=; b=A76p09v3qFlMeWeI9Fna3Jz44kPFDDf9iYjPjKhJGy9EqQGuL46ryyGA +VHDuSyDTBuFmPBarbOoOB/HIqlpWPmBCP0RVaWoOSb7u/M1jv9I2dl6e 4hL2EHlybaHnoSTBTlHmzWV5PAp0hgKcj+0Ej1ae4pXUklJXd/nXv6van 6O6+oo5EDBzRrgNLwfWM33Wu5yaTTnaQjv56yVv+3E3n3bQZ78Q0N1OnC DB+wfOvI9YCWZaQNb36wRBKAWKAV4AbQd7RR+r1QGRPKAuSFjxsQAMH+3 6DjbxIAcPe3pcqOvwKpj4u3QXJr5jdWCl5OYJqHdZtWfa2CppGpstYEzg g==; X-CSE-ConnectionGUID: CVBkTPOqT6+d67ZM1aI0VA== X-CSE-MsgGUID: Mfbif+sHS3+YkyMbHnPIkQ== X-IronPort-AV: E=McAfee;i="6700,10204,11283"; a="34599652" X-IronPort-AV: E=Sophos;i="6.12,226,1728975600"; d="scan'208";a="34599652" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2024 14:32:41 -0800 X-CSE-ConnectionGUID: xA9VdtGNTd+KwaceDJSNLQ== X-CSE-MsgGUID: 8k2c/X5xRLKkfuX/wqcECQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,226,1728975600"; d="scan'208";a="96192944" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by fmviesa008.fm.intel.com with ESMTP; 11 Dec 2024 14:32:40 -0800 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, andrew+netdev@lunn.ch, netdev@vger.kernel.org Cc: Przemek Kitszel , anthony.l.nguyen@intel.com, wojciech.drewek@intel.com, mateusz.polchlopek@intel.com, joe@perches.com, horms@kernel.org, jiri@resnulli.us, apw@canonical.com, lukas.bulwahn@gmail.com, dwaipayanray1@gmail.com, Igor Bagnucki , Pucha Himasekhar Reddy Subject: [PATCH net-next 6/7] ice: dump ethtool stats and skb by Tx hang devlink health reporter Date: Wed, 11 Dec 2024 14:32:14 -0800 Message-ID: <20241211223231.397203-7-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241211223231.397203-1-anthony.l.nguyen@intel.com> References: <20241211223231.397203-1-anthony.l.nguyen@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Przemek Kitszel Print the ethtool stats and skb diagnostic information 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. Reviewed-by: Igor Bagnucki Reviewed-by: Wojciech Drewek Reviewed-by: Simon Horman Signed-off-by: Mateusz Polchlopek Tested-by: Pucha Himasekhar Reddy (A Contingent worker at Intel) Signed-off-by: Przemek Kitszel Signed-off-by: Tony Nguyen --- .../net/ethernet/intel/ice/devlink/health.c | 36 +++++++++++++++++++ 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, 62 insertions(+), 5 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_ethtool_common.h diff --git a/drivers/net/ethernet/intel/ice/devlink/health.c b/drivers/net/ethernet/intel/ice/devlink/health.c index b8c5a1c372dc..b0abb6d4e3e4 100644 --- a/drivers/net/ethernet/intel/ice/devlink/health.c +++ b/drivers/net/ethernet/intel/ice/devlink/health.c @@ -3,6 +3,7 @@ #include "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) @@ -26,6 +27,36 @@ static void ice_devlink_health_report(struct devlink_health_reporter *reporter, devlink_health_report(reporter, msg, priv_ctx); } +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 * @@ -57,10 +88,12 @@ static int ice_tx_hang_reporter_dump(struct devlink_health_reporter *reporter, struct netlink_ext_ack *extack) { struct ice_tx_hang_event *event = priv_ctx; + struct sk_buff *skb; if (!event) return 0; + skb = event->tx_ring->tx_buf->skb; devlink_fmsg_obj_nest_start(fmsg); ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, event, head); ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, event, intr); @@ -71,8 +104,11 @@ static int ice_tx_hang_reporter_dump(struct devlink_health_reporter *reporter, devlink_fmsg_put(fmsg, "irq-mapping", event->tx_ring->q_vector->name); ice_fmsg_put_ptr(fmsg, "desc-ptr", event->tx_ring->desc); ice_fmsg_put_ptr(fmsg, "dma-ptr", (void *)(long)event->tx_ring->dma); + ice_fmsg_put_ptr(fmsg, "skb-ptr", skb); devlink_fmsg_binary_pair_put(fmsg, "desc", event->tx_ring->desc, event->tx_ring->count * sizeof(struct ice_tx_desc)); + devlink_fmsg_dump_skb(fmsg, skb); + 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 3072634bf049..b552439fc1f9 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c @@ -1507,7 +1507,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); @@ -1887,7 +1887,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: @@ -1990,9 +1990,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 8f2ad1c172c0..a1a34440557d 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_ */