From patchwork Wed Dec 11 22:32:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13904293 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 C2F37203D42 for ; Wed, 11 Dec 2024 22:32:39 +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=1733956361; cv=none; b=PwYlQbe8/rJ0UgXiN4vHvpCepzOYp5YTKxFcTtrEsJTY8rBOz5fSyMS6wsS/98bCvSAzDMHGGxB/KWNi4aS0mMI4EFvXx5/MRcRlM74nInXOCPg9U+nPZ4UUQ7DxeZVzoVIODw/TtX8MfQOvOMgDzVOmSSFuF2LPKAhswFQzR/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733956361; c=relaxed/simple; bh=v1jgyJaEIdY+KSakjWhz+KYH00QDygQdpDx5SSwYOh8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T6n/mXTSYz3KsDA48Bg+0LbQg1aFHANxSu+mE5Tqk4A4NXkCgDhCYJ7N5LR37xyX4xjUclS3QldjG8I6NdRPLjcwliRMmbkub5Sy1GXdrvvFy53xyo6/ew4BQoHagR9T8gCZT4d8cBryb42aWHviZfzN3VNAzkTYL+tazCKOMvE= 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=KGCc51IP; 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="KGCc51IP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733956359; x=1765492359; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v1jgyJaEIdY+KSakjWhz+KYH00QDygQdpDx5SSwYOh8=; b=KGCc51IPXqTWvtcvHC5lJk1MbXRu2tAU9YjmDbZ+MU3puLPB2To0tfKR jcPKpfLccnqsPe5AqA5DznabxtoKel+7AQheNnvmJ5xHbqtig/alWIwK3 ljf8D7F/0u7w8TBwUwHp8oPbKRrIDLrzYZfC1Y2IbKweV6pVD5wIWANvN RpnmnzkZhSggXQ6lwlogriA5H8M9G5sp/DBIHuflHfu0YO/33nGn/opZZ aLecDjNh7K+6M7VRa+14x3YPKnuatfuyMkHSrS/QXBCFfENcciJkvZYkH oyLY5dlFaCE1aHRc0jCogFtDM8Sl2CxKunXIkS1byjvLOjbPLckSC/vYJ Q==; X-CSE-ConnectionGUID: EFrb9xyVQdyShBCGm/F/dg== X-CSE-MsgGUID: u6YzX9cISCGHRH1TCybXSQ== X-IronPort-AV: E=McAfee;i="6700,10204,11283"; a="34599599" X-IronPort-AV: E=Sophos;i="6.12,226,1728975600"; d="scan'208";a="34599599" 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:38 -0800 X-CSE-ConnectionGUID: kbylXcSqQ0aOWpGFRdXOuA== X-CSE-MsgGUID: jnmPdLJZQkG0u1fzehHmBQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,226,1728975600"; d="scan'208";a="96192924" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by fmviesa008.fm.intel.com with ESMTP; 11 Dec 2024 14:32:38 -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 Subject: [PATCH net-next 1/7] checkpatch: don't complain on _Generic() use Date: Wed, 11 Dec 2024 14:32:09 -0800 Message-ID: <20241211223231.397203-2-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 Improve CamelCase recognition logic to avoid reporting on _Generic() use. Other C keywords, such as _Bool, are intentionally omitted, as those should be rather avoided in new source code. Reviewed-by: Wojciech Drewek Reviewed-by: Simon Horman Signed-off-by: Mateusz Polchlopek Signed-off-by: Przemek Kitszel Signed-off-by: Tony Nguyen --- scripts/checkpatch.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 9eed3683ad76..a2066a6c9dd8 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5843,6 +5843,8 @@ sub process { #CamelCase if ($var !~ /^$Constant$/ && $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && +#Ignore C keywords + $var !~ /^_Generic$/ && #Ignore some autogenerated defines and enum values $var !~ /^(?:[A-Z]+_){1,5}[A-Z]{1,3}[a-z]/ && #Ignore Page variants From patchwork Wed Dec 11 22:32:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13904296 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 28D2D20456D for ; Wed, 11 Dec 2024 22:32:40 +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=1733956364; cv=none; b=dlzdZbbnZX9QLUDDbLNukN8QOXMOTsH0kXddJMWkMw+SlzvAzy53WAW06JhipHEqec9z6/RMSGjZjBTL1VUKkoAAocQxzg2lvSj5nZA2Eu6udjD3Gm88WcXcBAf0aJb0MF9+KFnzjOL9Dbhtp8YQYJLEBB71NF/j3GkAqT+XSMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733956364; c=relaxed/simple; bh=/ipPID80lOfWAtFE1JfuL0fyBRP0NPdvpji+0aqWNPE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TAcrL5rxfQz+0xC6Gm+fW57NhKDaJysmQM1zHDnH/ydnmZN+sSgiuVo+mW76Rb/wxWge1/JWM9Y9B9s/zy108g65DuIMt0HLdXXX+tPp+YpagkGn/wcivYGd2uNM5JvezPISOpHWN8jXVcZB2BjQnsOkHe8uNHqkpQ8s9PEUx7M= 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=CzS40reN; 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="CzS40reN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733956362; x=1765492362; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/ipPID80lOfWAtFE1JfuL0fyBRP0NPdvpji+0aqWNPE=; b=CzS40reNhYu4NllpfcQRY0WFRXLdI77ArKQobV6kLvfLyxqh1O1B6+eE aI9uAWKlm9JIRcM+MFH6eLls7G7vYjXVr1rF6TMM4stwb2oD+yOcgyUDv g5YfoUd3PNHlJ5mjpOBgYux15qamwHVwoW88NGBZLCWtJcszHNHfoTldG 2LryY+PS+6QhAT4sm/wsloD4nqeutg0+enSPZZ1xne6og/F6BqzCu6bXx XVaHWlP7nc49cWGSHILuGPLzUNchOuFkfmZov5hptC/bw6d3qL5WZywe7 20earpXjeuz6VFB8YWMaCsT42YR8wlqILKhzkY2D68RdF9uhaJFvfffg0 A==; X-CSE-ConnectionGUID: zgdV5ADgTEOZOn7g5etTHw== X-CSE-MsgGUID: ESDQTxSoShykgFwHVSZnZA== X-IronPort-AV: E=McAfee;i="6700,10204,11283"; a="34599609" X-IronPort-AV: E=Sophos;i="6.12,226,1728975600"; d="scan'208";a="34599609" 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:39 -0800 X-CSE-ConnectionGUID: XblL9bgDSTCl0iaNTd3EXg== X-CSE-MsgGUID: 1Eu75P+yQxGkW0XzX7eFWg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,226,1728975600"; d="scan'208";a="96192929" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by fmviesa008.fm.intel.com with ESMTP; 11 Dec 2024 14:32:38 -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, Pucha Himasekhar Reddy Subject: [PATCH net-next 2/7] devlink: add devlink_fmsg_put() macro Date: Wed, 11 Dec 2024 14:32:10 -0800 Message-ID: <20241211223231.397203-3-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 Add devlink_fmsg_put() that dispatches based on the type of the value to put, example: bool -> devlink_fmsg_bool_pair_put(). 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 --- include/net/devlink.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/net/devlink.h b/include/net/devlink.h index fbb9a2668e24..b5e1427ea4d7 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1261,6 +1261,17 @@ enum devlink_trap_group_generic_id { .min_burst = _min_burst, \ } +#define devlink_fmsg_put(fmsg, name, value) ( \ + _Generic((value), \ + bool : devlink_fmsg_bool_pair_put, \ + u8 : devlink_fmsg_u8_pair_put, \ + u16 : devlink_fmsg_u32_pair_put, \ + u32 : devlink_fmsg_u32_pair_put, \ + u64 : devlink_fmsg_u64_pair_put, \ + char * : devlink_fmsg_string_pair_put, \ + const char * : devlink_fmsg_string_pair_put) \ + (fmsg, name, (value))) + enum { /* device supports reload operations */ DEVLINK_F_RELOAD = 1UL << 0, From patchwork Wed Dec 11 22:32:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13904294 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 5815E203D6F for ; Wed, 11 Dec 2024 22:32:41 +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=1733956363; cv=none; b=Z1oKb8Ls12IT5FAOG7yIwd7G9BSSs6H0pqN6gskLFO6+rjy58wxoHFAO2G45JoG2lzOxtZbinwHWxBv9K+KNEmby8Vy0OsJI7Yl0xf+VzlKHGAtOavH9pVWFHDP4k4lGZ2p41/YFwoqJHm5cFqLgjnL6p6waDKkGifPrKtAXCyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733956363; c=relaxed/simple; bh=q5/jvoaAbVEVFmIuKVFj5pGMb4F+0KO21MYcpSLKILs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f/vNzv6FQsy2eiIx8XX2PFCwAeComyR2L6NkpgEa6qI7nlvw/tvZ37D2X4S39gSSaS6OoPjf1a1Az9VC/g5MPCXwFn/+p6PfH2d20k7dAoT+PzDeSaTl2GrOQ2ope9in6wrhejU83H9CYFoqPDyZbukewZ6hlrZ5KpysTyGDLMk= 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=Ll/EvduN; 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="Ll/EvduN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733956361; x=1765492361; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q5/jvoaAbVEVFmIuKVFj5pGMb4F+0KO21MYcpSLKILs=; b=Ll/EvduNhQ9LzgUt6/Io5Ojwm+AuWXyHG/ntSKiPVDJI+mJm4dy3IIJ4 GYvvVTowzrl2/ZFksKkMvEq09uxeBZHZXLMRdbiAskTxKGHVoxcQFMdb7 5SHecTkuPvtVoLviAOrdF0sMIynrIjkeBZu6UEYSKNR7wI+ePpreA2PnA 2yML6p440bsfeIPt4ec6XNOzc1QQiqOqv8blceC4o0BLOtPfpHyPleF90 2tNzhloeZQOurHWAQoU2j3A5lsrkAiHrF1w7B8ayYWIQkG1LYBJrdpaj9 /nNOYsjAiHx5jhm5Lw/cIWojRJ3zUYy9vL0y8Il1r3axT8hn1PN1PthUz w==; X-CSE-ConnectionGUID: gHibzICZQX6Bs5nJYcfZ/A== X-CSE-MsgGUID: ro3eMWB1SbiYaRE+6mqz5g== X-IronPort-AV: E=McAfee;i="6700,10204,11283"; a="34599620" X-IronPort-AV: E=Sophos;i="6.12,226,1728975600"; d="scan'208";a="34599620" 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:39 -0800 X-CSE-ConnectionGUID: iPcNF0jYRaOKFgwvPL8bUQ== X-CSE-MsgGUID: 7Jp5yDcOTiGV65R4XRGHRg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,226,1728975600"; d="scan'208";a="96192933" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by fmviesa008.fm.intel.com with ESMTP; 11 Dec 2024 14:32:39 -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: Mateusz Polchlopek , anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, wojciech.drewek@intel.com, joe@perches.com, horms@kernel.org, jiri@resnulli.us, apw@canonical.com, lukas.bulwahn@gmail.com, dwaipayanray1@gmail.com, Pucha Himasekhar Reddy Subject: [PATCH net-next 3/7] devlink: add devlink_fmsg_dump_skb() function Date: Wed, 11 Dec 2024 14:32:11 -0800 Message-ID: <20241211223231.397203-4-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: Mateusz Polchlopek Add devlink_fmsg_dump_skb() function that adds some diagnostic information about skb (like length, pkt type, MAC, etc) to devlink fmsg mechanism using bunch of devlink_fmsg_put() function calls. 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 --- include/net/devlink.h | 2 ++ net/devlink/health.c | 67 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/include/net/devlink.h b/include/net/devlink.h index b5e1427ea4d7..58e33959c852 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1268,6 +1268,7 @@ enum devlink_trap_group_generic_id { u16 : devlink_fmsg_u32_pair_put, \ u32 : devlink_fmsg_u32_pair_put, \ u64 : devlink_fmsg_u64_pair_put, \ + int : devlink_fmsg_u32_pair_put, \ char * : devlink_fmsg_string_pair_put, \ const char * : devlink_fmsg_string_pair_put) \ (fmsg, name, (value))) @@ -2005,6 +2006,7 @@ int devlink_compat_switch_id_get(struct net_device *dev, int devlink_nl_port_handle_fill(struct sk_buff *msg, struct devlink_port *devlink_port); size_t devlink_nl_port_handle_size(struct devlink_port *devlink_port); +void devlink_fmsg_dump_skb(struct devlink_fmsg *fmsg, const struct sk_buff *skb); #else diff --git a/net/devlink/health.c b/net/devlink/health.c index b8d3084e6fe0..57db6799722a 100644 --- a/net/devlink/health.c +++ b/net/devlink/health.c @@ -1238,3 +1238,70 @@ int devlink_nl_health_reporter_test_doit(struct sk_buff *skb, return reporter->ops->test(reporter, info->extack); } + +/** + * devlink_fmsg_dump_skb - Dump sk_buffer structure + * @fmsg: devlink formatted message pointer + * @skb: pointer to skb + * + * Dump diagnostic information about sk_buff structure, like headroom, length, + * tailroom, MAC, etc. + */ +void devlink_fmsg_dump_skb(struct devlink_fmsg *fmsg, const struct sk_buff *skb) +{ + struct skb_shared_info *sh = skb_shinfo(skb); + struct sock *sk = skb->sk; + bool has_mac, has_trans; + + has_mac = skb_mac_header_was_set(skb); + has_trans = skb_transport_header_was_set(skb); + + devlink_fmsg_pair_nest_start(fmsg, "skb"); + devlink_fmsg_obj_nest_start(fmsg); + devlink_fmsg_put(fmsg, "actual len", skb->len); + devlink_fmsg_put(fmsg, "head len", skb_headlen(skb)); + devlink_fmsg_put(fmsg, "data len", skb->data_len); + devlink_fmsg_put(fmsg, "tail len", skb_tailroom(skb)); + devlink_fmsg_put(fmsg, "MAC", has_mac ? skb->mac_header : -1); + devlink_fmsg_put(fmsg, "MAC len", + has_mac ? skb_mac_header_len(skb) : -1); + devlink_fmsg_put(fmsg, "network hdr", skb->network_header); + devlink_fmsg_put(fmsg, "network hdr len", + has_trans ? skb_network_header_len(skb) : -1); + devlink_fmsg_put(fmsg, "transport hdr", + has_trans ? skb->transport_header : -1); + devlink_fmsg_put(fmsg, "csum", (__force u32)skb->csum); + devlink_fmsg_put(fmsg, "csum_ip_summed", (u8)skb->ip_summed); + devlink_fmsg_put(fmsg, "csum_complete_sw", !!skb->csum_complete_sw); + devlink_fmsg_put(fmsg, "csum_valid", !!skb->csum_valid); + devlink_fmsg_put(fmsg, "csum_level", (u8)skb->csum_level); + devlink_fmsg_put(fmsg, "sw_hash", !!skb->sw_hash); + devlink_fmsg_put(fmsg, "l4_hash", !!skb->l4_hash); + devlink_fmsg_put(fmsg, "proto", ntohs(skb->protocol)); + devlink_fmsg_put(fmsg, "pkt_type", (u8)skb->pkt_type); + devlink_fmsg_put(fmsg, "iif", skb->skb_iif); + + if (sk) { + devlink_fmsg_pair_nest_start(fmsg, "sk"); + devlink_fmsg_obj_nest_start(fmsg); + devlink_fmsg_put(fmsg, "family", sk->sk_type); + devlink_fmsg_put(fmsg, "type", sk->sk_type); + devlink_fmsg_put(fmsg, "proto", sk->sk_protocol); + devlink_fmsg_obj_nest_end(fmsg); + devlink_fmsg_pair_nest_end(fmsg); + } + + devlink_fmsg_obj_nest_end(fmsg); + devlink_fmsg_pair_nest_end(fmsg); + + devlink_fmsg_pair_nest_start(fmsg, "shinfo"); + devlink_fmsg_obj_nest_start(fmsg); + devlink_fmsg_put(fmsg, "tx_flags", sh->tx_flags); + devlink_fmsg_put(fmsg, "nr_frags", sh->nr_frags); + devlink_fmsg_put(fmsg, "gso_size", sh->gso_size); + devlink_fmsg_put(fmsg, "gso_type", sh->gso_type); + devlink_fmsg_put(fmsg, "gso_segs", sh->gso_segs); + devlink_fmsg_obj_nest_end(fmsg); + devlink_fmsg_pair_nest_end(fmsg); +} +EXPORT_SYMBOL_GPL(devlink_fmsg_dump_skb); From patchwork Wed Dec 11 22:32:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13904295 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 18BCA1F2C3B for ; Wed, 11 Dec 2024 22:32:42 +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=1733956364; cv=none; b=AGPDs0CwWBQdWKF2y7IQAUX1q/kuiQP4kcZMTQ4FFnsFTyBAMfHXaG1+8U08RMf7JzVvaYZUq+0e55UoIFT6RQniVTMKEQ7EihQMdKQZ+WrqunB6Id/B8tc3xC5VCFRBk2Zp5ra1aOP3G3Ls2PfwiInmvIM2D6bcp3omjI+sEpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733956364; c=relaxed/simple; bh=nDhiEm6ADZ2KjN6W6XXgdg7PeX6vb/cbAyLvMwp9qZk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FSR8UTxWdp5xnUFxi+C7/bJZWxJdbQj/iJFTS08VouP2SneNhy6ieLXEvlVTRfRiRne7NwvMrpECVahsyyh7hIw4YaZnBnH85HpWBeCxnR5KetnKcxspmB8J72f4k/0tA0eLLvkCKjoE6y0bRGdfiK75vwmYTwTAzDlimMewoVs= 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=f9WrK7ml; 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="f9WrK7ml" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733956362; x=1765492362; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nDhiEm6ADZ2KjN6W6XXgdg7PeX6vb/cbAyLvMwp9qZk=; b=f9WrK7ml8JvOUWYiG5gVtm3/fRTTQQC/8fBjCPAeimWURP7fd4Dn+uLK xTA79BAKOvdAtInmkRTezcqceBMo85MtKCTAT5OmrKPnrH52/Q+HuKcmK Ah5Ta2BT1/+pFJkUC2UF4YGpWL90whxemdypcKiSIcyc7nddaG4WzcdK/ tBIg/j69OOl/GAHt9aW/isedps7jk4YdNE8oxHCWOUVxi8r1+ZV0QlqrO OEE+G3t8x9bQwIQ9JpSbEUImYit8o/lgemCdX7adWVls0cps3bOs/Hukv yiBjwym7mzyw5htnN8+9AQdkG53t1yMnx8rmd1cGOysigvyihlmodIp6k w==; X-CSE-ConnectionGUID: mEiAwXW+Q8G0PohLAqsPlw== X-CSE-MsgGUID: eJzUiafqQHuF4KIAjU+SBg== X-IronPort-AV: E=McAfee;i="6700,10204,11283"; a="34599631" X-IronPort-AV: E=Sophos;i="6.12,226,1728975600"; d="scan'208";a="34599631" 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:40 -0800 X-CSE-ConnectionGUID: Begdxwe4SYWzdZVnwSesIg== X-CSE-MsgGUID: IN8OC1k4SUCnI3VAfND5VQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,226,1728975600"; d="scan'208";a="96192937" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by fmviesa008.fm.intel.com with ESMTP; 11 Dec 2024 14:32:39 -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 Subject: [PATCH net-next 4/7] ice: rename devlink_port.[ch] to port.[ch] Date: Wed, 11 Dec 2024 14:32:12 -0800 Message-ID: <20241211223231.397203-5-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 Drop "devlink_" prefix from files that sit in devlink/. I'm going to add more files there, and repeating "devlink" does not feel good. This is also the scheme used in most other places, most notably the devlink core files are named like that. devlink.[ch] stays as is. Signed-off-by: Przemek Kitszel Signed-off-by: Tony Nguyen --- drivers/net/ethernet/intel/ice/Makefile | 2 +- drivers/net/ethernet/intel/ice/devlink/devlink.c | 2 +- .../net/ethernet/intel/ice/devlink/{devlink_port.c => port.c} | 2 +- .../net/ethernet/intel/ice/devlink/{devlink_port.h => port.h} | 0 drivers/net/ethernet/intel/ice/ice_eswitch.h | 2 +- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_repr.c | 2 +- drivers/net/ethernet/intel/ice/ice_sf_eth.c | 2 +- 8 files changed, 7 insertions(+), 7 deletions(-) rename drivers/net/ethernet/intel/ice/devlink/{devlink_port.c => port.c} (99%) rename drivers/net/ethernet/intel/ice/devlink/{devlink_port.h => port.h} (100%) diff --git a/drivers/net/ethernet/intel/ice/Makefile b/drivers/net/ethernet/intel/ice/Makefile index 3307d551f431..56aa23aee472 100644 --- a/drivers/net/ethernet/intel/ice/Makefile +++ b/drivers/net/ethernet/intel/ice/Makefile @@ -32,7 +32,7 @@ ice-y := ice_main.o \ ice_parser_rt.o \ ice_idc.o \ devlink/devlink.o \ - devlink/devlink_port.o \ + devlink/port.o \ ice_sf_eth.o \ ice_sf_vsi_vlan_ops.o \ ice_ddp.o \ diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c index 415445cefdb2..1b10682c00b8 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c @@ -6,7 +6,7 @@ #include "ice.h" #include "ice_lib.h" #include "devlink.h" -#include "devlink_port.h" +#include "port.h" #include "ice_eswitch.h" #include "ice_fw_update.h" #include "ice_dcb_lib.h" diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c b/drivers/net/ethernet/intel/ice/devlink/port.c similarity index 99% rename from drivers/net/ethernet/intel/ice/devlink/devlink_port.c rename to drivers/net/ethernet/intel/ice/devlink/port.c index c6779d9dffff..767419a67fef 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c +++ b/drivers/net/ethernet/intel/ice/devlink/port.c @@ -5,7 +5,7 @@ #include "ice.h" #include "devlink.h" -#include "devlink_port.h" +#include "port.h" #include "ice_lib.h" #include "ice_fltr.h" diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h b/drivers/net/ethernet/intel/ice/devlink/port.h similarity index 100% rename from drivers/net/ethernet/intel/ice/devlink/devlink_port.h rename to drivers/net/ethernet/intel/ice/devlink/port.h diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.h b/drivers/net/ethernet/intel/ice/ice_eswitch.h index ac7db100e2cd..5c7dcf21b222 100644 --- a/drivers/net/ethernet/intel/ice/ice_eswitch.h +++ b/drivers/net/ethernet/intel/ice/ice_eswitch.h @@ -5,7 +5,7 @@ #define _ICE_ESWITCH_H_ #include -#include "devlink/devlink_port.h" +#include "devlink/port.h" #ifdef CONFIG_ICE_SWITCHDEV void ice_eswitch_detach_vf(struct ice_pf *pf, struct ice_vf *vf); diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 0ab35607e5d5..d641dd8b8184 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -14,7 +14,7 @@ #include "ice_dcb_lib.h" #include "ice_dcb_nl.h" #include "devlink/devlink.h" -#include "devlink/devlink_port.h" +#include "devlink/port.h" #include "ice_sf_eth.h" #include "ice_hwmon.h" /* Including ice_trace.h with CREATE_TRACE_POINTS defined will generate the diff --git a/drivers/net/ethernet/intel/ice/ice_repr.c b/drivers/net/ethernet/intel/ice/ice_repr.c index 970a99a52bf1..fb7a1b9a4313 100644 --- a/drivers/net/ethernet/intel/ice/ice_repr.c +++ b/drivers/net/ethernet/intel/ice/ice_repr.c @@ -4,7 +4,7 @@ #include "ice.h" #include "ice_eswitch.h" #include "devlink/devlink.h" -#include "devlink/devlink_port.h" +#include "devlink/port.h" #include "ice_sriov.h" #include "ice_tc_lib.h" #include "ice_dcb_lib.h" diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.c b/drivers/net/ethernet/intel/ice/ice_sf_eth.c index 75d7147e1c01..1a2c94375ca7 100644 --- a/drivers/net/ethernet/intel/ice/ice_sf_eth.c +++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.c @@ -5,8 +5,8 @@ #include "ice_txrx.h" #include "ice_fltr.h" #include "ice_sf_eth.h" -#include "devlink/devlink_port.h" #include "devlink/devlink.h" +#include "devlink/port.h" static const struct net_device_ops ice_sf_netdev_ops = { .ndo_open = ice_open, From patchwork Wed Dec 11 22:32:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13904297 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 81C8F204594 for ; Wed, 11 Dec 2024 22:32:43 +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=1733956365; cv=none; b=tY8BIIHpnguue6nE8tBe5n5RjqokK9EREzU5vXy0hXGAaaF4RJXW6y25eC4C3XQrqC2f/lnGsvem9aCnnEUDD9zLYEuPw518+dHAIK5Z75w81amQH1BwwRVY8Q9hpI6fhIMs8e1eGKvnvrd50/Ex6yAjyj3ygWkdz4rnTc6yVUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733956365; c=relaxed/simple; bh=fsWPt0xSRolST8lDpW6tj5oYSZrfQZOKKYXI4FeBAls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nQxMf+nMkMs8si6JXn1RRUADaMFW/mhdpXKXeoKNssh1yk6eqbX5U6f+VcooAgLDXDvdDwhPa3hzF4VzKpew2K/EiI+/Lb6VgC+8VVzTiMo3VIuTmLphi1LFKaXwiaaIHjIy4wO7Jt3M11T/yiU1CpqjizAImQLS8nk5GUkc/zk= 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=gcQzlakR; 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="gcQzlakR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733956363; x=1765492363; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fsWPt0xSRolST8lDpW6tj5oYSZrfQZOKKYXI4FeBAls=; b=gcQzlakRKy+WtsKEYYxwwCx/qh+Rl6Hmhg6lNX4JTPoD5nVIzHO6Ikjw 5W8YRJVTRev6V4mU2qJuC1VcfgCUmgXY0LymbwG6QfA15BYiQm8g3RwJx P7qz6RT+ati8RM/H0UQCFT0BAd6DP6p7/uJMHCRbtMof5sMUlj9jb4kSD fqjW7WGxmh7Cdia7DF39XsQQUXGeepWDNdO1OIehPti0fDwCdXJTInFUj Zc7ipD6Pxqg+gOUUAB/5fqQr8Kwtqnc39vqrnOEGe43wfq2Vpm+2aM/Rq q1XQPrFKpx8kGv/bQyg/OrMBiLQPwEvoD2mv97g4PztItheD8IJNlZdBZ w==; X-CSE-ConnectionGUID: R6JaGaO1Qj+zeoqxDaK2ug== X-CSE-MsgGUID: vwk1pNnfQJypEdKNpLPmyA== X-IronPort-AV: E=McAfee;i="6700,10204,11283"; a="34599641" X-IronPort-AV: E=Sophos;i="6.12,226,1728975600"; d="scan'208";a="34599641" 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:40 -0800 X-CSE-ConnectionGUID: GyblmMf+QLO2cysdZhJOrQ== X-CSE-MsgGUID: kNkMt0R0Ti660GsxSoj6qg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,226,1728975600"; d="scan'208";a="96192940" 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 5/7] ice: add Tx hang devlink health reporter Date: Wed, 11 Dec 2024 14:32:13 -0800 Message-ID: <20241211223231.397203-6-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 Add Tx hang devlink health reporter, see struct ice_tx_hang_event to see what is reported. Subsequent commits will extend it by more info, for now it dumps descriptors with little metadata. Reviewed-by: Igor Bagnucki Reviewed-by: Wojciech Drewek Co-developed-by: Mateusz Polchlopek 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 --- drivers/net/ethernet/intel/ice/Makefile | 1 + .../net/ethernet/intel/ice/devlink/health.c | 188 ++++++++++++++++++ .../net/ethernet/intel/ice/devlink/health.h | 48 +++++ drivers/net/ethernet/intel/ice/ice.h | 2 + drivers/net/ethernet/intel/ice/ice_main.c | 18 +- 5 files changed, 252 insertions(+), 5 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/devlink/health.c create mode 100644 drivers/net/ethernet/intel/ice/devlink/health.h diff --git a/drivers/net/ethernet/intel/ice/Makefile b/drivers/net/ethernet/intel/ice/Makefile index 56aa23aee472..9e0d9f710441 100644 --- a/drivers/net/ethernet/intel/ice/Makefile +++ b/drivers/net/ethernet/intel/ice/Makefile @@ -32,6 +32,7 @@ ice-y := ice_main.o \ ice_parser_rt.o \ ice_idc.o \ devlink/devlink.o \ + devlink/health.o \ devlink/port.o \ ice_sf_eth.o \ ice_sf_vsi_vlan_ops.o \ diff --git a/drivers/net/ethernet/intel/ice/devlink/health.c b/drivers/net/ethernet/intel/ice/devlink/health.c new file mode 100644 index 000000000000..b8c5a1c372dc --- /dev/null +++ b/drivers/net/ethernet/intel/ice/devlink/health.c @@ -0,0 +1,188 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2024, Intel Corporation. */ + +#include "health.h" +#include "ice.h" + +#define ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, obj, name) \ + devlink_fmsg_put(fmsg, #name, (obj)->name) + +/** + * ice_devlink_health_report - boilerplate to call given @reporter + * + * @reporter: devlink health reporter to call, do nothing on NULL + * @msg: message to pass up, "event name" is fine + * @priv_ctx: typically some event struct + */ +static void ice_devlink_health_report(struct devlink_health_reporter *reporter, + const char *msg, void *priv_ctx) +{ + if (!reporter) + return; + + /* We do not do auto recovering, so return value of the below function + * will always be 0, thus we do ignore it. + */ + devlink_health_report(reporter, msg, priv_ctx); +} + +/** + * ice_fmsg_put_ptr - put hex value of pointer into fmsg + * + * @fmsg: devlink fmsg under construction + * @name: name to pass + * @ptr: 64 bit value to print as hex and put into fmsg + */ +static void ice_fmsg_put_ptr(struct devlink_fmsg *fmsg, const char *name, + void *ptr) +{ + char buf[sizeof(ptr) * 3]; + + sprintf(buf, "%p", ptr); + devlink_fmsg_put(fmsg, name, buf); +} + +struct ice_tx_hang_event { + u32 head; + u32 intr; + u16 vsi_num; + u16 queue; + u16 next_to_clean; + u16 next_to_use; + struct ice_tx_ring *tx_ring; +}; + +static int ice_tx_hang_reporter_dump(struct devlink_health_reporter *reporter, + struct devlink_fmsg *fmsg, void *priv_ctx, + struct netlink_ext_ack *extack) +{ + struct ice_tx_hang_event *event = priv_ctx; + + if (!event) + return 0; + + devlink_fmsg_obj_nest_start(fmsg); + ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, event, head); + ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, event, intr); + ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, event, vsi_num); + ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, event, queue); + ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, event, next_to_clean); + ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, event, next_to_use); + 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); + devlink_fmsg_binary_pair_put(fmsg, "desc", event->tx_ring->desc, + event->tx_ring->count * sizeof(struct ice_tx_desc)); + devlink_fmsg_obj_nest_end(fmsg); + + return 0; +} + +void ice_prep_tx_hang_report(struct ice_pf *pf, struct ice_tx_ring *tx_ring, + u16 vsi_num, u32 head, u32 intr) +{ + struct ice_health_tx_hang_buf *buf = &pf->health_reporters.tx_hang_buf; + + buf->tx_ring = tx_ring; + buf->vsi_num = vsi_num; + buf->head = head; + buf->intr = intr; +} + +void ice_report_tx_hang(struct ice_pf *pf) +{ + struct ice_health_tx_hang_buf *buf = &pf->health_reporters.tx_hang_buf; + struct ice_tx_ring *tx_ring = buf->tx_ring; + + struct ice_tx_hang_event ev = { + .head = buf->head, + .intr = buf->intr, + .vsi_num = buf->vsi_num, + .queue = tx_ring->q_index, + .next_to_clean = tx_ring->next_to_clean, + .next_to_use = tx_ring->next_to_use, + .tx_ring = tx_ring, + }; + + ice_devlink_health_report(pf->health_reporters.tx_hang, "Tx hang", &ev); +} + +static struct devlink_health_reporter * +ice_init_devlink_rep(struct ice_pf *pf, + const struct devlink_health_reporter_ops *ops) +{ + struct devlink *devlink = priv_to_devlink(pf); + struct devlink_health_reporter *rep; + const u64 graceful_period = 0; + + rep = devl_health_reporter_create(devlink, ops, graceful_period, pf); + if (IS_ERR(rep)) { + struct device *dev = ice_pf_to_dev(pf); + + dev_err(dev, "failed to create devlink %s health report er", + ops->name); + return NULL; + } + return rep; +} + +#define ICE_DEFINE_HEALTH_REPORTER_OPS(_name) \ + static const struct devlink_health_reporter_ops ice_ ## _name ## _reporter_ops = { \ + .name = #_name, \ + .dump = ice_ ## _name ## _reporter_dump, \ +} + +ICE_DEFINE_HEALTH_REPORTER_OPS(tx_hang); + +/** + * ice_health_init - allocate and init all ice devlink health reporters and + * accompanied data + * + * @pf: PF struct + */ +void ice_health_init(struct ice_pf *pf) +{ + struct ice_health *reps = &pf->health_reporters; + + reps->tx_hang = ice_init_devlink_rep(pf, &ice_tx_hang_reporter_ops); +} + +/** + * ice_deinit_devl_reporter - destroy given devlink health reporter + * @reporter: reporter to destroy + */ +static void ice_deinit_devl_reporter(struct devlink_health_reporter *reporter) +{ + if (reporter) + devl_health_reporter_destroy(reporter); +} + +/** + * ice_health_deinit - deallocate all ice devlink health reporters and + * accompanied data + * + * @pf: PF struct + */ +void ice_health_deinit(struct ice_pf *pf) +{ + ice_deinit_devl_reporter(pf->health_reporters.tx_hang); +} + +static +void ice_health_assign_healthy_state(struct devlink_health_reporter *reporter) +{ + if (reporter) + devlink_health_reporter_state_update(reporter, + DEVLINK_HEALTH_REPORTER_STATE_HEALTHY); +} + +/** + * ice_health_clear - clear devlink health issues after a reset + * @pf: the PF device structure + * + * Mark the PF in healthy state again after a reset has completed. + */ +void ice_health_clear(struct ice_pf *pf) +{ + ice_health_assign_healthy_state(pf->health_reporters.tx_hang); +} diff --git a/drivers/net/ethernet/intel/ice/devlink/health.h b/drivers/net/ethernet/intel/ice/devlink/health.h new file mode 100644 index 000000000000..92e40d790e72 --- /dev/null +++ b/drivers/net/ethernet/intel/ice/devlink/health.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2024, Intel Corporation. */ + +#ifndef _HEALTH_H_ +#define _HEALTH_H_ + +#include + +/** + * DOC: health.h + * + * This header file stores everything that is needed for broadly understood + * devlink health mechanism for ice driver. + */ + +struct ice_pf; +struct ice_tx_ring; + +/** + * struct ice_health - stores ice devlink health reporters and accompanied data + * @tx_hang: devlink health reporter for tx_hang event + * @tx_hang_buf: pre-allocated place to put info for Tx hang reporter from + * non-sleeping context + * @tx_ring: ring that the hang occured on + * @head: descriptior head + * @intr: interrupt register value + * @vsi_num: VSI owning the queue that the hang occured on + */ +struct ice_health { + struct devlink_health_reporter *tx_hang; + struct_group_tagged(ice_health_tx_hang_buf, tx_hang_buf, + struct ice_tx_ring *tx_ring; + u32 head; + u32 intr; + u16 vsi_num; + ); +}; + + +void ice_health_init(struct ice_pf *pf); +void ice_health_deinit(struct ice_pf *pf); +void ice_health_clear(struct ice_pf *pf); + +void ice_prep_tx_hang_report(struct ice_pf *pf, struct ice_tx_ring *tx_ring, + u16 vsi_num, u32 head, u32 intr); +void ice_report_tx_hang(struct ice_pf *pf); + +#endif /* _HEALTH_H_ */ diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index 2f5d6f974185..71e05d30f0fd 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -78,6 +78,7 @@ #include "ice_irq.h" #include "ice_dpll.h" #include "ice_adapter.h" +#include "devlink/health.h" #define ICE_BAR0 0 #define ICE_REQ_DESC_MULTIPLE 32 @@ -665,6 +666,7 @@ struct ice_pf { struct ice_agg_node vf_agg_node[ICE_MAX_VF_AGG_NODES]; struct ice_dplls dplls; struct device *hwmon_dev; + struct ice_health health_reporters; u8 num_quanta_prof_used; }; diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index d641dd8b8184..316f5109bd3f 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -2364,9 +2364,11 @@ static void ice_service_task(struct work_struct *work) struct ice_pf *pf = container_of(work, struct ice_pf, serv_task); unsigned long start_time = jiffies; - /* subtasks */ + if (pf->health_reporters.tx_hang_buf.tx_ring) { + ice_report_tx_hang(pf); + pf->health_reporters.tx_hang_buf.tx_ring = NULL; + } - /* process reset requests first */ ice_reset_subtask(pf); /* bail if a reset/recovery cycle is pending or rebuild failed */ @@ -5087,6 +5089,7 @@ static int ice_init_devlink(struct ice_pf *pf) return err; ice_devlink_init_regions(pf); + ice_health_init(pf); ice_devlink_register(pf); return 0; @@ -5095,6 +5098,7 @@ static int ice_init_devlink(struct ice_pf *pf) static void ice_deinit_devlink(struct ice_pf *pf) { ice_devlink_unregister(pf); + ice_health_deinit(pf); ice_devlink_destroy_regions(pf); ice_devlink_unregister_params(pf); } @@ -7793,6 +7797,8 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) /* if we get here, reset flow is successful */ clear_bit(ICE_RESET_FAILED, pf->state); + ice_health_clear(pf); + ice_plug_aux_dev(pf); if (ice_is_feature_supported(pf, ICE_F_SRIOV_LAG)) ice_lag_rebuild(pf); @@ -8283,16 +8289,18 @@ void ice_tx_timeout(struct net_device *netdev, unsigned int txqueue) if (tx_ring) { struct ice_hw *hw = &pf->hw; - u32 head, val = 0; + u32 head, intr = 0; head = FIELD_GET(QTX_COMM_HEAD_HEAD_M, rd32(hw, QTX_COMM_HEAD(vsi->txq_map[txqueue]))); /* Read interrupt register */ - val = rd32(hw, GLINT_DYN_CTL(tx_ring->q_vector->reg_idx)); + intr = rd32(hw, GLINT_DYN_CTL(tx_ring->q_vector->reg_idx)); netdev_info(netdev, "tx_timeout: VSI_num: %d, Q %u, NTC: 0x%x, HW_HEAD: 0x%x, NTU: 0x%x, INT: 0x%x\n", vsi->vsi_num, txqueue, tx_ring->next_to_clean, - head, tx_ring->next_to_use, val); + head, tx_ring->next_to_use, intr); + + ice_prep_tx_hang_report(pf, tx_ring, vsi->vsi_num, head, intr); } pf->tx_timeout_last_recovery = jiffies; 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_ */ From patchwork Wed Dec 11 22:32:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13904299 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 2894B2046A6 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=B84FYue8OTtCvqSvrx4o8YHS0w0ME3/eYjTzXnjTwydx13tmJ2GYpeIpDvu1UWMNiagHOeH+DOh8P5kUT6uMgtuQQH85hyzmO3kqVLoS2tVbFScwF8bazoj2Y/GgsWIFr6XiQEIvLjqhqM9h3BBE/6M4GmeaJ08dCq2UvsjCIrc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733956366; c=relaxed/simple; bh=Btbce94nYPEGod4BC7F/cbhBgqtefqG66pIe6Ym/Sqo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OX6HRwCR0vfChRZwW4LPmjwDHMhwOaes9oDmqXQ0FyZ6RMS0x5vTzRA2Zh8XtgHFjPSatR3mTRPCHDX1gtw7W8zAEiwem7Rg+ZA+8w2zrei9CPi9CsQ1AXbWftdHvfGOtr46RrL/F8T+PGNS8S2H8OFz6pMKGl/PdOvvXhXOIvg= 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=Jw0sBUcY; 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="Jw0sBUcY" 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=Btbce94nYPEGod4BC7F/cbhBgqtefqG66pIe6Ym/Sqo=; b=Jw0sBUcYKwXzd5IdWdvJEhTOyXG4eyuopzExCc4JgrP+f7pZudv5x/zH gpO5+6cIfszshgOuWlEjuGw06AisUYv5ywND95wnm3NexI7VY6MvWKQCm SYyX6BqS/ALxRb1H8+SB6sesvz+d4W2eiCUUMVvkDAJPPqXE7k4Epbq4T zpU4g3ZNSB57OY+QHyc+R5vMcyQC5O2DLpS8+0mY+6uzVFSBCyNfL7wkc nLcuQ+l1G4Q3hjkRqEGO4M+5BzynpTOZx2HhpRlOAJj9zS+tt6AN4OoFa +4w1lAckErzQQaEqeeIahwsqHgkTgcHoA3jIm/q2lrYQIBx/wGmm28peZ w==; X-CSE-ConnectionGUID: VsM1WWa8R4ysXMc16Xoy1A== X-CSE-MsgGUID: CsloYDMKQxCKYR7ogiMJSQ== X-IronPort-AV: E=McAfee;i="6700,10204,11283"; a="34599663" X-IronPort-AV: E=Sophos;i="6.12,226,1728975600"; d="scan'208";a="34599663" 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: +R/ALqBNQX2vc8S1xv6kdQ== X-CSE-MsgGUID: Ix+EB42YTZmylwhr/NgloQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,226,1728975600"; d="scan'208";a="96192952" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by fmviesa008.fm.intel.com with ESMTP; 11 Dec 2024 14:32:41 -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: Ben Shelton , anthony.l.nguyen@intel.com, przemyslaw.kitszel@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 7/7] ice: Add MDD logging via devlink health Date: Wed, 11 Dec 2024 14:32:15 -0800 Message-ID: <20241211223231.397203-8-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: Ben Shelton Add a devlink health reporter for MDD events. The 'dump' handler will return the information captured in each call to ice_handle_mdd_event(). A device reset (CORER/PFR) will put the reporter back in healthy state. Signed-off-by: Ben Shelton 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) Co-developed-by: Przemek Kitszel Signed-off-by: Przemek Kitszel Signed-off-by: Tony Nguyen --- .../net/ethernet/intel/ice/devlink/health.c | 77 +++++++++++++++++++ .../net/ethernet/intel/ice/devlink/health.h | 11 +++ drivers/net/ethernet/intel/ice/ice_main.c | 6 ++ 3 files changed, 94 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/devlink/health.c b/drivers/net/ethernet/intel/ice/devlink/health.c index b0abb6d4e3e4..d9b852ccf99e 100644 --- a/drivers/net/ethernet/intel/ice/devlink/health.c +++ b/drivers/net/ethernet/intel/ice/devlink/health.c @@ -27,6 +27,79 @@ static void ice_devlink_health_report(struct devlink_health_reporter *reporter, devlink_health_report(reporter, msg, priv_ctx); } +struct ice_mdd_event { + enum ice_mdd_src src; + u16 vf_num; + u16 queue; + u8 pf_num; + u8 event; +}; + +static const char *ice_mdd_src_to_str(enum ice_mdd_src src) +{ + switch (src) { + case ICE_MDD_SRC_TX_PQM: + return "tx_pqm"; + case ICE_MDD_SRC_TX_TCLAN: + return "tx_tclan"; + case ICE_MDD_SRC_TX_TDPU: + return "tx_tdpu"; + case ICE_MDD_SRC_RX: + return "rx"; + default: + return "invalid"; + } +} + +static int +ice_mdd_reporter_dump(struct devlink_health_reporter *reporter, + struct devlink_fmsg *fmsg, void *priv_ctx, + struct netlink_ext_ack *extack) +{ + struct ice_mdd_event *mdd_event = priv_ctx; + const char *src; + + if (!mdd_event) + return 0; + + src = ice_mdd_src_to_str(mdd_event->src); + + devlink_fmsg_obj_nest_start(fmsg); + devlink_fmsg_put(fmsg, "src", src); + ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, mdd_event, pf_num); + ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, mdd_event, vf_num); + ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, mdd_event, event); + ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, mdd_event, queue); + devlink_fmsg_obj_nest_end(fmsg); + + return 0; +} + +/** + * ice_report_mdd_event - Report an MDD event through devlink health + * @pf: the PF device structure + * @src: the HW block that was the source of this MDD event + * @pf_num: the pf_num on which the MDD event occurred + * @vf_num: the vf_num on which the MDD event occurred + * @event: the event type of the MDD event + * @queue: the queue on which the MDD event occurred + * + * Report an MDD event that has occurred on this PF. + */ +void ice_report_mdd_event(struct ice_pf *pf, enum ice_mdd_src src, u8 pf_num, + u16 vf_num, u8 event, u16 queue) +{ + struct ice_mdd_event ev = { + .src = src, + .pf_num = pf_num, + .vf_num = vf_num, + .event = event, + .queue = queue, + }; + + ice_devlink_health_report(pf->health_reporters.mdd, "MDD event", &ev); +} + static void ice_dump_ethtool_stats_to_fmsg(struct devlink_fmsg *fmsg, struct net_device *netdev) { @@ -168,6 +241,7 @@ ice_init_devlink_rep(struct ice_pf *pf, .dump = ice_ ## _name ## _reporter_dump, \ } +ICE_DEFINE_HEALTH_REPORTER_OPS(mdd); ICE_DEFINE_HEALTH_REPORTER_OPS(tx_hang); /** @@ -180,6 +254,7 @@ void ice_health_init(struct ice_pf *pf) { struct ice_health *reps = &pf->health_reporters; + reps->mdd = ice_init_devlink_rep(pf, &ice_mdd_reporter_ops); reps->tx_hang = ice_init_devlink_rep(pf, &ice_tx_hang_reporter_ops); } @@ -201,6 +276,7 @@ static void ice_deinit_devl_reporter(struct devlink_health_reporter *reporter) */ void ice_health_deinit(struct ice_pf *pf) { + ice_deinit_devl_reporter(pf->health_reporters.mdd); ice_deinit_devl_reporter(pf->health_reporters.tx_hang); } @@ -220,5 +296,6 @@ void ice_health_assign_healthy_state(struct devlink_health_reporter *reporter) */ void ice_health_clear(struct ice_pf *pf) { + ice_health_assign_healthy_state(pf->health_reporters.mdd); ice_health_assign_healthy_state(pf->health_reporters.tx_hang); } diff --git a/drivers/net/ethernet/intel/ice/devlink/health.h b/drivers/net/ethernet/intel/ice/devlink/health.h index 92e40d790e72..a08c7bd174cf 100644 --- a/drivers/net/ethernet/intel/ice/devlink/health.h +++ b/drivers/net/ethernet/intel/ice/devlink/health.h @@ -16,9 +16,17 @@ struct ice_pf; struct ice_tx_ring; +enum ice_mdd_src { + ICE_MDD_SRC_TX_PQM, + ICE_MDD_SRC_TX_TCLAN, + ICE_MDD_SRC_TX_TDPU, + ICE_MDD_SRC_RX, +}; + /** * struct ice_health - stores ice devlink health reporters and accompanied data * @tx_hang: devlink health reporter for tx_hang event + * @mdd: devlink health reporter for MDD detection event * @tx_hang_buf: pre-allocated place to put info for Tx hang reporter from * non-sleeping context * @tx_ring: ring that the hang occured on @@ -27,6 +35,7 @@ struct ice_tx_ring; * @vsi_num: VSI owning the queue that the hang occured on */ struct ice_health { + struct devlink_health_reporter *mdd; struct devlink_health_reporter *tx_hang; struct_group_tagged(ice_health_tx_hang_buf, tx_hang_buf, struct ice_tx_ring *tx_ring; @@ -43,6 +52,8 @@ void ice_health_clear(struct ice_pf *pf); void ice_prep_tx_hang_report(struct ice_pf *pf, struct ice_tx_ring *tx_ring, u16 vsi_num, u32 head, u32 intr); +void ice_report_mdd_event(struct ice_pf *pf, enum ice_mdd_src src, u8 pf_num, + u16 vf_num, u8 event, u16 queue); void ice_report_tx_hang(struct ice_pf *pf); #endif /* _HEALTH_H_ */ diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 316f5109bd3f..1701f7143f24 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -1816,6 +1816,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf) if (netif_msg_tx_err(pf)) dev_info(dev, "Malicious Driver Detection event %d on TX queue %d PF# %d VF# %d\n", event, queue, pf_num, vf_num); + ice_report_mdd_event(pf, ICE_MDD_SRC_TX_PQM, pf_num, vf_num, + event, queue); wr32(hw, GL_MDET_TX_PQM, 0xffffffff); } @@ -1829,6 +1831,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf) if (netif_msg_tx_err(pf)) dev_info(dev, "Malicious Driver Detection event %d on TX queue %d PF# %d VF# %d\n", event, queue, pf_num, vf_num); + ice_report_mdd_event(pf, ICE_MDD_SRC_TX_TCLAN, pf_num, vf_num, + event, queue); wr32(hw, GL_MDET_TX_TCLAN_BY_MAC(hw), U32_MAX); } @@ -1842,6 +1846,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf) if (netif_msg_rx_err(pf)) dev_info(dev, "Malicious Driver Detection event %d on RX queue %d PF# %d VF# %d\n", event, queue, pf_num, vf_num); + ice_report_mdd_event(pf, ICE_MDD_SRC_RX, pf_num, vf_num, event, + queue); wr32(hw, GL_MDET_RX, 0xffffffff); }