From patchwork Mon Dec 11 17:18:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13487700 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="tFM9Pzek" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2085.outbound.protection.outlook.com [40.107.243.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D62D59B for ; Mon, 11 Dec 2023 09:19:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f1hy8SXHQ0vXqi8e3poUNSLck4SCDB8jV6HSOuLgdZkpiju9Mv1976tkJye0n6fKCr5FUfEnzsaT/lTdJi4XTT+HlIApP8OjZlHL+LqUOcbFjS6delf1alat7s8xxmeyawFuB4NaZUY/0LslSUi+FTqO2+5OuvBnpkm0xygirxC+UlMx0GEq5n2lN25lkRbqgehDxgh7zBxWRj3cmWnnX/BykejqCka2NLkzTRcspDWVAHMoHDRTEsUcL6H1CMOi0kjGYW++3kERDuCVPBFPeLpRUv1TtmEawF+8V17KHJJp5k0u1VkHkF6PBJiHsttIUkaOBsM06Wqs7g5HMtCs+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rgG2W4fi4iWtYDLLvgxoINe7lNhnUD1m0KIIdwUx6fg=; b=bxKXpc2t6c0wLdMOhiAgF5EW137mahm6YwwhN8gEMr/nGyrrgcBsjxRzKYjmOB/rimdqspWYYUn+mrorG08GydnvdiZMOJUDvGagW6n/UdW5RRv95Cm8T44qGhNgcwSdw1BGhD3ayUHI5ErgLi3g8zTfqCP3qESyq6NUPRbKJ/tzdNSbREjOI+xDkE3Dpx8s9l/vdqGFhzZT0YX1OPg4uvKR+ZGf3LiTPGrU7s+FTsKr5ZnIwjWR7F8OWK1uOgwHEmLaNrAx3sdyn5kg+z8at3DHfb659384I41DqpvlmUDXADyXThYjT/SDzzF+7BlC3pXBqeBLM8EMpfTgexTbUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rgG2W4fi4iWtYDLLvgxoINe7lNhnUD1m0KIIdwUx6fg=; b=tFM9PzekHU2vZuk5M7QOM/1+C0XGvC6f+X7MdWuymj37D+S3cr0b+p0XSK4G/qbMRn2vFzIfGqIDEDnisnWS3DlZDIWLygA+pyvhuLDQNzk7Hii9T1EYR2HVq2QbnqL1znbojPo9hiHiE0yHwX2B5AbotFgr9CZFb7jFSd463EQ= Received: from BL1PR13CA0321.namprd13.prod.outlook.com (2603:10b6:208:2c1::26) by CY8PR12MB7706.namprd12.prod.outlook.com (2603:10b6:930:85::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 17:19:40 +0000 Received: from BL6PEPF0001AB78.namprd02.prod.outlook.com (2603:10b6:208:2c1:cafe::d3) by BL1PR13CA0321.outlook.office365.com (2603:10b6:208:2c1::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.21 via Frontend Transport; Mon, 11 Dec 2023 17:19:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB78.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7091.18 via Frontend Transport; Mon, 11 Dec 2023 17:19:39 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 11 Dec 2023 11:19:38 -0600 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Mon, 11 Dec 2023 11:19:37 -0600 From: To: , , , , CC: Edward Cree , , , Jonathan Cooper Subject: [PATCH net-next 1/7] sfc: initial debugfs implementation Date: Mon, 11 Dec 2023 17:18:26 +0000 Message-ID: <9454bbffe8de24c0afcc6b307057e927ffaec6ca.1702314695.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB78:EE_|CY8PR12MB7706:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b3d7ba1-1521-4def-04e7-08dbfa6d5b85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zP+DCBFy0WndCvQmv0L51LJLvzP4Aln3dAR3pzOIeYGst7j4vgq9cBWAxm1ATjq900dLPH5/yhdbFpSxHGKDAplTNOIGXUcCA74fuqyPqW2iOwldr75BmDDpYDrN1RfLaET/9Bht0nMNHvyd7VUZUxuvOFLzjIVbR8zvomXX2TydDrVE29ucQUuKO1d/qusV0sBnhN6+1uKqasxSc/M6apw1KTz/gmFRts2t3OZ5GLIeytupFQpO1CgjO7LzinC8U1CWGorpV8wunit1BmpF9xFt6BSY+THNXMDrpLTdq2ce5BkQCQXVJJUopZpVHvHb50YJgyjTgvUBIh9lE81H5BpZ36TFUP6IlYBaXK5OFrQLQ0myzdVpim+PsVwtwVFZEVTURm+61GR7I/Bi1AOVHKgDbK5OFMTKymhuaBFBa92n7ObwW+SUzxGRLRGa17NHDmj3k9uUMLWJVblC3K1Be7+bTavRRytSRdjBCSZuQvjHKf+U70B98TYsPN6ZVtXDoPd86JrVD7/co/DzQhs0t+n+I/tj46HXDc4hKuT49lRzuaHbsmOnzn+1pLb8Q3yc2vF34+W1Mw5p0KGVNtjpXqctnNvchh03RE1SB07lO/wSW0WIWOgnGPolaglEOA/2PiObNnJC9ZeAnr+qKECyaqdzQQoPqZeMKSHIElrTpe6b1yWNiewHB5oh5QRwU9GTr8RyUxuBfeX6RoVzuZ4zgfg+RaRWH3gxmt/AClnbQXBoXR/v0VR1+CoOu1s03mtBH4DvgHEG3xOp6ERB//PVEL2KaihO+SWzkKESD9hXQVM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(376002)(39860400002)(346002)(136003)(230922051799003)(64100799003)(1800799012)(82310400011)(451199024)(186009)(36840700001)(46966006)(40470700004)(30864003)(6666004)(2906002)(2876002)(54906003)(70206006)(9686003)(356005)(81166007)(86362001)(55446002)(36756003)(4326008)(8676002)(8936002)(316002)(5660300002)(110136005)(40480700001)(70586007)(478600001)(40460700003)(41300700001)(36860700001)(82740400003)(47076005)(26005)(336012)(426003)(83380400001)(2004002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 17:19:39.6411 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5b3d7ba1-1521-4def-04e7-08dbfa6d5b85 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB78.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7706 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Just a handful of nodes, including one enum with a string table for pretty printing the values. Reviewed-by: Jonathan Cooper Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/Makefile | 1 + drivers/net/ethernet/sfc/debugfs.c | 234 ++++++++++++++++++++++++ drivers/net/ethernet/sfc/debugfs.h | 56 ++++++ drivers/net/ethernet/sfc/ef10.c | 10 + drivers/net/ethernet/sfc/ef100_netdev.c | 7 + drivers/net/ethernet/sfc/ef100_nic.c | 8 + drivers/net/ethernet/sfc/efx.c | 15 +- drivers/net/ethernet/sfc/efx_common.c | 7 + drivers/net/ethernet/sfc/net_driver.h | 29 +++ 9 files changed, 366 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/sfc/debugfs.c create mode 100644 drivers/net/ethernet/sfc/debugfs.h diff --git a/drivers/net/ethernet/sfc/Makefile b/drivers/net/ethernet/sfc/Makefile index 8f446b9bd5ee..1fbdd04dc2c5 100644 --- a/drivers/net/ethernet/sfc/Makefile +++ b/drivers/net/ethernet/sfc/Makefile @@ -12,6 +12,7 @@ sfc-$(CONFIG_SFC_MTD) += mtd.o sfc-$(CONFIG_SFC_SRIOV) += sriov.o ef10_sriov.o ef100_sriov.o ef100_rep.o \ mae.o tc.o tc_bindings.o tc_counters.o \ tc_encap_actions.o tc_conntrack.o +sfc-$(CONFIG_DEBUG_FS) += debugfs.o obj-$(CONFIG_SFC) += sfc.o diff --git a/drivers/net/ethernet/sfc/debugfs.c b/drivers/net/ethernet/sfc/debugfs.c new file mode 100644 index 000000000000..cf800addb4ff --- /dev/null +++ b/drivers/net/ethernet/sfc/debugfs.c @@ -0,0 +1,234 @@ +// SPDX-License-Identifier: GPL-2.0-only +/**************************************************************************** + * Driver for Solarflare network controllers and boards + * Copyright 2023, Advanced Micro Devices, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, incorporated herein by reference. + */ + +#include "debugfs.h" +#include +#include +#include +#include + +/* Maximum length for a name component or symlink target */ +#define EFX_DEBUGFS_NAME_LEN 32 + +/* Top-level debug directory ([/sys/kernel]/debug/sfc) */ +static struct dentry *efx_debug_root; + +/* "cards" directory ([/sys/kernel]/debug/sfc/cards) */ +static struct dentry *efx_debug_cards; + +/** + * efx_init_debugfs_netdev - create debugfs sym-link for net device + * @net_dev: Net device + * + * Create sym-link named after @net_dev to the debugfs directories for the + * corresponding NIC. The sym-link must be cleaned up using + * efx_fini_debugfs_netdev(). + * + * Return: a negative error code or 0 on success. + */ +static int efx_init_debugfs_netdev(struct net_device *net_dev) +{ + struct efx_nic *efx = efx_netdev_priv(net_dev); + char target[EFX_DEBUGFS_NAME_LEN]; + char name[EFX_DEBUGFS_NAME_LEN]; + + if (snprintf(name, sizeof(name), "nic_%s", net_dev->name) >= + sizeof(name)) + return -ENAMETOOLONG; + if (snprintf(target, sizeof(target), "cards/%s", pci_name(efx->pci_dev)) + >= sizeof(target)) + return -ENAMETOOLONG; + efx->debug_symlink = debugfs_create_symlink(name, + efx_debug_root, target); + if (IS_ERR_OR_NULL(efx->debug_symlink)) + return efx->debug_symlink ? PTR_ERR(efx->debug_symlink) : + -ENOMEM; + + return 0; +} + +/** + * efx_fini_debugfs_netdev - remove debugfs sym-link for net device + * @net_dev: Net device + * + * Remove sym-link created for @net_dev by efx_init_debugfs_netdev(). + */ +void efx_fini_debugfs_netdev(struct net_device *net_dev) +{ + struct efx_nic *efx = efx_netdev_priv(net_dev); + + debugfs_remove(efx->debug_symlink); + efx->debug_symlink = NULL; +} + +/* replace debugfs sym-links on net device rename */ +void efx_update_debugfs_netdev(struct efx_nic *efx) +{ + mutex_lock(&efx->debugfs_symlink_mutex); + if (efx->debug_symlink) + efx_fini_debugfs_netdev(efx->net_dev); + efx_init_debugfs_netdev(efx->net_dev); + mutex_unlock(&efx->debugfs_symlink_mutex); +} + +static int efx_debugfs_enum_read(struct seq_file *s, void *d) +{ + struct efx_debugfs_enum_data *data = s->private; + u64 value = 0; + size_t len; + + len = min(data->vlen, sizeof(value)); +#ifdef BIG_ENDIAN + /* If data->value is narrower than u64, we need to copy into the + * far end of value, as that's where the low bits live. + */ + memcpy(((void *)&value) + sizeof(value) - len, data->value, len); +#else + memcpy(&value, data->value, len); +#endif + seq_printf(s, "%#llx => %s\n", value, + value < data->max ? data->names[value] : "(invalid)"); + return 0; +} + +static int efx_debugfs_enum_open(struct inode *inode, struct file *f) +{ + struct efx_debugfs_enum_data *data = inode->i_private; + + return single_open(f, efx_debugfs_enum_read, data); +} + +static const struct file_operations efx_debugfs_enum_ops = { + .owner = THIS_MODULE, + .open = efx_debugfs_enum_open, + .release = single_release, + .read = seq_read, + .llseek = seq_lseek, +}; + +static void efx_debugfs_create_enum(const char *name, umode_t mode, + struct dentry *parent, + struct efx_debugfs_enum_data *data) +{ + debugfs_create_file(name, mode, parent, data, &efx_debugfs_enum_ops); +} + +static const char *const efx_interrupt_mode_names[] = { + [EFX_INT_MODE_MSIX] = "MSI-X", + [EFX_INT_MODE_MSI] = "MSI", + [EFX_INT_MODE_LEGACY] = "legacy", +}; + +#define EFX_DEBUGFS_EFX(_type, _name) \ + debugfs_create_##_type(#_name, 0444, efx->debug_dir, &efx->_name) + +/* Create basic debugfs parameter files for an Efx NIC */ +static void efx_init_debugfs_nic_files(struct efx_nic *efx) +{ + EFX_DEBUGFS_EFX(x32, rx_dma_len); + EFX_DEBUGFS_EFX(x32, rx_buffer_order); + EFX_DEBUGFS_EFX(x32, rx_buffer_truesize); + efx->debug_interrupt_mode.max = ARRAY_SIZE(efx_interrupt_mode_names); + efx->debug_interrupt_mode.names = efx_interrupt_mode_names; + efx->debug_interrupt_mode.vlen = sizeof(efx->interrupt_mode); + efx->debug_interrupt_mode.value = &efx->interrupt_mode; + efx_debugfs_create_enum("interrupt_mode", 0444, efx->debug_dir, + &efx->debug_interrupt_mode); +} + +/** + * efx_init_debugfs_nic - create debugfs directory for NIC + * @efx: Efx NIC + * + * Create debugfs directory containing parameter-files for @efx. + * The directory must be cleaned up using efx_fini_debugfs_nic(). + * + * Return: a negative error code or 0 on success. + */ +int efx_init_debugfs_nic(struct efx_nic *efx) +{ + /* Create directory */ + efx->debug_dir = debugfs_create_dir(pci_name(efx->pci_dev), + efx_debug_cards); + if (!efx->debug_dir) + return -ENOMEM; + efx_init_debugfs_nic_files(efx); + return 0; +} + +/** + * efx_fini_debugfs_nic - remove debugfs directory for NIC + * @efx: Efx NIC + * + * Remove debugfs directory created for @efx by efx_init_debugfs_nic(). + */ +void efx_fini_debugfs_nic(struct efx_nic *efx) +{ + debugfs_remove_recursive(efx->debug_dir); + efx->debug_dir = NULL; +} + +/** + * efx_init_debugfs - create debugfs directories for sfc driver + * + * Create debugfs directories "sfc" and "sfc/cards". This must be + * called before any of the other functions that create debugfs + * directories. The directories must be cleaned up using + * efx_fini_debugfs(). + * + * Return: a negative error code or 0 on success. + */ +int efx_init_debugfs(void) +{ + int rc; + + /* Create top-level directory */ + efx_debug_root = debugfs_create_dir(KBUILD_MODNAME, NULL); + if (!efx_debug_root) { + pr_err("debugfs_create_dir %s failed.\n", KBUILD_MODNAME); + rc = -ENOMEM; + goto err; + } else if (IS_ERR(efx_debug_root)) { + rc = PTR_ERR(efx_debug_root); + pr_err("debugfs_create_dir %s failed, rc=%d.\n", + KBUILD_MODNAME, rc); + goto err; + } + + /* Create "cards" directory */ + efx_debug_cards = debugfs_create_dir("cards", efx_debug_root); + if (!efx_debug_cards) { + pr_err("debugfs_create_dir cards failed.\n"); + rc = -ENOMEM; + goto err; + } else if (IS_ERR(efx_debug_cards)) { + rc = PTR_ERR(efx_debug_cards); + pr_err("debugfs_create_dir cards failed, rc=%d.\n", rc); + goto err; + } + + return 0; + +err: + efx_fini_debugfs(); + return rc; +} + +/** + * efx_fini_debugfs - remove debugfs directories for sfc driver + * + * Remove directories created by efx_init_debugfs(). + */ +void efx_fini_debugfs(void) +{ + debugfs_remove_recursive(efx_debug_root); + efx_debug_cards = NULL; + efx_debug_root = NULL; +} diff --git a/drivers/net/ethernet/sfc/debugfs.h b/drivers/net/ethernet/sfc/debugfs.h new file mode 100644 index 000000000000..1fe40fbffa5e --- /dev/null +++ b/drivers/net/ethernet/sfc/debugfs.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/**************************************************************************** + * Driver for Solarflare network controllers and boards + * Copyright 2023, Advanced Micro Devices, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, incorporated herein by reference. + */ + +#ifndef EFX_DEBUGFS_H +#define EFX_DEBUGFS_H +#include "net_driver.h" + +#ifdef CONFIG_DEBUG_FS + +/** + * DOC: Directory layout for sfc debugfs + * + * At top level ([/sys/kernel]/debug/sfc) are per-netdev symlinks "nic_$name" + * and the "cards" directory. For each PCI device to which the driver has + * bound and created a &struct efx_nic, there is a directory &efx_nic.debug_dir + * in "cards" whose name is the PCI address of the device; it is to this + * directory that the netdev symlink points. + */ + +void efx_fini_debugfs_netdev(struct net_device *net_dev); +void efx_update_debugfs_netdev(struct efx_nic *efx); + +int efx_init_debugfs_nic(struct efx_nic *efx); +void efx_fini_debugfs_nic(struct efx_nic *efx); + +int efx_init_debugfs(void); +void efx_fini_debugfs(void); + +#else /* CONFIG_DEBUG_FS */ + +static inline void efx_fini_debugfs_netdev(struct net_device *net_dev) {} + +static inline void efx_update_debugfs_netdev(struct efx_nic *efx) {} + +static inline int efx_init_debugfs_nic(struct efx_nic *efx) +{ + return 0; +} +static inline void efx_fini_debugfs_nic(struct efx_nic *efx) {} + +static inline int efx_init_debugfs(void) +{ + return 0; +} +static inline void efx_fini_debugfs(void) {} + +#endif /* CONFIG_DEBUG_FS */ + +#endif /* EFX_DEBUGFS_H */ diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index 6dfa062feebc..58e18fc92093 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c @@ -19,6 +19,7 @@ #include "workarounds.h" #include "selftest.h" #include "ef10_sriov.h" +#include "debugfs.h" #include #include #include @@ -580,6 +581,13 @@ static int efx_ef10_probe(struct efx_nic *efx) if (rc) goto fail3; + /* Populate debugfs */ +#ifdef CONFIG_DEBUG_FS + rc = efx_init_debugfs_nic(efx); + if (rc) + pci_err(efx->pci_dev, "failed to init device debugfs\n"); +#endif + rc = device_create_file(&efx->pci_dev->dev, &dev_attr_link_control_flag); if (rc) @@ -693,6 +701,7 @@ static int efx_ef10_probe(struct efx_nic *efx) fail4: device_remove_file(&efx->pci_dev->dev, &dev_attr_link_control_flag); fail3: + efx_fini_debugfs_nic(efx); efx_mcdi_detach(efx); mutex_lock(&nic_data->udp_tunnels_lock); @@ -962,6 +971,7 @@ static void efx_ef10_remove(struct efx_nic *efx) device_remove_file(&efx->pci_dev->dev, &dev_attr_link_control_flag); efx_mcdi_detach(efx); + efx_fini_debugfs_nic(efx); memset(nic_data->udp_tunnels, 0, sizeof(nic_data->udp_tunnels)); mutex_lock(&nic_data->udp_tunnels_lock); diff --git a/drivers/net/ethernet/sfc/ef100_netdev.c b/drivers/net/ethernet/sfc/ef100_netdev.c index 7f7d560cb2b4..e844d57754b7 100644 --- a/drivers/net/ethernet/sfc/ef100_netdev.c +++ b/drivers/net/ethernet/sfc/ef100_netdev.c @@ -26,10 +26,12 @@ #include "tc_bindings.h" #include "tc_encap_actions.h" #include "efx_devlink.h" +#include "debugfs.h" static void ef100_update_name(struct efx_nic *efx) { strcpy(efx->name, efx->net_dev->name); + efx_update_debugfs_netdev(efx); } static int ef100_alloc_vis(struct efx_nic *efx, unsigned int *allocated_vis) @@ -405,6 +407,11 @@ void ef100_remove_netdev(struct efx_probe_data *probe_data) ef100_pf_unset_devlink_port(efx); efx_fini_tc(efx); #endif +#ifdef CONFIG_DEBUG_FS + mutex_lock(&efx->debugfs_symlink_mutex); + efx_fini_debugfs_netdev(efx->net_dev); + mutex_unlock(&efx->debugfs_symlink_mutex); +#endif down_write(&efx->filter_sem); efx_mcdi_filter_table_remove(efx); diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c index 6da06931187d..ad378aa05dc3 100644 --- a/drivers/net/ethernet/sfc/ef100_nic.c +++ b/drivers/net/ethernet/sfc/ef100_nic.c @@ -27,6 +27,7 @@ #include "tc.h" #include "mae.h" #include "rx_common.h" +#include "debugfs.h" #define EF100_MAX_VIS 4096 #define EF100_NUM_MCDI_BUFFERS 1 @@ -1077,6 +1078,12 @@ static int ef100_probe_main(struct efx_nic *efx) /* Post-IO section. */ + /* Populate debugfs */ +#ifdef CONFIG_DEBUG_FS + rc = efx_init_debugfs_nic(efx); + if (rc) + pci_err(efx->pci_dev, "failed to init device debugfs\n"); +#endif rc = efx_mcdi_init(efx); if (rc) goto fail; @@ -1213,6 +1220,7 @@ void ef100_remove(struct efx_nic *efx) efx_mcdi_detach(efx); efx_mcdi_fini(efx); + efx_fini_debugfs_nic(efx); if (nic_data) efx_nic_free_buffer(efx, &nic_data->mcdi_buf); kfree(nic_data); diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 19f4b4d0b851..9266c7b5b4fd 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -33,6 +33,7 @@ #include "selftest.h" #include "sriov.h" #include "efx_devlink.h" +#include "debugfs.h" #include "mcdi_port_common.h" #include "mcdi_pcol.h" @@ -401,6 +402,11 @@ static void efx_remove_all(struct efx_nic *efx) #endif efx_remove_port(efx); efx_remove_nic(efx); +#ifdef CONFIG_DEBUG_FS + mutex_lock(&efx->debugfs_symlink_mutex); + efx_fini_debugfs_netdev(efx->net_dev); + mutex_unlock(&efx->debugfs_symlink_mutex); +#endif } /************************************************************************** @@ -667,6 +673,7 @@ static void efx_update_name(struct efx_nic *efx) strcpy(efx->name, efx->net_dev->name); efx_mtd_rename(efx); efx_set_channel_names(efx); + efx_update_debugfs_netdev(efx); } static int efx_netdev_event(struct notifier_block *this, @@ -1319,6 +1326,10 @@ static int __init efx_init_module(void) printk(KERN_INFO "Solarflare NET driver\n"); + rc = efx_init_debugfs(); + if (rc) + goto err_debugfs; + rc = register_netdevice_notifier(&efx_netdev_notifier); if (rc) goto err_notifier; @@ -1344,6 +1355,8 @@ static int __init efx_init_module(void) err_reset: unregister_netdevice_notifier(&efx_netdev_notifier); err_notifier: + efx_fini_debugfs(); + err_debugfs: return rc; } @@ -1355,7 +1368,7 @@ static void __exit efx_exit_module(void) pci_unregister_driver(&efx_pci_driver); efx_destroy_reset_workqueue(); unregister_netdevice_notifier(&efx_netdev_notifier); - + efx_fini_debugfs(); } module_init(efx_init_module); diff --git a/drivers/net/ethernet/sfc/efx_common.c b/drivers/net/ethernet/sfc/efx_common.c index 175bd9cdfdac..7a9d6b6b66e5 100644 --- a/drivers/net/ethernet/sfc/efx_common.c +++ b/drivers/net/ethernet/sfc/efx_common.c @@ -1022,6 +1022,9 @@ int efx_init_struct(struct efx_nic *efx, struct pci_dev *pci_dev) INIT_WORK(&efx->mac_work, efx_mac_work); init_waitqueue_head(&efx->flush_wq); +#ifdef CONFIG_DEBUG_FS + mutex_init(&efx->debugfs_symlink_mutex); +#endif efx->tx_queues_per_channel = 1; efx->rxq_entries = EFX_DEFAULT_DMAQ_SIZE; efx->txq_entries = EFX_DEFAULT_DMAQ_SIZE; @@ -1056,6 +1059,10 @@ void efx_fini_struct(struct efx_nic *efx) efx_fini_channels(efx); +#ifdef CONFIG_DEBUG_FS + mutex_destroy(&efx->debugfs_symlink_mutex); +#endif + kfree(efx->vpd_sn); if (efx->workqueue) { diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 27d86e90a3bb..961e2db31c6e 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -107,6 +107,24 @@ struct hwtstamp_config; struct efx_self_tests; +/** + * struct efx_debugfs_enum_data - information for pretty-printing enums + * @value: pointer to the actual enum + * @vlen: sizeof the enum + * @names: array of names of enumerated values. May contain some %NULL entries. + * @max: number of entries in @names, typically from ARRAY_SIZE() + * + * Where a driver struct contains an enum member which we wish to expose in + * debugfs, we also embed an instance of this struct, which + * efx_debugfs_enum_read() uses to pretty-print the value. + */ +struct efx_debugfs_enum_data { + void *value; + size_t vlen; + const char *const *names; + unsigned int max; +}; + /** * struct efx_buffer - A general-purpose DMA buffer * @addr: host base address of the buffer @@ -1123,6 +1141,17 @@ struct efx_nic { u32 rps_next_id; #endif +#ifdef CONFIG_DEBUG_FS + /** @debug_dir: NIC debugfs directory */ + struct dentry *debug_dir; + /** @debug_symlink: NIC debugfs symlink (``nic_eth%d``) */ + struct dentry *debug_symlink; + /** @debug_interrupt_mode: debugfs details for printing @interrupt_mode */ + struct efx_debugfs_enum_data debug_interrupt_mode; + /** @debugfs_symlink_mutex: protects debugfs @debug_symlink */ + struct mutex debugfs_symlink_mutex; +#endif + atomic_t active_queues; atomic_t rxq_flush_pending; atomic_t rxq_flush_outstanding; From patchwork Mon Dec 11 17:18:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13487704 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="I0DMjaFN" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2078.outbound.protection.outlook.com [40.107.243.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7B389B for ; Mon, 11 Dec 2023 09:19:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lYNDbF9wCi+Bu6HoKSAwCefGLoDwJ0IHFia9/s04f2AVCcDJyaF0ojKxhUJ9+rAthRflVfwSrlh1zd1WbZTCJYDA+DnOarWM9rn7NLi6tvCNVDrSLefM7foRZNhMfSvV+8C/gc/IRluFNI5bHqh/Q4L6HO7z0X2ElX3hl1zyeO4AussvFvBvfjeqxZb4nXuiOME9WQa2ih+M4GMcejwZvS8DkM0s0rkt9aTUq7M6pNqjzx1Fq5ELw+9yiRtBGKCqiEc4QgNWK+k8K6BMQsyzz/CMtlFJHqSJxFqnRbNRiMYqork8LscnQ5WcUUYLsgU3B71jlqTxNpBgvzul0abEqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QSf7IM+yJK+2bOGxs8/iljwayHYTF/LX7QhnW9vZDGo=; b=WOkqbC6iOY5ae+01276vpRLHV+jRb7WIwxVXxYnBb+Q4z1ViJzyRRwSJwHVlqh/+zZxpojdqBOxZv+SNqtTYPN+rLdsNG5b8ZFZpzfAMox9dnRORkZ/ExffkEm5aNgwIso5OLJGkK5bcEM86PXMhm94t3/DZ2f8fKqYOgO0vFQ/rXUFEHkJp4hEU+uShcHuPjyhIS/f6gAXWZdgKDHWB/uhmPmDV8hos1JRGGEo0YmeFg+njo3onplFzdY4Qg63erNOLCumZoVZpmUdETlMkBkLO9dKK1+/qko8NaWSV/IjECMCJgvMrQmIfm2O4k0teVofnJ2Rq+n/ZeBAVOGdvog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QSf7IM+yJK+2bOGxs8/iljwayHYTF/LX7QhnW9vZDGo=; b=I0DMjaFN/ADP+ppaNpVfQtUhzSL7vbw0ZBGqBIxxor0ciJLwZNdsQLxVGEeiX4JiZUaUIpyAhJk+0bBYKJHPTPK92ba8sYNKdGc0NTzTYkXL3SRTPfyYYQVCMEBdp24o20pv2cP0CtfCFv+nDjPWnGEeXJPDoXBuYJu1/WKmgNI= Received: from DM6PR13CA0002.namprd13.prod.outlook.com (2603:10b6:5:bc::15) by MW4PR12MB6730.namprd12.prod.outlook.com (2603:10b6:303:1ec::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Mon, 11 Dec 2023 17:19:42 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:5:bc:cafe::56) by DM6PR13CA0002.outlook.office365.com (2603:10b6:5:bc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.21 via Frontend Transport; Mon, 11 Dec 2023 17:19:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CY4PEPF0000EDD0.mail.protection.outlook.com (10.167.241.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7091.19 via Frontend Transport; Mon, 11 Dec 2023 17:19:41 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 11 Dec 2023 11:19:40 -0600 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Mon, 11 Dec 2023 11:19:39 -0600 From: To: , , , , CC: Edward Cree , , , Jonathan Cooper Subject: [PATCH net-next 2/7] sfc: debugfs for channels Date: Mon, 11 Dec 2023 17:18:27 +0000 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD0:EE_|MW4PR12MB6730:EE_ X-MS-Office365-Filtering-Correlation-Id: a2093385-4d05-4255-7587-08dbfa6d5cd9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LoeBl8Is6yPLYrjNhtR2+01Z3k1CVV3eiTDwGd8G0sG49FogJjRHxhsB/ALl87pYGV2xdrf0gZKSGL5gzthoIKHQprDaJNtFXmvkOwmPhuswxxhUUd/OzLnIcGMHs/Hb0KgRFTdl3fQMdcfp7hudAe/0HQm+10brim3LKDXpj8AAxI6fCgaUqtRQo3t4rRCswSv+ZtxBx2Tx6PHzGz85ginbZxfZz9+jpQCNtthshCKtZGxIK82x6r/iZuajrQfSGIgag9c+WnSM+pEDEBKeQiZtwjNTyOgdAy9aBquOAKkmtJNQ2Y/8hRFgXpire36qbUqkq5BSFgeNen3X7a3364gTZXLByzk++uF3zZXOvwDjf+xshKpp8foKS1jNaqOMu35BEHTqMWRjnvtyFoTObmw09JK6mRuKvQN6kIGVah52kE6uUx/LtuUNiPcW+gTGTr5FpfqDw83wAq6i3qzAba8+LzwhLg8UHiqfyH5S3EGte7eZQjE7ifJfPx48NYTS1bNHy2C/YmWSzbFpavjvUtZ3yr4qR3Ie0v3z5R8aww4iym8U/FX37DNWr0otST2Avw0KnwrjNuwlcXlvxW5/tqKrY75MwXXFjxHHZsp2UGf16n8wocPDN/wFVsmqa91ttQpPDqEnL2tYJngS5naemje7JC4pSsMYjzAvdJKJpwoGQylsj8ia3zmPhZH5stmQh+IwYkDOG0g9MDuLuCpDsqrOOJjmjohKGhDDqe0dHPtGdLX/9Od9KN8mrdBCbUKIr0wazMyUzMPvCpaEJft/qg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(346002)(376002)(396003)(136003)(230922051799003)(1800799012)(451199024)(64100799003)(82310400011)(186009)(40470700004)(36840700001)(46966006)(9686003)(40460700003)(36860700001)(5660300002)(47076005)(336012)(26005)(36756003)(426003)(54906003)(70586007)(70206006)(40480700001)(2876002)(2906002)(83380400001)(81166007)(82740400003)(41300700001)(356005)(478600001)(86362001)(8676002)(8936002)(4326008)(55446002)(110136005)(316002)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 17:19:41.8254 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a2093385-4d05-4255-7587-08dbfa6d5cd9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6730 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Expose each channel's IRQ number and EVQ read pointer. Reviewed-by: Jonathan Cooper Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/debugfs.c | 51 +++++++++++++++++++++++++ drivers/net/ethernet/sfc/debugfs.h | 15 ++++++++ drivers/net/ethernet/sfc/efx_channels.c | 8 ++++ drivers/net/ethernet/sfc/net_driver.h | 6 +++ 4 files changed, 80 insertions(+) diff --git a/drivers/net/ethernet/sfc/debugfs.c b/drivers/net/ethernet/sfc/debugfs.c index cf800addb4ff..b46339249794 100644 --- a/drivers/net/ethernet/sfc/debugfs.c +++ b/drivers/net/ethernet/sfc/debugfs.c @@ -78,6 +78,54 @@ void efx_update_debugfs_netdev(struct efx_nic *efx) mutex_unlock(&efx->debugfs_symlink_mutex); } +#define EFX_DEBUGFS_CHANNEL(_type, _name) \ + debugfs_create_##_type(#_name, 0444, channel->debug_dir, &channel->_name) + +/* Create basic debugfs parameter files for an Efx channel */ +static void efx_init_debugfs_channel_files(struct efx_channel *channel) +{ + EFX_DEBUGFS_CHANNEL(bool, enabled); + EFX_DEBUGFS_CHANNEL(u32, irq); /* actually an int */ + EFX_DEBUGFS_CHANNEL(u32, eventq_read_ptr); +} + +/** + * efx_init_debugfs_channel - create debugfs directory for channel + * @channel: Efx channel + * + * Create a debugfs directory containing parameter-files for @channel. + * The directory must be cleaned up using efx_fini_debugfs_channel(). + * + * Return: a negative error code or 0 on success. + */ +int efx_init_debugfs_channel(struct efx_channel *channel) +{ + char name[EFX_DEBUGFS_NAME_LEN]; + + if (!channel->efx->debug_channels_dir) + return -ENODEV; + if (snprintf(name, sizeof(name), "%d", channel->channel) + >= sizeof(name)) + return -ENAMETOOLONG; + channel->debug_dir = debugfs_create_dir(name, channel->efx->debug_channels_dir); + if (!channel->debug_dir) + return -ENOMEM; + efx_init_debugfs_channel_files(channel); + return 0; +} + +/** + * efx_fini_debugfs_channel - remove debugfs directory for channel + * @channel: Efx channel + * + * Remove directory created for @channel by efx_init_debugfs_channel(). + */ +void efx_fini_debugfs_channel(struct efx_channel *channel) +{ + debugfs_remove_recursive(channel->debug_dir); + channel->debug_dir = NULL; +} + static int efx_debugfs_enum_read(struct seq_file *s, void *d) { struct efx_debugfs_enum_data *data = s->private; @@ -160,6 +208,9 @@ int efx_init_debugfs_nic(struct efx_nic *efx) if (!efx->debug_dir) return -ENOMEM; efx_init_debugfs_nic_files(efx); + /* Create channels subdirectory */ + efx->debug_channels_dir = debugfs_create_dir("channels", + efx->debug_dir); return 0; } diff --git a/drivers/net/ethernet/sfc/debugfs.h b/drivers/net/ethernet/sfc/debugfs.h index 1fe40fbffa5e..4af4a03d1b97 100644 --- a/drivers/net/ethernet/sfc/debugfs.h +++ b/drivers/net/ethernet/sfc/debugfs.h @@ -22,11 +22,20 @@ * bound and created a &struct efx_nic, there is a directory &efx_nic.debug_dir * in "cards" whose name is the PCI address of the device; it is to this * directory that the netdev symlink points. + * + * Under this directory, besides top-level parameter files, are: + * + * * "channels/" (&efx_nic.debug_channels_dir). For each channel, this will + * contain a directory (&efx_channel.debug_dir), whose name is the channel + * index (in decimal). */ void efx_fini_debugfs_netdev(struct net_device *net_dev); void efx_update_debugfs_netdev(struct efx_nic *efx); +int efx_init_debugfs_channel(struct efx_channel *channel); +void efx_fini_debugfs_channel(struct efx_channel *channel); + int efx_init_debugfs_nic(struct efx_nic *efx); void efx_fini_debugfs_nic(struct efx_nic *efx); @@ -39,6 +48,12 @@ static inline void efx_fini_debugfs_netdev(struct net_device *net_dev) {} static inline void efx_update_debugfs_netdev(struct efx_nic *efx) {} +int efx_init_debugfs_channel(struct efx_channel *channel) +{ + return 0; +} +void efx_fini_debugfs_channel(struct efx_channel *channel) {} + static inline int efx_init_debugfs_nic(struct efx_nic *efx) { return 0; diff --git a/drivers/net/ethernet/sfc/efx_channels.c b/drivers/net/ethernet/sfc/efx_channels.c index c9e17a8208a9..804a25ceea7f 100644 --- a/drivers/net/ethernet/sfc/efx_channels.c +++ b/drivers/net/ethernet/sfc/efx_channels.c @@ -19,6 +19,7 @@ #include "nic.h" #include "sriov.h" #include "workarounds.h" +#include "debugfs.h" /* This is the first interrupt mode to try out of: * 0 => MSI-X @@ -667,6 +668,12 @@ static int efx_probe_channel(struct efx_channel *channel) channel->rx_list = NULL; + rc = efx_init_debugfs_channel(channel); + if (rc) /* not fatal */ + netif_err(channel->efx, drv, channel->efx->net_dev, + "Failed to create debugfs for channel %d, rc=%d\n", + channel->channel, rc); + return 0; fail: @@ -743,6 +750,7 @@ void efx_remove_channel(struct efx_channel *channel) netif_dbg(channel->efx, drv, channel->efx->net_dev, "destroy chan %d\n", channel->channel); + efx_fini_debugfs_channel(channel); efx_for_each_channel_rx_queue(rx_queue, channel) efx_remove_rx_queue(rx_queue); diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 961e2db31c6e..2b92c5461fe3 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -528,6 +528,10 @@ struct efx_channel { #define RPS_FLOW_ID_INVALID 0xFFFFFFFF u32 *rps_flow_id; #endif +#ifdef CONFIG_DEBUG_FS + /** @debug_dir: Channel debugfs directory (under @efx->debug_channels_dir) */ + struct dentry *debug_dir; +#endif unsigned int n_rx_tobe_disc; unsigned int n_rx_ip_hdr_chksum_err; @@ -1144,6 +1148,8 @@ struct efx_nic { #ifdef CONFIG_DEBUG_FS /** @debug_dir: NIC debugfs directory */ struct dentry *debug_dir; + /** @debug_channels_dir: contains channel debugfs dirs. Under @debug_dir */ + struct dentry *debug_channels_dir; /** @debug_symlink: NIC debugfs symlink (``nic_eth%d``) */ struct dentry *debug_symlink; /** @debug_interrupt_mode: debugfs details for printing @interrupt_mode */ From patchwork Mon Dec 11 17:18:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13487701 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="fh3I99uR" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2076.outbound.protection.outlook.com [40.107.223.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F6C3C7 for ; Mon, 11 Dec 2023 09:19:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fKLhVw9WJIgBMLXJ+SDofFr+ITVbYqKFG73Yh9g+MphIsHPyBK7XkT0+wTiwxjGkZzoazdzbB3RvQiMsiLsgmi/6okE7HhWIl8/4Cufknecg0Yd5+W84tpg5MgSaV2jDJr6rXsgc1oKP3Jpq4lA77fNOr9VH940aTL815wJuPFmh+Zjyhz4dP5sOxG8HtG43MCCbNY8uZYSyuDh7eF4Q2NI8OR0nCvLviXVdcXHai3ocV7Ti2qht8X4SPXha+zlFAyEe0PGdC88BEabEUMzSjiak7+Ska4fBSvuQJmjQgkCWocR9Bu3pWBbXo8OxtvnFp5beI1f/pQ2KAg5XPBYCgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mbu3jWDf6McsLaLyo98cnxOOfoXvMuUZYavxn2YJI18=; b=nHPSxWE6dZr9eI8mspqh2DZS/Or1ZnlkGN9WnpWAU3b7SaShr+7FUyne0hD/T8QSGXNnMxURtSP2KiEaouKfp4IoLyhSYtbc8p1alo17+L1T7YMilfk48EIeBpB3Y642nrs+sJ9oh/F/PwWkMd+Dvn32VL+Rr5oC5o2vEkhcZMuaaLEaoNmnaahWx22qAGwYnDsF/EcpPGAI9kFgOZuQGjk20dCKapi1dtwhpHXiSp920AHpp/XygExZ7de4oyS2eUKVHUBEEm9UQcp2X+0oex/qosONirXsgEwjftk/TYtmR/IR0NFTka9ARcL4+b2/42s6PJltQ+RndKGA6Sihiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mbu3jWDf6McsLaLyo98cnxOOfoXvMuUZYavxn2YJI18=; b=fh3I99uRARTpDssD0d420H+fkFul5GrettSLOIBPVnEVOTmv7eLL7q1pYzAY1rXURBB1mkEUaC76XVI0X1b9mzsKoK3ZpW095oUEbEENF+Wtc+zzEbUnIvH5jvk6owc1fDqR+6Sqkncp3paIg3iCdVkl1k7CxaFdv9OBhgdi6TI= Received: from BL1PR13CA0304.namprd13.prod.outlook.com (2603:10b6:208:2c1::9) by DM4PR12MB6110.namprd12.prod.outlook.com (2603:10b6:8:ad::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 17:19:43 +0000 Received: from BL6PEPF0001AB78.namprd02.prod.outlook.com (2603:10b6:208:2c1:cafe::35) by BL1PR13CA0304.outlook.office365.com (2603:10b6:208:2c1::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.21 via Frontend Transport; Mon, 11 Dec 2023 17:19:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB78.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7091.18 via Frontend Transport; Mon, 11 Dec 2023 17:19:43 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 11 Dec 2023 11:19:42 -0600 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Mon, 11 Dec 2023 11:19:41 -0600 From: To: , , , , CC: Edward Cree , , , Jonathan Cooper Subject: [PATCH net-next 3/7] sfc: debugfs for (nic) RX queues Date: Mon, 11 Dec 2023 17:18:28 +0000 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB78:EE_|DM4PR12MB6110:EE_ X-MS-Office365-Filtering-Correlation-Id: 88a92d96-b49d-4540-5274-08dbfa6d5d96 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9EF/gWeeUN00zNDLqJKFTsLTRxtn45zoEFCxh3xDAPbrxXYEgf3DZC6ixpa/xTVmDL/kc9iikxBjV3E9u3doo9OSvIKpwdmzCcLVt1jNzPUEouxOV5qYf3K8VoYENwDhl28vNLA89ZxNE6tHyZkVcgJZeANaULPKk+d8Tl8J1OX7mVHyFXkNrlvUzEY80CUjBLmEzrbzKWvVUgGLOc6NJJqhtOOu14UqGTvRWolAp9BHS3iybIuV/c8ERmm9d1RqN0HlFLPl5dnEZOMs8ga5KhX0fJmtfWG4PXm+T0rh7204WUIMppHhImHdriVpRHTsTBaCxwk+cPPOaIXptz1mGrlYUHsYt/Pwv01GyxX9X4HSSP5NVzeorU5TixFvBtaT6F3ZCmaxcV9g3iaewIjcKKdRlnk/Ta7gZvu13ykUORKLvu1CfWWYQx5pvpsX696z6g6Fy2BCv9Br/ChpbHlqGFw1E1PKw6yXpCg0JJ7o+LyJF+Aoc1jXl0dGcq5oQSBrtiHdKvDuc4ar2c1UgtsO1T2Soknj/m6l1M0ddMZ4JUJF6MebMUNH+axh25f9asDvRLYRCjxHa6QMdBmLq27IMzzIb2QM7mi9nJ7sbD7meEVFHO3XR2fYUFp6zDe2f8YUrKvd4sm32tejF0Qh/gIIL22FMMo3yi/MdeiXhniT70+XZp1FrExQUvgtumrMQoaDwk0Z4q7ABAU0ooGPaF9ZCsG2ru6zmUROnhog0dQgrEjvsJy+oSAeNoQy7qSYKT4tPKrXL9MZD6V0CJPWbrzsag== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(39860400002)(136003)(376002)(346002)(230922051799003)(82310400011)(1800799012)(64100799003)(186009)(451199024)(36840700001)(46966006)(40470700004)(40480700001)(426003)(336012)(26005)(40460700003)(82740400003)(81166007)(36756003)(356005)(55446002)(86362001)(83380400001)(5660300002)(9686003)(6666004)(36860700001)(8936002)(70586007)(8676002)(110136005)(70206006)(54906003)(316002)(47076005)(2906002)(4326008)(2876002)(41300700001)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 17:19:43.1100 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 88a92d96-b49d-4540-5274-08dbfa6d5d96 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB78.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6110 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Expose each RX queue's core RXQ association, and the read/write/etc pointers for the descriptor ring. Each RXQ dir also symlinks to its owning channel. Reviewed-by: Jonathan Cooper Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/debugfs.c | 69 ++++++++++++++++++++++++++- drivers/net/ethernet/sfc/debugfs.h | 15 ++++++ drivers/net/ethernet/sfc/net_driver.h | 6 +++ drivers/net/ethernet/sfc/rx_common.c | 9 ++++ 4 files changed, 98 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/debugfs.c b/drivers/net/ethernet/sfc/debugfs.c index b46339249794..43b1d06a985e 100644 --- a/drivers/net/ethernet/sfc/debugfs.c +++ b/drivers/net/ethernet/sfc/debugfs.c @@ -78,6 +78,72 @@ void efx_update_debugfs_netdev(struct efx_nic *efx) mutex_unlock(&efx->debugfs_symlink_mutex); } +#define EFX_DEBUGFS_RXQ(_type, _name) \ + debugfs_create_##_type(#_name, 0444, rx_queue->debug_dir, &rx_queue->_name) + +/* Create basic debugfs parameter files for an Efx RXQ */ +static void efx_init_debugfs_rx_queue_files(struct efx_rx_queue *rx_queue) +{ + EFX_DEBUGFS_RXQ(u32, core_index); /* actually an int */ + /* descriptor ring indices */ + EFX_DEBUGFS_RXQ(u32, added_count); + EFX_DEBUGFS_RXQ(u32, notified_count); + EFX_DEBUGFS_RXQ(u32, granted_count); + EFX_DEBUGFS_RXQ(u32, removed_count); +} + +/** + * efx_init_debugfs_rx_queue - create debugfs directory for RX queue + * @rx_queue: Efx RX queue + * + * Create a debugfs directory containing parameter-files for @rx_queue. + * The directory must be cleaned up using efx_fini_debugfs_rx_queue(), + * even if this function returns an error. + * + * Return: a negative error code or 0 on success. + */ +int efx_init_debugfs_rx_queue(struct efx_rx_queue *rx_queue) +{ + struct efx_channel *channel = efx_rx_queue_channel(rx_queue); + char target[EFX_DEBUGFS_NAME_LEN]; + char name[EFX_DEBUGFS_NAME_LEN]; + + if (!rx_queue->efx->debug_queues_dir) + return -ENODEV; + /* Create directory */ + if (snprintf(name, sizeof(name), "rx-%d", efx_rx_queue_index(rx_queue)) + >= sizeof(name)) + return -ENAMETOOLONG; + rx_queue->debug_dir = debugfs_create_dir(name, + rx_queue->efx->debug_queues_dir); + if (!rx_queue->debug_dir) + return -ENOMEM; + + /* Create files */ + efx_init_debugfs_rx_queue_files(rx_queue); + + /* Create symlink to channel */ + if (snprintf(target, sizeof(target), "../../channels/%d", + channel->channel) >= sizeof(target)) + return -ENAMETOOLONG; + if (!debugfs_create_symlink("channel", rx_queue->debug_dir, target)) + return -ENOMEM; + + return 0; +} + +/** + * efx_fini_debugfs_rx_queue - remove debugfs directory for RX queue + * @rx_queue: Efx RX queue + * + * Remove directory created for @rx_queue by efx_init_debugfs_rx_queue(). + */ +void efx_fini_debugfs_rx_queue(struct efx_rx_queue *rx_queue) +{ + debugfs_remove_recursive(rx_queue->debug_dir); + rx_queue->debug_dir = NULL; +} + #define EFX_DEBUGFS_CHANNEL(_type, _name) \ debugfs_create_##_type(#_name, 0444, channel->debug_dir, &channel->_name) @@ -208,9 +274,10 @@ int efx_init_debugfs_nic(struct efx_nic *efx) if (!efx->debug_dir) return -ENOMEM; efx_init_debugfs_nic_files(efx); - /* Create channels subdirectory */ + /* Create subdirectories */ efx->debug_channels_dir = debugfs_create_dir("channels", efx->debug_dir); + efx->debug_queues_dir = debugfs_create_dir("queues", efx->debug_dir); return 0; } diff --git a/drivers/net/ethernet/sfc/debugfs.h b/drivers/net/ethernet/sfc/debugfs.h index 4af4a03d1b97..53c98a2fb4c9 100644 --- a/drivers/net/ethernet/sfc/debugfs.h +++ b/drivers/net/ethernet/sfc/debugfs.h @@ -28,11 +28,20 @@ * * "channels/" (&efx_nic.debug_channels_dir). For each channel, this will * contain a directory (&efx_channel.debug_dir), whose name is the channel * index (in decimal). + * * "queues/" (&efx_nic.debug_queues_dir). + * + * * For each NIC RX queue, this will contain a directory + * (&efx_rx_queue.debug_dir), whose name is "rx-N" where N is the RX queue + * index. (This may not be the same as the kernel core RX queue index.) + * The directory will contain a symlink to the owning channel. */ void efx_fini_debugfs_netdev(struct net_device *net_dev); void efx_update_debugfs_netdev(struct efx_nic *efx); +int efx_init_debugfs_rx_queue(struct efx_rx_queue *rx_queue); +void efx_fini_debugfs_rx_queue(struct efx_rx_queue *rx_queue); + int efx_init_debugfs_channel(struct efx_channel *channel); void efx_fini_debugfs_channel(struct efx_channel *channel); @@ -48,6 +57,12 @@ static inline void efx_fini_debugfs_netdev(struct net_device *net_dev) {} static inline void efx_update_debugfs_netdev(struct efx_nic *efx) {} +int efx_init_debugfs_rx_queue(struct efx_rx_queue *rx_queue) +{ + return 0; +} +void efx_fini_debugfs_rx_queue(struct efx_rx_queue *rx_queue) {} + int efx_init_debugfs_channel(struct efx_channel *channel) { return 0; diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 2b92c5461fe3..63eb32670826 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -424,6 +424,10 @@ struct efx_rx_queue { struct work_struct grant_work; /* Statistics to supplement MAC stats */ unsigned long rx_packets; +#ifdef CONFIG_DEBUG_FS + /** @debug_dir: Queue debugfs directory (under @efx->debug_queues_dir) */ + struct dentry *debug_dir; +#endif struct xdp_rxq_info xdp_rxq_info; bool xdp_rxq_info_valid; }; @@ -1150,6 +1154,8 @@ struct efx_nic { struct dentry *debug_dir; /** @debug_channels_dir: contains channel debugfs dirs. Under @debug_dir */ struct dentry *debug_channels_dir; + /** @debug_queues_dir: contains RX/TX queue debugfs dirs. Under @debug_dir */ + struct dentry *debug_queues_dir; /** @debug_symlink: NIC debugfs symlink (``nic_eth%d``) */ struct dentry *debug_symlink; /** @debug_interrupt_mode: debugfs details for printing @interrupt_mode */ diff --git a/drivers/net/ethernet/sfc/rx_common.c b/drivers/net/ethernet/sfc/rx_common.c index d2f35ee15eff..7f63f70f082d 100644 --- a/drivers/net/ethernet/sfc/rx_common.c +++ b/drivers/net/ethernet/sfc/rx_common.c @@ -14,6 +14,7 @@ #include "efx.h" #include "nic.h" #include "rx_common.h" +#include "debugfs.h" /* This is the percentage fill level below which new RX descriptors * will be added to the RX descriptor ring. @@ -208,6 +209,12 @@ int efx_probe_rx_queue(struct efx_rx_queue *rx_queue) if (!rx_queue->buffer) return -ENOMEM; + rc = efx_init_debugfs_rx_queue(rx_queue); + if (rc) /* not fatal */ + netif_err(efx, drv, efx->net_dev, + "Failed to create debugfs for RXQ %d, rc=%d\n", + efx_rx_queue_index(rx_queue), rc); + rc = efx_nic_probe_rx(rx_queue); if (rc) { kfree(rx_queue->buffer); @@ -311,6 +318,8 @@ void efx_remove_rx_queue(struct efx_rx_queue *rx_queue) efx_nic_remove_rx(rx_queue); + efx_fini_debugfs_rx_queue(rx_queue); + kfree(rx_queue->buffer); rx_queue->buffer = NULL; } From patchwork Mon Dec 11 17:18:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13487703 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="J19yIvQt" Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2072.outbound.protection.outlook.com [40.107.94.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29660CF for ; Mon, 11 Dec 2023 09:19:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NGYheD7zjP/nLYMOuvtWg+cFLZ6bWkx180W9Vu9yHcWTr9BcbhwQCjgD1PVRrFelsoOq4tV7cqtSox77TCm9H0ckttfjsBOC2YaLPPIT5RvSq+eMwWICW7wczcmGpxdJ15OhLr1vlGBc6HT/uvialqyCL1F4Lbc95Lu65dMZByNWZjOzyMKwCiwiY2zyGjRdQ9R0rAa5AOXydpA6wshnttrIJpg0y3O67O/jVGWAl7vj6etWB/GVG+wwBdkFG5B+WFUqJoHq7/lkMKekdTHl/qrLfl97N7MqwG1yxFKD80aohGiDoHnbNMZ6IbHiXDrH//pEKKv05RGibFwMsaNdOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sbTvZ8qbUZ8Fx17miXc33ApZU0mLxRuM6IqI8xBdFaA=; b=cyT5Oo4S5e8cY04B7nBJXfZYB8iSA2SvuNZNIMaY/EzzUr5bcOAFaBXT9Qx0TJMqZodFGMbIjtoShXvwHEQnhvSSK5+jrfF+OdW+ha66Wy7Uw3L2rz7OQMdiS8xxE+jMPuyfXlR+ZwY9vgPRydxpw0cjnDiIC8dpcjZBz07JvkmhVoVKNtViV+lTHYy2hFgDBVxcMxQPutCc8KdameBYj0zGyWdYPWXUROEA1OKWH4w35bZLqHAJtRAkzs2vnd0bUefVKABCqreAzxAZ701nV0ssele8S9rJv4UmYjNS3Jt7TGfSTEBPX5OYONrkV5Xy062YqVN9MbmEQlC0fZOTDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sbTvZ8qbUZ8Fx17miXc33ApZU0mLxRuM6IqI8xBdFaA=; b=J19yIvQtsCHV0KXRK886Y3M4hf+4bP3Jl90wZGy+KJGl8I+X1Pd54KsKuz88aciIMctwENvkUDBnZDw9ZGZcjTcwU44xx5CTTGalmXBQyN08SLQd86eBgeVs32X68Ag5yB+FM2l1eAmXgGYyq4x8VjxhV1EsLe2QEM6jIUhluvc= Received: from BL1PR13CA0304.namprd13.prod.outlook.com (2603:10b6:208:2c1::9) by SN7PR12MB7853.namprd12.prod.outlook.com (2603:10b6:806:348::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 17:19:44 +0000 Received: from BL6PEPF0001AB78.namprd02.prod.outlook.com (2603:10b6:208:2c1:cafe::35) by BL1PR13CA0304.outlook.office365.com (2603:10b6:208:2c1::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.21 via Frontend Transport; Mon, 11 Dec 2023 17:19:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB78.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7091.18 via Frontend Transport; Mon, 11 Dec 2023 17:19:44 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 11 Dec 2023 11:19:43 -0600 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Mon, 11 Dec 2023 11:19:42 -0600 From: To: , , , , CC: Edward Cree , , , Jonathan Cooper Subject: [PATCH net-next 4/7] sfc: debugfs for (nic) TX queues Date: Mon, 11 Dec 2023 17:18:29 +0000 Message-ID: <91beef38162b8e243c2275b41a6f37c01f19850f.1702314695.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB78:EE_|SN7PR12MB7853:EE_ X-MS-Office365-Filtering-Correlation-Id: 206c48de-01d9-408c-994b-08dbfa6d5e5e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y3hSWVFPsKU25mh/sPZmaHini1oK4xpP0WElQq83I7WkfOawar/zTmmocjnhdJgyQ5JYc6AAaveZsVm0saFAzZYviyr0fea3Ifway/rMbqQqdzWLsPG8vGsP4dD6kTz0b9ATnHldNs5dPbMQMPv/EmTIddNYdILkCDlXr/lCBfAp9vaPRE7nVkFuMSp9VmCvXdE1QW7pMWHb4E8VruJTXKDg38rdUp/P2ELjHTgEwAS8oNTBOUO6TQ11/w3B71L6n4Ipcrce4gYVdBiGAcL8St5VsjI2PRFxoUhJ4o9H8f3Tg66X6BSgqPpc/cAXPwXo2trvK+nkAuPTkPn4nrZzXNHgi7FuS0pMYxYxGGqp6LQlTmFBHT7/plyIQFkvIOxZyRs+7ClYmsQBPuxUKEv99ljAMO0InGVH9DpcnOfy4q4nmIjpIS1HHqTrlRGl3Bf91t2x2ocX3PEYnp4cCsYa3aKQ7tC8Z3YDwHeTqum5j1axAedaB+YxNoExxa2RbXGN/xjzhIfE1P81bgS/M7iCmHB9JBHFsvYC9QSOb6Dv6dL47RjxNbjSbDEZP54D6CO+hbDilo5VEZCj42BsLuBRsiPgj8yKFNQe9QlvzIFfIJ2I+Z3HoekKswiSQp6qAH2/9Ke2ia5oRHi05SSc5b/oby4K0X4MqtTdMc+QCbnkNshv5iKZ+RLGrPyG+4O1Uc1zYEJKtorpWjR1N1TP3RXFUva0tEkw/KskVvdQigVTI01slP3M05bVnHzW53N1Fpz7Je/Vq8fJdk1uVeac3JrCRw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(376002)(396003)(39860400002)(346002)(136003)(230922051799003)(186009)(1800799012)(82310400011)(64100799003)(451199024)(40470700004)(46966006)(36840700001)(2876002)(40460700003)(2906002)(41300700001)(36756003)(110136005)(36860700001)(86362001)(55446002)(82740400003)(356005)(9686003)(336012)(426003)(26005)(478600001)(6666004)(83380400001)(47076005)(81166007)(4326008)(5660300002)(316002)(70586007)(70206006)(54906003)(8936002)(8676002)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 17:19:44.4225 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 206c48de-01d9-408c-994b-08dbfa6d5e5e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB78.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7853 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Expose each TX queue's label, type (csum offloads), TSO and timestamping capabilities, and the read/write/etc pointers for the descriptor ring. Each TXQ dir also symlinks to its owning channel. Reviewed-by: Jonathan Cooper Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/debugfs.c | 71 +++++++++++++++++++++++++++ drivers/net/ethernet/sfc/debugfs.h | 14 ++++++ drivers/net/ethernet/sfc/net_driver.h | 4 ++ drivers/net/ethernet/sfc/tx_common.c | 8 +++ 4 files changed, 97 insertions(+) diff --git a/drivers/net/ethernet/sfc/debugfs.c b/drivers/net/ethernet/sfc/debugfs.c index 43b1d06a985e..8ee6e401ea44 100644 --- a/drivers/net/ethernet/sfc/debugfs.c +++ b/drivers/net/ethernet/sfc/debugfs.c @@ -78,6 +78,77 @@ void efx_update_debugfs_netdev(struct efx_nic *efx) mutex_unlock(&efx->debugfs_symlink_mutex); } +#define EFX_DEBUGFS_TXQ(_type, _name) \ + debugfs_create_##_type(#_name, 0444, tx_queue->debug_dir, &tx_queue->_name) + +/* Create basic debugfs parameter files for an Efx TXQ */ +static void efx_init_debugfs_tx_queue_files(struct efx_tx_queue *tx_queue) +{ + EFX_DEBUGFS_TXQ(u32, label); + EFX_DEBUGFS_TXQ(bool, xdp_tx); + /* offload features */ + EFX_DEBUGFS_TXQ(u32, type); + EFX_DEBUGFS_TXQ(u32, tso_version); + EFX_DEBUGFS_TXQ(bool, tso_encap); + EFX_DEBUGFS_TXQ(bool, timestamping); + /* descriptor ring indices */ + EFX_DEBUGFS_TXQ(u32, read_count); + EFX_DEBUGFS_TXQ(u32, insert_count); + EFX_DEBUGFS_TXQ(u32, write_count); + EFX_DEBUGFS_TXQ(u32, notify_count); +} + +/** + * efx_init_debugfs_tx_queue - create debugfs directory for TX queue + * @tx_queue: Efx TX queue + * + * Create a debugfs directory containing parameter-files for @tx_queue. + * The directory must be cleaned up using efx_fini_debugfs_tx_queue(), + * even if this function returns an error. + * + * Return: a negative error code or 0 on success. + */ +int efx_init_debugfs_tx_queue(struct efx_tx_queue *tx_queue) +{ + char target[EFX_DEBUGFS_NAME_LEN]; + char name[EFX_DEBUGFS_NAME_LEN]; + + if (!tx_queue->efx->debug_queues_dir) + return -ENODEV; + /* Create directory */ + if (snprintf(name, sizeof(name), "tx-%d", tx_queue->queue) + >= sizeof(name)) + return -ENAMETOOLONG; + tx_queue->debug_dir = debugfs_create_dir(name, + tx_queue->efx->debug_queues_dir); + if (!tx_queue->debug_dir) + return -ENOMEM; + + /* Create files */ + efx_init_debugfs_tx_queue_files(tx_queue); + + /* Create symlink to channel */ + if (snprintf(target, sizeof(target), "../../channels/%d", + tx_queue->channel->channel) >= sizeof(target)) + return -ENAMETOOLONG; + if (!debugfs_create_symlink("channel", tx_queue->debug_dir, target)) + return -ENOMEM; + + return 0; +} + +/** + * efx_fini_debugfs_tx_queue - remove debugfs directory for TX queue + * @tx_queue: Efx TX queue + * + * Remove directory created for @tx_queue by efx_init_debugfs_tx_queue(). + */ +void efx_fini_debugfs_tx_queue(struct efx_tx_queue *tx_queue) +{ + debugfs_remove_recursive(tx_queue->debug_dir); + tx_queue->debug_dir = NULL; +} + #define EFX_DEBUGFS_RXQ(_type, _name) \ debugfs_create_##_type(#_name, 0444, rx_queue->debug_dir, &rx_queue->_name) diff --git a/drivers/net/ethernet/sfc/debugfs.h b/drivers/net/ethernet/sfc/debugfs.h index 53c98a2fb4c9..3e8d2e2b5bad 100644 --- a/drivers/net/ethernet/sfc/debugfs.h +++ b/drivers/net/ethernet/sfc/debugfs.h @@ -34,11 +34,19 @@ * (&efx_rx_queue.debug_dir), whose name is "rx-N" where N is the RX queue * index. (This may not be the same as the kernel core RX queue index.) * The directory will contain a symlink to the owning channel. + * * For each NIC TX queue, this will contain a directory + * (&efx_tx_queue.debug_dir), whose name is "tx-N" where N is the TX queue + * index. (This may differ from both the kernel core TX queue index and + * the hardware queue label of the TXQ.) + * The directory will contain a symlink to the owning channel. */ void efx_fini_debugfs_netdev(struct net_device *net_dev); void efx_update_debugfs_netdev(struct efx_nic *efx); +int efx_init_debugfs_tx_queue(struct efx_tx_queue *tx_queue); +void efx_fini_debugfs_tx_queue(struct efx_tx_queue *tx_queue); + int efx_init_debugfs_rx_queue(struct efx_rx_queue *rx_queue); void efx_fini_debugfs_rx_queue(struct efx_rx_queue *rx_queue); @@ -57,6 +65,12 @@ static inline void efx_fini_debugfs_netdev(struct net_device *net_dev) {} static inline void efx_update_debugfs_netdev(struct efx_nic *efx) {} +int efx_init_debugfs_tx_queue(struct efx_tx_queue *tx_queue) +{ + return 0; +} +void efx_fini_debugfs_tx_queue(struct efx_tx_queue *tx_queue) {} + int efx_init_debugfs_rx_queue(struct efx_rx_queue *rx_queue) { return 0; diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 63eb32670826..feb87979059c 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -273,6 +273,10 @@ struct efx_tx_queue { bool initialised; bool timestamping; bool xdp_tx; +#ifdef CONFIG_DEBUG_FS + /** @debug_dir: Queue debugfs directory (under @efx->debug_queues_dir) */ + struct dentry *debug_dir; +#endif /* Members used mainly on the completion path */ unsigned int read_count ____cacheline_aligned_in_smp; diff --git a/drivers/net/ethernet/sfc/tx_common.c b/drivers/net/ethernet/sfc/tx_common.c index 9f2393d34371..3780da849e98 100644 --- a/drivers/net/ethernet/sfc/tx_common.c +++ b/drivers/net/ethernet/sfc/tx_common.c @@ -12,6 +12,7 @@ #include "efx.h" #include "nic_common.h" #include "tx_common.h" +#include "debugfs.h" #include static unsigned int efx_tx_cb_page_count(struct efx_tx_queue *tx_queue) @@ -47,6 +48,11 @@ int efx_probe_tx_queue(struct efx_tx_queue *tx_queue) rc = -ENOMEM; goto fail1; } + rc = efx_init_debugfs_tx_queue(tx_queue); + if (rc) /* not fatal */ + netif_err(efx, drv, efx->net_dev, + "Failed to create debugfs for TXQ %d, rc=%d\n", + tx_queue->queue, rc); /* Allocate hardware ring, determine TXQ type */ rc = efx_nic_probe_tx(tx_queue); @@ -133,6 +139,8 @@ void efx_remove_tx_queue(struct efx_tx_queue *tx_queue) "destroying TX queue %d\n", tx_queue->queue); efx_nic_remove_tx(tx_queue); + efx_fini_debugfs_tx_queue(tx_queue); + if (tx_queue->cb_page) { for (i = 0; i < efx_tx_cb_page_count(tx_queue); i++) efx_nic_free_buffer(tx_queue->efx, From patchwork Mon Dec 11 17:18:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13487702 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="SR4WmBfG" Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2077.outbound.protection.outlook.com [40.107.94.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9650BD for ; Mon, 11 Dec 2023 09:19:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RkhExCiIDNiiByCQDQ7qG3ggtUP9it6LtwqhaOZSK3JIndz/eJgRQtSyzN/4ayRpDyfr77y6qKFFCouOlMuedCGMWsiMvRpYwx4dBBZ481pd3aBVH8QmIv1jaCDb1FjUCmn04ArJvxnKklxSLD3KvSib0t//rH88E3xGv84IPH6d8irn8FmSlVfpd4NoM/t1a2KwrtmCzjEsqI0IQhkrHwpXdCwU3s29Dt+pBudjTdkYLWe8EJdMJ/9NF4OxnfjOdGsdRSR/Z0HRjJp859yQFHyRfKYqE4WvJcTZK6RqXIsk7DT0yUmsCrk2ZYtv6ynpYfiIe7yAroMcLPxJ0AjcFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=n3QUNy3zqCecER5PbAHdTyN7lwhF5kxzOdi/OQMklwM=; b=ftWOWq2yXOY1ZmqPtzPGiw3TdXSRZk8xHtP1KtMOAGc+K7n+yYAdSoBZXo0MlG+bPByhTL+1JS5ZQreHjMaL6ZP+kYiJhXjMAVJcxG2RPRSlhom6cx5i7zLM0fqdQAD/3VbOVY8J1Lxs134DnGgEnFwLsjIzuzSEt6SSCUIkj4C5fRwavi2Hb8AxqtmTI9hiAOi3dVwIw2wNql+b/Vpw4bsehm9L6ERi+ImoGLfLmFupOupNyZsYVUkJuPFnVu6jWXwFg95lC24UPuMzJ5cqPPo1/fQQPaQfQcM6kzbMT6oo4pfNLajzBxrbnmEuTC6BQLxmDiKje7oo0ujxiqbJlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n3QUNy3zqCecER5PbAHdTyN7lwhF5kxzOdi/OQMklwM=; b=SR4WmBfGoJg2oZ5Dm7DhW0dVayjleuhXYRlYsz8vLoW656OlRkOA7t+ROiaOwJstZTbS3bhbbSa38GYyESV+FEi5iC6PQ2UEySXRJqk4llaDs/5IJHLLluHfSFXvjPPIcYXsSQCfl3gPZuxZ0wYdev4T2ry67oK5Ok8K4Ran+Is= Received: from BLAPR03CA0125.namprd03.prod.outlook.com (2603:10b6:208:32e::10) by CH2PR12MB4295.namprd12.prod.outlook.com (2603:10b6:610:a7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 17:19:46 +0000 Received: from BL6PEPF0001AB73.namprd02.prod.outlook.com (2603:10b6:208:32e:cafe::12) by BLAPR03CA0125.outlook.office365.com (2603:10b6:208:32e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32 via Frontend Transport; Mon, 11 Dec 2023 17:19:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB73.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7091.18 via Frontend Transport; Mon, 11 Dec 2023 17:19:45 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 11 Dec 2023 11:19:45 -0600 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Mon, 11 Dec 2023 11:19:44 -0600 From: To: , , , , CC: Edward Cree , , , Jonathan Cooper Subject: [PATCH net-next 5/7] sfc: add debugfs nodes for loopback mode Date: Mon, 11 Dec 2023 17:18:30 +0000 Message-ID: <97029c69a149de5bd6ba6e70c6de1e04bcdc6692.1702314695.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB73:EE_|CH2PR12MB4295:EE_ X-MS-Office365-Filtering-Correlation-Id: 44c9310e-0f5b-43bf-f0c6-08dbfa6d5f2b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LDnEyIrP1x8w1ZtIdiQHVYQNz8SJMtfTKA8H+wQ1BRpP+9WihjXp5ACxM2+6ccFGJxlWaW4gq23uVZ5CV90VLMXdlziFEl+1xVfZaFymzIVzn+uJU5gdDxm0jvIHW4n+PEtdPr931BhxesUKzfQeof6bzrMUmTsOXephmg2pRsw0RHDSpF0bYxCqolB311KcMYZ89UIwjhxaWt62tEnEzh/hcjoKAfKDSavW+XWgr+rYNtbDdBXZQuH2w6X6oSrenAeXv7hzIzYYS9XB8QGBCimwK26HITtZUJShH4wbJ2/UM7NQpjneeeiRUVZq+9TRkk0hhvdJCrszQXDD0XEB34CkGfwVyX/vQGkiNLKgNc5itpXi9w/hLGsAPLMUr6ADuWK1OSIeyx4KUXqbHmWx8FEbQE1XdZ3mA7qVujVWOW20CiAgLJzy2G9jDK8EqBI6GpXftdTVsOpBPuLCPc//evIFphsNVy3tLtKxmvY7vxwZQfe998QsVa+R2cKuFuSo5x72V6MHE1bfAhRuzqki4f4ZkLQQNsTBmfqUUTBzJCQkJQtGY3o/WfxcA3/KhLSg8IhJQXCw2E+EHX575It90mWMR7JzJSXOlXEckXEvOWcqULO6VApK0a/KC6gr1oG6IBD/CfqCWI3lzBG8ONnr7Rq/usR4bFd2TBE0hiwxA4aNpkLxAaBDRCBuVZk0LVbUOGe8Dzubr39ObmmxS9kilhJo0bFGwLUZmRvN9A0nuBHPQ7PsxLpeMvs+yzwr+zdnyAzzTQYFqZDAgoGYEYi4aw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(376002)(39860400002)(396003)(346002)(230922051799003)(1800799012)(186009)(82310400011)(451199024)(64100799003)(40470700004)(46966006)(36840700001)(40480700001)(40460700003)(47076005)(26005)(478600001)(6666004)(9686003)(81166007)(82740400003)(36756003)(55446002)(86362001)(356005)(2906002)(41300700001)(70586007)(70206006)(5660300002)(426003)(336012)(36860700001)(2876002)(110136005)(316002)(8676002)(8936002)(54906003)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 17:19:45.7682 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 44c9310e-0f5b-43bf-f0c6-08dbfa6d5f2b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB73.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4295 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree 'loopback_mode' shows the currently selected mode, while 'loopback_modes' is a bitmask of modes supported by the NIC+FW. Reviewed-by: Jonathan Cooper Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/debugfs.c | 7 +++++++ drivers/net/ethernet/sfc/net_driver.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/net/ethernet/sfc/debugfs.c b/drivers/net/ethernet/sfc/debugfs.c index 8ee6e401ea44..549ff1ee273e 100644 --- a/drivers/net/ethernet/sfc/debugfs.c +++ b/drivers/net/ethernet/sfc/debugfs.c @@ -326,6 +326,13 @@ static void efx_init_debugfs_nic_files(struct efx_nic *efx) efx->debug_interrupt_mode.value = &efx->interrupt_mode; efx_debugfs_create_enum("interrupt_mode", 0444, efx->debug_dir, &efx->debug_interrupt_mode); + EFX_DEBUGFS_EFX(x64, loopback_modes); + efx->debug_loopback_mode.max = efx_loopback_mode_max; + efx->debug_loopback_mode.names = efx_loopback_mode_names; + efx->debug_loopback_mode.vlen = sizeof(efx->loopback_mode); + efx->debug_loopback_mode.value = &efx->loopback_mode; + efx_debugfs_create_enum("loopback_mode", 0444, efx->debug_dir, + &efx->debug_loopback_mode); } /** diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index feb87979059c..e3605c361117 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -1164,6 +1164,8 @@ struct efx_nic { struct dentry *debug_symlink; /** @debug_interrupt_mode: debugfs details for printing @interrupt_mode */ struct efx_debugfs_enum_data debug_interrupt_mode; + /** @debug_loopback_mode: debugfs details for printing @loopback_mode */ + struct efx_debugfs_enum_data debug_loopback_mode; /** @debugfs_symlink_mutex: protects debugfs @debug_symlink */ struct mutex debugfs_symlink_mutex; #endif From patchwork Mon Dec 11 17:18:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13487705 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="GH5davCd" Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2077.outbound.protection.outlook.com [40.107.94.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05167D9 for ; Mon, 11 Dec 2023 09:19:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=acY56NQ6JjSbeHDcK9WrVLqnPc30Q//YC7RJ0e5PcIDphEdUlSAHvllBSeluiyL7+f7QMYER4elW0/NvoTTsizUQJ7Lcp5Mts5YnZ97fDx01Go9oM6AQpxpLpVaxDnxADwTPf18IIU+AKQK/o9VeFHxQGRRrug9zoFES9va00vMayJwq9F/ii1KSh9mmRKOEYltnV5EHkGI/E0eHC82H+fRgJlN2rb1V7H4aUbOOzrTVKfN8ZaJ8eqHfIR135UtXFKWoxOZTHQCjvTbj8dgsANCL76+vvQ6GeK/r0lb9+hO5ZpgiHCoiIY9Gj2Omjc/dO9reRNozi1Q3xywluML6Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RyORSVF8tbgPaEjDtp5KFWSGtEv1YMdooBwAQ43NxCc=; b=fXrHlyvteL1I6HVf1XIYuNWvcRHX74coSoztZF2yAUX8rRnmGWDRYFnxAEQ4r7hW90CtWf92LBzYHM7j+i7F4l6DsuOw8+VwiQv1HydxMh4BaHMhWCI7uPXROp3aozAamUfQsdxtzB6UzhaHY5vqa/R73+2oGUc5a5j5IpTU7E92FxOFiUyhVneLNYnBuSqVzxucnc3TlIwFtadWiCWQycPALuMiikWmNEAHf4YMD6agPRq8mIX+MyU9Teku5UlfTx4tV7eC5Dd7uvFcSCQh77bevZjvoTO+OAklpWq3uDzUyIw9zkaVoqtv5Ai9Nttz9P3YUPR6GtRGhZ6FNXBsSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RyORSVF8tbgPaEjDtp5KFWSGtEv1YMdooBwAQ43NxCc=; b=GH5davCdKTQfqoQtpnhD0Pn7iMM6fm0SLtUG9BCgDlKdp55KCKWRQ2XRvKXOmeesl/bXxJm98WtZnbNZT09EG3UK++i2Mgu0gTQDXzd/UkY3zqyH/CvsZkjJjFfamjXwfDC60UPUiGRy1IsVgHN+J2xuUbDejutdelQii6AEZN8= Received: from BLAPR03CA0071.namprd03.prod.outlook.com (2603:10b6:208:329::16) by SJ2PR12MB7824.namprd12.prod.outlook.com (2603:10b6:a03:4c4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 17:19:48 +0000 Received: from BL6PEPF0001AB75.namprd02.prod.outlook.com (2603:10b6:208:329:cafe::4a) by BLAPR03CA0071.outlook.office365.com (2603:10b6:208:329::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33 via Frontend Transport; Mon, 11 Dec 2023 17:19:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB75.mail.protection.outlook.com (10.167.242.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7091.18 via Frontend Transport; Mon, 11 Dec 2023 17:19:47 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 11 Dec 2023 11:19:46 -0600 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Mon, 11 Dec 2023 11:19:45 -0600 From: To: , , , , CC: Edward Cree , , , Jonathan Cooper Subject: [PATCH net-next 6/7] sfc: add debugfs entries for filter table status Date: Mon, 11 Dec 2023 17:18:31 +0000 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB75:EE_|SJ2PR12MB7824:EE_ X-MS-Office365-Filtering-Correlation-Id: fb1e5893-dd8e-4b11-d81e-08dbfa6d6002 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XzGBrZxyU9gvHXWdGTvYEmZzQlaxxGoN/7cF7sulD+kh+Hy0djWwJVJ53MN9VyhXtSYSCUa6nKrkQWI6yWmnl9gwepdkXGcEul+a3ldZr5JRge5ryw95yHK50q+0y+YHCmbEE2hiEMTI65RWx54OlB4ujMJcojdITwxg13iJ8AZVyitumHOyRSmENH8ayQiCD8686NSIHlr9uDrFWpLf7RZCOYgcDqf6e8QtBF0orAavQ7KWZ2xu3tnt7sukQ1l75Ss9euAIf22lJ4dt5XgN7BTljPSyS4RojqP+HyoCKypV5NlvySmG9Gz2dVz/+hggQFnm/6SbTsMqI99tCXcTZ5M2vdwKLxglHLyieu+DxwK9Iv7D/KUq5iaLJBd93+Rlld5KrlsOq77FSWvxCmTGqqoHDKqbkkOAJxigFGo18Q7h8op61ZHrcwYEfl2Pf5awoHfFYgCbAa4Q1hJDhbHAsniwX/3Y6bljgHouQ8Sao+3Y9JWFgYV7OeovtxPby9uwOTdNFW8Ks6qAuXx30iAYkgEmKIoczTKTju3acJLN+EqwdrI+N+73+sF5SbzPWSDmso1ZP0dAIEAG6DlShDeEeV40UxsfVldql83lMXqeToxGE4nPoZiptw5YGrm5gNdpRGDyKY1EpkisenpAiRRGLXypGWUZjvBiycHNjlecdtJZ0F/sVt5UyNNaDeIoRqhJfCzmUJCnHto1xQXGfgedM/EywrE039Bnw37TSjBps5qUTRqUAlpOkcSfn9ifZlG6vALVtvrkQCfXtninqnDuQQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(346002)(136003)(396003)(39860400002)(376002)(230922051799003)(186009)(82310400011)(451199024)(1800799012)(64100799003)(46966006)(36840700001)(40470700004)(40480700001)(336012)(26005)(426003)(40460700003)(82740400003)(81166007)(316002)(356005)(55446002)(86362001)(36756003)(47076005)(5660300002)(83380400001)(6666004)(9686003)(36860700001)(70206006)(70586007)(110136005)(8936002)(8676002)(54906003)(4326008)(2876002)(2906002)(41300700001)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 17:19:47.1766 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fb1e5893-dd8e-4b11-d81e-08dbfa6d6002 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB75.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7824 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Filter table management is complicated by the possibility of overflow kicking us into a promiscuous fallback for either unicast or multicast. Expose the internal flags that drive this. Since the table state (efx->filter_state) has a separate, shorter lifetime than struct efx_nic, put its debugfs nodes in a subdirectory (efx->filter_state->debug_dir) so that they can be cleaned up easily before the filter_state is freed. Reviewed-by: Jonathan Cooper Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/debugfs.h | 4 ++++ drivers/net/ethernet/sfc/mcdi_filters.c | 18 ++++++++++++++++++ drivers/net/ethernet/sfc/mcdi_filters.h | 4 ++++ 3 files changed, 26 insertions(+) diff --git a/drivers/net/ethernet/sfc/debugfs.h b/drivers/net/ethernet/sfc/debugfs.h index 3e8d2e2b5bad..7a96f3798cbd 100644 --- a/drivers/net/ethernet/sfc/debugfs.h +++ b/drivers/net/ethernet/sfc/debugfs.h @@ -39,6 +39,10 @@ * index. (This may differ from both the kernel core TX queue index and * the hardware queue label of the TXQ.) * The directory will contain a symlink to the owning channel. + * + * * "filters/" (&efx_mcdi_filter_table.debug_dir). + * This contains parameter files for the NIC receive filter table + * (@efx->filter_state). */ void efx_fini_debugfs_netdev(struct net_device *net_dev); diff --git a/drivers/net/ethernet/sfc/mcdi_filters.c b/drivers/net/ethernet/sfc/mcdi_filters.c index 4ff6586116ee..a4ab45082c8f 100644 --- a/drivers/net/ethernet/sfc/mcdi_filters.c +++ b/drivers/net/ethernet/sfc/mcdi_filters.c @@ -1348,6 +1348,20 @@ int efx_mcdi_filter_table_probe(struct efx_nic *efx, bool multicast_chaining) INIT_LIST_HEAD(&table->vlan_list); init_rwsem(&table->lock); +#ifdef CONFIG_DEBUG_FS + table->debug_dir = debugfs_create_dir("filters", efx->debug_dir); + debugfs_create_bool("uc_promisc", 0444, table->debug_dir, + &table->uc_promisc); + debugfs_create_bool("mc_promisc", 0444, table->debug_dir, + &table->mc_promisc); + debugfs_create_bool("mc_promisc_last", 0444, table->debug_dir, + &table->mc_promisc_last); + debugfs_create_bool("mc_overflow", 0444, table->debug_dir, + &table->mc_overflow); + debugfs_create_bool("mc_chaining", 0444, table->debug_dir, + &table->mc_chaining); +#endif + efx->filter_state = table; return 0; @@ -1518,6 +1532,10 @@ void efx_mcdi_filter_table_remove(struct efx_nic *efx) return; vfree(table->entry); +#ifdef CONFIG_DEBUG_FS + /* Remove debugfs entries pointing into @table */ + debugfs_remove_recursive(table->debug_dir); +#endif kfree(table); } diff --git a/drivers/net/ethernet/sfc/mcdi_filters.h b/drivers/net/ethernet/sfc/mcdi_filters.h index c0d6558b9fd2..897843ade3ec 100644 --- a/drivers/net/ethernet/sfc/mcdi_filters.h +++ b/drivers/net/ethernet/sfc/mcdi_filters.h @@ -91,6 +91,10 @@ struct efx_mcdi_filter_table { bool vlan_filter; /* Entries on the vlan_list are added/removed under filter_sem */ struct list_head vlan_list; +#ifdef CONFIG_DEBUG_FS + /* filter table debugfs directory */ + struct dentry *debug_dir; +#endif }; int efx_mcdi_filter_table_probe(struct efx_nic *efx, bool multicast_chaining); From patchwork Mon Dec 11 17:18:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13487706 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="g4v80DOp" Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2047.outbound.protection.outlook.com [40.107.220.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06B75DB for ; Mon, 11 Dec 2023 09:19:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FMFq0/RbIat/iO0+v+ocfTztSD8/ENOJ4VFekGDp4Tg77sK0KccjvcKxSZTqDH84CwBpCKnuGdRkXAKpyHSjb1mozG65jMRXRLa49GAxDExwUJNXEvdrclRf2oudTN2q69cHhXKcKxeKUWUcKlmFwVZBe0ORFBNQ9VFzKtEfYVPN6hy9hsmQn/axvV+1ETdAY22CIJsPfloZLzIRqoXrtNv9MNUOV5HCPq0RyDJWIGTT664ZzAckp1KftE7YxzbbKx5vGZv741uY4iT0DAB6shE3EmK2kTwWwaS0ynCHj4FzbYHLMrZqZQIk1VZe7VpdFnQsEPziEeHJfDPcchYE0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AiiE/G0fjq8l8nKeRjZq8S+Jym/ah+ztytXTEswnBNU=; b=Wf+AD7HEzJ9BkOKGYzFb0XBUf49xSA+4KMHVAtzpt82QbjW2BmTzuE4G98tXCIkHFTGx/lS5Ml4nNUioBUCq/lEXlRW5AsrTmOtVJYCyIky5NcfqHMIO+9KG7fB3TRsiRdsLTuF/k3Fxl3J2lfc2KAg67XvrwyAH+i6JznxGyPvpNLER0b4t+V/6RfPkIzMnyj0I1/AXpLnTKiLD4Nx/+ywhORa8CHUHqOlQbxaGPvuU4WSu+46qyjhUpiu6R+ir5yfNL8VJ2eEKUDU/oJKG+sBu/5hEAWbsij0k8v7Js0GoWFFQzwHOv0YLWYRqgDVladXSrxXTSz7GrTdY/uhjvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AiiE/G0fjq8l8nKeRjZq8S+Jym/ah+ztytXTEswnBNU=; b=g4v80DOpDZhf9Rla+wdre4MMH5Azi8mbBvnnAk9UcRexCo/TE+ujwXc8sNZbEESPINfrpxoGOMNSLwqdVY/vE8oxuS7kG9KlIOHtQpzvfcdi+/l46tHI045zfXglO0e4HR8LQIp4v53+urkfYe26cPGewdt6EfSTG8OwuKMfkUc= Received: from BLAPR03CA0081.namprd03.prod.outlook.com (2603:10b6:208:329::26) by SN7PR12MB7978.namprd12.prod.outlook.com (2603:10b6:806:34b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 17:19:49 +0000 Received: from BL6PEPF0001AB75.namprd02.prod.outlook.com (2603:10b6:208:329:cafe::8c) by BLAPR03CA0081.outlook.office365.com (2603:10b6:208:329::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32 via Frontend Transport; Mon, 11 Dec 2023 17:19:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB75.mail.protection.outlook.com (10.167.242.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7091.18 via Frontend Transport; Mon, 11 Dec 2023 17:19:49 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 11 Dec 2023 11:19:47 -0600 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Mon, 11 Dec 2023 11:19:46 -0600 From: To: , , , , CC: Edward Cree , , , Jonathan Cooper Subject: [PATCH net-next 7/7] sfc: add debugfs node for filter table contents Date: Mon, 11 Dec 2023 17:18:32 +0000 Message-ID: <0cf27cb7a42cc81c8d360b5812690e636a100244.1702314695.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB75:EE_|SN7PR12MB7978:EE_ X-MS-Office365-Filtering-Correlation-Id: fc7fbc85-c4ec-4152-77f3-08dbfa6d6168 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: csISDJYgiH37f3c0yY5M7jmDD1/JXwh6HS/4qy6ecEQnKpFNGCNODRrQ2ZlCPL3YAq+M301gFVIzvRdBFnB+z/trZTWGdPJFJqvNus23Orb9M1qZIFWGNKEdRwt5AHjmTQq5HergiWfMQhk6TUBCLk9/8ojrzi6oGS8neKWszRqJytk9BVw1qCX150pjWMyVR3jDNIqYu57gqTTUO/KRirWjPukCdeVtSsQm3dTCiGl52di9I/BXmZE+eAD71ouDWdGOKz/d0R6/I3SFupPPxfpsB0z0V0YWrI5nBCd5yajERyEyj9oDch9tj/RkSNm06TvnuxlQ1rGwYxcr4ArPpjiRaV1yS00lzMPv8z3kMuk9pGwsCJCMBC6b1adNbYJw7xG7JQ+0LN72HwvjA9fqVqHHiDCOLQ+U/eblfGUMic2fKu8vn0tsKCMk5kuvRb6j0dqrS/+smvuA0O66QyuwW97TKOD4FXoxyPxDSnViD7LP1xYroVo2o9V+wSzQSmanaOZwIa1iixvEU67nwzOD9W3VpCje9WiiXvreYebVVEQSuqjumQHpRsigv8HE21j4D8FAWpTTdUE8CDfYfFkcbHZK2e6FkEbJrRBZfPIRq4j6I7Xgp9GUz6EU8Lx19Q9RQs1ER/MhWoA0m7Bhi/FDA4gsykzCzdSzR9HbbfJVMADPVFERfe9mw+pqu0GB/ZdfRSoWosSrT0vK/lEH4tphWKMotw+d5gpmZIao3eV9/EdqtsjkBnKKgB6fcg3gZfnXMmgoBChGjt8QbttTHljooQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(136003)(376002)(39860400002)(346002)(230922051799003)(1800799012)(451199024)(186009)(82310400011)(64100799003)(40470700004)(36840700001)(46966006)(40480700001)(26005)(426003)(336012)(40460700003)(82740400003)(36756003)(81166007)(55446002)(86362001)(356005)(47076005)(5660300002)(83380400001)(6666004)(9686003)(36860700001)(316002)(70586007)(70206006)(110136005)(8936002)(8676002)(54906003)(4326008)(2876002)(2906002)(41300700001)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 17:19:49.5204 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc7fbc85-c4ec-4152-77f3-08dbfa6d6168 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB75.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7978 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Expose the filter table entries. Reviewed-by: Jonathan Cooper Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/debugfs.c | 117 +++++++++++++++++++++++- drivers/net/ethernet/sfc/debugfs.h | 45 +++++++++ drivers/net/ethernet/sfc/mcdi_filters.c | 39 ++++++++ 3 files changed, 197 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/sfc/debugfs.c b/drivers/net/ethernet/sfc/debugfs.c index 549ff1ee273e..e67b0fc927fe 100644 --- a/drivers/net/ethernet/sfc/debugfs.c +++ b/drivers/net/ethernet/sfc/debugfs.c @@ -9,10 +9,6 @@ */ #include "debugfs.h" -#include -#include -#include -#include /* Maximum length for a name component or symlink target */ #define EFX_DEBUGFS_NAME_LEN 32 @@ -428,3 +424,116 @@ void efx_fini_debugfs(void) efx_debug_cards = NULL; efx_debug_root = NULL; } + +/** + * efx_debugfs_print_filter - format a filter spec for display + * @s: buffer to write result into + * @l: length of buffer @s + * @spec: filter specification + */ +void efx_debugfs_print_filter(char *s, size_t l, struct efx_filter_spec *spec) +{ + u32 ip[4]; + int p = snprintf(s, l, "match=%#x,pri=%d,flags=%#x,q=%d", + spec->match_flags, spec->priority, spec->flags, + spec->dmaq_id); + + if (spec->vport_id) + p += snprintf(s + p, l - p, ",vport=%#x", spec->vport_id); + + if (spec->flags & EFX_FILTER_FLAG_RX_RSS) + p += snprintf(s + p, l - p, ",rss=%#x", spec->rss_context); + + if (spec->match_flags & EFX_FILTER_MATCH_OUTER_VID) + p += snprintf(s + p, l - p, + ",ovid=%d", ntohs(spec->outer_vid)); + if (spec->match_flags & EFX_FILTER_MATCH_INNER_VID) + p += snprintf(s + p, l - p, + ",ivid=%d", ntohs(spec->inner_vid)); + if (spec->match_flags & EFX_FILTER_MATCH_ENCAP_TYPE) + p += snprintf(s + p, l - p, + ",encap=%d", spec->encap_type); + if (spec->match_flags & EFX_FILTER_MATCH_LOC_MAC) + p += snprintf(s + p, l - p, + ",lmac=%02x:%02x:%02x:%02x:%02x:%02x", + spec->loc_mac[0], spec->loc_mac[1], + spec->loc_mac[2], spec->loc_mac[3], + spec->loc_mac[4], spec->loc_mac[5]); + if (spec->match_flags & EFX_FILTER_MATCH_REM_MAC) + p += snprintf(s + p, l - p, + ",rmac=%02x:%02x:%02x:%02x:%02x:%02x", + spec->rem_mac[0], spec->rem_mac[1], + spec->rem_mac[2], spec->rem_mac[3], + spec->rem_mac[4], spec->rem_mac[5]); + if (spec->match_flags & EFX_FILTER_MATCH_ETHER_TYPE) + p += snprintf(s + p, l - p, + ",ether=%#x", ntohs(spec->ether_type)); + if (spec->match_flags & EFX_FILTER_MATCH_IP_PROTO) + p += snprintf(s + p, l - p, + ",ippr=%#x", spec->ip_proto); + if (spec->match_flags & EFX_FILTER_MATCH_LOC_HOST) { + if (ntohs(spec->ether_type) == ETH_P_IP) { + ip[0] = (__force u32) spec->loc_host[0]; + p += snprintf(s + p, l - p, + ",lip=%d.%d.%d.%d", + ip[0] & 0xff, + (ip[0] >> 8) & 0xff, + (ip[0] >> 16) & 0xff, + (ip[0] >> 24) & 0xff); + } else if (ntohs(spec->ether_type) == ETH_P_IPV6) { + ip[0] = (__force u32) spec->loc_host[0]; + ip[1] = (__force u32) spec->loc_host[1]; + ip[2] = (__force u32) spec->loc_host[2]; + ip[3] = (__force u32) spec->loc_host[3]; + p += snprintf(s + p, l - p, + ",lip=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x", + ip[0] & 0xffff, + (ip[0] >> 16) & 0xffff, + ip[1] & 0xffff, + (ip[1] >> 16) & 0xffff, + ip[2] & 0xffff, + (ip[2] >> 16) & 0xffff, + ip[3] & 0xffff, + (ip[3] >> 16) & 0xffff); + } else { + p += snprintf(s + p, l - p, ",lip=?"); + } + } + if (spec->match_flags & EFX_FILTER_MATCH_REM_HOST) { + if (ntohs(spec->ether_type) == ETH_P_IP) { + ip[0] = (__force u32) spec->rem_host[0]; + p += snprintf(s + p, l - p, + ",rip=%d.%d.%d.%d", + ip[0] & 0xff, + (ip[0] >> 8) & 0xff, + (ip[0] >> 16) & 0xff, + (ip[0] >> 24) & 0xff); + } else if (ntohs(spec->ether_type) == ETH_P_IPV6) { + ip[0] = (__force u32) spec->rem_host[0]; + ip[1] = (__force u32) spec->rem_host[1]; + ip[2] = (__force u32) spec->rem_host[2]; + ip[3] = (__force u32) spec->rem_host[3]; + p += snprintf(s + p, l - p, + ",rip=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x", + ip[0] & 0xffff, + (ip[0] >> 16) & 0xffff, + ip[1] & 0xffff, + (ip[1] >> 16) & 0xffff, + ip[2] & 0xffff, + (ip[2] >> 16) & 0xffff, + ip[3] & 0xffff, + (ip[3] >> 16) & 0xffff); + } else { + p += snprintf(s + p, l - p, ",rip=?"); + } + } + if (spec->match_flags & EFX_FILTER_MATCH_LOC_PORT) + p += snprintf(s + p, l - p, + ",lport=%d", ntohs(spec->loc_port)); + if (spec->match_flags & EFX_FILTER_MATCH_REM_PORT) + p += snprintf(s + p, l - p, + ",rport=%d", ntohs(spec->rem_port)); + if (spec->match_flags & EFX_FILTER_MATCH_LOC_MAC_IG) + p += snprintf(s + p, l - p, ",%s", + spec->loc_mac[0] ? "mc" : "uc"); +} diff --git a/drivers/net/ethernet/sfc/debugfs.h b/drivers/net/ethernet/sfc/debugfs.h index 7a96f3798cbd..f50b4bf33a6b 100644 --- a/drivers/net/ethernet/sfc/debugfs.h +++ b/drivers/net/ethernet/sfc/debugfs.h @@ -10,6 +10,10 @@ #ifndef EFX_DEBUGFS_H #define EFX_DEBUGFS_H +#include +#include +#include +#include #include "net_driver.h" #ifdef CONFIG_DEBUG_FS @@ -63,6 +67,45 @@ void efx_fini_debugfs_nic(struct efx_nic *efx); int efx_init_debugfs(void); void efx_fini_debugfs(void); +void efx_debugfs_print_filter(char *s, size_t l, struct efx_filter_spec *spec); + +/* Generate operations for a debugfs node with a custom reader function. + * The reader should have signature int (*)(struct seq_file *s, void *data) + * where data is the pointer passed to EFX_DEBUGFS_CREATE_RAW. + */ +#define EFX_DEBUGFS_RAW_PARAMETER(_reader) \ + \ +static int efx_debugfs_##_reader##_read(struct seq_file *s, void *d) \ +{ \ + return _reader(s, s->private); \ +} \ + \ +static int efx_debugfs_##_reader##_open(struct inode *inode, struct file *f) \ +{ \ + return single_open(f, efx_debugfs_##_reader##_read, inode->i_private); \ +} \ + \ +static const struct file_operations efx_debugfs_##_reader##_ops = { \ + .owner = THIS_MODULE, \ + .open = efx_debugfs_##_reader##_open, \ + .release = single_release, \ + .read = seq_read, \ + .llseek = seq_lseek, \ +}; \ + \ +static void efx_debugfs_create_##_reader(const char *name, umode_t mode, \ + struct dentry *parent, void *data) \ +{ \ + debugfs_create_file(name, mode, parent, data, \ + &efx_debugfs_##_reader##_ops); \ +} + +/* Instantiate a debugfs node with a custom reader function. The operations + * must have been generated with EFX_DEBUGFS_RAW_PARAMETER(_reader). + */ +#define EFX_DEBUGFS_CREATE_RAW(_name, _mode, _parent, _data, _reader) \ + efx_debugfs_create_##_reader(_name, _mode, _parent, _data) + #else /* CONFIG_DEBUG_FS */ static inline void efx_fini_debugfs_netdev(struct net_device *net_dev) {} @@ -99,6 +142,8 @@ static inline int efx_init_debugfs(void) } static inline void efx_fini_debugfs(void) {} +void efx_debugfs_print_filter(char *s, size_t l, struct efx_filter_spec *spec) {} + #endif /* CONFIG_DEBUG_FS */ #endif /* EFX_DEBUGFS_H */ diff --git a/drivers/net/ethernet/sfc/mcdi_filters.c b/drivers/net/ethernet/sfc/mcdi_filters.c index a4ab45082c8f..465226c3e8c7 100644 --- a/drivers/net/ethernet/sfc/mcdi_filters.c +++ b/drivers/net/ethernet/sfc/mcdi_filters.c @@ -13,6 +13,7 @@ #include "mcdi.h" #include "nic.h" #include "rx_common.h" +#include "debugfs.h" /* The maximum size of a shared RSS context */ /* TODO: this should really be from the mcdi protocol export */ @@ -1173,6 +1174,42 @@ s32 efx_mcdi_filter_get_rx_ids(struct efx_nic *efx, return count; } +static int efx_debugfs_read_filter_list(struct seq_file *file, void *data) +{ + struct efx_mcdi_filter_table *table; + struct efx_nic *efx = data; + int i; + + down_read(&efx->filter_sem); + table = efx->filter_state; + if (!table || !table->entry) { + up_read(&efx->filter_sem); + return -ENETDOWN; + } + + /* deliberately don't lock the table->lock, so that we can + * still dump the table even if we hang mid-operation. + */ + for (i = 0; i < EFX_MCDI_FILTER_TBL_ROWS; ++i) { + struct efx_filter_spec *spec = + efx_mcdi_filter_entry_spec(table, i); + char filter[256]; + + if (spec) { + efx_debugfs_print_filter(filter, sizeof(filter), spec); + + seq_printf(file, "%d[%#04llx],%#x = %s\n", + i, table->entry[i].handle & 0xffff, + efx_mcdi_filter_entry_flags(table, i), + filter); + } + } + + up_read(&efx->filter_sem); + return 0; +} +EFX_DEBUGFS_RAW_PARAMETER(efx_debugfs_read_filter_list); + static int efx_mcdi_filter_match_flags_from_mcdi(bool encap, u32 mcdi_flags) { int match_flags = 0; @@ -1360,6 +1397,8 @@ int efx_mcdi_filter_table_probe(struct efx_nic *efx, bool multicast_chaining) &table->mc_overflow); debugfs_create_bool("mc_chaining", 0444, table->debug_dir, &table->mc_chaining); + EFX_DEBUGFS_CREATE_RAW("entries", 0444, table->debug_dir, efx, + efx_debugfs_read_filter_list); #endif efx->filter_state = table;