Allow disabling pause frames on panic
Florian Fainelli
maintainerv3 cover Allow disabling pause frames on panic
This patch set allows disabling pause frame generation upon encountering a kernel panic. This has proven to be helpful in lab environments where devices are still being worked on, will panic for various reasons, and will occasionally take down the entire Ethernet switch they are attached to.
Changes in v3:
- early feedback as to whether we can disable pause on panic
- correct documentation
- simplify network device list traversal
- only need to disable pause frame generation (TX)
Changes in v2:
- introduce a dedicated callback that runs in panic context
Florian Fainelli (2):
net: ethernet: Allow disabling pause on panic
net: bcmgenet: Add support for set_pauseparam_panic
Documentation/ABI/testing/sysfs-class-net | 16 ++++ .../net/ethernet/broadcom/genet/bcmgenet.c | 8 ++ .../net/ethernet/broadcom/genet/bcmgenet.h | 1 + drivers/net/ethernet/broadcom/genet/bcmmii.c | 10 +++ include/linux/ethtool.h | 3 + include/linux/netdevice.h | 1 + net/core/net-sysfs.c | 39 +++++++++ net/ethernet/Makefile | 3 +- net/ethernet/pause_panic.c | 79 +++++++++++++++++++ 9 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 net/ethernet/pause_panic.c
Signature · 1 line
2.34.1
Florian Fainelli
maintainerPATCH v3 1/2 net: ethernet: Allow disabling pause on panic
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/<device>/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.
--- Documentation/ABI/testing/sysfs-class-net | 16 +++++ include/linux/ethtool.h | 3 + include/linux/netdevice.h | 1 + net/core/net-sysfs.c | 39 +++++++++++ net/ethernet/Makefile | 3 +- net/ethernet/pause_panic.c | 79 +++++++++++++++++++++++ 6 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 net/ethernet/pause_panic.c
Documentation/ABI/testing/sysfs-class-net +16 -0
@@ -352,3 +352,19 @@ Description: 0 threaded mode disabled for this dev 1 threaded mode enabled for this dev == ================================== + +What: /sys/class/net/<iface>/disable_pause_on_panic +Date: Nov 2025 +KernelVersion: 6.20 +Contact: [email protected] +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: + == ===================================================== + 0 do not disable pause frame generation on kernel panic + 1 disable pause frame generation on kernel panic + == =====================================================
include/linux/ethtool.h +3 -0
@@ -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. This +* 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 objects * @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 );
include/linux/netdevice.h +1 -0
@@ -2441,6 +2441,7 @@ struct net_device {bool proto_down;bool irq_affinity_auto;bool rx_cpu_rmap_auto; +bool disable_pause_on_panic;/* priv_flags_slow, ungrouped to save space */ unsigned long see_all_hwtstamp_requests:1;
net/core/net-sysfs.c +39 -0
@@ -770,6 +770,44 @@ static ssize_t threaded_store(struct device *dev, }static DEVICE_ATTR_RW (threaded); +static ssize_t disable_pause_on_panic_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct net_device *ndev =to_net_dev (dev); +ssize_t ret = -EINVAL ; + +rcu_read_lock (); +if (dev_isalive (ndev)) + ret =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) +{ +const struct ethtool_ops *ops = dev->ethtool_ops; + +if (!ops || !ops->set_pauseparam_panic) +return -EOPNOTSUPP ; + +if (val !=0 && val !=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 = { &dev_attr_netdev_group.attr, &dev_attr_type.attr,
@@ -800,6 +838,7 @@ static struct attribute *net_class_attrs[] __ro_after_init = { &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);
net/ethernet/Makefile +2 -1
@@ -3,4 +3,5 @@ # Makefile for the Linux Ethernet layer. # -obj-y += eth.o +obj-y += eth.o \ + pause_panic.o
net/ethernet/pause_panic.c new file +79 -0
79 lines not on this page · raw message
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerRe: [PATCH net-next v3 1/2] net: ethernet: Allow disabling pause on panic
Quoted 7 lines · On Thu, 6 Nov 2025 16:25:09 -0800 Florian Fainelli wrote:
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.
Quoted 7 lines
To accomodate for such situation introduce a /sys/class/net/<device>/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_panicto specifically deal with that atomic context.
Some basic review comments below (no promises if addressing those will make me for one feel any warmer towards the concept).
Quoted 6 lines
Documentation/ABI/testing/sysfs-class-net | 16 +++++ include/linux/ethtool.h | 3 + include/linux/netdevice.h | 1 + net/core/net-sysfs.c | 39 +++++++++++ net/ethernet/Makefile | 3 +- net/ethernet/pause_panic.c | 79 +++++++++++++++++++++++
panic.c or shutdown.c is probably a slightly better name, more likely we'd add more code in that.
Quoted 17 lines
6 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 net/ethernet/pause_panic.cDocumentation/ABI/testing/sysfs-class-net +6
-0@@ -352,3 +352,19 @@ Description: 0 threaded mode disabled for this dev 1 threaded mode enabled for this dev == ================================== + +What: /sys/class/net/<iface>/disable_pause_on_panic +Date: Nov 2025 +KernelVersion: 6.20 +Contact: [email protected] +Description:
Documentation/ABI/testing/sysfs-class-net Description: · line 370
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-net +10
-0+ 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: + == ===================================================== + 0 do not disable pause frame generation on kernel panic + 1 disable pause frame generation on kernel panic + == =====================================================
please no sysfs for something as niche as this feature
include/linux/netdevice.h struct net_device { · line 2444
Quoted 9 lines
include/linux/netdevice.h +1
-0@@ -2441,6 +2441,7 @@ struct net_device {bool proto_down;bool irq_affinity_auto;bool rx_cpu_rmap_auto; +bool disable_pause_on_panic;
Warning: include/linux/netdevice.h:2567 struct member 'disable_pause_on_panic' not described in 'net_device'
include/linux/netdevice.h struct net_device {
Quoted 11 lines
include/linux/netdevice.h +8
-0/* priv_flags_slow, ungrouped to save space */ unsigned long see_all_hwtstamp_requests:1; +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/panic_notifier.h> +#include <linux/netdevice.h> +#include <linux/ethtool.h> +#include <linux/notifier.h> +#include <linux/if_ether.h> +#include <net/net_namespace.h>
Alphabetical sort, please.
Quoted 8 lines
include/linux/netdevice.h +8
-0+/* +* 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 */
include/linux/netdevice.h
Quoted 10 lines
include/linux/netdevice.h +10
-0+if (!READ_ONCE (dev->disable_pause_on_panic)) +return ; + + ops = dev->ethtool_ops; +if (!ops || !ops->set_pauseparam_panic) +return ; + +/* +* In panic context, we're in atomic context and cannot sleep. +*/
single-line comment would do?
Quoted 2 lines
include/linux/netdevice.h +2
-0+ ops->set_pauseparam_panic (dev); +}
Signature · 1 line
pw-bot: cr
Florian Fainelli
maintainerRe: [PATCH net-next v3 1/2] net: ethernet: Allow disabling pause on panic
Quoted 50 lines · Jakub Kicinski
Quoted 7 lines · On Thu, 6 Nov 2025 16:25:09 -0800 Florian Fainelli wrote:
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.
Quoted 7 lines
To accomodate for such situation introduce a /sys/class/net/<device>/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_panicto specifically deal with that atomic context.Some basic review comments below (no promises if addressing those will make me for one feel any warmer towards the concept).
Quoted 6 lines
Documentation/ABI/testing/sysfs-class-net | 16 +++++ include/linux/ethtool.h | 3 + include/linux/netdevice.h | 1 + net/core/net-sysfs.c | 39 +++++++++++ net/ethernet/Makefile | 3 +- net/ethernet/pause_panic.c | 79 +++++++++++++++++++++++
panic.corshutdown.cis probably a slightly better name, more likely we'd add more code in that.Quoted 21 lines
6 files changed, 140 insertions(+), 1 deletion(-)create mode 100644
net/ethernet/pause_panic.cDocumentation/ABI/testing/sysfs-class-net +10
-0@@ -352,3 +352,19 @@ Description: 0 threaded mode disabled for this dev 1 threaded mode enabled for this dev == ================================== + +What: /sys/class/net/<iface>/disable_pause_on_panic +Date: Nov 2025 +KernelVersion: 6.20 +Contact: [email protected] +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)
Quoted 8 lines
Documentation/ABI/testing/sysfs-class-net Description: · line 370
Quoted 6 lines
Documentation/ABI/testing/sysfs-class-net +6
-0+ + Possible values: + == ===================================================== + 0 do not disable pause frame generation on kernel panic + 1 disable pause frame generation on kernel panic + == =====================================================please no sysfs for something as niche as this feature
Would you prefer ethtool in that case?
Signature · 1 line
Florian
Jakub Kicinski
maintainerRe: [PATCH net-next v3 1/2] net: ethernet: Allow disabling pause on panic
Quoted 3 lines · On Wed, 12 Nov 2025 14:53:51 -0800 Florian Fainelli wrote:
Quoted 1 line
please no sysfs for something as niche as this feature
Would you prefer ethtool in that case?
Yes, no strong preference where exactly but somewhere within ethtool would be better.
Florian Fainelli
maintainerPATCH v3 2/2 net: bcmgenet: Add support for set_pauseparam_panic
In reply to Florian FainelliAvoid 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.
--- 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(+)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +8 -0
@@ -966,6 +966,13 @@ static int bcmgenet_set_pauseparam(struct net_device *dev,return 0 ; } +static void bcmgenet_set_pauseparam_panic (struct net_device *dev) +{ +struct bcmgenet_priv *priv =netdev_priv (dev); + +bcmgenet_set_pause_panic (priv); +} +/* standard ethtool support functions. */ enum bcmgenet_stat_type {BCMGENET_STAT_RTNL =-1 ,
@@ -1702,6 +1709,7 @@ static const struct ethtool_ops bcmgenet_ethtool_ops = { .set_rxnfc = bcmgenet_set_rxnfc, .get_pauseparam = bcmgenet_get_pauseparam, .set_pauseparam = bcmgenet_set_pauseparam, + .set_pauseparam_panic = bcmgenet_set_pauseparam_panic, };/* Power down the unimac, based on mode. */
drivers/net/ethernet/broadcom/genet/bcmgenet.h +1 -0
@@ -738,6 +738,7 @@ int bcmgenet_mii_config(struct net_device *dev, bool init);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);
drivers/net/ethernet/broadcom/genet/bcmmii.c +10 -0
@@ -147,6 +147,16 @@ void bcmgenet_phy_pause_set(struct net_device *dev, bool rx, bool tx)mutex_unlock (&phydev->lock); } +void bcmgenet_set_pause_panic (struct bcmgenet_priv *priv) +{ +u32 reg; + +/* Disable pause frame generation */ + reg =bcmgenet_umac_readl (priv,UMAC_CMD ); + reg |=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 =netdev_priv (dev);
Signature · 1 line
2.34.1