From nobody Fri Dec 19 11:16:13 2025 Received: from relay.smtp-ext.broadcom.com (relay.smtp-ext.broadcom.com [192.19.166.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08454F9EC; Tue, 4 Nov 2025 22:13:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.19.166.228 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762294441; cv=none; b=MNw0wWXxi8C9EUDp6tw112guAKl7Dj5T+DLnFTK4l+xncPD5BjRPI3G0YoZbSe9a7Fd772jTIIHU+wlaEr0mUi9P+uj5AtULVA9qZ/7uoIDcyK88d73Yd0c+7yXplmkoShzAtdhjC88AF5Bwe3C2zhlsN3OTBbzuMcEg1+a06tg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762294441; c=relaxed/simple; bh=UK8z9Y3mu32O43wFFOv01k01S4FD4xAr8BcG370+lJ8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AgUytXekiJIR2x2mmihljvNg6VpUh1y2CXPkhsBfhROZn3Wg9636FNXYTuSvdooKNeziSRQQAn04gO8DyEaYq8TU4XNWjfMM0y7GDabC5AndCySivbClXQ9+1sD5nZI/K8ezz38D4b40bfZy+WkFovT3mnLTFuYDa2e6J+fplIw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=WyPgKVpz; arc=none smtp.client-ip=192.19.166.228 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="WyPgKVpz" Received: from mail-acc-it-01.broadcom.com (mail-acc-it-01.acc.broadcom.net [10.35.36.83]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id 51E1BC000547; Tue, 4 Nov 2025 14:13:53 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 51E1BC000547 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1762294433; bh=UK8z9Y3mu32O43wFFOv01k01S4FD4xAr8BcG370+lJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WyPgKVpzRbGsa0KYqJBn9/oT1DlskCVhVMRV9wox3XwJlMj5kUcNRgZ61hmK8mGtZ vEsSh4oO41l4wowZRbLvyjPxStDJxY5VGtXP2q7AR082uA//T09xetVkdG+zzMOI7L EVLaYyrZjEfl/Ucb5/r4AcEtDkxKx5PnE5NTlYkw= Received: from stbirv-lnx-1.igp.broadcom.net (stbirv-lnx-1.igp.broadcom.net [10.67.48.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-acc-it-01.broadcom.com (Postfix) with ESMTPSA id 07B5A4002F45; Tue, 4 Nov 2025 17:13:51 -0500 (EST) From: Florian Fainelli To: netdev@vger.kernel.org Cc: bcm-kernel-feedback-list@broadcom.com, Florian Fainelli , Doug Berger , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Stanislav Fomichev , Antoine Tenart , Kuniyuki Iwashima , Yajun Deng , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v2 1/2] net: ethernet: Allow disabling pause on panic Date: Tue, 4 Nov 2025 14:13:47 -0800 Message-Id: <20251104221348.4163417-2-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251104221348.4163417-1-florian.fainelli@broadcom.com> References: <20251104221348.4163417-1-florian.fainelli@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Development devices on a lab network might be subject to kernel panics and if they have pause frame generation enabled, once the kernel panics, the Ethernet controller stops being serviced. This can create a flood of pause frames that certain switches are unable to handle resulting a completle paralysis of the network because they broadcast to other stations on that same network segment. To accomodate for such situation introduce a /sys/class/net//disable_pause_on_panic knob which will disable Ethernet pause frame generation upon kernel panic. Note that device driver wishing to make use of that feature need to implement ethtool_ops::set_pauseparam_panic to specifically deal with that atomic context. Signed-off-by: Florian Fainelli --- Documentation/ABI/testing/sysfs-class-net | 16 +++++ include/linux/ethtool.h | 3 + include/linux/netdevice.h | 1 + net/core/net-sysfs.c | 34 ++++++++++ net/ethernet/Makefile | 3 +- net/ethernet/pause_panic.c | 81 +++++++++++++++++++++++ 6 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 net/ethernet/pause_panic.c diff --git a/Documentation/ABI/testing/sysfs-class-net b/Documentation/ABI/= testing/sysfs-class-net index ebf21beba846..f762ce439203 100644 --- a/Documentation/ABI/testing/sysfs-class-net +++ b/Documentation/ABI/testing/sysfs-class-net @@ -352,3 +352,19 @@ Description: 0 threaded mode disabled for this dev 1 threaded mode enabled for this dev =3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +What: /sys/class/net//disable_pause_on_panic +Date: Nov 2025 +KernelVersion: 6.20 +Contact: netdev@vger.kernel.org +Description: + Boolean value to control whether to disable pause frame + generation on panic. This is helpful in environments where + the link partner may incorrect respond to pause frames (e.g.: + improperly configured Ethernet switches) + + Possible values: + =3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + 0 threaded mode disabled for this dev + 1 threaded mode enabled for this dev + =3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index c2d8b4ec62eb..e014d0f2a5ac 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -956,6 +956,8 @@ struct kernel_ethtool_ts_info { * @get_pauseparam: Report pause parameters * @set_pauseparam: Set pause parameters. Returns a negative error code * or zero. + * @set_pauseparam_panic: Set pause parameters while in a panic context. T= his + * call is not allowed to sleep. Returns a negative error code or zero. * @self_test: Run specified self-tests * @get_strings: Return a set of strings that describe the requested objec= ts * @set_phys_id: Identify the physical devices, e.g. by flashing an LED @@ -1170,6 +1172,7 @@ struct ethtool_ops { struct ethtool_pauseparam*); int (*set_pauseparam)(struct net_device *, struct ethtool_pauseparam*); + void (*set_pauseparam_panic)(struct net_device *); void (*self_test)(struct net_device *, struct ethtool_test *, u64 *); void (*get_strings)(struct net_device *, u32 stringset, u8 *); int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state); diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index e808071dbb7d..2d4b07693745 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2441,6 +2441,7 @@ struct net_device { bool proto_down; bool irq_affinity_auto; bool rx_cpu_rmap_auto; + bool disable_pause_on_panic; =20 /* priv_flags_slow, ungrouped to save space */ unsigned long see_all_hwtstamp_requests:1; diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index ca878525ad7c..c01dc3e200d8 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -770,6 +770,39 @@ static ssize_t threaded_store(struct device *dev, } static DEVICE_ATTR_RW(threaded); =20 +static ssize_t disable_pause_on_panic_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct net_device *ndev =3D to_net_dev(dev); + ssize_t ret =3D -EINVAL; + + rcu_read_lock(); + if (dev_isalive(ndev)) + ret =3D sysfs_emit(buf, fmt_dec, READ_ONCE(ndev->disable_pause_on_panic)= ); + rcu_read_unlock(); + + return ret; +} + +static int modify_disable_pause_on_panic(struct net_device *dev, unsigned = long val) +{ + if (val !=3D 0 && val !=3D 1) + return -EINVAL; + + WRITE_ONCE(dev->disable_pause_on_panic, val); + + return 0; +} + +static ssize_t disable_pause_on_panic_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) +{ + return netdev_store(dev, attr, buf, len, modify_disable_pause_on_panic); +} +static DEVICE_ATTR_RW(disable_pause_on_panic); + static struct attribute *net_class_attrs[] __ro_after_init =3D { &dev_attr_netdev_group.attr, &dev_attr_type.attr, @@ -800,6 +833,7 @@ static struct attribute *net_class_attrs[] __ro_after_i= nit =3D { &dev_attr_carrier_up_count.attr, &dev_attr_carrier_down_count.attr, &dev_attr_threaded.attr, + &dev_attr_disable_pause_on_panic.attr, NULL, }; ATTRIBUTE_GROUPS(net_class); diff --git a/net/ethernet/Makefile b/net/ethernet/Makefile index e03eff94e0db..9b1f3ff8695a 100644 --- a/net/ethernet/Makefile +++ b/net/ethernet/Makefile @@ -3,4 +3,5 @@ # Makefile for the Linux Ethernet layer. # =20 -obj-y +=3D eth.o +obj-y +=3D eth.o \ + pause_panic.o diff --git a/net/ethernet/pause_panic.c b/net/ethernet/pause_panic.c new file mode 100644 index 000000000000..8ef61eb768a0 --- /dev/null +++ b/net/ethernet/pause_panic.c @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Ethernet pause disable on panic handler + * + * This module provides per-device control via sysfs to disable Ethernet f= low + * control (pause frames) on individual Ethernet devices when the kernel p= anics. + * Each device can be configured via /sys/class/net//disable_pause= _on_panic. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Disable pause/flow control on a single Ethernet device. + */ +static void disable_pause_on_device(struct net_device *dev) +{ + const struct ethtool_ops *ops; + + /* Only proceed if this device has the flag enabled */ + if (!READ_ONCE(dev->disable_pause_on_panic)) + return; + + ops =3D dev->ethtool_ops; + if (!ops || !ops->set_pauseparam_panic) + return; + + /* + * In panic context, we're in atomic context and cannot sleep. + */ + ops->set_pauseparam_panic(dev); +} + +/* + * Panic notifier to disable pause frames on all Ethernet devices. + * Called in atomic context during kernel panic. + */ +static int eth_pause_panic_handler(struct notifier_block *this, + unsigned long event, void *ptr) +{ + struct net_device *dev; + + /* + * Iterate over all network devices in the init namespace. + * In panic context, we cannot acquire locks that might sleep, + * so we use RCU iteration. + * Each device will check its own disable_pause_on_panic flag. + */ + rcu_read_lock(); + for_each_netdev_rcu(&init_net, dev) { + /* Reference count might not be available in panic */ + if (!dev) + continue; + + disable_pause_on_device(dev); + } + rcu_read_unlock(); + + return NOTIFY_DONE; +} + +static struct notifier_block eth_pause_panic_notifier =3D { + .notifier_call =3D eth_pause_panic_handler, + .priority =3D INT_MAX, /* Run as late as possible */ +}; + +static int __init eth_pause_panic_init(void) +{ + /* Register panic notifier */ + atomic_notifier_chain_register(&panic_notifier_list, + ð_pause_panic_notifier); + + return 0; +} +device_initcall(eth_pause_panic_init); --=20 2.34.1 From nobody Fri Dec 19 11:16:13 2025 Received: from relay.smtp-ext.broadcom.com (relay.smtp-ext.broadcom.com [192.19.144.205]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD3202C376B; Tue, 4 Nov 2025 22:14:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.19.144.205 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762294442; cv=none; b=A3peoPehMrGLUTPh6pS/2YjtGDpKOb6aQqzESrou70NH5S1QZRaNrLtp1z/JkR8Mhckrgd8l2lNP9puvBTtPCTSJBckbxmf291N7xrr0eFtQ1E1gyxSoAASTUKADM/ofFLrXP2SHzopaDdq9baqPhDV67esub6VzyGOQ0KkjrPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762294442; c=relaxed/simple; bh=nkdxGoHbtBgkqF4hvXzcmYUK6jPG9kz/+bIf/5XKspA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fCf/XbUJWVK7Pyz+oOV2gPrMRjL3FzKn/79okb11A/+ZCPxUFFkC0zTZRYXfrM2kfxGcfUiN6sLDmVqPx2WF5iBEPmgfYlegxrWrVCtlE2TX8ep3i3K+eC0R6qCh8pFxxofz6sYtA4lubWSw7/CyblL5AJbAYDWYaA9Y6Z+oKWA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=O3RA4WZN; arc=none smtp.client-ip=192.19.144.205 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="O3RA4WZN" Received: from mail-acc-it-01.broadcom.com (mail-acc-it-01.acc.broadcom.net [10.35.36.83]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id 52344C000C7F; Tue, 4 Nov 2025 14:13:54 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 52344C000C7F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1762294434; bh=nkdxGoHbtBgkqF4hvXzcmYUK6jPG9kz/+bIf/5XKspA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O3RA4WZNn0l/GpokJl4x55zNousas4IhQ6meRiHHjM1QpdXJ1XWBzfJqPb17geWR7 ETHLM7tl54RdcFM8yoVUw2YTJHn3AOrgVaF1VVqGlNxn8Eu1zQKyVof90AsNJhGx3V Nh/tOTQ7xiaO5I17tGvucCQAHpHaJ57uFdlMrlb0= Received: from stbirv-lnx-1.igp.broadcom.net (stbirv-lnx-1.igp.broadcom.net [10.67.48.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-acc-it-01.broadcom.com (Postfix) with ESMTPSA id 3CB094002F44; Tue, 4 Nov 2025 17:13:53 -0500 (EST) From: Florian Fainelli To: netdev@vger.kernel.org Cc: bcm-kernel-feedback-list@broadcom.com, Florian Fainelli , Doug Berger , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Stanislav Fomichev , Antoine Tenart , Kuniyuki Iwashima , Yajun Deng , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v2 2/2] net: bcmgenet: Add support for set_pauseparam_panic Date: Tue, 4 Nov 2025 14:13:48 -0800 Message-Id: <20251104221348.4163417-3-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251104221348.4163417-1-florian.fainelli@broadcom.com> References: <20251104221348.4163417-1-florian.fainelli@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Avoid making sleeping calls that would in not being able to complete the MMIO writes ignoring pause frame reception and generation at the Ethernet MAC controller level. Signed-off-by: Florian Fainelli --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 8 ++++++++ drivers/net/ethernet/broadcom/genet/bcmgenet.h | 1 + drivers/net/ethernet/broadcom/genet/bcmmii.c | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/e= thernet/broadcom/genet/bcmgenet.c index d99ef92feb82..323bf119c2af 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -966,6 +966,13 @@ static int bcmgenet_set_pauseparam(struct net_device *= dev, return 0; } =20 +static void bcmgenet_set_pauseparam_panic(struct net_device *dev) +{ + struct bcmgenet_priv *priv =3D netdev_priv(dev); + + bcmgenet_set_pause_panic(priv); +} + /* standard ethtool support functions. */ enum bcmgenet_stat_type { BCMGENET_STAT_RTNL =3D -1, @@ -1702,6 +1709,7 @@ static const struct ethtool_ops bcmgenet_ethtool_ops = =3D { .set_rxnfc =3D bcmgenet_set_rxnfc, .get_pauseparam =3D bcmgenet_get_pauseparam, .set_pauseparam =3D bcmgenet_set_pauseparam, + .set_pauseparam_panic =3D bcmgenet_set_pauseparam_panic, }; =20 /* Power down the unimac, based on mode. */ diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/e= thernet/broadcom/genet/bcmgenet.h index 5ec3979779ec..faf0d2406e9a 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h @@ -738,6 +738,7 @@ int bcmgenet_mii_config(struct net_device *dev, bool in= it); int bcmgenet_mii_probe(struct net_device *dev); void bcmgenet_mii_exit(struct net_device *dev); void bcmgenet_phy_pause_set(struct net_device *dev, bool rx, bool tx); +void bcmgenet_set_pause_panic(struct bcmgenet_priv *priv); void bcmgenet_phy_power_set(struct net_device *dev, bool enable); void bcmgenet_mii_setup(struct net_device *dev); =20 diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/eth= ernet/broadcom/genet/bcmmii.c index 38f854b94a79..a9a1d06032fa 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -147,6 +147,16 @@ void bcmgenet_phy_pause_set(struct net_device *dev, bo= ol rx, bool tx) mutex_unlock(&phydev->lock); } =20 +void bcmgenet_set_pause_panic(struct bcmgenet_priv *priv) +{ + u32 reg; + + /* Disable pause frame generation and reception */ + reg =3D bcmgenet_umac_readl(priv, UMAC_CMD); + reg |=3D CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE; + bcmgenet_umac_writel(priv, reg, UMAC_CMD); +} + void bcmgenet_phy_power_set(struct net_device *dev, bool enable) { struct bcmgenet_priv *priv =3D netdev_priv(dev); --=20 2.34.1