Skip to content

Commit 05d2a72

Browse files
author
Herton R. Krzesinski
committed
Merge: CNB: net: add netdev_sw_irq_coalesce_default_on()
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1970 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> Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com> Approved-by: Ivan Vecera <ivecera@redhat.com> Approved-by: Michal Schmidt <mschmidt@redhat.com> Approved-by: Petr Oros <poros@redhat.com> Approved-by: Andrea Claudi <aclaudi@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents b8e1426 + bee4544 commit 05d2a72

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
@@ -10470,6 +10470,22 @@ void netdev_set_default_ethtool_ops(struct net_device *dev,
1047010470
}
1047110471
EXPORT_SYMBOL_GPL(netdev_set_default_ethtool_ops);
1047210472

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

0 commit comments

Comments
 (0)