diff options
author | Jakub Kicinski <kuba@kernel.org> | 2021-05-19 10:18:25 -0700 |
---|---|---|
committer | Saeed Mahameed <saeedm@nvidia.com> | 2021-06-03 13:10:17 -0700 |
commit | 490dcecabbf93e705006af498fa6815251404a54 (patch) | |
tree | f29ba97ace44c3e34c7f0950f730c2232ce16a81 /net | |
parent | 270d47dc1fc4756a0158778084a236bc83c156d2 (diff) | |
download | lwn-490dcecabbf93e705006af498fa6815251404a54.tar.gz lwn-490dcecabbf93e705006af498fa6815251404a54.zip |
mlx5: count all link events
mlx5 devices were observed generating MLX5_PORT_CHANGE_SUBTYPE_ACTIVE
events without an intervening MLX5_PORT_CHANGE_SUBTYPE_DOWN. This
breaks link flap detection based on Linux carrier state transition
count as netif_carrier_on() does nothing if carrier is already on.
Make sure we count such events.
netif_carrier_event() increments the counters and fires the linkwatch
events. The latter is not necessary for the use case but seems like
the right thing to do.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/sched/sch_generic.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index fc8b56bcabf3..e9c0afc8becc 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -540,6 +540,24 @@ void netif_carrier_off(struct net_device *dev) } EXPORT_SYMBOL(netif_carrier_off); +/** + * netif_carrier_event - report carrier state event + * @dev: network device + * + * Device has detected a carrier event but the carrier state wasn't changed. + * Use in drivers when querying carrier state asynchronously, to avoid missing + * events (link flaps) if link recovers before it's queried. + */ +void netif_carrier_event(struct net_device *dev) +{ + if (dev->reg_state == NETREG_UNINITIALIZED) + return; + atomic_inc(&dev->carrier_up_count); + atomic_inc(&dev->carrier_down_count); + linkwatch_fire_event(dev); +} +EXPORT_SYMBOL_GPL(netif_carrier_event); + /* "NOOP" scheduler: the best scheduler, recommended for all interfaces under all circumstances. It is difficult to invent anything faster or cheaper. |