Skip to content

Commit bee4544

Browse files
author
Dan Campbell
committed
net: add netdev_sw_irq_coalesce_default_on()
Bugzilla: https://bugzilla.redhat.com/2161921 commit d936070 Author: Heiner Kallweit <hkallweit1@gmail.com> Date: Wed Nov 30 23:28:26 2022 +0100 net: add netdev_sw_irq_coalesce_default_on() Add a helper for drivers wanting to set SW IRQ coalescing by default. The related sysfs attributes can be used to override the default values. Follow Jakub's suggestion and put this functionality into net core so that drivers wanting to use software interrupt coalescing per default don't have to open-code it. Note that this function needs to be called before the netdevice is registered. Suggested-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Dan Campbell <dacampbe@redhat.com>
1 parent b2d07e5 commit bee4544

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

include/linux/netdevice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct xdp_buff;
7777
void synchronize_net(void);
7878
void netdev_set_default_ethtool_ops(struct net_device *dev,
7979
const struct ethtool_ops *ops);
80+
void netdev_sw_irq_coalesce_default_on(struct net_device *dev);
8081

8182
/* Backlog congestion levels */
8283
#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */

net/core/dev.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10466,6 +10466,22 @@ void netdev_set_default_ethtool_ops(struct net_device *dev,
1046610466
}
1046710467
EXPORT_SYMBOL_GPL(netdev_set_default_ethtool_ops);
1046810468

10469+
/**
10470+
* netdev_sw_irq_coalesce_default_on() - enable SW IRQ coalescing by default
10471+
* @dev: netdev to enable the IRQ coalescing on
10472+
*
10473+
* Sets a conservative default for SW IRQ coalescing. Users can use
10474+
* sysfs attributes to override the default values.
10475+
*/
10476+
void netdev_sw_irq_coalesce_default_on(struct net_device *dev)
10477+
{
10478+
WARN_ON(dev->reg_state == NETREG_REGISTERED);
10479+
10480+
dev->gro_flush_timeout = 20000;
10481+
dev->napi_defer_hard_irqs = 1;
10482+
}
10483+
EXPORT_SYMBOL_GPL(netdev_sw_irq_coalesce_default_on);
10484+
1046910485
void netdev_freemem(struct net_device *dev)
1047010486
{
1047110487
char *addr = (char *)dev - dev->padded;

0 commit comments

Comments
 (0)