Thread (12 messages) flat view 12 messages, 3 authors, 2021-05-20

Re: [PATCH net-next] mlx5: count all link events

From: Jakub Kicinski <kuba@kernel.org>
Date: 2021-05-19 19:51:09

On Wed, 19 May 2021 14:34:34 -0500 Lijun Pan wrote:
Is it possible to integrate netif_carrier_event into netif_carrier_on? like,


void netif_carrier_on(struct net_device *dev)
{
	if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
		if (dev->reg_state == NETREG_UNINITIALIZED)
			return;
		atomic_inc(&dev->carrier_up_count);
		linkwatch_fire_event(dev);
		if (netif_running(dev))
			__netdev_watchdog_up(dev);
	} else {
		if (dev->reg_state == NETREG_UNINITIALIZED)
			return;
		atomic_inc(&dev->carrier_down_count);
		atomic_inc(&dev->carrier_up_count);
	}
}
EXPORT_SYMBOL(netif_carrier_on);
Ah, I meant to address that in the commit message, thanks for bringing
this up. I suspect drivers may depend on the current behavior of
netif_carrier_on()/off() being idempotent. We have no real reason for
removing that assumption.

I assumed netif_carrier_event() would be used specifically in places
driver is actually servicing a link event from the device, and
therefore is relatively certain that _something_ has happened.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help